/* ============================================================
   Unschool — Design Tokens & Styles
   Editorial calm. Warm ivory, charcoal, one burnt-coral accent.
   Typography-first. Light + dark. Subtle functional motion only.
   ============================================================ */

:root {
  /* Type — warm editorial serif + humanist sans (source design system) */
  --font-display: "Zodiak", Georgia, "Times New Roman", serif;
  --font-body: "General Sans", system-ui, -apple-system, sans-serif;

  /* Light — warm paper / near-black ink. Accent DEFAULTS TO INK; colour is
     introduced only per-subject at runtime (restrained editorial system). */
  --bg: #ece5d8;          /* paper-2 — page behind the phone */
  --surface: #f4efe6;     /* paper — the reading surface (phone) */
  --surface-2: #ece5d8;   /* recessed panels, inputs */
  --card: #fbf8f1;        /* lifted card tone (slightly above paper) */
  --ink: #1c1a17;         /* near-black ink */
  --ink-muted: #443f38;   /* ink-2, secondary */
  --ink-faint: #746c60;   /* ink-3, tertiary / placeholders */
  --line: #d8cfbe;        /* rule / hairlines */
  --line-strong: #c3b8a2;
  --field: #ffffff;
  --accent: #1c1a17;      /* ink by default — chrome is calm ink, not coral */
  --accent-soft: #e7dfce; /* neutral warm tint fill */
  --accent-ink: #443f38;  /* muted ink for eyebrows / links */
  --brand: #b5533c;       /* Threshold burnt-coral — brand mark + focus */
  --brand-ink: #9c4230;   /* AA-safe coral for text on paper */
  --brand-soft: #f0dcd3;  /* faint coral wash for bounded surfaces */
  --bezel: #2b2925;       /* dark phone bezel ring */
  --shadow: 0 1px 2px rgba(28, 26, 23, 0.05), 0 12px 30px rgba(28, 26, 23, 0.07);
  --shadow-lift: 0 2px 4px rgba(28, 26, 23, 0.06), 0 22px 48px rgba(28, 26, 23, 0.12);
  --radius: 44px;
  --radius-sm: 12px;
  --ok: #3f7a34;          /* quiz-correct green (AA on paper) */
  --err: #b23b2e;         /* quiz-incorrect red (AA on paper) */
}

.dark {
  --bg: #100e0a;
  --surface: #16140f;
  --surface-2: #201d17;
  --card: #201d17;
  --ink: #f1ece1;
  --ink-muted: #d3cbba;
  --ink-faint: #9a9182;
  --line: #34302a;
  --line-strong: #47423a;
  --field: #1b1813;
  --accent: #f1ece1;
  --accent-soft: #2a2620;
  --accent-ink: #d3cbba;
  --brand: #e0876f;       /* brightened coral for dark ground (AA on #100e0a) */
  --brand-ink: #e0876f;
  --brand-soft: #3a241d;  /* deep coral wash */
  --bezel: #000000;
  --shadow: 0 1px 2px rgba(0,0,0,0.4), 0 14px 34px rgba(0,0,0,0.5);
  --shadow-lift: 0 2px 4px rgba(0,0,0,0.5), 0 24px 52px rgba(0,0,0,0.6);
  --ok: #6bbf68;          /* brightened green for dark ground */
  --err: #e0705f;         /* brightened red for dark ground */
}

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

html, body, #root { height: 100%; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden; /* no page scroll, ever */
  transition: background 0.4s ease, color 0.4s ease;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
a { color: var(--accent-ink); }

/* ---------- Stage (desktop centers phone; mobile = full viewport) ---------- */
.stage {
  height: 100dvh;
  width: 100vw;
  display: grid;
  place-items: center;
  padding: 24px;
  position: relative;
}

/* subtle editorial texture behind the phone on desktop */
.stage::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(120% 90% at 50% -10%, rgba(184, 72, 46, 0.05), transparent 60%);
  pointer-events: none;
}

.stage-label {
  position: absolute;
  bottom: 20px;
  left: 0; right: 0;
  text-align: center;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

/* ---------- Phone shell (device: bezel ring + print grain) ---------- */
.phone {
  position: relative;
  width: 390px;
  height: 844px;
  max-height: calc(100dvh - 48px);
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow:
    0 0 0 2px var(--line-strong),
    0 0 0 12px var(--bezel),
    var(--shadow-lift);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* print-like grain over the whole device surface */
.phone::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.5;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.035'/%3E%3C/svg%3E");
  z-index: 60;
}
.dark .phone::after { mix-blend-mode: screen; opacity: 0.35; }

/* cosmetic iOS-style status bar pinned at the top of the device */
.statusbar {
  flex: 0 0 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px 0 26px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: 0.02em;
  z-index: 20;
}
.statusbar .sb-icons { display: flex; gap: 6px; align-items: center; }
.statusbar svg { display: block; }

/* On real mobile, dissolve the frame into the full viewport */
@media (max-width: 480px) {
  .stage { padding: 0; }
  .stage::before { display: none; }
  .stage-label { display: none; }
  .phone {
    width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
    box-shadow: none;
  }
  .phone::after { border-radius: 0; }
}

/* ---------- Header ---------- */
.hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 8px;
  flex: 0 0 auto;
}
.hdr-brand { display: flex; align-items: center; gap: 9px; }
.hdr-brand .mark { color: var(--brand); }

/* Global keyboard focus — one coral ring across the app */
:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 4px;
}
.hdr-wordmark {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 17px;
  letter-spacing: -0.01em;
}
.hdr-actions { display: flex; align-items: center; gap: 2px; }

