/* Chess Coach — design tokens v2 (docs/DESIGN-SYSTEM.md §2). One accent, grade colours for grades only. */
:root {
  /* board, annotation and overlay palette (same in both themes) */
  --edge-inset: inset 0 0 0 1px rgba(0,0,0,0.25);
  --shadow-board: 0 4px 14px rgba(0,0,0,0.4);
  --hl-btn: inset 0 1px 0 rgba(255, 255, 255, 0.06);
  --hl-btn-primary: inset 0 1px 0 rgba(255, 255, 255, 0.18);
  --zebra: rgba(255,255,255,0.03);
  --sq-best: rgba(92, 157, 58, 0.55);
  --sq-good: rgba(150, 188, 75, 0.5);
  --sq-inacc: rgba(242, 195, 48, 0.6);
  --sq-mistake: rgba(232, 137, 46, 0.6);
  --sq-blunder: rgba(202, 52, 49, 0.6);
  --sq-hint: rgba(79, 179, 137, 0.6);
  --sq-selected: rgba(20, 85, 30, 0.45);
  --sq-check: radial-gradient(ellipse at center, rgba(255, 0, 0, 1) 0%, rgba(231, 0, 0, 1) 25%, rgba(169, 0, 0, 0) 89%, rgba(158, 0, 0, 0) 100%);
  --sq-dest: radial-gradient(rgba(20, 85, 30, 0.5) 22%, transparent 24%);
  --sq-dest-capture: radial-gradient(transparent 0%, transparent 79%, rgba(20, 85, 0, 0.4) 80%);
  --sq-dest-hover: rgba(20, 85, 30, 0.3);
  --shadow-badge: 0 1px 3px rgba(0,0,0,0.45);
  --ctl-w1: rgba(120, 190, 255, 0.28);
  --ctl-w2: rgba(120, 190, 255, 0.5);
  --ctl-b1: rgba(255, 140, 60, 0.28);
  --ctl-b2: rgba(255, 140, 60, 0.5);
  --sq-hang: inset 0 0 0 4px rgba(224, 82, 74, 0.95);
  --sq-premove-dest: radial-gradient(rgba(20, 30, 85, 0.45) 22%, transparent 24%);
  --sq-premove: rgba(20, 30, 85, 0.45);
  --shadow-sheet: 0 -8px 30px rgba(0,0,0,0.45);
  --board-busy: rgba(20, 18, 16, 0.42);
  --spinner-track: rgba(255,255,255,0.25);
  --scrim: rgba(0, 0, 0, 0.5);
  --badge-best: #5c9d3a;
  --badge-good: #96bc4b;
  --badge-inacc: #f0c22e;
  --badge-mistake: #e58f2a;
  --badge-blunder: #ca3431;
  --on-amber: #3a2b00;
  --on-color: #ffffff;
  --eval-ink-light: #111111;
  --eval-ink-dark: #eeeeee;
  color-scheme: dark;
  --bg: #1d1c1a;
  --surface-1: #262522;
  --surface-2: #302e2b;
  --surface-3: #3a3835;
  --line: #3a3835;
  --line-strong: #4a4744;
  --ink: #f3f1ec;
  --ink-2: #c4c0b9;
  --ink-3: #a09b94;
  --brand: #81b64c;
  --brand-ink: #10200a;
  --brand-soft: color-mix(in srgb, var(--brand) 16%, transparent);
  --brand-hover: color-mix(in srgb, var(--brand) 88%, #ffffff);
  --brand-deep: color-mix(in srgb, var(--brand) 55%, #000000);
  --good: #81b64c;
  --inacc: #e6b422;
  --mistake: #e58f2a;
  --blunder: #e0524a;
  --info: #6aa8e6;

  --sq-light: #eeeed2;
  --sq-dark: #769656;
  --sq-last: rgba(255, 255, 51, 0.5);
  --arrow-best: #5c9d3a;
  --arrow-green: #15781b; --arrow-red: #b32a2a; --arrow-blue: #2b6cb0; --arrow-yellow: #d19a1c; --arrow-orange: #e58f2a;
  --coord-on-light: #769656;
  --coord-on-dark: #eeeed2;
  --eval-white: #f0f0ec;
  --eval-black: #403e3b;

  --font-display: "Montserrat", "Inter", system-ui, sans-serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  /* type scale (rem): display · page title · section · card title · body · meta · label */
  --fs-nav: 0.75rem; /* phone bottom-bar labels (12px) */
  --fs-display: 2rem; --fs-title: 1.5rem; --fs-section: 1.125rem; --fs-card: 1rem; --fs-body: 0.9375rem; --fs-meta: 0.8125rem; --fs-label: 0.6875rem;
  /* 4-pt spacing scale */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px; --s6: 24px; --s8: 32px; --s12: 48px;

  --radius: 12px;
  --radius-sm: 8px;
  --radius-board: 6px;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  --ease: 150ms ease-out;
  --ease-panel: 220ms ease-out;
  --side-w: 176px;
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f3f0;
  --surface-1: #ffffff;
  --surface-2: #efede9;
  --surface-3: #e4e1dc;
  --line: #e4e1dc;
  --line-strong: #cfcbc5;
  --ink: #1d1c1a;
  --ink-2: #4a4743;
  --ink-3: #66625d;
  --brand: #3f6d1c;
  --brand-ink: #ffffff;
  --brand-hover: color-mix(in srgb, var(--brand) 88%, #000000);
  --good: #3f6d1c;
  --inacc: #9a7400;
  --mistake: #b35f00;
  --blunder: #c0362f;
  --info: #2f6db0;
  --eval-black: #3a3a3a;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.16);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; height: 100%; }
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  font-feature-settings: "tnum" 1, "cv11" 1;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); }
button, input, textarea, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
h1, h2, h3, h4 { font-family: var(--font-body); font-weight: 600; line-height: 1.25; }
/* Montserrat only for the wordmark and page titles */
.brand-name, .page-head h2, .home-hero h2, .lib-title, .onboard-hero h2 { font-family: var(--font-display); font-weight: 700; }

/* ---------- app shell: sidebar + content ---------- */
.app { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 8px;
  background: var(--surface-1); border-right: 1px solid var(--line);
  padding: 16px 12px 12px;
}
.brand { display: flex; align-items: center; gap: 8px; padding: 4px 8px 12px; }
.brand-mark {
  width: 30px; height: 30px; flex: none; border-radius: 6px;
  background:
    linear-gradient(45deg, var(--sq-dark) 25%, transparent 25%, transparent 75%, var(--sq-dark) 75%),
    linear-gradient(45deg, var(--sq-dark) 25%, var(--sq-light) 25%, var(--sq-light) 75%, var(--sq-dark) 75%);
  background-size: 15px 15px; background-position: 0 0, 7.5px 7.5px;
  box-shadow: var(--edge-inset);
}
.brand-name { font-family: var(--font-display); font-weight: 700; font-size: var(--fs-section); letter-spacing: -0.01em; color: var(--ink); white-space: nowrap; }
.brand-name b { color: var(--brand); font-weight: 700; }
.tabs { display: flex; flex-direction: column; gap: 2px; }
.tab {
  display: flex; align-items: center; gap: 12px; width: 100%;
  border: 0; background: transparent; color: var(--ink);
  padding: 8px 12px; border-radius: 8px;
  font-family: var(--font-body); font-weight: 600; font-size: var(--fs-body); text-align: left;
  cursor: pointer; white-space: nowrap;
  transition: background 150ms ease-out;
}
.tab:hover { background: var(--surface-2); }
.tab[aria-selected="true"] { background: var(--surface-2); color: var(--ink); }
.tab .ico { width: 18px; height: 18px; margin: 0; color: var(--ink-3); transition: color var(--ease); }
.tab[aria-selected="true"] .ico { color: var(--brand); }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; padding: 0 4px; }
.settings-pop .version { display: block; font-size: var(--fs-label); color: var(--ink-3); }
.side-foot { position: relative; }
.side-foot > .btn { width: 100%; }
.settings-wrap { position: relative; }
.avatar-btn { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 44px; padding: 8px; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--ink); font: inherit; font-weight: 600; text-align: left; cursor: pointer; transition: background var(--ease); }
.avatar-btn:hover, .avatar-btn[aria-expanded="true"] { background: var(--surface-2); }
.avatar { width: 28px; height: 28px; flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--brand); color: var(--brand-ink); font-size: var(--fs-meta); font-weight: 700; }
.avatar .ico { margin: 0; width: 16px; height: 16px; }
.avatar-btn .who { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--fs-meta); }
.popover { position: absolute; left: 0; bottom: calc(100% + 8px); z-index: 30; width: min(320px, calc(100vw - 32px)); background: var(--surface-2); border: 1px solid var(--line-strong); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.settings-pop label { display: block; font-size: var(--fs-label); text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600; color: var(--ink-3); margin: 12px 0 8px; }
.settings-pop .seg { gap: 4px; }
.settings-pop .seg-btn { background: var(--surface-3); }
.settings-pop .seg-btn[aria-pressed="true"] { background: var(--brand); }
.settings-account { display: flex; flex-direction: column; gap: 4px; padding-bottom: 12px; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; font-size: var(--fs-meta); }
.settings-actions { display: flex; flex-direction: column; gap: 4px; margin: 12px 0 8px; padding-top: 12px; border-top: 1px solid var(--line); }
.settings-actions .btn { justify-content: flex-start; }
.settings-actions .btn[aria-pressed="false"] { color: var(--ink-3); }
.subnav { margin: 0 0 16px; }
body[data-view="games"] .subnav, body[data-view="patterns"] .subnav { max-width: 1100px; margin-inline: auto; }
.about { max-width: 760px; }
.about .card p { margin: 0 0 12px; max-width: 68ch; }
.offline-pill { align-self: flex-start; font-size: var(--fs-label); padding: 2px 8px; border-radius: 999px; background: var(--inacc); color: var(--on-amber); font-weight: 700; }
.signin-pop {
  position: absolute; left: 0; bottom: calc(100% + 8px); z-index: 30; width: min(340px, calc(100vw - 32px));
  background: var(--surface-2); border: 1px solid var(--line-strong); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px;
}
.signin-pop label { display: block; font-weight: 700; font-size: var(--fs-body); margin-bottom: 8px; color: var(--ink); }
.signin-pop input { background: var(--surface-1); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); padding: 8px 12px; min-width: 0; }

.content { min-width: 0; padding: 20px clamp(16px, 2.4vw, 32px) 48px; }

/* ---------- page headers (content pages) ---------- */
.page-head { display: flex; align-items: center; gap: 12px; margin: 2px 0 16px; }
.page-head h2 { margin: 0; font-size: var(--fs-title); font-weight: 700; }

/* ---------- board layouts ---------- */
.layout, .drill-layout, .lesson-layout {
  display: grid;
  grid-template-columns: minmax(0, calc(var(--board-max) + 36px)) 400px;
  justify-content: center; gap: 24px; align-items: start;
}
.lesson-layout { grid-template-columns: minmax(0, calc(var(--board-max) + 36px)) minmax(380px, 460px); }
.layout, .drill-layout, .lesson-layout { --board-max: max(360px, var(--board-max-raw, 0px)); }
.layout { --board-max-raw: calc(100vh - 300px); }
.drill-layout { --board-max-raw: calc(100vh - 150px); }
.lesson-layout { --board-max-raw: calc(100vh - 200px); }
@media (min-width: 901px) { aside { position: sticky; top: 14px; max-height: calc(100vh - 28px); overflow-y: auto; scrollbar-width: thin; } }

