/* base.css — @font-face, reset, layout, the due-today hero, exam ledger,
   readiness arcs, timer, dialogs, components, states. Design tokens
   (colors/type/spacing/radius) live in tokens.css (and are duplicated
   inline in index.html's <head> for zero-request first paint — keep both
   in sync), loaded first. */

/* ---------- self-hosted fonts (offline-first — cached by sw.js) ----------
   Fraunces (display serif — exam titles, section heads, the readiness
   percentage) and Space Grotesk (UI/body + every tabular figure) are both
   free for commercial use (SIL OFL), downloaded once — no runtime CDN
   request, required for an offline-first PWA and for perf. font-display:
   swap avoids a blank-text flash; the metrics-tuned FALLBACK faces below
   make the swap itself nearly invisible, keeping CLS near zero. */
@font-face {
  font-family: "Fraunces";
  font-style: normal;
  font-weight: 500 600;
  font-display: swap;
  src: url("../assets/fonts/fraunces-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Fraunces";
  font-style: normal;
  font-weight: 500 600;
  font-display: swap;
  src: url("../assets/fonts/fraunces-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Fraunces Fallback";
  src: local("Georgia"), local("Times New Roman");
  size-adjust: 98%;
  ascent-override: 92%;
  descent-override: 24%;
  line-gap-override: 0%;
}
@font-face {
  font-family: "Space Grotesk";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("../assets/fonts/space-grotesk-latin.woff2") format("woff2");
}
@font-face {
  font-family: "Space Grotesk";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1EFF;
  src: url("../assets/fonts/space-grotesk-latin-ext.woff2") format("woff2");
}
@font-face {
  font-family: "Space Grotesk Fallback";
  src: local("Arial"), local("Helvetica"), local("Segoe UI"), local("Roboto");
  size-adjust: 126.64%;
  ascent-override: 77.7%;
  descent-override: 23.06%;
  line-gap-override: 0%;
}

/* ---------- reset ---------- */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-ui);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  padding-bottom: var(--sp-7);
  position: relative;
}
h1, h2, h3 { margin: 0; line-height: var(--lh-tight); font-weight: 600; }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
.tnum { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 var(--sp-4); }
.ic { width: 18px; height: 18px; flex: 0 0 auto; }
.ic-lg { width: 26px; height: 26px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: -999px; top: 0; z-index: 200; background: var(--accent); color: var(--accent-ink); padding: 10px 16px; border-radius: 0 0 var(--radius-xs) 0; font-weight: 600; }
.skip-link:focus { left: 0; }

/* Custom focus ring — a crisp 2px accent outline with offset, applied to
   every interactive element via :focus-visible so mouse users don't see it,
   but keyboard users always do (WCAG 2.4.7). Never `outline: none` without
   this. */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

/* ---------- faint warm paper grain — decorative, disabled under reduced-
   motion/contrast/forced-colors. A static SVG turbulence filter data-URI —
   no animation, no network request. ---- */
.grain { position: fixed; inset: 0; pointer-events: none; z-index: 1; opacity: var(--grain-opacity);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  mix-blend-mode: multiply; }
@media (prefers-contrast: more), (forced-colors: active) { .grain { display: none; } }

/* ---------- header / footer ---------- */
.site-header { padding: calc(env(safe-area-inset-top) + var(--sp-4)) 0 var(--sp-2); }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); flex-wrap: wrap; }
.wordmark { display: flex; align-items: center; gap: var(--sp-2); font-family: var(--font-display); font-weight: 600; font-size: var(--fs-h1); color: var(--ink); text-decoration: none; }
.wordmark .ic { color: var(--accent); width: 24px; height: 24px; }
.header-nav { display: flex; gap: var(--sp-2); align-items: center; }
.site-footer { padding: var(--sp-6) 0 var(--sp-4); color: var(--ink-soft); font-size: var(--fs-sm); }
.site-footer .wrap { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; justify-content: center; text-align: center; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2); min-height: 44px;
  padding: 11px 18px; border-radius: var(--radius-sm); border: 1.5px solid var(--line); background: var(--surface);
  color: var(--ink); font-weight: 600; font-size: 0.95rem; transition: transform var(--dur-fast) var(--ease-settle), background var(--dur-fast); }
