/* ───────── Tokens ───────── */
:root {
  color-scheme: dark;
  --bg: #11141b;
  --surface-1: #191d26;
  --surface-2: #222733;
  --surface-3: #2c3240;
  --line: #343b4a;
  --text: #eef0f4;
  --text-2: #b8bdc9;
  --text-3: #868c9a;
  --accent: #e2a54a;
  --accent-ink: #1e1406;
  --focus: #f1c27d;

  /* win / draw / loss — diverging blue ↔ red, gray midpoint */
  --win: #3987e5;
  --draw: #6b6a64;
  --loss: #e66767;

  /* categorical series (rapid / blitz / bullet) */
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;

  /* move classifications */
  --c-brilliant: #22c3d6;
  --c-great: #7b8cff;
  --c-best: #3fbf8a;
  --c-excellent: #6cc7a1;
  --c-good: #96b9ab;
  --c-book: #b99a74;
  --c-forced: #8f97a6;
  --c-inaccuracy: #e9c14b;
  --c-mistake: #f08c3c;
  --c-miss: #f2706b;
  --c-blunder: #dd3a48;

  /* board */
  --sq-light: #e9e2d0;
  --sq-dark: #557481;
  --sq-hl: rgba(232, 172, 72, .5);
  --sq-sel: rgba(30, 50, 80, .45);

  --radius: 12px;
  --radius-sm: 8px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", monospace;
  --nav-w: 216px;
  --tab-h: 62px;
}
:root[data-board="graphite"] { --sq-light: #dadbd6; --sq-dark: #7a7f89; }
:root[data-board="plum"] { --sq-light: #ece3e6; --sq-dark: #87697f; }

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --bg: #f4f3ef; --surface-1: #ffffff; --surface-2: #eeece6; --surface-3: #e2dfd7;
    --line: #d9d5cb; --text: #171a20; --text-2: #4a4f5a; --text-3: #737885;
    --accent: #94600f; --accent-ink: #ffffff; --focus: #6f480b;
    --win: #2a78d6; --draw: #a3a19a; --loss: #e34948;
    --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a;
  }
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f3ef; --surface-1: #ffffff; --surface-2: #eeece6; --surface-3: #e2dfd7;
  --line: #d9d5cb; --text: #171a20; --text-2: #4a4f5a; --text-3: #737885;
  --accent: #94600f; --accent-ink: #ffffff; --focus: #6f480b;
  --win: #2a78d6; --draw: #a3a19a; --loss: #e34948;
  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a;
}

/* ───────── Base ───────── */
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text); font: 15px/1.45 var(--font);
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 24px; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 17px; font-weight: 600; }
h3 { font-size: 14px; font-weight: 600; color: var(--text-2); text-transform: uppercase; letter-spacing: .06em; }
.muted { color: var(--text-3); }
.mono { font-family: var(--mono); font-size: .92em; }
.num { font-variant-numeric: tabular-nums; }

/* ───────── Shell ───────── */
.shell { display: grid; grid-template-columns: var(--nav-w) 1fr; min-height: 100%; }
.sidenav {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 6px;
  padding: 18px 12px; background: var(--surface-1); border-right: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; font-weight: 700; font-size: 17px; }
