:root {
  --bg: oklch(0.17 0.012 258);
  --surface: oklch(0.225 0.014 258);
  --surface2: oklch(0.27 0.016 258);
  --text: oklch(0.96 0.004 258);
  --muted: oklch(0.65 0.012 258);
  --hair: oklch(0.32 0.014 258);
  --accent: oklch(0.66 0.17 253);
  --accent-soft: oklch(0.28 0.06 253);
  --green: oklch(0.72 0.13 150);
  --violet: oklch(0.72 0.09 290);
  --amber: oklch(0.75 0.15 90);
  --danger: oklch(0.68 0.17 22);
  --font-heading: 'Outfit', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
  --tabbar-h: 78px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  -webkit-tap-highlight-color: transparent;
  /* Native pull-to-refresh is intentionally left enabled here (no
     overscroll-behavior block) — it's genuinely useful (e.g. School Hub's
     "couldn't load, tap Retry" state is exactly the kind of thing you'd
     expect to pull-to-refresh instead). It no longer conflicts with the
     bottom-sheet drag-to-dismiss gesture the way it used to: the grabber
     itself now has touch-action: none (stops the browser from ever
     recognizing a scroll/refresh gesture starting there, regardless of
     this rule), and the page behind an open sheet is separately locked
     via lockBodyScroll() in app.js, so there's nothing scrollable back
     there to trigger a refresh on even for a touch that lands elsewhere
     on the sheet. If a conflict ever resurfaces, this is the line to
     bring back: overscroll-behavior-y: contain. */
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  padding: 24px 20px calc(var(--tabbar-h) + 24px);
  position: relative;
}

.hidden { display: none !important; }

.hero {
  text-align: center;
  margin-top: 60px;
  margin-bottom: 32px;
}

.logo-big {
  font-family: var(--font-heading);
  font-size: 30px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text);
}

.logo-sm {
  font-family: var(--font-heading);
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
}

.subtitle {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 24px;
  line-height: 1.5;
}

.hint { font-size: 13px; color: var(--muted); margin-bottom: 12px; }