.btn:hover { border-color: var(--accent); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn-primary:hover { filter: brightness(1.06); }
.btn-secondary { background: var(--surface-2); border-color: var(--surface-2); }
.btn-ghost { background: transparent; }
.btn-lg { min-height: 56px; padding: 13px 26px; font-size: 1.05rem; font-weight: 700; }
.btn-sm { min-height: 40px; padding: 8px 14px; font-size: 0.875rem; }
.btn-danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn-block { width: 100%; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px;
  border-radius: 50%; border: 1.5px solid var(--line); background: var(--surface); color: var(--ink-soft); flex: 0 0 auto; }
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn.is-active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.link-btn { background: none; border: none; padding: 0; color: var(--accent); font-weight: 600; text-decoration: underline; min-height: 44px; }

/* ---------- overflow menus ---------- */
.menu-wrap { position: relative; }
.menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 40; min-width: 210px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius-sm); box-shadow: 0 10px 30px -8px color-mix(in srgb, var(--accent) 24%, black 30%);
  padding: var(--sp-2); display: flex; flex-direction: column; gap: 2px; }
.menu-item { display: flex; align-items: center; gap: var(--sp-2); width: 100%; text-align: left; font-weight: 600;
  font-size: 0.9rem; padding: 10px 12px; border-radius: var(--radius-xs); border: none; background: transparent; color: var(--ink); min-height: 44px; }