.brand img { width: 34px; height: 34px; }
.brand small { display: block; font-weight: 500; font-size: 11px; color: var(--text-3); letter-spacing: .08em; text-transform: uppercase; }
.navlinks { display: flex; flex-direction: column; gap: 2px; }
.navlinks a, .tabbar a {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--text-2); font-weight: 500;
}
.navlinks a:hover { background: var(--surface-2); color: var(--text); }
.navlinks a.active { background: var(--surface-3); color: var(--text); }
.navlinks svg, .tabbar svg { width: 20px; height: 20px; flex: none; }
.sync { margin-top: auto; font-size: 12px; color: var(--text-3); padding: 8px; }
.sync button { margin-top: 6px; width: 100%; }
main { min-width: 0; padding: 24px 28px 48px; outline: none; }
.tabbar { display: none; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidenav { display: none; }
  main { padding: 14px 16px calc(var(--tab-h) + 24px + env(safe-area-inset-bottom)); }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    height: calc(var(--tab-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: color-mix(in srgb, var(--surface-1) 92%, transparent); backdrop-filter: blur(12px);
    border-top: 1px solid var(--line);
  }
  .tabbar a { flex-direction: column; gap: 3px; justify-content: center; padding: 6px 0; font-size: 11px; border-radius: 0; }
  .tabbar a.active { color: var(--accent); }
  h1 { font-size: 21px; }
}

/* ───────── Components ───────── */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--text-3); }
.card { background: var(--surface-1); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; min-width: 0; }
.card > h3 { margin-bottom: 12px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 700px) { .g2, .g3 { grid-template-columns: 1fr; } .g4 { gap: 10px; } }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.compare-filters .field { flex: 1 1 155px; min-width: 0; }
.compare-filters input, .compare-filters select { width: 100%; min-width: 0; }
.compare-filters [hidden] { display: none; }
.compare-target { padding: 14px 0; border-bottom: 1px solid var(--line); }
.compare-target:last-child { border-bottom: 0; }
.compare-coverage { margin-top: 12px; }
.compare-notes p { margin: 0 0 4px; }
.compare-notes p:empty { display: none; }
.compare-picks-box { gap: 8px; }
.compare-picks { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.compare-picks > .muted:first-child { flex: 0 0 auto; min-width: 150px; font-size: 13px; }
.compare-pick .muted { font-weight: 400; }
.compare-filters .compare-players-field { flex-basis: 240px; }
@media (max-width: 600px) { .compare-picks > .muted:first-child { flex-basis: 100%; } }
.spacer { flex: 1; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 38px; padding: 0 14px;
  border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface-2); cursor: pointer;
  font-weight: 600; font-size: 14px; white-space: nowrap;
}
.btn:hover { background: var(--surface-3); }
.btn.primary { background: var(--accent); border-color: transparent; color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.sm { min-height: 30px; padding: 0 10px; font-size: 13px; }
.btn[disabled] { opacity: .5; cursor: default; }
.btn svg { width: 18px; height: 18px; }
.iconbtn { width: 44px; padding: 0; }

.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 6px; cursor: pointer; font-weight: 500; font-size: 13px; color: var(--text-2); }
.seg button.on { background: var(--surface-3); color: var(--text); }

.input, select.input { min-height: 38px; padding: 0 12px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface-2); min-width: 0; }
label.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-2); font-weight: 500; }

.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--surface-3); color: var(--text-2); white-space: nowrap; }
.pill.win { color: var(--win); } .pill.loss { color: var(--loss); } .pill.draw { color: var(--text-2); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }

.stat { display: flex; flex-direction: column; gap: 2px; }
.stat .v { font-size: 28px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat .l { font-size: 13px; color: var(--text-3); }
.stat .d { font-size: 13px; font-weight: 600; }
.up { color: var(--c-best); } .down { color: var(--loss); }

.list { display: flex; flex-direction: column; }
.list > * { border-top: 1px solid var(--line); }
.list > *:first-child { border-top: 0; }
.gamerow { display: grid; grid-template-columns: 34px 1fr auto; gap: 12px; align-items: center; padding: 11px 4px; }
.gamerow:hover { background: var(--surface-2); }
.gamerow .res { width: 34px; height: 34px; border-radius: 8px; display: grid; place-items: center; font-weight: 700; font-size: 13px; background: var(--surface-3); }
.gamerow .res.win { color: var(--win); } .gamerow .res.loss { color: var(--loss); } .gamerow .res.draw { color: var(--text-2); }
.gamerow .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gamerow .s { font-size: 13px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gamerow .acts { display: flex; gap: 6px; align-items: center; }
@media (max-width: 560px) {
  .gamerow { grid-template-columns: 34px minmax(0, 1fr); gap: 6px 12px; }
  .gamerow .acts { grid-column: 2; flex-wrap: wrap; }
  .gamerow .hide-sm { display: none; }
}

.insight { display: grid; grid-template-columns: 30px 1fr; gap: 12px; padding: 12px 2px; }
.insight .ic { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: var(--surface-3); }
.insight .ic svg { width: 17px; height: 17px; }
.insight b { display: block; }
.insight span { color: var(--text-3); font-size: 13px; }

.wdl { display: flex; height: 8px; border-radius: 4px; overflow: hidden; gap: 2px; min-width: 60px; }
.wdl i { display: block; height: 100%; }
.wdl i:first-child { border-radius: 4px 0 0 4px; } .wdl i:last-child { border-radius: 0 4px 4px 0; }

.progress { height: 6px; background: var(--surface-3); border-radius: 3px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--accent); transition: width .2s; }

.loading-state { display: flex; align-items: center; justify-content: center; gap: 11px; min-height: 92px; padding: 22px; color: var(--text-3); font-size: 14px; }
.loading-state.compact { min-height: 0; padding: 8px 0; justify-content: flex-start; font-size: 12px; }
.spinner { display: inline-block; width: 22px; height: 22px; flex: none; border: 3px solid var(--surface-3); border-top-color: var(--accent); border-radius: 50%; animation: spinner-turn .7s linear infinite; }
.loading-state.compact .spinner { width: 16px; height: 16px; border-width: 2px; }
@keyframes spinner-turn { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 1.8s; } }

