/* ── Design Tokens ─────────────────────────────────────── */
:root {
  /* Telegram theme */
  --bg:        var(--tg-theme-bg-color,           #f0f2f5);
  --surface:   var(--tg-theme-secondary-bg-color, #ffffff);
  --text:      var(--tg-theme-text-color,         #0f172a);
  --muted:     var(--tg-theme-hint-color,         #64748b);
  --accent:    var(--tg-theme-button-color,       #3b82f6);
  --accent-fg: var(--tg-theme-button-text-color,  #ffffff);

  /* Extended palette */
  --border:    rgba(100,116,139,.12);
  --border-md: rgba(100,116,139,.2);
  --danger:    #ef4444;
  --success:   #22c55e;
  --warning:   #f59e0b;

  /* Icon */
  --icon:       var(--tg-theme-hint-color, #64748b);
  --icon-active: var(--tg-theme-button-color, #3b82f6);

  /* Radius scale */
  --r-sm:   8px;
  --r-md:   12px;
  --r-lg:   16px;
  --r-xl:   22px;
  --r-full: 99px;

  /* Shadow system */
  --shadow-sm: 0 1px 2px rgba(0,0,0,.04), 0 2px 6px rgba(0,0,0,.04);
  --shadow-md: 0 2px 8px rgba(0,0,0,.07), 0 8px 20px rgba(0,0,0,.05);
  --shadow-lg: 0 8px 24px rgba(0,0,0,.15);

  /* Layout */
  --hh: 54px;
  --sh: 38px;
  --fh: 38px;
  --bh: 74px;

  /* Aliases for missing vars used throughout */
  --hint:         var(--muted);
  --card:         var(--surface);
  --bg-secondary: #f0f2f5;
  --overdue:      var(--danger);
  --accent-rgb:   59, 130, 246;

  /* Spacing scale */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 12px;
  --space-lg: 16px;
  --space-xl: 24px;
  --space-2xl: 32px;

  /* Typography scale */
  --text-xs:   10px;
  --text-sm:   12px;
  --text-base: 14px;
  --text-md:   15px;
  --text-lg:   17px;
  --text-xl:   20px;
  --text-2xl:  24px;
  --fw-normal:    500;
  --fw-medium:    600;
  --fw-bold:      700;
  --fw-extrabold: 800;
}

/* ── Force Light Theme ────────────────────────────────── */
[data-theme="light"] {
  --bg:        #f0f2f5;
  --surface:   #ffffff;
  --text:      #0f172a;
  --muted:     #64748b;
  --accent:    #3b82f6;
  --accent-fg: #ffffff;
  --border:    rgba(100,116,139,.12);
  --border-md: rgba(100,116,139,.2);
  --icon:      #64748b;
  --icon-active: #3b82f6;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.04), 0 2px 6px rgba(0,0,0,.04);
  --shadow-md: 0 2px 8px rgba(0,0,0,.07), 0 8px 20px rgba(0,0,0,.05);
  --shadow-lg: 0 8px 24px rgba(0,0,0,.15);
  color-scheme: light;
}

/* ── Dark Theme ───────────────────────────────────────── */
[data-theme="dark"] {
  --bg:        #0f1117;
  --surface:   #1a1d27;
  --text:      #f1f5f9;
  --muted:     #8892a4;
  --accent:    #60a5fa;
  --accent-fg: #ffffff;
  --border:    rgba(255,255,255,.08);
  --border-md: rgba(255,255,255,.14);
  --icon:      #8892a4;
  --icon-active: #60a5fa;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.3),  0 2px 6px rgba(0,0,0,.2);
  --shadow-md: 0 2px 8px rgba(0,0,0,.4),  0 8px 20px rgba(0,0,0,.3);
  --shadow-lg: 0 8px 24px rgba(0,0,0,.6);
  color-scheme: dark;
  --bg-secondary: #161820;
  --card:         #1e2130;
  --accent-rgb:   96, 165, 250;
}

/* ── Reset ────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; }
body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}
button { font: inherit; cursor: pointer; border: none; background: none;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
a { color: inherit; }
svg { display: block; flex-shrink: 0; }

/* ── App shell ────────────────────────────────────────── */
.app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}
@supports not (height: 100dvh) {
  .app { height: calc(var(--tg-viewport-stable-height, 100vh) * 1px); }
}

/* ── Header ──────────────────────────────────────────── */
.header {
  flex-shrink: 0;
  height: calc(var(--hh) + env(safe-area-inset-top, 0px) + var(--tg-content-safe-area-inset-top, 0px));
  padding-top: calc(env(safe-area-inset-top, 0px) + var(--tg-content-safe-area-inset-top, 0px));
  display: flex;
  align-items: center;
  gap: 2px;
  padding-left: 4px;
  padding-right: 4px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  z-index: 10;
}

.hd-center {
  flex: 1;
  text-align: center;
  min-width: 0;
  overflow: hidden;
}

.hd-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hd-sub {
  font-size: 11px;
  color: var(--muted);
  margin-top: 1px;
}

.hd-right {
  display: flex;
  align-items: center;
  gap: 2px;
}

.hd-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--r-md);
  display: grid;
  place-items: center;
  color: var(--icon);
  flex-shrink: 0;
  transition: background .15s, color .15s, transform .1s cubic-bezier(.34,1.56,.64,1);
}
.hd-btn:active { background: var(--border); color: var(--text); transform: scale(.84); }

/* ── Sync dot ─────────────────────────────────────────── */
.sync-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--muted);
  opacity: .3;
  transition: background .3s, opacity .3s;
  flex-shrink: 0;
  margin-right: 2px;
}
.sync-dot.ok          { background: var(--success); opacity: 1; }
.sync-dot.error       { background: var(--danger);  opacity: 1; }
.sync-dot.disconnected{ background: var(--muted);   opacity: .45; }
.sync-dot.syncing     { background: var(--accent);  opacity: 1; animation: dot-pulse 1s ease infinite; }

@keyframes dot-pulse {
  0%,100% { transform: scale(1); }
  50%      { transform: scale(1.55); }
}

/* ── Search bar ──────────────────────────────────────── */
/* ── Unified search + filter panel ───────────────────── */
.search-filter-panel {
  flex-shrink: 0;
  background: var(--surface);
  overflow: hidden;
  max-height: 0;
  border-bottom: 1px solid transparent;
  transition: max-height .28s cubic-bezier(.4,0,.2,1), border-color .22s;
}
.search-filter-panel.search-open {
  max-height: 200px;
  border-bottom-color: var(--border);
}
.search-filter-panel.is-stats { max-height: 0 !important; border-bottom-color: transparent !important; transition: none !important; }

.search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
}

.search-icon {
  flex-shrink: 0;
  color: var(--muted);
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
}

.search-input {
  flex: 1;
  padding: 7px 10px;
  border-radius: var(--r-md);
  border: 1.5px solid transparent;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  outline: none;
  -webkit-appearance: none;
  transition: border-color .15s;
}
.search-input:focus { border-color: var(--accent); }
.search-input:focus + .search-clear,
.search-input:not(:placeholder-shown) ~ .search-clear { display: grid !important; }

.search-clear {
  color: var(--muted);
  padding: 6px;
  border-radius: var(--r-sm);
  flex-shrink: 0;
  display: none;
  place-items: center;
  transition: background .15s;
}
.search-clear[hidden] { display: none !important; }
.search-clear:active { background: var(--border); }

/* ── Stats bar ───────────────────────────────────────── */
.stats-bar {
  flex-shrink: 0;
  height: var(--sh);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}
.stats-bar::-webkit-scrollbar { display: none; }
#stats-bar { transition: opacity .22s ease, height .25s cubic-bezier(.4,0,.2,1), border-color .25s; }
#stats-bar.is-empty { opacity: 0; height: 0 !important; min-height: 0; border-color: transparent; padding: 0; pointer-events: none; overflow: hidden; }

.stat {
  display: flex; align-items: center; gap: 5px;
  padding: 3px 10px;
  border-radius: var(--r-full);
  border: 1px solid var(--border);
  background: var(--bg);
  font-size: 12px;
  white-space: nowrap;
  flex-shrink: 0;
}
.stat b { font-size: 13px; font-weight: 700; }
.stat span { color: var(--muted); }
.stat.is-zero { display: none; }

.s-done b   { color: var(--success); }
.s-active b { color: var(--accent); }
.s-overdue b{ color: var(--danger); }

/* ── Filter bar ──────────────────────────────────────── */
.filter-bar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px 7px;
  overflow-x: auto;
  scrollbar-width: none;
}
.filter-bar::-webkit-scrollbar { display: none; }

/* search button: accent when filter is active */
.hd-btn.filter-active { color: var(--accent); }

.fc {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 12px;
  border-radius: var(--r-full);
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--border-md);
  background: var(--bg);
  color: var(--text);
  transition: background .15s, border-color .15s, color .15s;
  white-space: nowrap;
}
.fc.active {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: var(--accent);
}