.menu-item:hover { background: var(--surface-2); }
.menu-item .ic { color: var(--accent); }
.menu-item.danger { color: var(--danger); }
.menu-item.danger .ic { color: var(--danger); }
.theme-swatch-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--sp-1); padding: var(--sp-1); }
.theme-swatch { display: flex; align-items: center; gap: var(--sp-2); padding: 8px 10px; border-radius: var(--radius-xs); border: 1.5px solid transparent; background: transparent; font-weight: 600; font-size: 0.85rem; color: var(--ink); min-height: 44px; }
.theme-swatch:hover { background: var(--surface-2); }
.theme-swatch[aria-checked="true"] { border-color: var(--accent); background: var(--surface-2); }
.swatch-dot { width: 16px; height: 16px; border-radius: 50%; flex: 0 0 auto; border: 1px solid rgba(0,0,0,.15); }
.swatch-dot[data-swatch="paper"] { background: #93601A; }
.swatch-dot[data-swatch="dusk"] { background: #E3A63F; }
.swatch-dot[data-swatch="moss"] { background: #4C6934; }
.swatch-dot[data-swatch="plum"] { background: #C97FA0; }
/* curated per-exam subject swatches (SPEC §6) — fixed regardless of active
   theme, matching js/content.js SUBJECT_COLORS exactly. */
.swatch-dot[data-swatch="subj-marigold"] { background: #93601A; }
.swatch-dot[data-swatch="subj-slateteal"] { background: #2E7566; }
.swatch-dot[data-swatch="subj-rosewood"] { background: #A2483F; }
.swatch-dot[data-swatch="subj-indigo"] { background: #4C5A9E; }
.swatch-dot[data-swatch="subj-moss"] { background: #4C6934; }
.swatch-dot[data-swatch="subj-plum"] { background: #8B4C7A; }

/* ---------- main layout — editorial grid: due-today hero + ledger-style
   exam list, NOT a centered hero + three equal cards (SPEC §6). Source
   order (due -> exams -> timer -> stats) stays the sensible reading order
   for keyboard/screen-reader users regardless of the 2-column placement
   below 900px. ---------- */
main { padding: var(--sp-4) 0 var(--sp-8); }
.layout { display: grid; gap: var(--sp-6);
  grid-template-columns: 1fr;
  grid-template-areas: "due" "exams" "timer" "stats"; }
@media (min-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.9fr);
    grid-template-areas: "due exams" "timer stats"; align-items: start; }
}
.due-hero { grid-area: due; }
.exams-panel { grid-area: exams; }
.timer-panel { grid-area: timer; }
.stats-panel { grid-area: stats; }

/* ---------- section labels (small-caps + hairline rule, editorial voice) - */
.section-label { font-family: var(--font-ui); font-weight: 700; font-size: var(--fs-xs); letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--ink-soft); padding-bottom: var(--sp-2); border-bottom: 1px solid var(--line); margin-bottom: var(--sp-3); }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--sp-4);
  box-shadow: 0 10px 28px -18px color-mix(in srgb, var(--accent) 30%, black 40%); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); margin-bottom: var(--sp-1); }
.panel-head .section-label { flex: 1; margin-bottom: 0; border-bottom: none; padding-bottom: 0; }

/* ---------- readiness arc — the signature motif (SPEC §6), echoed at three
   sizes: tiny (exam ledger rows), md (the focus timer), lg (exam detail).
   Generated fresh per render by Render.arcSVG(); the CSS only handles the
   shared visual language + the fill transition (the one micro-interaction
   this whole app is built around). ---------- */
.arc-wrap { position: relative; display: inline-flex; flex: 0 0 auto; }
.arc-svg { transform: rotate(-90deg); }
.arc-track { fill: none; stroke: var(--surface-2); }
.arc-fill { fill: none; stroke-linecap: round; transition: stroke-dashoffset var(--dur-arc) var(--ease-settle), stroke var(--dur-fast); }
.arc-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 1px; }
.arc-pct { font-family: var(--font-display); font-weight: 600; font-variant-numeric: tabular-nums; color: var(--ink); line-height: 1; }
.arc-unit { font-size: 9px; color: var(--ink-soft); letter-spacing: 0.04em; text-transform: uppercase; }

/* ---------- due-today hero ---------- */
.due-hero .section-label { border-bottom: none; padding-bottom: 0; margin-bottom: var(--sp-1); }
.due-title { font-family: var(--font-display); font-weight: 600; font-size: var(--fs-display); display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; }
.due-count { display: inline-flex; align-items: center; justify-content: center; min-width: 34px; height: 34px; padding: 0 10px;
  border-radius: var(--radius-pill); background: var(--accent); color: var(--accent-ink); font-family: var(--font-ui); font-weight: 700; font-size: 1rem; }
.due-sub { color: var(--ink-soft); font-size: var(--fs-sm); margin: var(--sp-1) 0 var(--sp-4); max-width: 52ch; }
.due-nudge { display: flex; align-items: center; gap: var(--sp-2); background: color-mix(in srgb, var(--danger) 10%, var(--surface)); border: 1px solid color-mix(in srgb, var(--danger) 30%, var(--line)); color: var(--danger); border-radius: var(--radius-sm); padding: var(--sp-2) var(--sp-3); font-size: var(--fs-sm); font-weight: 600; margin-bottom: var(--sp-3); }
.due-nudge .ic { color: var(--danger); }

.queue-list { display: flex; flex-direction: column; gap: var(--sp-2); margin-bottom: var(--sp-4); }
.queue-row { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3); border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--bg); }
.queue-row.is-overdue { border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); }
.subject-dot { width: 12px; height: 12px; border-radius: 50%; flex: 0 0 auto; border: 1px solid rgba(0,0,0,.15); }
.queue-info { flex: 1; min-width: 0; }
.queue-topic-title { font-weight: 600; overflow-wrap: anywhere; }
.queue-meta { font-size: var(--fs-xs); color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.due-chip { font-size: var(--fs-xs); font-weight: 700; padding: 4px 10px; border-radius: var(--radius-pill); background: var(--surface-2); color: var(--ink-soft); flex: 0 0 auto; white-space: nowrap; }
.due-chip.is-overdue { background: color-mix(in srgb, var(--danger) 16%, var(--surface)); color: var(--danger); }
.due-chip.is-today { background: color-mix(in srgb, var(--accent) 18%, var(--surface)); color: var(--accent); }
.queue-more { color: var(--ink-soft); font-size: var(--fs-sm); text-align: center; padding: var(--sp-1) 0 var(--sp-2); }
.queue-actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: center; }
.empty-block { text-align: center; padding: var(--sp-5) var(--sp-3); }
.empty-block .ic-lg { margin: 0 auto var(--sp-2); color: var(--good); }
.empty-title { font-family: var(--font-display); font-weight: 600; font-size: 1.15rem; margin-bottom: 4px; }
.empty-body { color: var(--ink-soft); font-size: var(--fs-sm); max-width: 44ch; margin: 0 auto; }
.empty-dates { color: var(--ink-soft); font-size: var(--fs-sm); margin-top: var(--sp-2); font-weight: 600; }

