/* CCDV-F Study — core stylesheet.
 * Shared tokens + components (see docs/frontend-contract.md); mock.css builds on these.
 * Aesthetic: calm study notebook. Warm paper, ink text, one terracotta accent, serif for reading.
 *
 * Token notes for other modules:
 *   --accent-ink  = text/icon colour to put ON an --accent fill (e.g. .btn.primary). For accent-coloured
 *                   text on the page background use --accent itself.
 *   --*-soft      = tinted backgrounds that pair with the matching colour as text.
 *   Extra (non-contract) tokens: --border-strong, --track, --topbar-h, --read-size.
 */

/* ============================================================ tokens */
:root {
  --bg: #f7f4ee;
  --surface: #fffdf9;
  --surface-2: #f2ede4;
  --border: #e4ddd1;
  --border-strong: #d3cabb;
  --track: #ebe4d8;
  --text: #1f2328;
  --muted: #6a6259;
  --accent: #ad4f2c;
  --accent-ink: #ffffff;
  --accent-soft: #f8ece5;
  --good: #2d7a4b;
  --good-soft: #e4f1e8;
  --bad: #b4233c;
  --bad-soft: #f9e3e6;
  --warn: #8a5d00;
  --warn-soft: #f6ecd3;

  --radius: 10px;
  --shadow: 0 1px 2px rgba(70, 50, 30, 0.05), 0 2px 10px rgba(70, 50, 30, 0.035);
  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --font-read: "Iowan Old Style", "Charter", "Bitstream Charter", "Source Serif Pro", Georgia, serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --topbar-h: 57px;
  --read-size: 1.125rem;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1c1a17;
    --surface: #24211d;
    --surface-2: #2c2824;
    --border: #3a352f;
    --border-strong: #4a443c;
    --track: #35302a;
    --text: #ebe5da;
    --muted: #a59c8f;
    --accent: #e0896a;
    --accent-ink: #1c1a17;
    --accent-soft: #3a2a23;
    --good: #7cc495;
    --good-soft: #1f3127;
    --bad: #f0879a;
    --bad-soft: #3b2228;
    --warn: #e0b65f;
    --warn-soft: #362d1b;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1c1a17;
  --surface: #24211d;
  --surface-2: #2c2824;
  --border: #3a352f;
  --border-strong: #4a443c;
  --track: #35302a;
  --text: #ebe5da;
  --muted: #a59c8f;
  --accent: #e0896a;
  --accent-ink: #1c1a17;
  --accent-soft: #3a2a23;
  --good: #7cc495;
  --good-soft: #1f3127;
  --bad: #f0879a;
  --bad-soft: #3b2228;
  --warn: #e0b65f;
  --warn-soft: #362d1b;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  color-scheme: dark;
}