/* ── Content ─────────────────────────────────────────── */
.content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  padding-bottom: calc(var(--bh) + env(safe-area-inset-bottom, 0px) + 26px);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity .2s ease, transform .22s cubic-bezier(.34,1.2,.64,1);
}
.content--visible { opacity: 1; transform: none; }

/* ── Pull-to-refresh ──────────────────────────────────── */
.ptr-indicator {
  overflow: hidden;
  height: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 6px;
  transition: height .2s ease;
}
.ptr-spinner {
  width: 22px;
  height: 22px;
  border: 2.5px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  opacity: 0;
  transition: opacity .15s, transform .3s;
  transform: scale(.6);
}
.ptr-visible .ptr-spinner {
  opacity: 1;
  transform: scale(1);
}
.ptr-triggered .ptr-spinner {
  animation: ptr-spin .7s linear infinite;
  border-top-color: var(--accent);
}
@keyframes ptr-spin { to { transform: rotate(360deg); } }

.today-exec-card {
  width: calc(100% - 24px);
  margin: 12px auto 0;
  padding: 16px;
  border-radius: calc(var(--r-lg) + 2px);
  border: 1px solid color-mix(in srgb, var(--today-exec, var(--accent)) 22%, transparent);
  background:
    radial-gradient(circle at top right, color-mix(in srgb, var(--today-exec, var(--accent)) 16%, transparent), transparent 34%),
    var(--surface);
  box-shadow: var(--shadow-sm);
}

.today-exec-kicker {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--today-exec, var(--accent));
  margin-bottom: 6px;
}

.today-exec-title {
  font-size: 18px;
  font-weight: 800;
  line-height: 1.2;
}

.today-exec-sub {
  margin-top: 8px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--muted);
}

.today-focus-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  padding: 7px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  color: var(--today-exec, var(--accent));
  background: color-mix(in srgb, var(--today-exec, var(--accent)) 12%, var(--surface));
}

.today-exec-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.today-exec-metric {
  padding: 10px;
  border-radius: 14px;
  background: var(--bg);
  border: 1px solid var(--border);
}

.today-exec-metric strong {
  display: block;
  font-size: 18px;
  line-height: 1;
  margin-bottom: 4px;
}

.today-exec-metric span {
  font-size: 11px;
  color: var(--muted);
}

.today-exec-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.today-exec-btn {
  min-height: 42px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--border-md);
  background: var(--bg);
  font-weight: 700;
  color: var(--text);
}

.today-exec-btn--primary {
  background: var(--today-exec, var(--accent));
  border-color: var(--today-exec, var(--accent));
  color: #fff;
}

.today-exec-btn--wide {
  grid-column: 1 / -1;
}

.voice-hero {
  display: flex;
  align-items: center;
  gap: 8px;
  width: calc(100% - 24px);
  margin: 8px 12px 4px;
  padding: 8px 12px;
  border-radius: var(--r-md);
  border: 1px solid rgba(var(--accent-rgb), .18);
  background: rgba(var(--accent-rgb), .06);
  cursor: pointer;
  text-align: left;
}
.voice-hero {
  animation: voice-hero-pulse 3s ease-in-out infinite;
}
@keyframes voice-hero-pulse {
  0%, 100% { border-color: rgba(var(--accent-rgb), .15); }
  50%       { border-color: rgba(var(--accent-rgb), .38); }
}
.voice-hero:active { opacity: .75; transform: scale(.98); }

.voice-hero-icon {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--accent);
  background: rgba(var(--accent-rgb), .12);
}

.voice-hero-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
}

/* ── Bottom navigation — iOS floating tab bar ─────────────── */
.bottom-bar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(env(safe-area-inset-bottom, 0px) + 12px);
  width: min(calc(100% - 48px), 340px);
  height: var(--bh);
  z-index: 40;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  align-items: center;
  border-radius: 32px;
  background: rgba(255,255,255,.4);
  backdrop-filter: blur(40px) saturate(180%);
  -webkit-backdrop-filter: blur(40px) saturate(180%);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.45),
    0 8px 40px rgba(0,0,0,.14),
    0 2px 8px rgba(0,0,0,.07);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
/* Hairline highlight along the top of the pill — adds Apple-grade definition */
.bottom-bar::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg,
    transparent, rgba(255,255,255,.5) 20%, rgba(255,255,255,.5) 80%, transparent);
  pointer-events: none;
  border-radius: inherit;
  z-index: 2;
}
[data-theme="dark"] .bottom-bar {
  background: rgba(28,28,30,.4);
  backdrop-filter: blur(40px) saturate(160%);
  -webkit-backdrop-filter: blur(40px) saturate(160%);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.06),
    0 8px 40px rgba(0,0,0,.55),
    0 2px 8px rgba(0,0,0,.28);
}
[data-theme="dark"] .bottom-bar::before {
  background: linear-gradient(90deg,
    transparent, rgba(255,255,255,.08) 20%, rgba(255,255,255,.08) 80%, transparent);
}

/* Sliding capsule indicator
   Pill container fills full tab cell width (for animation math),
   but the visible capsule is drawn by ::after with horizontal inset
   so it never touches the bar's left/right edges. */