/* ---------- welcome / true first-run state ---------- */
.welcome-copy { max-width: 60ch; }
.welcome-title { font-family: var(--font-display); font-weight: 600; font-size: var(--fs-display); margin-bottom: var(--sp-2); }
.welcome-body { color: var(--ink-soft); margin-bottom: var(--sp-4); }
.preset-row { display: flex; flex-wrap: wrap; gap: var(--sp-2); }

/* ---------- exam ledger ---------- */
.exam-list { display: flex; flex-direction: column; gap: var(--sp-2); }
.exam-row { display: flex; align-items: center; gap: var(--sp-3); width: 100%; text-align: left; padding: var(--sp-3);
  border: 1px solid var(--line); border-left-width: 4px; border-radius: var(--radius-sm); background: var(--bg); min-height: 44px; }
.exam-row:hover { border-color: var(--accent); }
.exam-info { flex: 1; min-width: 0; }
.exam-title { font-family: var(--font-display); font-weight: 600; font-size: 1.02rem; overflow-wrap: anywhere; }
.exam-meta { font-size: var(--fs-xs); color: var(--ink-soft); margin-top: 2px; }
.exam-meta .is-overdue { color: var(--danger); font-weight: 700; }
.exam-hint { font-size: var(--fs-xs); color: var(--ink-soft); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- exam detail (sheet) ---------- */
.exam-detail-head { display: flex; gap: var(--sp-4); align-items: center; margin-bottom: var(--sp-4); flex-wrap: wrap; }
.exam-detail-readiness { text-align: center; }
.exam-detail-readiness p { font-size: var(--fs-xs); color: var(--ink-soft); margin-top: 4px; font-weight: 600; max-width: 18ch; }
.milestone-list { display: flex; flex-direction: column; gap: var(--sp-1); margin-bottom: var(--sp-3); }
.milestone-row { display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-2); border-radius: var(--radius-sm); }
.milestone-row.is-done .milestone-title { text-decoration: line-through; color: var(--ink-soft); }
.milestone-title { flex: 1; font-weight: 600; overflow-wrap: anywhere; }
.milestone-blurb { font-size: var(--fs-xs); color: var(--ink-soft); margin-top: 1px; }
.milestone-due { font-size: var(--fs-xs); color: var(--ink-soft); font-weight: 700; white-space: nowrap; }
.milestone-due.is-overdue { color: var(--danger); }
.milestone-due.is-today { color: var(--accent); }
/* 44x44 hit area (WCAG 2.5.8) around a visually smaller 22px checkbox glyph
   — the padding is the tap target, not just the drawn box. */
.checkbox-btn { width: 44px; height: 44px; min-width: 44px; border-radius: var(--radius-xs); border: none; background: transparent; color: transparent; display: grid; place-items: center; flex: 0 0 auto; }
.checkbox-btn::before { content: ""; width: 22px; height: 22px; border-radius: 7px; border: 1.5px solid var(--line); background: var(--surface); grid-area: 1 / 1; }
.checkbox-btn.is-checked::before { background: var(--good); border-color: var(--good); }
.checkbox-btn.is-checked { color: var(--good-ink); }
.checkbox-btn .ic { grid-area: 1 / 1; z-index: 1; width: 15px; height: 15px; }
.mini-add-form { display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: flex-end; margin-top: var(--sp-2); padding-top: var(--sp-3); border-top: 1px solid var(--line); }
.mini-add-form .field { flex: 1 1 160px; }
.mini-add-form-title { flex: 2 1 200px; }

.topic-list { display: flex; flex-direction: column; gap: var(--sp-2); }
.topic-row { display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-2) var(--sp-3); border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--bg); }
.topic-info { flex: 1; min-width: 0; }
.topic-title { font-weight: 600; overflow-wrap: anywhere; }
.topic-meta { font-size: var(--fs-xs); color: var(--ink-soft); display: flex; align-items: center; gap: 6px; margin-top: 2px; flex-wrap: wrap; }
.box-chip { display: inline-flex; align-items: center; gap: 4px; font-weight: 700; padding: 2px 8px; border-radius: var(--radius-pill); background: var(--surface-2); }
.box-chip.is-healthy { background: color-mix(in srgb, var(--good) 18%, var(--surface)); color: var(--good); }

