/* Layout: chapter rail on the left, one reading column on the right. Serif for study text, sans for controls. Two signal colours in diagrams: teal and orange. */
:root {
  --bg: #f2f4f7; --surface: #ffffff; --surface-2: #e9edf2; --fg: #16202b; --muted: #566475; --line: #d6dde5; --line-strong: #97a4b3;
  --accent: #0b6a70; --accent-soft: #d5ebec; --accent-fg: #ffffff; --warm: #b0510e; --warm-soft: #fbe5d0;
  --good: #1c7743; --good-soft: #dbf0e2; --bad: #b3261e; --bad-soft: #fbdfdc; --mark: #ffe680; --shadow: 0 1px 2px rgba(22, 32, 43, .06), 0 6px 20px rgba(22, 32, 43, .06);
  --f-display: "Source Sans 3", "Segoe UI", system-ui, -apple-system, sans-serif; --f-body: "Source Sans 3", "Segoe UI", system-ui, -apple-system, sans-serif; --f-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --f-prose: "Source Serif 4", Georgia, "Times New Roman", serif; --gut: 16px; --rail: 272px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1319; --surface: #161d25; --surface-2: #1f2833; --fg: #e3e8ee; --muted: #93a1b1; --line: #2a3542; --line-strong: #566475;
    --accent: #5fc9c4; --accent-soft: #123a3c; --accent-fg: #05201f; --warm: #f1a25e; --warm-soft: #40280f;
    --good: #62cd8b; --good-soft: #133422; --bad: #ff8d83; --bad-soft: #45201d; --mark: #6a5810; --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1319; --surface: #161d25; --surface-2: #1f2833; --fg: #e3e8ee; --muted: #93a1b1; --line: #2a3542; --line-strong: #566475;
  --accent: #5fc9c4; --accent-soft: #123a3c; --accent-fg: #05201f; --warm: #f1a25e; --warm-soft: #40280f;
  --good: #62cd8b; --good-soft: #133422; --bad: #ff8d83; --bad-soft: #45201d; --mark: #6a5810; --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25); color-scheme: dark;
}
:root[data-theme="light"] { color-scheme: light; }
@media (min-width: 720px) { :root { --gut: 32px; } }