.nav-pill {
  position: absolute;
  top: 7px; bottom: 7px; left: 0;
  width: calc(100% / 3);
  transition: transform .32s cubic-bezier(.32,.72,0,1);
  pointer-events: none;
  will-change: transform;
  z-index: 0;
}
.nav-pill::after {
  content: '';
  position: absolute;
  inset: 0 8px;
  border-radius: 32px;
  background: rgba(0,0,0,.05);
  box-shadow: inset 0 0 0 .5px rgba(0,0,0,.04);
}
[data-theme="dark"] .nav-pill::after {
  background: rgba(255,255,255,.08);
  box-shadow: inset 0 0 0 .5px rgba(255,255,255,.06);
}

@keyframes tab-icon-pop {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.15); }
  70%  { transform: scale(0.95); }
  100% { transform: scale(1); }
}

.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 6px 4px;
  color: rgba(0,0,0,.45);
  transition: color .2s ease, transform .15s ease;
  position: relative;
  z-index: 1;
}
.tab:active {
  transform: scale(0.92);
  transition: color .2s ease, transform .08s ease;
}
[data-theme="dark"] .tab { color: rgba(255,255,255,.38); }
.tab.active { color: #30D158; }

.tab-icon {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  color: inherit;
  position: relative;
  z-index: 1;
  transition: color .2s ease;
}
.tab-icon svg { width: 24px; height: 24px; }
.tab.active .tab-icon {
  animation: tab-icon-pop .38s cubic-bezier(.32,.72,0,1) forwards;
}

/* Outline ↔ filled crossfade (SF Symbols-style) */
.tab-icon .ti-outline,
.tab-icon .ti-filled {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  transition: opacity .22s ease;
}
.tab-icon .ti-filled    { opacity: 0; }
.tab.active .ti-outline { opacity: 0; }
.tab.active .ti-filled  { opacity: 1; }

/* Keyboard accessibility (HIG focus ring) */
.tab:focus-visible {
  outline: 2px solid #30D158;
  outline-offset: -3px;
  border-radius: 22px;
}

/* Respect user's motion preferences */
@media (prefers-reduced-motion: reduce) {
  .nav-pill,
  .tab,
  .tab.active .tab-icon,
  .tab-icon .ti-outline,
  .tab-icon .ti-filled {
    transition-duration: .01s !important;
    animation: none !important;
  }
}

.tab-label {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: -.05px;
  line-height: 1;
  position: relative;
  z-index: 1;
}


/* ── Skeleton loading ────────────────────────────────── */
@keyframes shimmer {
  from { background-position: -200% 0; }
  to   { background-position:  200% 0; }
}

.skel {
  background: linear-gradient(90deg,
    var(--border) 25%,
    var(--surface) 50%,
    var(--border) 75%
  );
  background-size: 200%;
  animation: shimmer 1.4s linear infinite;
  border-radius: var(--r-sm);
}

.skel-list { display: flex; flex-direction: column; gap: 8px; padding: 12px; }

.skel-card {
  background: var(--surface);
  border-radius: var(--r-md);
  padding: 14px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

/* ── Week strip ──────────────────────────────────────── */
.week-strip {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  padding: 8px 12px 10px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.day-pill {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 2px;
  border-radius: var(--r-md);
  transition: background .15s, transform .1s cubic-bezier(.34,1.56,.64,1);
}
.day-pill:active:not(.is-selected) { background: var(--border); transform: scale(.9); }

.dp-lbl {
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.dp-num {
  font-size: 17px;
  font-weight: 800;
  line-height: 1;
}

.dp-dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: transparent;
}
.dp-dot.has     { background: var(--accent); }
.dp-dot.overdue { background: var(--danger); }
.dp-count {
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.dp-count--overdue { color: var(--danger); }

.day-pill.is-today .dp-lbl,
.day-pill.is-today .dp-num { color: var(--accent); }

.day-pill.is-selected {
  background: rgba(59,130,246,.10);
}

/* ── List view ───────────────────────────────────────── */
.list-view { padding: 4px 0 12px; }

.list-section { padding: 0 12px; }

.list-day-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  padding: 10px 0 6px;
}
.list-day-count {
  font-size: 10px;
  font-weight: 700;
  color: var(--accent);
  background: rgba(var(--accent-rgb), .1);
  padding: 1px 7px;
  border-radius: var(--r-full);
  letter-spacing: 0;
  text-transform: none;
}

.ev-card {
  background: var(--surface);
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  border-left: 4px solid var(--cat, var(--accent));
  padding: 12px 14px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: transform .12s cubic-bezier(.34,1.56,.64,1), box-shadow .15s;
  box-shadow: var(--shadow-sm);
  -webkit-tap-highlight-color: transparent;
  animation: ev-card-in .22s ease both;
}
@keyframes ev-card-in {
  from { opacity: 0; transform: translateY(5px); }
  to   { opacity: 1; transform: none; }
}
.ev-card:active { transform: scale(.97); box-shadow: none; }
.ev-card.ev-done { opacity: .55; }
.ev-card.ev-done .ev-title { text-decoration: line-through; }

.ev-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 5px;
}

.ev-time {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: .03em;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.ev-title {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.25;
  margin-bottom: 3px;
  color: var(--text);
}

.ev-meta {
  font-size: 11px;
  color: var(--muted);
}

.ev-desc {
  font-size: 12px;
  color: var(--muted);
  margin-top: 5px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ── Badge ───────────────────────────────────────────── */
.badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .03em;
  padding: 2px 7px;
  border-radius: var(--r-full);
  border: 1px solid currentColor;
  white-space: nowrap;
  flex-shrink: 0;
}

.badge-live {
  color: var(--success);
  background: rgba(34,197,94,.1);
  border-color: rgba(34,197,94,.3);
  animation: live-pulse 2s ease infinite;
}

@keyframes live-pulse { 0%,100% { opacity: 1; } 50% { opacity: .65; } }

.badge-overdue {
  color: var(--danger);
  background: rgba(239,68,68,.08);
  border-color: rgba(239,68,68,.22);
}

/* ── Timeline view ───────────────────────────────────── */
.timeline {
  position: relative;
  padding: 0 12px 16px 58px;
}
.tl-overflow {
  position: sticky;
  left: 0;
  right: 0;
  z-index: 5;
  padding: 5px 14px 5px 58px;
  font-size: 11px;
  font-weight: 600;
  color: var(--warning);
  background: color-mix(in srgb, var(--warning) 8%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--warning) 20%, transparent);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin: 0 12px;
  border-radius: var(--r-sm);
}
.tl-overflow--bottom {
  bottom: 0;
  border-radius: 0 0 var(--r-sm) var(--r-sm);
}
.tl-overflow--top {
  top: 0;
  border-radius: var(--r-sm) var(--r-sm) 0 0;
}

.tl-hour {
  position: absolute;
  left: 56px;
  right: 12px;
  border-top: 1px solid var(--border);
}

.tl-label {
  position: absolute;
  left: 0;
  width: 50px;
  text-align: right;
  top: -8px;
  font-size: 10px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  padding-right: 6px;
}

.tl-now-line {
  position: absolute;
  left: 50px;
  right: 8px;
  height: 2px;
  background: var(--danger);
  z-index: 4;
  border-radius: 1px;
}
.tl-now-line::before {
  content: '';
  position: absolute;
  left: -5px;
  top: -4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--danger);
}
.tl-now-badge {
  position: absolute;
  left: -52px;
  top: -9px;
  background: var(--danger);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  padding: 2px 5px;
  border-radius: var(--r-full);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  line-height: 1.4;
  pointer-events: none;
}
.tl-slot-tooltip {
  position: absolute;
  background: var(--text);
  color: var(--bg);
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: var(--r-full);
  pointer-events: none;
  z-index: 10;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  box-shadow: var(--shadow-md);
  opacity: .9;
}

.tl-event {
  position: absolute;
  border-radius: var(--r-sm);
  border-left: 3px solid var(--cat, var(--accent));
  padding: 5px 9px;
  overflow: hidden;
  cursor: pointer;
  min-height: 32px;
  transition: transform .1s, opacity .15s;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
.tl-event:active { transform: scale(.97); }
.tl-event.tl-completed { opacity: .45; }
.tl-event.tl-live {
  box-shadow: 0 0 0 1.5px var(--success), 0 0 10px rgba(34,197,94,.18);
}
.tl-event.tl-overdue { border-left-color: var(--danger) !important; }
/* ── Timeline quick-action menu ──────────────────────── */
.tl-quick-menu {
  position: absolute;
  z-index: 110;
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--border-md);
  border-radius: var(--r-full);
  padding: 4px 6px;
  box-shadow: var(--shadow-lg);
  animation: tl-qm-pop .18s cubic-bezier(.34,1.56,.64,1);
  pointer-events: auto;
}
@keyframes tl-qm-pop {
  from { opacity: 0; transform: scale(.7) translateY(6px); }
  to   { opacity: 1; transform: none; }
}
.tl-qm-btn {
  padding: 6px 10px;
  border-radius: var(--r-full);
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  white-space: nowrap;
  transition: background .12s;
}
.tl-qm-btn:active { background: var(--border-md); }
.tl-qm-done {
  color: var(--success);
  border-color: rgba(34,197,94,.3);
  background: rgba(34,197,94,.08);
}
.tl-qm-close {
  color: var(--muted);
  background: transparent;
  border-color: transparent;
  padding: 6px 8px;
}

.tl-drag-ghost { position: absolute; z-index: 100; pointer-events: none; }
.tl-drag-placeholder {
  position: absolute;
  z-index: 5;
  pointer-events: none;
  border-radius: var(--r-sm);
  border: 2px dashed var(--accent);
  background: rgba(var(--accent-rgb), .08);
  transition: top .1s ease;
}

.tl-ev-time {
  font-size: 10px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  line-height: 1.2;
}
.tl-ev-title {
  font-size: 12px;
  font-weight: 700;
  line-height: 1.25;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.tl-ev-meta {
  font-size: 10px;
  color: var(--muted);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.tl-ev-desc {
  font-size: 10px;
  color: var(--muted);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  line-height: 1.3;
  opacity: .75;
}

/* ── Timeline dim ────────────────────────────────────── */
.tl-hour--dim { opacity: 0.35; }

/* ── Empty / error states ────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 52px 24px;
  text-align: center;
  color: var(--muted);
}

.error-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 52px 24px;
  text-align: center;
  color: var(--muted);
}

.empty-icon {
  width: 48px; height: 48px;
  display: grid;
  place-items: center;
  color: var(--muted);
  opacity: .5;
}
.empty-icon svg { width: 44px; height: 44px; }

.empty-title { font-size: 16px; font-weight: 700; color: var(--text); }

.retry-btn {
  margin-top: 12px;
  padding: 10px 22px;
  background: var(--accent);
  color: var(--accent-fg);
  border-radius: var(--r-md);
  font-size: 14px;
  font-weight: 600;
  transition: opacity .15s;
}
.retry-btn:active { opacity: .85; }

/* ── Overlay / Bottom sheet ──────────────────────────── */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.44);
  z-index: 50;
  display: flex;
  align-items: flex-end;
  opacity: 0;
  transition: opacity .22s ease;
}
.overlay[hidden] { display: none !important; }
.overlay.open    { opacity: 1; }

.sheet {
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
  background: var(--surface);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  max-height: 88dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform .42s cubic-bezier(.175,.885,.32,1.08);
  will-change: transform;
}
.overlay.open .sheet { transform: translateY(0); }

.sheet-knob {
  flex-shrink: 0;
  width: 40px; height: 4px;
  border-radius: 2px;
  background: var(--border-md);
  margin: 12px auto 0;
  cursor: grab;
}

.sheet-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px 16px calc(24px + env(safe-area-inset-bottom, 0px));
}