/* ---------- board stage ---------- */
.stage { display: grid; grid-template-columns: 24px 1fr; grid-template-rows: auto 1fr auto; column-gap: 12px; row-gap: 8px; width: 100%; }
.player { grid-column: 2; display: flex; align-items: center; gap: 12px; min-height: 34px; font-size: var(--fs-body); }
.player .piece-dot { width: 32px; height: 32px; flex: none; border-radius: 4px; background: var(--surface-2) center / 80% no-repeat; }
.player.w .piece-dot { background-image: url(pieces/wP.svg); }
.player.b .piece-dot { background-image: url(pieces/bP.svg); }
.player .name { font-weight: 700; }
.player .elo { font-family: var(--font-mono); font-size: var(--fs-meta); color: var(--ink-3); }
.player .you { font-size: var(--fs-label); font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; padding: 1px 8px; border-radius: 999px; background: var(--brand); color: var(--brand-ink); }
.player .turn { margin-left: auto; font-size: var(--fs-label); color: var(--ink-3); display: none; align-items: center; gap: 8px; }
.player .turn::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--brand); }
.player.to-move .turn { display: inline-flex; }
.player .swap { font-size: var(--fs-label); }
.evalbar { grid-row: 2; position: relative; border-radius: 3px; overflow: hidden; background: var(--eval-black); }
.evalbar-white { position: absolute; left: 0; right: 0; bottom: 0; height: 50%; background: var(--eval-white); transition: height 220ms ease-out; }
.evalbar.flipped .evalbar-white { bottom: auto; top: 0; }
.evalbar-label { position: absolute; left: 0; right: 0; text-align: center; font: 700 var(--fs-label)/1 var(--font-mono); letter-spacing: -0.04em; padding: 4px 0; pointer-events: none; color: var(--eval-ink-light); }
.evalbar-label.at-bottom { bottom: 0; }
.evalbar-label.at-top { top: 0; color: var(--eval-ink-dark); }
.board-shell { grid-row: 2; position: relative; aspect-ratio: 1; width: 100%; border-radius: var(--radius-board); overflow: hidden; box-shadow: var(--shadow-board); user-select: none; container-type: size; }
.board-controls { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; align-items: center; }

/* ---------- components (docs/DESIGN-SYSTEM.md §3): one implementation each ---------- */
/* Button: .btn [.primary | .ghost | .danger] [.sm | .lg] [.icon] [.is-loading]; secondary is the default */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; background: var(--surface-2); color: var(--ink);
  border-radius: var(--radius-sm); padding: 8px 16px; min-height: 36px;
  font-family: var(--font-body); font-size: var(--fs-meta); font-weight: 600; line-height: 1.25;
  cursor: pointer; box-shadow: var(--hl-btn);
  transition: background var(--ease), color var(--ease);
}
.btn:hover { background: var(--surface-3); }
.btn:active { background: var(--line-strong); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn.primary { background: var(--brand); color: var(--brand-ink); box-shadow: var(--hl-btn-primary); }
.btn.primary:hover { background: var(--brand-hover); }
.btn.primary:active { background: var(--brand-deep); }
.btn.ghost { background: transparent; color: var(--ink-2); box-shadow: none; }
.btn.ghost:hover { color: var(--ink); background: var(--surface-2); }
.btn.danger { background: color-mix(in srgb, var(--blunder) 18%, transparent); color: var(--blunder); box-shadow: none; }
.btn.danger:hover { background: color-mix(in srgb, var(--blunder) 28%, transparent); }
.btn.sm { padding: 4px 12px; min-height: 28px; }
.btn.lg { padding: 12px 24px; min-height: 48px; font-size: var(--fs-body); }
.btn.icon { padding: 8px; min-width: 36px; }
.btn.is-loading { color: transparent !important; position: relative; pointer-events: none; }
.btn.is-loading::after { content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--ink-3); border-top-color: var(--ink); animation: spin 0.8s linear infinite; }
.btn.primary.is-loading::after { border-color: color-mix(in srgb, var(--brand-ink) 35%, transparent); border-top-color: var(--brand-ink); }
.spacer { flex: 1; }
.ply-counter { font-family: var(--font-mono); font-size: var(--fs-meta); color: var(--ink-3); font-variant-numeric: tabular-nums; }
.link { background: none; border: 0; color: var(--brand); cursor: pointer; padding: 0; font: inherit; font-weight: 600; text-decoration: none; }
.link:hover { text-decoration: underline; text-underline-offset: 2px; }

/* Segmented control / tabs: .seg > .seg-btn[aria-pressed|aria-selected]; .seg.under = full-width panel tabs */
.seg { display: flex; flex-wrap: wrap; gap: 8px; }
.seg-btn { display: inline-flex; align-items: center; gap: 4px; border: 0; background: var(--surface-2); color: var(--ink-2); border-radius: 999px; padding: 8px 12px; min-height: 32px; font-size: var(--fs-meta); font-weight: 600; cursor: pointer; transition: background var(--ease), color var(--ease); }
.seg-btn:hover { background: var(--surface-3); color: var(--ink); }
.seg-btn[aria-pressed="true"], .seg-btn[aria-selected="true"] { background: var(--brand); color: var(--brand-ink); }
.seg-btn .n { font-size: var(--fs-label); font-weight: 500; margin-left: 4px; }
.seg.under { flex-wrap: nowrap; gap: 0; background: var(--bg); border-bottom: 1px solid var(--line); }
.seg.under > .seg-btn { flex: 1; justify-content: center; border-radius: 0; background: transparent; color: var(--ink-3); padding: 12px 8px 8px; border-bottom: 3px solid transparent; }
.seg.under > .seg-btn:hover { color: var(--ink); background: transparent; }
.seg.under > .seg-btn[aria-selected="true"] { color: var(--ink); background: transparent; border-bottom-color: var(--brand); }

/* Card: .card [.fill = column, footer pinned] [.card-link = clickable]; .card-head (title + meta + action), .card-foot */
.card { background: var(--surface-1); border-radius: var(--radius); padding: 20px; }
.card + .card { margin-top: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card h2, .card-title { margin: 0; font-size: var(--fs-card); font-weight: 600; }
.card.fill { display: flex; flex-direction: column; gap: 8px; height: 100%; }
.card-foot { display: flex; gap: 8px; flex-wrap: wrap; margin-top: auto; padding-top: 8px; }
.card-link { display: flex; flex-direction: column; gap: 8px; text-align: left; border: 0; cursor: pointer; color: inherit; font: inherit; transition: background var(--ease); }
.card-link:hover { background: var(--surface-2); }
.card + .card.fill, .card + .card-link { margin-top: 0; }

/* Stat: big number + label; .stat.sm for strips; empty values use a word, never a dash */
.stat { background: var(--surface-1); border-radius: var(--radius); padding: 16px; }
.stat-n { display: block; font-size: var(--fs-title); font-weight: 700; line-height: 1.25; font-variant-numeric: tabular-nums; }
.stat-l { display: block; color: var(--ink-3); font-size: var(--fs-label); text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600; }
.stat.sm { padding: 8px 12px; }
.stat.sm .stat-n { font-size: var(--fs-section); }

/* List row: lead (dot/stripe/icon) · body · trailing value; 48px min; .row.sm for dense key/value lines */
.row { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 48px; padding: 8px; border: 0; border-top: 1px solid var(--line); background: none; color: inherit; font: inherit; text-align: left; border-radius: 4px; }
.row:first-child { border-top: 0; }
.row > :where(:not(.stripe):not(:last-child)) { flex: 1 1 auto; min-width: 0; }
.row > :where(:last-child:not(:first-child)) { flex: 0 1 auto; min-width: 0; }
button.row, .row[data-id] { cursor: pointer; transition: background var(--ease); }
button.row:hover { background: var(--surface-2); }
.row.sm { min-height: 36px; padding: 8px 0; justify-content: space-between; font-size: var(--fs-body); }
.row.sm small { color: var(--ink-3); }
.row .link { text-align: left; }

/* Callout: one shape (left bar, surface-2 fill); neutral by default, .success / .warning / .danger; data-class = move grade */
.callout { background: var(--surface-2); border-left: 3px solid var(--line-strong); border-radius: var(--radius); padding: 12px 16px; font-size: var(--fs-body); }
.callout.success { border-left-color: var(--brand); background: color-mix(in srgb, var(--brand) 12%, var(--surface-2)); }
.callout.warning { border-left-color: var(--inacc); background: color-mix(in srgb, var(--inacc) 10%, var(--surface-2)); }
.callout.danger { border-left-color: var(--blunder); background: color-mix(in srgb, var(--blunder) 12%, var(--surface-2)); }
.callout[data-class="best"], .callout[data-class="good"] { border-left-color: var(--good); }
.callout[data-class="inaccuracy"] { border-left-color: var(--inacc); }
.callout[data-class="mistake"] { border-left-color: var(--mistake); }
.callout[data-class="blunder"] { border-left-color: var(--blunder); }
.callout .eyebrow { display: block; margin-bottom: 2px; }
.callout h2 { margin: 0; font-size: var(--fs-card); font-weight: 600; }
.callout .card-head { margin-bottom: 8px; }
.callout.warning .eyebrow { color: var(--inacc); }

/* Empty state: icon, title, one line, one action (ui.js emptyState); plain text form for inline "nothing here" lines */
.empty-state { color: var(--ink-3); font-size: var(--fs-meta); margin: 0; }
div.empty-state { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding: 20px 4px; font-size: var(--fs-body); }
.empty-state .ico { width: 28px; height: 28px; margin: 0 0 4px; opacity: 0.7; }
.empty-state b { color: var(--ink); font-size: var(--fs-card); font-weight: 600; }
.empty-state p { margin: 0; max-width: 46ch; }
.empty-state .btn { margin-top: 8px; }

/* Progress bar: .progress > (div|span) with width % */
.progress { display: block; height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.progress > * { display: block; height: 100%; width: 0%; background: var(--brand); border-radius: inherit; transition: width var(--ease-panel); }
.card-link .foot .progress { flex: 1; }

input[type="text"], input[type="email"] { background: var(--bg); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); padding: 8px 12px; font-size: var(--fs-body); min-width: 0; }
input:focus { border-color: var(--brand); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 22%, transparent); }
input[type="checkbox"] { accent-color: var(--brand); width: 15px; height: 15px; }
select { background: var(--surface-2); border: 0; border-radius: var(--radius-sm); padding: 8px 12px; }

/* ---------- panels ---------- */
.eyebrow { font-size: var(--fs-label); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); font-weight: 700; }
.card.task { border-top: 3px solid var(--brand); }
.card.task .drill-prompt { margin-top: 0; font-size: var(--fs-card); line-height: 1.35; align-items: flex-start; font-family: var(--font-body); }
.card.task .drill-prompt .side { margin-top: -2px; flex: none; }
.card.task .board-controls { margin-top: 12px; }
.card.task .drill-meta { margin-top: 12px; }
.why-block { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.hint { color: var(--ink-3); font-size: var(--fs-meta); margin: 8px 0 0; }
.status { font-size: var(--fs-meta); color: var(--ink-3); }
.mono { font-family: var(--font-mono); font-size: var(--fs-meta); font-variant-numeric: tabular-nums; }
.neg { color: var(--blunder); }
textarea { width: 100%; min-height: 110px; background: var(--bg); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); padding: 12px 12px; font-family: var(--font-mono); font-size: var(--fs-meta); line-height: 1.5; resize: vertical; }
textarea:focus { border-color: var(--brand); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 22%, transparent); }
.input-row, .import-row { display: flex; gap: 12px; align-items: center; margin-top: 12px; flex-wrap: wrap; }
.import-row { margin-top: 0; }
.import-row input { font-family: var(--font-mono); font-size: var(--fs-meta); min-width: 180px; flex: 1 1 180px; }
.save-note { font-size: var(--fs-meta); color: var(--ink-3); margin-top: 8px; }
#gamePanel.collapsed textarea, #gamePanel.collapsed .input-row, #gamePanel.collapsed .progress { display: none; }
#gamePanel.collapsed { padding-block: 12px; }

