:root {
  --bg: #12141c;
  --surface: #171a21;
  --surface2: #1f2330;
  --border: #2a2f3d;
  --text: #f2f3f7;
  --muted: #9aa0b0;
  --accent: #6c5ce7;
  --accent2: #8b7cf6;
  --danger: #ff6b6b;
  --idea: #9aa0b0;
  --drafted: #f5b942;
  --scheduled: #4dabf7;
  --posted: #51cf66;

  --glass-bg: rgba(30, 32, 44, 0.5);
  --glass-bg-strong: rgba(30, 32, 44, 0.68);
  --glass-border: rgba(255, 255, 255, 0.12);
  --glass-highlight: rgba(255, 255, 255, 0.06);
  --glass-blur: 18px;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f5f6fa;
    --surface: #ffffff;
    --surface2: #f0f1f7;
    --border: #e3e5ee;
    --text: #191b22;
    --muted: #6b7080;

    --glass-bg: rgba(255, 255, 255, 0.55);
    --glass-bg-strong: rgba(255, 255, 255, 0.72);
    --glass-border: rgba(255, 255, 255, 0.6);
    --glass-highlight: rgba(255, 255, 255, 0.4);
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  background-image:
    radial-gradient(circle at 15% 8%, rgba(108, 92, 231, 0.55), transparent 42%),
    radial-gradient(circle at 88% 18%, rgba(77, 171, 247, 0.45), transparent 38%),
    radial-gradient(circle at 20% 78%, rgba(81, 207, 102, 0.35), transparent 40%),
    radial-gradient(circle at 92% 85%, rgba(245, 185, 66, 0.35), transparent 42%);
  background-attachment: fixed;
  background-repeat: no-repeat;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

.glass {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(var(--glass-blur)) saturate(160%);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(160%);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.18), inset 0 1px 0 var(--glass-highlight);
}
.glass-strong {
  background: var(--glass-bg-strong);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(24px) saturate(160%);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.22), inset 0 1px 0 var(--glass-highlight);
}

#app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-bottom: 90px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: max(16px, env(safe-area-inset-top)) 20px 12px;
  position: sticky;
  top: 0;
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur)) saturate(160%);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(160%);
  border-bottom: 1px solid var(--glass-border);
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; }
.brand-icon { width: 28px; height: 28px; border-radius: 8px; }
.icon-btn {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(var(--glass-blur)) saturate(160%);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(160%);
  box-shadow: inset 0 1px 0 var(--glass-highlight);
  color: var(--text);
  width: 40px; height: 40px;
  border-radius: 12px;
  font-size: 18px;
  display: flex; align-items: center; justify-content: center;
}
.icon-btn.on { background: rgba(108, 92, 231, 0.55); border-color: var(--accent); }

.biz-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 20px 14px;
  scrollbar-width: none;
}
.biz-tabs::-webkit-scrollbar { display: none; }
.biz-tab {
  flex: 0 0 auto;
  padding: 6px 16px 6px 6px;
  border-radius: 20px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(var(--glass-blur)) saturate(160%);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(160%);
  box-shadow: inset 0 1px 0 var(--glass-highlight);
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 8px;
}
.biz-tab.manage { padding: 9px 16px; }
.biz-tab.active { background: rgba(108, 92, 231, 0.55); border-color: var(--accent); color: #fff; }
.biz-tab.manage { color: var(--muted); }
.biz-avatar {
  width: 26px; height: 26px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--surface2);
  flex: 0 0 auto;
}
.biz-avatar.placeholder {
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: var(--text);
}

.content { padding: 0 20px; flex: 1; }

.hey-banner {
  background: linear-gradient(135deg, rgba(108, 92, 231, 0.55), rgba(139, 124, 246, 0.4));
  border: 1px solid rgba(255, 255, 255, 0.25);
  backdrop-filter: blur(var(--glass-blur)) saturate(160%);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(160%);
  box-shadow: 0 8px 32px rgba(108, 92, 231, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.25);
  border-radius: 16px;
  padding: 14px 16px;
  margin-bottom: 16px;
  color: #fff;
}
.hey-title { font-weight: 700; font-size: 14px; margin-bottom: 4px; }
.hey-body { font-size: 13.5px; line-height: 1.5; opacity: 0.95; }
.hey-body strong { font-weight: 700; }

.view-toggle { display: flex; gap: 8px; margin-bottom: 16px; }
.view-btn {
  flex: 1;
  padding: 10px;
  border-radius: 12px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(var(--glass-blur)) saturate(160%);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(160%);
  box-shadow: inset 0 1px 0 var(--glass-highlight);
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}
.view-btn.active { background: rgba(139, 124, 246, 0.3); color: var(--text); border-color: var(--accent2); }

.icon-btn.small { width: 34px; height: 34px; font-size: 18px; }
.cal-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.cal-label { font-weight: 700; font-size: 16px; }
.cal-legend { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.cal-legend-item { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); }
.cal-legend-dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; }