/* Sheet content */
.sh-header {
  border-left: 3.5px solid var(--cat, var(--accent));
  padding: 2px 0 14px 12px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.sh-time {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 5px;
}

.sh-title {
  font-size: 20px;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -.01em;
  margin-bottom: 6px;
}

.sh-meta {
  font-size: 12px;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.gcal-pill {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: var(--r-full);
  border: 1px solid rgba(34,197,94,.3);
  color: var(--success);
  background: rgba(34,197,94,.08);
}

.sh-desc {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
  margin-bottom: 14px;
  padding: 10px 12px;
  background: var(--bg);
  border-radius: var(--r-md);
}

.sh-section { margin-bottom: 16px; }

.sh-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
  margin-bottom: 8px;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.st-opt {
  padding: 10px 6px;
  border-radius: var(--r-md);
  font-size: 13px;
  font-weight: 600;
  border: 1.5px solid var(--border-md);
  background: var(--bg);
  color: var(--text);
  text-align: center;
  transition: all .15s;
}
.st-opt.active { color: #fff; border-color: transparent; }
.st-opt:active { opacity: .8; }

.cat-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.cat-opt {
  padding: 6px 12px;
  border-radius: var(--r-full);
  font-size: 13px;
  border: 1.5px solid var(--border-md);
  background: var(--bg);
  color: var(--text);
  transition: all .15s;
}
.cat-opt.active { color: #fff; border-color: transparent; }
.cat-opt:active { opacity: .8; }

.delete-btn {
  width: 100%;
  margin-top: 4px;
  padding: 12px;
  border-radius: var(--r-md);
  background: rgba(239,68,68,.07);
  color: var(--danger);
  border: 1.5px solid rgba(239,68,68,.16);
  font-size: 14px;
  font-weight: 600;
  transition: background .15s, transform .1s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}
.delete-btn:active  { background: rgba(239,68,68,.16); transform: scale(.98); }
.delete-btn.confirm { background: rgba(239,68,68,.88); color: #fff; border-color: var(--danger); }

/* ── Toast ───────────────────────────────────────────── */
.toasts {
  position: fixed;
  bottom: calc(var(--bh) + env(safe-area-inset-bottom, 0px) + 10px + 14px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 200;
  pointer-events: none;
  width: min(92vw, 340px);
}

.toast {
  padding: 11px 16px;
  border-radius: var(--r-lg);
  font-size: 13px;
  font-weight: 600;
  background: rgba(15,23,42,.82);
  backdrop-filter: blur(12px) saturate(1.5);
  -webkit-backdrop-filter: blur(12px) saturate(1.5);
  border: 1px solid rgba(255,255,255,.12);
  color: #f1f5f9;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(8px) scale(.95);
  transition: opacity .2s, transform .2s;
  text-align: center;
}
.toast.show      { opacity: 1; transform: none; }
.toast.t-success { background: rgba(5,46,22,.88); border-color: rgba(34,197,94,.15); }
.toast.t-error   { background: rgba(69,10,10,.88); border-color: rgba(239,68,68,.15); }

.toast--action {
  display: flex;
  align-items: center;
  gap: 12px;
  pointer-events: auto;
  text-align: left;
}
.toast-msg { flex: 1; }
.toast-action-btn {
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  color: #93c5fd;
  background: rgba(255,255,255,.10);
  border: 1px solid rgba(255,255,255,.18);
  border-radius: var(--r-sm);
  padding: 4px 10px;
  white-space: nowrap;
  cursor: pointer;
  flex-shrink: 0;
}
.toast-action-btn:active { opacity: .8; }

/* ── FAB ─────────────────────────────────────────────── */
.fab-container {
  position: fixed;
  bottom: calc(var(--bh) + env(safe-area-inset-bottom, 0px) + 10px + 14px);
  right: 16px;
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  transition: opacity .2s;
}
.fab-container.hidden { opacity: 0; pointer-events: none; }

.fab {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-fg);
  display: grid;
  place-items: center;
  box-shadow: 0 4px 18px rgba(var(--accent-rgb), .42), 0 2px 6px rgba(var(--accent-rgb), .2);
  transition: transform .2s cubic-bezier(.34,1.56,.64,1), opacity .15s, box-shadow .15s;
  flex-shrink: 0;
}
.fab:active { transform: scale(.88); box-shadow: 0 2px 8px rgba(var(--accent-rgb), .3); }

.fab-main {
  /* main trigger button */
}
.fab-main svg {
  transition: transform .25s cubic-bezier(.34,1.56,.64,1);
}
.fab-container.is-open .fab-main svg {
  transform: rotate(45deg);
}

.fab-sm {
  width: 48px;
  height: 48px;
}

.fab-secondary {
  background: var(--surface);
  color: var(--accent);
  border: 1px solid rgba(var(--accent-rgb), .18);
  box-shadow: var(--shadow-md);
}
.fab-secondary:active { box-shadow: none; }

.fab-menu {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: flex-end;
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transform: translateY(8px) scale(.96);
  transition: max-height .32s cubic-bezier(.34,1.2,.64,1), opacity .22s, transform .28s cubic-bezier(.34,1.56,.64,1);
  pointer-events: none;
}
.fab-container.is-open .fab-menu {
  max-height: 200px;
  opacity: 1;
  transform: none;
  pointer-events: auto;
}
.fab-menu-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.fab-menu-label {
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: var(--r-full);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
  white-space: nowrap;
}

.fab-secondary:active { box-shadow: 0 2px 8px rgba(15,23,42,.14); }

/* ── Event form ──────────────────────────────────────── */
.form-sheet { padding: 0 16px calc(12px + env(safe-area-inset-bottom, 0px)); }

.form-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0 14px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.form-heading {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -.01em;
}

.form-cancel {
  font-size: 14px;
  color: var(--muted);
  padding: 6px 0 6px 12px;
  transition: color .15s;
}
.form-cancel:active { color: var(--text); }

.form-field { margin-bottom: 14px; }

.form-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  padding: 11px 13px;
  border-radius: var(--r-md);
  border: 1.5px solid var(--border-md);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 15px;
  outline: none;
  transition: border-color .15s;
  -webkit-appearance: none;
}
.form-input:focus { border-color: var(--accent); }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.dur-grid {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.dur-btn {
  padding: 7px 13px;
  border-radius: var(--r-full);
  font-size: 13px;
  font-weight: 600;
  border: 1.5px solid var(--border-md);
  background: var(--bg);
  color: var(--text);
  transition: all .15s;
  white-space: nowrap;
}
.dur-btn.active {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: var(--accent);
}
.dur-btn:active { opacity: .75; }

.form-input-compact {
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.form-submit {
  width: 100%;
  margin-top: 6px;
  padding: 13px;
  border-radius: var(--r-md);
  background: var(--accent);
  color: var(--accent-fg);
  font-size: 15px;
  font-weight: 700;
  transition: opacity .15s, transform .1s;
}
.form-submit:active { opacity: .85; transform: scale(.98); }
.form-submit:disabled { opacity: .5; }

.edit-btn {
  width: 100%;
  margin-top: 8px;
  padding: 11px 14px;
  border-radius: var(--r-md);
  background: var(--bg);
  color: var(--accent);
  border: 1.5px solid var(--border-md);
  font-size: 14px;
  font-weight: 600;
  transition: background .15s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}
.edit-btn:active { background: var(--border); }

.voice-sheet {
  padding: 4px 2px calc(12px + env(safe-area-inset-bottom, 0px));
}

.voice-sheet-head {
  margin-bottom: 18px;
}

.voice-sheet-kicker {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 5px;
}

.voice-sheet-title {
  font-size: 20px;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -.01em;
}

.voice-sheet-sub {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.45;
}

.voice-sheet--recording {
  text-align: center;
  padding-top: 12px;
}

.voice-waveform {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 5px;
  height: 40px;
  margin: 0 auto 14px;
}
.voice-waveform span {
  width: 5px;
  height: 4px;
  border-radius: 3px;
  background: var(--accent);
  opacity: .7;
  transition: height .08s ease;
  animation: voice-bar-idle 1.2s ease-in-out infinite;
}
.voice-waveform span:nth-child(1) { animation-delay: 0s;    animation-duration: 1.0s; }
.voice-waveform span:nth-child(2) { animation-delay: .15s;  animation-duration: 1.3s; }
.voice-waveform span:nth-child(3) { animation-delay: .3s;   animation-duration: 0.9s; }
.voice-waveform span:nth-child(4) { animation-delay: .45s;  animation-duration: 1.1s; }
.voice-waveform span:nth-child(5) { animation-delay: .6s;   animation-duration: 1.4s; }
@keyframes voice-bar-idle {
  0%, 100% { height: 4px;  opacity: .5; }
  50%       { height: 22px; opacity: 1;  }
}

.voice-recorder {
  position: relative;
  width: 160px;
  height: 160px;
  margin: 4px auto 18px;
  display: grid;
  place-items: center;
}

.voice-recorder-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(59,130,246,.18), rgba(59,130,246,.04) 65%, transparent 66%);
  opacity: .7;
}

.voice-recorder.is-live .voice-recorder-ring {
  animation: voice-breathe 1.8s ease-in-out infinite;
}

.voice-recorder.is-processing .voice-recorder-ring {
  animation: voice-spin 1.2s linear infinite;
  border: 2px solid rgba(59,130,246,.12);
  border-top-color: rgba(59,130,246,.55);
  background: transparent;
}

.voice-recorder-btn {
  position: relative;
  width: 88px;
  height: 88px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, var(--accent), #2563eb);
  color: var(--accent-fg);
  box-shadow: 0 12px 32px rgba(59,130,246,.28);
}

.voice-recorder-btn:disabled { opacity: .6; }

.voice-status {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 18px;
}

.voice-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.voice-transcript {
  padding: 14px;
  border-radius: var(--r-lg);
  background: var(--bg);
  border: 1px solid var(--border);
  margin-bottom: 14px;
}

.voice-transcript-label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 8px;
}

.voice-transcript-text {
  font-size: 14px;
  line-height: 1.5;
}

.voice-preview-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.voice-preview-card {
  margin-bottom: 0;
}
.voice-ev-title {
  width: 100%;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  background: transparent;
  border: none;
  outline: none;
  padding: 0;
  line-height: 1.25;
  margin-bottom: 3px;
}
.voice-ev-title:focus {
  border-bottom: 1.5px solid var(--accent);
}
.voice-ev-time {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  background: transparent;
  border: none;
  outline: none;
  font-variant-numeric: tabular-nums;
  letter-spacing: .03em;
  padding: 0;
  cursor: pointer;
  -webkit-appearance: none;
}
.voice-ev-time:focus { color: var(--accent); }
.voice-ev-dur {
  font-size: 10px;
  font-weight: 700;
  color: var(--accent);
  background: rgba(var(--accent-rgb), .1);
  border: 1px solid rgba(var(--accent-rgb), .2);
  border-radius: var(--r-full);
  padding: 2px 6px;
  cursor: pointer;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

.replan-textarea {
  min-height: 132px;
  resize: vertical;
  text-align: left;
  line-height: 1.5;
}

.replan-summary {
  padding: 14px;
  margin-bottom: 14px;
  border-radius: var(--r-lg);
  background: rgba(59,130,246,.06);
  border: 1px solid rgba(59,130,246,.14);
  font-size: 14px;
  line-height: 1.5;
}

.voice-empty {
  padding: 22px 14px;
  border-radius: var(--r-lg);
  background: var(--bg);
  border: 1px dashed var(--border-md);
  text-align: center;
}

.voice-empty-title {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 5px;
}

.voice-empty-sub {
  color: var(--muted);
  line-height: 1.45;
}

.voice-inline-cancel {
  padding: 0;
  text-align: center;
}

@keyframes voice-breathe {
  0%, 100% { transform: scale(.95); opacity: .55; }
  50% { transform: scale(1.03); opacity: 1; }
}

@keyframes voice-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.form-date-label {
  padding: 11px 13px;
  border-radius: var(--r-md);
  border: 1.5px solid var(--border-md);
  background: var(--bg);
  font-size: 15px;
  color: var(--muted);
}

/* ── Profile sheet ───────────────────────────────────── */
.profile-sheet { padding: 4px 0 24px; }

.profile-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 20px 0 16px;
}

.profile-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-fg);
  display: grid;
  place-items: center;
  font-size: 26px;
  font-weight: 700;
  flex-shrink: 0;
}
.profile-avatar--photo { object-fit: cover; }

.profile-name {
  font-size: 18px;
  font-weight: 600;
  text-align: center;
}
.profile-username { font-size: 13px; color: var(--muted); text-align: center; margin-top: 2px; }

.schedule-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.schedule-row .schedule-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  color: var(--text);
}
.schedule-row .schedule-label svg { color: var(--icon); }