/* ---------- coach callout ---------- */
aside > .callout { margin-bottom: 12px; }
.coach-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 4px; }
.coach-move { font-family: var(--font-body); font-weight: 700; font-size: var(--fs-section); }
.coach-body { color: var(--ink); font-size: var(--fs-body); }
.coach-body b { font-family: var(--font-mono); font-weight: 600; }
.coach-alt { display: inline-flex; align-items: center; gap: 8px; margin-top: 8px; padding: 4px 12px 4px 8px; border-radius: 999px; background: var(--surface-2); font-size: var(--fs-meta); }
.coach-alt .swatch { width: 10px; height: 10px; border-radius: 2px; background: var(--arrow-best); }
.coach-alt b { font-family: var(--font-mono); }
.coach-why { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.coach-why .eyebrow { display: block; margin-bottom: 4px; }
.why-list { margin: 0 0 8px; padding-left: 20px; font-size: var(--fs-body); }
.why-list li { margin: 4px 0; }
.line-row { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 8px 0; border-top: 1px dashed var(--line); font-size: var(--fs-meta); }
.line-label { color: var(--ink-3); white-space: nowrap; }
.line-moves { overflow-x: auto; white-space: nowrap; scrollbar-width: thin; }
.line-play { padding: 4px 8px; font-size: var(--fs-meta); }
.callout.warning .eyebrow { display: block; margin-bottom: 2px; color: var(--inacc); }

/* ---------- pills / counts ---------- */
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: var(--fs-label); font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--on-color); line-height: 1.5; }
.pill.best { background: var(--good); } .pill.good { background: var(--good); color: var(--brand-ink); }
.pill.inaccuracy { background: var(--inacc); color: var(--on-amber); } .pill.mistake { background: var(--mistake); } .pill.blunder { background: var(--blunder); }
.counts { display: flex; gap: 8px; flex-wrap: wrap; }
.count { display: inline-flex; align-items: center; gap: 8px; padding: 4px 12px; border-radius: 999px; background: var(--surface-2); font-size: var(--fs-meta); font-variant-numeric: tabular-nums; }
.count .dot { width: 8px; height: 8px; border-radius: 50%; }
.count strong { font-weight: 700; }
.dot.best { background: var(--good); } .dot.good { background: var(--good); } .dot.inaccuracy { background: var(--inacc); } .dot.mistake { background: var(--mistake); } .dot.blunder { background: var(--blunder); }
.acc-row { display: flex; gap: 16px; align-items: baseline; margin-bottom: 8px; font-size: var(--fs-meta); }
.acc-row .big { font-family: var(--font-body); font-size: var(--fs-title); font-weight: 700; font-variant-numeric: tabular-nums; }
.acc-row .small { color: var(--ink-3); font-size: var(--fs-meta); }

/* ---------- moments list ---------- */
.moments { display: flex; flex-direction: column; margin-top: 12px; }
.row .stripe { width: 4px; height: 28px; border-radius: 2px; }
.row .stripe.mistake { background: var(--mistake); } .row .stripe.blunder { background: var(--blunder); } .row .stripe.inaccuracy { background: var(--inacc); } .row .stripe.chance { background: var(--brand); }
.row .what { font-size: var(--fs-body); }
.row .what b { font-family: var(--font-mono); }
.row .what small { color: var(--ink-3); }
.row .loss { font-family: var(--font-mono); font-size: var(--fs-meta); color: var(--ink-3); font-variant-numeric: tabular-nums; }
.moments h3 { font-size: var(--fs-label); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); margin: 12px 0 2px; font-weight: 700; }

/* ---------- scoresheet ---------- */
.sheet { position: relative; max-height: 380px; overflow-y: auto; scrollbar-width: thin; font-family: var(--font-mono); font-size: var(--fs-meta); font-variant-numeric: tabular-nums; background: var(--bg); border-radius: var(--radius-sm); }
.sheet-row { display: grid; grid-template-columns: 3.2ch 1fr 1fr; }
.sheet-row:nth-child(even) { background: var(--zebra); }
.sheet .no { padding: 8px 0 8px 12px; color: var(--ink-3); }
.cell { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 12px; border: 0; background: none; text-align: left; font: inherit; color: inherit; cursor: pointer; border-radius: 4px; }
.cell:hover { background: var(--surface-2); }
.cell.active { background: var(--surface-3); font-weight: 700; }
.cell .glyph { font-weight: 700; font-size: var(--fs-meta); }
.glyph.best { color: var(--good); } .glyph.good { color: var(--good); } .glyph.inaccuracy { color: var(--inacc); } .glyph.mistake { color: var(--mistake); } .glyph.blunder { color: var(--blunder); }
.cell.opp { opacity: 0.55; } .cell.opp .glyph { visibility: hidden; }
.sheet.show-opp .cell.opp { opacity: 1; } .sheet.show-opp .cell.opp .glyph { visibility: visible; }

/* ---------- eval graph ---------- */
.graph-wrap { margin-top: 12px; position: relative; }
.eval-graph { display: block; width: 100%; height: 88px; cursor: pointer; touch-action: none; overflow: visible; }
.eval-graph .g-field { fill: var(--eval-black); }
.eval-graph .g-area { fill: var(--eval-white); }
.eval-graph .g-line { fill: none; stroke: var(--ink-3); stroke-width: 1; }
.eval-graph .g-mid { stroke: var(--ink-3); stroke-width: 1; stroke-dasharray: 3 3; }
.eval-graph .g-tick { stroke: var(--line-strong); stroke-width: 1; opacity: 0.6; }
.eval-graph .g-label { fill: var(--ink-3); font-size: var(--fs-label); font-family: var(--font-body); font-variant-numeric: tabular-nums; }
.eval-graph .g-mark { stroke: var(--surface-1); stroke-width: 1.5; }
.eval-graph .g-mark.mistake { fill: var(--mistake); } .eval-graph .g-mark.blunder { fill: var(--blunder); }
.eval-graph .g-cursor { stroke: var(--brand); stroke-width: 2; }
.eval-graph:empty { display: none; }
.graph-hint { font-size: var(--fs-label); font-variant-numeric: tabular-nums; color: var(--ink-3); min-height: 1.2em; margin-top: 4px; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 8px; font-size: var(--fs-meta); color: var(--ink-3); }
.legend span { display: inline-flex; align-items: center; gap: 8px; }
.legend i { display: inline-block; width: 22px; height: 0; border-top: 3px solid var(--arrow-best); border-radius: 2px; }
.legend i.bd { width: 16px; height: 16px; border: 0; border-radius: 50%; background: var(--badge-blunder); color: var(--on-color); font: 700 var(--fs-label)/16px var(--font-mono); text-align: center; font-style: normal; }

/* ---------- games ---------- */
.games { max-width: 1100px; margin-inline: auto; }
.res { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 8px; vertical-align: middle; }
.res.win { background: var(--good); } .res.loss { background: var(--blunder); } .res.draw { background: var(--ink-3); }
/* games list: one row per game — result chip, opponent + meta, accuracy, review state */
.game-list { margin: 0 -8px; }
.game-row { min-height: 64px; padding: 8px; gap: 16px; }
.res-chip { flex: none; display: grid; place-items: center; width: 32px; height: 32px; border-radius: var(--radius-sm); font-weight: 700; font-size: var(--fs-meta); }
.res-chip.win { background: color-mix(in srgb, var(--good) 28%, transparent); color: var(--ink); }
.res-chip.loss { background: color-mix(in srgb, var(--blunder) 28%, transparent); color: var(--ink); }
.res-chip.draw { background: var(--surface-3); color: var(--ink-2); }
.game-row .row-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.game-row .row-body b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.game-row .row-body b small { font-weight: 400; color: var(--ink-3); font-size: var(--fs-meta); font-variant-numeric: tabular-nums; margin-left: 4px; }
.game-row .row-body > small { color: var(--ink-3); font-size: var(--fs-meta); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.game-row .acc { flex: none; display: flex; flex-direction: column; align-items: flex-end; min-width: 64px; }
.game-row .acc b { font-variant-numeric: tabular-nums; font-weight: 600; }
.game-row .acc small { font-size: var(--fs-label); color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600; }
.game-row .state { flex: none; display: inline-flex; align-items: center; gap: 4px; min-width: 104px; justify-content: center; padding: 4px 12px; border-radius: 999px; font-size: var(--fs-meta); font-weight: 600; color: var(--ink-3); background: var(--surface-2); }
.game-row .state.todo { color: var(--brand); background: var(--brand-soft); }
.game-row .state.reviewed { color: var(--good); background: transparent; }
.game-row .state .ico { width: 14px; height: 14px; }
.game-row > .chev { flex: none; width: 16px; height: 16px; color: var(--ink-3); }
@media (max-width: 760px) {
  .game-row { gap: 12px; flex-wrap: wrap; }
  .game-row .row-body { flex: 1 1 calc(100% - 140px); }
  .game-row .state { min-width: 0; padding: 2px 8px; font-size: var(--fs-label); margin-left: 44px; }
  .game-row > .chev { display: none; }
}

/* ---------- insights (patterns) ---------- */
.patterns { max-width: 1100px; margin-inline: auto; }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 16px; margin-bottom: 16px; }
.pattern-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.pattern-grid .card + .card { margin-top: 0; }
.span-2 { grid-column: 1 / -1; }
@media (max-width: 760px) { .pattern-grid { grid-template-columns: 1fr; } }
.bar-row { display: grid; grid-template-columns: minmax(110px, 1fr) 2fr 4ch; gap: 12px; align-items: center; padding: 4px 0; font-size: var(--fs-meta); }
.bar-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { height: 10px; background: var(--surface-2); border-radius: 5px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--brand); border-radius: 5px; }
.bar-fill.mistake { background: var(--mistake); } .bar-fill.blunder { background: var(--blunder); } .bar-fill.inaccuracy { background: var(--inacc); } .bar-fill.best { background: var(--good); }
.bar-value { font-family: var(--font-mono); font-size: var(--fs-meta); text-align: right; color: var(--ink-3); }
@media (max-width: 600px) {
  .bar-row { grid-template-columns: 1fr 4ch; }
  .bar-label { grid-column: 1 / -1; white-space: normal; }
}
.row.sm small { color: var(--ink-3); }
.row .link { text-align: left; }
.spark { width: 100%; height: 90px; display: block; }
.spark-grid { stroke: var(--line-strong); stroke-width: 0.4; stroke-dasharray: 1 1.5; }
.spark-line { fill: none; stroke: var(--brand); stroke-width: 1.2; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.spark-dot { fill: var(--brand); }
.spark-axis { display: flex; justify-content: space-between; font-size: var(--fs-label); color: var(--ink-3); font-family: var(--font-mono); }
aside .stat-row { grid-template-columns: repeat(3, 1fr); gap: 8px; }
aside .stat { padding: 12px 12px; background: var(--surface-2); }
aside .stat-n { font-size: var(--fs-title); }
aside .bar-row { grid-template-columns: minmax(90px, 1fr) 1.4fr 7ch; font-size: var(--fs-meta); padding: 4px 0; }

/* ---------- puzzles / play ---------- */
.drills, .lessons { max-width: none; }
.drill-prompt { display: flex; align-items: center; gap: 12px; margin-top: 12px; font-weight: 700; }
.drill-prompt .side { width: 26px; height: 26px; background: center / contain no-repeat; }
.drill-prompt .side.w { background-image: url(pieces/wP.svg); } .drill-prompt .side.b { background-image: url(pieces/bP.svg); }
.drill-status { margin-top: 8px; min-height: 1.4em; font-size: var(--fs-body); }
.drill-status.ok { color: var(--good); font-weight: 700; }
.drill-status.bad { color: var(--blunder); font-weight: 700; }
.drill-meta { font-size: var(--fs-meta); color: var(--ink-3); overflow-wrap: anywhere; }
.streak { font-family: var(--font-body); font-size: var(--fs-title); font-weight: 700; }
.drill-dots { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 12px; }
.drill-dots i { width: 9px; height: 9px; border-radius: 50%; background: var(--blunder); opacity: 0.85; }
.drill-dots i.ok { background: var(--good); }
.storm-bar { display: flex; align-items: center; gap: 16px; margin-top: 12px; padding: 8px 12px; border-radius: var(--radius-sm); background: var(--surface-2); }
.storm-clock { font-family: var(--font-mono); font-weight: 700; font-size: var(--fs-section); font-variant-numeric: tabular-nums; }
.storm-clock.low { color: var(--blunder); }
.storm-score { font-family: var(--font-body); font-weight: 700; font-size: var(--fs-section); }
.storm-score::after { content: " solved"; font: var(--fs-meta) var(--font-body); color: var(--ink-3); }
#playMoves { margin-top: 12px; }
.row .tags { color: var(--ink-3); font-size: var(--fs-meta); }
.srs-pill { font-size: var(--fs-label); padding: 1px 8px; border-radius: 999px; background: var(--surface-2); color: var(--ink-3); margin-left: 8px; }
.srs-pill.due { background: color-mix(in srgb, var(--brand) 22%, transparent); color: var(--brand); }
.row.row-stats { display: grid; grid-template-columns: 6ch 1fr 9ch; }
.row-stats .san { font-family: var(--font-mono); font-weight: 700; }
.row-stats .wdl { display: flex; height: 8px; border-radius: 4px; overflow: hidden; background: var(--surface-2); }
.row-stats .wdl i { display: block; height: 100%; }
.row-stats .wdl .w { background: var(--good); } .row-stats .wdl .d { background: var(--ink-3); } .row-stats .wdl .l { background: var(--blunder); }
.row-stats .n { font-family: var(--font-mono); font-size: var(--fs-meta); color: var(--ink-3); text-align: right; }

/* ---------- explore ---------- */
.explore-line { font-size: var(--fs-meta); color: var(--ink-3); overflow-wrap: anywhere; }
.explore-lines { display: flex; flex-direction: column; gap: 8px; }
.eline { display: grid; grid-template-columns: 5.5ch 1fr; gap: 12px; align-items: baseline; text-align: left; padding: 8px 12px; border: 0; border-radius: var(--radius-sm); background: var(--surface-2); cursor: pointer; font: inherit; color: inherit; }
.eline:hover { background: var(--surface-3); }
.eline .ev { font-family: var(--font-mono); font-weight: 700; font-variant-numeric: tabular-nums; }
.eline .ev.w { color: var(--ink); } .eline .ev.b { color: var(--ink-3); }
.eline .mv { font-family: var(--font-mono); font-size: var(--fs-meta); overflow-wrap: anywhere; }
.eline .mv b { color: var(--brand); }
.eline.thinking { opacity: 0.6; }
#exploreBtn[aria-pressed="true"] { background: var(--brand); color: var(--brand-ink); }

/* ---------- learn: library ---------- */
.lib-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.lib-title { font-size: var(--fs-title); font-weight: 700; margin: 0; }
.lib-filter { display: flex; gap: 8px; flex-wrap: wrap; }
.lib-track { margin-top: 24px; }
.lib-track > h3 { font-size: var(--fs-section); font-weight: 700; margin: 0; }
.lib-track > p { color: var(--ink-3); font-size: var(--fs-meta); margin: 2px 0 12px; max-width: 70ch; }
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; max-width: 1400px; }
.card-link h4 { margin: 0; font-size: var(--fs-card); font-weight: 700; line-height: 1.3; }
.card-link .by { font-size: var(--fs-meta); color: var(--ink-3); }
.card-link .blurb { font-size: var(--fs-meta); color: var(--ink-3); margin: 0; flex: 1; }
.card-link .foot { display: flex; align-items: center; gap: 8px; font-size: var(--fs-meta); color: var(--ink-3); }
.lvl { font-size: var(--fs-label); font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line-strong); }
.card-link.done { opacity: 0.65; }
.lesson-list .row .what small { color: var(--ink-3); }