/* ============================================================ base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html.no-scroll { overflow: hidden; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.5;
  overflow-wrap: break-word;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
a { color: var(--accent); text-underline-offset: 2px; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
img { max-width: 100%; height: auto; }
button { font: inherit; }
code, kbd, pre { font-family: var(--font-mono); }
code { font-size: 0.88em; }
kbd {
  display: inline-block;
  min-width: 1.5em;
  padding: 0 0.35em;
  font-size: 0.75rem;
  line-height: 1.5;
  text-align: center;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#main:focus, .q-card:focus, .sum-card:focus { outline: none; }
::selection { background: color-mix(in srgb, var(--accent) 28%, transparent); }

.vh {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.nowrap { white-space: nowrap; }

.skip {
  position: fixed; left: 12px; top: -64px; z-index: 300;
  padding: 8px 14px; border-radius: 8px;
  background: var(--text); color: var(--bg); border: 0; cursor: pointer;
}
.skip:focus { top: 10px; }

/* ============================================================ shared components (contract) */
.btn {
  appearance: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 38px;
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font: inherit; font-size: 0.93rem; font-weight: 600; line-height: 1.2;
  text-align: center; text-decoration: none;
  cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease, transform .06s ease;
}
.btn:hover { background: var(--surface-2); border-color: var(--muted); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: color-mix(in srgb, var(--accent) 86%, #000); border-color: color-mix(in srgb, var(--accent) 86%, #000); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text); }
.btn.ghost:hover { background: var(--surface-2); border-color: transparent; }
.btn.small { min-height: 32px; padding: 5px 11px; font-size: 0.85rem; border-radius: 7px; }
.btn.danger { color: var(--bad); }
.btn.danger:hover { background: var(--bad-soft); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn:disabled:hover { background: var(--surface); border-color: var(--border-strong); }
.btn.primary:disabled:hover { background: var(--accent); border-color: var(--accent); }
.btn.ghost:disabled:hover { background: transparent; border-color: transparent; }
.btn svg { flex: none; }

.icon-btn {
  appearance: none;
  display: inline-grid; place-items: center;
  width: 36px; height: 36px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background-color .15s ease, color .15s ease;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 1px 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.74rem; font-weight: 600; line-height: 1.6;
  white-space: nowrap;
}
.pill.good { background: var(--good-soft); color: var(--good); border-color: transparent; }
.pill.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.pill.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.pill.accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

.meter {
  display: block; position: relative;
  height: 6px; min-width: 40px;
  border-radius: 999px;
  background: var(--track);
  overflow: hidden;
}
.meter > span {
  display: block; height: 100%; width: 0;
  border-radius: inherit;
  background: var(--accent);
  transition: width .45s ease;
}
.meter.good > span { background: var(--good); }
.meter.warn > span { background: var(--warn); }
.meter.bad > span { background: var(--bad); }
.meter.muted > span { background: var(--muted); }

.opt-list { display: grid; gap: 10px; }
.opt {
  appearance: none;
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: start; gap: 12px;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit; font-size: 1rem; line-height: 1.5;
  text-align: left;
  cursor: pointer;
  transition: border-color .15s ease, background-color .15s ease, opacity .15s ease, box-shadow .15s ease;
}
.opt:hover { border-color: var(--accent); }
.opt .key {
  display: inline-grid; place-items: center;
  width: 26px; height: 26px; margin-top: -1px;
  border-radius: 7px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--muted);
  font-family: var(--font-mono); font-size: 0.8rem; font-weight: 700;
  transition: inherit;
}
.opt.selected { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.opt.selected .key { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.opt.correct { border-color: var(--good); background: var(--good-soft); }
.opt.correct .key { background: var(--good); border-color: var(--good); color: var(--surface); }
.opt.correct.missed { background: transparent; border-style: dashed; border-width: 2px; padding: 11px 13px; }
.opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.opt.wrong .key { background: var(--bad); border-color: var(--bad); color: var(--surface); }
.opt.dim { opacity: 0.55; }
.opt[aria-disabled="true"], .opt-list.static .opt { cursor: default; }
.opt[aria-disabled="true"]:hover.dim, .opt-list.static .opt.dim:hover { border-color: var(--border-strong); }
.opt-mark { width: 1.2em; text-align: center; font-weight: 700; line-height: 1.5; }
.opt.correct .opt-mark { color: var(--good); }
.opt.wrong .opt-mark { color: var(--bad); }
.opt-tag {
  display: inline-block; margin-left: 8px; padding: 0 6px;
  border: 1px solid var(--border-strong); border-radius: 4px;
  font-family: var(--font-ui); font-size: 0.68rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--muted); vertical-align: 1px;
}
.opt-tag.good { color: var(--good); border-color: var(--good); }
.opt-list.static { gap: 8px; }
.opt-list.static .opt { padding: 9px 12px; font-size: 0.94rem; }
.opt-list.static .opt.correct.missed { padding: 8px 11px; }

.page { max-width: 1080px; margin: 0 auto; padding: 32px 28px 96px; }
.page-head { margin: 0 0 26px; }
.page-head h1 {
  margin: 0 0 8px;
  font-family: var(--font-read);
  font-size: clamp(1.7rem, 1.25rem + 1.5vw, 2.3rem);
  font-weight: 600; line-height: 1.15; letter-spacing: -0.01em;
}
.page-head .sub { margin: 0; color: var(--muted); font-size: 0.98rem; }
.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.74rem; font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase;
}

/* ============================================================ topbar */
.topbar {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: saturate(1.2) blur(10px);
  backdrop-filter: saturate(1.2) blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  display: flex; align-items: center; gap: 18px;
  min-height: calc(var(--topbar-h) - 1px);
  padding: 0 20px;
}
.drawer-btn { display: none; }
.brand {
  display: inline-flex; align-items: center; gap: 10px;
  color: var(--text); text-decoration: none; flex: none;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  position: relative; width: 24px; height: 24px; border-radius: 7px; background: var(--accent); flex: none;
}
.brand-mark::after {
  content: ""; position: absolute; left: 6px; right: 6px; top: 7px; height: 10px;
  background:
    linear-gradient(var(--accent-ink), var(--accent-ink)) 0 0 / 100% 2px no-repeat,
    linear-gradient(var(--accent-ink), var(--accent-ink)) 0 4px / 100% 2px no-repeat,
    linear-gradient(var(--accent-ink), var(--accent-ink)) 0 8px / 60% 2px no-repeat;
  opacity: .95;
}
.brand-name { font-family: var(--font-read); font-weight: 700; font-size: 1.08rem; letter-spacing: 0.005em; white-space: nowrap; }
.brand-name span { color: var(--muted); font-weight: 400; font-style: italic; }

.mainnav { display: flex; align-items: center; gap: 2px; flex: 1; min-width: 0; }
.mainnav a {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.92rem; font-weight: 550;
  text-decoration: none; white-space: nowrap;
  transition: background-color .15s ease, color .15s ease;
}
.mainnav a:hover { color: var(--text); background: var(--surface-2); }
.mainnav a.active { color: var(--accent); background: var(--accent-soft); }
.mainnav .count {
  display: inline-grid; place-items: center;
  min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 999px;
  background: var(--bad-soft); color: var(--bad);
  font-size: 0.72rem; font-weight: 700; font-variant-numeric: tabular-nums;
}
.top-tools { display: flex; align-items: center; gap: 8px; flex: none; margin-left: auto; }
.top-meter {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 4px 8px; border-radius: 8px;
  color: var(--muted); text-decoration: none;
  font-size: 0.8rem; font-weight: 600; font-variant-numeric: tabular-nums;
}
.top-meter:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.top-meter .meter { width: 96px; height: 5px; }
.top-meter-label::after { content: " read"; font-weight: 400; }

/* ============================================================ shell & sidebar */
.shell { display: block; overflow-x: clip; }
.sidebar { display: none; }
.shell.has-sidebar { display: grid; grid-template-columns: 300px minmax(0, 1fr); }
.shell.has-sidebar .sidebar {
  display: block;
  position: sticky; top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  height: calc(100dvh - var(--topbar-h));
  overflow-y: auto; overscroll-behavior: contain;
  padding: 18px 12px 48px 14px;
  border-right: 1px solid var(--border);
  background: var(--bg);
  scrollbar-width: thin;
}
#main { min-width: 0; display: block; }
.scrim { display: none; }

.side-head { display: flex; align-items: center; justify-content: space-between; margin: 0 0 10px; padding: 0 8px; }
.side-title { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase; color: var(--muted); }
.side-close { display: none; }
.side-domains, .side-topics, .side-concepts { list-style: none; margin: 0; padding: 0; }
.side-domain { margin: 0 0 12px; }
.side-dlink {
  display: flex; align-items: baseline; gap: 8px;
  padding: 5px 8px; border-radius: 6px;
  color: var(--muted); text-decoration: none;
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
}
.side-dlink:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.side-dnum { color: var(--accent); font-family: var(--font-mono); letter-spacing: 0; }
.side-dname { flex: 1; min-width: 0; }
.side-w { font-variant-numeric: tabular-nums; font-weight: 600; letter-spacing: 0; }
.side-domain.current .side-dlink { color: var(--text); }
.side-tlink {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 8px; border-radius: 8px;
  color: var(--text); text-decoration: none;
  font-size: 0.9rem; line-height: 1.3;
}
.side-tlink:hover { background: var(--surface-2); text-decoration: none; }
.side-topic.current > .side-tlink { font-weight: 650; }
.side-tname { flex: 1; min-width: 0; }
.tick {
  flex: none; display: inline-grid; place-items: center;
  width: 16px; height: 16px; border-radius: 50%;
  border: 1.5px solid var(--border-strong);
  font-size: 10px; font-weight: 800; line-height: 1; color: var(--surface);
}
.tick.part { border-color: var(--accent); background: linear-gradient(90deg, var(--accent) 50%, transparent 50%); }
.tick.done { border-color: var(--good); background: var(--good); }
.side-score {
  flex: none; padding: 0 6px; border-radius: 999px;
  background: var(--surface-2); color: var(--muted);
  font-size: 0.72rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.6;
}
.side-score.good { background: var(--good-soft); color: var(--good); }
.side-score.warn { background: var(--warn-soft); color: var(--warn); }
.side-score.bad { background: var(--bad-soft); color: var(--bad); }
.side-concepts { margin: 2px 0 8px 16px; padding-left: 10px; border-left: 1px solid var(--border); }
.side-c {
  display: flex; align-items: baseline; gap: 9px;
  padding: 4px 8px; border-radius: 6px;
  color: var(--muted); text-decoration: none;
  font-size: 0.84rem; line-height: 1.35;
}
.side-c:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.side-c.read { color: var(--text); }
.cdot { flex: none; width: 6px; height: 6px; border-radius: 50%; background: var(--border-strong); transform: translateY(-2px); }
.side-c.read .cdot { background: var(--good); }
.side-check { font-weight: 600; color: var(--accent); }
.side-check .cdot { background: var(--accent); border-radius: 2px; }
.sidebar a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 650; }

.outline-btn { display: none; }

/* ============================================================ breadcrumbs, sections, banners */
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-size: 0.84rem; color: var(--muted); margin: 0 0 18px; min-width: 0; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--accent); text-decoration: underline; }
.crumbs .sep { color: var(--border-strong); }
.reader-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.reader-top .crumbs { flex: 1; }

