/* ScoreChess — v0.2 styles (three-column workspace + interactive board)
   Theming knobs live in :root and are meant to be customized later. */

/* Urbanist — Bold (700) for titles/subtitles, Regular (400) for body text. */
@font-face {
  font-family: "Urbanist";
  src: url("../fonts/Urbanist/static/Urbanist-Regular.ttf") format("truetype");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Urbanist";
  src: url("../fonts/Urbanist/static/Urbanist-SemiBold.ttf") format("truetype");
  font-weight: 600; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Urbanist";
  src: url("../fonts/Urbanist/static/Urbanist-Bold.ttf") format("truetype");
  font-weight: 700; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Urbanist";
  src: url("../fonts/Urbanist/static/Urbanist-ExtraBold.ttf") format("truetype");
  font-weight: 800; font-style: normal; font-display: swap;
}

:root {
  --bg: #0d0c1c;
  --panel: #131128;
  --panel-2: #1a1836;
  --panel-3: #221f42;
  --text: #e7e9ee;
  --muted: #9aa3b2;
  --accent: #7a7aff;
  --accent-2: #a4acfd;
  --accent-dark: #4E36CC;
  --border: #2d2a55;
  --light-sq: #e9edf6;
  --dark-sq: #5484dd;
  --good: #66bd63;
  --bad: #d73027;
  --radius: 10px;
  --font: "Urbanist", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --focus-ring: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent);
}

* { box-sizing: border-box; }
/* The HTML `hidden` attribute must win over component `display` rules
   (e.g. .side-section/.config-block use display:flex). */
[hidden] { display: none !important; }

/* Inline SVG icon set — replaces the old emoji glyphs (docs/ux-ui-audit.md
   §7): inherits color via currentColor instead of rendering differently per
   OS/font. Sized to match the text it sits next to. */
svg.ico { width: 1em; height: 1em; flex: 0 0 auto; display: inline-block; vertical-align: -0.15em; }

/* One focus-visible ring, reused everywhere instead of the browser default
   outline (docs/ux-ui-audit.md §7 — no designed focus state existed before). */
button:focus-visible, select:focus-visible, textarea:focus-visible, input:focus-visible,
.side-btn:focus-visible, .seg-btn:focus-visible, .tab:focus-visible, .mode-btn:focus-visible,
.nav-btn:focus-visible, .cand-play:focus-visible, .opening-row:focus-visible,
.opening-family-header:focus-visible, .spot-row:focus-visible, .wiz-color-card:focus-visible,
.move-cell:focus-visible, .ghost-btn:focus-visible, .topbar-btn:focus-visible,
.actionbar-btn:focus-visible, a:focus-visible, [tabindex]:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}
.switch input:focus-visible + .slider { box-shadow: var(--focus-ring); }

/* Visually hidden but readable by screen readers (board move announcements). */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-weight: 400;
  line-height: 1.4;
}

/* ───────────────────── Workspace layout ───────────────────── */
.workspace {
  display: grid;
  grid-template-columns: 290px minmax(340px, 1fr) 430px;
  gap: 18px;
  padding: 18px;
  align-items: start;
}
@media (max-width: 1180px) {
  .workspace { grid-template-columns: 260px 1fr; }
  .panel { grid-column: 1 / -1; }
}

.mobile-topbar, .mobile-actionbar, .mobile-backdrop { display: none; }