/* ---------- timer panel ---------- */
.timer-body { display: flex; align-items: center; gap: var(--sp-4); flex-wrap: wrap; }
.timer-numerals { font-family: var(--font-ui); font-weight: 600; font-size: 1.4rem; line-height: 1; }
.timer-mode { font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--accent); }
.timer-controls { display: flex; gap: var(--sp-2); flex-wrap: wrap; margin-top: var(--sp-3); }
.timer-prefill-hint { font-size: var(--fs-xs); color: var(--ink-soft); margin-top: var(--sp-2); }

/* ---------- this-week stats panel ---------- */
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-2); margin-bottom: var(--sp-3); }
.stat { text-align: center; }
.stat-value { font-family: var(--font-display); font-size: 1.5rem; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--accent); }
.stat-label { font-size: var(--fs-xs); color: var(--ink-soft); }
.week-bars { display: flex; align-items: flex-end; gap: 6px; height: 72px; margin-bottom: var(--sp-3); padding-top: var(--sp-2); }
.week-bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 4px; }
.week-bar { width: 100%; max-width: 22px; background: color-mix(in srgb, var(--ink-soft) 45%, var(--surface)); border-radius: 4px 4px 0 0; min-height: 3px; }
.week-bar-col.is-today .week-bar { background: var(--accent); }
.week-bar-label { font-size: 10px; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.mix-row { display: flex; justify-content: space-between; gap: var(--sp-2); font-size: var(--fs-xs); padding: 5px 0; }
.mix-label { display: flex; align-items: center; gap: 6px; color: var(--ink-soft); }
.mix-bar-track { flex: 1; height: 6px; border-radius: 3px; background: var(--surface-2); margin: 0 var(--sp-2); overflow: hidden; }
.mix-bar-fill { height: 100%; background: var(--accent); border-radius: 3px; }
.mix-min { font-weight: 700; color: var(--ink-soft); font-variant-numeric: tabular-nums; }

/* ---------- forms / fields (dialogs) ---------- */
.field-label { display: block; font-weight: 600; font-size: var(--fs-sm); margin: var(--sp-3) 0 6px; }
.field-label:first-child { margin-top: 0; }
.field { width: 100%; min-height: 44px; padding: 0 14px; border-radius: var(--radius-sm); border: 1.5px solid var(--line); background: var(--bg); color: var(--ink); }
textarea.field { min-height: 76px; padding: 10px 14px; resize: vertical; }
.field:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.field-hint { font-size: var(--fs-xs); color: var(--ink-soft); margin-top: 6px; }
.field-error { font-size: var(--fs-xs); color: var(--danger); margin-top: 6px; }
.form-actions { display: flex; justify-content: flex-end; gap: var(--sp-2); margin-top: var(--sp-5); flex-wrap: wrap; }
.form-actions-tight { margin-top: 0; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-3); }
.seg-group { display: flex; flex-wrap: wrap; gap: var(--sp-1); background: var(--surface-2); border-radius: var(--radius-sm); padding: 3px; }
.seg { flex: 1 1 auto; font-weight: 700; font-size: 0.8rem; min-height: 44px; border: none; border-radius: var(--radius-xs);
  background: transparent; color: var(--ink-soft); padding: 8px 8px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.seg .ic { width: 14px; height: 14px; }
.seg[aria-pressed="true"] { background: var(--surface); color: var(--accent); box-shadow: 0 1px 4px -1px rgba(0,0,0,.18); }
.subject-seg { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.subject-btn { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 8px 12px; border-radius: var(--radius-pill); border: 1.5px solid var(--line); background: var(--bg); font-weight: 600; font-size: 0.85rem; }
.subject-btn[aria-pressed="true"] { border-color: var(--ink); background: var(--surface-2); }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); padding: var(--sp-2) 0; min-height: 44px; }
.toggle-row .toggle-copy { flex: 1; }
.toggle-row .toggle-copy strong { display: block; font-size: 0.92rem; }
.toggle-row .toggle-copy span { font-size: var(--fs-xs); color: var(--ink-soft); }
.toggle-row input[type="checkbox"] { width: 24px; height: 24px; accent-color: var(--accent); flex: 0 0 auto; }
.range-row { display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-2) 0; }
.range-row input[type="range"] { flex: 1; accent-color: var(--accent); min-height: 44px; }
.number-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: var(--sp-3); margin-top: var(--sp-2); }
.number-field label { display: block; font-size: var(--fs-xs); color: var(--ink-soft); margin-bottom: 4px; }
.number-field input { width: 100%; min-height: 44px; padding: 0 12px; border-radius: var(--radius-sm); border: 1.5px solid var(--line); background: var(--bg); }
.preset-pick { display: flex; flex-direction: column; gap: var(--sp-2); margin-bottom: var(--sp-3); }
.preset-pick-btn { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; padding: 10px 14px; border-radius: var(--radius-sm); border: 1.5px solid var(--line); background: var(--bg); min-height: 44px; }
.preset-pick-btn strong { font-size: 0.92rem; }
.preset-pick-btn span { font-size: var(--fs-xs); color: var(--ink-soft); }
.preset-pick-btn[aria-pressed="true"] { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--bg)); }
.template-row { display: flex; gap: var(--sp-2); align-items: center; padding: var(--sp-2) 0; border-top: 1px solid var(--line); }
.template-row:first-of-type { border-top: none; }
.template-row input[type="text"] { flex: 1; }
.template-row .frac-field { width: 74px; flex: 0 0 auto; }
.data-actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.data-actions .btn { flex: 1 1 auto; }
.import-status { font-size: var(--fs-sm); margin-top: var(--sp-2); }
.import-status.is-error { color: var(--danger); }
.import-status.is-ok { color: var(--good); }
.confirm-type-row { margin-top: var(--sp-3); }

