:root {
  --bg: #f4f2ee;
  --surface: #ffffff;
  --ink: #23262b;
  --muted: #6b717b;
  --line: #dcd8cf;
  --accent: #3f7d4a;
  --accent-ink: #ffffff;
  --mine: #2a6f3b;
  --opp: #8a4b1f;
  --bad: #b3322d;
  --good: #1f7a3a;
  --sq-light: #eeeed2;
  --sq-dark: #769656;
  --hl-last: rgba(246, 246, 105, 0.55);
  --hl-sel: rgba(20, 120, 220, 0.45);
  --pw-fill: #fbfaf5;
  --pw-stroke: #1b1b1b;
  --pb-fill: #3a3a3c;
  --pb-stroke: #0b0b0b;
  --pb-detail: #f1efe6;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1e21;
    --surface: #26292e;
    --ink: #e8e6e1;
    --muted: #9aa0a9;
    --line: #3a3e45;
    --accent: #5fa56c;
    --mine: #7fcf92;
    --opp: #e0a070;
    --bad: #ee7b74;
    --good: #7fd698;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; }
.topbar { display: flex; align-items: center; gap: 14px; padding: 10px 20px; background: var(--surface); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 18px; letter-spacing: 0.2px; }
.logo { color: var(--accent); font-size: 22px; margin-right: 2px; }
.repsel { display: flex; align-items: center; gap: 8px; color: var(--muted); }
select, input[type=text], input:not([type]), textarea { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; }
textarea { width: 100%; resize: vertical; }
.toast { margin-left: auto; opacity: 0; transition: opacity 0.2s; color: var(--ink); background: var(--bg); border: 1px solid var(--line); padding: 4px 10px; border-radius: 6px; max-width: 50ch; font-size: 13px; }
.toast.show { opacity: 1; }
.layout { display: grid; grid-template-columns: minmax(320px, 640px) minmax(340px, 1fr); gap: 22px; padding: 20px; max-width: 1400px; margin: 0 auto; align-items: start; }
.board-wrap { width: 100%; aspect-ratio: 1; border-radius: 6px; overflow: hidden; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18); touch-action: none; user-select: none; }
.board, .board-svg { width: 100%; height: 100%; display: block; }
.sq-light { fill: var(--sq-light); }
.sq-dark { fill: var(--sq-dark); }
.hl-last { fill: var(--hl-last); }
.hl-sel { fill: var(--hl-sel); }
.coord { font: 600 20px system-ui, sans-serif; pointer-events: none; }
.coord.on-dark { fill: var(--sq-light); }
.coord.on-light { fill: var(--sq-dark); }
.pc { stroke-width: 1.6; stroke-linejoin: round; stroke-linecap: round; }
.pc.pw { fill: var(--pw-fill); stroke: var(--pw-stroke); }
.pc.pb { fill: var(--pb-fill); stroke: var(--pb-stroke); }
.pc .detail { fill: none; stroke: var(--pw-stroke); }
.pc.pb .detail { stroke: var(--pb-detail); }
.pc .cross { fill: none; stroke-width: 2.6; }
.pc .eye { fill: var(--pw-stroke); stroke: none; }
.pc.pb .eye { fill: var(--pb-detail); }
.eco-line { min-height: 24px; font-weight: 600; margin-bottom: 8px; color: var(--accent); }
.board-controls { display: flex; gap: 8px; margin-top: 10px; }
.hint-text { color: var(--muted); font-size: 12.5px; margin-top: 8px; }
.btn { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 6px 12px; cursor: pointer; }
.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.danger { color: var(--bad); }
.btn.small { padding: 2px 8px; font-size: 13px; }
.btn.icon { padding: 6px 10px; }
.btn.promo { padding: 4px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.tab { font: inherit; background: none; border: none; padding: 9px 16px; cursor: pointer; color: var(--muted); border-bottom: 3px solid transparent; }
.tab.active { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px 18px; min-height: 420px; }
.panel h3 { margin: 18px 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.row { display: flex; align-items: center; margin: 8px 0; }
.row.between { justify-content: space-between; flex-wrap: wrap; gap: 8px; }
.row.gap { gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.muted { color: var(--muted); font-size: 13px; }
.badge { padding: 2px 10px; border-radius: 99px; font-weight: 600; font-size: 13px; color: #fff; }
.badge.mine { background: var(--mine); }
.badge.opp { background: var(--opp); }
.tree { max-height: 300px; overflow: auto; border: 1px solid var(--line); border-radius: 6px; padding: 10px; line-height: 2; background: var(--bg); }
.tree .var { margin: 2px 0 2px 14px; padding-left: 10px; border-left: 2px solid var(--line); font-size: 14px; }
.mvnum { color: var(--muted); margin: 0 2px 0 4px; font-size: 13px; }
.mv { font: inherit; font-weight: 600; background: none; border: none; padding: 1px 4px; border-radius: 4px; cursor: pointer; }
.mv.mine { color: var(--mine); }
.mv.opp { color: var(--opp); }
.mv.side { font-weight: 500; }
.mv:hover { background: rgba(120, 120, 120, 0.18); }
.mv.cur { background: var(--accent); color: #fff; }
.cmt { color: var(--muted); font-style: italic; font-size: 13px; margin: 0 4px; }
.root-cmt { margin-bottom: 6px; }
.moves-here .mh-row { display: flex; align-items: center; gap: 10px; padding: 4px 0; border-bottom: 1px dashed var(--line); }
.tag { font-size: 12px; color: var(--muted); }
.tag.main { color: var(--accent); font-weight: 600; }
.chip { font: inherit; font-size: 13px; background: var(--bg); border: 1px solid var(--line); border-radius: 99px; padding: 2px 10px; cursor: pointer; margin: 3px 4px 0 0; color: var(--ink); }
.chip:hover { border-color: var(--accent); }
.book { margin-top: 10px; }
.empty { border: 1px dashed var(--line); border-radius: 8px; padding: 14px; margin: 10px 0; color: var(--muted); }
.empty p { margin: 0 0 10px; }
label.inline { display: inline-flex; gap: 8px; align-items: center; margin-top: 8px; }
.stat-row { display: flex; gap: 10px; flex-wrap: wrap; margin: 8px 0 14px; }
.stat { flex: 1 1 70px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; text-align: center; }
.stat-v { font-size: 22px; font-weight: 700; }
.stat-l { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.msg { padding: 10px 12px; border-radius: 8px; margin: 10px 0; border: 1px solid var(--line); background: var(--bg); }
.msg.good { border-color: var(--good); color: var(--good); }
.msg.bad { border-color: var(--bad); color: var(--bad); font-weight: 600; }
.msg.ask { border-color: var(--accent); font-weight: 600; }
.summary { margin-top: 12px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 4px 6px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 6px; border-bottom: 1px solid var(--line); }
.tbl tr.clickable { cursor: pointer; }
.tbl tr.clickable:hover { background: var(--bg); }
.gap-row { padding: 8px 0; border-bottom: 1px solid var(--line); }
.linkish { font: inherit; background: none; border: none; color: var(--accent); cursor: pointer; padding: 0; text-align: left; font-weight: 600; }
.eco-box { padding: 8px 12px; background: var(--bg); border-radius: 6px; border: 1px solid var(--line); }
.bar-right { fill: var(--good); }
.bar-wrong { fill: var(--bad); }
.axis { stroke: var(--line); }
dialog { border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); padding: 18px 22px; min-width: 300px; }
dialog::backdrop { background: rgba(0, 0, 0, 0.4); }
dialog h2 { margin-top: 0; font-size: 18px; }
dialog label { display: flex; flex-direction: column; gap: 4px; margin: 10px 0; color: var(--muted); font-size: 13px; }
dialog label.check { flex-direction: row; align-items: center; gap: 8px; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.promo-choices { display: flex; gap: 8px; margin-top: 10px; }
.pcicon { display: block; }
.pcicon .pc { stroke-width: 1.6; }
@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; padding: 12px; }
}