/* ---------- learn: reader ---------- */
.reader { background: var(--surface-1); border-radius: var(--radius); padding: 20px 20px; display: flex; flex-direction: column; gap: 12px; }
@media (min-width: 901px) { .reader { position: sticky; top: 14px; max-height: calc(100vh - 28px); } }
.reader-top { display: flex; gap: 16px; align-items: center; font-size: var(--fs-meta); }
.reader-study { margin: 0; font-size: var(--fs-meta); color: var(--ink-3); }
.reader-study #lessonTitle { font-weight: 700; color: var(--ink); }
.reader-study a { display: inline-block; padding: 4px 0; }
.reader-top .link { padding: 4px 0; }
.chapter-toggle { display: flex; justify-content: space-between; align-items: center; gap: 8px; width: 100%; background: var(--surface-2); border: 0; border-radius: var(--radius-sm); padding: 8px 12px; font-size: var(--fs-meta); color: var(--ink-3); cursor: pointer; }
.chapter-toggle:hover { color: var(--ink); background: var(--surface-3); }
.chapter-toggle[aria-expanded="true"] .caret { transform: rotate(180deg); }
.chapters { max-height: 300px; overflow-y: auto; scrollbar-width: thin; background: var(--bg); border-radius: var(--radius-sm); }
.reader .chapters { max-height: 38vh; flex: none; }
.chapter { display: flex; justify-content: space-between; gap: 12px; width: 100%; text-align: left; padding: 8px 12px; border: 0; border-top: 1px solid var(--line); background: none; cursor: pointer; font-size: var(--fs-body); color: inherit; }
.chapter:first-child { border-top: 0; }
.chapter:hover { background: var(--surface-2); }
.chapter.active { background: color-mix(in srgb, var(--brand) 22%, transparent); font-weight: 700; }
.chapter .done { color: var(--good); }
.reader-title { font-size: var(--fs-title); font-weight: 700; line-height: 1.2; margin: 8px 0 0; text-wrap: balance; }
.reading { flex: 1 1 auto; min-height: 140px; overflow-y: auto; scrollbar-width: thin; font-size: var(--fs-card); line-height: 1.7; color: var(--ink); padding-right: 8px; overflow-wrap: anywhere; }
.reading p { margin: 0 0 0.85em; max-width: 60ch; }
.reading p:last-child { margin-bottom: 0; }
.reading .hint { font-size: var(--fs-body); }
.reading .note-move { display: inline-block; font-family: var(--font-mono); font-weight: 600; font-size: var(--fs-body); background: var(--surface-2); border-radius: 6px; padding: 1px 8px; margin: 0 0 8px; }
.reading.fade-in { animation: noteIn 220ms ease-out; }
@keyframes noteIn { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }
.note { font-size: var(--fs-body); line-height: 1.55; min-height: 60px; }
.note-move { font-family: var(--font-mono); font-weight: 600; margin-right: 8px; }
.rich-link { color: var(--brand); text-underline-offset: 3px; }
.rich-link.study, .rich-link.game { display: inline-block; text-decoration: none; font-size: var(--fs-body); font-weight: 700; background: color-mix(in srgb, var(--brand) 18%, transparent); border-radius: 999px; padding: 2px 12px; margin: 2px 0; }
.rich-link.study::before { content: "📖 "; } .rich-link.game::before { content: "♟ "; }
.rich-link.study:hover, .rich-link.game:hover { background: color-mix(in srgb, var(--brand) 30%, transparent); }
.reader-nav { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.reader-nav .btn.primary { padding-inline: 20px; }
.move-strip { display: flex; align-items: center; gap: 2px; margin-top: 12px; padding: 8px 8px; overflow-x: auto; white-space: nowrap; scrollbar-width: thin; background: var(--surface-1); border-radius: var(--radius-sm); font-family: var(--font-mono); font-size: var(--fs-meta); }
.move-strip:empty { display: none; }
.ms-no { color: var(--ink-3); margin-left: 8px; }
.ms-move { border: 0; background: none; font: inherit; color: inherit; padding: 4px 8px; border-radius: 4px; cursor: pointer; position: relative; }
.ms-move:hover { background: var(--surface-2); }
.ms-move.has-note::after { content: ""; position: absolute; left: 50%; bottom: -1px; width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: var(--brand); }
.ms-move.active { background: var(--brand); color: var(--brand-ink); }
.ms-move.active.has-note::after { background: var(--brand-ink); }
.ms-move.has-alt { text-decoration: underline dotted; text-decoration-color: color-mix(in srgb, var(--brand) 70%, transparent); text-underline-offset: 3px; }
.ms-move.branching { outline: 1px dashed var(--brand); outline-offset: -1px; }

/* ---------- Gotham's rules ---------- */
.gotham .rule { display: grid; grid-template-columns: minmax(150px, 220px) 1fr auto; gap: 8px 16px; padding: 12px 0; border-top: 1px solid var(--line); align-items: start; }
.gotham .rule:first-child { border-top: 0; }
.gotham .rule b { font-size: var(--fs-body); line-height: 1.35; }
.gotham .rule p { margin: 0; font-size: var(--fs-meta); color: var(--ink-3); line-height: 1.45; max-width: 70ch; }
.gotham .eps { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; max-width: 150px; }
.gotham .eps a { font-family: var(--font-mono); font-size: var(--fs-label); padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--ink-3); text-decoration: none; }
.gotham .eps a:hover { background: var(--brand); color: var(--brand-ink); }
.gotham .broke { font-size: var(--fs-label); padding: 1px 8px; border-radius: 999px; background: color-mix(in srgb, var(--blunder) 22%, transparent); color: var(--blunder); margin-left: 8px; white-space: nowrap; }
.gotham .auto { font-size: var(--fs-label); padding: 1px 8px; border-radius: 999px; background: var(--surface-2); color: var(--ink-3); margin-left: 8px; white-space: nowrap; }
.gotham details summary { cursor: pointer; font-weight: 700; font-size: var(--fs-body); }
.ep-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 8px 16px; margin-top: 12px; }
.ep-list a { display: grid; grid-template-columns: 34px 1fr; gap: 8px; align-items: baseline; text-decoration: none; color: inherit; padding: 8px 8px; border-radius: 6px; }
.ep-list a:hover { background: var(--surface-2); }
.ep-list .n { font-family: var(--font-mono); font-size: var(--fs-label); color: var(--ink-3); }
.ep-list .t { font-size: var(--fs-meta); font-weight: 700; }
.ep-list .band { font-family: var(--font-mono); font-size: var(--fs-label); color: var(--ink-3); margin-left: 8px; font-weight: 400; }
.ep-list .note { display: block; font-size: var(--fs-meta); color: var(--ink-3); line-height: 1.35; }
@media (max-width: 640px) { .gotham .rule { grid-template-columns: 1fr; } .gotham .eps { justify-content: flex-start; max-width: none; } }