/* ---------- review walkthrough (the retrieval-practice flow) ------------- */
.review-progress { font-size: var(--fs-xs); font-weight: 700; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: var(--sp-2); }
.review-card { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: var(--sp-4); margin-bottom: var(--sp-3); }
.review-topic-title { font-family: var(--font-display); font-weight: 600; font-size: 1.25rem; margin-bottom: 4px; }
.review-topic-meta { font-size: var(--fs-sm); color: var(--ink-soft); margin-bottom: var(--sp-2); }
.review-note { font-size: var(--fs-sm); color: var(--ink-soft); white-space: pre-wrap; overflow-wrap: anywhere; }
.review-prompt { font-size: var(--fs-sm); color: var(--ink-soft); font-style: italic; margin-bottom: var(--sp-3); }
.confidence-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: var(--sp-2); margin-bottom: var(--sp-3); }
.confidence-btn { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 64px;
  border-radius: var(--radius-sm); border: 1.5px solid var(--line); background: var(--surface); font-weight: 700; font-size: 0.72rem; text-align: center; padding: 6px 4px; }
.confidence-btn .cval { font-family: var(--font-display); font-size: 1.2rem; font-weight: 600; }
.confidence-btn[data-tier="shaky"]:hover { border-color: var(--danger); color: var(--danger); }
.confidence-btn[data-tier="ok"]:hover { border-color: var(--ink-soft); }
.confidence-btn[data-tier="got"]:hover { border-color: var(--good); color: var(--good); }
.review-secondary { display: flex; justify-content: space-between; gap: var(--sp-2); flex-wrap: wrap; }

/* ---------- source cards (About the method) ---------- */
.source-card { padding: var(--sp-3) 0; border-top: 1px solid var(--line); }
.source-card:first-child { border-top: none; padding-top: 0; }
.source-card h3 { font-family: var(--font-display); font-size: 1rem; font-weight: 600; margin-bottom: 4px; }
.source-card p { color: var(--ink-soft); font-size: 0.92rem; margin-bottom: 4px; }
.source-cite { font-size: var(--fs-xs); color: var(--ink-soft); font-style: italic; }
.honesty-box, .giveback-box, .readiness-note-box { background: var(--surface-2); border-radius: var(--radius-sm); padding: var(--sp-3); margin-bottom: var(--sp-4); font-size: 0.92rem; }
.honesty-box .ic, .giveback-box .ic, .readiness-note-box .ic { color: var(--accent); width: 20px; height: 20px; margin-bottom: 6px; }

