/* Chess Trainer — styled to sit next to StudyCorner (indigo accent, Inter,
   light/dark). Self-hosted fonts so file:// works offline. */
@font-face {
  font-family: "Inter"; font-style: normal; font-display: swap; font-weight: 100 900;
  src: url("../fonts/inter-latin-wght-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter"; font-style: normal; font-display: swap; font-weight: 100 900;
  src: url("../fonts/inter-latin-ext-wght-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1E9F, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  color-scheme: light;
  --paper: #f7f7fc;
  --surface: #ffffff;
  --surface-2: #f2f2f9;
  --ink: #12122b;
  --ink-soft: #42425e;
  --muted: #6b6b86;
  --line: #e5e4f0;
  --line-strong: #d0cee3;
  --accent: #5a45e6;
  --accent-dark: #4630cc;
  --accent-soft: #efecff;
  --good: #0f9a72;
  --good-soft: #e2f6ee;
  --warn: #b8730a;
  --warn-soft: #fdf3e1;
  --bad: #dc3a4c;
  --bad-soft: #fdeaec;
  --gradient: linear-gradient(135deg, #5a45e6 0%, #7c4dff 48%, #b450f0 100%);
  --shadow-sm: 0 1px 2px rgb(18 18 43 / 5%), 0 1px 3px rgb(18 18 43 / 4%);
  --shadow: 0 1px 2px rgb(18 18 43 / 4%), 0 10px 28px -10px rgb(40 30 110 / 18%);
  --shadow-lg: 0 2px 4px rgb(18 18 43 / 4%), 0 24px 48px -16px rgb(40 30 110 / 26%);
  --sans: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", "Cascadia Code", Consolas, monospace;
  --radius-sm: .55rem;
  --radius: .9rem;
  --radius-lg: 1.25rem;
  --ease: cubic-bezier(.22, 1, .36, 1);
  --sq-light: #eed8b6;
  --sq-dark: #b08560;
  --hl-last: rgb(255 214 64 / 42%);
  --hl-sel: rgb(90 69 230 / 38%);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #0b0c17;
  --surface: #12142a;
  --surface-2: #181a33;
  --ink: #eeedfb;
  --ink-soft: #bdbbd8;
  --muted: #8d8bab;
  --line: #24273f;
  --line-strong: #353859;
  --accent: #8f80ff;
  --accent-dark: #ada2ff;
  --accent-soft: #221e4d;
  --good: #3ddc9f;
  --good-soft: #12302a;
  --warn: #f5b84a;
  --warn-soft: #33270f;
  --bad: #ff7a8a;
  --bad-soft: #3a1720;
  --gradient: linear-gradient(135deg, #6e5bff 0%, #8b5cf6 48%, #c05cf5 100%);
  --shadow-sm: 0 1px 2px rgb(0 0 0 / 30%);
  --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 10px 30px -10px rgb(0 0 0 / 55%);
  --shadow-lg: 0 2px 4px rgb(0 0 0 / 30%), 0 28px 56px -18px rgb(0 0 0 / 70%);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) {
    color-scheme: dark;
    --paper: #0b0c17; --surface: #12142a; --surface-2: #181a33; --ink: #eeedfb; --ink-soft: #bdbbd8; --muted: #8d8bab;
    --line: #24273f; --line-strong: #353859; --accent: #8f80ff; --accent-dark: #ada2ff; --accent-soft: #221e4d;
    --good: #3ddc9f; --good-soft: #12302a; --warn: #f5b84a; --warn-soft: #33270f; --bad: #ff7a8a; --bad-soft: #3a1720;
    --gradient: linear-gradient(135deg, #6e5bff 0%, #8b5cf6 48%, #c05cf5 100%);
    --shadow-sm: 0 1px 2px rgb(0 0 0 / 30%); --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 10px 30px -10px rgb(0 0 0 / 55%);
    --shadow-lg: 0 2px 4px rgb(0 0 0 / 30%), 0 28px 56px -18px rgb(0 0 0 / 70%);
  }
}

/* board themes */
[data-board="walnut"] { --sq-light: #eed8b6; --sq-dark: #b08560; }
[data-board="indigo"] { --sq-light: #e7e4f6; --sq-dark: #8a7fd0; --hl-last: rgb(255 214 64 / 45%); }
[data-board="green"] { --sq-light: #ecedd1; --sq-dark: #739552; }
[data-board="slate"] { --sq-light: #dee3e6; --sq-dark: #8ca2ad; }
[data-board="coral"] { --sq-light: #f1e6dc; --sq-dark: #c9846d; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh;
  background: var(--paper); color: var(--ink);
  font: 15px/1.55 var(--sans);
  font-feature-settings: "cv11", "ss01";
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { line-height: 1.2; margin: 0 0 .5rem; letter-spacing: -.01em; }
h1 { font-size: clamp(1.6rem, 3vw, 2.2rem); font-weight: 800; letter-spacing: -.025em; }
h2 { font-size: 1.3rem; font-weight: 750; }
h3 { font-size: 1.05rem; font-weight: 700; }
p { margin: 0 0 .7rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.icon { flex: none; }
.san { font-weight: 650; white-space: nowrap; }
.prose p:last-child { margin-bottom: 0; }
.prose strong { color: var(--ink); }
:focus-visible { outline: 2.5px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---------- shell ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 1rem;
  padding: .55rem 1rem;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: .55rem; font-weight: 800; color: var(--ink); letter-spacing: -.02em; font-size: 1.05rem; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 30px; height: 30px; border-radius: 9px; background: var(--gradient); display: grid; place-items: center; color: #fff; box-shadow: var(--shadow-sm); }
.nav { display: flex; gap: .15rem; overflow-x: auto; scrollbar-width: none; flex: 1; }
.nav::-webkit-scrollbar { display: none; }
.nav a { display: flex; align-items: center; gap: .4rem; padding: .45rem .7rem; border-radius: .6rem; color: var(--ink-soft); font-weight: 600; font-size: .9rem; white-space: nowrap; }
.nav a:hover { background: var(--surface-2); text-decoration: none; color: var(--ink); }
.nav a.active { background: var(--accent-soft); color: var(--accent-dark); }
.topbar-right { display: flex; align-items: center; gap: .5rem; }
.pill { display: inline-flex; align-items: center; gap: .3rem; padding: .25rem .6rem; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); font-size: .8rem; font-weight: 650; color: var(--ink-soft); white-space: nowrap; }
.pill .icon { color: var(--warn); }
.embed .topbar { display: none; }
.embed-open { position: absolute; top: .45rem; right: .6rem; z-index: 30; display: grid; place-items: center; width: 2rem; height: 2rem; border-radius: .55rem; background: var(--surface); border: 1px solid var(--line); color: var(--ink-soft); box-shadow: var(--shadow-sm); opacity: .75; }
.embed-open:hover { opacity: 1; color: var(--accent-dark); text-decoration: none; }

.page { max-width: 1240px; margin: 0 auto; padding: 1.5rem 1rem 4rem; }
.page-narrow { max-width: 920px; }
.page-head { margin-bottom: 1.25rem; }
.page-head p { color: var(--muted); max-width: 60ch; }
.crumbs { font-size: .85rem; color: var(--muted); margin-bottom: .5rem; display: flex; gap: .4rem; flex-wrap: wrap; }
.crumbs a { color: var(--muted); }

/* ---------- cards & grids ---------- */
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.grid-2 { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.1rem 1.15rem; box-shadow: var(--shadow-sm);
}
.card h3 { margin-bottom: .3rem; }
a.card, .card.link { color: inherit; display: block; transition: transform var(--ease) .25s, box-shadow .25s; cursor: pointer; }
a.card:hover, .card.link:hover { text-decoration: none; transform: translateY(-2px); box-shadow: var(--shadow); }
.card-row { display: flex; align-items: center; gap: .75rem; }
.card-kicker { font-size: .72rem; font-weight: 750; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: .25rem; }
.card .meta { display: flex; gap: .75rem; flex-wrap: wrap; font-size: .8rem; color: var(--muted); margin-top: .6rem; }
.hero {
  position: relative; overflow: hidden;
  background: var(--gradient); color: #fff; border-radius: var(--radius-lg);
  padding: 1.6rem 1.5rem; box-shadow: var(--shadow); margin-bottom: 1.25rem;
}
.hero h1 { color: #fff; margin-bottom: .35rem; }
.hero p { color: rgb(255 255 255 / 88%); max-width: 62ch; }
.hero .stats { display: flex; gap: 1.6rem; flex-wrap: wrap; margin-top: 1rem; }
.hero .stat b { display: block; font-size: 1.6rem; font-weight: 800; line-height: 1.1; }
.hero .stat span { font-size: .78rem; opacity: .85; text-transform: uppercase; letter-spacing: .06em; font-weight: 650; }
.hero-knight { position: absolute; right: -10px; bottom: -30px; width: 210px; height: 210px; opacity: .14; background-size: contain; background-repeat: no-repeat; pointer-events: none; }

.section { margin: 2rem 0 1rem; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: .75rem; flex-wrap: wrap; }
.section-head p { margin: 0; color: var(--muted); font-size: .9rem; }

.bar { height: 7px; border-radius: 99px; background: var(--surface-2); overflow: hidden; border: 1px solid var(--line); }
.bar > span { display: block; height: 100%; background: var(--gradient); border-radius: 99px; transition: width .5s var(--ease); }
.bar.good > span { background: var(--good); }

.chip { display: inline-flex; align-items: center; gap: .25rem; padding: .12rem .5rem; border-radius: 99px; font-size: .72rem; font-weight: 700; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink-soft); white-space: nowrap; }
.chip-new { background: var(--accent-soft); color: var(--accent-dark); border-color: transparent; }
.chip-due { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.chip-learning { background: var(--surface-2); }
.chip-mastered, .chip-done { background: var(--good-soft); color: var(--good); border-color: transparent; }
.chip-w { background: #fff; color: #222; border-color: #bbb; }
.chip-b { background: #2b2938; color: #fff; border-color: #2b2938; }
.lvl { display: inline-grid; place-items: center; min-width: 1.4rem; height: 1.4rem; border-radius: .4rem; font-size: .7rem; font-weight: 800; background: var(--surface-2); color: var(--muted); }
.lvl-1 { background: var(--accent-soft); color: var(--accent-dark); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .55rem .9rem; border-radius: .65rem; border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--ink); font: inherit; font-weight: 650; font-size: .9rem;
  cursor: pointer; transition: background .15s, border-color .15s, transform .1s; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
:root[data-theme="dark"] .btn-primary, :root:not([data-theme]) .btn-primary { color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-soft); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn-danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn-sm { padding: .35rem .6rem; font-size: .8rem; border-radius: .55rem; }
.btn-good { background: var(--good); border-color: var(--good); color: #fff; }
.btn-row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.icon-btn { padding: .5rem; }

/* ---------- training layout ---------- */
.train {
  display: grid; gap: 1.25rem; align-items: start;
  grid-template-columns: minmax(0, min(680px, calc(100vh - 150px))) minmax(300px, 400px);
  justify-content: center;
}
.board-col { display: flex; gap: .5rem; min-width: 0; }
.board-wrap { flex: 1; min-width: 0; position: relative; }
.board-wrap .cb { box-shadow: var(--shadow); }
.board-below { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-top: .6rem; flex-wrap: wrap; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); display: flex; flex-direction: column; overflow: hidden; max-height: calc(100vh - 110px); position: sticky; top: 72px; }
.panel-head { padding: .9rem 1rem .7rem; border-bottom: 1px solid var(--line); }
.panel-head h2 { font-size: 1.05rem; margin: 0 0 .15rem; }
.panel-head .muted { font-size: .82rem; }
.panel-body { padding: .9rem 1rem; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: .8rem; }
.panel-body > * { flex-shrink: 0; }
.panel-foot { padding: .7rem 1rem; border-top: 1px solid var(--line); display: flex; gap: .5rem; flex-wrap: wrap; background: var(--surface-2); }
@media (max-width: 960px) {
  .train { grid-template-columns: minmax(0, 1fr); }
  .panel { position: static; max-height: none; }
  .board-col { max-width: min(100%, calc(100vh - 140px)); margin: 0 auto; width: 100%; }
}

/* Embedded in a StudyCorner lesson (?embed=1): the frame is about 700 x 600, so keep the
   board and panel side by side, with the board sized to the frame's height. */
.embed .page { padding: .45rem .6rem .45rem; }
.embed .crumbs { min-height: 2.1rem; align-items: center; margin-bottom: .35rem; padding-right: 2.6rem; }
.embed .board-below { margin-top: .4rem; }
@media (min-width: 560px) {
  .embed .train { grid-template-columns: minmax(0, min(680px, calc(100vh - 6.3rem))) minmax(280px, 1fr); gap: .75rem; }
  .embed .panel { position: sticky; top: .45rem; max-height: calc(100vh - 3.4rem); }
  .embed .board-col { max-width: none; margin: 0; }
}

.prompt { display: flex; align-items: center; gap: .6rem; padding: .7rem .8rem; border-radius: .7rem; background: var(--surface-2); border: 1px solid var(--line); font-weight: 650; }
.prompt .dot { width: .9rem; height: .9rem; border-radius: 50%; border: 1.5px solid #555; flex: none; }
.prompt .dot.w { background: #fff; } .prompt .dot.b { background: #2b2938; }
.feedback { padding: .75rem .85rem; border-radius: .7rem; border: 1px solid var(--line); background: var(--surface-2); font-size: .92rem; }
.feedback h4 { margin: 0 0 .25rem; font-size: .95rem; display: flex; align-items: center; gap: .4rem; }
.feedback.good { background: var(--good-soft); border-color: transparent; }
.feedback.good h4 { color: var(--good); }
.feedback.bad { background: var(--bad-soft); border-color: transparent; }
.feedback.bad h4 { color: var(--bad); }
.feedback.warn { background: var(--warn-soft); border-color: transparent; }
.feedback.warn h4 { color: var(--warn); }
.feedback.info { background: var(--accent-soft); border-color: transparent; }
.feedback.info h4 { color: var(--accent-dark); }
.comment { font-size: .93rem; color: var(--ink-soft); }
.comment .who { font-weight: 750; color: var(--ink); }
.steps-dots { display: flex; gap: .3rem; flex-wrap: wrap; }
.steps-dots span { width: .6rem; height: .6rem; border-radius: 50%; background: var(--line-strong); }
.steps-dots span.done { background: var(--good); }
.steps-dots span.cur { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* move list */
.moves { display: grid; grid-template-columns: 2.4rem 1fr 1fr; gap: 1px 0; font-size: .9rem; align-content: start; }
.moves .num { color: var(--muted); padding: .2rem .3rem; text-align: right; font-variant-numeric: tabular-nums; }
.moves .mv { padding: .2rem .45rem; border-radius: .35rem; cursor: pointer; font-weight: 600; display: flex; align-items: center; gap: .3rem; min-height: 1.7rem; }
.moves .mv:hover { background: var(--surface-2); }
.moves .mv.cur { background: var(--accent-soft); color: var(--accent-dark); }
.moves .mv .k { font-size: .7rem; font-weight: 800; padding: 0 .3rem; border-radius: .3rem; color: #fff; }
.k-best, .k-great { background: #16a34a; } .k-excellent { background: #22c55e; } .k-good { background: #65a30d; }
.k-book { background: #a16207; } .k-inaccuracy { background: #d97706; } .k-mistake { background: #ea580c; }
.k-blunder { background: #dc2626; } .k-miss { background: #e11d48; }
.line-moves { font-size: .9rem; line-height: 1.8; }
.line-moves .m { padding: .1rem .25rem; border-radius: .3rem; cursor: pointer; font-weight: 600; }
.line-moves .m.cur { background: var(--accent-soft); color: var(--accent-dark); }
.line-moves .m.future { color: var(--muted); font-weight: 500; }
.line-moves .n { color: var(--muted); margin-left: .2rem; }

/* eval bar */
.evalbar { width: 16px; border-radius: 6px; background: #2c2a35; position: relative; overflow: hidden; border: 1px solid var(--line-strong); flex: none; }
.evalbar .fill { position: absolute; left: 0; right: 0; bottom: 0; background: #f4f2ee; transition: height .45s var(--ease); }
.evalbar.flipped .fill { bottom: auto; top: 0; }
.evalbar .val { position: absolute; left: 0; right: 0; font-size: 9px; font-weight: 800; text-align: center; z-index: 2; }
.evalbar .val.top { top: 3px; color: #f4f2ee; } .evalbar .val.bot { bottom: 3px; color: #2c2a35; }
.engine-lines { font-size: .82rem; display: flex; flex-direction: column; gap: .3rem; }
.engine-lines .el { display: flex; gap: .5rem; align-items: baseline; cursor: pointer; padding: .15rem .3rem; border-radius: .3rem; }
.engine-lines .el:hover { background: var(--surface-2); }
.engine-lines .sc { font-weight: 800; min-width: 3.4rem; font-variant-numeric: tabular-nums; }
.engine-lines .pv { color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- chessboard ---------- */
.cb { position: relative; width: 100%; aspect-ratio: 1 / 1; user-select: none; -webkit-user-select: none; touch-action: none; border-radius: 6px; overflow: hidden; container-type: inline-size; }
.cb-squares { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(8, 1fr); }
.cb-sq { position: relative; }
.cb-sq.light { background: var(--sq-light); }
.cb-sq.dark { background: var(--sq-dark); }
.cb-sq::after { content: ""; position: absolute; inset: 0; pointer-events: none; }
.cb-sq.last::after { background: var(--hl-last); }
.cb-sq.sel::after { background: var(--hl-sel); }
.cb-sq.mark-g::after { background: rgb(21 128 61 / 42%); }
.cb-sq.mark-r::after { background: rgb(220 38 38 / 40%); }
.cb-sq.mark-y::after { background: rgb(234 179 8 / 45%); }
.cb-sq.mark-b::after { background: rgb(37 99 235 / 38%); }
.cb-sq.check { background-image: radial-gradient(circle, rgb(255 0 0 / 85%) 0%, rgb(230 0 0 / 55%) 30%, rgb(169 0 0 / 0%) 75%); }
.cb-sq.dest::before { content: ""; position: absolute; left: 50%; top: 50%; width: 30%; height: 30%; transform: translate(-50%, -50%); border-radius: 50%; background: rgb(20 20 40 / 24%); z-index: 1; }
.cb-sq.cap::before { content: ""; position: absolute; inset: 4%; border-radius: 50%; border: 5px solid rgb(20 20 40 / 22%); border-width: max(3px, 0.8cqi); z-index: 1; }
.cb-sq.hover { box-shadow: inset 0 0 0 4px rgb(255 255 255 / 65%); }
.cb-coord { position: absolute; font-size: clamp(8px, 2.2cqi, 13px); font-weight: 700; line-height: 1; pointer-events: none; z-index: 2; }
.cb-rank { top: 4%; left: 5%; } .cb-file { bottom: 4%; right: 6%; }
.cb-sq.light .cb-coord { color: var(--sq-dark); } .cb-sq.dark .cb-coord { color: var(--sq-light); }
.cb-pieces { position: absolute; inset: 0; pointer-events: none; z-index: 3; }
.cb-pc { position: absolute; left: 0; top: 0; width: 12.5%; height: 12.5%; background-size: 100% 100%; background-repeat: no-repeat; will-change: transform; }
.cb-pc.anim { transition: transform 180ms var(--ease); }
.cb-pc.dragging { z-index: 10; filter: drop-shadow(0 6px 8px rgb(0 0 0 / 35%)); scale: 1.1; transition: none; }
.cb-pc.fade-in { animation: pcIn .2s ease; }
.cb-pc.fade-out { opacity: 0; transition: opacity .18s; }
@keyframes pcIn { from { opacity: 0; } to { opacity: 1; } }
.cb-svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 4; }
.cb-badge { position: absolute; z-index: 6; width: 2.3em; height: 2.3em; border-radius: 50%; color: #fff; font-weight: 850; font-size: clamp(9px, 2.6cqi, 15px); display: grid; place-items: center; box-shadow: 0 2px 6px rgb(0 0 0 / 35%); border: 2px solid #fff; pointer-events: none; letter-spacing: -.04em; }
.cb-badge.pop { animation: pop .3s var(--ease); }
@keyframes pop { from { transform: scale(.3); } to { transform: scale(1); } }
.cb-promo { position: absolute; inset: 0; z-index: 20; background: rgb(10 10 20 / 45%); }
.cb-promo-opt { position: absolute; width: 12.5%; height: 12.5%; border: 0; border-radius: 50%; background-color: #f5f3ff; background-size: 88%; background-position: center; background-repeat: no-repeat; cursor: pointer; box-shadow: 0 2px 8px rgb(0 0 0 / 40%); transition: background-color .15s, border-radius .15s; }
.cb-promo-opt:hover { background-color: #fff; border-radius: 12%; }
.mini-board { width: 100%; max-width: 260px; pointer-events: none; }
.mini-board .cb { border-radius: 4px; }
.cb.locked { cursor: default; }
.flash-good .cb { animation: flashGood .6s; }
.flash-bad .cb { animation: flashBad .6s; }
@keyframes flashGood { 30% { box-shadow: 0 0 0 4px var(--good), var(--shadow); } }
@keyframes flashBad { 0%, 100% { transform: none; } 20% { transform: translateX(-5px); } 40% { transform: translateX(5px); } 60% { transform: translateX(-3px); } 80% { transform: translateX(3px); } }

/* ---------- lists ---------- */
.list { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.list-item { display: flex; align-items: center; gap: .75rem; padding: .7rem .9rem; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .title { font-weight: 650; }
.list-item .sub { font-size: .8rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item:hover { background: var(--surface-2); }
.chapter { margin: 1.5rem 0; }
.chapter-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: .6rem; }
.chapter-head p { margin: .2rem 0 0; color: var(--muted); font-size: .9rem; max-width: 70ch; }
.ideas { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.idea { display: flex; flex-direction: column; gap: .6rem; }
.idea .mini-board { max-width: none; }
.idea p { font-size: .88rem; color: var(--ink-soft); margin: 0; }

/* study plan */
.plan { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.plan .card h3 { display: flex; justify-content: space-between; align-items: center; }
.plan ul { list-style: none; padding: 0; margin: .6rem 0 0; display: flex; flex-direction: column; gap: .35rem; }
.plan li { display: flex; align-items: flex-start; gap: .5rem; font-size: .88rem; }
.plan li .tick { width: 1.1rem; height: 1.1rem; border-radius: 50%; border: 1.5px solid var(--line-strong); flex: none; margin-top: .15rem; display: grid; place-items: center; }
.plan li.done .tick { background: var(--good); border-color: var(--good); color: #fff; }
.plan li.done a { color: var(--muted); text-decoration: line-through; }

/* forms */
.form-row { display: flex; flex-direction: column; gap: .35rem; margin-bottom: .9rem; }
.form-row label, .label { font-size: .78rem; font-weight: 750; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
select, input[type="text"], input[type="number"], textarea {
  font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong); border-radius: .6rem; padding: .5rem .65rem; width: 100%;
}
textarea { min-height: 7rem; font-family: var(--mono); font-size: .85rem; }
input[type="range"] { width: 100%; accent-color: var(--accent); }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: .65rem; overflow: hidden; }
.seg button { border: 0; background: var(--surface); color: var(--ink-soft); padding: .45rem .8rem; font: inherit; font-weight: 650; font-size: .85rem; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line-strong); }
.seg button[aria-pressed="true"] { background: var(--accent); color: #fff; }
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .55rem 0; border-bottom: 1px solid var(--line); }
.toggle:last-child { border-bottom: 0; }
.toggle input { width: 1.1rem; height: 1.1rem; accent-color: var(--accent); }
.swatches { display: flex; gap: .5rem; flex-wrap: wrap; }
.swatch { width: 54px; height: 54px; border-radius: .6rem; border: 2px solid transparent; cursor: pointer; display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; overflow: hidden; padding: 0; }
.swatch[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* toasts & modal */
.toasts { position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: .5rem; align-items: center; }
.toast { background: var(--ink); color: var(--paper); padding: .6rem 1rem; border-radius: .7rem; box-shadow: var(--shadow-lg); font-weight: 600; font-size: .9rem; transition: opacity .3s, transform .3s; }
.toast.out { opacity: 0; transform: translateY(8px); }
.toast-good { background: var(--good); color: #fff; } .toast-bad { background: var(--bad); color: #fff; }
.modal-wrap { position: fixed; inset: 0; z-index: 150; background: rgb(10 10 25 / 50%); display: grid; place-items: center; padding: 1rem; animation: fadeIn .15s; }
.modal { background: var(--surface); border-radius: var(--radius-lg); padding: 1.4rem; max-width: 520px; width: 100%; box-shadow: var(--shadow-lg); max-height: 90vh; overflow: auto; }
.modal-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1.2rem; flex-wrap: wrap; }
@keyframes fadeIn { from { opacity: 0; } }

/* stats */
.kpis { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .85rem 1rem; }
.kpi b { display: block; font-size: 1.5rem; font-weight: 800; letter-spacing: -.02em; }
.kpi span { font-size: .75rem; color: var(--muted); font-weight: 650; text-transform: uppercase; letter-spacing: .05em; }
.review-summary { display: grid; grid-template-columns: 1fr auto auto; gap: .25rem .75rem; font-size: .85rem; align-items: center; }
.review-summary .k { justify-self: start; }
.acc { display: flex; gap: 1rem; }
.acc div { flex: 1; text-align: center; padding: .6rem; border-radius: .6rem; background: var(--surface-2); }
.acc b { display: block; font-size: 1.4rem; }
.graph { width: 100%; height: 90px; display: block; cursor: pointer; border-radius: .5rem; background: var(--surface-2); }
.typed-move { display: flex; gap: .4rem; }
.typed-move input { font-family: var(--mono); }
.kbd { font-family: var(--mono); font-size: .75rem; padding: .05rem .35rem; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: .3rem; background: var(--surface-2); }
.empty { text-align: center; padding: 2.5rem 1rem; color: var(--muted); }
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin-bottom: .25rem; overflow-x: auto; overflow-y: hidden; flex: none; scrollbar-width: none; }
.tabs button { border: 0; background: none; padding: .6rem .9rem; font: inherit; font-weight: 650; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button[aria-selected="true"] { color: var(--accent-dark); border-bottom-color: var(--accent); }

.reduce-motion *, .reduce-motion *::before, .reduce-motion *::after { animation: none !important; transition: none !important; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
@media (max-width: 640px) {
  .page { padding: 1rem .75rem 3rem; }
  .brand span { display: none; }
  .topbar { gap: .5rem; padding: .5rem .6rem; }
  .nav a span { display: none; }
  .nav a { padding: .5rem .55rem; }
  .hero { padding: 1.2rem 1.1rem; }
}