.schedule-time {
  width: 110px !important;
  text-align: center;
  padding: 9px 10px !important;
}

.notif-toggle {
  width: 100%;
  padding: 14px;
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  text-align: left;
}

.notif-toggle.active {
  border-color: rgba(59,130,246,.28);
  background: rgba(59,130,246,.06);
}

.notif-toggle-copy {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.notif-toggle-title {
  font-size: 15px;
  font-weight: 700;
}

.notif-toggle-sub {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}

.notif-switch {
  width: 48px;
  height: 30px;
  border-radius: 999px;
  background: rgba(100,116,139,.26);
  position: relative;
  flex-shrink: 0;
  transition: background .18s ease;
}

.notif-switch-knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 2px 8px rgba(15,23,42,.16);
  transition: transform .18s ease;
}

.notif-toggle.active .notif-switch {
  background: var(--accent);
}

.notif-toggle.active .notif-switch-knob {
  transform: translateX(18px);
}

.reminder-block.is-hidden {
  display: none;
}

.reminder-btn {
  min-width: 68px;
}

/* ── Stats view ──────────────────────────────────────── */
.stats-view { padding: 8px 12px 24px; display: flex; flex-direction: column; gap: 12px; }

.stats-period-row { display: flex; gap: 8px; }
.stats-period-btn {
  flex: 1; padding: 9px 0; border-radius: var(--r-md);
  font-size: 13px; font-weight: 600;
  border: 1.5px solid var(--border-md); background: var(--bg); color: var(--muted);
  transition: all .15s;
}
.stats-period-btn.active {
  background: var(--accent); color: var(--accent-fg); border-color: var(--accent);
}