/* lesson header: course button + lesson id/theme + actions */
.hdr-course {
  display: flex; align-items: center; gap: 7px;
  padding: 7px 12px 7px 9px;
  border-radius: 999px;
  color: var(--ink-muted);
  border: 1px solid var(--line);
  background: var(--surface);
  transition: all 0.18s ease;
}
.hdr-course:hover { border-color: var(--line-strong); color: var(--ink); }
.hdr-course:active { transform: scale(0.96); }
.hdr-course-label {
  font-size: 12px; font-weight: 600; letter-spacing: 0.02em;
}
.hdr-spacer { flex: 1 1 auto; min-width: 0; }
.hdr-overview { padding: 18px 22px 8px; }
.icon-btn {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: 50%;
  color: var(--ink-muted);
  transition: background 0.2s ease, color 0.2s ease;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn:active { transform: scale(0.92); }
.icon-btn.is-on { color: var(--accent); }

/* ---------- Progress rail ---------- */
.progress {
  display: flex;
  gap: 6px;
  padding: 0 20px 4px;
  flex: 0 0 auto;
}
/* Each segment is a button: a thin visible bar (.pip-bar) inside a taller,
   transparent hit area so the rail stays slim while every card is easy to tap
   or click. Jumping to a card never completes the lesson (go() only clamps). */
.pip {
  flex: 1;
  min-width: 0;
  appearance: none;
  border: 0;
  background: none;
  margin: 0;
  padding: 9px 0; /* generous vertical tap target around the slim bar */
  display: flex;
  align-items: center;
  cursor: pointer;
}
.pip-bar {
  display: block;
  width: 100%;
  height: 3.3px; /* ~10% thicker than the prior 3px accent line; no layout shift */
  border-radius: 2px;
  background: var(--line-strong);
  position: relative;
  overflow: hidden;
  transition: background 0.3s ease;
}
.pip.done .pip-bar { background: var(--sub-accent, var(--accent)); }
.pip.active .pip-bar { background: var(--sub-accent, var(--accent)); }
.pip.active .pip-bar::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--accent);
}
.pip:focus-visible { outline: none; }
.pip:focus-visible .pip-bar {
  outline: 2px solid var(--brand);
  outline-offset: 3px;
  border-radius: 2px;
}
.pip:hover .pip-bar { background: color-mix(in srgb, var(--sub-accent, var(--accent)) 55%, var(--line-strong)); }