*, *::before, *::after { box-sizing: border-box; }
html { scroll-padding-top: 76px; -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 16px/1.6 var(--f-body); }
[hidden] { display: none !important; }
a { color: var(--accent); text-underline-offset: 3px; }
h1, h2, h3 { font-family: var(--f-display); line-height: 1.2; text-wrap: balance; margin: 0; letter-spacing: -.01em; }
h1 { font-size: clamp(1.6rem, 3.5vw, 2.1rem); font-weight: 700; }
p { margin: 0; }
kbd { font: 600 .75rem var(--f-body); border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 4px; padding: 0 .35em; background: var(--surface); color: var(--muted); }
code { overflow-wrap: anywhere; font: .88em var(--f-mono); background: var(--surface-2); padding: .08em .35em; border-radius: 4px; }
mark { background: var(--mark); color: inherit; border-radius: 2px; padding: 0 1px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.ic { width: 1.05em; height: 1.05em; fill: currentColor; flex: none; vertical-align: -.15em; }
.ic .st { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; }
.muted { color: var(--muted); font-size: .9rem; }
.eyebrow { font-size: .88rem; font-weight: 600; color: var(--muted); }

/* ----- frame ----- */
#app { display: grid; grid-template-columns: var(--rail) minmax(0, 1fr); min-height: 100vh; }
#side { position: sticky; top: 0; align-self: start; height: 100vh; height: 100dvh; overflow-y: auto; background: var(--surface); border-right: 1px solid var(--line); padding: 18px 12px 28px; padding-left: max(12px, env(safe-area-inset-left, 0px)); display: flex; flex-direction: column; gap: 14px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px; color: var(--fg); text-decoration: none; }
.brand svg { width: 34px; height: 34px; flex: none; }
.brand b { display: block; font: 600 1.05rem var(--f-display); }
.brand small { display: block; font-size: .74rem; color: var(--muted); }
#nav .grp { display: flex; flex-direction: column; gap: 1px; }
#nav .grp-l { font-size: .8rem; font-weight: 600; color: var(--muted); padding: 16px 10px 6px; }
#nav a { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 5px; color: var(--fg); text-decoration: none; font-size: .92rem; line-height: 1.3; }
#nav a:hover { background: var(--surface-2); }
#nav a[aria-current] { background: var(--accent-soft); color: var(--fg); font-weight: 600; }
#nav .num, .ep .num { font-size: .8rem; font-weight: 600; width: 1.9em; height: 1.9em; display: grid; place-items: center; border: 1px solid var(--line-strong); border-radius: 6px; flex: none; color: var(--muted); }
#nav a[aria-current] .num { border-color: var(--accent); color: var(--accent); }
#nav .t { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.badge { margin-left: auto; background: var(--warm); color: var(--surface); font-size: .78rem; font-weight: 700; border-radius: 99px; padding: 0 8px; }
.meter { display: block; height: 4px; border-radius: 4px; background: var(--surface-2); overflow: hidden; min-width: 40px; }
#nav a[aria-current] .meter { background: var(--surface); }
.meter i { display: block; height: 100%; background: var(--accent); border-radius: 4px; transition: width .3s; }
.meter.big { height: 8px; }
#main { min-width: 0; display: flex; flex-direction: column; }
#top { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; display: flex; gap: 10px; align-items: center; padding: 10px var(--gut); padding-left: max(var(--gut), env(safe-area-inset-left, 0px)); padding-right: max(var(--gut), env(safe-area-inset-right, 0px)); background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 30; background: var(--bg); }
.search { flex: 1; max-width: 520px; }
.search input { width: 100%; font: inherit; font-size: .95rem; padding: 8px 12px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface); color: var(--fg); }
.icon-btn { width: 38px; height: 38px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 5px; background: var(--surface); color: var(--fg); cursor: pointer; font-size: 1.05rem; flex: none; }
.icon-btn:hover { border-color: var(--line-strong); }
#menu { display: none; }
#theme { margin-left: auto; }
#scrim { display: none; }
#view { flex: 1; padding-block: 28px 80px; padding-left: max(var(--gut), env(safe-area-inset-left, 0px)); padding-right: max(var(--gut), env(safe-area-inset-right, 0px)); max-width: 1180px; width: 100%; }
#foot { padding: 20px var(--gut) 28px; padding-left: max(var(--gut), env(safe-area-inset-left, 0px)); padding-right: max(var(--gut), env(safe-area-inset-right, 0px)); color: var(--muted); font-size: .8rem; border-top: 1px solid var(--line); max-width: 1180px; }
body.has-player #foot { padding-bottom: 96px; }
@media (max-width: 900px) {
  #app { grid-template-columns: minmax(0, 1fr); }
  #side { position: fixed; z-index: 50; left: 0; top: 0; width: min(86vw, 300px); transform: translateX(-102%); transition: transform .2s; box-shadow: var(--shadow); padding-top: calc(18px + env(safe-area-inset-top, 0px)); }
  body.nav-open #side { transform: none; }
  body.nav-open #scrim { display: block; position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, .4); }
  #menu { display: grid; }
}