.stats-cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.stat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 14px 12px; text-align: center; box-shadow: var(--shadow-sm);
}
.stat-card-val { font-size: 26px; font-weight: 800; line-height: 1; }
.stat-card-lbl {
  font-size: 10px; color: var(--muted); margin-top: 5px;
  font-weight: 600; text-transform: uppercase; letter-spacing: .05em;
}
.stat-card--green .stat-card-val { color: var(--success); }
.stat-card--blue  .stat-card-val { color: var(--accent); }
.stat-card--red   .stat-card-val { color: var(--danger); }

.stats-section {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 14px 12px; box-shadow: var(--shadow-sm);
}
.stats-section-title {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .07em; color: var(--muted); margin-bottom: 14px;
}

/* Weekday SVG bar chart */
.stats-svg-chart {
  display: block;
  width: 100%;
  overflow: visible;
}
.svgb-bg    { fill: var(--bg); }
.svgb-total {
  fill: var(--border-md);
  transform-origin: bottom;
  transform-box: fill-box;
  transform: scaleY(0);
  transition: none;
}
.svgb-done {
  fill: var(--accent);
  opacity: .85;
  transform-origin: bottom;
  transform-box: fill-box;
  transform: scaleY(0);
  transition: none;
}
.stats-svg-chart--animated .svgb-total {
  transform: scaleY(1);
  transition: transform .5s cubic-bezier(.34,1.2,.64,1);
}
.stats-svg-chart--animated .svgb-done {
  transform: scaleY(1);
  transition: transform .5s cubic-bezier(.34,1.2,.64,1) .08s;
}
.svgb-hit   { cursor: pointer; }
.svgb-hit:active ~ .svgb-total,
.svgb-hit:active ~ .svgb-done { opacity: .6; }
.svgb-label {
  font-size: 10px;
  font-weight: 600;
  fill: var(--muted);
  font-family: inherit;
}
.svgb-spark-line {
  stroke: var(--accent);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: .5;
}
.svgb-spark-dot {
  fill: var(--accent);
  opacity: .7;
}
.stats-bar-tooltip {
  position: absolute;
  top: -32px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: var(--r-full);
  white-space: nowrap;
  pointer-events: none;
  z-index: 10;
  box-shadow: var(--shadow-md);
}