/* ---------- Card region ---------- */
.card-region {
  flex: 1 1 auto;
  position: relative;
  overflow: hidden;
}
.card {
  position: absolute;
  inset: 0;
  padding: 8px 26px 12px;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overscroll-behavior: contain;
  animation: cardIn 0.42s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes cardIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.card.reverse { animation-name: cardInRev; }
@keyframes cardInRev {
  from { opacity: 0; transform: translateY(-10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Static rail navigation. Directly below the progress rail: a quiet left arrow
   under the first segment and a right arrow under the last, with the numeric card
   count between them. The row shares the rail's 20px side padding so each arrow's
   hit area lines up with the first/last pip edge; a negative margin pulls the glyph
   itself out to that edge while the padding keeps a generous invisible tap target.
   Non-animated, and legible in light/dark via the ink tokens. This is the single
   navigation model at every width -- there is no separate Back/Next footer bar. */
.rail-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px 6px;
  flex: 0 0 auto;
}
.rail-arrow {
  appearance: none;
  border: 0;
  background: none;
  margin: 0;
  padding: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-faint);
  cursor: pointer;
  border-radius: 8px;
  transition: color 0.2s ease, opacity 0.2s ease;
}
.rail-arrow svg { width: 18px; height: 18px; display: block; }
.rail-prev { margin-left: -6px; }  /* pull glyph out to the first-segment edge */
.rail-next { margin-right: -6px; } /* pull glyph out to the last-segment edge */
.rail-arrow:hover { color: var(--ink); }
.rail-arrow:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.rail-arrow:disabled { opacity: 0.28; cursor: default; }
.rail-count {
  font-size: 12px;
  letter-spacing: 0.08em;
  font-variant-numeric: tabular-nums;
  color: var(--ink-faint);
}

.card-title {
  font-family: var(--font-display);
  font-weight: 570;
  font-size: 29px;
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin-bottom: 14px;
  flex: 0 0 auto;
  text-wrap: balance;
}

.card-body {
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink-muted);
  flex: 0 0 auto;
}

.sticky-line {
  margin-top: 14px;
  padding-left: 14px;
  border-left: 2px solid var(--accent);
  font-family: var(--font-display);
  font-style: italic;
  font-size: 16.5px;
  line-height: 1.35;
  color: var(--ink);
  flex: 0 0 auto;
}

/* spacer pushes interaction to the bottom of the card */
.card-spacer { flex: 1 1 auto; min-height: 10px; }

/* ---------- Interactions ---------- */
.interaction { flex: 0 0 auto; }
.interaction-prompt {
  font-size: 12.5px;
  color: var(--ink-muted);
  margin-bottom: 9px;
  font-weight: 500;
}

/* reveal */
.reveal-btn {
  width: 100%;
  padding: 15px 16px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px dashed var(--line-strong);
  color: var(--ink-muted);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s ease;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.reveal-btn:hover { border-color: var(--accent); color: var(--ink); }
.revealed-line {
  padding: 15px 16px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  border: 1px solid transparent;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 15.5px;
  line-height: 1.4;
  color: var(--ink);
  animation: cardIn 0.35s ease;
  margin-bottom: 10px;
}

/* choice chips */
.choices { display: flex; flex-wrap: wrap; gap: 8px; }
.choices.stack { flex-direction: column; }
.chip {
  padding: 11px 15px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 500;
  transition: all 0.18s ease;
  text-align: left;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.choices.stack .chip { border-radius: var(--radius-sm); width: 100%; justify-content: space-between; }
.chip:hover { border-color: var(--accent); }
.chip:active { transform: scale(0.97); }
.chip.selected {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.dark .chip.selected { color: #16130f; }
/* quiz feedback — icon carries meaning; colour is reinforcement, not sole signal */
.chip-status { flex: 0 0 auto; display: inline-flex; align-items: center; }
.chip.correct, .chip.incorrect { background: var(--surface); font-weight: 600; }
.chip.correct { border-color: var(--ok); color: var(--ok); }
.chip.incorrect { border-color: var(--err); color: var(--err); }
.chip.correct .chip-label, .chip.incorrect .chip-label { color: var(--ink); }
.chip.correct .chip-status { color: var(--ok); }
.chip.incorrect .chip-status { color: var(--err); }

/* journal */
.journal-prompts {
  font-size: 12px;
  color: var(--ink-faint);
  line-height: 1.5;
  margin-bottom: 8px;
}
.journal-prompts li { list-style: none; }
.journal-prompts li::before { content: "\2014  "; color: var(--accent); }
.journal-area {
  width: 100%;
  min-height: 82px;
  resize: none;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  padding: 12px 13px;
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
}
.journal-area:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.journal-area::placeholder { color: var(--ink-faint); }
.journal-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 9px; gap: 12px;
}
.save-btn {
  padding: 9px 18px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.2s ease;
  display: flex; align-items: center; gap: 7px;
}
.dark .save-btn { color: #16130f; }
.save-btn:active { transform: scale(0.96); }
.save-btn.saved { background: var(--ok); }
.save-hint { font-size: 11.5px; color: var(--ink-faint); }

/* final takeaway on card 5 sticky already covers it */

/* toolbar row: sources + ask tutor */
.toolbar {
  flex: 0 0 auto;
  display: flex;
  gap: 8px;
  padding: 0 20px 8px;
}
.tool-btn {
  flex: 1;
  display: flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-muted);
  font-size: 12.5px;
  font-weight: 500;
  transition: all 0.18s ease;
}
.tool-btn:hover { border-color: var(--line-strong); color: var(--ink); }
.tool-btn .badge {
  font-size: 10px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  border-radius: 999px;
  padding: 1px 6px;
  font-weight: 600;
}

/* ---------- Bottom sheet drawers ---------- */
.scrim {
  position: absolute;
  inset: 0;
  background: rgba(20, 17, 13, 0.42);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  z-index: 20;
}
.scrim.open { opacity: 1; pointer-events: auto; }

.sheet {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  max-height: 74%;
  background: var(--surface);
  border-radius: 24px 24px 0 0;
  box-shadow: 0 -18px 40px -20px rgba(0,0,0,0.35);
  transform: translateY(100%);
  transition: transform 0.36s cubic-bezier(0.22, 1, 0.36, 1);
  z-index: 21;
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--line);
}
.sheet.open { transform: translateY(0); }
.sheet-grip {
  width: 36px; height: 4px; border-radius: 2px;
  background: var(--line-strong);
  margin: 10px auto 4px;
  flex: 0 0 auto;
}
.sheet-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 22px 12px;
  flex: 0 0 auto;
}
.sheet-title {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 560;
  letter-spacing: -0.01em;
}
.sheet-sub { font-size: 12px; color: var(--ink-faint); margin-top: 2px; }
.sheet-body {
  overflow-y: auto;
  padding: 0 22px 24px;
  -webkit-overflow-scrolling: touch;
}

/* source item */
.source {
  padding: 14px 0;
  border-top: 1px solid var(--line);
}
.source:first-child { border-top: none; }
.source-title {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
}
.source-title:hover { color: var(--accent-ink); }
.source-pub { font-size: 12px; color: var(--ink-faint); margin: 2px 0 6px; }
.source-supports { font-size: 13px; line-height: 1.5; color: var(--ink-muted); }
/* FTC short-form affiliate disclosure, shown next to each "Additional Reading" link. */
.source-paid {
  margin-top: 6px; font-size: 11.5px; line-height: 1.4; font-weight: 600;
  letter-spacing: 0.01em; color: var(--ink-faint);
}
.source-meta {
  margin-top: 4px;
  font-size: 11px;
  color: var(--ink-faint);
  letter-spacing: 0.04em;
}
.safety-note {
  margin-top: 16px;
  padding: 13px 15px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--ink-muted);
}
.safety-note strong { color: var(--ink); }

/* tutor */
.tutor-note {
  font-size: 12px;
  color: var(--ink-faint);
  background: var(--surface-2);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 14px;
  line-height: 1.45;
}
.preset {
  width: 100%;
  text-align: left;
  padding: 13px 15px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 13.5px;
  color: var(--ink);
  margin-bottom: 8px;
  transition: all 0.18s ease;
  display: flex; align-items: center; gap: 10px;
}
.preset:hover { border-color: var(--accent); }
.preset .q-ico { color: var(--accent); flex: 0 0 auto; }
.tutor-input-row {
  display: flex; gap: 8px; margin-top: 8px; align-items: flex-end;
}
.tutor-input {
  flex: 1;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  padding: 12px 16px;
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--ink);
}
.tutor-input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.tutor-send {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: grid; place-items: center;
  flex: 0 0 auto;
}
.dark .tutor-send { color: #16130f; }
.tutor-reply {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink);
  animation: cardIn 0.3s ease;
}