/* ----- buttons ----- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: 500 .93rem var(--f-body); padding: 9px 16px; border-radius: 5px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--fg); cursor: pointer; text-decoration: none; text-align: center; }
.btn:hover:not(:disabled) { border-color: var(--fg); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.pri { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); font-weight: 600; }
.btn.pri:hover:not(:disabled) { filter: brightness(1.08); border-color: var(--accent); }
.btn.sm { font-size: .82rem; padding: 5px 10px; border-color: var(--line); }
.btn.wide { width: 100%; margin-top: 12px; }
.btn.danger { color: var(--bad); border-color: var(--bad); }
.btn.on { background: var(--accent-soft); border-color: var(--accent); font-weight: 600; }
.acts { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; align-items: center; }
.acts.col { flex-direction: column; align-items: stretch; margin-top: 0; }
.acts.center { justify-content: center; }

/* ----- chapter header ----- */
.ch-head { display: flex; flex-direction: column; gap: 10px; margin-bottom: 26px; }
.blurb { color: var(--muted); max-width: 62ch; font-size: 1.05rem; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin-top: 8px; }
.tabs a { padding: 8px 14px; text-decoration: none; color: var(--muted); font-weight: 500; font-size: .93rem; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a:hover { color: var(--fg); }
.tabs a[aria-current] { color: var(--fg); border-bottom-color: var(--accent); }

/* ----- learn ----- */
.learn { display: grid; grid-template-columns: minmax(0, 1fr); gap: 28px; }
.toc { display: flex; flex-direction: column; gap: 2px; font-size: .88rem; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 14px; }
.toc-l { font-size: .8rem; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.toc a { display: flex; gap: 10px; padding: 4px 8px; border-radius: 6px; color: var(--muted); text-decoration: none; line-height: 1.35; border-left: 2px solid transparent; }
.toc a span { font-size: .8rem; font-weight: 600; width: 1.3em; flex: none; padding-top: 2px; }
.toc a:hover { color: var(--fg); background: var(--surface-2); }
.toc a.here { color: var(--fg); border-left-color: var(--accent); font-weight: 500; }
.toc a.is-read span { color: var(--good); }
.toc a.is-read span::after { content: "✓"; margin-left: 1px; }
.toc a.is-read span { font-size: 0; }
.toc a.is-read span::after { font-size: .8rem; }
@media (min-width: 1160px) {
  .learn { grid-template-columns: minmax(0, 70ch) 240px; justify-content: space-between; }
  .toc { order: 2; position: sticky; top: 76px; align-self: start; max-height: calc(100vh - 100px); overflow-y: auto; }
}
article { min-width: 0; max-width: 70ch; }
.sec { padding-bottom: 30px; margin-bottom: 30px; border-bottom: 1px solid var(--line); }
.sec-h { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; margin-bottom: 14px; }
.sec-h h2 { font-size: 1.45rem; font-weight: 600; }
.sec-n { font-size: .95rem; font-weight: 600; color: var(--muted); margin-right: .5em; font-variant-numeric: tabular-nums; }
.prose { display: flex; flex-direction: column; gap: 14px; font: 1.08rem/1.65 var(--f-prose); }
.prose > *, .widget > *, .narrow > *, .sheet > * { min-width: 0; max-width: 100%; }
.prose .call, .prose table, .prose figcaption, .prose .widget { font-family: var(--f-body); }
.prose .call { font-size: 1rem; line-height: 1.55; }
.prose h3 { font: 600 1.15rem var(--f-display); margin-top: 10px; }
.prose ul, .prose ol { margin: 0; padding-left: 1.3em; display: flex; flex-direction: column; gap: 6px; }
.prose li::marker { color: var(--muted); }
.speaking { background: var(--mark); border-radius: 4px; box-shadow: 0 0 0 4px var(--mark); }
.call { border: 1px solid var(--line); border-radius: 6px; padding: 12px 16px; background: var(--surface); display: flex; flex-direction: column; gap: 4px; }
.call-l { font: 700 .82rem var(--f-body); }
.call.key { background: var(--accent-soft); border-color: transparent; } .call.key .call-l { color: var(--accent); }
.call.trap { background: var(--warm-soft); border-color: transparent; } .call.trap .call-l { color: var(--warm); }
.call.ex .call-l, .call.def .call-l { color: var(--muted); }
.tw { overflow-x: auto; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: .92rem; line-height: 1.45; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font: 600 .88rem var(--f-body); color: var(--fg); background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
table.num td { font-variant-numeric: tabular-nums; white-space: nowrap; }
table.num .meter { display: inline-block; width: 70px; vertical-align: middle; margin-right: 6px; }
.fig { margin: 4px 0; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 14px; }
.fig-s { overflow-x: auto; }
.fig svg, .w-fig svg { display: block; width: 100%; height: auto; margin: 0 auto; }
figcaption { font-size: .85rem; color: var(--muted); margin-top: 10px; line-height: 1.45; }
.done { display: inline-flex; gap: 10px; align-items: center; margin-top: 18px; padding: 9px 14px; border: 1px solid var(--line-strong); border-radius: 5px; cursor: pointer; font-weight: 500; font-size: .93rem; background: var(--surface); }
.done input { width: 18px; height: 18px; accent-color: var(--good); }
.done:has(input:checked) { background: var(--good-soft); border-color: var(--good); }
.after { display: flex; flex-wrap: wrap; gap: 10px; }
.pn { display: flex; justify-content: space-between; gap: 16px; margin-top: 28px; font-size: .93rem; }

/* diagrams */
.d-txt { font: 13px var(--f-body); fill: var(--fg); }
.d-b { font-weight: 600; }
.d-sm { font-size: 11.5px; fill: var(--muted); }
.d-sm.halo, .d-b.halo { paint-order: stroke; stroke: var(--surface); stroke-width: 5px; stroke-linejoin: round; }
.d-sm.halo { fill: var(--fg); }
.d-box { fill: var(--surface-2); stroke: var(--line-strong); stroke-width: 1.2; }
.d-box.a { fill: var(--accent-soft); stroke: var(--accent); }
.d-box.w { fill: var(--warm-soft); stroke: var(--warm); }
.d-box.h { fill: var(--surface); stroke: var(--fg); }
.d-box.soft { fill: none; stroke-dasharray: 5 4; }
.d-box.dead { fill: var(--bad-soft); stroke: var(--bad); stroke-dasharray: 3 3; }
.d-box.ghost { fill: var(--surface); stroke: var(--line); }
.d-box.both { fill: var(--accent); stroke: var(--warm); stroke-width: 3; }
.d-box.both + .d-txt { fill: var(--accent-fg); }
.d-note { fill: var(--surface); stroke: var(--line-strong); }
.d-arr { stroke: var(--fg); stroke-width: 1.4; fill: none; }
.d-arr.a { stroke: var(--accent); stroke-width: 1.8; } .d-arr.w { stroke: var(--warm); stroke-width: 1.8; }
.d-arr.dash, .d-line.dash { stroke-dasharray: 5 4; }
.d-head { fill: var(--fg); } .d-head.a { fill: var(--accent); } .d-head.w { fill: var(--warm); }
.d-line { stroke: var(--line-strong); stroke-width: 1.2; }
.d-line.life { stroke-dasharray: 3 4; }
.d-line.thick { stroke: var(--fg); stroke-width: 1.6; }
.d-dot { fill: var(--line-strong); }

/* widgets */
.widget { border: 1px solid var(--accent); border-radius: 6px; background: var(--surface); padding: 14px; display: flex; flex-direction: column; gap: 12px; font-size: .93rem; }
.w-head { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; }
.w-ctl { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.w-ctl label { display: inline-flex; gap: 6px; align-items: center; font-size: .85rem; }
.widget select, .widget input[type=number] { font: inherit; padding: 4px 6px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--surface); color: var(--fg); width: 4.6em; }
.w-fig { overflow-x: auto; }
.w-msg { line-height: 1.5; }
.w-split { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; }
.w-split .w-fig { flex: 1 1 280px; min-width: 0; }
.w-side { flex: 0 1 200px; }
table.mini { font-size: .85rem; } table.mini caption { font-weight: 600; text-align: left; padding-bottom: 6px; } table.mini th, table.mini td { padding: 4px 10px; }
.w-sliders { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.w-sliders label { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; font-size: .85rem; }
.w-sliders input { grid-column: 1; width: 100%; accent-color: var(--accent); } .w-sliders output { font-weight: 700; font-variant-numeric: tabular-nums; }
.checks { list-style: none; padding: 0; margin: 0 0 8px; display: flex; flex-direction: column; gap: 6px; }
.checks .ok { color: var(--good); } .checks .bad { color: var(--bad); }

/* ----- home ----- */
.home { display: flex; flex-direction: column; gap: 34px; }
.hero { display: grid; grid-template-columns: minmax(0, 1fr); gap: 24px; align-items: start; }
.hero > div:first-child { display: flex; flex-direction: column; gap: 10px; }
@media (min-width: 760px) { .hero { grid-template-columns: minmax(0, 1fr) 280px; } }
.ready { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 18px; display: flex; flex-direction: column; gap: 6px; }
.ready-n { font: 600 2rem/1.1 var(--f-display); font-variant-numeric: tabular-nums; }
.ready-l { font-size: .88rem; font-weight: 600; color: var(--muted); }
.ready-s { font-size: .82rem; color: var(--muted); margin-top: 8px; }
.ready-s input { font: inherit; padding: 2px 6px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--fg); }
.h-sm { font: 600 1.1rem var(--f-display); margin-bottom: 12px; }
.row-h { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.next { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.next-c { display: flex; flex-direction: column; gap: 4px; padding: 16px; border-radius: 6px; text-decoration: none; color: var(--fg); background: var(--surface); border: 1px solid var(--line); }
.next-c:first-child { border-color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
.next-c strong { font: 600 1.05rem var(--f-display); }
.next-c span { font-size: .88rem; color: var(--muted); line-height: 1.45; }
.next-c:hover { border-color: var(--fg); }
.streak { display: flex; gap: 10px; align-items: center; font-size: .8rem; color: var(--muted); margin-bottom: 12px; }
.days { display: inline-flex; gap: 3px; } .days i { width: 10px; height: 10px; border-radius: 2px; background: var(--surface-2); border: 1px solid var(--line); }
.days .l1 { background: color-mix(in srgb, var(--accent) 35%, var(--surface)); } .days .l2 { background: color-mix(in srgb, var(--accent) 65%, var(--surface)); } .days .l3 { background: var(--accent); }
.grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); }
.ch-card { display: flex; gap: 14px; padding: 14px; border-radius: 6px; text-decoration: none; color: var(--fg); background: var(--surface); border: 1px solid var(--line); }
.ch-card:hover { border-color: var(--fg); }
.ch-card.bonus { background: transparent; border-style: dashed; }
.ch-num { font: 600 1.25rem var(--f-display); width: 2em; height: 2em; display: grid; place-items: center; border-radius: 5px; background: var(--surface-2); flex: none; }
.ch-b { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1; }
.ch-b strong { font: 600 1.02rem var(--f-display); }
.ch-b small { color: var(--muted); font-size: .78rem; }
.ch-m { display: flex; gap: 8px; align-items: center; margin-top: 4px; } .ch-m .meter { flex: 1; } .ch-m em { font-size: .8rem; font-style: normal; color: var(--muted); }
.how ol { margin: 0 0 12px; padding-left: 1.3em; display: flex; flex-direction: column; gap: 6px; max-width: 70ch; }

/* ----- quiz, cards, exam ----- */
.narrow { max-width: 680px; display: flex; flex-direction: column; gap: 16px; }
.narrow.wide { max-width: 760px; }
.lead { color: var(--muted); max-width: 66ch; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 22px; display: flex; flex-direction: column; gap: 10px; }
.panel h2 { font-size: 1.2rem; }
.q-top { display: flex; justify-content: space-between; gap: 12px; font-size: .88rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.q-top a { color: var(--muted); text-decoration: none; } .q-top a:hover { color: var(--fg); }
.q-card { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 22px; display: flex; flex-direction: column; gap: 16px; }
.q-text { font-size: 1.25rem; font-weight: 500; line-height: 1.35; }
.opts { display: flex; flex-direction: column; gap: 8px; }
.opt { display: flex; gap: 12px; align-items: flex-start; text-align: left; font: inherit; line-height: 1.45; padding: 12px 14px; border: 1px solid var(--line-strong); border-radius: 5px; background: var(--surface); color: var(--fg); cursor: pointer; }
.opt kbd { margin-top: 3px; flex: none; }
.opt:hover:not(:disabled) { border-color: var(--fg); background: var(--surface-2); }
.opt:disabled { cursor: default; color: var(--muted); }
.opt.right { border-color: var(--good); background: var(--good-soft); color: var(--fg); font-weight: 500; }
.opt.wrong { border-color: var(--bad); background: var(--bad-soft); color: var(--fg); }
.why { border-top: 1px solid var(--line); padding-top: 14px; display: flex; flex-direction: column; gap: 6px; }
.why-h { font-weight: 700; }
.why-h.ok { color: var(--good); } .why-h.bad { color: var(--bad); }
.result .score { font: 600 3rem/1.1 var(--f-display); font-variant-numeric: tabular-nums; }
.miss { border-left: 3px solid var(--line-strong); padding: 2px 0 2px 14px; display: flex; flex-direction: column; gap: 4px; font-size: .95rem; }
.miss-q { font-weight: 600; } .miss-a { color: var(--good); font-weight: 500; }
.stats3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stats3 div { display: flex; flex-direction: column; } .stats3 b { font: 600 1.9rem/1.1 var(--f-display); font-variant-numeric: tabular-nums; } .stats3 span { font-size: .8rem; color: var(--muted); }
.fc { background: var(--surface); border: 1px solid var(--line-strong); border-radius: 6px; padding: 26px 24px; min-height: 250px; display: flex; flex-direction: column; gap: 16px; cursor: pointer; }
.fc.flipped { cursor: default; }
.fc-front { font: 600 1.35rem/1.35 var(--f-display); text-wrap: balance; }
.fc-back { border-top: 1px dashed var(--line-strong); padding-top: 16px; display: flex; flex-direction: column; gap: 10px; font-size: 1.03rem; }
.fc-back ul { margin: 0; padding-left: 1.2em; }
.grade { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.g { display: flex; flex-direction: column; align-items: center; gap: 2px; font: 600 .93rem var(--f-body); padding: 10px 4px; border-radius: 5px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--fg); cursor: pointer; }
.g small { font-size: .78rem; font-weight: 400; color: var(--muted); } .g kbd { margin-bottom: 2px; }
.g1:hover { border-color: var(--bad); background: var(--bad-soft); } .g2:hover { border-color: var(--warm); background: var(--warm-soft); } .g3:hover { border-color: var(--good); background: var(--good-soft); } .g4:hover { border-color: var(--accent); background: var(--accent-soft); }
.exq { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 20px; display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }
.exq > * { max-width: 100%; }
.exq-h { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.pts { font-size: .82rem; font-weight: 600; background: var(--surface-2); padding: 2px 8px; border-radius: 4px; }
.exq-q { font-size: 1.08rem; font-weight: 500; display: flex; flex-direction: column; gap: 8px; line-height: 1.5; }
.exq-q ul, .exq-q ol { margin: 0; padding-left: 1.3em; }
textarea { width: 100%; font: .95rem/1.5 var(--f-body); padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 5px; background: var(--bg); color: var(--fg); resize: vertical; }
#backup { font: .75rem var(--f-mono); }
.model { width: 100%; border-top: 1px solid var(--line); padding-top: 14px; display: flex; flex-direction: column; gap: 12px; }
.model-h { display: flex; justify-content: space-between; align-items: center; gap: 10px; color: var(--accent); }
.model .prose { font-size: .98rem; }
.selfg { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: .88rem; color: var(--muted); }
.mock-n { font-weight: 600; color: var(--muted); margin-top: 8px; }
.mockbar { position: sticky; top: calc(59px + env(safe-area-inset-top, 0px)); z-index: 10; display: flex; flex-wrap: wrap; gap: 12px; align-items: center; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 6px; padding: 10px 14px; margin-bottom: 16px; max-width: 760px; }
.mockbar span { flex: 1; min-width: 140px; } .mockbar strong { font-size: 1.1rem; font-weight: 700; font-variant-numeric: tabular-nums; } .mockbar .late { color: var(--bad); }
.sheet { display: flex; flex-direction: column; gap: 12px; }
.sheet h3 { font-size: 1rem; margin-top: 10px; } .sheet h3 a { color: var(--fg); text-decoration: none; } .sheet h3 a:hover { text-decoration: underline; }
.sh-sec { display: flex; flex-direction: column; gap: 8px; }
.sh-ch { font-size: 1.4rem; margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--line); } .sh-ch a { color: var(--fg); text-decoration: none; }
.terms { margin: 0; display: grid; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.terms div { display: grid; grid-template-columns: minmax(0, 1fr); gap: 2px 16px; padding: 10px 14px; background: var(--surface); font-size: .93rem; }
@media (min-width: 640px) { .terms div { grid-template-columns: 230px minmax(0, 1fr); } }
.terms dt { font-weight: 600; } .terms dd { margin: 0; color: var(--fg); }
.hit { display: flex; flex-direction: column; gap: 3px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); text-decoration: none; color: var(--fg); }
.hit:hover { border-color: var(--fg); }
.hit-k { font-size: .8rem; color: var(--muted); }
.hit-x { font-size: .88rem; color: var(--muted); line-height: 1.5; }

/* ----- player and toast ----- */
#player { position: fixed; z-index: 60; left: 0; right: 0; bottom: 0; display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; padding: 10px max(16px, env(safe-area-inset-right, 0px)) calc(10px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); background: var(--fg); color: var(--bg); box-shadow: 0 -4px 20px rgba(0, 0, 0, .2); }
@media (min-width: 901px) { #player { left: var(--rail); } }
#player .p-btns { display: flex; gap: 6px; }
#player button { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 5px; border: 1px solid color-mix(in srgb, var(--bg) 35%, transparent); background: transparent; color: inherit; cursor: pointer; font-size: 1.05rem; }
#player button:hover { background: color-mix(in srgb, var(--bg) 16%, transparent); }
#player #p-toggle { background: var(--bg); color: var(--fg); border-color: var(--bg); }
#player :focus-visible { outline-color: var(--bg); }
.p-info { flex: 1; min-width: 120px; display: flex; flex-direction: column; line-height: 1.25; font-size: .88rem; }
#p-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } #p-pos { font-size: .78rem; opacity: .75; font-variant-numeric: tabular-nums; }
#player select { font: inherit; font-size: .82rem; padding: 6px 8px; border-radius: 6px; border: 1px solid color-mix(in srgb, var(--bg) 35%, transparent); background: var(--fg); color: var(--bg); max-width: 170px; }
#toast { position: fixed; z-index: 70; left: 50%; transform: translateX(-50%); bottom: calc(84px + env(safe-area-inset-bottom, 0px)); background: var(--fg); color: var(--bg); padding: 10px 16px; border-radius: 5px; font-size: .9rem; max-width: min(92vw, 520px); }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }
@media print { #side, #top, #player, .btn, .done { display: none !important; } #app { display: block; } }

/* ----- animated explainers ----- */
.ax { border-color: var(--line-strong); }
.ax-h { display: flex; flex-direction: column; gap: 2px; }
.ax-h .call-l { color: var(--accent); }
.ax-h strong { font: 600 1.08rem var(--f-display); }
.ax-stage { overflow-x: auto; }
.ax-stage svg { display: block; width: 100%; height: auto; margin: 0 auto; }
.ax-cap { min-height: 4.6em; font-size: 1rem; line-height: 1.5; }
.ax-pk { fill: var(--fg); } .ax-pk.a { fill: var(--accent); } .ax-pk.w { fill: var(--warm); }
.ax-lost { fill: var(--bad); font-size: 15px; }
.ax-st { fill: var(--fg); }
.ax-quiz { border-top: 1px solid var(--line); padding-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.ax-q { font-weight: 600; }
.ax-why { line-height: 1.5; }
.ax-ctl { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.ax-n { color: var(--muted); font-size: .88rem; font-variant-numeric: tabular-nums; margin-left: 4px; }
.ax-nar { margin-left: auto; display: inline-flex; gap: 6px; align-items: center; font-size: .88rem; }
.ax-nar input { accent-color: var(--accent); }
/* ----- podcast ----- */
.eps { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.ep { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.ep:last-child { border-bottom: 0; }
.ep-t { display: flex; gap: 10px; align-items: center; min-width: 0; }
.ep .num { width: 2.2em; height: 1.9em; display: grid; place-items: center; border: 1px solid var(--line-strong); border-radius: 5px; flex: none; color: var(--muted); }
.ep-b { display: flex; flex-wrap: wrap; gap: 6px; }
.now p { font: 1.1rem/1.5 var(--f-prose); min-height: 3.2em; }
.sleep { display: inline-flex; gap: 8px; align-items: center; font-size: .9rem; }
.sleep select { font: inherit; padding: 6px 8px; border: 1px solid var(--line-strong); border-radius: 5px; background: var(--surface); color: var(--fg); }
p, li, dd, td { overflow-wrap: break-word; }