.sec-title { margin: 0 0 12px; font-size: 1.02rem; font-weight: 700; letter-spacing: 0.005em; }
.sec-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 16px; margin: 0 0 12px; }
.sec-head .sec-title { margin: 0; }
.sec-head p { margin: 0; }
.dash-sec { margin: 36px 0 0; }

.banner {
  margin: 0 0 18px; padding: 12px 16px;
  border-radius: var(--radius);
  border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
  background: var(--accent-soft); color: var(--text);
  font-size: 0.95rem;
}
.banner.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.banner.good { background: var(--good-soft); border-color: color-mix(in srgb, var(--good) 30%, transparent); }
.empty { text-align: center; padding: 40px 24px; }
.empty h2 { margin: 0 0 8px; font-family: var(--font-read); font-size: 1.35rem; font-weight: 600; }
.empty p { max-width: 46ch; margin: 0 auto 18px; }
.empty .sum-actions { justify-content: center; margin: 0; }
.count-badge {
  display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 7px; margin-left: 6px;
  border-radius: 999px; background: var(--bad-soft); color: var(--bad);
  font-size: 0.75rem; font-weight: 700; vertical-align: 2px;
}

/* ============================================================ dashboard */
.dash-top {
  display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr) minmax(0, 1fr); gap: 16px;
}
.hero {
  padding: 26px 26px 24px;
  background:
    radial-gradient(120% 140% at 100% 0%, var(--accent-soft) 0%, transparent 55%),
    var(--surface);
}
.hero-title { margin: 2px 0 6px; font-family: var(--font-read); font-size: 1.65rem; font-weight: 600; line-height: 1.2; }
.hero-where { margin: 0 0 4px; font-size: 1rem; }
.hero-meta { margin: 0; color: var(--muted); font-size: 0.88rem; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
.stat { display: flex; flex-direction: column; }
.stat-label { margin: 0; color: var(--muted); font-size: 0.74rem; font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase; }
.stat-num { margin: 8px 0 16px; font-family: var(--font-read); font-size: 2.7rem; font-weight: 600; line-height: 1; font-variant-numeric: lining-nums tabular-nums; }
.stat-sub { margin: 12px 0 0; color: var(--muted); font-size: 0.84rem; }
.stat .meter { height: 7px; }

.dgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(232px, 1fr)); gap: 14px; }
.dcard {
  display: flex; flex-direction: column; gap: 10px;
  color: inherit; text-decoration: none;
  transition: border-color .15s ease, transform .15s ease;
}
.dcard:hover { border-color: color-mix(in srgb, var(--accent) 55%, var(--border)); transform: translateY(-1px); text-decoration: none; }
.dcard-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.dnum { font-family: var(--font-mono); font-size: 0.82rem; font-weight: 700; color: var(--accent); }
.dcard-name { margin: 0; font-family: var(--font-read); font-size: 1.12rem; font-weight: 600; line-height: 1.25; min-height: 2.5em; }
.dcard-stats, .mock-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin: 2px 0 0; }
.dcard-stats dt, .mock-stats dt { color: var(--muted); font-size: 0.68rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; white-space: nowrap; }
.dcard-stats { grid-template-columns: repeat(3, auto); justify-content: space-between; column-gap: 10px; }
.dcard-stats dd, .mock-stats dd { margin: 0; font-weight: 650; font-variant-numeric: tabular-nums; }
.dcard-stats dd.good, .mock-stats dd.good, .mini-num.good, .trow-meta .good { color: var(--good); }
.dcard-stats dd.warn, .mini-num.warn, .trow-meta .warn { color: var(--warn); }
.dcard-stats dd.bad, .mock-stats dd.bad, .mini-num.bad, .trow-meta .bad { color: var(--bad); }
.mock-stats dd small { color: var(--muted); font-weight: 400; font-size: 0.75rem; }