/* --- Insights tab --- */
.insight-line { font-size: 13.5px; color: var(--text); line-height: 1.5; margin-bottom: 6px; }
.insight-line:last-child { margin-bottom: 0; }
.insight-line strong { color: var(--accent); font-weight: 600; }
.insight-stat-row { display: flex; justify-content: space-around; }
.insight-stat { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.insight-stat-num { font-family: var(--font-heading); font-size: 22px; font-weight: 700; color: var(--text); }
.insight-stat-num--done { color: #4caf50; }
.insight-stat-num--skipped { color: var(--warning, #f6bf26); }
.insight-stat-num--rescheduled { color: #b39ddb; }
.insight-stat-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

/* Green/amber/red completion-rate indicators — see rateColor() in app.js
   for the thresholds. Reused for both the day-density lines in "How you
   actually work" and the workload comparison multiplier. */
.insight-rate-line { display: flex; align-items: baseline; gap: 8px; font-size: 13px; margin-bottom: 9px; }
.insight-rate-line:last-of-type { margin-bottom: 0; }
.insight-rate-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; transform: translateY(-1px); }
.insight-rate-dot--good { background: #4caf50; }
.insight-rate-dot--mid { background: var(--warning, #f6bf26); }
.insight-rate-dot--low { background: #e67c73; }
.insight-rate-pct--good { color: #4caf50; }
.insight-rate-pct--mid { color: var(--warning, #f6bf26); }
.insight-rate-pct--low { color: #e67c73; }

.insight-divider { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--hair, #2a2a2a); }
.insight-subheading { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 8px; }

/* A labeled stat sitting in its own rounded, filled row — "Longest active
   streak" and "Furthest behind" in This Week, instead of a plain sentence. */
.insight-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface2);
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 10px;
  font-size: 13px;
}
.insight-box-value { font-weight: 700; color: var(--text); }
.insight-box--accent {
  display: block;
  border-left: 3px solid var(--warning, #f6bf26);
  border-radius: 8px 12px 12px 8px;
}

.insight-activity-list { margin-top: 10px; border-top: 1px solid var(--hair, #2a2a2a); padding-top: 8px; }
.insight-activity-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 5px 0;
  font-size: 13px;
}
.insight-activity-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; transform: translateY(-1px); }
.insight-activity-dot--done { background: #4caf50; }
.insight-activity-dot--missed { background: #e67c73; }
.insight-activity-dot--skipped { background: var(--warning, #f6bf26); }
.insight-activity-title { flex: 1; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.insight-activity-time { flex-shrink: 0; color: var(--muted); font-size: 11.5px; }

/* Workload forecast's small bar chart — one bar per upcoming week, the
   heaviest one highlighted. Heights are set inline (relative % of a
   fixed-height container) since they're computed per-render from real
   data, not something fixed CSS can express. */
.insight-bar-chart { display: flex; align-items: flex-end; }
.insight-bar-chart--week { gap: 14px; height: 110px; }
.insight-bar-chart--day { gap: 10px; height: 130px; }
.insight-bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.insight-bar-score {
  font-size: 10px;
  font-weight: 700;
  /* Keeps digit width stable while the count-up animation below is
     changing the displayed number every frame — without this, digits of
     different widths (e.g. "1" vs "8") cause a faint horizontal jitter
     as the count climbs. */
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  margin-bottom: 6px;
  /* No opacity set here on purpose — it comes entirely from the
     animation's own "from" keyframe below (via fill-mode: both). If
     reduced-motion disables the animation, there's nothing left
     overriding the browser's default opacity:1, so the score is simply
     visible immediately rather than permanently stuck invisible, which
     is exactly what would happen if opacity:0 were set directly here
     instead. */
  animation: barScoreFadeIn 0.35s cubic-bezier(0.2, 0.7, 0.3, 1) both;
}
.insight-bar-score--heavy { color: var(--warning, #f6bf26); }
.insight-bar {
  /* Width is fixed per chart type below, NOT tied to column width — a
     percentage-based width (the previous approach) meant the same "60%"
     produced very different actual pixel widths between the 4-column
     week chart and the 7-column day chart, and shifted unevenly with any
     gap/label change. Columns stay flex:1 purely for even spacing/
     alignment; the visible bar itself is always the same fixed width
     within its own chart type regardless of how many columns exist or
     how long a label is (e.g. "Sep 14" vs "Oct 5"). */
  border-radius: 6px 6px 0 0;
  background: var(--surface2);
  transform-origin: bottom;
  animation: barGrow 0.45s cubic-bezier(0.2, 0.7, 0.3, 1) both;
}
.insight-bar-chart--week .insight-bar { width: 44px; border-radius: 8px 8px 0 0; }
.insight-bar-chart--day .insight-bar { width: 26px; }
.insight-bar--heavy { background: var(--warning, #f6bf26); }
/* Staggers each bar (and its score label above it) slightly after the
   one before it, for a quick left-to-right "wave" rather than everything
   snapping in at once — same 7-wide cap covers both the day charts
   (7 days) and the week comparison chart (currently 4 weeks; extra rules
   here are simply unused if a chart ever has fewer bars). The bar's own
   grow-up animation and the score label's fade-in share the same delay
   per column, so the number settles in roughly alongside its bar instead
   of visibly lagging behind or racing ahead of it. */
.insight-bar-col:nth-child(1) .insight-bar, .insight-bar-col:nth-child(1) .insight-bar-score { animation-delay: 0ms; }
.insight-bar-col:nth-child(2) .insight-bar, .insight-bar-col:nth-child(2) .insight-bar-score { animation-delay: 35ms; }
.insight-bar-col:nth-child(3) .insight-bar, .insight-bar-col:nth-child(3) .insight-bar-score { animation-delay: 70ms; }
.insight-bar-col:nth-child(4) .insight-bar, .insight-bar-col:nth-child(4) .insight-bar-score { animation-delay: 105ms; }
.insight-bar-col:nth-child(5) .insight-bar, .insight-bar-col:nth-child(5) .insight-bar-score { animation-delay: 140ms; }
.insight-bar-col:nth-child(6) .insight-bar, .insight-bar-col:nth-child(6) .insight-bar-score { animation-delay: 175ms; }
.insight-bar-col:nth-child(7) .insight-bar, .insight-bar-col:nth-child(7) .insight-bar-score { animation-delay: 210ms; }
/* Gaps here must match the corresponding .insight-bar-chart modifier's
   own gap exactly, or the day-of-week/date labels below drift out from
   under their bars. */
.insight-bar-labels { display: flex; margin-top: 4px; }
.insight-bar-labels--week { gap: 14px; }
.insight-bar-labels--day { gap: 10px; }
.insight-bar-label { flex: 1; text-align: center; font-size: 9.5px; color: var(--muted); }
.insight-bar-label--heavy { color: var(--warning, #f6bf26); font-weight: 600; }

@keyframes barScoreFadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes barGrow {
  from { transform: scaleY(0); }
  to   { transform: scaleY(1); }
}

.insight-ai-summary {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed var(--hair, #2a2a2a);
}
.insight-ai-summary-text {
  font-size: 13.5px;
  color: var(--text);
  line-height: 1.5;
}
.insight-ai-summary-text strong { color: var(--accent); font-weight: 600; }

.section-label {
  font-family: var(--font-heading);
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.header .btn-ghost {
  height: 34px;
  border-radius: 17px;
  background: var(--surface2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 500;
  padding: 0 14px;
  flex-shrink: 0;
  white-space: nowrap;
  margin-left: auto;
}
.header .btn-ghost:hover { opacity: 0.85; }

/* status indicator dot in header */
.header-status {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}

.home-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

/* --- Quick capture bar + inbox (Home) --- */
.capture-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border-radius: 14px;
  padding: 6px 6px 6px 14px;
  margin-bottom: 12px;
}
.capture-bar-icon { width: 17px; height: 17px; color: var(--accent); flex-shrink: 0; }
.capture-input {
  flex: 1;
  min-width: 0;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  padding: 8px 0;
}
.capture-input::placeholder { color: var(--muted); }
.capture-submit-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
}
.capture-submit-btn svg { width: 16px; height: 16px; }
.capture-submit-btn:disabled { opacity: 0.4; cursor: default; }

.capture-inbox-section { margin-bottom: 14px; }
.capture-inbox-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}
.capture-inbox-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-heading);
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.capture-schedule-all {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-body);
  padding: 0;
}
.capture-inbox-hint {
  font-size: 11px;
  color: var(--muted);
  opacity: 0.8;
  margin: 0 0 10px;
}
.capture-inbox-count {
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 999px;
}
.capture-swipe-wrap {
  position: relative;
  overflow: hidden;
  border-radius: 14px;
  margin-bottom: 8px;
}
.capture-swipe-wrap .capture-item { margin-bottom: 0; position: relative; z-index: 1; }
.capture-item {
  background: var(--surface);
  border-radius: 14px;
  padding: 12px 14px;
}
.capture-item-top { display: flex; align-items: flex-start; gap: 10px; }
.capture-item-text { flex: 1; min-width: 0; }
.capture-item-title { font-size: 13.5px; color: var(--text); word-break: break-word; }
.capture-item-age { font-size: 11px; color: var(--muted); margin-top: 2px; }
.capture-item-age.soon { color: var(--amber); }
.capture-dismiss-btn {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: none;
  border: none;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}
.capture-dismiss-btn svg { width: 13px; height: 13px; }
.capture-dismiss-btn:hover { color: var(--danger); }

.capture-swipe-bg {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  font-size: 13px;
  font-weight: 600;
  opacity: 0;
  transition: opacity 0.12s ease;
  border-radius: 14px;
}
.capture-swipe-bg-done {
  background: color-mix(in srgb, var(--success, #34a853) 30%, transparent);
  color: var(--success, #34a853);
  justify-content: flex-start;
  padding-left: 18px;
}
.capture-swipe-bg-schedule {
  background: var(--accent-soft);
  color: var(--accent);
  justify-content: flex-end;
  padding-right: 18px;
}
.capture-swipe-wrap.reveal-done .capture-swipe-bg-done { opacity: 1; }
.capture-swipe-wrap.reveal-schedule .capture-swipe-bg-schedule { opacity: 1; }

.capture-resolved-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: none;
  border: none;
  padding: 8px 4px 4px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  font-family: var(--font-body);
}
.capture-resolved-chevron { font-size: 10px; }
.capture-item-resolved { display: flex; align-items: center; justify-content: space-between; opacity: 0.75; }
.capture-resolved-badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
  flex-shrink: 0;
}
.capture-resolved-badge.done { background: color-mix(in srgb, var(--green) 20%, transparent); color: var(--green); }
.capture-resolved-badge.skipped { background: var(--surface2); color: var(--muted); }

/* --- Quick capture modal (FAB entry point) --- */
#capture-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
#capture-modal {
  width: 100%;
  max-width: 480px;
  background: var(--surface);
  border-top-left-radius: 24px;
  border-top-right-radius: 24px;
  padding: 20px 18px calc(24px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
}

#class-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
#class-modal {
  width: 100%;
  max-width: 480px;
  background: var(--surface);
  border-top-left-radius: 24px;
  border-top-right-radius: 24px;
  padding: 20px 18px calc(24px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
}

#capture-item-menu-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
#capture-item-menu {
  width: 100%;
  max-width: 480px;
  background: var(--surface);
  border-top-left-radius: 24px;
  border-top-right-radius: 24px;
  padding: 20px 18px calc(24px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
}

.school-hub-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-top: 4px;
}
.school-classes-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--hair);
  border-radius: 11px;
  padding: 8px 12px;
  font-size: 12.5px;
  color: var(--muted);
  cursor: pointer;
  font-family: var(--font-body);
  flex-shrink: 0;
  white-space: nowrap;
}
.school-classes-pill svg { width: 14px; height: 14px; flex-shrink: 0; }

/* Same gray pill as school-classes-pill above, but with a blue glow
   border instead of a plain hairline — this is a manual "regenerate the
   AI text right now" trigger (see api/regenerate-insights.js), not a
   routine navigation control, so it earns a touch more visual weight
   without breaking from the app's established pill-button language. */
.insight-regenerate-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: 11px;
  padding: 8px 12px;
  margin: 10px 0 14px;
  font-size: 12.5px;
  color: var(--muted);
  cursor: pointer;
  font-family: var(--font-body);
  white-space: nowrap;
  box-shadow: 0 0 9px color-mix(in srgb, var(--accent) 50%, transparent);
}
.insight-regenerate-pill svg { width: 14px; height: 14px; flex-shrink: 0; }
.insight-regenerate-pill:disabled { opacity: 0.6; cursor: default; box-shadow: none; }
.my-class-row {
  background: var(--surface);
  border-radius: 16px;
  padding: 14px 15px;
  margin-bottom: 10px;
}
.my-class-row.all-planned { opacity: 0.72; }
.my-class-top { cursor: pointer; }
.my-class-text { flex: 1; min-width: 0; }
.my-class-name-row { display: flex; align-items: center; gap: 8px; }
.my-class-color-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.my-class-name { font-size: 14.5px; font-weight: 600; color: var(--text); flex: 1; }
.my-class-summary-row { display: flex; align-items: center; gap: 8px; margin-top: 7px; }
.my-class-code {
  font-size: 11px;
  background: var(--surface2);
  color: var(--muted);
  padding: 3px 8px;
  border-radius: 6px;
  flex-shrink: 0;
}
.my-class-count { font-size: 12px; color: var(--muted); }
.my-class-notes {
  font-size: 12px;
  color: var(--muted);
  margin-top: 9px;
  padding-top: 9px;
  border-top: 1px solid var(--hair);
  line-height: 1.5;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.my-class-warning {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 9px;
  font-size: 11.5px;
  color: var(--amber);
}
.my-class-warning svg { width: 13px; height: 13px; flex-shrink: 0; }
.my-class-edit-btn {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: none;
  border: none;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}
.my-class-edit-btn svg { width: 14px; height: 14px; }
.my-class-edit-btn:hover { color: var(--accent); }

.my-class-deadlines { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--hair); }
.my-class-deadline-swipe-wrap {
  position: relative;
  overflow: hidden;
  border-radius: 10px;
  margin-bottom: 6px;
}
.my-class-deadline-swipe-wrap .my-class-deadline-row { margin-bottom: 0; position: relative; z-index: 1; }
.my-class-deadline-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--surface2);
  border-radius: 10px;
  padding: 9px 12px;
  cursor: pointer;
}
.my-class-deadline-title { font-size: 12.5px; color: var(--text); flex: 1; min-width: 0; }
.my-class-deadline-row.completed .my-class-deadline-title { color: var(--muted); text-decoration: line-through; }
.my-class-deadline-date { font-size: 11px; color: var(--muted); flex-shrink: 0; white-space: nowrap; }
.my-class-deadline-swipe-bg {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  padding-left: 16px;
  font-size: 12px;
  font-weight: 600;
  background: color-mix(in srgb, var(--success, #34a853) 30%, transparent);
  color: var(--success, #34a853);
  opacity: 0;
  transition: opacity 0.12s ease;
  border-radius: 10px;
}
.my-class-deadline-swipe-wrap.reveal-done .my-class-deadline-swipe-bg { opacity: 1; }

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--surface2);
  border: none;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
}
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn:hover { opacity: 0.85; }

.buffer-indicator {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11.5px;
  color: var(--muted);
}
.buffer-indicator .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
}
.buffer-indicator.active .dot { background: var(--green); }

/* --- Floating action button --- */
.fab-container {
  position: fixed;
  right: max(20px, env(safe-area-inset-right));
  bottom: calc(var(--tabbar-h) + 6px);
  z-index: 50;
}
.fab-backdrop {
  position: fixed;
  inset: 0;
  background: oklch(0.1 0.01 258 / 0.72);
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s;
}
.fab-container.open .fab-backdrop { opacity: 1; pointer-events: auto; }
.fab-main {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 8px 20px -4px oklch(0.4 0.15 253 / 0.6);
  position: relative;
  z-index: 2;
  transition: transform .18s;
}
.fab-main svg { width: 22px; height: 22px; }
.fab-container.open .fab-main { transform: rotate(45deg); }
.fab-menu {
  position: absolute;
  right: 0;
  bottom: 62px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 14px;
  pointer-events: none;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .15s, transform .15s;
}
.fab-container.open .fab-menu { opacity: 1; transform: translateY(0); pointer-events: auto; }
.fab-option {
  display: flex;
  align-items: center;
  gap: 10px;
  border: none;
  cursor: pointer;
  background: none;
  padding: 0;
}
.fab-option-label {
  background: var(--surface2);
  color: var(--text);
  border-radius: 20px;
  padding: 10px 16px;
  font-size: 13.5px;
  font-weight: 500;
  white-space: nowrap;
  box-shadow: 0 6px 16px -6px rgba(0,0,0,0.5);
  font-family: var(--font-body);
}
.fab-option-icon {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--surface2);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 6px 16px -6px rgba(0,0,0,0.5);
}
.fab-option-icon svg { width: 17px; height: 17px; }

.btn {
  width: 100%;
  padding: 15px 16px;
  border-radius: 16px;
  font-size: 15px;
  font-weight: 600;
  font-family: var(--font-heading);
  cursor: pointer;
  border: none;
  transition: opacity .15s, transform .05s;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { opacity: 0.92; }

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--hair);
  font-weight: 500;
}
.btn-secondary:hover { background: var(--surface2); }

.btn-ghost {
  background: none;
  border: none;
  font-size: 13.5px;
  color: var(--muted);
  cursor: pointer;
  padding: 6px 4px;
  font-family: var(--font-body);
}
.btn-ghost:hover { color: var(--text); }

.input {
  width: 100%;
  padding: 13px 14px;
  border: 1px solid var(--hair);
  border-radius: 12px;
  font-size: 15px;
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-appearance: none;
}
.input::placeholder { color: var(--muted); }
.input:focus { outline: none; border-color: var(--accent); }

select.input {
  color-scheme: dark;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23a8abba' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 38px;
}
input[type="date"].input::-webkit-calendar-picker-indicator,
input[type="time"].input::-webkit-calendar-picker-indicator { filter: invert(0.8); cursor: pointer; }

.divider-text {
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  margin: 20px 0 14px;
  position: relative;
}
.divider-text::before, .divider-text::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 32%;
  height: 1px;
  background: var(--hair);
}
.divider-text::before { left: 0; }
.divider-text::after { right: 0; }

.cal-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  border-radius: 14px;
  margin-bottom: 8px;
  background: var(--surface);
}
.cal-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.cal-name {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cal-select {
  font-size: 11.5px;
  font-weight: 500;
  border: none;
  border-radius: 8px;
  padding: 6px 10px;
  background: var(--surface2);
  color: var(--muted);
  cursor: pointer;
  font-family: var(--font-body);
}

.summary-card {
  background: none;
  padding: 0;
  margin-bottom: 4px;
  font-size: 11.5px;
  color: var(--muted);
}
.summary-card .label { display: none; }
.summary-card .value { font-size: 11.5px; font-weight: 400; color: var(--muted); }
#summary-cards { margin-bottom: 4px; }

.session-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 13px 14px;
  background: var(--surface);
  border-left: 3px solid var(--accent);
  border-radius: 14px;
  margin-bottom: 8px;
  cursor: pointer;
}
.session-item.unchecked { opacity: 0.45; border-left-color: var(--hair); }
.session-checkbox, .session-radio {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}
.session-info { flex: 1; min-width: 0; }
.session-title {
  font-size: 14.5px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 3px;
}
.session-time { font-size: 12px; color: var(--muted); }

.spinner {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 3px solid var(--surface2);
  border-top-color: var(--accent);
  animation: spin .8s linear infinite;
  margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (min-width: 481px) {
  #app {
    margin-top: 24px;
    margin-bottom: 24px;
    border-radius: 32px;
    box-shadow: 0 30px 60px -20px rgba(0,0,0,0.5);
    min-height: calc(100vh - 48px);
  }
}

/* --- Habits --- */
.day-picker { display: flex; flex-direction: column; gap: 6px; margin-bottom: 4px; }
.day-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface);
  border-radius: 12px;
  cursor: pointer;
  user-select: none;
}
.day-row:has(.day-checkbox:checked) { background: var(--accent-soft); }
.day-checkbox {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}
.day-label { font-size: 14px; color: var(--text); }

.color-picker { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 4px; }
.color-swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
}
.color-swatch.selected { border-color: var(--text); }

.habit-card {
  padding: 14px;
  background: var(--surface);
  border-radius: 14px;
  margin-bottom: 8px;
  cursor: pointer;
}
.habit-card-top { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.habit-card.habit-paused { opacity: 0.55; }
.habit-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.habit-name { font-size: 14.5px; font-weight: 500; color: var(--text); flex: 1; }
.habit-meta { font-size: 11.5px; color: var(--muted); line-height: 1.5; }

.priority-badge {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .03em;
  padding: 3px 9px;
  border-radius: 8px;
  flex-shrink: 0;
}
.priority-low { background: var(--surface2); color: var(--muted); }
.priority-medium { background: color-mix(in srgb, var(--amber) 20%, transparent); color: var(--amber); }
.priority-high { background: color-mix(in srgb, var(--danger) 20%, transparent); color: var(--danger); }

/* --- School Hub --- */
.school-card {
  padding: 13px 14px;
  background: var(--surface);
  border-radius: 14px;
  margin-bottom: 8px;
  cursor: pointer;
}
.school-status-tabs {
  display: flex;
  background: var(--surface);
  border-radius: 12px;
  padding: 3px;
  margin: 14px 0 10px;
  gap: 2px;
}
.school-status-tab {
  flex: 1;
  text-align: center;
  padding: 7px 0;
  border-radius: 9px;
  background: none;
  border: none;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  font-family: var(--font-body);
}
.school-status-tab.active { background: var(--surface2); color: var(--text); }
.school-status-tab span { font-size: 11px; }
.school-status-tab.active span { color: var(--accent); font-weight: 600; }

/* Solid warning fill whenever a deadline needs sessions — replaces the
   old dismissible banner as the "you can't miss this" signal, but as a
   permanent property of the tab itself rather than a one-time notice. */
.school-status-tab.tab-alert,
.school-status-tab.tab-alert.active {
  background: var(--warning, #f6bf26);
  color: #1a1400;
  font-weight: 700;
}
.school-status-tab.tab-alert span { color: #1a1400; font-weight: 700; }

.school-class-chips {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 14px;
  scrollbar-width: none;
}
.school-class-chips::-webkit-scrollbar { display: none; }
.school-class-chip {
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 9px;
  border: none;
  white-space: nowrap;
  flex-shrink: 0;
  cursor: pointer;
  font-family: var(--font-body);
}
.school-class-chip.active { background: var(--accent-soft); color: var(--accent); font-weight: 500; }

.school-group-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--muted);
  text-transform: uppercase;
  margin: 16px 0 8px;
}
.school-group-label:first-child { margin-top: 4px; }

.school-card {
  padding: 14px 15px;
  background: var(--surface);
  border-radius: 16px;
  margin-bottom: 10px;
  cursor: pointer;
}
.school-card--warn { border-left: 3px solid var(--warning, #f6bf26); }
.school-card-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.school-title { font-size: 14.5px; font-weight: 600; color: var(--text); }
.school-due-text { font-size: 12px; font-weight: 500; color: var(--muted); white-space: nowrap; flex-shrink: 0; }
.school-due-text.warn { color: var(--warning, #f6bf26); }
.school-meta { font-size: 12px; color: var(--muted); margin-top: 3px; }

.school-progress-row { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.school-progress-bar { flex: 1; height: 4px; border-radius: 2px; background: var(--surface2); overflow: hidden; }
.school-progress-fill { height: 100%; background: var(--green); border-radius: 2px; }
.school-progress-text { font-size: 11.5px; color: var(--muted); white-space: nowrap; flex-shrink: 0; }

.school-quick-actions { display: flex; gap: 8px; margin-top: 12px; }
.school-quick-plan-btn {
  flex: 1;
  background: var(--surface2);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 500;
  border: none;
  border-radius: 10px;
  padding: 9px;
  cursor: pointer;
  font-family: var(--font-body);
}
.school-adjust-btn {
  background: none;
  color: var(--muted);
  font-size: 12.5px;
  border: 1px solid var(--hair);
  border-radius: 10px;
  padding: 9px 12px;
  cursor: pointer;
  font-family: var(--font-body);
}

.deadline-progress-row { display: flex; align-items: center; gap: 10px; margin-top: 16px; }
.deadline-progress-bar {
  flex: 1;
  height: 5px;
  border-radius: 3px;
  background: var(--surface2);
  overflow: hidden;
}
.deadline-progress-fill { height: 100%; background: var(--green); border-radius: 3px; transition: width 0.3s ease; }
.deadline-progress-text { font-size: 12px; color: var(--muted); white-space: nowrap; flex-shrink: 0; }

.deadline-session-swipe-wrap {
  position: relative;
  overflow: hidden;
  border-radius: 13px;
  margin-bottom: 8px;
}
.deadline-session-swipe-wrap .deadline-session-row { margin-bottom: 0; position: relative; z-index: 1; }
.deadline-session-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border-radius: 13px;
  padding: 12px 14px;
}
.deadline-session-check {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1.5px solid var(--hair);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.deadline-session-row.done .deadline-session-check {
  border: none;
  background: var(--green);
  color: var(--bg);
}
.deadline-session-row.done .deadline-session-check svg { width: 11px; height: 11px; }
.deadline-session-time { flex: 1; font-size: 13.5px; color: var(--text); }
.deadline-session-row.done .deadline-session-time { color: var(--muted); }
.deadline-session-done-label { font-size: 11.5px; color: var(--green); flex-shrink: 0; }
.deadline-session-menu-btn {
  width: 24px;
  height: 24px;
  border-radius: 7px;
  background: var(--surface2);
  border: none;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}
.deadline-session-menu-btn svg { width: 13px; height: 13px; }
.deadline-session-swipe-bg {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  font-size: 13px;
  font-weight: 600;
  opacity: 0;
  transition: opacity 0.12s ease;
  border-radius: 13px;
}
.deadline-session-swipe-bg-done {
  background: color-mix(in srgb, var(--green) 30%, transparent);
  color: var(--green);
  justify-content: flex-start;
  padding-left: 18px;
}
.deadline-session-swipe-bg-delete {
  background: color-mix(in srgb, var(--danger, #e67c73) 30%, transparent);
  color: var(--danger, #e67c73);
  justify-content: flex-end;
  padding-right: 18px;
}
.deadline-session-swipe-wrap.reveal-done .deadline-session-swipe-bg-done { opacity: 1; }
.deadline-session-swipe-wrap.reveal-delete .deadline-session-swipe-bg-delete { opacity: 1; }


/* --- Agenda & History --- */
.agenda-day-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  margin: 16px 0 8px;
}
.agenda-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface);
  border-left: 3px solid var(--accent);
  border-radius: 14px;
  margin-bottom: 8px;
  cursor: pointer;
}
.agenda-item.past { opacity: 0.5; }
.agenda-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; background: var(--green); }
.agenda-info { flex: 1; min-width: 0; }
.agenda-title {
  font-size: 14.5px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.agenda-time { font-size: 12px; color: var(--muted); margin-top: 2px; }
.agenda-empty { font-size: 13px; color: var(--muted); padding: 10px 2px; }

.needs-attention-label { color: var(--warning, #f6bf26); }
.needs-attention-hint { font-size: 12px; color: var(--muted); margin: -4px 0 10px; }
.needs-attention-item {
  background: color-mix(in srgb, var(--warning, #f6bf26) 8%, var(--surface));
}

/* Days-left countdown on a "needs your attention" row — filled (yellow)
   dots count down to empty (gray) as each day passes without the session
   being marked done or skipped, matching the server's own auto-miss
   timing (see attentionCountdown in app.js) so it's never showing a
   number that doesn't match what will actually happen. */
.attention-countdown {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 6px;
}
.attention-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--hair, #3a3a3a);
  flex-shrink: 0;
}
.attention-dot-left { background: var(--warning, #f6bf26); }

.run-card {
  padding: 13px 14px;
  background: var(--surface);
  border-radius: 14px;
  margin-bottom: 8px;
}
.run-card-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.run-date { font-size: 14px; font-weight: 500; color: var(--text); }
.run-source {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 3px 9px;
  border-radius: 8px;
}
.run-source.auto { background: color-mix(in srgb, var(--green) 20%, transparent); color: var(--green); }
.run-source.manual { background: var(--accent-soft); color: var(--accent); }
.run-source.backfill { background: var(--surface2); color: var(--muted); }
.run-summary { font-size: 12px; color: var(--muted); line-height: 1.55; }

/* --- Bottom tab bar --- */
.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: flex;
  justify-content: center;
  padding: 10px max(10px, env(safe-area-inset-left)) calc(10px + env(safe-area-inset-bottom));
  z-index: 40;
  pointer-events: none;
}
.tabbar-inner {
  width: 100%;
  max-width: 440px;
  background: var(--surface);
  border-radius: 20px;
  display: flex;
  justify-content: space-around;
  padding: 8px;
  box-shadow: 0 10px 30px -10px rgba(0,0,0,0.6);
  pointer-events: auto;
}
.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  border-radius: 14px;
  color: var(--muted);
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font-body);
}
.tab svg { width: 20px; height: 20px; }
.tab span { font-size: 10.5px; }
.tab.active { background: var(--surface2); color: var(--accent); }
.tab.active span { font-weight: 500; }

/* --- Session action menu, choice mode, streaks, undo --- */
#session-menu-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
#session-menu {
  width: 100%;
  max-width: 480px;
  background: var(--surface);
  border-top-left-radius: 24px;
  border-top-right-radius: 24px;
  padding: 20px 18px calc(24px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.session-menu-title {
  font-family: var(--font-heading);
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  text-align: center;
  margin-bottom: 6px;
}
.best-badge {
  font-size: 10px;
  font-weight: 600;
  color: var(--green);
  background: color-mix(in srgb, var(--green) 18%, transparent);
  padding: 2px 8px;
  border-radius: 8px;
  margin-left: 6px;
  vertical-align: middle;
}
.regen-btn {
  background: var(--surface2);
  border: none;
  border-radius: 10px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 14px;
  flex-shrink: 0;
  align-self: center;
}
.regen-btn:hover { opacity: 0.85; }
.streak-badge { color: var(--amber); }

/* --- Habits screen sub-tabs (Habits / Streaks) --- */
.subtab-bar {
  display: flex;
  background: var(--surface2);
  border-radius: 12px;
  padding: 3px;
  margin: 14px 0 16px;
  gap: 2px;
}
.subtab {
  flex: 1;
  border: none;
  background: none;
  color: var(--muted);
  font-family: var(--font-body);
  font-size: 13.5px;
  font-weight: 600;
  padding: 9px 0;
  border-radius: 9px;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}
.subtab.active {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 10px color-mix(in srgb, var(--accent) 45%, transparent);
}

/* --- Streaks view --- */
.streak-hero {
  text-align: center;
  padding: 24px 16px;
  background: linear-gradient(160deg, color-mix(in srgb, var(--amber) 16%, var(--surface)), var(--surface));
  border-radius: 20px;
  margin-bottom: 16px;
}
.streak-hero-flame { font-size: 32px; line-height: 1; margin-bottom: 6px; }
.streak-hero-num { font-family: var(--font-heading); font-size: 40px; font-weight: 700; color: var(--text); line-height: 1; }
.streak-hero-unit { font-size: 12.5px; color: var(--muted); margin-top: 4px; text-transform: uppercase; letter-spacing: .04em; }
.streak-hero-habit {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  background: var(--surface2);
  padding: 5px 12px;
  border-radius: 999px;
}
.streak-hero-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

.streak-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--surface);
  border-radius: 14px;
  margin-bottom: 8px;
  cursor: pointer;
}
.streak-row-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.streak-row-name { flex: 1; font-size: 14px; font-weight: 500; color: var(--text); }
.streak-row-paused-tag {
  font-size: 9.5px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--surface2);
  padding: 2px 6px;
  border-radius: 6px;
  margin-left: 6px;
}
.streak-row.streak-row-paused { opacity: 0.55; }
.streak-row-value { font-size: 14px; font-weight: 600; color: var(--amber); flex-shrink: 0; }
.streak-row-value.streak-row-value-zero { color: var(--muted); font-weight: 400; }

/* --- Reminders editor (habit form + Add Task) --- */
.reminder-row {
  background: var(--surface2);
  border-radius: 12px;
  padding: 10px;
  margin-bottom: 8px;
}
.reminder-row-top { display: flex; align-items: center; gap: 8px; }
.reminder-bell { width: 18px; height: 18px; color: var(--muted); flex-shrink: 0; }
.reminder-row-top select.reminder-method { flex: 1; }
.reminder-remove {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: none;
  border: none;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
}
.reminder-remove svg { width: 14px; height: 14px; }
.reminder-remove:hover { color: var(--danger); }
.reminder-row-bottom { display: flex; gap: 8px; margin-top: 8px; padding-left: 26px; }
.reminder-row-bottom input.reminder-amount { width: 70px; flex-shrink: 0; }
.reminder-row-bottom select.reminder-unit { flex: 1; }
.add-reminder-link {
  background: none;
  border: none;
  color: var(--accent);
  font-family: var(--font-body);
  font-size: 13.5px;
  font-weight: 600;
  padding: 6px 0;
  cursor: pointer;
}
.add-reminder-link:hover { opacity: 0.85; }



/* --- Habit sessions timeline (edit-habit screen) --- */
.habit-timeline-stats {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  padding: 12px 14px;
  background: var(--surface2);
  border-radius: 14px;
}
.habit-timeline-stat { display: flex; flex-direction: column; align-items: center; flex-shrink: 0; }
.habit-timeline-stat-num { font-family: var(--font-heading); font-size: 19px; font-weight: 600; color: var(--text); line-height: 1; }
.habit-timeline-stat-label { font-size: 9.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-top: 3px; }
.habit-timeline-progress { flex: 1; height: 6px; background: var(--surface); border-radius: 999px; overflow: hidden; }
.habit-timeline-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--green), color-mix(in srgb, var(--green) 65%, var(--accent) 35%));
  border-radius: 999px;
  transition: width 0.4s ease;
}

.habit-timeline-today {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--accent);
}
.habit-timeline-today::before, .habit-timeline-today::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--accent-soft);
}

/* Generic version of .habit-timeline-today's divider look, for timelines
   that aren't date-based (e.g. the class detail screen's done/upcoming
   assignment split). Kept as its own class rather than reusing
   .habit-timeline-today directly so the name doesn't lie about what it's
   for in a non-habit context. */
.timeline-divider {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--accent);
}
.timeline-divider::before, .timeline-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--accent-soft);
}

.habit-timeline-node { display: flex; gap: 12px; cursor: pointer; }
.habit-timeline-rail { display: flex; flex-direction: column; align-items: center; width: 14px; flex-shrink: 0; }
.habit-timeline-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--hair);
  background: var(--bg);
  flex-shrink: 0;
  margin-top: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.habit-timeline-dot svg { width: 8px; height: 8px; }
.habit-timeline-dot.done { border-color: var(--green); background: var(--green); }
.habit-timeline-dot.missed { border-color: var(--warning, #f6bf26); background: var(--warning, #f6bf26); }
.habit-timeline-dot.skipped { border-color: var(--muted); background: var(--muted); }
.habit-timeline-line { flex: 1; width: 2px; background: var(--hair); margin: 2px 0; min-height: 18px; }
.habit-timeline-content { flex: 1; padding-bottom: 16px; min-width: 0; }
.habit-timeline-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.habit-timeline-date { font-size: 13.5px; font-weight: 500; color: var(--text); }
.habit-timeline-time { font-size: 12px; color: var(--muted); margin-top: 2px; }
.habit-timeline-badge {
  font-size: 9.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .03em;
  padding: 2px 7px;
  border-radius: 7px;
  flex-shrink: 0;
}
.habit-timeline-badge.done { background: color-mix(in srgb, var(--green) 20%, transparent); color: var(--green); }
.habit-timeline-badge.missed { background: color-mix(in srgb, var(--warning, #f6bf26) 20%, transparent); color: var(--warning, #f6bf26); }
.habit-timeline-badge.skipped { background: var(--surface2); color: var(--muted); }

.run-source.undo { background: color-mix(in srgb, var(--danger) 18%, transparent); color: var(--danger); }
.run-source.repair { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }
.run-source.autoplan { background: color-mix(in srgb, var(--warning, #f6bf26) 18%, transparent); color: var(--warning, #f6bf26); }
.run-source.capture { background: color-mix(in srgb, var(--violet) 20%, transparent); color: var(--violet); }
.run-undo-btn {
  margin-top: 8px;
  background: none;
  border: 1px solid var(--hair);
  color: var(--danger);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 12px;
  cursor: pointer;
  font-family: var(--font-body);
}
.run-undo-btn:hover { background: color-mix(in srgb, var(--danger) 10%, transparent); }

/* --- Plan tab hero card --- */
.plan-hero-card {
  background: var(--accent-soft);
  border-radius: 16px;
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  margin-bottom: 20px;
  border: none;
  width: 100%;
  text-align: left;
  font-family: var(--font-body);
}
.plan-hero-card .icon {
  width: 22px; height: 22px; flex-shrink: 0; color: var(--accent);
}
.plan-hero-card .title { font-size: 14px; font-weight: 600; color: var(--accent); }
.plan-hero-card .desc { font-size: 11.5px; color: var(--muted); margin-top: 1px; }

/* --- Grouped form sections (Habit form, Settings) --- */
.form-card {
  background: var(--surface);
  border-radius: 18px;
  padding: 16px;
  margin-bottom: 12px;
}
.form-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.form-card-header.tight { margin-bottom: 4px; }
.form-card-icon {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: var(--surface2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  flex-shrink: 0;
}
.form-card-icon svg { width: 17px; height: 17px; }
.form-card-title {
  font-family: var(--font-heading);
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
.form-card-subtitle { font-size: 11.5px; color: var(--muted); margin-top: 1px; line-height: 1.4; }
.form-card-divider { height: 1px; background: var(--hair); margin: 14px 0; border: none; }
.section-header-plain {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 20px 0 8px;
}
.section-header-plain:first-child { margin-top: 0; }
.section-header-plain .form-card-icon { width: 28px; height: 28px; }
.section-header-plain .form-card-icon svg { width: 15px; height: 15px; }
.section-header-plain .form-card-title { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-family: var(--font-body); font-weight: 600; }

.account-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  border-radius: 14px;
  padding: 13px 14px;
  margin-bottom: 8px;
  cursor: pointer;
}
.account-row span { font-size: 14px; font-weight: 500; color: var(--text); }
.account-row .btn-ghost { padding: 0; width: auto; height: auto; border-radius: 0; background: none; color: var(--accent); font-size: 13px; }


/* --- Phase 4: limits, autopilot, per-day windows --- */
.day-picker-inline { display: flex; gap: 5px; }
.day-chip-sm {
  flex: 1;
  text-align: center;
  padding: 8px 0;
  border-radius: 8px;
  background: var(--surface-2, #252525);
  border: 1px solid var(--border, #333);
  color: var(--text-dim, #999);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}
.day-chip-sm.selected {
  background: color-mix(in srgb, var(--danger, #e67c73) 20%, transparent);
  border-color: var(--danger, #e67c73);
  color: var(--danger, #e67c73);
}
.toggle-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 13px;
  color: var(--text, #e8e8e8);
  cursor: pointer;
  line-height: 1.45;
}
.toggle-row input { width: 18px; height: 18px; accent-color: var(--accent, #1a73e8); flex-shrink: 0; margin-top: 1px; }
.radio-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13.5px;
  color: var(--text, #e8e8e8);
  cursor: pointer;
}
.radio-row input { width: 18px; height: 18px; accent-color: var(--accent, #1a73e8); flex-shrink: 0; }

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  cursor: pointer;
}
.switch-label { display: flex; flex-direction: column; gap: 3px; }
.switch-label strong { font-size: 14px; color: var(--text); font-weight: 500; }
.switch-sublabel { font-size: 11.5px; color: var(--muted); line-height: 1.4; }
.switch { position: relative; display: inline-block; width: 44px; height: 26px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch-track {
  position: absolute;
  inset: 0;
  background: var(--surface2);
  border-radius: 999px;
  transition: background 0.2s ease;
}
.switch-track::before {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.switch input:checked + .switch-track { background: var(--accent, #1a73e8); }
.switch input:checked + .switch-track::before { transform: translateX(18px); }
.day-chip-sm.accent.selected {
  background: color-mix(in srgb, var(--accent, #1a73e8) 20%, transparent);
  border-color: var(--accent, #1a73e8);
  color: var(--accent, #1a73e8);
}
.perday-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.perday-day { width: 84px; font-size: 13px; color: var(--text-dim, #999); flex-shrink: 0; }
.perday-row input[type="time"] { flex: 1; }


/* --- Full agenda: external events + swipe actions --- */
.agenda-item.app-item, .agenda-item.external-item { border-left: 3px solid transparent; }
.agenda-item.external-item { opacity: 0.82; }
.agenda-item.external-item .agenda-title { font-weight: 400; }
.agenda-item.external-item { cursor: default; }

.swipe-wrap {
  position: relative;
  overflow: hidden;
  border-radius: 10px;
  margin-bottom: 6px;
}
.swipe-wrap .agenda-item { margin-bottom: 0; position: relative; z-index: 1; }
.swipe-bg {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  font-size: 13px;
  font-weight: 600;
  opacity: 0;
  transition: opacity 0.12s ease;
  border-radius: 10px;
}
.swipe-bg-done {
  background: color-mix(in srgb, var(--success, #34a853) 30%, transparent);
  color: var(--success, #34a853);
  justify-content: flex-start;
  padding-left: 18px;
}
.swipe-bg-skip {
  background: color-mix(in srgb, var(--warning, #f6bf26) 26%, transparent);
  color: var(--warning, #f6bf26);
  justify-content: flex-end;
  padding-right: 18px;
}
.swipe-wrap.reveal-done .swipe-bg-done { opacity: 1; }
.swipe-wrap.reveal-skip .swipe-bg-skip { opacity: 1; }


/* ============================================================
   Premium motion & polish (screens, cards, presses, sheet)
   ============================================================ */

/* Screen transitions: soft fade + rise on every tab/screen change */
@keyframes screenIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.screen { animation: screenIn 0.24s cubic-bezier(0.2, 0.7, 0.3, 1); }

/* List items staggering in (delay set per-item in JS) */
@keyframes cardIn {
  from { opacity: 0; transform: translateY(9px); }
  to   { opacity: 1; transform: translateY(0); }
}
.anim-in { animation: cardIn 0.3s cubic-bezier(0.2, 0.7, 0.3, 1) both; }

/* Press feedback: quiet scale-down on anything tappable */
.btn, .btn-ghost, .tab, .fab-option, .fab-main, .icon-btn,
.agenda-item.app-item, .habit-card, .run-card, .school-card, .streak-row, .subtab,
.menu-action, .account-row, .day-row, .plan-hero-card, .run-undo-btn {
  transition: transform 0.13s ease, opacity 0.13s ease;
}
.btn:active, .btn-ghost:active, .tab:active, .fab-option:active, .fab-main:active, .icon-btn:active,
.agenda-item.app-item:active, .habit-card:active, .run-card:active, .school-card:active, .streak-row:active,
.menu-action:active, .account-row:active, .day-row:active,
.plan-hero-card:active, .run-undo-btn:active {
  transform: scale(0.97);
}
.habit-timeline-content { transition: opacity 0.13s ease; }
.habit-timeline-node:active .habit-timeline-content { opacity: 0.65; }

/* Action sheet: backdrop fade + sheet spring-up */
@keyframes backdropIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes sheetUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}
#session-menu-backdrop:not(.hidden) { animation: backdropIn 0.2s ease-out; }
#session-menu-backdrop:not(.hidden) #session-menu {
  animation: sheetUp 0.32s cubic-bezier(0.32, 0.72, 0.28, 1.04);
}
#capture-modal-backdrop:not(.hidden) { animation: backdropIn 0.2s ease-out; }
#capture-modal-backdrop:not(.hidden) #capture-modal {
  animation: sheetUp 0.32s cubic-bezier(0.32, 0.72, 0.28, 1.04);
}
#class-modal-backdrop:not(.hidden) { animation: backdropIn 0.2s ease-out; }
#class-modal-backdrop:not(.hidden) #class-modal {
  animation: sheetUp 0.32s cubic-bezier(0.32, 0.72, 0.28, 1.04);
}
#capture-item-menu-backdrop:not(.hidden) { animation: backdropIn 0.2s ease-out; }
#capture-item-menu-backdrop:not(.hidden) #capture-item-menu {
  animation: sheetUp 0.32s cubic-bezier(0.32, 0.72, 0.28, 1.04);
}

/* ============================================================
   Action sheet redesign
   ============================================================ */
.sheet-grabber {
  /* The visible bar stays exactly 38x4px (drawn via ::before below) —
     this box is the actual touch target, made much bigger than the line
     you can see so a drag-to-dismiss attempt doesn't need pixel-perfect
     accuracy to land on it. touch-action: none stops the browser from
     ever treating a drag that starts here as a page scroll/refresh
     gesture, which is the more reliable, compositor-level version of
     what the JS's preventDefault() is also trying to do. */
  width: 100%;
  height: 28px;
  margin: -12px 0 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
}
.sheet-grabber::before {
  content: '';
  width: 38px;
  height: 4px;
  border-radius: 2px;
  background: var(--border, #3a3a3a);
}
.session-menu-title {
  font-size: 17px;
  font-weight: 650;
  color: var(--text, #f0f0f0);
  text-align: center;
  margin-bottom: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.session-menu-subtitle {
  font-size: 13px;
  color: var(--text-dim, #999);
  text-align: center;
  margin-bottom: 16px;
}
.menu-action {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 14px 16px;
  background: var(--surface-2, #252525);
  border: 1px solid var(--border, #2e2e2e);
  border-radius: 12px;
  color: var(--text, #e8e8e8);
  font-size: 14.5px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
}
.menu-action + .menu-action { margin-top: 8px; }
.menu-icon {
  width: 21px;
  height: 21px;
  flex-shrink: 0;
  display: inline-flex;
  color: var(--text-dim, #a8a8a8);
}
.menu-icon svg { width: 100%; height: 100%; }
.menu-action-danger { color: var(--danger, #e67c73); }
.menu-action-danger .menu-icon { color: var(--danger, #e67c73); }
.menu-action-success { color: var(--success, #34a853); }
.menu-action-success .menu-icon { color: var(--success, #34a853); }
.menu-action-warning { color: var(--warning, #f6bf26); }
.menu-action-warning .menu-icon { color: var(--warning, #f6bf26); }
.menu-action-accent { color: var(--accent); }
.menu-action-accent .menu-icon { color: var(--accent); }

/* ============================================================
   Settings: room to breathe
   ============================================================ */
#screen-settings .section-label {
  margin-top: 34px;
  padding-top: 22px;
  border-top: 1px solid color-mix(in srgb, var(--border, #2e2e2e) 70%, transparent);
  letter-spacing: 0.01em;
}
#screen-settings .header + .section-label {
  margin-top: 8px;
  padding-top: 0;
  border-top: none;
}
#screen-settings .hint { line-height: 1.55; margin-bottom: 10px; }
#screen-settings .input,
#screen-settings select { margin-bottom: 6px; }
#screen-settings .toggle-row { margin-top: 16px; margin-bottom: 4px; }
#screen-settings .account-row { margin-bottom: 8px; }
#screen-settings #btn-save-settings { margin-top: 30px; }

/* Respect users who prefer less motion */
@media (prefers-reduced-motion: reduce) {
  .screen, .anim-in, .insight-bar, .insight-bar-score,
  #session-menu-backdrop:not(.hidden),
  #session-menu-backdrop:not(.hidden) #session-menu,
  #capture-modal-backdrop:not(.hidden),
  #capture-modal-backdrop:not(.hidden) #capture-modal,
  #class-modal-backdrop:not(.hidden),
  #class-modal-backdrop:not(.hidden) #class-modal,
  #capture-item-menu-backdrop:not(.hidden),
  #capture-item-menu-backdrop:not(.hidden) #capture-item-menu {
    animation: none !important;
  }
  .btn:active, .tab:active, .agenda-item.app-item:active,
  .habit-card:active, .menu-action:active, .icon-btn:active, .school-card:active, .streak-row:active {
    transform: none !important;
  }
  .habit-timeline-node:active .habit-timeline-content { opacity: 1 !important; }
  .habit-timeline-progress-fill { transition: none !important; }
}

.update-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 10px 16px;
  padding-top: calc(10px + env(safe-area-inset-top));
  background: var(--accent);
  color: white;
  font-size: 13px;
  font-weight: 600;
}
.update-banner button {
  background: rgba(255,255,255,0.22);
  border: none;
  border-radius: 8px;
  padding: 5px 12px;
  color: white;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  font-family: var(--font-body);
  flex-shrink: 0;
}