/* Category bars */
.stats-cat-row { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.stats-cat-row:last-child { margin-bottom: 0; }
.stats-cat-name { font-size: 12px; width: 82px; flex-shrink: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stats-cat-bar-wrap { flex: 1; }
.stats-cat-bar { height: 10px; border-radius: var(--r-full); position: relative; overflow: hidden; min-width: 4px; }
.stats-cat-done { position: absolute; left: 0; top: 0; bottom: 0; border-radius: var(--r-full); transition: width .4s ease; }
.stats-cat-count { font-size: 11px; font-weight: 700; color: var(--muted); width: 36px; text-align: right; flex-shrink: 0; }

/* Insights / facts */
.stats-facts { display: flex; flex-direction: column; gap: 10px; }
.stats-fact {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--text);
}
.stats-fact-icon {
  width: 32px; height: 32px;
  border-radius: var(--r-sm);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  color: var(--accent-fg);
}
.stats-fact strong { color: var(--accent); }

/* ── Theme Toggle ─────────────────────────────────────── */
.theme-toggle {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-top: 8px;
}
.theme-btn {
  padding: 9px 4px;
  border-radius: var(--r-md);
  background: var(--bg);
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  border: 1.5px solid var(--border-md);
  transition: background .15s, color .15s, border-color .15s;
}
.theme-btn.active {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: var(--accent);
}
.theme-btn:active:not(.active) { background: var(--border); }

/* ── Templates & Routines ──────────────────────────────── */
.form-secondary {
  width: 100%;
  padding: 11px 14px;
  border-radius: var(--r-md);
  background: var(--bg);
  color: var(--accent);
  border: 1.5px solid var(--border-md);
  font-size: 14px;
  font-weight: 600;
  transition: background .15s;
  text-align: center;
}
.form-secondary:active { background: var(--border); }
.form-secondary:disabled { opacity: .5; }

.icon-btn {
  background: none;
  border: none;
  padding: 6px;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  border-radius: var(--r-sm);
  transition: background .15s;
}
.icon-btn:active { background: var(--border); }

.tmpl-item {
  background: var(--card);
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  padding: 12px 14px;
  margin-bottom: 10px;
}
.tmpl-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}
.tmpl-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}
.tmpl-block-count {
  font-size: 12px;
  color: var(--hint);
  margin-left: 6px;
}
.tmpl-blocks {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
}
.tmpl-block {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text);
}
.tmpl-block-time {
  font-variant-numeric: tabular-nums;
  color: var(--hint);
  min-width: 100px;
  flex-shrink: 0;
}
.tmpl-block-title { flex: 1; }
.tmpl-block-cat { font-size: 12px; flex-shrink: 0; }
.tmpl-apply-btn {
  width: 100%;
  padding: 9px 14px;
  border-radius: var(--r-md);
  background: var(--accent);
  color: var(--accent-fg);
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  transition: opacity .15s;
}
.tmpl-apply-btn:active { opacity: .8; }

/* ── Priority ──────────────────────────────────────── */
.priority-grid {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 6px;
}
.pri-btn {
  flex: 1;
  min-width: 80px;
  padding: 7px 6px;
  border-radius: var(--r-md);
  font-size: 12px;
  font-weight: 600;
  background: var(--bg);
  color: var(--text);
  border: 1.5px solid var(--border-md);
  text-align: center;
  transition: all .15s;
  white-space: nowrap;
}
.pri-btn.active {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: var(--accent);
}
.pri-btn:active { opacity: .8; }

.ev-priority { font-size: 11px; line-height: 1; }
.ev-fixed { font-size: 11px; line-height: 1; }

.flex-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
}
.flex-toggle input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--accent);
  flex-shrink: 0;
}

.tmpl-block-edit {
  background: var(--bg);
  border-radius: var(--r-sm);
  padding: 8px;
  margin-bottom: 6px;
  border: 1px solid var(--border);
}