/* ---------- chessground theme ---------- */
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
.board-shell.shake { animation: shake 220ms ease-out; }
.board-shell .cg-wrap, .board-shell .board { width: 100%; height: 100%; display: block; }
.board-shell cg-board { background-image: conic-gradient(var(--sq-dark) 25%, var(--sq-light) 0 50%, var(--sq-dark) 0 75%, var(--sq-light) 0); background-size: 25% 25%; }
.board-shell cg-board square.last-move { background: var(--sq-last); }
.board-shell cg-board square.best { background: var(--sq-best); }
.board-shell cg-board square.good { background: var(--sq-good); }
.board-shell cg-board square.inaccuracy { background: var(--sq-inacc); }
.board-shell cg-board square.mistake { background: var(--sq-mistake); }
.board-shell cg-board square.blunder { background: var(--sq-blunder); }
.board-shell cg-board square.hint { background: var(--sq-hint); }
.board-shell cg-board square.wrong { background: var(--sq-blunder); }
.board-shell cg-board square.selected { background: var(--sq-selected); }
.board-shell cg-board square.check { background: var(--sq-check); }
.board-shell cg-board square.move-dest { background: var(--sq-dest); }
.board-shell cg-board square.premove-dest { background: none; }
.board-shell cg-board square.oc.move-dest { background: var(--sq-dest-capture); }
.board-shell cg-board square.move-dest:hover { background: var(--sq-dest-hover); }
.board-shell .cg-wrap coords { font: 700 var(--fs-label)/1 var(--font-body); opacity: 1; z-index: 3; }
.board-shell .cg-wrap coords.ranks { top: 0; left: 3px; width: 12px; height: 100%; }
.board-shell .cg-wrap coords.ranks coord { transform: none; padding-top: 2px; }
.board-shell .cg-wrap coords.files { bottom: 0; left: 0; width: 100%; height: 12px; text-transform: none; }
.board-shell .cg-wrap coords.files coord { text-align: right; padding-right: 2px; }
.board-shell .cg-wrap coords coord { color: var(--coord-on-dark); }
.board-shell .cg-wrap coords.ranks coord:nth-child(2n), .board-shell .cg-wrap coords.files coord:nth-child(2n) { color: var(--coord-on-light); }
.board-shell .cg-wrap coords.ranks.black coord:nth-child(2n), .board-shell .cg-wrap coords.files.black coord:nth-child(2n) { color: var(--coord-on-dark); }
.board-shell .cg-wrap coords.ranks.black coord:nth-child(2n+1), .board-shell .cg-wrap coords.files.black coord:nth-child(2n+1) { color: var(--coord-on-light); }
.board-shell .cg-wrap piece { cursor: grab; }
.board-shell .cg-wrap piece.dragging { cursor: grabbing; }
.board-overlay { position: absolute; inset: 0; pointer-events: none; z-index: 5; }
.board-overlay .badge { position: absolute; width: 12.5%; height: 12.5%; transform: translate(var(--dx, 46%), var(--dy, -46%)) scale(0.37); transform-origin: center; }
.badge { border-radius: 50%; display: flex; align-items: center; justify-content: center; font: 700 6.4cqw/1 var(--font-mono); /* token-ok: badge scales with the board */ color: var(--on-color); box-shadow: var(--shadow-badge); }
.badge svg { width: 62%; height: 62%; display: block; fill: currentColor; }
.badge.best { background: var(--badge-best); } .badge.good { background: var(--badge-good); } .badge.inaccuracy { background: var(--badge-inacc); color: var(--on-amber); } .badge.mistake { background: var(--badge-mistake); } .badge.blunder { background: var(--badge-blunder); }

/* ---------- narrow screens: rail sidebar, then bottom bar ---------- */
@media (max-width: 1180px) and (min-width: 761px) {
  :root { --side-w: 68px; }
  .brand-name, .tab span, .avatar-btn .who { display: none; }
  .avatar-btn { justify-content: center; padding: 8px 0; }
  .brand { justify-content: center; padding-inline: 0; }
  .tab { justify-content: center; padding: 12px 0; }
  .tab[aria-selected="true"] { box-shadow: none; }
  .side-foot > .btn { padding: 8px 4px; font-size: var(--fs-label); }
}
@media (max-width: 900px) {
  .layout, .drill-layout, .lesson-layout { grid-template-columns: 1fr; --board-max-raw: calc(100vw - 60px); }
  aside { position: static; max-height: none; overflow: visible; }
  .reader { position: static; max-height: none; }
}
@media (max-width: 760px) {
  :root { --side-w: 0px; }
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto; height: auto; z-index: 40;
    flex-direction: row; align-items: center; gap: 0;
    padding: 4px 4px calc(4px + env(safe-area-inset-bottom, 0px));
    border-right: 0; border-top: 1px solid var(--line);
  }
  .brand { display: none; }
  .tabs { flex-direction: row; flex: 1; gap: 0; }
  .tab { flex-direction: column; justify-content: center; gap: 2px; padding: 4px 0; border-radius: 6px; font-size: var(--fs-label); font-weight: 700; }
  .tab[aria-selected="true"] { box-shadow: none; background: transparent; color: var(--brand); }
  .tab .ico { width: 22px; height: 22px; }
  .tab[aria-selected="true"] .ico { color: var(--brand); }
  .side-foot { margin: 0; padding: 0 2px; flex-direction: row; align-items: center; gap: 4px; }
  .side-foot > .btn { width: auto; padding: 8px; font-size: var(--fs-label); }
  .avatar-btn { width: auto; padding: 8px; }
  .avatar-btn .who { display: none; }
  .popover { position: fixed; left: 12px; right: 12px; bottom: calc(var(--nav-h, 72px) + 8px); width: auto; max-height: calc(100dvh - var(--nav-h, 72px) - 24px); overflow-y: auto; }
  .signin-pop { position: fixed; left: 12px; right: 12px; bottom: calc(var(--nav-h, 72px) + 8px); width: auto; }
  .content { padding: 12px 16px calc(var(--nav-h, 72px) + 16px); }
  .stage { grid-template-columns: 18px 1fr; column-gap: 8px; }
  .layout, .drill-layout, .lesson-layout { --board-max-raw: calc(100vw - 52px); gap: 16px; }
  .card { padding: 16px; }
  .lib-grid { grid-template-columns: 1fr; }
  .stat-row { grid-template-columns: 1fr 1fr; }
}

/* panel heads wrap cleanly when the title is long (game panel on phones) */
.card-head { flex-wrap: wrap; row-gap: 8px; }
.card-head h2 { flex: 1 1 auto; min-width: 0; }
.player .swap { padding: 4px 8px; margin: -4px 0; }
#gamePanel .card-head > span { flex-wrap: wrap; }

/* ---------- side panel: one card, tabbed (Review / Moves / Load …) ---------- */
.side-panel { background: var(--surface-1); border-radius: var(--radius); overflow: hidden; }
.side-panel .pane { display: flex; flex-direction: column; }
.side-panel .card, .side-panel .pane > .callout { background: transparent; border-radius: 0; margin: 0; padding: 16px 16px; border-top: 1px solid var(--line); box-shadow: none; }
.side-panel .pane > :first-child { border-top: 0; }
.side-panel .pane > .callout { border-top: 0; border-left-width: 4px; }
.side-panel .card.task { border-top: 0; }
.side-panel .card.callout.success { border-left: 4px solid var(--brand); }
.side-panel .card-head { margin-bottom: 8px; }
.side-panel .card h2 { font-size: var(--fs-body); }
.side-panel .sheet { max-height: none; background: transparent; }
.side-panel .pane[data-pane="moves"] .card { padding-inline: 8px; }
.pane-foot { padding: 12px 16px 16px; border-top: 1px solid var(--line); }
.pane-foot:has(> [hidden]:only-child) { display: none; }
.pane-foot .btn { width: 100%; }
.opening-line { margin: 0; padding: 8px 16px; font-size: var(--fs-meta); color: var(--ink-3); background: var(--bg); border-bottom: 1px solid var(--line); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .opening-line { padding: 0 0 4px; background: transparent; border: 0; white-space: normal; font-family: var(--font-body); }

/* control map + premove squares */
.board-shell cg-board square.ctl-w1 { background: var(--ctl-w1); }
.board-shell cg-board square.ctl-w2 { background: var(--ctl-w2); }
.board-shell cg-board square.ctl-b1 { background: var(--ctl-b1); }
.board-shell cg-board square.ctl-b2 { background: var(--ctl-b2); }
.board-shell cg-board square.hang { box-shadow: var(--sq-hang); }
.board-shell cg-board square.premove-dest { background: var(--sq-premove-dest); }
.board-shell cg-board square.current-premove { background: var(--sq-premove); }
#heatBtn[aria-pressed="true"] { background: var(--surface-2); color: var(--ink); }

/* puzzles: rating line */
.drill-rating { margin-top: 8px; font-size: var(--fs-meta); color: var(--ink-3); }
.drill-rating b { color: var(--ink); font-variant-numeric: tabular-nums; }
.drill-rating .up { color: var(--good); } .drill-rating .down { color: var(--blunder); }

/* lessons: play-it-yourself prompt */
.callout .link { margin-left: 8px; }
.callout .alts { display: inline-block; margin-left: 4px; color: var(--ink-3); }
.callout .alts a { color: var(--brand); font-family: var(--font-mono); text-decoration: none; }
.callout .alts a:hover { text-decoration: underline; }
.note-move.side { opacity: 0.85; }

/* ---------- home ---------- */
.home { max-width: 1100px; margin-inline: auto; }
.onboard { max-width: 720px; }
.onboard-hero h2 { font-size: var(--fs-title); font-weight: 700; line-height: 1.2; margin: 8px 0 8px; text-wrap: balance; }
.onboard-hero p { color: var(--ink-3); margin: 0 0 20px; max-width: 60ch; }
.onboard-steps { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 12px; }
.onboard-steps li { display: grid; grid-template-columns: 34px 1fr; gap: 12px; background: var(--surface-1); border-radius: var(--radius); padding: 16px 16px; }
.onboard-steps b { display: block; font-family: var(--font-body); font-size: var(--fs-card); }
.onboard-steps p { margin: 2px 0 0; color: var(--ink-3); font-size: var(--fs-body); }
.onboard-steps form { margin-top: 12px; }
.onboard-steps input { flex: 1 1 220px; }
.step-n { width: 34px; height: 34px; border-radius: 50%; background: var(--brand); color: var(--brand-ink); font-family: var(--font-body); font-weight: 700; display: flex; align-items: center; justify-content: center; }
.home-hero { margin-bottom: 16px; }
.home-hero h2 { margin: 0; font-size: var(--fs-title); font-weight: 700; }
.home-hero .hint { margin: 4px 0 0; }
.continue { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 24px; margin-bottom: 16px; background: color-mix(in srgb, var(--brand) 8%, var(--surface-1)); }
.continue-body { min-width: 0; }
.continue-title { margin: 4px 0; font-size: var(--fs-title); font-weight: 700; line-height: 1.25; }
.continue .hint { margin: 0; }
.continue .home-line { margin-top: 8px; }
.continue .btn.lg { flex: none; }
.home-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-top: 16px; }
.home-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.card.fill h3 { margin: 0; font-size: var(--fs-meta); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); font-weight: 700; }
.card.fill .big { margin: 0; font-family: var(--font-body); font-size: var(--fs-title); font-weight: 700; }
.card.fill .hint { margin: 0; }
.home-line { margin: 0; font-size: var(--fs-body); }
.page-head.compact { margin-bottom: 8px; }
.page-title-sm { font-size: var(--fs-section) !important; font-weight: 700 !important; }
@media (max-width: 960px) { .home-grid { grid-template-columns: 1fr; } }
@media (max-width: 760px) { .home-hero h2 { font-size: var(--fs-section); } .home-stats { grid-template-columns: 1fr 1fr; gap: 8px; } .continue { flex-direction: column; align-items: stretch; padding: 20px; } }

/* puzzle strip */
.home-stats .stat { background: var(--surface-2); }
.home-stats .stat { background: var(--surface-1); }
@keyframes pop { 0% { transform: scale(0.8); opacity: 0.4; } 60% { transform: scale(1.12); opacity: 1; } 100% { transform: scale(1); } }
.pop { animation: pop 380ms cubic-bezier(.2,.9,.3,1.3); display: inline-block; }

@media (prefers-reduced-motion: reduce) { .pop { animation: none; } }