/* ───────────────────── Sidebar ───────────────────── */
.sidebar {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  position: sticky;
  top: 18px;
}
.brand { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 9px;
  display: grid; place-items: center; font-size: 22px;
  background: linear-gradient(145deg, var(--accent), #4E36CC); color: #12102a;
}
.brand-mark-logo { width: 22px; height: 22px; display: block; }
.brand-name { font-weight: 700; font-size: 1.05rem; }
.brand-tag { color: var(--muted); font-size: 0.78rem; }

.side-actions { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.side-btn {
  display: flex; align-items: center; gap: 9px;
  width: 100%; text-align: left;
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 9px 11px; font-size: 0.9rem; cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.08s ease, filter 0.08s ease;
}
.side-btn:hover { border-color: var(--accent); }
/* Pressed state — applies to every .side-btn variant (.solid/.danger/etc.) via
   the cascade, so each variant's own color language darkens correctly without
   needing a per-variant override. */
.side-btn:active { transform: scale(0.97); filter: brightness(0.85); }
.side-btn .ico { width: 16px; text-align: center; color: var(--muted); }
.side-btn .key {
  margin-left: auto; font-size: 0.7rem; color: var(--muted);
  border: 1px solid var(--border); border-radius: 4px; padding: 0 5px;
}
.side-btn.solid { background: var(--accent); color: #12102a; font-weight: 600; border-color: var(--accent); justify-content: center; }
.side-btn.solid:hover { background: var(--accent-2); }
.side-btn.danger:hover { border-color: var(--bad); color: #ffb4ab; }
.btn-restart-global { color: #cd4b55; border-color: rgba(215, 48, 39, 0.30); }
.btn-restart-global .ico { color: inherit; }
.btn-restart-global:hover { background: rgba(215, 48, 39, 0.10); border-color: var(--bad); color: #ffb4ab; }

.side-section { display: flex; flex-direction: column; gap: 7px; margin-bottom: 14px; }
.side-section > label { font-size: 0.78rem; color: var(--muted); }
textarea, input[type="number"], select {
  width: 100%; background: var(--panel-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px; padding: 7px 9px;
  font-family: ui-monospace, Consolas, monospace; font-size: 0.84rem;
}
select { font-family: inherit; }

.side-status {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.82rem; color: var(--muted);
  border-top: 1px solid var(--border); padding-top: 12px;
}
.dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; }
.dot.on { background: var(--good); box-shadow: 0 0 8px var(--good); }
.dot.off { background: #6b7280; }
.engine-status-text { flex: 1 1 auto; min-width: 0; }
.restart-engine-btn {
  flex: 0 0 auto; width: 24px; height: 24px; display: grid; place-items: center;
  background: transparent; border: 1px solid var(--border); border-radius: 6px;
  color: var(--muted); font-size: 0.95rem; line-height: 1; cursor: pointer;
  transition: border-color 0.15s, color 0.15s, transform 0.4s, filter 0.08s ease;
}
.restart-engine-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--text); }
.restart-engine-btn:active:not(:disabled) { transform: scale(0.85); filter: brightness(0.8); }
.restart-engine-btn:disabled { opacity: 0.5; cursor: default; transform: rotate(300deg); }

/* Mode picker (left column) */
.mode-actions { display: flex; flex-direction: column; gap: 6px; }
.mode-btn {
  display: flex; align-items: center; gap: 9px; width: 100%; text-align: left;
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 12px; font-size: 0.92rem; font-family: inherit; cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s, transform 0.08s ease, filter 0.08s ease;
}
.mode-btn .ico { width: 18px; text-align: center; }
.mode-btn:hover { border-color: var(--accent); }
.mode-btn:active { transform: scale(0.97); filter: brightness(0.85); }
.mode-btn.active { background: var(--accent); color: #12102a; font-weight: 700; border-color: var(--accent); }

/* Mode-config blocks + generic field label spans */
.config-block {
  border: 1px solid var(--border); border-radius: 9px;
  background: var(--panel-2); padding: 11px;
}
.config-block > label { font-weight: 700; color: var(--text); }
.field-label { font-size: 0.86rem; color: var(--text); }
.side-subsection { display: flex; flex-direction: column; gap: 7px; margin-bottom: 12px; }
.side-subsection > label { font-size: 0.78rem; color: var(--muted); }

/* Collapsible "Game options" / "Analysis power" dropdowns */
.side-dropdown, .overlay-dropdown {
  border: 1px solid var(--border); border-radius: 9px;
  background: var(--panel-2); margin-bottom: 14px; overflow: hidden;
}
.overlay-dropdown { margin: 10px 0; }
.side-dropdown > summary, .overlay-dropdown > summary {
  cursor: pointer; list-style: none; user-select: none;
  display: flex; align-items: center; gap: 9px;
  padding: 10px 12px; font-size: 0.9rem; font-weight: 700; color: var(--text);
  transition: background 0.15s;
}
/* No hover/active existed on these <summary> triggers before — added for the
   same clicked-cue consistency as every other button in the app. */
.side-dropdown > summary:hover, .overlay-dropdown > summary:hover { background: rgba(127, 128, 250, 0.06); }
.side-dropdown > summary:active, .overlay-dropdown > summary:active { background: rgba(127, 128, 250, 0.16); }
.side-dropdown > summary::-webkit-details-marker,
.overlay-dropdown > summary::-webkit-details-marker { display: none; }
.side-dropdown > summary::after, .overlay-dropdown > summary::after {
  content: "▾"; margin-left: auto; color: var(--muted); transition: transform 0.2s;
}
.side-dropdown[open] > summary::after, .overlay-dropdown[open] > summary::after { transform: rotate(180deg); }
.side-dropdown > summary .ico, .overlay-dropdown > summary .ico { color: var(--muted); }
.dropdown-body { padding: 0 12px 12px; }
.overlay-dropdown .dropdown-body { padding: 4px 12px 12px; }
.dropdown-body .side-actions { margin-bottom: 12px; }
.dropdown-body .side-subsection:first-of-type { margin-top: 2px; }

/* ───────────────────── Board area ───────────────────── */
.board-area { display: flex; flex-direction: column; align-items: center; gap: 12px; }
/* align-items: flex-start (not stretch) — the eval bar's height is pinned in
   JS to #board's own box (see syncEvalbarHeight() in app.js), not to
   .board-col's full height (which also includes the captured-pieces strip
   below the board). Stretching here would make the track taller than the
   board and misalign its top/bottom. See docs/ux-ui-audit.md §7. */
.board-stage { display: flex; gap: 10px; align-items: flex-start; width: 100%; justify-content: center; }

.evalbar { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.evalbar-track {
  position: relative; width: 16px; flex: 1 1 auto;
  background: #1a1836; border: 1px solid var(--border); border-radius: 8px; overflow: hidden;
  min-height: 200px;
}
.evalbar-fill {
  position: absolute; bottom: 0; left: 0; right: 0; height: 50%;
  background: linear-gradient(180deg, #f3f4f0, #cfd2c4);
  transition: height 0.35s ease;
}
.evalbar-num { font-size: 0.72rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.evalbar-num.black-fav { color: #c9cdd6; }

.board-col {
  position: relative; /* anchors the "GO!" cue to exactly overlay #board below */
  display: flex; flex-direction: column; gap: 8px;
  width: min(62vh, 100%);
  max-width: 600px;
}
.board {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  border: 3px solid #3a4150;
  border-radius: 6px;
  overflow: hidden;
  container-type: size;
  user-select: none;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

/* Captured pieces / material balance strip, aligned with the board width.
   White's captures sit on the left, Black's on the right; each piece type is
   a tightly-overlapped stack, and the leading side's material score trails
   directly after its own pile (never centered). */
.captured-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  min-height: 26px;
}
.captured-block { display: flex; align-items: center; gap: 4px; min-width: 0; }
.captured-side { display: flex; align-items: center; gap: 6px; }
.captured-group { display: flex; }
.captured-piece { width: 22px; height: 22px; object-fit: contain; }
.captured-piece + .captured-piece { margin-left: -13px; }
.material-diff {
  font-weight: 700; font-size: 0.85rem; font-variant-numeric: tabular-nums;
  color: var(--text);
}
.squares-layer {
  position: absolute; inset: 0;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
}
.arrow-layer { position: absolute; inset: 0; pointer-events: none; }
.arrow-layer .arrow-group path {
  fill: rgba(255, 255, 255, 0.22);
  stroke: rgba(255, 255, 255, 0.5);
  stroke-width: 0.03;
  stroke-linejoin: round;
}
.arrow-layer .arrow-group.best path { fill: rgba(255, 255, 255, 0.28); }
.arrow-layer .arrow-group.hover path { fill: rgba(255, 255, 255, 0.18); }

.square { position: relative; display: flex; align-items: center; justify-content: center; }
.square.light { background: var(--light-sq); }
.square.dark { background: var(--dark-sq); }
.square.last-move::after {
  content: ""; position: absolute; inset: 0;
  background: rgba(246, 201, 69, 0.32);
}
.square.selected::after {
  content: ""; position: absolute; inset: 0;
  background: rgba(127, 128, 250, 0.34);
}
.square.keyboard-focus {
  outline: var(--focus-ring);
  outline-offset: -1px;
}
.square.in-check {
  box-shadow: inset 0 0 0 100vw rgba(210, 35, 20, 0.42),
              inset 0 0 22px 6px rgba(255, 60, 30, 0.55);
}

.piece {
  position: relative; z-index: 2;
  width: 94%; height: 94%;
  object-fit: contain;
  -webkit-user-drag: none; user-select: none;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.35));
}
.piece.movable { cursor: grab; }
.piece.movable:active { cursor: grabbing; }
.drag-ghost {
  position: absolute; z-index: 50; pointer-events: none;
  width: auto; height: auto;
  filter: drop-shadow(0 5px 7px rgba(0, 0, 0, 0.55));
}

.move-target {
  position: absolute; z-index: 1;
  width: 30%; height: 30%; border-radius: 50%;
  background: rgba(30, 30, 30, 0.32);
}
.move-target.capture {
  width: 86%; height: 86%; background: transparent;
  border: 0.9cqmin solid rgba(30, 30, 30, 0.32); border-radius: 50%;
}

.badge-board {
  position: absolute; top: 3%; right: 3%; z-index: 3;
  min-width: 4cqmin; padding: 0.4cqmin 1.1cqmin;
  font-size: 3.1cqmin; font-weight: 700; line-height: 1.25;
  border-radius: 999px; text-align: center;
  box-shadow: 0 1px 2px rgba(0,0,0,0.4);
}
.coord {
  position: absolute; z-index: 2; font-size: 2.3cqmin; font-weight: 700; opacity: 0.55; color: #2c3322;
}
.square.light .coord { color: #5484dd; }
.square.dark .coord { color: #e9edf6; }
.coord.rank { top: 2%; left: 4%; }
.coord.file { bottom: 1%; right: 5%; }

/* Promotion picker + overlay */
.board-overlay { position: absolute; inset: 0; z-index: 40; background: rgba(8, 10, 14, 0.45); }
.promo-menu {
  position: absolute; width: 12.5%;
  display: flex; flex-direction: column;
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 8px; box-shadow: 0 8px 22px rgba(0, 0, 0, 0.55); overflow: hidden;
}
.promo-opt {
  padding: 0; border: none; background: transparent; cursor: pointer;
  aspect-ratio: 1 / 1; display: grid; place-items: center;
  transition: background 0.15s, transform 0.08s ease;
}
.promo-opt:hover { background: rgba(127, 128, 250, 0.25); }
.promo-opt:active { background: rgba(127, 128, 250, 0.38); transform: scale(0.92); }
.promo-opt .piece { width: 86%; height: 86%; position: static; }

/* Board navigation */
.board-nav { display: flex; align-items: center; gap: 8px; }
.nav-btn {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--border);
  border-radius: 7px; padding: 5px 11px; font-size: 0.9rem; cursor: pointer;
  transition: border-color 0.15s, transform 0.08s ease, filter 0.08s ease;
}
.nav-btn:hover { border-color: var(--accent); }
.nav-btn:active { transform: scale(0.92); filter: brightness(0.85); }
.game-state { color: var(--text); font-size: 0.92rem; font-weight: 700; min-width: 130px; text-align: center; }

/* "Reveal best move" — board-anchored, outline "ghost" button (not a filled
   grey pill like other side buttons) so it reads as a distinct, momentary
   action rather than routine chrome. See docs/ux-ui-audit.md §5. Always
   rendered — dimmed/disabled rather than hidden, so it never shifts layout. */
.ghost-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; max-width: 320px; margin: 2px auto 0;
  background: transparent; color: var(--accent-2);
  border: 1.5px dashed var(--accent); border-radius: 999px;
  padding: 8px 16px; font-size: 0.88rem; font-weight: 600; font-family: inherit; cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.08s ease, filter 0.08s ease, opacity 0.15s;
}
.ghost-btn:hover:not(:disabled) { background: rgba(127, 128, 250, 0.12); }
.ghost-btn:active:not(:disabled) { transform: scale(0.97); filter: brightness(0.9); }
.ghost-btn:disabled, .ghost-btn.inactive {
  opacity: 0.4; border-style: solid; border-color: var(--border); color: var(--muted); cursor: default;
}

/* ───────────────────── Right panel ───────────────────── */
.panel { display: flex; flex-direction: column; gap: 16px; }
/* Top-level right-column tabs — "Game" (everything that lived here before)
   vs "Analysis" (Move analysis/Move history, promoted from the bottom of the
   column to one click away). Reuses the existing .seg segmented-control look
   rather than the .tabs-card underline style, since these sit directly in the
   panel (not inside a card). */
.panel-toplevel-tabs { margin-bottom: 2px; }
.panel-tab-body { display: flex; flex-direction: column; gap: 16px; }
.panel-card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 15px;
}
.card-title {
  font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.6px;
  color: var(--muted); margin-bottom: 10px; font-weight: 700;
}
.field-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 9px; }
.field-row label { font-size: 0.86rem; color: var(--text); }
.field-row input[type="number"], .field-row select { max-width: 160px; }
.field-row input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--accent); }

/* In-game controls (right column) */
.flip-btn { justify-content: center; margin-bottom: 10px; }
.toggle-row { margin-bottom: 4px; }
/* On/off toggle switch */
.switch { position: relative; display: inline-block; width: 42px; height: 23px; flex: 0 0 auto; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; inset: 0; cursor: pointer; border-radius: 999px;
  background: var(--panel-3); border: 1px solid var(--border); transition: background 0.18s;
}
.switch .slider::before {
  content: ""; position: absolute; height: 17px; width: 17px; left: 2px; top: 2px;
  border-radius: 50%; background: #9aa3b2; transition: transform 0.18s, background 0.18s;
}
.switch input:checked + .slider { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(19px); background: #12102a; }

button.primary {
  width: 100%; margin-top: 4px; background: var(--accent); border: 1px solid var(--accent);
  color: #12102a; font-weight: 600; font-size: 0.95rem; padding: 9px; border-radius: 7px; cursor: pointer;
  transition: background 0.15s, transform 0.08s ease, filter 0.08s ease;
}
button.primary:hover { background: var(--accent-2); }
button.primary:active:not(:disabled) { transform: scale(0.98); filter: brightness(0.88); }
button.primary:disabled { opacity: 0.6; cursor: progress; }

.status-line {
  margin-top: 10px; font-size: 0.85rem; color: var(--muted);
  border-left: 3px solid var(--border); padding-left: 9px;
}
.status-line.busy { border-left-color: var(--accent); color: var(--text); }
.status-line.ok { border-left-color: var(--good); color: var(--text); }
.status-line.warn { border-left-color: #fdae61; }
.status-line.error { border-left-color: var(--bad); color: #ffb4ab; }

/* Segmented controls (mode switch, color pickers) */
.seg { display: flex; gap: 4px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 9px; padding: 3px; }
.seg-btn {
  flex: 1; background: transparent; color: var(--muted); border: none; border-radius: 6px;
  padding: 7px 8px; font-size: 0.84rem; font-family: inherit; cursor: pointer;
  transition: background 0.15s, color 0.15s, transform 0.08s ease, filter 0.08s ease; white-space: nowrap;
}
.seg-btn:hover { color: var(--text); }
.seg-btn:active { transform: scale(0.95); filter: brightness(0.85); }
.seg-btn.active { background: var(--accent); color: #12102a; font-weight: 600; }
.seg-btn { position: relative; }
.ready-indicator {
  position: absolute; top: 2px; right: 2px;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 3px var(--accent);
}
.seg.small .seg-btn { padding: 5px 7px; font-size: 0.8rem; }
.mode-hint { margin-top: 9px; font-size: 0.8rem; color: var(--muted); }
.sub-note { font-size: 0.78rem; color: var(--muted); margin: 4px 0 8px; }
.pill {
  font-size: 0.8rem; font-weight: 700; color: var(--accent-2);
  background: rgba(127, 128, 250, 0.12); border: 1px solid var(--border);
  border-radius: 999px; padding: 2px 10px; font-variant-numeric: tabular-nums;
}
.seg-actions { display: flex; gap: 6px; margin-top: 4px; }
.seg-actions .primary { width: auto; flex: 1; margin-top: 0; }
.seg-actions .side-btn { width: auto; justify-content: center; flex: 0 0 auto; }

/* Range slider */
input[type="range"] {
  width: 100%; margin: 2px 0 0; accent-color: var(--accent);
  height: 6px; cursor: pointer;
}
input[type="range"]:disabled { opacity: 0.5; cursor: not-allowed; }

/* Elo strength sliders — Lila blue/purple gradient track (weak = light,
   strong = dark), thumb tinted to match its position on the gradient. */
input.elo-slider {
  -webkit-appearance: none;
  appearance: none;
  accent-color: unset;
  background: transparent;
  height: 8px;
}
input.elo-slider::-webkit-slider-runnable-track {
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent-2), var(--accent-dark));
}
input.elo-slider::-moz-range-track {
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent-2), var(--accent-dark));
}
input.elo-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  margin-top: -5px;
  border-radius: 50%;
  background: var(--thumb-color, var(--accent));
  border: 2px solid rgba(255, 255, 255, 0.85);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
  cursor: pointer;
}
input.elo-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--thumb-color, var(--accent));
  border: 2px solid rgba(255, 255, 255, 0.85);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
  cursor: pointer;
}
input.elo-slider:disabled { opacity: 0.5; cursor: not-allowed; }

/* Analysis power panel */
#power-preset { margin-bottom: 8px; }
.power-custom {
  margin: 4px 0 10px; padding: 10px; border: 1px solid var(--border);
  border-radius: 9px; background: var(--panel-2);
}
.power-custom .field-row { margin-bottom: 4px; }
.power-custom input[type="range"] { margin-bottom: 8px; }
.power-custom input[type="range"]:last-child { margin-bottom: 0; }
#power-threads-note { margin: 2px 0 0; }

/* Move-quality settings (thresholds + colors) */
.quality-colors {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px;
  margin: 4px 0 10px;
}
.qcolor-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.qcolor-row label { font-size: 0.82rem; color: var(--text); }
.qcolor-row input[type="color"] {
  width: 30px; height: 24px; padding: 0; border: 1px solid var(--border);
  border-radius: 6px; background: none; cursor: pointer;
}
.cand.detailed { border-color: rgba(127, 128, 250, 0.45); }

/* Opening trainer — collapsible picker toggle */
.train-details { width: 100%; }
.train-details > summary {
  cursor: pointer; list-style: none; user-select: none;
  display: flex; align-items: center; justify-content: space-between;
  font-size: 0.82rem; font-weight: 700; color: var(--muted);
  padding: 2px 0 8px; margin-bottom: 2px;
}
.train-details > summary::-webkit-details-marker { display: none; }
.train-details > summary::after {
  content: "▾"; font-size: 0.8rem; transition: transform 0.18s; color: var(--muted);
}
.train-details:not([open]) > summary::after { transform: rotate(-90deg); }
.train-details-body { display: flex; flex-direction: column; gap: 7px; }

/* Opening trainer — search + filter + results list */
.opening-search {
  width: 100%; font-family: inherit; font-size: 0.86rem;
}
.seg.filters { margin-bottom: 4px; }
.opening-list {
  max-height: 240px; overflow-y: auto;
  border: 1px solid var(--border); border-radius: 8px; background: var(--panel-2);
  display: flex; flex-direction: column;
}

/* Flat opening row (families with a single entry) */
.opening-row {
  display: flex; align-items: baseline; gap: 9px; width: 100%; text-align: left;
  background: transparent; border: none; border-bottom: 1px solid var(--border);
  color: var(--text); font-family: inherit; font-size: 0.84rem; padding: 7px 10px; cursor: pointer;
  transition: background 0.12s;
}
.opening-row:last-child { border-bottom: none; }
.opening-row:hover { background: rgba(127, 128, 250, 0.10); }
/* List rows get a background-only press cue (no scale) so they don't shift
   against their fixed-width neighbours in the scrollable list. */
.opening-row:active { background: rgba(127, 128, 250, 0.22); }
.opening-row.selected { background: var(--accent); color: #12102a; }
.opening-row.selected:active { filter: brightness(0.85); }
.opening-row.selected .op-eco { color: #12102a; }

/* Indented sub-rows inside a family group */
.opening-row.sub { padding-left: 22px; font-size: 0.82rem; }

/* Family group header */
.opening-group { border-bottom: 1px solid var(--border); }
.opening-group:last-child { border-bottom: none; }
.opening-family-header {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  background: var(--panel-3); border: none;
  color: var(--text); font-family: inherit; font-size: 0.84rem;
  font-weight: 600; padding: 7px 10px; cursor: pointer;
  transition: background 0.12s;
}
.opening-family-header:hover { background: rgba(127, 128, 250, 0.14); }
.opening-family-header:active { background: rgba(127, 128, 250, 0.26); }
.op-family-name { flex: 1; }
.op-fam-count {
  font-size: 0.72rem; color: var(--muted); font-variant-numeric: tabular-nums;
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 999px; padding: 0 7px;
}
.family-arrow { font-size: 0.8rem; color: var(--muted); flex: 0 0 auto; }
.opening-sub-list { display: flex; flex-direction: column; }

.op-eco {
  flex: 0 0 34px; font-family: ui-monospace, Consolas, monospace; font-size: 0.74rem;
  font-weight: 700; color: var(--muted);
}
.op-name { flex: 1; }
.opening-chosen {
  margin: 6px 0 4px; padding: 8px 10px; border-radius: 8px;
  background: rgba(127, 128, 250, 0.10); border: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 3px;
}
.opening-chosen .op-pgn {
  font-family: ui-monospace, Consolas, monospace; font-size: 0.74rem; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Opening trainer line display */
.train-line { margin: 10px 0 4px; }
.tl-name { font-size: 0.78rem; color: var(--muted); margin-bottom: 6px; }
.tl-moves { display: flex; flex-wrap: wrap; gap: 4px; }
.tl-move {
  font-size: 0.8rem; font-weight: 600; padding: 2px 7px; border-radius: 6px;
  background: var(--panel-2); border: 1px solid var(--border); color: var(--muted);
}
.tl-move.done { color: var(--text); border-color: var(--accent); }
.tl-move.current { background: var(--accent); color: #12102a; border-color: var(--accent); }

/* Puzzle trainer — info card */
.puzzle-info {
  margin: 10px 0 4px; padding: 9px 11px; border-radius: 8px;
  background: rgba(127, 128, 250, 0.10); border: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 7px;
}
.pz-head { display: flex; align-items: center; gap: 8px; }
.pz-rating {
  font-weight: 800; color: var(--accent-2); font-variant-numeric: tabular-nums;
  background: rgba(127, 128, 250, 0.14); border-radius: 999px; padding: 1px 10px;
}
.pz-turn { font-weight: 700; font-size: 0.88rem; }
.pz-prompt { font-size: 0.82rem; color: var(--muted); }
.pz-result { margin-left: auto; font-size: 0.78rem; font-weight: 700; padding: 2px 9px; border-radius: 999px; }
.pz-result.ok { background: rgba(102, 189, 99, 0.18); color: var(--good); }
.pz-result.bad { background: rgba(253, 174, 97, 0.16); color: #fdae61; }
.pz-themes { display: flex; flex-wrap: wrap; gap: 5px; }
.pz-theme {
  font-size: 0.74rem; font-weight: 600; color: var(--muted);
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 6px; padding: 2px 7px;
}
.pz-link { font-size: 0.78rem; color: var(--accent-2); text-decoration: none; }
.pz-link:hover { text-decoration: underline; }

/* Puzzle hint — ring the piece the solver should move. */
.square.hint { box-shadow: inset 0 0 0 0.6cqmin rgba(102, 189, 99, 0.9); }

/* Game-review accuracy summary */
.review-summary { display: flex; gap: 10px; margin-top: 12px; }
.acc-card {
  flex: 1; background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 9px; padding: 10px; text-align: center;
}
.acc-name { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); }
.acc-num { font-size: 1.5rem; font-weight: 800; color: var(--text); font-variant-numeric: tabular-nums; margin: 2px 0; }
.acc-break { font-size: 0.74rem; color: var(--muted); }

/* Review dots + quality labels in the move history */
.rev-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  margin-right: 6px; vertical-align: middle;
}
/* Move history scrolls inside its own box (keeps the page from jumping when a
   new move is added and the active row is scrolled into view). */
.history-scroll { max-height: 360px; overflow-y: auto; }
.mc-san { font-weight: 600; }
.qual-tag {
  display: block; margin-top: 2px; font-size: 0.71rem; font-weight: 700;
  letter-spacing: 0.2px; line-height: 1.3; white-space: nowrap;
}
.history-note { padding: 8px 4px 2px; font-size: 0.78rem; color: var(--muted); }

/* PGN-imported comments/variations, shown read-only below the move pair. */
.ann-marker { color: var(--accent-2); font-size: 0.7rem; margin-left: 3px; vertical-align: super; }
tr.ann-row td { background: var(--panel-2); padding: 6px 9px; }
.ann-block + .ann-block { margin-top: 6px; }
.ann-move { font-weight: 600; margin-right: 6px; }
.ann-comment { font-style: italic; color: var(--muted); }
.ann-variations { margin-top: 3px; font-size: 0.8rem; }
.ann-variations summary { cursor: pointer; color: var(--accent-2); }
.ann-variations summary:hover { color: var(--text); }
.ann-var-line { color: var(--muted); padding: 2px 0 2px 14px; font-variant-numeric: tabular-nums; }

/* Tabs */
.tabs-card { padding: 0; overflow: hidden; }
.tabs { display: flex; border-bottom: 1px solid var(--border); }
.tab {
  flex: 1; background: transparent; color: var(--muted); border: none;
  padding: 11px; font-size: 0.86rem; cursor: pointer; border-bottom: 2px solid transparent;
  transition: background 0.15s, color 0.15s;
}
/* No hover/active existed here before — added for consistency. */
.tab:hover { color: var(--text); background: rgba(127, 128, 250, 0.05); }
.tab:active { background: rgba(127, 128, 250, 0.14); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }
.tab-body { padding: 10px; }

/* Tables */
.table-wrap { max-height: 420px; overflow: auto; border-radius: 8px; }
table.results, table.history { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
table.results thead th, table.history thead th {
  position: sticky; top: 0; background: var(--panel-2); text-align: left;
  padding: 7px 9px; color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--border); white-space: nowrap;
}
table.results tbody td, table.history tbody td {
  padding: 6px 9px; border-bottom: 1px solid var(--border); vertical-align: middle;
}
table.results tbody tr { cursor: default; }
table.results tbody tr:hover { background: rgba(127, 128, 250, 0.10); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.move { font-weight: 600; white-space: nowrap; }
.move .uci { font-weight: 400; color: var(--muted); font-size: 0.74rem; font-family: ui-monospace, Consolas, monospace; margin-left: 3px; }
.eval { font-variant-numeric: tabular-nums; font-weight: 600; }
.empty { text-align: center; color: var(--muted); padding: 16px; }

/* Navigable move history */
table.history .move-cell { cursor: pointer; font-weight: 600; border-radius: 4px; transition: background 0.12s; }
table.history .move-cell:hover { background: rgba(127, 128, 250, 0.12); }
table.history .move-cell:active { background: rgba(127, 128, 250, 0.28); }
table.history .move-cell.active { background: var(--accent); color: #12102a; }
table.history .move-cell.active:active { filter: brightness(0.85); }
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 0.76rem; font-weight: 600; white-space: nowrap;
}
.pv-col { max-width: 130px; }
.pv {
  display: block; max-width: 130px;
  color: var(--muted); font-family: ui-monospace, Consolas, monospace; font-size: 0.74rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Candidate-move cards */
.cards { display: flex; flex-direction: column; gap: 7px; max-height: 460px; overflow: auto; }
.cand {
  display: grid; grid-template-columns: 20px 1fr auto; align-items: center; gap: 10px;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 9px; padding: 8px 10px;
}
.cand:hover { border-color: var(--accent); background: rgba(127, 128, 250, 0.07); }
.cand.best { border-color: rgba(102, 189, 99, 0.6); }
.cand-rank { color: var(--muted); font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }
.cand-main { min-width: 0; }
.cand-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.cand-move { font-weight: 700; font-size: 0.95rem; white-space: nowrap; }
.cand-move .uci {
  font-weight: 400; color: var(--muted); font-size: 0.72rem;
  font-family: ui-monospace, Consolas, monospace; margin-left: 4px;
}
.cand-eval { font-variant-numeric: tabular-nums; font-weight: 700; }
.cand-meta { display: flex; align-items: center; gap: 8px; margin-top: 5px; flex-wrap: wrap; }
.cand-loss { font-size: 0.77rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.cand-score {
  font-size: 0.75rem; font-weight: 700; color: var(--accent-2);
  background: rgba(127, 128, 250, 0.12); border-radius: 999px; padding: 1px 7px; font-variant-numeric: tabular-nums;
}
.cand-depth { font-size: 0.74rem; color: var(--muted); margin-left: auto; white-space: nowrap; }
.cand-pv {
  margin-top: 5px; color: var(--muted); font-family: ui-monospace, Consolas, monospace;
  font-size: 0.73rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cand-play {
  width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--panel-3); color: var(--accent-2); font-size: 0.82rem; cursor: pointer;
  display: grid; place-items: center;
  transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.08s ease;
}
.cand-play:hover { background: var(--accent); color: #12102a; border-color: var(--accent); }
.cand-play:active { transform: scale(0.88); filter: brightness(0.9); }
.cand-play:disabled { opacity: 0.5; cursor: not-allowed; }

/* Spotlights — key moments */
.spotlights { display: flex; flex-direction: column; gap: 6px; }
.spot-row {
  display: flex; align-items: center; gap: 9px; width: 100%; text-align: left;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px;
  padding: 7px 10px; color: var(--text); font-family: inherit; font-size: 0.84rem; cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.spot-row:hover { border-color: var(--accent); background: rgba(127, 128, 250, 0.08); }
.spot-row:active { background: rgba(127, 128, 250, 0.18); filter: brightness(0.95); }
.spot-dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; }
.spot-move { font-weight: 700; min-width: 78px; white-space: nowrap; }
.spot-cat { color: var(--muted); }
.spot-loss { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--muted); }

/* Legend */
.legend { margin-top: 10px; }
.legend summary { cursor: pointer; color: var(--muted); font-size: 0.83rem; transition: color 0.15s; }
.legend summary:hover { color: var(--text); }
.legend summary:active { color: var(--accent-2); }
.legend-body { display: flex; flex-wrap: wrap; gap: 8px 14px; margin-top: 10px; }
.legend-item { display: flex; align-items: center; gap: 7px; }
.legend-desc { color: var(--muted); font-size: 0.78rem; }

.app-footer {
  padding: 14px 20px 26px; color: var(--muted); font-size: 0.78rem;
  border-top: 1px solid var(--border); margin-top: 6px;
}

/* ─────────── Train openings — wizard modal ─────────── */
.wizard-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(8, 6, 20, 0.82);
  display: flex; align-items: center; justify-content: center;
}
.wizard-panel {
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
  width: min(540px, 94vw); max-height: 88vh;
  display: flex; flex-direction: column;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6);
  overflow: hidden;
}

/* Header */
.wizard-header {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 18px 14px; border-bottom: 1px solid var(--border); flex: 0 0 auto;
}
.wizard-title { font-weight: 800; font-size: 1rem; color: var(--text); white-space: nowrap; }
.wizard-breadcrumb { display: flex; align-items: center; gap: 6px; flex: 1; font-size: 0.8rem; }
.wiz-crumb { color: var(--muted); padding: 2px 9px; border-radius: 999px; white-space: nowrap; }
.wiz-crumb.active { color: var(--accent-2); background: rgba(127, 128, 250, 0.13); font-weight: 700; }
.wiz-crumb-sep { color: var(--border); font-size: 0.9rem; }
.wiz-close {
  background: transparent; border: 1px solid var(--border); border-radius: 7px;
  color: var(--muted); font-size: 0.82rem; cursor: pointer;
  width: 28px; height: 28px; display: grid; place-items: center; flex: 0 0 auto;
  transition: border-color 0.15s, color 0.15s, transform 0.08s ease;
}
.wiz-close:hover { border-color: var(--accent); color: var(--text); }
.wiz-close:active { transform: scale(0.88); filter: brightness(0.9); }

/* Body */
.wiz-body {
  flex: 1 1 auto; overflow-y: auto; padding: 16px 18px;
  display: flex; flex-direction: column; gap: 10px;
}
.wiz-list { max-height: 290px; }

/* Step 1 — opening preview */
.wiz-preview {
  padding: 11px 13px; border-radius: 9px;
  background: rgba(127, 128, 250, 0.08); border: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 5px; flex: 0 0 auto;
}
.wiz-preview-name { font-weight: 700; font-size: 0.9rem; color: var(--text); }
.wiz-preview-pgn {
  font-family: ui-monospace, Consolas, monospace; font-size: 0.8rem;
  color: var(--muted); line-height: 1.7; white-space: pre-wrap; word-break: break-word;
}

/* Step 2 — configuration */
.wiz-opening-label {
  font-weight: 700; font-size: 0.9rem; color: var(--text);
  padding: 9px 12px; background: rgba(127, 128, 250, 0.08);
  border: 1px solid var(--border); border-radius: 8px;
}
.wiz-section-label {
  font-size: 0.75rem; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.5px; margin-top: 4px;
}
.wiz-section-hint { text-transform: none; font-weight: 400; letter-spacing: 0; font-size: 0.74rem; }
.wiz-color-cards { display: flex; gap: 10px; }
.wiz-color-card {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 14px 10px; border-radius: 10px;
  background: var(--panel-2); border: 2px solid var(--border);
  color: var(--text); font-family: inherit; cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.08s ease;
}
.wiz-color-card:hover { border-color: var(--accent); }
.wiz-color-card:active { transform: scale(0.97); background: rgba(127, 128, 250, 0.18); }
.wiz-color-card.active { border-color: var(--accent); background: rgba(127, 128, 250, 0.12); }
.wiz-piece-icon { width: 2.1rem; height: 2.1rem; }
.wiz-color-name { font-weight: 700; font-size: 0.92rem; }
.wiz-color-sub { font-size: 0.74rem; color: var(--muted); }

/* Footer */
.wizard-footer {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 18px; border-top: 1px solid var(--border); flex: 0 0 auto;
}
.wiz-dots { display: flex; gap: 6px; flex: 1; justify-content: center; }
.wiz-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--border); transition: background 0.2s; }
.wiz-dot.active { background: var(--accent); }
.wiz-cta { width: auto; margin-top: 0; padding: 9px 22px; flex: 0 0 auto; }
.wiz-nav-btn { width: auto; flex: 0 0 auto; }

/* Sidebar — train drill summary (shown after wizard completes) */
.train-config-summary {
  padding: 9px 11px; border-radius: 8px;
  background: rgba(127, 128, 250, 0.08); border: 1px solid var(--border);
  margin-bottom: 4px;
}
.train-config-name { font-weight: 700; font-size: 0.88rem; color: var(--text); margin-bottom: 2px; }

/* Wrong-move shake (strict mode) */
@keyframes board-shake {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-7px); }
  40%       { transform: translateX(7px); }
  60%       { transform: translateX(-4px); }
  80%       { transform: translateX(4px); }
}
.board.shake { animation: board-shake 0.42s ease; }

/* ─────────── "GO!" launch cue + mode-switch toast ─────────── */
/* Centered over the BOARD (not the viewport) — a sibling of #board inside the
   now-relatively-positioned .board-col, sized to exactly match #board's own
   square box (top/left/width match, aspect-ratio 1/1 matches the height).
   Non-blocking flash that fires when a Play bot game or Train openings drill
   actually starts (see showGoCue() in app.js). Not used for Puzzles: loading a
   puzzle isn't a "launch" moment the same way a game/drill start is. */
.go-cue {
  position: absolute; top: 0; left: 0; width: 100%; aspect-ratio: 1 / 1;
  z-index: 50; display: grid; place-items: center; pointer-events: none;
  container-type: size; /* lets the "GO!" text size itself off the board's own box, not the viewport */
}
.go-cue span {
  font-weight: 800; font-size: 26cqmin;
  color: #fff;
  -webkit-text-stroke: 0.6cqmin #1a1a1a;
  paint-order: stroke fill; /* stroke drawn under the fill so it reads as a clean outline */
  filter: drop-shadow(0 3px 7px rgba(0, 0, 0, 0.45));
  opacity: 0; transform: scale(0.55);
  letter-spacing: 1px;
}
.go-cue.go-cue-play span { animation: go-cue-pop 1.3s cubic-bezier(0.2, 1.4, 0.4, 1) forwards; }
@keyframes go-cue-pop {
  0%   { opacity: 0; transform: scale(0.55); }
  15%  { opacity: 1; transform: scale(1.08); }
  25%  { opacity: 1; transform: scale(1); }
  72%  { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.04); }
}