.dash-split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; margin-top: 16px; }
.dash-sec + .dash-split { margin-top: 36px; }
.weak-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.weak-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px;
  color: inherit; text-decoration: none;
  transition: background-color .15s ease, border-color .15s ease;
}
.weak-item:hover { background: var(--surface-2); border-color: var(--border-strong); text-decoration: none; }
.weak-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.weak-name { font-weight: 650; }
.weak-meta { color: var(--muted); font-size: 0.82rem; }
.weak-go { color: var(--muted); }
.mock-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.mock-card {
  display: flex; flex-direction: column; gap: 10px;
  padding: 14px; border: 1px solid var(--border); border-radius: 8px;
  color: inherit; text-decoration: none;
  transition: border-color .15s ease, background-color .15s ease;
}
.mock-card:hover { border-color: color-mix(in srgb, var(--accent) 55%, var(--border)); text-decoration: none; }
.mock-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px; }
.mock-name { font-family: var(--font-read); font-size: 1.05rem; font-weight: 600; }
.mock-badges { display: flex; flex-wrap: wrap; gap: 4px; }
.mock-none { margin: 0; color: var(--muted); font-size: 0.86rem; }
.mock-cta { margin-top: auto; color: var(--accent); font-size: 0.88rem; font-weight: 650; }
.note { background: var(--surface-2); box-shadow: none; }
.note p { margin: 0 0 10px; font-size: 0.92rem; }
.note p:last-child { margin-bottom: 0; }
.tools p { margin: 0 0 12px; }
.tool-row { display: flex; flex-wrap: wrap; gap: 8px; }
.tool-msg { margin: 10px 0 0; min-height: 1.3em; color: var(--muted); }
.tool-msg.good { color: var(--good); }
.tool-msg.bad { color: var(--bad); }