/* toast + sound */
.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(12px); z-index: 60; display: inline-flex; align-items: center; gap: 8px; max-width: calc(100vw - 32px); background: var(--surface-3); color: var(--ink); padding: 12px 20px; border-radius: 999px; font-weight: 600; font-size: var(--fs-body); box-shadow: var(--shadow); opacity: 0; transition: opacity var(--ease), transform var(--ease); pointer-events: none; }
.toast .ico { width: 18px; height: 18px; flex: none; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.ok { background: var(--brand); color: var(--brand-ink); }
.toast.warn { background: var(--inacc); color: var(--brand-ink); }
@media (max-width: 760px) { .toast { bottom: calc(var(--nav-h, 72px) + 12px); } }

/* icons */
.ico { width: 1.05em; height: 1.05em; vertical-align: -0.2em; margin-right: 8px; flex: none; }
.btn.icon .ico { margin: 0; width: 1.15em; height: 1.15em; vertical-align: -0.25em; }
.btn.icon { padding: 8px 12px; }

/* empty states */

/* ---------- type roles ---------- */
.onboard-hero h2 { font-size: var(--fs-display); }
.home-hero h2, .page-head h2, .lib-title { font-size: var(--fs-title); letter-spacing: -0.01em; }
.lib-track > h3, .reader-title { font-size: var(--fs-section); }
.reader-title { font-size: var(--fs-title); }
.side-panel .card h2 { font-size: var(--fs-body); }
.coach-body, .drill-status, .reading .hint, .home-line, .row .what { font-size: var(--fs-body); }
.hint, .status, .empty-state, .save-note, .drill-meta, .graph-hint, .player .elo, .card-link .by { font-size: var(--fs-meta); }
.eyebrow, .stat-l, .card.fill h3, .moments h3 { font-size: var(--fs-label); letter-spacing: 0.08em; }
.page-head { margin-bottom: 20px; }
.side-panel .card { padding: 16px 16px; }
@media (max-width: 760px) { :root { --fs-display: 1.5rem; --fs-title: 1.125rem; } .card { padding: 16px; } }

/* board colours + pieces settings */
html[data-board="brown"] { --sq-light: #f0d9b5; --sq-dark: #b58863; --coord-on-light: #b58863; --coord-on-dark: #f0d9b5; --sq-last: rgba(205, 210, 106, 0.6); }
html[data-board="blue"] { --sq-light: #dee3e6; --sq-dark: #8ca2ad; --coord-on-light: #8ca2ad; --coord-on-dark: #dee3e6; --sq-last: rgba(140, 180, 220, 0.6); }
html[data-board="grey"] { --sq-light: #e2e2e2; --sq-dark: #8d8d8d; --coord-on-light: #8d8d8d; --coord-on-dark: #e2e2e2; --sq-last: rgba(200, 200, 80, 0.55); }
.board-preview { margin-top: 12px; height: 64px; border-radius: 6px; overflow: hidden; position: relative; }
.board-preview .cg-wrap { position: absolute; inset: 0; width: 100%; height: 100%; }
.board-preview cg-board { position: absolute; inset: 0; background-image: conic-gradient(var(--sq-dark) 25%, var(--sq-light) 0 50%, var(--sq-dark) 0 75%, var(--sq-light) 0); background-size: 25% 100%; }
.board-preview piece { position: absolute; top: 4px; width: 56px; height: 56px; background-size: contain; background-repeat: no-repeat; background-position: center; }
.board-preview piece.knight { left: 20px; } .board-preview piece.queen { left: 150px; }

/* ---------- phones: full-bleed board, right panel becomes a bottom sheet ---------- */
.sheet-handle { display: none; }
@media (max-width: 760px) {
  .layout, .drill-layout, .lesson-layout { margin-inline: -16px; --board-max-raw: calc(100vw - 14px); gap: 12px; }
  .layout > div:first-child, .drill-layout > div:first-child, .lesson-layout > div:first-child { min-width: 0; }
  .stage { grid-template-columns: 14px 1fr; column-gap: 0; row-gap: 4px; }
  .drill-layout .stage, .lesson-layout .stage, #playView .stage { grid-template-columns: 0 1fr; }
  .drill-layout .evalbar, .lesson-layout .evalbar, #playView .evalbar { display: none; }
  .player { padding-inline: 12px; }
  .board-shell { border-radius: 0; box-shadow: none; }
  .board-controls, .graph-wrap, .move-strip, #playMoves { margin-inline: 12px; }
  .page-head.compact { margin-inline: 16px; }
  body.has-sheet .content { padding-bottom: calc(34vh + var(--nav-h, 60px) + 32px); }
  .side-panel, .reader {
    position: fixed; left: 0; right: 0; z-index: 35; margin: 0;
    bottom: var(--nav-h, calc(60px + env(safe-area-inset-bottom, 0px)));
    height: 34vh; max-height: none; overflow-y: auto; overscroll-behavior: contain;
    border-radius: 14px 14px 0 0; box-shadow: var(--shadow-sheet);
    transition: height 220ms ease-out;
  }
  .side-panel.sheet-collapsed, .reader.sheet-collapsed { height: 64px; overflow: hidden; }
  .side-panel.sheet-expanded, .reader.sheet-expanded { height: calc(100dvh - var(--nav-h, 60px) - 12px); }
  .sheet-handle { display: flex; justify-content: center; align-items: center; width: 100%; height: 22px; border: 0; background: var(--bg); cursor: grab; touch-action: none; position: sticky; top: 0; z-index: 2; }
  .side-panel .sheet-handle { background: var(--bg); }
  .reader .sheet-handle { background: var(--surface-1); }
  .sheet-handle i { width: 42px; height: 5px; border-radius: 3px; background: var(--line-strong); display: block; }
  .seg.under { position: sticky; top: 22px; z-index: 2; }
  .reader { padding-top: 0; }
  .reader > :not(.sheet-handle):first-of-type { margin-top: 12px; }
}
.board-shell { grid-column: 2; }
.evalbar { grid-column: 1; }
@media (max-width: 760px) { .evalbar-label { display: none; } }

/* loading feel: ring over a busy board, pulse on a thinking opponent */
.board-shell.busy::after { content: attr(data-busy-label); position: absolute; inset: 0; z-index: 6; display: flex; align-items: center; justify-content: center; padding-top: 72px; background: var(--board-busy); color: var(--on-color); font-family: var(--font-body); font-weight: 700; font-size: var(--fs-body); letter-spacing: 0.02em; backdrop-filter: blur(1px); }
.board-shell.busy::before { content: ""; position: absolute; left: 50%; top: 50%; z-index: 7; width: 44px; height: 44px; margin: -40px 0 0 -22px; /* token-ok: centres the 44px spinner */ border-radius: 50%; border: 4px solid var(--spinner-track); border-top-color: var(--brand); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.player.thinking .turn::before { animation: pulse 1s ease-in-out infinite; }
.player.thinking .turn::after { content: "thinking"; margin-left: 2px; }
.player.thinking .turn { display: inline-flex; }
@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.4; transform: scale(0.7); } }
@media (prefers-reduced-motion: reduce) { .board-shell.busy::before { animation: none; } .player.thinking .turn::before { animation: none; } }

/* the Slowrun course */
.course-progress { display: flex; align-items: center; gap: 12px; margin: 12px 0 16px; }
.course-progress .progress { flex: 0 0 200px; height: 6px; }
.course-routine { background: var(--bg); border-radius: var(--radius-sm); padding: 12px 16px; margin-bottom: 16px; }
.course-routine h3 { margin: 0 0 8px; font-size: var(--fs-label); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); }
.course-routine ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.course-routine label { display: flex; gap: 8px; align-items: flex-start; font-size: var(--fs-body); cursor: pointer; }
.course-routine input:checked + span { color: var(--ink-3); text-decoration: line-through; }
.course-list { display: flex; flex-direction: column; }
.concept { border-top: 1px solid var(--line); }
.concept summary { display: flex; align-items: center; gap: 12px; padding: 12px 4px; cursor: pointer; list-style: none; }
.concept summary::-webkit-details-marker { display: none; }
.concept summary::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--line-strong); flex: none; }
.concept.learned summary::before { background: var(--brand); }
.concept .c-name { font-family: var(--font-body); font-weight: 700; font-size: var(--fs-body); flex: 1; }
.concept .eps { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.concept .eps a { font-family: var(--font-mono); font-size: var(--fs-label); padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--ink-3); text-decoration: none; }
.concept .eps a:hover { background: var(--brand); color: var(--brand-ink); }
.concept .c-body { padding: 0 4px 12px 24px; max-width: 72ch; }
.concept .c-body p { margin: 0 0 8px; font-size: var(--fs-body); line-height: 1.55; color: var(--ink); }
.concept .c-body b { color: var(--brand); font-weight: 700; }
.c-learned { display: flex; gap: 8px; align-items: center; font-size: var(--fs-meta); color: var(--ink-3); cursor: pointer; margin-top: 8px; }
@media (max-width: 640px) { .concept summary { flex-wrap: wrap; } .concept .eps { justify-content: flex-start; width: 100%; padding-left: 20px; } .course-progress .progress { flex: 1; } }

/* ---------- course (repertoire trainer) ---------- */
.course-home { max-width: 1100px; }
.course-side { margin: 16px 0 8px; font-size: var(--fs-meta); text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-3); }
.course-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.course-card { position: relative; display: flex; flex-direction: column; gap: 4px; align-items: flex-start; text-align: left; }
.course-card .hint { margin: 0; }
.course-card.soon { opacity: 0.5; cursor: default; }
.course-card .due-badge { position: absolute; top: 10px; right: 10px; min-width: 22px; padding: 1px 8px; border-radius: 999px; background: var(--brand); color: var(--brand-ink); font-size: var(--fs-label); font-weight: 700; text-align: center; }
.ms-move.muted { opacity: 0.55; }
.ms-move.bad { color: var(--blunder); }
#courseTiers { margin: 4px 0; }
.grade-best { color: var(--good); } .grade-good { color: var(--good); } .grade-inaccuracy { color: var(--inacc); } .grade-mistake { color: var(--mistake); } .grade-blunder { color: var(--blunder); }
.callout .test-moves { display: block; margin-top: 4px; font-family: var(--font-mono); font-size: var(--fs-meta); }
.ms-move.active[class*="grade-"] { background: transparent; outline: 1px solid currentColor; outline-offset: -1px; }
/* course unit player (task 3.4) */
.course-steps { margin: 8px 0 12px; }
.mcq-opts { display: grid; gap: 8px; margin-top: 8px; }
.mcq-opts .btn { justify-content: flex-start; text-align: left; white-space: normal; line-height: 1.3; }
.mcq-opts .btn.right { outline: 2px solid var(--good); }
.mcq-opts .btn.wrong { outline: 2px solid var(--blunder); opacity: 0.7; }
.course-card.weak { border-color: var(--blunder); }
.sources { max-width: 70ch; font-size: var(--fs-body); }
.sources h3, .sources h4 { margin: 16px 0 8px; }
.sources ul { margin: 0 0 12px; padding-left: 20px; }
.sources-line { margin-top: 12px; font-size: var(--fs-body); }