.empty { text-align: center; padding: 40px 16px; color: var(--text-3); }
.empty b { display: block; color: var(--text); font-size: 16px; margin-bottom: 6px; }

table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font-weight: 500; color: var(--text-3); font-size: 12px; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 8px; border-bottom: 1px solid var(--line); }
.tbl tr.click { cursor: pointer; } .tbl tr.click:hover td { background: var(--surface-2); }
.tbl .r { text-align: right; }
.scroll-x { overflow-x: auto; }

#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); opacity: 0; pointer-events: none;
  background: var(--surface-3); border: 1px solid var(--line); padding: 10px 16px; border-radius: 10px; font-weight: 500; transition: .2s; z-index: 50; max-width: calc(100% - 32px); }
#toast.on { opacity: 1; transform: translateX(-50%); }
@media (max-width: 860px) { #toast { bottom: calc(var(--tab-h) + 16px); } }

/* ───────── Classification icons ───────── */
.cls { width: 20px; height: 20px; border-radius: 50%; display: inline-grid; place-items: center; font: 800 11px/1 var(--font); color: #fff; flex: none; letter-spacing: -.04em; }
.cls svg { width: 13px; height: 13px; }
.cls.brilliant { background: var(--c-brilliant); } .cls.great { background: var(--c-great); } .cls.best { background: var(--c-best); }
.cls.excellent { background: var(--c-excellent); } .cls.good { background: var(--c-good); } .cls.book { background: var(--c-book); }
.cls.forced { background: var(--c-forced); } .cls.inaccuracy { background: var(--c-inaccuracy); color: #2a2100; } .cls.mistake { background: var(--c-mistake); }
.cls.miss { background: var(--c-miss); } .cls.blunder { background: var(--c-blunder); }
.t-brilliant { color: var(--c-brilliant); } .t-great { color: var(--c-great); } .t-best { color: var(--c-best); } .t-excellent { color: var(--c-excellent); }
.t-good { color: var(--c-good); } .t-book { color: var(--c-book); } .t-forced { color: var(--c-forced); } .t-inaccuracy { color: var(--c-inaccuracy); }
.t-mistake { color: var(--c-mistake); } .t-miss { color: var(--c-miss); } .t-blunder { color: var(--c-blunder); }

/* ───────── Board ───────── */
.board-wrap { position: relative; width: 100%; aspect-ratio: 1; user-select: none; -webkit-user-select: none; touch-action: none; }
.board { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(8, 1fr); border-radius: 6px; overflow: hidden; container-type: inline-size; }
.sq { position: relative; display: grid; place-items: center; }
.sq.l { background: var(--sq-light); } .sq.d { background: var(--sq-dark); }
.sq.hl::before, .sq.sel::before { content: ""; position: absolute; inset: 0; background: var(--sq-hl); }
.sq.sel::before { background: var(--sq-sel); }
.sq.hint::before { content: ""; position: absolute; inset: 0; box-shadow: inset 0 0 0 4px var(--c-great); }
.sq.target::after { content: ""; position: absolute; width: 30%; height: 30%; border-radius: 50%; background: rgba(0,0,0,.18); }
.sq.target.cap::after { width: 86%; height: 86%; background: transparent; border: 5px solid rgba(0,0,0,.18); box-sizing: border-box; }
.sq .coord { position: absolute; font-size: max(9px, 2.4cqw); font-weight: 700; line-height: 1; pointer-events: none; }
.sq .coord.f { right: 4%; bottom: 3%; } .sq .coord.r { left: 4%; top: 4%; }
.sq.l .coord { color: var(--sq-dark); } .sq.d .coord { color: var(--sq-light); }
.pc {
  position: relative; z-index: 2; font-size: 10.2cqw; line-height: 1; cursor: default; pointer-events: none;
  font-family: "Apple Symbols", "Segoe UI Symbol", "Noto Sans Symbols 2", "DejaVu Sans", serif; transform: translateY(1%);
}
.pc.w { color: #fff; text-shadow: 0 0 1px #000, 0 0 1px #000, 0 1px 1px #000, 1px 0 1px #000, -1px 0 1px #000, 0 -1px 1px #000; }
.pc.b { color: #262421; text-shadow: 0 0 1px rgba(255,255,255,.35); }
.board.interactive .pc.mine { pointer-events: auto; cursor: grab; }
.pc.dragging { opacity: .25; }
.drag-ghost { position: fixed; z-index: 100; pointer-events: none; transform: translate(-50%, -55%); line-height: 1; }
.badge { position: absolute; top: -7%; right: -7%; z-index: 4; width: 42%; height: 42%; max-width: 30px; max-height: 30px; border-radius: 50%; display: grid; place-items: center;
  font: 800 max(10px, 2.2cqw)/1 var(--font); color: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.4); }
.arrows { position: absolute; inset: 0; pointer-events: none; z-index: 3; }

/* eval bar */
.evalbar { position: relative; background: #403d39; border-radius: 4px; overflow: hidden; }
.evalbar i { position: absolute; background: #f4f2ec; transition: .35s ease; }
.evalbar span { position: absolute; font: 700 10px/1 var(--font); z-index: 1; }
.evalbar.v { width: 22px; } .evalbar.v i { left: 0; right: 0; bottom: 0; }
.evalbar.v span { left: 0; right: 0; text-align: center; }
.evalbar.h { height: 12px; } .evalbar.h i { top: 0; bottom: 0; left: 0; } .evalbar.h span { top: 1px; }
.evalbar.hidden-eval { background: repeating-linear-gradient(135deg, var(--surface-3) 0 6px, var(--surface-2) 6px 12px); }
.evalbar.hidden-eval i, .evalbar.hidden-eval span { display: none; }

/* ───────── Review layout ───────── */
.review { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 20px; align-items: start; }
.review-board { display: grid; grid-template-columns: 22px minmax(0, 1fr); grid-template-areas: ". ptop" "evv board" ". pbot" ". ctl"; column-gap: 8px; max-width: min(100%, calc(100vh - 150px)); }
.review-board .ptop { grid-area: ptop; } .review-board .pbot { grid-area: pbot; } .review-board .ctl { grid-area: ctl; }
.review-board .evalbar.v { grid-area: evv; } .review-board .boardel { grid-area: board; } .review-board .evalbar.h { grid-area: evh; display: none; }
.player { display: flex; align-items: center; gap: 10px; padding: 6px 2px; font-weight: 600; }
.player .clock { margin-left: auto; font-family: var(--mono); font-size: 13px; background: var(--surface-2); padding: 3px 8px; border-radius: 6px; color: var(--text-2); }
.player .elo { color: var(--text-3); font-weight: 500; }
.player .sw { width: 14px; height: 14px; border-radius: 3px; border: 1px solid var(--line); }
.ctl { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-top: 6px; }
.ctl .btn { min-height: 44px; }
.panel { position: sticky; top: 16px; display: flex; flex-direction: column; gap: 12px; max-height: calc(100vh - 32px); }
.panel .card { padding: 14px; }
.moves { overflow-y: auto; max-height: 300px; font-size: 14px; display: grid; grid-template-columns: 36px 1fr 1fr; align-content: start; }
.moves .n { color: var(--text-3); padding: 5px 0; font-size: 13px; }
.moves button { display: flex; align-items: center; gap: 6px; text-align: left; border: 0; background: transparent; padding: 5px 8px; border-radius: 6px; cursor: pointer; font-weight: 500; }
.moves button:hover { background: var(--surface-2); }
.moves button.cur { background: var(--surface-3); }
.moves button .cls { width: 16px; height: 16px; font-size: 9px; }
.moves button .cls svg { width: 10px; height: 10px; }
.coach { display: flex; flex-direction: column; gap: 10px; }
.coach .hd { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 16px; }
.coach .hd .cls { width: 26px; height: 26px; font-size: 12px; }
.coach p { margin: 0; color: var(--text-2); font-size: 14px; }
.coach .ev { margin-left: auto; font-family: var(--mono); font-size: 13px; background: var(--surface-3); padding: 2px 8px; border-radius: 6px; }
.graph { width: 100%; height: 90px; display: block; cursor: pointer; border-radius: 6px; }
.clsgrid { display: grid; grid-template-columns: 1fr auto 1fr; gap: 6px 12px; align-items: center; font-size: 14px; }
.clsgrid .c { display: flex; align-items: center; gap: 8px; justify-content: center; font-weight: 500; color: var(--text-2); }
.clsgrid .v { text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }
.acc { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.acc > div { background: var(--surface-2); border-radius: 10px; padding: 12px; text-align: center; }
.acc b { display: block; font-size: 26px; font-variant-numeric: tabular-nums; }
.acc span { font-size: 12px; color: var(--text-3); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: -4px -4px 10px; }
.tabs button { border: 0; background: transparent; padding: 8px 10px; cursor: pointer; font-weight: 600; color: var(--text-3); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button.on { color: var(--text); border-bottom-color: var(--accent); }
.keymoment { display: flex; align-items: center; gap: 10px; padding: 8px 6px; border-radius: 8px; cursor: pointer; }
.keymoment:hover { background: var(--surface-2); }

@media (max-width: 1100px) { .review { grid-template-columns: minmax(0, 1fr) 300px; } }
@media (max-width: 860px) {
  .review { grid-template-columns: 1fr; }
  .review-board { max-width: none; width: 100%; }
  .panel { position: static; max-height: none; }
  .moves { max-height: 220px; }
}
@media (max-width: 860px) {
  .review-board { grid-template-columns: minmax(0, 1fr); grid-template-areas: "ptop" "evh" "board" "pbot" "ctl"; }
  .review-board .evalbar.v { display: none; }
  .review-board .evalbar.h { display: block; margin-bottom: 6px; }
  .ctl { position: sticky; bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 6px); z-index: 5; background: var(--bg); padding: 6px 0; }
}

/* ───────── Learn mode ───────── */
.prompt { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; background: var(--surface-1); display: flex; flex-direction: column; gap: 12px; }
.prompt.focus { border-color: var(--c-great); box-shadow: 0 0 0 3px color-mix(in srgb, var(--c-great) 25%, transparent); }
.prompt.good { border-color: var(--c-best); }
.prompt.bad { border-color: var(--c-mistake); }
.prompt .kicker { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--c-great); display: flex; align-items: center; gap: 8px; }
.prompt .big { font-size: 19px; font-weight: 700; }
.tactic-trainer { display:grid; grid-template-columns:minmax(0,min(54%,calc(100dvh - 270px))) minmax(0,1fr); gap:24px; align-items:start; }
.tactic-board-column { min-width:0; position:sticky; top:16px; }
.tactic-board-stage { position:relative; }
.tactic-loading { position:absolute; inset:0; display:flex; align-items:center; justify-content:center; background:var(--surface-1); border:1px solid var(--line); border-radius:var(--radius); }
.tactic-loading[hidden] { display:none; }
.tactic-source { display:flex; flex-direction:column; gap:4px; color:var(--text-3); font-size:12px; padding-top:6px; }
.tactic-panel { display:flex; flex-direction:column; gap:12px; min-width:0; min-height:0; max-height:calc(100dvh - 124px); overflow-y:auto; overscroll-behavior:contain; scrollbar-gutter:stable; padding-right:8px; }
.tactic-side { display:flex; align-items:center; gap:8px; font-size:12px; letter-spacing:.05em; text-transform:uppercase; font-weight:700; color:var(--text-2); }
.tactic-title { font-size:24px; line-height:1.15; margin:6px 0 8px; }
.tactic-message p { color:var(--text-2); margin:0; }
.tactic-options { border-top:1px solid var(--line); padding-top:8px; }
.tactic-option-fields { display:flex; flex-direction:column; gap:10px; padding-top:10px; }
.tactic-options .seg { width:100%; }
.tactic-options .seg button { flex:1; }
.tactic-method { font-size:13px; color:var(--text-2); }
.tactic-method ul { padding-left:20px; }
.tactic-buttons { display:grid; grid-template-columns:1fr 1fr; gap:8px; }
.tactic-buttons [hidden] { display:none; }
.tactic-wide { grid-column:1/-1; }
.tactic-guidance { font-size:13px; margin:4px 0 0; }
.tactic-next { width:100%; }
.tactic-result.card { padding:12px; }
.tactic-result h3, .tactic-result h4, .tactic-result p { margin:6px 0 8px; }
.tactic-result p { font-size:13px; }
.tactic-comparison { display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1fr); gap:6px; }
.tactic-comparison .btn { white-space:normal; }
#tactic-solved-summary .prompt { padding:8px; gap:4px; }
#tactic-solved-summary h3 { font-size:14px; text-transform:none; margin:0; }
#tactic-solved-summary p, #tactic-eval-caption { font-size:12px; margin:4px 0; }
@media(max-width:900px) {
  .tactic-trainer { grid-template-columns:1fr; gap:14px; }
  .tactic-board-column { position:static; max-width:100%; grid-row:2; }
  .tactic-panel { display:contents; }
  #tactic-task { grid-row:1; }
  #tactic-actions { grid-row:3; }
  #tactic-followup { grid-row:4; }
  #scout-status { grid-row:5; }
  .tactic-options { grid-row:6; }
}
.prompt p { margin: 0; color: var(--text-2); }
.pips { display: flex; gap: 6px; flex-wrap: wrap; }
.pips i { width: 22px; height: 6px; border-radius: 3px; background: var(--surface-3); }
.pips i.done { background: var(--c-best); } .pips i.part { background: var(--c-inaccuracy); } .pips i.fail { background: var(--c-mistake); } .pips i.cur { background: var(--c-great); }
.timer { font-family: var(--mono); font-size: 13px; color: var(--text-3); }

/* ───────── Charts ───────── */
.chart { width: 100%; display: block; overflow: visible; }
.chart .grid-l { stroke: var(--line); stroke-width: 1; }
.chart text { fill: var(--text-3); font-size: 11px; font-family: var(--font); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--text-2); margin-bottom: 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.progress-legend { gap: 4px 6px; }
.time-scrub { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 10px; margin: 0 0 10px; font-size: 13px; }
.time-scrub[hidden] { display: none; }
.time-scrub input[type="range"] { flex: 1 1 140px; min-width: 120px; accent-color: var(--accent); }
.time-scrub [data-scrub-play] { min-width: 62px; }
.time-scrub [data-scrub-label] { flex: 1 1 100%; }
.site-bar { margin-bottom: 12px; }
.site-bar[hidden] { display: none; }
.rating-site + .rating-site { margin-top: 14px; }
@media (max-width: 600px) { .site-bar .seg { display: flex; } .site-bar .seg button { flex: 1 1 auto; padding: 8px 6px; } }
.legend-toggle { display: inline-flex; align-items: center; gap: 6px; border: 1px solid transparent; background: transparent; color: inherit; font: inherit; padding: 4px 8px; border-radius: var(--radius-sm); cursor: pointer; }
.legend-toggle:hover { background: var(--surface-2); }
.legend-toggle[aria-pressed="false"] { color: var(--text-3); text-decoration: line-through; border-color: var(--line); }
.legend-toggle[aria-pressed="false"] .dot { opacity: .35; }
.tip { position: fixed; z-index: 60; pointer-events: none; background: var(--surface-3); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; font-size: 12px; box-shadow: 0 4px 16px rgba(0,0,0,.3); display: none; }
.hbar { display: grid; grid-template-columns: minmax(90px, 160px) 1fr 44px; gap: 10px; align-items: center; font-size: 13px; padding: 5px 0; }
.hbar .track { height: 10px; background: var(--surface-3); border-radius: 5px; overflow: hidden; }
.hbar .track i { display: block; height: 100%; border-radius: 5px; }
.insight-filters { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
.insight-filters label { display: grid; gap: 5px; color: var(--text-2); font-size: 12px; }
.insight-filters .input { width: 100%; min-width: 0; }
#body .hbar { grid-template-columns: minmax(110px, 170px) minmax(30px, 1fr) minmax(65px, auto); }
#body .keymoment { cursor: default; justify-content: space-between; flex-wrap: wrap; }
@media (max-width: 600px) { .insight-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.progress-controls { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: flex-end; margin-bottom: 12px; }
.progress-controls > .progress-metric-field { flex: 1 1 auto; display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-2); font-weight: 500; }
.progress-controls .seg { flex-wrap: wrap; }
.progress-chart + .progress-chart { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.progress-head { justify-content: space-between; align-items: baseline; gap: 4px 12px; flex-wrap: wrap; margin-bottom: 6px; }
.progress-head h4 { margin: 0; }
.progress-head .muted { font-size: 13px; }
.progress-method { font-size: 13px; margin: 10px 0 0; }
.progress-controls > label.field { min-width: 0; }
.progress-controls > label.field .input { width: 100%; }
@media (max-width: 600px) { .progress-controls > label.field { flex: 1 1 130px; } .progress-controls .seg { width: 100%; } .progress-controls .seg button { flex: 1 1 auto; padding: 6px 8px; } }

/* ───────── Openings ───────── */
.explorer { display: grid; grid-template-columns: minmax(260px, 440px) 1fr; gap: 20px; align-items: start; }
@media (max-width: 900px) { .explorer { grid-template-columns: 1fr; } }
.crumbs { display: flex; flex-wrap: wrap; gap: 4px; font-family: var(--mono); font-size: 13px; }
.crumbs button { border: 0; background: var(--surface-2); padding: 3px 7px; border-radius: 5px; cursor: pointer; }
.flag { border-left: 3px solid var(--loss); padding: 8px 12px; background: var(--surface-2); border-radius: 0 8px 8px 0; }
.flag.good { border-left-color: var(--win); }
.opening-filters { margin-bottom: 16px; align-items: end; }
.opening-filters label { display: grid; gap: 5px; color: var(--text-2); font-size: 12px; }
#opening-select { width: 100%; min-width: 0; text-overflow: ellipsis; }
.opening-habits { display: grid; gap: 8px; max-height: 620px; overflow-y: auto; }
.opening-habit { display: grid; gap: 5px; width: 100%; text-align: left; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-1); color: var(--text); cursor: pointer; }
.opening-habit span { font-size: 12px; color: var(--text-2); }
.opening-habit.selected { border-color: var(--accent); background: var(--surface-2); }
.opening-habit:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.opening-branches { display: flex; margin-top: 12px; }
.opening-branches button { flex: 1; white-space: normal; }
.opening-line { font-size: 13px; min-height: 40px; overflow-wrap: anywhere; }
.opening-study .card { min-width: 0; }
#study-board { scroll-margin-top: 16px; }
@media (max-width: 900px) { .opening-study > .card { order: -1; } .opening-habits { max-height: 240px; } }
@media (max-width: 600px) { .opening-filters label { flex: 1; min-width: 135px; } .opening-filters .input { width: 100%; } }

/* Rating tiles stay in one row on phones */
@media (max-width: 700px) {
  .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; gap: 8px !important; }
  .tiles .card { padding: 12px; }
  .tiles .stat .v { font-size: 22px; }
  .tiles svg { display: none; }
  .tiles .stat .d .muted { display: none; }
}
.coach .hd > svg, .prompt .kicker > svg { width: 20px; height: 20px; flex: none; }
.evalbar.h { box-shadow: inset 0 0 0 1px var(--line); }

/* Guided repertoire walkthrough */
.walk-heading { margin:24px 0 16px; }
.walk-attention { margin-bottom:18px; border-left:6px solid; }
.walk-attention[hidden] { display:none; }
.own-mistake { border-color:var(--c-mistake); }
.opponent-chance { border-color:var(--c-best); }
.walk-step-lesson.lesson-focus { border-left-width:6px; }
.walk-step-lesson h2 { margin-bottom:12px; }
.insight-quality { display:block; width:100%; padding:4px 0; border:0; background:transparent; color:inherit; cursor:pointer; text-align:left; }
.insight-quality:hover, .insight-quality:focus-visible { background:var(--surface-2); }
#insight-moves[hidden] { display:none; }
#saved-practice[hidden] { display:none; }
.lesson-current { font-size:16px; font-weight:500; }
.walk-layout { display:grid; grid-template-columns:minmax(300px,520px) minmax(280px,1fr); gap:20px; align-items:start; }
.walk-board-card { padding:12px; }
.walk-board-card .mono { line-height:1.9; font-size:13px; }
.walk-board-card .row { flex-wrap:wrap; }
.walk-coach { border-top:4px solid var(--accent,#66894b); }
.walk-coach p { line-height:1.75; }
.walk-coach .eyebrow { color:var(--muted); font-size:12px; text-transform:uppercase; letter-spacing:.06em; }
.walk-verdict { display:inline-block; font-size:12px; font-weight:600; padding:5px 9px; border-radius:20px; background:var(--bg); vertical-align:middle; }
.walk-verdict.fine { color:var(--c-best); }
.walk-verdict.inaccurate { color:var(--c-inaccuracy); }
.walk-verdict.mistake { color:var(--c-mistake); }
.walk-replies { display:flex; flex-wrap:wrap; gap:8px; margin-top:10px; }
.walk-replies .branch-option { display:flex; flex-direction:column; align-items:flex-start; gap:4px; text-align:left; white-space:normal; }
.branch-option span { font-size:12px; font-weight:400; color:var(--muted); }
.walk-alternative, .walk-demo { padding:12px; background:var(--bg); border-radius:8px; }
.walk-lesson-link { display:block; width:100%; padding:12px 0; text-align:left; background:none; border:0; border-bottom:1px solid var(--border); color:inherit; cursor:pointer; font:inherit; }
.walk-lesson-link:hover { color:var(--accent,#66894b); }
#walk-quiz[hidden] { display:none; }
@media(max-width:900px) { .walk-layout { grid-template-columns:1fr; } .walk-layout > .stack { min-width:0; } }

/* Practice results, manual continuations and shared position chat. */
.tactic-eval-layout{display:flex;gap:10px;align-items:stretch}.tactic-eval-layout #tactic-board{flex:1;min-width:0}.tactic-eval-layout .evalbar.v{position:relative;inset:auto;flex:0 0 26px;width:26px;height:auto;align-self:stretch}.tactic-eval-layout .evalbar[hidden]{display:none}
.coach-chat{border-top:1px solid var(--line);margin-top:16px;padding-top:14px}.coach-chat textarea{width:100%;resize:vertical}.coach-chat-message{padding:10px;border-radius:8px;margin:8px 0;background:var(--bg)}.coach-chat-message.user{border-left:3px solid var(--accent)}.coach-chat-message p{white-space:pre-wrap;overflow-wrap:anywhere;margin:4px 0}.coach-chat-messages{max-height:400px;overflow:auto}.coach-chat form{display:grid;gap:8px}.coach-chat form .btn{justify-self:start}
.training-comparison{margin-top:24px;overflow-x:auto}.training-comparison table{width:100%;border-collapse:collapse;font-size:14px}.training-comparison th,.training-comparison td{text-align:left;padding:10px 8px;border-bottom:1px solid var(--line)}.tactic-line-moves{flex-wrap:wrap}

/* Hidden action buttons must not be restored by .btn display rules. */
.btn[hidden] { display:none; }

/* ───────── Accounts ───────── */
.account-entry { max-width: 420px; margin: 48px auto; }
.account-entry h1 { margin: 4px 0 0; }
.account-entry .card { padding: 24px; }
.brand-mini { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.brand-mini img { width: 28px; height: 28px; }
.brand-mini small { color: var(--text-3); font-weight: 500; text-transform: uppercase; letter-spacing: .08em; font-size: 11px; }
.btn.social { width: 100%; min-height: 44px; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--text-3); font-size: 13px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.notice { border: 1px solid var(--line); border-left: 3px solid var(--c-great); background: var(--surface-2); border-radius: 0 8px 8px 0; padding: 10px 12px; font-size: 14px; margin-bottom: 12px; }
.notice code { font-family: var(--mono); font-size: 12px; }
@media (max-width: 560px) { .account-entry { margin: 16px auto; } }

/* ───────── Learn mode: score chart, legible badges, position viewer, free play, summary ───────── */
.learn-panel { overflow-y: auto; overscroll-behavior: contain; }
.learn-graph { margin: 4px 0 8px; }
.learn-graph .graph, .learn-summary-graph .graph { height: 64px; }
.learn-summary-graph .graph { height: 96px; }
.learn-score-chart { cursor: pointer; touch-action: manipulation; }
.learn-seq { display: flex; flex-direction: column; gap: 10px; }
.learn-seq .input { width: 100%; }
.learn-seq-status { font-size: 13px; flex: 1 1 140px; min-width: 0; }
.learn-graph-empty { font-size: 12px; color: var(--text-3); background: var(--surface-2); border-radius: 6px; padding: 10px; text-align: center; }
.learn-moves button:disabled { cursor: default; }
.learn-moves button:not(:disabled):hover { background: var(--surface-2); }
.learn-moves button.cur { background: var(--surface-3); box-shadow: inset 0 0 0 1px var(--line); }
.learn-moves button[class*="t-"] { color: color-mix(in srgb, currentColor 62%, var(--text)); }
/* Bigger, pill-shaped badges with dark ink so two-character glyphs like ?! stay readable. */
.learn-moves button .cls, .learn-summary .cls, .learn-explore .cls, .learn-view .cls {
  width: auto; min-width: 20px; height: 20px; padding: 0 4px; border-radius: 10px; font-size: 12px; font-weight: 800; letter-spacing: 0;
  color: #15140f; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .22);
}
.learn-moves button .cls.blunder, .learn-summary .cls.blunder, .learn-explore .cls.blunder, .learn-view .cls.blunder { color: #fff; }
.learn-moves button .cls svg { width: 12px; height: 12px; }
.learn-view .row, .learn-explore .row { gap: 6px; }
.learn-view .btn svg, .learn-explore .btn svg { width: 16px; height: 16px; }
.learn-view-move { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 0 0 10px; }
.learn-view { border-color: var(--c-great); }
.learn-toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; letter-spacing: 0; text-transform: none; color: var(--text-2); cursor: pointer; }
.learn-toggles { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.learn-toggle input { width: 16px; height: 16px; accent-color: var(--accent); }
.learn-explore-moves { display: flex; flex-wrap: wrap; gap: 6px; }
.learn-explore-moves button { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); border-radius: 6px; padding: 4px 8px; font: 600 13px/1.2 var(--font); cursor: pointer; }
.learn-explore-moves button.cur { border-color: var(--c-great); background: var(--surface-3); }
.learn-explore-moves .ev { font-family: var(--mono); font-size: 11px; color: var(--text-3); font-weight: 500; }
.learn-explore-moves .spinner { width: 12px; height: 12px; }
.learn-comment { border-left: 3px solid var(--accent); padding: 2px 0 2px 10px; }
.learn-comment p { margin: 0; }
.learn-notice { margin: 0; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.learn-summary { display: flex; flex-direction: column; gap: 10px; }
.learn-summary > h3 { margin: 0; }
.learn-summary h4 { margin: 4px 0 0; font-size: 13px; color: var(--text-2); }
.learn-legend { margin: 0; font-size: 12px; }
.learn-ring { width: 10px; height: 10px; border-radius: 50%; border: 2.5px solid var(--text-3); display: inline-block; }
.learn-tick { width: 0; height: 0; border-left: 5px solid transparent; border-right: 5px solid transparent; border-top: 8px solid var(--c-miss); display: inline-block; flex: none; }
.learn-acc-strip svg { width: 100%; height: 44px; display: block; background: var(--surface-2); border-radius: 6px; cursor: pointer; }
.learn-tactics .keymoment { color: inherit; }
.learn-pieces { margin: 0; font-size: 14px; color: var(--text-2); line-height: 1.6; }
.learn-summary .row .btn svg { width: 16px; height: 16px; }
@media (max-width: 860px) { .learn-panel { overflow: visible; } }