/* ============================================================ domain page */
.domain-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.mini {
  display: flex; flex-direction: column; gap: 6px;
  padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
}
.mini-label { color: var(--muted); font-size: 0.72rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.mini-num { font-family: var(--font-read); font-size: 1.75rem; font-weight: 600; line-height: 1.1; font-variant-numeric: lining-nums tabular-nums; }
.mini-num small { color: var(--muted); font-size: 1rem; }
.trows { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.trow { display: flex; align-items: center; gap: 18px; padding: 16px 18px; }
.trow-main { flex: 1; min-width: 0; }
.trow-name { margin: 0 0 6px; font-family: var(--font-read); font-size: 1.14rem; font-weight: 600; line-height: 1.25; }
.trow-name a { color: var(--text); text-decoration: none; }
.trow-name a:hover { color: var(--accent); text-decoration: underline; }
.trow-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; margin: 0 0 10px; color: var(--muted); font-size: 0.85rem; }
.trow .meter { max-width: 320px; }
.trow-actions { display: flex; gap: 8px; flex: none; }
.practice-btn { margin-top: 14px; }
.recall-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 12px; align-items: start; }
.recall { padding: 0; transition: border-color .15s ease; }
.recall[open] { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.recall summary {
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 12px;
  padding: 16px 18px; cursor: pointer; list-style: none;
}
.recall summary::-webkit-details-marker { display: none; }
.recall-n {
  grid-row: span 2; display: inline-grid; place-items: center;
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
  font-size: 0.8rem; font-weight: 700;
}
.recall-q { font-family: var(--font-read); font-size: 1.02rem; line-height: 1.45; }
.recall-cta { color: var(--accent); font-size: 0.75rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.recall .when-open, .recall[open] .when-closed { display: none; }
.recall[open] .when-open { display: inline; }
.recall-a { margin: 0 18px 16px 56px; padding-top: 12px; border-top: 1px dashed var(--border-strong); font-family: var(--font-read); line-height: 1.55; }
.recall-a p { margin: 0 0 8px; }
.recall-a p:last-child { margin: 0; }

/* ============================================================ pager */
.pager { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; margin-top: 44px; }
.pager-link {
  display: flex; flex-direction: column; gap: 4px;
  padding: 14px 18px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
  color: var(--text); text-decoration: none;
  transition: border-color .15s ease, background-color .15s ease;
}
.pager-link:hover { border-color: var(--accent); text-decoration: none; }
.pager-link.next { text-align: right; }
.pager-dir { color: var(--muted); font-size: 0.75rem; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; }
.pager-title { font-family: var(--font-read); font-size: 1.04rem; line-height: 1.3; }
.pager-link.to-check { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.pager-link.to-check .pager-dir, .pager-link.to-check .pager-title { color: var(--accent); }
.pager-link.to-check .pager-title { font-weight: 600; }

/* ============================================================ reader */
.page.reader { max-width: 800px; }
.topic-facts { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; }
.objective { margin: 0 0 8px; padding: 4px 0 4px 18px; border-left: 3px solid var(--accent); }
.objective .label { margin: 0 0 6px; color: var(--muted); font-size: 0.74rem; font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase; }
.objective p { margin: 0; font-family: var(--font-read); font-size: 1.14rem; line-height: 1.6; }
.clist { list-style: none; margin: 0; padding: 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.clist li + li { border-top: 1px solid var(--border); }
.clist-item { display: flex; align-items: baseline; gap: 14px; padding: 11px 16px; color: var(--text); text-decoration: none; transition: background-color .15s ease; }
.clist-item:hover { background: var(--surface-2); text-decoration: none; }
.clist-n { flex: none; min-width: 2ch; text-align: right; color: var(--muted); font-family: var(--font-mono); font-size: 0.8rem; }
.clist-title { flex: 1; min-width: 0; font-family: var(--font-read); font-size: 1.04rem; }
.clist-state { flex: none; color: var(--good); font-weight: 700; }
.overview-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-top: 26px; }

.reader-pos { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin: 0 0 18px; }
.pos-label { color: var(--muted); font-size: 0.75rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; font-variant-numeric: tabular-nums; }
.dots { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; }
.dot { display: inline-grid; place-items: center; min-width: 14px; height: 20px; border-radius: 4px; text-decoration: none; }
.dot::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--track); box-shadow: inset 0 0 0 1px var(--border-strong); transition: background-color .15s ease, width .15s ease; }
.dot.read::before { background: color-mix(in srgb, var(--good) 70%, var(--surface)); box-shadow: none; }
.dot.current::before { width: 20px; border-radius: 4px; background: var(--accent); box-shadow: none; }
.dot:hover::before { background: var(--accent); box-shadow: none; }

.concept-title {
  margin: 0 0 22px;
  font-family: var(--font-read);
  font-size: clamp(1.65rem, 1.3rem + 1.2vw, 2.15rem);
  font-weight: 600; line-height: 1.18; letter-spacing: -0.01em;
}
.kbd-hint { margin: 18px 0 0; color: var(--muted); font-size: 0.8rem; text-align: center; }

/* reading column */
.prose {
  max-width: 70ch;
  font-family: var(--font-read);
  font-size: var(--read-size);
  line-height: 1.68;
  color: var(--text);
  font-variant-numeric: lining-nums proportional-nums;
  hanging-punctuation: first;
}
.prose > :first-child { margin-top: 0; }
.prose p, .prose ul, .prose ol, .prose blockquote, .prose pre, .prose figure, .prose .table-wrap { margin: 0 0 1.05em; }
.prose h1, .prose h2, .prose h3, .prose h4 { font-family: var(--font-read); font-weight: 600; line-height: 1.25; margin: 1.7em 0 0.55em; letter-spacing: -0.005em; }
.prose h1 { font-size: 1.5rem; }
.prose h2 { font-size: 1.36rem; }
.prose h3 { font-size: 1.16rem; }
.prose h4 { font-size: 1rem; text-transform: uppercase; letter-spacing: 0.05em; font-family: var(--font-ui); color: var(--muted); }
.prose ul, .prose ol { padding-left: 1.35em; }
.prose li { margin: 0.4em 0; padding-left: 0.15em; }
.prose li > ul, .prose li > ol { margin: 0.35em 0 0.5em; }
.prose li::marker { color: var(--accent); }
.prose strong { font-weight: 700; }
.prose em { font-style: italic; }
.prose a { color: var(--accent); }
.prose hr { border: 0; border-top: 1px solid var(--border); margin: 2.2em 0; }
.prose blockquote { padding: 2px 0 2px 1.1em; border-left: 3px solid var(--accent); color: var(--muted); font-style: italic; }
.prose code {
  padding: 0.08em 0.36em;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface-2);
  font-size: 0.82em;
  font-variant-numeric: normal;
  overflow-wrap: anywhere;
}
.prose pre {
  max-width: 100%;
  overflow-x: auto;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  font-size: 0.84rem; line-height: 1.55;
  tab-size: 4;
}
.prose pre code { padding: 0; border: 0; background: none; font-size: inherit; overflow-wrap: normal; white-space: pre; }
.prose figure { margin: 1.8em auto; text-align: center; }
.prose img {
  display: block; max-width: 100%; height: auto; margin: 0 auto;
  border: 1px solid var(--border); border-radius: 8px; background: #fff;
  cursor: zoom-in;
}
.prose figcaption {
  max-width: 62ch; margin: 0.7em auto 0;
  color: var(--muted);
  font-family: var(--font-ui); font-size: 0.84rem; line-height: 1.45;
}
.table-wrap {
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.prose table, table.data {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-ui);
  font-size: 0.9rem; line-height: 1.45;
  font-variant-numeric: tabular-nums;
}
.prose th, .prose td, table.data th, table.data td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left; vertical-align: top;
}
.prose td { min-width: 9ch; }
.prose th, table.data th { background: var(--surface-2); font-weight: 650; white-space: nowrap; }
.prose tr:last-child td, table.data tr:last-child td { border-bottom: 0; }
.prose tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--surface-2) 45%, transparent); }
table.data .num { text-align: right; white-space: nowrap; }