.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  font-weight: 700;
  margin-bottom: 6px;
}
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 5px;
}
.cal-day {
  aspect-ratio: 1;
  border-radius: 10px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(var(--glass-blur)) saturate(160%);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(160%);
  box-shadow: inset 0 1px 0 var(--glass-highlight);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 5px 2px;
  font-size: 12px;
  color: var(--text);
  position: relative;
  min-width: 0;
}
.cal-day.empty { background: transparent; border-color: transparent; }
.cal-day.today { border-color: var(--accent); border-width: 2px; }
.cal-day.tomorrow { box-shadow: 0 0 0 2px var(--accent2) inset; }
.cal-day .dnum { font-weight: 600; }
.cal-day .ddots { display: flex; gap: 2px; margin-top: 3px; flex-wrap: wrap; justify-content: center; max-width: 100%; }
.cal-day .ddot { width: 6px; height: 6px; border-radius: 50%; }

.day-item-biz { font-size: 12px; font-weight: 700; margin-bottom: 2px; }

.stats-row { display: flex; gap: 10px; margin-bottom: 16px; }
.stat-card {
  flex: 1;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(var(--glass-blur)) saturate(160%);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(160%);
  box-shadow: inset 0 1px 0 var(--glass-highlight);
  border-radius: 14px;
  padding: 12px 14px;
}
.stat-card .num { font-size: 20px; font-weight: 700; }
.stat-card .label { font-size: 12px; color: var(--muted); margin-top: 2px; }

.filter-row { display: flex; gap: 8px; margin-bottom: 14px; overflow-x: auto; }
.chip {
  padding: 7px 14px;
  border-radius: 16px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(var(--glass-blur)) saturate(160%);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(160%);
  box-shadow: inset 0 1px 0 var(--glass-highlight);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
.chip.active { background: rgba(139, 124, 246, 0.3); color: var(--text); border-color: var(--accent2); }

.task-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.task-item {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(var(--glass-blur)) saturate(160%);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(160%);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12), inset 0 1px 0 var(--glass-highlight);
  border-radius: 16px;
  padding: 14px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.status-dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 6px; flex: 0 0 auto; }
.status-dot.idea { background: var(--idea); }
.status-dot.drafted { background: var(--drafted); }
.status-dot.scheduled { background: var(--scheduled); }
.status-dot.posted { background: var(--posted); }

.task-main { flex: 1; min-width: 0; }
.task-title { font-weight: 600; font-size: 15px; margin-bottom: 3px; }
.task-meta { font-size: 12.5px; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; }
.task-meta .overdue { color: var(--danger); font-weight: 600; }
.task-notes { font-size: 13px; color: var(--muted); margin-top: 6px; }

.empty-state { text-align: center; color: var(--muted); margin-top: 60px; font-size: 14px; }

.fab {
  position: fixed;
  bottom: max(24px, env(safe-area-inset-bottom));
  right: max(24px, calc((100vw - 560px) / 2 + 24px));
  width: 56px; height: 56px;
  border-radius: 50%;
  background: rgba(108, 92, 231, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.3);
  backdrop-filter: blur(var(--glass-blur)) saturate(160%);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(160%);
  color: #fff;
  font-size: 28px;
  box-shadow: 0 8px 24px rgba(108, 92, 231, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.35);
  z-index: 20;
}

.sheet-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.35);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex; align-items: flex-end;
  z-index: 50;
}
.sheet-backdrop[hidden] { display: none; }
.sheet {
  background: var(--glass-bg-strong);
  border: 1px solid var(--glass-border);
  border-bottom: none;
  backdrop-filter: blur(30px) saturate(160%);
  -webkit-backdrop-filter: blur(30px) saturate(160%);
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.25), inset 0 1px 0 var(--glass-highlight);
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  border-radius: 20px 20px 0 0;
  padding: 10px 20px max(20px, env(safe-area-inset-bottom));
  max-height: 88vh;
  overflow-y: auto;
}
.sheet-handle { width: 40px; height: 4px; background: var(--border); border-radius: 2px; margin: 6px auto 14px; }
.sheet h2 { margin: 0 0 16px; font-size: 18px; }

form label { display: block; font-size: 13px; color: var(--muted); font-weight: 600; margin-bottom: 12px; }
input, select, textarea {
  width: 100%;
  margin-top: 6px;
  padding: 11px 12px;
  border-radius: 10px;
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
}
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.check-row { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text); }
.check-row input { width: auto; margin: 0; }

.sheet-actions { display: flex; gap: 10px; margin-top: 8px; }
.btn { flex: 1; padding: 13px; border-radius: 12px; border: none; font-size: 15px; font-weight: 600; }
.btn.primary {
  background: rgba(108, 92, 231, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.3);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3);
  color: #fff;
}
.btn.ghost {
  background: var(--glass-bg);
  color: var(--text);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.btn.danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); flex: 0 0 auto; padding: 13px 16px; }

.biz-manage-list { list-style: none; padding: 0; margin: 0 0 16px; display: flex; flex-direction: column; gap: 8px; }
.biz-manage-item {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--glass-bg); border: 1px solid var(--glass-border);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: inset 0 1px 0 var(--glass-highlight);
  border-radius: 12px; padding: 10px 14px; font-size: 14px; font-weight: 600;
}
.biz-manage-item button { background: none; border: none; color: var(--danger); font-size: 13px; font-weight: 600; }
.biz-manage-item .left { display: flex; align-items: center; gap: 10px; }
.biz-manage-item .biz-avatar { width: 36px; height: 36px; cursor: pointer; }
.hint { font-size: 13px; color: var(--muted); margin: -8px 0 14px; }
.optional { font-weight: 400; text-transform: none; opacity: 0.7; }
.category-chip { display: flex; align-items: center; gap: 6px; }