/* ── Week sub-view toggle ─────────────────────────── */
.wst-row {
  display: flex;
  gap: 6px;
  padding: 8px 16px 4px;
}
.wst-btn {
  flex: 1;
  padding: 8px 0;
  border-radius: var(--r-md);
  font-size: 13px;
  font-weight: 600;
  background: var(--bg);
  color: var(--hint);
  border: 1.5px solid var(--border);
  transition: all .15s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.wst-btn svg { flex-shrink: 0; }
.wst-btn.active {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: var(--accent);
}

.wst-bal-btn {
  flex-shrink: 0;
  padding: 8px 10px;
  border-radius: var(--r-md);
  border: 1.5px solid var(--border);
  background: var(--bg);
  color: var(--muted);
  display: grid;
  place-items: center;
  transition: all .15s;
}
.wst-bal-btn:active { background: var(--border); }
.wst-bal-btn:disabled { opacity: .4; }

/* ── Weekly review card ───────────────────────────── */
.week-review-card {
  margin: 8px 16px;
  padding: 12px 14px;
  background: var(--card);
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.wrev-bars {
  display: flex;
  align-items: flex-end;
  gap: 5px;
}
.wrev-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 24px;
}
.wrev-bar-wrap {
  height: 36px;
  display: flex;
  align-items: flex-end;
}
.wrev-bar {
  width: 16px;
  border-radius: 3px 3px 0 0;
  background: var(--accent);
  min-height: 2px;
  opacity: .7;
  transition: height .3s ease;
}
.wrev-day.wrev-overloaded .wrev-bar { background: #ef4444; opacity: 1; }
.wrev-day.wrev-today .wrev-bar { opacity: 1; }
.wrev-lbl { font-size: 10px; font-weight: 600; color: var(--hint); }
.wrev-time { font-size: 9px; color: var(--hint); }
.wrev-today .wrev-lbl { color: var(--accent); }
.wrev-ai-btn {
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--r-md);
  font-size: 13px;
  font-weight: 700;
  background: var(--accent);
  color: var(--accent-fg);
  transition: opacity .15s;
}
.wrev-ai-btn:active { opacity: .8; }
.wrev-ai-btn:disabled { opacity: .5; }

/* ── Visual week canvas ───────────────────────────── */
.wc-wrap {
  overflow-x: auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  margin: 8px 0 12px;
  max-height: calc(var(--vh,1vh)*100 - 290px);
  min-height: 200px;
}
.wc-grid {
  display: flex;
  position: relative;
  min-width: max-content;
}
.wc-time-col {
  position: sticky;
  left: 0;
  z-index: 4;
  width: 42px;
  flex-shrink: 0;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
}
.wc-hour-lbl {
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  padding: 2px 6px 0 0;
  font-size: 9px;
  color: var(--hint);
  font-variant-numeric: tabular-nums;
}
.wc-day-col {
  position: relative;
  flex-shrink: 0;
  border-right: 1px solid var(--border-light, var(--border));
}
.wc-today .wc-ev-area { background: rgba(var(--accent-rgb,59,130,246),.03); }
.wc-day-hdr {
  position: sticky;
  top: 0;
  z-index: 3;
  height: 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  gap: 0;
}
.wc-day-hdr--today {
  background: var(--accent);
}
.wc-day-hdr--today .wc-hdr-day,
.wc-day-hdr--today .wc-hdr-num { color: var(--accent-fg); }
.wc-hdr-day { font-size: 9px; font-weight: 600; color: var(--hint); line-height: 1; }
.wc-hdr-num { font-size: 13px; font-weight: 700; color: var(--text); line-height: 1; }
.wc-hdr-count {
  font-size: 8px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
  margin-top: 1px;
}
.wc-hdr-count--overdue { color: var(--danger); }
.wc-day-hdr--today .wc-hdr-count { color: rgba(255,255,255,.8); }
.wc-ev-area { position: relative; }
.wc-grid-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--border);
  opacity: .4;
}
.wc-now-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent);
  z-index: 2;
  border-radius: 1px;
}
.wc-event {
  position: absolute;
  left: 2px;
  right: 2px;
  border-left: 2px solid var(--cat);
  background: color-mix(in srgb, var(--cat) 18%, var(--card));
  border-radius: 3px;
  padding: 2px 3px;
  overflow: hidden;
  cursor: pointer;
  z-index: 1;
  transition: opacity .1s;
}
.wc-event:active { opacity: .7; }
.wc-done { opacity: .45; }
.wc-overdue { border-left-color: #ef4444 !important; }
.wc-ev-title {
  font-size: 10px;
  font-weight: 600;
  color: var(--cat);
  line-height: 1.2;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.wc-ev-time {
  font-size: 9px;
  color: var(--hint);
  font-variant-numeric: tabular-nums;
}

/* ── Week canvas inline popup ─────────────────────────── */
.wc-popup {
  position: fixed;
  z-index: 200;
  width: 240px;
  background: var(--surface);
  border: 1px solid var(--border-md);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  opacity: 0;
  transform: scale(.9) translateY(4px);
  transition: opacity .15s ease, transform .18s cubic-bezier(.34,1.56,.64,1);
  pointer-events: auto;
}
.wc-popup--visible {
  opacity: 1;
  transform: none;
}
.wc-popup-head {
  padding: 10px 12px 8px 14px;
  border-bottom: 1px solid var(--border);
}
.wc-popup-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.25;
}
.wc-popup-meta {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}
.wc-popup-status {
  font-size: 10px;
  font-weight: 700;
  margin-top: 3px;
  letter-spacing: .02em;
}
.wc-popup-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 7px 8px;
  overflow-x: auto;
  scrollbar-width: none;
}
.wc-popup-actions::-webkit-scrollbar { display: none; }
.wc-popup-btn {
  flex-shrink: 0;
  padding: 5px 10px;
  border-radius: var(--r-full);
  font-size: 11px;
  font-weight: 700;
  background: var(--bg);
  border: 1px solid var(--border-md);
  color: var(--text);
  white-space: nowrap;
  transition: background .1s;
}
.wc-popup-btn:active { background: var(--border-md); }
.wc-popup-btn--start {
  color: var(--accent);
  border-color: rgba(var(--accent-rgb), .3);
  background: rgba(var(--accent-rgb), .08);
}
.wc-popup-btn--done {
  color: var(--success);
  border-color: rgba(34,197,94,.3);
  background: rgba(34,197,94,.08);
}
.wc-popup-btn--open {
  color: var(--text);
  margin-left: auto;
}
.wc-popup-btn--close {
  color: var(--muted);
  background: transparent;
  border-color: transparent;
  padding: 5px 7px;
}

/* ── Week event quick sheet ───────────────────────── */
.wqs-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 4px;
}
.wqs-btn {
  padding: 10px 8px;
  border-radius: var(--r-md);
  font-size: 13px;
  font-weight: 600;
  background: var(--bg);
  color: var(--text);
  border: 1.5px solid var(--border-md);
  text-align: center;
  transition: background .1s;
}
.wqs-btn:active { background: var(--border); }
.wqs-btn--active { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }

/* ── AI Balance sheet ─────────────────────────────── */
.bal-insight {
  font-size: 14px;
  color: var(--text);
  line-height: 1.5;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}
.bal-tag {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--r-full);
  margin-bottom: 4px;
}
.bal-tag--warn { background: rgba(239,68,68,.1); color: #ef4444; }
.bal-tag--free { background: rgba(34,197,94,.1); color: #16a34a; }
.bal-sug {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.bal-sug:last-child { border-bottom: none; }
.bal-ev-title { font-size: 14px; font-weight: 600; color: var(--text); }
.bal-ev-move { font-size: 12px; color: var(--accent); margin: 2px 0; font-variant-numeric: tabular-nums; }
.bal-ev-reason { font-size: 12px; color: var(--hint); }

/* ── Interactive Tour ─────────────────────────────────── */
.tour-overlay {
  position: fixed;
  inset: 0;
  z-index: 9000;
}

/* Spotlight: box-shadow darkens everything outside the highlight rect */
.tour-hl {
  position: fixed;
  border-radius: 10px;
  box-shadow: 0 0 0 9999px rgba(0,0,0,.72);
  z-index: 9001;
  pointer-events: none;
  outline: 2px solid rgba(255,255,255,.25);
  outline-offset: 1px;
}

.tour-card {
  position: fixed;
  background: var(--surface);
  border-radius: var(--r-xl);
  padding: 20px 20px 16px;
  z-index: 9002;
  box-shadow: 0 20px 60px rgba(0,0,0,.35), 0 0 0 1px rgba(255,255,255,.08);
  max-width: calc(100vw - 32px);
}
.tour-card--center {
  top: 50% !important;
  left: 50% !important;
  transform: translate(-50%,-50%) !important;
  width: 340px;
  max-width: calc(100vw - 32px);
}

.tour-badge {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: .06em;
  text-transform: uppercase;
  margin-bottom: 10px;
}

.tour-ttl {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
  line-height: 1.3;
}

.tour-txt {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.6;
  margin-bottom: 16px;
}

.tour-dots {
  display: flex;
  gap: 5px;
  justify-content: center;
  margin-bottom: 18px;
}
.tour-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--border-md);
  flex-shrink: 0;
  transition: width .2s, background .2s;
}
.tour-dot--on {
  width: 18px;
  border-radius: 3px;
  background: var(--accent);
}

.tour-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.tour-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}
.tour-skip {
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  background: none;
  border: none;
  padding: 8px 4px;
  cursor: pointer;
}
.tour-back {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  background: var(--bg-secondary);
  border: none;
  padding: 10px 16px;
  border-radius: var(--r-full);
  cursor: pointer;
}
.tour-nxt {
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  background: var(--accent);
  border: none;
  padding: 10px 22px;
  border-radius: var(--r-full);
  cursor: pointer;
}
.tour-nxt:active { opacity: .85; }

/* Profile "restart tour" button */
.tour-restart-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  margin-top: 12px;
  padding: 12px;
  background: none;
  border: 1.5px solid var(--border-md);
  border-radius: var(--r-lg);
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
}
.tour-restart-btn:active { background: rgba(59,130,246,.06); }