/* Toast — brief acknowledgment when leaving an active Play bot / Train
   openings / Puzzles session for another mode (see sessionLeaveMessage() in
   app.js). Non-blocking by design: nothing is actually lost when switching
   modes, so this reassures rather than gates the click. */
.toast {
  position: fixed; left: 50%; bottom: 26px; z-index: 250;
  max-width: min(92vw, 420px);
  background: var(--panel-2); border: 1px solid var(--border);
  color: var(--text); font-size: 0.86rem; font-weight: 600; text-align: center;
  padding: 10px 18px; border-radius: 999px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  opacity: 0; pointer-events: none;
}
.toast.toast-play { animation: toast-pop 3s ease forwards; }
@keyframes toast-pop {
  0%   { opacity: 0; transform: translateX(-50%) translateY(16px); }
  8%   { opacity: 1; transform: translateX(-50%) translateY(0); }
  85%  { opacity: 1; transform: translateX(-50%) translateY(0); }
  100% { opacity: 0; transform: translateX(-50%) translateY(8px); }
}
.toast:not(.toast-play) { transform: translateX(-50%) translateY(16px); }

/* ───────────────────── Mobile shell (≤780px) ─────────────────────
   docs/ux-ui-audit.md §4: below this breakpoint the desktop 3-column grid
   reflow (board buried under the whole setup sidebar) is replaced by a real
   mobile layout — slim top bar, board as the hero, a docked bottom action
   bar for the controls used every move, and the setup sidebar / management
   panel become an off-canvas drawer and bottom sheet respectively. These
   mobile-only elements are hidden entirely above 780px so this is inert on
   desktop. Placed at the end of the stylesheet so it wins the cascade over
   the unconditional .sidebar/.panel/.board-col rules above (same specificity,
   source order decides — a media query alone doesn't raise specificity). */