/* toast */
.toast {
  position: absolute;
  bottom: 88px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: var(--ink);
  color: var(--surface);
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: all 0.28s ease;
  z-index: 30;
  white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.sheet-close { color: var(--ink-muted); }
.sheet-close:hover { color: var(--ink); }

/* ---------- Checklist interaction ---------- */
.checklist { display: flex; flex-direction: column; gap: 7px; margin-bottom: 8px; }
.checklist li { list-style: none; }
.check-item {
  width: 100%;
  display: flex; align-items: center; gap: 11px;
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  text-align: left;
  transition: all 0.16s ease;
}
.check-item:hover { border-color: var(--accent); }
.check-item:active { transform: scale(0.99); }
.check-box {
  flex: 0 0 auto;
  width: 22px; height: 22px;
  border-radius: 7px;
  border: 1.5px solid var(--line-strong);
  display: grid; place-items: center;
  color: #fff;
  transition: all 0.16s ease;
}
.dark .check-item.on .check-box { color: #16130f; }
.check-item.on .check-box { background: var(--accent); border-color: var(--accent); }
.check-label {
  font-size: 13.5px; line-height: 1.35; color: var(--ink); font-weight: 500;
}
.check-item.on .check-label { color: var(--ink-muted); }
.check-count {
  font-size: 11.5px; color: var(--ink-faint);
  font-variant-numeric: tabular-nums; text-align: right;
}

/* ---------- Timer interaction ---------- */
.timer { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.timer-ring {
  width: 116px; height: 116px;
  border-radius: 50%;
  display: grid; place-items: center;
  transition: background 0.9s linear;
}
.timer-ring.running { animation: timerPulse 2.4s ease-in-out infinite; }
@keyframes timerPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.03); }
}
.timer-face {
  width: 96px; height: 96px;
  border-radius: 50%;
  background: var(--surface);
  display: grid; place-items: center;
}
.timer-time {
  font-family: var(--font-display);
  font-size: 26px; font-weight: 560;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.timer-done {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 15px;
  color: var(--accent-ink);
  text-align: center;
}

/* ---------- Course overview (editorial) ---------- */
.overview {
  position: relative;
  width: 390px; height: 844px;
  max-height: calc(100dvh - 48px);
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow:
    0 0 0 2px var(--line-strong),
    0 0 0 12px var(--bezel),
    var(--shadow-lift);
  overflow: hidden;
  display: flex; flex-direction: column;
}
.overview::after {
  content: "";
  position: absolute; inset: 0; pointer-events: none;
  opacity: 0.5; mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.035'/%3E%3C/svg%3E");
  z-index: 60;
}
.dark .overview::after { mix-blend-mode: screen; opacity: 0.35; }
@media (max-width: 480px) {
  .overview {
    width: 100vw; height: 100dvh; max-height: 100dvh;
    border-radius: 0; box-shadow: none;
  }
  .overview::after { border-radius: 0; }
}
.overview-scroll {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 4px 22px calc(28px + env(safe-area-inset-bottom, 0px));
}
.ov-masthead { padding: 14px 0 20px; border-bottom: 1px solid var(--line); }
.ov-kicker {
  font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--accent-ink); font-weight: 600; margin-bottom: 12px;
}
.ov-title {
  font-family: var(--font-display);
  font-weight: 560;
  font-size: 30px; line-height: 1.08; letter-spacing: -0.02em;
  text-wrap: balance;
  margin-bottom: 12px;
}
.ov-promise {
  font-size: 14.5px; line-height: 1.5; color: var(--ink-muted); margin-bottom: 14px;
}
.ov-byline {
  font-size: 12px; color: var(--ink-faint); letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
}

.ov-progress { padding: 18px 0; border-bottom: 1px solid var(--line); }
.ov-progress-top {
  display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 9px;
}
.ov-progress-label { font-size: 13px; color: var(--ink-muted); font-weight: 500; }
.ov-progress-pct {
  font-family: var(--font-display);
  font-size: 18px; font-weight: 560; color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.ov-progress-bar {
  height: 4px; border-radius: 2px; background: var(--line-strong); overflow: hidden;
}
.ov-progress-fill {
  height: 100%; background: var(--sub-accent, var(--accent)); border-radius: 2px;
  transition: width 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}
.ov-cta {
  width: 100%;
  margin-top: 16px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 14px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--surface);
  font-size: 14.5px; font-weight: 600;
  transition: all 0.2s ease;
}
.ov-cta:hover { background: var(--accent); }
.ov-cta:active { transform: scale(0.98); }

.ov-list { list-style: none; padding-top: 6px; }
.ov-row {
  width: 100%;
  display: flex; align-items: flex-start; gap: 14px;
  padding: 18px 4px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  transition: background 0.16s ease;
}
.ov-row:hover { background: var(--surface-2); }
.ov-num {
  flex: 0 0 auto;
  font-family: var(--font-display);
  font-size: 15px; font-weight: 560;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
  padding-top: 3px; width: 24px;
}
.ov-row.done .ov-num, .ov-row.in-progress .ov-num { color: var(--accent-ink); }
.ov-row-main { flex: 1 1 auto; min-width: 0; }
.ov-row-theme {
  display: block;
  font-size: 10.5px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--ink-faint); font-weight: 600; margin-bottom: 3px;
}
/* Subject identity cue — a small colour dot that carries the subject accent.
   Colour is never the only signal: the subject/theme label sits right beside it. */
