/* Verbatim: an answer booklet, marked in red pen. */

@font-face { font-family: 'Atkinson'; src: url('../fonts/atkinson-400.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Atkinson'; src: url('../fonts/atkinson-700.woff2') format('woff2'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'JetBrains'; src: url('../fonts/jetbrains-400.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'JetBrains'; src: url('../fonts/jetbrains-700.woff2') format('woff2'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Caveat'; src: url('../fonts/caveat-700.woff2') format('woff2'); font-weight: 700; font-display: swap; }

:root {
  --desk: #e8eef3;
  --sheet: #f8fafc;
  --rule: #c9d6e1;
  --rule-soft: #dde6ee;
  --ink: #18293a;
  --ink-2: #57687a;
  --ink-3: #8a9aab;
  --pen: #c41f33;
  --pen-soft: #c41f3318;
  --blue: #1f56a8;
  --blue-soft: #1f56a814;
  --s1: #b9cde6; --s2: #7fa3d3; --s3: #4677bb; --s4: #23559a; --s5: var(--pen);

  --sans: 'Atkinson', system-ui, sans-serif;
  --mono: 'JetBrains', ui-monospace, Consolas, monospace;
  --hand: 'Caveat', 'Segoe Print', cursive;

  --type: 1.3rem;
  --lh: 2.15;
  --radius: 6px;
  color-scheme: light;
}

:root[data-size='s'] { --type: 1.1rem; }
:root[data-size='l'] { --type: 1.6rem; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --desk: #132030; --sheet: #1a2a3c; --rule: #2e4258; --rule-soft: #24364a;
    --ink: #e4ebf2; --ink-2: #9fb0c2; --ink-3: #6d8197;
    --pen: #f2646f; --pen-soft: #f2646f22; --blue: #86adeb; --blue-soft: #86adeb1c;
    --s1: #33506f; --s2: #4a72a0; --s3: #6992cc; --s4: #9bbcec;
    color-scheme: dark;
  }
}
:root[data-theme='dark'] {
  --desk: #132030; --sheet: #1a2a3c; --rule: #2e4258; --rule-soft: #24364a;
  --ink: #e4ebf2; --ink-2: #9fb0c2; --ink-3: #6d8197;
  --pen: #f2646f; --pen-soft: #f2646f22; --blue: #86adeb; --blue-soft: #86adeb1c;
  --s1: #33506f; --s2: #4a72a0; --s3: #6992cc; --s4: #9bbcec;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--desk);
  color: var(--ink);
  font: 400 1.0625rem/1.55 var(--sans);
  min-height: 100vh;
}
a { color: var(--blue); text-underline-offset: 0.18em; }
a:hover { text-decoration-thickness: 2px; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 0.5em; font-weight: 700; }
h1 { font-size: clamp(1.75rem, 1.2rem + 2.2vw, 2.6rem); letter-spacing: -0.01em; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 0.8em; }
small { font-size: 0.8em; color: var(--ink-2); font-weight: 400; }
code { font-family: var(--mono); font-size: 0.9em; }
kbd {
  font: 400 0.72em var(--mono);
  border: 1px solid currentColor;
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 0.05em 0.4em;
  margin-left: 0.4em;
  opacity: 0.7;
  white-space: nowrap;
}
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; border-radius: 3px; }
.muted { color: var(--ink-2); }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 1rem; top: 1rem; background: var(--sheet); padding: 0.5rem 1rem; z-index: 10; }

/* ---- header -------------------------------------------------------------- */