/* ---------- Learn home: tier list + lessons by track; optional path view ---------- */
.ladder { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 16px; align-items: start; max-width: 1100px; }
.tier-list { display: flex; flex-direction: column; gap: 4px; position: sticky; top: 16px; }
.tier-item { display: grid; grid-template-columns: 36px 1fr auto; align-items: center; gap: 12px; width: 100%; min-height: 52px; padding: 8px 12px; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--ink); font: inherit; text-align: left; cursor: pointer; transition: background var(--ease); }
.tier-item:hover { background: var(--surface-1); }
.tier-item[aria-current="true"] { background: var(--surface-1); box-shadow: inset 0 0 0 1px var(--line-strong); }
.tier-item.locked { color: var(--ink-3); }
.tier-item-text { display: flex; flex-direction: column; min-width: 0; }
.tier-item-text b { font-weight: 600; }
.tier-item-text .hint { margin: 0; }
.tier-item-n { font-size: var(--fs-meta); color: var(--ink-3); font-variant-numeric: tabular-nums; }
.tier-item-n .ico { margin: 0; width: 16px; height: 16px; }
.tier-item:not(.locked) .tier-item-n .ico { color: var(--brand); }
.ring { width: 36px; height: 36px; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 4; }
.ring-track { stroke: var(--surface-3); }
.ring-fill { stroke: var(--brand); stroke-linecap: round; }
.tier-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.tier-main .tier-title { margin: 4px 0; font-size: var(--fs-title); font-weight: 700; }
.tier-head .hint { margin: 0; }
.tier-actions { display: flex; gap: 8px; align-items: center; }
.tier-actions .btn[aria-pressed="true"] { background: var(--surface-2); color: var(--ink); }
.tier-sel { margin-bottom: 16px; }
.tier-sel p { margin: 4px 0 0; }
.track-head { display: flex; align-items: center; gap: 8px; margin: 24px 0 4px; font-size: var(--fs-label); text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-3); font-weight: 600; }
.track-head:first-child { margin-top: 0; }
.track-head .ico { margin: 0; width: 16px; height: 16px; }
.track-head .hint { margin: 0 0 0 auto; text-transform: none; letter-spacing: 0; }
.lesson-row { border-top: 1px solid var(--line); }
.lesson-row .lesson-dot { width: 28px; height: 28px; flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--ink-3); }
.lesson-row .lesson-dot .ico { margin: 0; width: 16px; height: 16px; }
.lesson-row.done .lesson-dot { background: var(--brand-soft); color: var(--brand); }
.lesson-row.current .lesson-dot { background: var(--brand); color: var(--brand-ink); }
.lesson-row .lesson-text { display: flex; flex-direction: column; min-width: 0; }
.lesson-row .lesson-title { font-weight: 600; }
.lesson-row.current .lesson-title { color: var(--brand); }
.lesson-row .hint { margin: 0; }
.lesson-row > .ico { margin: 0; color: var(--ink-3); width: 16px; height: 16px; }
.lesson-row.locked { color: var(--ink-3); cursor: default; }
.lesson-row.locked:hover { background: none; }
.tier-body.as-path { max-height: calc(100vh - 220px); overflow-y: auto; overscroll-behavior: contain; container-type: inline-size; }
.learn-tiles { display: flex; flex-direction: column; align-items: center; padding: 8px 0; }
.learn-tile { --d: clamp(84px, 26cqw, 132px); position: relative; width: var(--d); height: var(--d); flex: none; border: 0; padding: 0; cursor: pointer; background: var(--surface-2); color: var(--ink-2); clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); display: grid; place-items: center; transition: filter var(--ease); }
.learn-tile + .learn-tile { margin-top: calc(var(--d) / -2); }
.learn-tile.c0 { transform: translateX(calc(var(--d) / -4)); }
.learn-tile.c1 { transform: translateX(calc(var(--d) / 4)); }
.learn-tile:hover:not(.locked) { filter: brightness(1.15); }
.learn-tile .ico { margin: 0; width: calc(var(--d) * 0.28); height: calc(var(--d) * 0.28); }
.learn-tile.open { background: var(--line-strong); }
.learn-tile.done { background: var(--brand); color: var(--brand-ink); }
.learn-tile.current { background: var(--ink); color: var(--bg); }
.learn-tile.locked { background: var(--surface-3); color: var(--ink-3); }
.learn-tile.selected::after { content: ""; position: absolute; inset: calc(var(--d) * 0.07); clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%, 50% 0, 50% 7px, 7px 50%, 50% calc(100% - 7px), calc(100% - 7px) 50%, 50% 7px); background: var(--brand); }
.learn-check { position: absolute; bottom: calc(var(--d) * 0.17); left: 50%; transform: translateX(-50%); width: calc(var(--d) * 0.2); height: calc(var(--d) * 0.2); border-radius: 50%; background: var(--brand-ink); color: var(--brand); display: grid; place-items: center; }
.learn-check .ico { width: 60%; height: 60%; }
.course-more { margin-top: 24px; max-width: 1100px; }
.course-more > summary { cursor: pointer; color: var(--ink-3); font-weight: 600; font-size: var(--fs-body); padding: 8px 0; }
.course-more[open] > summary { color: var(--ink); }
@media (max-width: 900px) {
  .ladder { grid-template-columns: 1fr; }
  .tier-list { position: static; flex-direction: row; overflow-x: auto; scrollbar-width: thin; padding-bottom: 4px; }
  .tier-item { flex: none; width: auto; grid-template-columns: 36px auto; }
  .tier-item-n { display: none; }
}
@media (max-width: 760px) {
  .tier-main { padding: 16px; } .tier-actions { width: 100%; } .tier-actions #courseGo { flex: 1; }
  .tier-list { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); overflow: visible; gap: 4px; }
  .tier-item { grid-template-columns: 1fr; justify-items: center; gap: 4px; padding: 8px 4px; min-height: 0; text-align: center; }
  .tier-item-text { align-items: center; } .tier-item-text b { font-size: var(--fs-label); } .tier-item-text .hint { display: none; }
}
.course-more .link { display: inline-block; padding: 4px 0; }
/* course: folded explanation of a bad counter (task 7.2) */
.counter-why { margin-top: 8px; }
.counter-why summary { cursor: pointer; font-weight: 700; }
/* lesson view header (task 9.6): breadcrumb, title, meta, step tabs, progress, sections */
.crumbs { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: var(--fs-meta); color: var(--ink-3); }
.crumbs .link { padding: 4px 0; }
#courseCrumbs { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.crumb-sep { color: var(--ink-3); }
.lesson-title-h { margin: 4px 0 0; font-size: var(--fs-title); font-weight: 700; line-height: 1.25; text-wrap: balance; }
.course-meta { margin: 0; }
.course-meta:empty { display: none; }
.lesson-prog { margin: 4px 0 0; }
.step-title { margin: 8px 0 0; font-size: var(--fs-section); font-weight: 600; }
.step-title:empty { display: none; }
#courseNote { max-width: 68ch; min-height: 0; flex: 0 1 auto; }
@media (max-width: 760px) { #courseNote { flex: 1 1 auto; min-height: 140px; } }
#courseNote .lede { font-weight: 600; color: var(--ink); }
#courseNote h4 { margin: 16px 0 4px; font-size: var(--fs-label); text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-3); font-weight: 600; }
#courseNote h4 + p { margin-top: 0; }
.move-chip { display: inline; border: 0; padding: 2px 8px; margin: 0 1px; border-radius: 6px; background: var(--surface-2); color: var(--ink); font-family: var(--font-mono); font-size: 0.9em; font-weight: 500; cursor: pointer; transition: background var(--ease); }
.move-chip:hover { background: var(--surface-3); }
.move-chip.active { background: var(--brand); color: var(--brand-ink); }

/* ---------- 9.7 Puzzles + Play ---------- */
/* stats strip on top of the puzzle panel: number + label inline, hairline dividers */
.puzzle-strip { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--bg); border-bottom: 1px solid var(--line); }
.strip-item { display: flex; align-items: baseline; justify-content: center; gap: 8px; padding: 12px 8px; min-width: 0; white-space: nowrap; }
.strip-item + .strip-item { border-left: 1px solid var(--line); }
.strip-item b { font-size: var(--fs-card); font-weight: 700; font-variant-numeric: tabular-nums; }
.strip-item span { font-size: var(--fs-label); text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600; color: var(--ink-3); }
.strip-item i { font-style: normal; font-weight: 700; letter-spacing: 0; margin-left: 4px; }
.strip-item i.up { color: var(--good); } .strip-item i.down { color: var(--blunder); }

/* compact settings row: theme + level selects */
.puzzle-settings { display: flex; gap: 8px; align-items: center; margin-bottom: 16px; }
.select-chip { position: relative; display: flex; flex-direction: column; flex: 1 1 0; min-width: 0; padding: 4px 32px 4px 12px; border-radius: var(--radius-sm); background: var(--surface-2); cursor: pointer; transition: background var(--ease); }
.select-chip:hover { background: var(--surface-3); }
.select-chip::after { content: ""; position: absolute; right: 12px; top: 50%; width: 6px; height: 6px; margin-top: -4px; border-right: 2px solid var(--ink-3); border-bottom: 2px solid var(--ink-3); transform: rotate(45deg); pointer-events: none; }
.select-chip > span { font-size: var(--fs-label); text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600; color: var(--ink-3); }
.select-chip select { appearance: none; -webkit-appearance: none; background: transparent; border: 0; padding: 0; width: 100%; font-size: var(--fs-meta); font-weight: 600; color: var(--ink); cursor: pointer; text-overflow: ellipsis; }
.select-chip select:focus-visible { outline: none; }
.select-chip:focus-within { outline: 2px solid var(--brand); outline-offset: 2px; }
.select-chip option { background: var(--surface-2); color: var(--ink); }
.puzzle-settings .btn.icon { flex: none; width: 44px; height: 44px; padding: 0; justify-content: center; }

/* one toolbar style for board actions */
.toolbar { display: flex; align-items: center; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.toolbar .btn.icon { width: 40px; height: 40px; min-width: 40px; padding: 0; justify-content: center; }

/* journey: horizontal stepper with a connecting line */
.stepper { display: flex; align-items: center; overflow-x: auto; padding: 4px 4px 8px; scrollbar-width: thin; scroll-behavior: smooth; }
.stepper .step { position: relative; flex: none; display: grid; place-items: center; width: 32px; height: 32px; margin-right: 16px; border-radius: 50%; border: 2px solid var(--line-strong); background: var(--surface-1); color: var(--ink-3); font-weight: 700; font-size: var(--fs-meta); font-variant-numeric: tabular-nums; cursor: pointer; transition: background var(--ease), border-color var(--ease); }
.stepper .step:last-child { margin-right: 0; }
.stepper .step:not(:last-child)::after { content: ""; position: absolute; left: 100%; top: 50%; width: 18px; height: 2px; margin-left: 0; background: var(--line-strong); }
.stepper .step.done { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.stepper .step.done::after { background: var(--brand); }
.stepper .step.done .ico { width: 16px; height: 16px; }
.stepper .step.current { border-color: var(--brand); color: var(--ink); box-shadow: 0 0 0 4px var(--brand-soft); }
.stepper .step:hover:not(:disabled) { border-color: var(--brand); }
.stepper .step:disabled { cursor: not-allowed; opacity: 0.5; }
.journey-run { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 12px; font-size: var(--fs-meta); color: var(--ink-3); }
.journey-run .dots { display: flex; gap: 4px; }
.journey-run .dots i { width: 12px; height: 12px; border-radius: 50%; background: var(--surface-3); }
.journey-run .dots i.ok { background: var(--good); } .journey-run .dots i.bad { background: var(--blunder); } .journey-run .dots i.now { box-shadow: inset 0 0 0 2px var(--brand); }
.storm-bar { margin: 0 0 12px; }

/* toggle switch on a checkbox */
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 16px; cursor: pointer; }
.switch-row > span { display: flex; flex-direction: column; gap: 2px; font-size: var(--fs-body); }
.switch-row > span b { font-weight: 600; }
.switch-row > span small { color: var(--ink-3); font-size: var(--fs-meta); }
.switch-row.sm > span { font-size: var(--fs-meta); color: var(--ink-3); }
input.switch { appearance: none; -webkit-appearance: none; flex: none; position: relative; width: 40px; height: 24px; margin: 0; border-radius: 999px; background: var(--surface-3); cursor: pointer; transition: background var(--ease); }
input.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--ink-2); transition: transform var(--ease), background var(--ease); }
input.switch:checked { background: var(--brand); }
input.switch:checked::after { transform: translateX(16px); background: var(--brand-ink); }
input.switch:focus { box-shadow: none; }
input.switch:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* play setup: level slider with named stops, colour segmented control */
.field { margin-top: 16px; }
.field-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.field-head b { font-size: var(--fs-body); font-weight: 600; font-variant-numeric: tabular-nums; }
.field-label { display: block; font-size: var(--fs-label); text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600; color: var(--ink-3); margin-bottom: 8px; }
.field-head .field-label { margin-bottom: 0; }
.slider { -webkit-appearance: none; appearance: none; display: block; width: 100%; height: 24px; margin: 0; background: transparent; cursor: pointer; --fill: 0%; }
.slider::-webkit-slider-runnable-track { height: 6px; border-radius: 999px; background: linear-gradient(to right, var(--brand) var(--fill), var(--surface-3) var(--fill)); }
.slider::-moz-range-track { height: 6px; border-radius: 999px; background: linear-gradient(to right, var(--brand) var(--fill), var(--surface-3) var(--fill)); }
.slider::-webkit-slider-thumb { -webkit-appearance: none; width: 20px; height: 20px; margin-top: -7px; /* token-ok: centres the thumb on the 6px track */ border-radius: 50%; background: var(--ink); border: 0; box-shadow: 0 0 0 4px var(--brand-soft); }
.slider::-moz-range-thumb { width: 20px; height: 20px; border-radius: 50%; background: var(--ink); border: 0; box-shadow: 0 0 0 4px var(--brand-soft); }
.slider:focus { outline: none; box-shadow: none; }
.slider:focus-visible::-webkit-slider-thumb { outline: 2px solid var(--brand); outline-offset: 2px; }
.slider-stops { display: flex; justify-content: space-between; margin: 4px -4px 0; }
.slider-stops button { flex: 1 1 0; min-width: 0; border: 0; background: none; padding: 4px; color: var(--ink-3); font-size: var(--fs-label); font-weight: 600; cursor: pointer; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-radius: 4px; }
.slider-stops button:first-child { text-align: left; } .slider-stops button:last-child { text-align: right; }
.slider-stops button:hover { color: var(--ink); }
.slider-stops button[aria-pressed="true"] { color: var(--brand); }
.seg-fill { flex-wrap: nowrap; gap: 4px; padding: 4px; border-radius: var(--radius-sm); background: var(--surface-2); }
.seg-fill .seg-btn { flex: 1; justify-content: center; border-radius: 6px; background: transparent; min-height: 36px; }
.seg-fill .seg-btn:hover { background: var(--surface-3); }
.seg-fill .seg-btn[aria-pressed="true"] { background: var(--brand); color: var(--brand-ink); }
#playSetup .card-foot { display: flex; gap: 8px; align-items: center; margin-top: 20px; }
#playSetup .card-foot #playNew { flex: 1; justify-content: center; }
.practice-list .row { padding: 8px 4px; }
.practice-list .row-body { display: flex; flex-direction: column; gap: 2px; }
.practice-list .row-body b { font-weight: 600; font-size: var(--fs-body); }
.practice-list .row-body small { color: var(--ink-3); font-size: var(--fs-meta); }
.practice-list .row > .ico { flex: none; color: var(--ink-3); width: 16px; height: 16px; }