.ov-dot {
  display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: var(--sub-accent, var(--line-strong));
  margin-right: 7px; vertical-align: middle; position: relative; top: -1px;
}
.dark .ov-dot, .dark .ov-progress-fill, .dark .pip.done .pip-bar, .dark .pip.active .pip-bar,
.dark .today-rule {
  background: color-mix(in srgb, var(--sub-accent, var(--accent)) 68%, #fff);
}
/* Dark mode only: lift every subject-accent colour fill ~15% more luminous so
   subjects stay identifiable on the near-black ground. Brightness-only keeps
   each hue distinct; applied to pure colour elements (bars/dots/spines), never
   to text, so contrast is unaffected. */
.dark .ov-dot, .dark .ov-progress-fill, .dark .pip.done .pip-bar, .dark .pip.active .pip-bar,
.dark .today-rule, .dark .subj-spine {
  filter: brightness(1.15);
}
.ov-row-title {
  display: block;
  font-family: var(--font-display);
  font-size: 18px; line-height: 1.18; font-weight: 550; letter-spacing: -0.01em;
  color: var(--ink); margin-bottom: 5px; text-wrap: balance;
}
.ov-row-blurb {
  display: block;
  font-size: 12.5px; line-height: 1.45; color: var(--ink-muted);
}
.ov-status {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 4px;
  font-size: 10.5px; color: var(--ink-faint);
  padding-top: 3px; white-space: nowrap;
}
.ov-status.done { color: var(--accent-ink); }
.ov-status.in-progress .ov-status-text { color: var(--accent-ink); }
.ov-foot {
  margin-top: 18px;
  font-size: 11px; line-height: 1.5; color: var(--ink-faint);
  letter-spacing: 0.02em;
}

/* subject TOC — back link + coming-soon (locked) rows */
.toc-back {
  display: inline-flex; align-items: center; gap: 6px;
  margin: 2px 0 10px; padding: 6px 2px;
  font-size: 12.5px; font-weight: 600; color: var(--ink-muted);
  letter-spacing: 0.01em;
}
.toc-back:hover { color: var(--ink); }
.ov-coming { padding-top: 2px; }
.ov-row.is-locked { cursor: default; opacity: 0.62; }
.ov-row.is-locked:hover { background: transparent; }
.ov-row.is-locked .ov-row-title { font-weight: 500; }

/* ---------- End-of-lesson advance banner ---------- */
.lesson-done-banner {
  position: absolute;
  left: 12px; right: 12px;
  bottom: calc(84px + env(safe-area-inset-bottom, 0px));
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  box-shadow: 0 12px 30px -18px rgba(0,0,0,0.4);
  z-index: 16;
  animation: cardIn 0.4s ease;
}
.ldb-check {
  flex: 0 0 auto;
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: grid; place-items: center;
}
.dark .ldb-check { color: #16130f; }
.ldb-text {
  flex: 1 1 auto;
  font-size: 12.5px; line-height: 1.35; color: var(--ink); font-weight: 500;
}
.ldb-btn {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 5px;
  padding: 9px 13px;
  border-radius: 999px;
  background: var(--ink); color: var(--surface);
  font-size: 12px; font-weight: 600;
  transition: all 0.2s ease;
  max-width: 150px;
}
.ldb-btn:hover { background: var(--accent); }
.ldb-btn:active { transform: scale(0.97); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .timer-ring.running { animation: none; }
}

/* ---------- Developer-only metadata preview ---------- */
.dev-dot {
  position: absolute;
  right: 10px;
  bottom: 10px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: transparent;
  border: 1px solid var(--line-strong);
  opacity: 0.35;
  z-index: 15;
  transition: opacity 0.2s ease;
}
.dev-dot:hover { opacity: 0.85; border-color: var(--accent); }

.dev-feedback { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.dev-feedback .chip { font-size: 12.5px; padding: 8px 12px; }

.dev-section-title {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin: 14px 0 8px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.meta-table {
  font-family: "SF Mono", ui-monospace, "JetBrains Mono", Menlo, monospace;
  font-size: 11.5px;
}
.meta-row {
  display: flex;
  gap: 10px;
  padding: 4px 0;
  border-bottom: 1px dotted var(--line);
  align-items: baseline;
}
.meta-k { color: var(--ink-faint); flex: 0 0 138px; }
.meta-v { color: var(--ink); flex: 1; word-break: break-word; }

.dev-ident {
  font-family: ui-monospace, monospace;
  font-size: 10.5px;
  color: var(--ink-faint);
  margin-bottom: 8px;
}
.event-log {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.event-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 11px;
  border-bottom: 1px solid var(--line);
  font-family: ui-monospace, monospace;
  font-size: 11px;
}
.event-row:last-child { border-bottom: none; }
.event-name { color: var(--accent-ink); font-weight: 600; }
.event-meta { color: var(--ink-faint); }
.event-empty { padding: 12px; font-size: 12px; color: var(--ink-faint); }

/* ============================================================
   Onboarding · Paywall · App shell · Settings
   Reuses the phone frame + tokens above. Editorial, not SaaS.
   ============================================================ */

/* shared primary/ghost buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 14px 20px; border-radius: 999px;
  font-size: 14.5px; font-weight: 600; letter-spacing: 0.01em;
  transition: all 0.2s ease;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--ink); color: var(--surface); width: 100%; }
.btn-primary:hover { background: var(--accent); }
.btn-primary:disabled { opacity: 0.34; cursor: not-allowed; }
.dark .btn-primary { background: var(--ink); color: var(--surface); }
.btn-ghost {
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line-strong);
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent-ink); }
/* Sign in with Google — recognizable light button with the multi-color G. */
.btn-google {
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line-strong); width: 100%;
}
.btn-google:hover { border-color: var(--ink-faint); }
.g-icon { flex: 0 0 auto; }

/* add-subjects entry buttons + sheet */
.sec-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin: 24px 0 4px;
}
.add-entry {
  padding: 8px 14px; font-size: 12.5px; gap: 6px; flex: 0 0 auto;
}
.add-entry svg { width: 15px; height: 15px; }
.add-entry:hover { border-color: var(--brand); color: var(--brand-ink); }
.lib-add-wrap { margin-top: 20px; display: flex; }
.lib-add-wrap .add-entry { width: 100%; }
.add-confirm { width: 100%; margin-top: 22px; }
.subj-card.is-added {
  opacity: 0.8; cursor: default;
  border-style: dashed; background: var(--surface);
}
.subj-added-tag {
  flex: 0 0 auto; font-size: 10.5px; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--brand-ink);
  display: inline-flex; align-items: center; gap: 5px;
}
.subj-added-tag::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: var(--sub-accent, var(--brand));
}

/* onboarding header + scroll */
.hdr-onb { padding: 16px 22px 8px; }
.onb-step {
  font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--ink-faint); font-weight: 600;
}
.onb-scroll {
  flex: 1 1 auto; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 8px 22px calc(20px + env(safe-area-inset-bottom, 0px));
}
.onb-center { display: flex; flex-direction: column; justify-content: center; }

/* Cold open is a fixed warm-ivory brand moment: it keeps the approved light
   palette even under app/system dark mode. Re-declaring the light tokens on the
   wrapper forces the background (#f4efe6) and every foreground element (charcoal
   logo/wordmark/tagline, black Start button with ivory text, coral underline) to
   the light-screen values from first paint with no JS timing. Onboarding screens
   after Start and the rest of the app still honor dark mode. */
.phone-welcome {
  --bg: #ece5d8;
  --surface: #f4efe6;
  --surface-2: #ece5d8;
  --card: #fbf8f1;
  --ink: #1c1a17;
  --ink-muted: #443f38;
  --ink-faint: #746c60;
  --line: #d8cfbe;
  --line-strong: #c3b8a2;
  --field: #ffffff;
  --accent: #1c1a17;
  --accent-soft: #e7dfce;
  --accent-ink: #443f38;
  --brand: #b5533c;
  --brand-ink: #9c4230;
  --brand-soft: #f0dcd3;
  --bezel: #2b2925;
  --shadow: 0 1px 2px rgba(28, 26, 23, 0.05), 0 12px 30px rgba(28, 26, 23, 0.07);
  --shadow-lift: 0 2px 4px rgba(28, 26, 23, 0.06), 0 22px 48px rgba(28, 26, 23, 0.12);
  --ok: #3f7a34;
  --err: #b23b2e;
  /* Set base color too: elements that only inherit `color` (e.g. the wordmark
     h1) would otherwise inherit the body's already-computed dark-mode ivory. */
  background: var(--surface);
  color: var(--ink);
}
/* Keep the print grain in its light (multiply) form on the ivory cold open,
   overriding the dark screen-blend variant for this wrapper only. */