/* ---------- overlay sheets (dialogs) — Nielsen consistency: one pattern
   for every overlay in the app. Native focus-trap + Esc handled in app.js. */
.overlay { position: fixed; inset: 0; z-index: 80; background: color-mix(in srgb, black 45%, var(--bg) 20%);
  display: flex; align-items: center; justify-content: center; padding: var(--sp-3); overflow-y: auto; }
.sheet { position: relative; background: var(--bg); width: 100%; max-width: var(--maxw-narrow); border-radius: 18px;
  max-height: 90vh; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: var(--sp-5) var(--sp-4) calc(var(--sp-4) + env(safe-area-inset-bottom));
  animation: rise 260ms var(--ease-settle); box-shadow: 0 30px 60px -20px color-mix(in srgb, var(--accent) 30%, black 45%); }
.sheet-wide { max-width: 760px; }
@keyframes rise { from { transform: translateY(20px); opacity: 0.3; } to { transform: none; opacity: 1; } }
.sheet h2 { font-family: var(--font-display); font-size: 1.35rem; font-weight: 600; margin: 0 0 6px; padding-right: 40px; }
.sheet .sub { color: var(--ink-soft); font-size: 0.9rem; margin-bottom: var(--sp-2); }
.sheet-icon { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; background: var(--surface-2); color: var(--accent); border: 1px solid var(--line); margin-bottom: var(--sp-2); }
.sheet-close { position: absolute; top: var(--sp-3); right: var(--sp-3); width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); color: var(--ink-soft); display: grid; place-items: center; }
.sheet-close:active { transform: scale(0.92); }
.settings-section { margin-top: var(--sp-5); }
.settings-section:first-of-type { margin-top: 0; }
.settings-section h3 { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--ink-soft); margin-bottom: var(--sp-2); font-weight: 700; }

/* ---------- install banner / toast ---------- */
.banner { position: fixed; left: 0; right: 0; bottom: 0; z-index: 90; background: var(--surface); border-top: 1px solid var(--line);
  padding: var(--sp-3) var(--sp-4) calc(var(--sp-3) + env(safe-area-inset-bottom)); display: flex; align-items: center; gap: var(--sp-2); justify-content: center; flex-wrap: wrap; }
.banner button { min-height: 44px; }
.banner .close { width: 40px; height: 40px; }
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  z-index: 95; background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: var(--radius-pill);
  display: flex; align-items: center; gap: var(--sp-3); font-size: 0.9rem; font-weight: 600; box-shadow: 0 12px 30px -10px rgba(0,0,0,.4); max-width: 92vw; }
.toast-btn { background: none; border: none; color: var(--accent); font-weight: 700; text-decoration: underline; min-height: 44px; padding: 0 2px; }
[data-theme="dusk"] .toast, [data-theme="plum"] .toast { background: var(--surface-2); color: var(--ink); border: 1px solid var(--line); }

/* ---------- reduced motion / high contrast / forced colors ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
}
@media (prefers-contrast: more) {
  .btn, .field, .queue-row, .exam-row, .topic-row, .panel, .confidence-btn { border-width: 2px; }
}
@media (forced-colors: active) {
  .arc-fill { forced-color-adjust: none; stroke: Highlight; }
  .btn-primary { forced-color-adjust: none; background: Highlight; color: HighlightText; }
}

/* ---------- small spacing utilities (avoid one-off inline styles) ---------- */
.u-mt-2 { margin-top: var(--sp-2); }
.u-mt-3 { margin-top: var(--sp-3); }
.u-mt-4 { margin-top: var(--sp-4); }

/* ---------- responsive ---------- */
@media (max-width: 480px) {
  .confidence-row { grid-template-columns: repeat(5, 1fr); gap: 4px; }
  .confidence-btn { font-size: 0.62rem; min-height: 58px; }
  .form-row { grid-template-columns: 1fr; }
  .exam-detail-head { flex-direction: column; align-items: flex-start; }
}