@media (max-width: 780px) {
  .workspace { grid-template-columns: 1fr; padding: 10px 10px calc(10px + env(safe-area-inset-bottom)); gap: 10px; }

  /* Slim top bar */
  .mobile-topbar {
    display: flex; align-items: center; gap: 6px;
    position: sticky; top: 0; z-index: 120;
    background: var(--panel); border-bottom: 1px solid var(--border);
    padding: 8px 10px; padding-top: calc(8px + env(safe-area-inset-top));
  }
  .topbar-brand { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
  .topbar-brand .brand-mark { width: 28px; height: 28px; border-radius: 7px; }
  .topbar-brand .brand-mark-logo { width: 16px; height: 16px; }
  .topbar-brand .brand-name { font-weight: 700; font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .topbar-btn {
    flex: 0 0 auto; width: 36px; height: 36px; display: grid; place-items: center;
    background: var(--panel-2); color: var(--text); border: 1px solid var(--border);
    border-radius: 8px; cursor: pointer;
    transition: border-color 0.15s, transform 0.08s ease, filter 0.08s ease;
  }
  .topbar-btn:active { transform: scale(0.92); filter: brightness(0.85); }
  .topbar-btn .ico { width: 19px; height: 19px; }

  /* Backdrop shared by the drawer + sheet */
  .mobile-backdrop {
    display: block; position: fixed; inset: 0; z-index: 130;
    background: rgba(6, 5, 16, 0.55);
  }

  /* Sidebar becomes an off-canvas drawer, sliding in from the left. */
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 140;
    width: min(86vw, 340px); max-width: none;
    border-radius: 0; border-right: 1px solid var(--border); border-top: none; border-bottom: none;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    overflow-y: auto; overscroll-behavior: contain;
    padding-top: calc(14px + env(safe-area-inset-top));
    padding-bottom: calc(14px + env(safe-area-inset-bottom));
  }
  body.mobile-sidebar-open .sidebar { transform: translateX(0); }

  /* Right panel becomes a bottom sheet. */
  .panel {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 140;
    max-height: 78vh;
    border-radius: 16px 16px 0 0; border-bottom: none;
    background: var(--bg);
    padding: 10px 12px calc(12px + env(safe-area-inset-bottom));
    transform: translateY(100%);
    transition: transform 0.25s ease;
    overflow-y: auto; overscroll-behavior: contain;
  }
  body.mobile-panel-open .panel { transform: translateY(0); }

  /* Board — width-first sizing (not the desktop 62vh height-driven rule),
     so the docked top/bottom bars don't push it taller than the viewport
     can show comfortably in portrait. */
  .board-col { width: min(100%, 92vw); }

  /* Docked bottom action bar — the controls used every move, kept out of
     the drawer/sheet entirely (docs/ux-ui-audit.md §4.2). */
  .mobile-actionbar {
    display: flex; gap: 8px;
    position: sticky; bottom: calc(-1 * (10px + env(safe-area-inset-bottom))); z-index: 110;
    background: var(--panel); border-top: 1px solid var(--border);
    padding: 8px 12px; padding-bottom: calc(8px + env(safe-area-inset-bottom));
    margin: 4px -10px calc(-10px - env(safe-area-inset-bottom));
  }
  .actionbar-btn {
    flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px;
    background: var(--panel-2); color: var(--text); border: 1px solid var(--border);
    border-radius: 9px; padding: 10px; font-size: 0.86rem; font-family: inherit; cursor: pointer;
    transition: border-color 0.15s, transform 0.08s ease, filter 0.08s ease;
  }
  .actionbar-btn:active { transform: scale(0.96); filter: brightness(0.85); }
}