.dark .phone-welcome::after { mix-blend-mode: multiply; opacity: 0.5; }

/* welcome — cold open (centered, no top chrome) */
.onb-cold {
  flex: 1 1 auto; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center;
  padding: 8px 30px calc(28px + env(safe-area-inset-bottom, 0px));
}
.onb-cold .mark { color: var(--ink); margin-bottom: 30px; }
.onb-cold .onb-display span { display: block; }
.onb-cold .onb-lead { max-width: 34ch; margin-left: auto; margin-right: auto; }
.onb-cold .btn-primary { margin-top: 52px; max-width: 280px; }

/* welcome */
.onb-kicker {
  font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--accent-ink); font-weight: 700; margin-bottom: 18px;
}
.onb-display {
  font-family: var(--font-display); font-weight: 560;
  font-size: 34px; line-height: 1.06; letter-spacing: -0.025em;
  margin-bottom: 18px; text-wrap: balance;
}
.onb-display span { display: block; }
.onb-display span:last-child { color: var(--accent-ink); }
.onb-lead { font-size: 15.5px; line-height: 1.55; color: var(--ink-muted); }
.onb-lead-two span { display: block; }
/* Welcome cold-open subtitle (Option D spacing): larger (15.5 -> 19.5px),
   regular weight. Gaps are tuned to exact targets: 56px title-to-line-1
   (38px here + the 18px title margin), 7px between the two lines, and 52px
   from line-2 to the Start button (set on .onb-cold .btn-primary). */
.onb-cold .onb-lead-two { font-size: 19.5px; font-weight: 400; color: var(--ink); line-height: 1.5; margin-top: 38px; }
.onb-cold .onb-lead-two span:first-child { margin-bottom: 7px; }
.onb-foot-cta { margin-top: 28px; }

/* onboarding titles */
.onb-title {
  font-family: var(--font-display); font-weight: 560;
  font-size: 26px; line-height: 1.12; letter-spacing: -0.02em;
  margin: 6px 0 8px; text-wrap: balance;
}
.onb-sub { font-size: 14.5px; line-height: 1.5; color: var(--ink-muted); margin-bottom: 20px; }
.onb-sectionlabel {
  font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--ink-faint); font-weight: 600; margin: 26px 0 12px;
}

/* onboarding footer (pinned) */
.onb-footer {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 14px;
  padding: 14px 22px calc(18px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--line);
}
.onb-footer .btn-primary { width: auto; flex: 1 1 auto; }
.onb-progress-note { font-size: 12.5px; color: var(--ink-muted); white-space: nowrap; }

/* subject cards */
.subj-list { display: flex; flex-direction: column; gap: 10px; }
.subj-card {
  display: flex; align-items: center; gap: 13px; text-align: left;
  padding: 15px 16px 15px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong); background: var(--card);
  transition: all 0.18s ease;
}
.subj-card:hover { border-color: var(--rule-strong, var(--line-strong)); background: var(--surface); }
.subj-card.on {
  border-color: var(--sub-accent, var(--accent));
  background: color-mix(in srgb, var(--sub-accent, var(--accent)) 9%, var(--card));
}
.subj-spine {
  flex: 0 0 6px; align-self: stretch; min-height: 36px;
  border-radius: 3px; background: var(--sub-accent, var(--line-strong));
}
.subj-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.subj-name { font-family: var(--font-display); font-size: 17px; font-weight: 560; }
.subj-blurb { font-size: 13px; color: var(--ink-muted); line-height: 1.4; }
.subj-tick {
  flex: 0 0 auto; width: 24px; height: 24px; border-radius: 50%;
  display: grid; place-items: center;
  border: 1.5px solid var(--line-strong); color: transparent;
  transition: all 0.18s ease;
}
.subj-tick.on {
  background: var(--sub-accent, var(--accent));
  border-color: var(--sub-accent, var(--accent));
  color: #fff;
}

/* coming-soon section (subject picker): separate, non-selectable, notify-only */
.cs-sectionhead {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; margin: 28px 0 12px;
}
.cs-sectionhead .onb-sectionlabel { margin: 0; }
.cs-sectionnote { font-size: 12.5px; color: var(--ink-faint); }
.cs-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.cs-card {
  display: flex; flex-direction: column; gap: 8px;
  padding: 12px 12px; min-height: 84px; justify-content: space-between;
  border: 1px dashed var(--line-strong); border-radius: var(--radius-sm);
  background: transparent;
}
.cs-card-name { font-size: 13.5px; font-weight: 600; color: var(--ink-muted); line-height: 1.25; }
.cs-card-blurb { font-size: 12px; color: var(--ink-faint); line-height: 1.35; margin-top: -3px; }
.cs-notify {
  display: inline-flex; align-items: center; gap: 5px; align-self: flex-start;
  font-family: var(--font-body); font-size: 12px; font-weight: 600;
  padding: 6px 11px; min-height: 32px; border-radius: 999px;
  border: 1px solid var(--line-strong); background: transparent; color: var(--ink-muted);
  cursor: pointer; transition: all 0.18s ease;
}
.cs-notify:hover { border-color: var(--accent); color: var(--accent-ink); }
.cs-notify.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-ink); }

/* pace cards */
.pace-list { display: flex; flex-direction: column; gap: 10px; }
.pace-card {
  display: flex; align-items: center; gap: 14px; text-align: left;
  padding: 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong); background: var(--surface);
  transition: all 0.18s ease;
}
.pace-card:hover { border-color: var(--accent); }
.pace-card.on { border-color: var(--accent); background: var(--accent-soft); }
/* Dark mode: the cadence tick falls back to the light ivory --accent fill, so a
   white check is invisible. Use a dark check for clear AA contrast on ivory. */
.dark .pace-card .subj-tick.on { color: var(--surface); }
.pace-main { flex: 1 1 auto; display: flex; flex-direction: column; gap: 3px; }
.pace-label { font-family: var(--font-display); font-size: 16px; font-weight: 560; }
.pace-sub { font-size: 13px; color: var(--ink-muted); line-height: 1.4; }