/* in-game: move list with grade chips */
.move-list { display: grid; grid-template-columns: 3ch 1fr 1fr; align-items: center; row-gap: 2px; column-gap: 4px; max-height: 240px; overflow-y: auto; margin-top: 12px; padding: 8px; border-radius: var(--radius-sm); background: var(--bg); font-family: var(--font-mono); font-size: var(--fs-meta); font-variant-numeric: tabular-nums; scrollbar-width: thin; }
.ml-no { color: var(--ink-3); text-align: right; padding-right: 4px; }
.ml-move { display: flex; align-items: center; gap: 4px; min-height: 28px; padding: 0 8px; border-radius: 4px; }
.ml-move.last { background: var(--surface-2); }
.ml-empty { grid-column: 1 / -1; font-family: var(--font-body); color: var(--ink-3); padding: 4px; }
.grade-chip { font-family: var(--font-body); font-size: var(--fs-label); font-weight: 700; line-height: 1; padding: 2px 4px; border-radius: 4px; color: var(--on-amber); }
.grade-chip.inaccuracy { background: var(--inacc); } .grade-chip.mistake { background: var(--mistake); } .grade-chip.blunder { background: var(--blunder); color: var(--on-color); }
.play-coach { margin-top: 12px; }
.play-coach .why-list { margin-bottom: 12px; }
#playGame .card-head h2 { font-size: var(--fs-card); }
#playGame .drill-status:empty { display: none; }
@media (max-width: 760px) { .move-list { max-height: 160px; } .strip-item { padding: 8px 4px; } }
#drillsView .drill-status:empty { min-height: 0; margin-top: 0; }

/* ---------- 9.8 Review ---------- */
.row .row-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.row .row-body b { font-weight: 600; font-size: var(--fs-body); }
.row .row-body small { color: var(--ink-3); font-size: var(--fs-meta); }
.row > .ico:first-child { flex: none; width: 18px; height: 18px; color: var(--ink-3); }
.row .row-go { flex: none; font-size: var(--fs-meta); font-weight: 600; color: var(--brand); }
.row .num, .row.sm .num { font-variant-numeric: tabular-nums; font-size: var(--fs-meta); color: var(--ink-2); white-space: nowrap; }
.insights-empty div.empty-state { padding: 8px 0; }
.insights-progress { display: flex; align-items: center; gap: 12px; width: min(320px, 100%); margin: 4px 0 8px; font-size: var(--fs-meta); color: var(--ink-3); font-variant-numeric: tabular-nums; }
.insights-progress .progress { flex: 1; }
.patterns .insights-empty + .pattern-grid { margin-top: 16px; }
@media (max-width: 760px) {
  .row.sm .num { white-space: normal; text-align: right; flex: 0 1 auto; }
  .game-row .row-body > small { white-space: normal; }
}

/* ---------- 9.9 phone: slim top bar (title + avatar), 5-item bottom bar, 44px tap targets ---------- */
.topbar { display: none; }
@media (max-width: 760px) {
  :root { --top-h: 48px; }
  .topbar { display: flex; align-items: center; position: sticky; top: 0; z-index: 30; height: var(--top-h); margin: -12px -16px 8px; padding: 0 64px 0 16px; background: var(--bg); border-bottom: 1px solid var(--line); }
  .topbar-title { margin: 0; font-family: var(--font-display); font-size: var(--fs-section); font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .side-foot { position: fixed; top: 0; right: 8px; height: var(--top-h); z-index: 41; padding: 0; gap: 8px; }
  .side-foot > .btn { min-height: 36px; padding: 8px 12px; font-size: var(--fs-meta); }
  .avatar-btn { width: 44px; height: 44px; padding: 0; justify-content: center; }
  .avatar { width: 32px; height: 32px; }
  .popover { top: calc(var(--top-h) + 4px); bottom: auto; max-height: calc(100dvh - var(--top-h) - var(--nav-h, 72px) - 16px); }
  .signin-pop { top: calc(var(--top-h) + 4px); bottom: auto; }
  .tabs { justify-content: space-around; }
  .tab { min-height: 52px; font-size: var(--fs-nav); font-weight: 600; gap: 4px; }
  .page-head:not(.compact) > h2 { display: none; }
  .page-head:has(> h2:only-child) { display: none; }
  /* tap targets */
  .btn, .seg-btn:not(.seg.under > .seg-btn), select, .select-chip { min-height: 44px; }
  .seg-btn { min-width: 44px; justify-content: center; }
  .btn.icon, .toolbar .btn.icon { min-width: 44px; height: 44px; width: 44px; }
  .btn.sm { min-height: 40px; }
  .seg.under > .seg-btn { min-height: 44px; }
  button.row { min-height: 44px; }
  .slider-stops button { min-height: 44px; }
  .slider { height: 44px; }
  .switch-row { min-height: 44px; }
}
.switch-inline { display: inline-flex; align-items: center; gap: 8px; margin: 0; font-size: var(--fs-meta); color: var(--ink-3); cursor: pointer; }
@media (max-width: 760px) { .switch-inline { min-height: 44px; } }
@media (max-width: 760px) {
  /* board + both player bars fit between the top bar and the 34vh sheet */
  .drill-layout .stage, .lesson-layout .stage { width: min(100%, calc(66dvh - var(--top-h) - var(--nav-h, 60px) - 84px)); margin-inline: auto; }
  #analyzeView .stage { width: min(100%, calc(66dvh - var(--top-h) - var(--nav-h, 60px) - 132px + 14px)); margin-inline: auto; }
  /* sheet spacing: no gap slots for empty rows, tighter head */
  .reader { gap: 8px; }
  .reader .lib-filter:empty, .reader > [hidden] { display: none; }
  .reader .lesson-title-h { font-size: var(--fs-section); margin: 0; }
  .reader .course-steps { margin: 4px 0; }
  .reader-top .link { min-height: 44px; min-width: 44px; padding: 8px 4px; margin: -8px -4px; }
  .side-panel .card, .side-panel .pane > .callout { padding: 16px; }
  body[data-view="course"]:has(#courseTrainer:not([hidden])) .subnav { display: none; }
}

/* ---------- 9.10 micro-interactions ---------- */
/* press: a small sink on everything clickable; hover/focus already on each component */
.btn:active:not(:disabled), .seg-btn:active, button.row:active, .tab:active, .stepper .step:active:not(:disabled), .avatar-btn:active, .card-link:active { transform: scale(0.98); }
.btn, .seg-btn, button.row, .tab, .avatar-btn, .card-link { transition: background var(--ease), color var(--ease), transform 100ms ease-out, border-color var(--ease); }
.link:hover { text-decoration: underline; text-underline-offset: 3px; }
button.row:focus-visible, .card-link:focus-visible, .tab:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
.btn:disabled, .seg-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* skeleton loaders */
.skeleton { display: flex; flex-direction: column; gap: 12px; padding: 8px 0; }
.skeleton i { display: block; height: 12px; border-radius: 6px; background: linear-gradient(90deg, var(--surface-2) 0%, var(--surface-3) 50%, var(--surface-2) 100%); background-size: 200% 100%; animation: skeleton 1.2s ease-in-out infinite; }
.skeleton i:last-child:not(:first-child) { width: 60%; }
.skeleton.block { background: var(--surface-1); border-radius: var(--radius); padding: 20px; }
.skeleton.block i:first-child { height: 24px; width: 40%; }
.home-sub .skeleton, #homeSub .skeleton { padding: 4px 0; width: 280px; max-width: 100%; }
@keyframes skeleton { from { background-position: 100% 0; } to { background-position: -100% 0; } }

/* board flip: a short fade-and-settle instead of a jump */
.board-shell.flip-anim .board { animation: board-flip 220ms ease-out; }
@keyframes board-flip { from { opacity: 0.25; transform: scale(0.97) rotate(-3deg); } to { opacity: 1; transform: none; } }

/* keyboard shortcuts dialog (?) */
.keys-dialog { width: min(520px, calc(100vw - 32px)); max-height: calc(100dvh - 64px); padding: 24px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface-2); color: var(--ink); box-shadow: var(--shadow); }
.keys-dialog::backdrop { background: var(--scrim); }
.keys-dialog h2 { margin: 0 0 16px; font-size: var(--fs-section); font-weight: 700; }
.keys-dialog h3 { margin: 16px 0 8px; font-size: var(--fs-label); text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600; color: var(--ink-3); }
.keys-dialog dl { display: grid; grid-template-columns: 9rem 1fr; align-items: center; gap: 8px 16px; margin: 0; font-size: var(--fs-body); }
.keys-dialog dt { white-space: nowrap; }
.keys-dialog dd { margin: 0; color: var(--ink-2); }
kbd { display: inline-block; min-width: 24px; padding: 2px 8px; border-radius: 6px; background: var(--surface-1); border: 1px solid var(--line-strong); border-bottom-width: 2px; font-family: var(--font-body); font-size: var(--fs-meta); font-weight: 600; text-align: center; }
.keys-dialog .dialog-foot { display: flex; justify-content: flex-end; margin-top: 20px; }
.keys-dialog .dialog-foot .btn { background: var(--surface-3); }