/* lightbox */
.lightbox {
  position: fixed; inset: 0; z-index: 200;
  display: grid; place-items: center;
  padding: 56px 20px 24px;
  background: rgba(18, 14, 11, 0.88);
  cursor: zoom-out;
}
.lb-fig { margin: 0; max-width: min(1280px, 100%); text-align: center; }
.lb-fig img { max-width: 100%; max-height: calc(100vh - 140px); max-height: calc(100dvh - 140px); object-fit: contain; border-radius: 8px; background: #fff; }
.lb-fig figcaption { margin: 12px auto 0; max-width: 72ch; color: #ece6dc; font-size: 0.88rem; line-height: 1.45; }
.lb-close {
  position: fixed; top: 12px; right: 12px;
  display: grid; place-items: center; width: 40px; height: 40px;
  border: 0; border-radius: 50%;
  background: rgba(255, 255, 255, 0.14); color: #fff; cursor: pointer;
}
.lb-close:hover { background: rgba(255, 255, 255, 0.24); }

/* ============================================================ quiz */
.page.quiz-page { max-width: 800px; }
.quiz-bar { display: flex; align-items: center; gap: 14px; margin: 0 0 16px; }
.quiz-count { flex: none; color: var(--muted); font-size: 0.88rem; font-variant-numeric: tabular-nums; }
.quiz-count b { color: var(--text); }
.quiz-bar .meter { flex: 1; }
.q-card { padding: 24px 24px 22px; }
.q-meta { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; }
.q-stem { margin: 0 0 20px; font-family: var(--font-read); font-size: 1.17rem; line-height: 1.55; }
.q-stem.small-stem { font-size: 1.02rem; margin-bottom: 14px; }
.q-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-top: 20px; }
.q-hint { margin: 0; color: var(--muted); font-size: 0.84rem; }
.q-hint.nudge { color: var(--bad); animation: nudge .32s ease; }
.sel-count { font-weight: 650; color: var(--text); }
@keyframes nudge { 0%, 100% { transform: none; } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
.q-feedback { margin-top: 22px; padding-top: 18px; border-top: 1px dashed var(--border-strong); }
.verdict { margin: 0 0 8px; font-size: 1rem; }
.verdict.good strong { color: var(--good); }
.verdict.bad strong { color: var(--bad); }
.expl { font-family: var(--font-read); font-size: 1.02rem; line-height: 1.62; }
.expl p { margin: 0 0 0.7em; }

.sum-card { padding: 24px; }
.sum-top { display: flex; align-items: center; gap: 22px; margin-bottom: 18px; }
.sum-score { display: flex; align-items: baseline; gap: 6px; font-family: var(--font-read); font-variant-numeric: lining-nums tabular-nums; }
.sum-score .big { font-size: 3.1rem; font-weight: 600; line-height: 1; }
.sum-score .of { color: var(--muted); font-size: 1.35rem; }
.sum-label { margin: 0 0 2px; color: var(--muted); font-size: 0.74rem; font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase; }
.sum-msg { margin: 0; font-size: 1rem; }
.sum-card .meter { height: 8px; }
.sum-card + .banner { margin-top: 16px; }
.sum-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 20px 0 30px; }
.sum-list, .rev-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.sum-item { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.sum-item summary, .rev-item summary { cursor: pointer; list-style: none; }
.sum-item summary::-webkit-details-marker, .rev-item summary::-webkit-details-marker { display: none; }
.sum-item summary { display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px; }
.sum-mark {
  flex: none; display: inline-grid; place-items: center;
  width: 24px; height: 24px; border-radius: 50%;
  font-size: 0.82rem; font-weight: 800;
}
.sum-item.ok .sum-mark { background: var(--good-soft); color: var(--good); }
.sum-item.miss .sum-mark { background: var(--bad-soft); color: var(--bad); }
.sum-stem, .rev-stem {
  flex: 1; min-width: 0;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden;
  line-height: 1.45;
}
.sum-item[open] .sum-stem, .rev-item[open] .rev-stem { -webkit-line-clamp: unset; line-clamp: none; display: block; overflow: visible; font-family: var(--font-read); font-size: 1.04rem; line-height: 1.5; }
.sum-item summary::after, .rev-item summary::after { content: "Show"; flex: none; margin-left: auto; color: var(--accent); font-size: 0.76rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; }
.sum-item[open] summary::after, .rev-item[open] summary::after { content: "Hide"; color: var(--muted); }
.sum-body { padding: 0 16px 16px 50px; }

/* ============================================================ review */
.review-actions { margin: -6px 0 8px; }
.rev-group { margin-top: 30px; }
.rev-item { padding: 0; }
.rev-item summary { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 14px; padding: 14px 16px; }
.rev-item summary::after { grid-column: 2; grid-row: 1; align-self: start; }
.rev-meta { grid-column: 1; display: flex; flex-wrap: wrap; gap: 6px; }
.rev-body { padding: 0 16px 16px; }

/* ============================================================ library */

/* ============================================================ responsive */
@media (max-width: 1080px) {
  .top-meter .meter { display: none; }
}
@media (max-width: 980px) {
  .dash-top { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .dash-top .hero { grid-column: 1 / -1; }
}
@media (max-width: 899.98px) {
  .shell.has-sidebar { display: block; }
  .shell.has-sidebar .sidebar {
    position: fixed; z-index: 90; top: 0; bottom: 0; left: 0;
    width: min(340px, 88vw); height: auto;
    padding-top: 14px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.22);
    transform: translateX(-104%);
    visibility: hidden;
    transition: transform .22s ease, visibility 0s linear .22s;
  }
  .shell.drawer-open .sidebar { transform: none; visibility: visible; transition: transform .22s ease, visibility 0s; }
  .shell.drawer-open .scrim { display: block; position: fixed; inset: 0; z-index: 85; background: rgba(18, 14, 11, 0.42); }
  .side-close { display: inline-grid; }
  .has-outline .drawer-btn { display: inline-grid; }
  .outline-btn { display: inline-flex; flex: none; margin-top: -6px; }
  .dash-split { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  :root { --topbar-h: 0px; } /* topbar scrolls away on phones, so sticky offsets start at 0 */
  .topbar { position: static; }
  .topbar-inner { flex-wrap: wrap; gap: 4px 8px; padding: 8px 12px 0; }
  .mainnav {
    order: 3; flex: 1 0 100%;
    overflow-x: auto; scrollbar-width: none;
    padding: 2px 0 8px;
  }
  .mainnav::-webkit-scrollbar { display: none; }
  .mainnav a { padding: 6px 9px; font-size: 0.9rem; }
  .top-meter-label::after { content: ""; }
  .page { padding: 20px 16px 72px; }
  .card { padding: 16px; }
  .hero { padding: 20px; }
  .q-card { padding: 18px 16px; }
  .trow { flex-direction: column; align-items: stretch; gap: 12px; padding: 14px 16px; }
  .trow-actions .btn { flex: 1; }
  .domain-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .mini { padding: 10px 12px; }
  .mini-num { font-size: 1.35rem; }
  .pager { grid-template-columns: minmax(0, 1fr); }
  .pager-link.next { order: -1; }
  .sum-body { padding: 0 14px 14px; }
  .recall-a { margin-left: 18px; }
}
@media (max-width: 560px) {
  :root { --read-size: 1.07rem; }
  .dash-top { grid-template-columns: minmax(0, 1fr); }
  .stat-num { font-size: 2.2rem; margin-bottom: 12px; }
  .mock-cards { grid-template-columns: minmax(0, 1fr); }
  .brand-name span { display: none; }
  .sum-top { gap: 16px; }
  .sum-score .big { font-size: 2.5rem; }
  .q-stem { font-size: 1.08rem; }
  .opt { padding: 11px 12px; gap: 10px; font-size: 0.97rem; }
  .opt.correct.missed { padding: 10px 11px; }
  .quiz-bar { gap: 10px; }
  .recall-grid { grid-template-columns: minmax(0, 1fr); }
  .dgrid { grid-template-columns: minmax(0, 1fr); }
  .dcard-name { min-height: 0; }
  .kbd-hint { display: none; }
}

/* dark-mode touches */
:root[data-theme="dark"] .prose img, :root[data-theme="dark"] .lb-fig img { filter: brightness(0.93); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .prose img, :root:not([data-theme="light"]) .lb-fig img { filter: brightness(0.93); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    transition-delay: 0s !important;
    scroll-behavior: auto !important;
  }
}

@media print {
  .topbar, .sidebar, .scrim, .pager, .kbd-hint, .outline-btn, .skip { display: none !important; }
  .shell.has-sidebar { display: block; }
  body { background: #fff; }
}