/* paywall */
.pw-benefits { list-style: none; margin: 4px 0 22px; display: flex; flex-direction: column; gap: 11px; }
.pw-benefits li { display: flex; align-items: flex-start; gap: 10px; font-size: 14px; line-height: 1.4; }
.pw-benefits li svg { color: var(--accent); flex: 0 0 auto; margin-top: 2px; }
.plan-list { display: flex; flex-direction: column; gap: 10px; }
.plan-card {
  display: flex; align-items: center; gap: 12px; text-align: left;
  padding: 15px 16px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--line-strong); background: var(--surface);
  transition: all 0.18s ease;
}
.plan-card:hover { border-color: var(--accent); }
.plan-card.on { border-color: var(--accent); background: var(--accent-soft); }
.plan-radio {
  flex: 0 0 auto; width: 20px; height: 20px; border-radius: 50%;
  border: 2px solid var(--line-strong); position: relative;
}
.plan-card.on .plan-radio { border-color: var(--accent); }
.plan-card.on .plan-radio::after {
  content: ""; position: absolute; inset: 3px; border-radius: 50%; background: var(--accent);
}
.plan-main { flex: 1 1 auto; display: flex; flex-direction: column; gap: 4px; }
.plan-name { font-family: var(--font-display); font-size: 16px; font-weight: 560; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.plan-badge {
  font-family: var(--font-body); font-size: 9.5px; font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase; padding: 3px 7px; border-radius: 999px;
  background: var(--accent); color: #fff; white-space: nowrap;
}
/* Dark mode: --accent is light ivory, so white badge text is unreadable. Flip to
   dark text on the ivory pill (mirrors the light-mode inverted pill), AA-safe. */
.dark .plan-badge { color: var(--surface); }
.plan-note { font-size: 12.5px; color: var(--ink-muted); }
.plan-price { font-family: var(--font-display); font-size: 16px; font-weight: 600; color: var(--ink); white-space: nowrap; }
.pw-footer { flex-direction: column; align-items: stretch; gap: 10px; }
.pw-fine { font-size: 11px; line-height: 1.45; color: var(--ink-faint); }
.pw-promo-toggle, .pw-disclosure-toggle {
  font-size: 12.5px; font-weight: 600; color: var(--accent-ink); align-self: flex-start;
  padding: 4px 0;
}
.pw-promo { padding-top: 4px; }
.pw-promo-row { display: flex; gap: 8px; }
.pw-promo-input {
  flex: 1 1 auto; padding: 11px 13px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong); background: var(--surface-2);
  font-family: inherit; font-size: 14px; color: var(--ink);
}
.pw-promo-input:focus { outline: none; border-color: var(--accent); }
.pw-promo-apply { padding: 11px 16px; flex: 0 0 auto; }
.pw-promo-msg { font-size: 12px; color: var(--accent-ink); margin-top: 8px; }
.pw-auth { display: flex; flex-direction: column; gap: 10px; align-items: stretch; }
.pw-email { display: flex; flex-direction: column; gap: 8px; }
.pw-email .pw-promo-input { width: 100%; }
.pw-leadin { font-size: 13.5px; font-weight: 600; color: var(--ink); margin: 2px 0 12px; }
.pw-legal { margin-top: 6px; text-align: center; }
.pw-legal-links { font-size: 11.5px; font-weight: 600; color: var(--ink-muted); }
.pw-legal-note { font-size: 11px; line-height: 1.45; color: var(--ink-faint); margin-top: 4px; }

/* ---------- Post-entitlement app shell ---------- */
.app-head { padding: 16px 20px 10px; border-bottom: 1px solid var(--line); }
.plan-chip {
  font-size: 11px; font-weight: 700; letter-spacing: 0.04em;
  padding: 6px 12px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent-ink);
  margin-right: 4px;
}
.app-body {
  flex: 1 1 auto; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 16px 22px calc(20px + env(safe-area-inset-bottom, 0px));
}
.app-h1 {
  font-family: var(--font-display); font-weight: 560;
  font-size: 26px; letter-spacing: -0.02em; margin-bottom: 6px;
}
.app-sub { font-size: 14px; color: var(--ink-muted); line-height: 1.5; margin-bottom: 18px; }
.app-sectionlabel {
  font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--ink-faint); font-weight: 600; margin: 24px 0 4px;
}
.ll { display: block; }
.ll .ov-list { padding-top: 0; }

/* today card */
.today-card {
  position: relative;
  display: flex; flex-direction: column; gap: 6px;
  padding: 22px; border-radius: var(--radius-sm);
  background: var(--accent-soft); border: 1px solid var(--line);
  overflow: hidden;
}
/* subject-coloured spine on the day's card */
.today-rule {
  position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: var(--sub-accent, var(--accent));
}
.today-eyebrow {
  font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--accent-ink); font-weight: 700;
}
.today-theme {
  font-family: var(--font-display); font-size: 13px; font-weight: 600;
  color: var(--accent-ink); letter-spacing: 0.01em;
}
.today-title {
  font-family: var(--font-display); font-weight: 560;
  font-size: 22px; line-height: 1.12; letter-spacing: -0.02em; margin-top: 2px;
}
.today-blurb { font-size: 14px; line-height: 1.5; color: var(--ink-muted); margin-bottom: 14px; }
.today-card .btn-primary { width: 100%; }

/* search */
.search-field {
  position: relative; display: flex; align-items: center; margin-bottom: 16px;
}
.search-field-icon {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  display: inline-flex; color: var(--ink-faint); pointer-events: none;
}
.search-field-icon svg { width: 18px; height: 18px; }
.search-input {
  width: 100%; padding: 13px 15px 13px 42px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong); background: var(--surface-2);
  font-family: inherit; font-size: 15px; color: var(--ink);
}
.search-input:focus { outline: none; border-color: var(--accent); }
.search-field:focus-within .search-field-icon { color: var(--accent); }
.search-empty { font-size: 14px; color: var(--ink-muted); }