.top {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  max-width: 1040px;
  margin: 0 auto;
  padding: 1rem 1.25rem;
}
.brand {
  display: flex; align-items: center; gap: 0.4rem;
  color: var(--ink); text-decoration: none;
  font-weight: 700; font-size: 1.2rem;
}
.brand-mark { width: 1.6rem; height: 1.6rem; color: var(--pen); }
.nav { display: flex; gap: 0.25rem; }
.nav a {
  color: var(--ink-2); text-decoration: none;
  padding: 0.35rem 0.7rem; border-radius: var(--radius);
}
.nav a:hover { color: var(--ink); background: var(--blue-soft); }
.nav a[aria-current] { color: var(--ink); font-weight: 700; box-shadow: inset 0 -2px var(--pen); border-radius: 0; }
.me { margin-left: auto; display: flex; align-items: center; gap: 1rem; }
.me-level { display: grid; grid-template-columns: auto auto; column-gap: 0.5rem; align-items: center; text-decoration: none; color: var(--ink); }
.me-grade { grid-row: span 2; font: 700 1.7rem/1 var(--hand); color: var(--pen); min-width: 1.6rem; text-align: center; }
.me-lv { font-size: 0.8rem; color: var(--ink-2); }
.me-bar { width: 5.5rem; height: 5px; background: var(--rule-soft); border-radius: 3px; overflow: hidden; }
.me-bar i { display: block; height: 100%; background: var(--blue); }
.me-streak { display: flex; align-items: center; gap: 0.2rem; font-weight: 700; color: var(--ink-3); }
.me-streak svg { width: 1.1rem; height: 1.1rem; fill: currentColor; }
.me-streak.lit { color: #d9731a; }

main {
  max-width: 1040px;
  margin: 0 auto;
  padding: 1rem 1.25rem 4rem;
}
main:focus { outline: none; }
.loading, .empty { color: var(--ink-2); padding: 3rem 0; text-align: center; }

/* ---- buttons ------------------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.2rem;
  font: inherit; font-weight: 700; font-size: 0.95rem;
  padding: 0.55rem 1rem;
  border: 1.5px solid var(--rule);
  border-radius: var(--radius);
  background: var(--sheet);
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { border-color: var(--ink-3); }
.btn.primary { background: var(--blue); border-color: var(--blue); color: var(--sheet); }
.btn.primary:hover { filter: brightness(1.1); }
.btn.big { font-size: 1.05rem; padding: 0.8rem 1.3rem; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn.danger { color: var(--pen); }
.btn.small { padding: 0.2rem 0.6rem; font-size: 0.85rem; }

/* ---- home ---------------------------------------------------------------- */

.home-lead {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 2.5rem;
  align-items: end;
  padding: 2.5rem 0 3rem;
}
.lead-copy h1 { max-width: 16ch; }
.lede { font-size: 1.15rem; color: var(--ink-2); max-width: 46ch; }
.lead-card {
  background: var(--sheet);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: 0 1px 0 var(--rule), 0 12px 30px -18px #1a2b3c55;
  border-top: 4px solid var(--pen);
}
.up-kind { color: var(--ink-2); font-size: 0.9rem; margin-bottom: 0.2rem; }
.up-title { font-size: 1.45rem; font-weight: 700; margin-bottom: 0.1rem; line-height: 1.25; }
.up-sub { color: var(--ink-2); }
.lead-card .btn { margin-top: 0.6rem; width: 100%; }
.goal { margin-top: 1.25rem; display: grid; gap: 0.35rem; font-size: 0.85rem; color: var(--ink-2); }
.goal-bar { display: block; height: 6px; background: var(--rule-soft); border-radius: 3px; overflow: hidden; }
.goal-bar i { display: block; height: 100%; background: var(--blue); }

.subject { margin-bottom: 2.5rem; }
.subject h2 { border-bottom: 1px solid var(--rule); padding-bottom: 0.4rem; }
.packs { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 1rem; }
.pack {
  display: grid; gap: 0.3rem;
  height: 100%;
  padding: 1.1rem 1.2rem 1rem;
  background: var(--sheet);
  border-radius: var(--radius);
  border-left: 3px solid var(--rule);
  color: var(--ink); text-decoration: none;
}
.pack:hover { border-left-color: var(--pen); }
.pack-title { font-weight: 700; font-size: 1.15rem; }
.pack-meta { font-size: 0.85rem; color: var(--ink-2); }
.pack-desc { font-size: 0.95rem; margin-bottom: 0.4rem; }
.pack-count { font-size: 0.85rem; color: var(--ink-2); }
.contribute { color: var(--ink-2); font-size: 0.95rem; }

.stagebar { display: flex; height: 8px; background: var(--rule-soft); border-radius: 4px; overflow: hidden; gap: 1px; min-width: 6rem; }
.stagebar .seg.s0 { background: transparent; }
.seg.s1 { background: var(--s1); } .seg.s2 { background: var(--s2); } .seg.s3 { background: var(--s3); }
.seg.s4 { background: var(--s4); } .seg.s5 { background: var(--s5); }

/* ---- pack ---------------------------------------------------------------- */

.crumbs { font-size: 0.9rem; margin: 0.5rem 0 1rem; }
.pack-head { margin-bottom: 1.5rem; }
.pack-head .pack-meta { margin-bottom: 0.5rem; }

.modes { border: 0; padding: 0; margin: 0 0 2rem; display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.6rem; }
.modes legend { font-weight: 700; margin-bottom: 0.5rem; padding: 0; }
.mode {
  display: grid; gap: 0.15rem;
  padding: 0.8rem 0.9rem;
  background: var(--sheet);
  border: 1.5px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  position: relative;
}
.mode input { position: absolute; opacity: 0; }
.mode:has(input:checked) { border-color: var(--blue); box-shadow: inset 0 0 0 1px var(--blue); }
.mode:has(input:focus-visible) { outline: 3px solid var(--blue); outline-offset: 2px; }
.mode-name { font-weight: 700; }
.mode-blurb { font-size: 0.85rem; color: var(--ink-2); line-height: 1.4; }

.units { list-style: none; counter-reset: unit; padding: 0; margin: 0; }
.unit { counter-increment: unit; border-bottom: 1px solid var(--rule); }
.unit summary {
  display: grid;
  grid-template-columns: 2.2rem minmax(0, 1fr) minmax(6rem, 12rem) auto auto;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 0;
  cursor: pointer;
  list-style: none;
}
.unit summary::-webkit-details-marker { display: none; }
.unit summary::before { content: counter(unit); font: 700 1.5rem/1 var(--hand); color: var(--ink-3); }
.unit-title { font-weight: 700; }
.unit-count { font-size: 0.85rem; color: var(--ink-2); text-align: right; }
.unit.locked .unit-title, .unit.locked summary::before { color: var(--ink-3); }
.unit.locked summary { grid-template-columns: 2.2rem minmax(0, 1fr) minmax(6rem, 12rem) minmax(0, 18rem); }
.unit.locked .unit-count { text-align: left; }
.items { list-style: none; margin: 0 0 1rem 3.2rem; padding: 0; columns: 2 18rem; column-gap: 2rem; }
.items li { display: flex; align-items: center; gap: 0.6rem; padding: 0.25rem 0; break-inside: avoid; }
.items .unit.locked span { color: var(--ink-3); }
.pips { display: inline-flex; gap: 2px; }
.pips i { width: 6px; height: 6px; border-radius: 50%; background: var(--rule); }
.pips i.on { background: var(--s3); }
.pips i.on:nth-child(5) { background: var(--pen); }
.item-best { font-size: 0.78rem; color: var(--ink-3); }
.due { font-size: 0.72rem; font-weight: 700; color: var(--pen); border: 1px solid currentColor; border-radius: 3px; padding: 0 0.3rem; }

/* ---- practice: the answer booklet --------------------------------------- */

body[data-view='play'] .top { opacity: 0.55; transition: opacity 0.2s; }
body[data-view='play'] .top:hover, body[data-view='play'] .top:focus-within { opacity: 1; }

.play { max-width: 860px; margin: 0 auto; }
.play-bar { display: flex; align-items: center; gap: 1rem; margin-bottom: 0.8rem; min-height: 2.5rem; }
.play-title { font-weight: 700; }
.play-count { color: var(--ink-2); font-size: 0.9rem; white-space: nowrap; }
.play-live { margin-left: auto; white-space: nowrap; color: var(--ink-2); font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.play-live b { color: var(--ink); margin-left: 0.6rem; }

.paper {
  --margin: 4.5rem;
  --done: 0;
  position: relative;
  background: var(--sheet);
  border-radius: 3px;
  padding: 1.75rem calc(var(--margin) + 1.25rem) 1.25rem 2rem;
  box-shadow: 0 1px 0 var(--rule), 0 20px 40px -28px #1a2b3c66;
}
/* The examiner's margin on the right. */
.paper::after {
  content: '';
  position: absolute; top: 0; bottom: 0; right: var(--margin);
  border-left: 1px solid var(--pen-soft);
  box-shadow: -3px 0 0 var(--pen-soft);
  pointer-events: none;
}
/* Progress through the answer, drawn down the margin. */
.paper::before {
  content: '';
  position: absolute; top: 0; right: calc(var(--margin) - 1px);
  width: 2px; height: calc(var(--done) * 100%);
  background: var(--pen);
  opacity: 0.6;
  transition: height 0.15s;
}

.q { display: grid; grid-template-columns: 2.2rem 1fr auto; gap: 0.4rem 0.6rem; align-items: baseline; margin-bottom: 1.25rem; }
.q-num { font-weight: 700; font-size: 1.15rem; }
.q-text { font-weight: 700; font-size: 1.2rem; margin: 0 0 0.25rem; }
.q-meta { font-size: 0.88rem; color: var(--ink-2); margin: 0; }
.q-marks { position: absolute; right: calc(var(--margin) + 1.25rem); top: 1.75rem; font-weight: 700; color: var(--ink-2); }
.q-body { padding-right: 2.5rem; }

.answer {
  position: relative;
  min-height: calc(var(--type) * var(--lh) * 2);
  cursor: text;
}
.sheet {
  font-size: var(--type);
  line-height: var(--lh);
  background-image: linear-gradient(to bottom, transparent calc(100% - 1px), var(--rule) calc(100% - 1px));
  background-size: 100% calc(var(--type) * var(--lh));
  background-position: 0 -0.3em;
  padding-bottom: 0.2em;
  user-select: none;
  font-variant-ligatures: none;
  font-feature-settings: 'liga' 0, 'calt' 0;
}
.sheet.is-prose { font-family: var(--sans); word-spacing: 0.05em; }
.sheet.is-code { font-family: var(--mono); font-size: calc(var(--type) * 0.86); line-height: calc(var(--lh) * 1.163); background-size: 100% calc(var(--type) * var(--lh)); }
.sheet .w { white-space: nowrap; }
.sheet .line { white-space: pre; min-height: 1lh; }
.sheet .ch { color: var(--ink-3); position: relative; border-radius: 2px; }
.sheet .ch.ok { color: var(--ink); }
.sheet .ch.auto { color: var(--ink-2); }
.sheet .ch.bad { color: var(--pen); background: var(--pen-soft); text-decoration: underline wavy var(--pen) 1px; text-underline-offset: 0.25em; }
.sheet .ch.sp.bad { text-decoration: none; background: var(--pen); opacity: 0.45; }
.sheet .ch.nl { color: var(--rule); font-size: 0.75em; padding-left: 0.15em; }
.sheet .ch.nl.ok { color: var(--rule); }
/* Hidden letters keep their width so the line layout doesn't shift. */
.sheet .ch.m:not(.ok):not(.bad):not(.shown) { color: transparent; background: linear-gradient(to top, var(--ink-3) 2px, transparent 2px) no-repeat; border-radius: 0; }
.sheet .ch.m.shown:not(.ok):not(.bad) { color: var(--blue); opacity: 0.6; }
.sheet .ch.cur::before {
  content: '';
  position: absolute; left: -1px; top: 0.35em; bottom: 0.3em;
  width: 2px; background: var(--blue);
  border-radius: 1px;
  animation: blink 1.1s steps(1) infinite;
}
.answer:not(.focused) .ch.cur::before { opacity: 0.35; animation: none; }
@keyframes blink { 50% { opacity: 0; } }
.type-input {
  position: absolute; left: 0; top: 0;
  width: 1px; height: 1px;
  opacity: 0; border: 0; padding: 0; resize: none;
  font-size: 16px;
  caret-color: transparent;
}
.answer.nudge { animation: nudge 0.18s; }
@keyframes nudge { 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }

/* Stacked layout: each character is a two-row cell, the text above and your typing below. */
.sheet.stacked { line-height: 1.45; background: none; padding-bottom: 0; }
.sheet.stacked .ch { display: inline-block; vertical-align: top; white-space: pre; padding-bottom: 1.45em; margin-bottom: 0.7em; }
.sheet.stacked .ch.ok, .sheet.stacked .ch.bad, .sheet.stacked .ch.auto { color: var(--ink-3); background: none; text-decoration: none; opacity: 1; }
.sheet.stacked .ch::after {
  content: attr(data-t);
  /* Positioned so a wrong key never changes the width of the letter above it. */
  position: absolute;
  left: 0; right: 0; top: 1.45em;
  height: 1.45em;
  border-bottom: 1.5px solid var(--rule);
  color: var(--ink);
}
.sheet.stacked .ch.bad::after { color: var(--pen); background: var(--pen-soft); border-bottom-color: var(--pen); text-decoration: underline wavy var(--pen) 1px; text-underline-offset: 0.25em; }
.sheet.stacked .ch.auto::after { color: var(--ink-2); }
.sheet.stacked .ch.nl, .sheet.stacked .ch.nl.ok { font-size: inherit; padding-left: 0; color: var(--rule); }
.sheet.stacked .ch.cur::before { top: auto; bottom: 0.2em; height: 1.05em; }
.sheet.stacked.is-code .line { white-space: nowrap; }
.sheet.stacked.is-code .ch { margin-bottom: 0.45em; }

.paper-foot { display: flex; align-items: center; flex-wrap: wrap; gap: 0.5rem 1rem; margin-top: 1rem; font-size: 0.82rem; color: var(--ink-3); }
.paper-foot .hint-key { margin-left: auto; }
.paper-foot .btn { font-size: 0.82rem; padding: 0.25rem 0.7rem; }

/* ---- result -------------------------------------------------------------- */

.result {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px dashed var(--rule);
  animation: settle 0.3s ease-out;
}
@keyframes settle { from { opacity: 0; transform: translateY(6px); } }
.mark {
  position: absolute;
  right: 0; width: var(--margin);
  display: grid; justify-items: center; gap: 0.2rem;
  margin-top: -0.4rem;
}
.ticks { display: inline-flex; flex-direction: column; align-items: center; gap: 0; }
.tick { width: 2.3rem; height: 1.8rem; fill: none; stroke: var(--pen); stroke-width: 3.2; stroke-linecap: round; stroke-linejoin: round; }
.tick path { stroke-dasharray: 60; stroke-dashoffset: 60; animation: draw 0.35s ease-out forwards; }
.tick:nth-child(2) path { animation-delay: 0.15s; }
.tick:nth-child(3) path { animation-delay: 0.3s; }
.tick.miss { stroke: var(--ink-3); stroke-width: 2; opacity: 0.4; }
@keyframes draw { to { stroke-dashoffset: 0; } }
.mark-score { font: 700 2rem/1 var(--hand); color: var(--pen); }

.result-stats { display: flex; flex-wrap: wrap; gap: 0.5rem 2.25rem; margin: 0 0 0.75rem; }
.result-stats dt { font-size: 0.82rem; color: var(--ink-2); }
.result-stats dd { margin: 0; font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stage-move { color: var(--ink-2); }
.stage-move.up { color: var(--ink); font-weight: 700; }
.stage-move.up::before { content: '\2191  '; color: var(--pen); }
.stage-move.down::before { content: '\2193  '; }
.xp-parts { font-size: 0.9rem; color: var(--ink-2); margin-bottom: 1rem; }
.xp-parts summary { cursor: pointer; }
.xp-parts ul { margin: 0.4rem 0 0; padding-left: 1.2rem; }
.also h3 { font-size: 0.9rem; color: var(--ink-2); margin-bottom: 0.2rem; }
.also ul { margin: 0 0 0.8rem; padding-left: 1.2rem; }
.note { border-left: 3px solid var(--pen); padding-left: 0.8rem; }
.source { font-size: 0.82rem; color: var(--ink-3); }
.result-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; margin-top: 1rem; }

/* ---- round summary ------------------------------------------------------- */

.sum-head { margin-bottom: 1.5rem; }
.sum-total .mark-score { font-size: 3.2rem; }
.sum-level { display: grid; grid-template-columns: auto 1fr auto; gap: 1rem; align-items: center; font-size: 0.9rem; color: var(--ink-2); margin-bottom: 1.5rem; }
.sum-list { list-style: none; padding: 0; margin: 0; }
.sum-list li { display: grid; grid-template-columns: auto 1fr auto auto; gap: 1rem; align-items: center; padding: 0.35rem 0; border-bottom: 1px solid var(--rule-soft); }
.sum-list .ticks { flex-direction: row; }
.sum-list .tick { width: 1.4rem; height: 1.1rem; }
.sum-num { color: var(--ink-2); font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.sum-xp { font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---- progress ------------------------------------------------------------ */

.prog-head { padding: 1.5rem 0 1rem; }
.ladder { list-style: none; display: flex; padding: 0; margin: 1.5rem 0 0; border-bottom: 2px solid var(--rule); }
.ladder li { flex: 1; display: grid; gap: 0.1rem; padding: 0.4rem 0.2rem 0.6rem; text-align: center; position: relative; }
.rung-grade { font: 700 1.6rem/1 var(--hand); color: var(--ink-3); }
.rung-xp { font-size: 0.72rem; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.ladder li.past .rung-grade { color: var(--ink-2); }
.ladder li.now .rung-grade { color: var(--pen); font-size: 2.2rem; }
.ladder li.now::after { content: ''; position: absolute; left: 15%; right: 15%; bottom: -2px; height: 4px; background: var(--pen); border-radius: 2px; }

.prog-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin: 1.5rem 0 1rem; }
.tallies { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(4, 1fr); gap: 1.25rem 1rem; margin: 0; padding: 1.25rem 1.5rem; background: var(--sheet); border-radius: var(--radius); }
.tallies dt { font-size: 0.82rem; color: var(--ink-2); }
.tallies dd { margin: 0; font-size: 1.7rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.panel { background: var(--sheet); border-radius: var(--radius); padding: 1.25rem 1.5rem; margin-bottom: 1rem; }
.chart { width: 100%; height: auto; }
.chart .grid line { stroke: var(--rule-soft); }
.chart .grid text { fill: var(--ink-3); font-size: 11px; }
.chart circle { fill: var(--s2); }
.chart path { fill: none; stroke: var(--blue); stroke-width: 2.5; stroke-linejoin: round; }
.cal { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 1fr); gap: 3px; justify-content: start; }
.cal i { width: 13px; height: 13px; border-radius: 2px; background: var(--rule-soft); }
.cal .c1 { background: var(--s1); } .cal .c2 { background: var(--s3); } .cal .c3 { background: var(--pen); }
.achs { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0.6rem; }
.achs li { display: grid; gap: 0.1rem; padding: 0.7rem 0.8rem; border: 1px dashed var(--rule); border-radius: var(--radius); color: var(--ink-3); }
.achs li span { font-size: 0.85rem; }
.achs li.got { border: 1px solid var(--pen); color: var(--ink); }
.achs li.got b::before { content: '\2713  '; color: var(--pen); }
.achs time { font-size: 0.75rem; color: var(--ink-2); }
.row { display: flex; gap: 0.6rem; flex-wrap: wrap; }

/* ---- settings ------------------------------------------------------------ */

.settings { display: grid; gap: 1rem; }
.setting { display: flex; gap: 0.75rem; align-items: flex-start; cursor: pointer; }
.setting input[type='checkbox'] { width: 1.15rem; height: 1.15rem; margin-top: 0.2rem; accent-color: var(--blue); }
.setting span { display: grid; }
.setting small { font-size: 0.88rem; }
.choice { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 0.4rem; }
.choice legend { font-weight: 700; margin-bottom: 0.4rem; padding: 0; width: 100%; }
.choice label { cursor: pointer; }
.choice input { position: absolute; opacity: 0; }
.choice label span { display: inline-block; padding: 0.35rem 0.8rem; border: 1.5px solid var(--rule); border-radius: var(--radius); }
.choice input:checked + span { border-color: var(--blue); background: var(--blue-soft); font-weight: 700; }
.choice input:focus-visible + span { outline: 3px solid var(--blue); outline-offset: 2px; }

/* ---- toasts -------------------------------------------------------------- */

.toasts { position: fixed; bottom: 1.25rem; left: 50%; transform: translateX(-50%); display: grid; gap: 0.5rem; z-index: 20; width: min(92vw, 420px); }
.toast {
  background: var(--ink); color: var(--sheet);
  padding: 0.75rem 1rem; border-radius: var(--radius);
  box-shadow: 0 10px 30px -10px #0008;
  animation: settle 0.25s ease-out;
  transition: opacity 0.5s, transform 0.5s;
}
.toast.level, .toast.ach { border-left: 4px solid var(--pen); }
.toast.out { opacity: 0; transform: translateY(8px); }
.toast .btn { margin-left: 0.5rem; }
.noscript { text-align: center; padding: 3rem; }

/* ---- small screens ------------------------------------------------------- */

@media (max-width: 760px) {
  .top { flex-wrap: wrap; gap: 0.5rem 1rem; padding: 0.75rem 1rem; }
  .nav { order: 3; width: 100%; }
  main { padding: 0.5rem 1rem 3rem; }
  .home-lead { grid-template-columns: 1fr; gap: 1.5rem; padding: 1rem 0 2rem; }
  .modes { grid-template-columns: 1fr 1fr; }
  .unit summary { grid-template-columns: 1.6rem 1fr auto; }
  .unit summary .stagebar { grid-column: 2 / -1; grid-row: 2; }
  .unit.locked summary { grid-template-columns: 1.6rem 1fr; }
  .unit.locked .unit-count { grid-column: 2; }
  .items { margin-left: 1.6rem; }
  .paper { --margin: 3rem; padding: 1.25rem calc(var(--margin) + 0.75rem) 1rem 1rem; }
  .play-bar { flex-wrap: wrap; gap: 0.25rem 0.75rem; }
  .play-bar .btn.ghost { padding-left: 0; }
  .q { grid-template-columns: 1.6rem 1fr; }
  .q-marks { right: calc(var(--margin) + 0.75rem); top: 1.25rem; }
  .tick { width: 1.8rem; height: 1.4rem; }
  .mark-score { font-size: 1.5rem; }
  .tallies { grid-template-columns: 1fr 1fr; }
  .prog-grid { grid-template-columns: 1fr; }
  .ladder li:nth-child(n+9) { display: none; }
  .sum-list li { grid-template-columns: auto 1fr auto; }
  .sum-num { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition: none !important; }
  .tick path { stroke-dashoffset: 0; }
}