/* tab bar */
.tabbar {
  flex: 0 0 auto; display: flex; align-items: stretch;
  border-top: 1px solid var(--line); background: var(--surface);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.tab {
  flex: 1 1 0; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 9px 4px 8px; color: var(--ink-faint);
  transition: color 0.18s ease;
}
.tab:hover { color: var(--ink-muted); }
.tab.on { color: var(--accent); }
.tab-label { font-size: 10.5px; font-weight: 600; letter-spacing: 0.01em; }

/* ---------- Settings ---------- */
.set-head { justify-content: space-between; padding: 16px 16px 12px; border-bottom: 1px solid var(--line); }
.set-group { padding: 18px 0; border-bottom: 1px solid var(--line); }
.set-group:last-of-type { border-bottom: none; }
.set-label {
  font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--ink-faint); font-weight: 600; margin-bottom: 12px;
}
.set-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 0;
}
.set-k { font-size: 14.5px; color: var(--ink); }
.set-v { font-size: 13.5px; color: var(--ink-muted); }
.set-link { cursor: pointer; color: var(--ink-muted); }
.set-link:hover { color: var(--accent-ink); }
.set-btn { width: 100%; margin-top: 12px; }
/* Flat editorial selectors (Daily goal, Text size): no native gloss/bevel, a
   quiet full border with a restrained radius, and a simple inline caret. */
.set-select {
  font-family: inherit; font-size: 13.5px; color: var(--ink);
  background: transparent; border: 1px solid var(--line-strong);
  border-radius: 6px; padding: 8px 10px; min-height: 40px;
}
select.set-select {
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  cursor: pointer; padding-right: 28px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238a857a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M6 9l6 6 6-6'/></svg>");
  background-repeat: no-repeat; background-position: right 9px center; background-size: 12px;
}
.set-select:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-color: var(--brand); }
.set-fine { font-size: 11px; line-height: 1.45; color: var(--ink-faint); margin-top: 10px; }

/* toggle switch */
.switch {
  width: 46px; height: 27px; border-radius: 999px; background: var(--line-strong);
  position: relative; transition: background 0.2s ease; flex: 0 0 auto;
}
.switch.on { background: var(--accent); }
.switch-dot {
  position: absolute; top: 3px; left: 3px; width: 21px; height: 21px;
  border-radius: 50%; background: #fff; transition: transform 0.2s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.25);
}
.switch.on .switch-dot { transform: translateX(19px); }

/* ---------- Persistent nav inside a lesson ---------- */
/* Lesson is a flex column (header, progress, rail-nav, card, toolbar, tabbar),
   so controls sit above the bar with no overlap. Absolutely-positioned overlays
   lift to clear the added bar height. */
.lesson-phone .lesson-done-banner { bottom: calc(150px + env(safe-area-inset-bottom, 0px)); }
.lesson-phone .dev-dot { bottom: calc(64px + env(safe-area-inset-bottom, 0px)); }

/* ---------- Settings hub extras ---------- */
.set-scroll { padding-top: 4px; }
.set-k { display: flex; flex-direction: column; gap: 2px; }
.set-k-sub { font-size: 12px; color: var(--ink-faint); font-weight: 400; }
.set-link { width: 100%; text-align: left; background: none; border: none; }
.set-link-r { display: flex; align-items: center; gap: 8px; color: var(--ink-faint); }
.set-signout { margin: 18px 0 8px; color: var(--accent-ink); border-color: var(--accent); }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 999px; overflow: hidden; }
.seg-btn {
  font-size: 12.5px; font-weight: 600; padding: 7px 12px; color: var(--ink-muted);
  background: var(--surface); transition: all 0.15s ease;
}
.seg-btn + .seg-btn { border-left: 1px solid var(--line-strong); }
/* Selected option: --surface is always the opposite luminance of --accent, so the
   label stays readable in both themes (was #fff, which vanished on the ivory dark
   accent). */
.seg-btn.on { background: var(--accent); color: var(--surface); }

/* Destructive row (Delete account): red text, no chevron, still a full-width,
   clearly tappable row that reads as distinct from ordinary navigation links. */
.set-danger .set-k { color: var(--err); font-weight: 600; }
.set-danger:hover .set-k { color: var(--err); }

/* ---------- Paywall disclosure ---------- */
.pw-compact {
  font-size: 12px; line-height: 1.45; font-weight: 600; color: var(--ink);
  text-align: center; margin: 2px 0 2px;
}
.pw-disclosure { font-size: 11px; line-height: 1.5; color: var(--ink-muted); }
.pw-inline-link {
  font: inherit; color: var(--accent-ink); font-weight: 600; text-decoration: underline;
  background: none; border: none; padding: 0; cursor: pointer;
}
.pw-inline-link:hover { color: var(--accent); }

/* ---------- Legal reader (drafts) ---------- */
.legal-scroll { padding-top: 12px; }
.legal-body { padding-bottom: 20px; }
.legal-h2 {
  font-family: var(--font-display); font-weight: 560; font-size: 17px;
  letter-spacing: -0.01em; margin: 20px 0 8px; color: var(--ink);
}
.legal-h3 {
  font-family: var(--font-display); font-weight: 560; font-size: 14.5px;
  letter-spacing: -0.005em; margin: 14px 0 6px; color: var(--ink);
}
.legal-p { font-size: 13.5px; line-height: 1.6; color: var(--ink-muted); margin: 8px 0; }
.legal-em { font-style: italic; color: var(--ink-faint); }
.legal-p strong, .legal-quote strong, .legal-ul strong { color: var(--ink); }
.legal-quote {
  font-size: 13.5px; line-height: 1.6; color: var(--ink); margin: 10px 0;
  padding: 10px 14px; border-left: 3px solid var(--accent);
  background: var(--accent-soft); border-radius: 0 8px 8px 0;
}
.legal-ul { margin: 8px 0 8px 18px; }
.legal-ul li { font-size: 13.5px; line-height: 1.55; color: var(--ink-muted); margin: 4px 0; list-style: disc; }

/* ---------- Text size (Appearance › Text size) ---------- */
html.ts-s .card-title { font-size: 21px; }
html.ts-s .card-body { font-size: 14px; }
html.ts-l .card-title { font-size: 27px; }
html.ts-l .card-body { font-size: 18px; }
