body { margin: 0; font-family: system-ui, sans-serif; background: #1a1a1e; color: #e8e6e3; }
#root { padding: 12px; }

.app header { display: flex; align-items: baseline; gap: 16px; flex-wrap: wrap; }
.app h1 { font-size: 1.2rem; margin: 0; }
.conn-controls button { margin-right: 6px; }
.model-selector { display: flex; align-items: center; gap: 8px; max-width: 100%; min-width: 0; }
.model-selector select { min-width: 0; max-width: 100%; font: inherit; background: #242428; color: #e8e6e3; padding: 4px; }
.sgf-file { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; font-size: 12px; }
.sgf-file input { max-width: 100%; min-width: 0; }

.status-bar { margin: 8px 0; display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap; }
.status-bar .conn { text-transform: uppercase; font-weight: 600; }
.status-bar .fatal { color: #ff6b6b; }
.status-bar .transport { color: #f7b955; }
.status-bar .pending { color: #f7b955; }

.app main { display: flex; gap: 24px; align-items: flex-start; flex-wrap: wrap; }
.board-wrap { max-width: 100%; }
.board { display: grid; gap: 0; position: relative; isolation: isolate; background: #d9b991; border: 6px solid #3a2f23; border-radius: 6px; box-sizing: border-box; width: min(78vmin, 640px); max-width: 100%; }
.board-lines { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.board-lines line { stroke: #3a2f23; stroke-width: 1; vector-effect: non-scaling-stroke; }
.board-lines circle { fill: #3a2f23; }
.cell {
  aspect-ratio: 1; min-width: 0; border: none; background: transparent; cursor: pointer;
  position: relative; z-index: 1; font-size: 14px; padding: 0;
  display: flex; align-items: center; justify-content: center;
}
.cell:disabled { cursor: default; }
.cell .stone { width: 90%; height: 90%; border-radius: 50%; box-sizing: border-box; font-size: 0; }
.cell.black .stone { background: #101010; border: 1px solid #333; }
.cell.white .stone { background: #f5f5f5; border: 1px solid #777; }
.cell.legal:not(.black):not(.white) .stone { width: 18%; height: 18%; background: #287837; }
.cell.linked .stone { box-shadow: inset 0 0 0 2px #a371f7; }
.cell:focus-visible { outline: 2px solid #287837; outline-offset: -3px; border-radius: 50%; }
.cell .mark {
  position: absolute; top: 1px; right: 3px; font-size: 0.6em; color: #a371f7; font-weight: 700;
}
.board-footer { display: flex; gap: 12px; align-items: baseline; margin-top: 8px; }
.mask-basis { color: #9c948a; font-size: 0.85rem; }

aside { min-width: 0; width: 420px; max-width: 100%; }
.kind-selector button { margin-right: 6px; }
.kind-selector .selected { outline: 2px solid #3fb950; }
.quota-bar, .replay-bar, .analysis-panel, .receipt-log { margin-top: 12px; }
.quota-bar .terminal { color: #f7b955; font-weight: 600; margin-left: 8px; }
.quota-bar .pending-double { color: #a371f7; margin-left: 8px; }
.replay-bar { display: flex; gap: 8px; align-items: center; }
.replay-bar[data-replay="true"] span { color: #f7b955; font-weight: 600; }
.analysis-panel table { border-collapse: collapse; margin-top: 6px; width: 100%; }
.analysis-panel th, .analysis-panel td { text-align: left; padding: 2px 8px 2px 0; font-size: 0.85rem; }
.analysis-panel th:nth-child(-n+3), .analysis-panel td:nth-child(-n+3) { white-space: nowrap; }
.analysis-controls { display: flex; flex-wrap: wrap; gap: 6px; }
.analysis-meta, .analysis-error { color: #9c948a; font-size: 0.8rem; margin-top: 4px; }
.analysis-error { color: #f7b955; }
.receipt-log { font-size: 0.8rem; }
.receipt-log .accepted { color: #3fb950; }
.receipt-log .rejected { color: #ff6b6b; }
.receipt-log .pending { color: #9c948a; }
.receipt-log .pending.unknown { color: #f7b955; }
.export-log pre { white-space: pre-wrap; word-break: break-all; max-height: 200px; overflow: auto; background: #101014; padding: 8px; }
.no-board { padding: 48px; color: #9c948a; }

/* SGF export/import panel (M6-D4) */
.sgf-panel { border: 1px solid #444; border-radius: 6px; padding: 8px; margin-top: 8px; }
.sgf-panel h2 { font-size: 14px; margin: 0 0 6px 0; }
.sgf-panel textarea { width: 100%; box-sizing: border-box; background: #1b1b1b; color: #ddd; border: 1px solid #555; border-radius: 4px; font-family: monospace; font-size: 11px; }
.sgf-panel button { margin-top: 4px; }
.sgf-export, .sgf-import { margin-bottom: 8px; }
.sgf-import-preview { display: flex; flex-direction: column; gap: 4px; margin-top: 4px; }
.loss-declaration { color: #d7a94c; font-size: 12px; }
.import-status { color: #7fb3ff; font-size: 12px; }
.dim { color: #888; font-size: 12px; }
.fatal { color: #e06c60; font-size: 12px; }

/* Reference workspace: rail, board, and theme-aware tool bands. */
body { background: #edf0ef; }
#root { padding: 0; }
.app { --app: #edf0ef; --panel: #fff; --ink: #243431; --muted: #71817c; --border: #d9e1dc; --accent: #276653; --accent-ink: #fff; --soft: #e4eee8; --board: #dcb873; --line: #54452d; --stone-black: #151818; --stone-white: #fff; --danger: #b44040; min-height: 100vh; background: var(--app); color: var(--ink); display: flex; font-size: 14px; letter-spacing: 0; }
.app[data-theme="dark"] { --app: #181c20; --panel: #242a2f; --ink: #e6eaee; --muted: #a2afb7; --border: #394249; --accent: #8ccdb8; --accent-ink: #132922; --soft: #303c3b; --board: #56616b; --line: #c1c9ce; --stone-black: #0c1013; --stone-white: #eef2f3; --danger: #ffa49d; }
.app[data-theme="elegant"] { --app: #f2efe9; --panel: #faf8f2; --ink: #554d40; --muted: #887d69; --border: #dcd5c5; --accent: #855342; --accent-ink: #fffaf1; --soft: #eae3d6; --board: #e6dbc6; --line: #675d4b; --stone-black: #211f1b; --stone-white: #fffdf7; }
.app[data-theme="minimal"] { --app: #fff; --panel: #fff; --ink: #151515; --muted: #686868; --border: #ddd; --accent: #151515; --accent-ink: #fff; --soft: #eee; --board: #fff; --line: #151515; --stone-black: #111; --stone-white: #fff; }
.app[data-theme="cyber"] { --app: #090d10; --panel: #0e171c; --ink: #bdf6ee; --muted: #78aaa8; --border: #254247; --accent: #5ae4d0; --accent-ink: #082620; --soft: #152c30; --board: #10232a; --line: #39858c; --stone-black: #071315; --stone-white: #e3fffa; --danger: #ff9ab7; }
.app button, .app select, .app input, .app textarea { font: inherit; box-sizing: border-box; }
.app button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 34px; padding: 7px 11px; border: 1px solid var(--border); border-radius: 6px; background: var(--panel); color: var(--ink); cursor: pointer; transition: background .15s, border-color .15s; }
.app button:hover:not(:disabled) { background: var(--soft); border-color: var(--accent); }
.app button:disabled { opacity: .4; cursor: default; }
.app button:focus-visible, .app input:focus-visible, .app select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.app input, .app select, .app textarea { background: var(--panel); color: var(--ink); border: 1px solid var(--border); border-radius: 5px; padding: 7px 9px; }
.app input[type="checkbox"] { accent-color: var(--accent); width: 15px; height: 15px; margin: 0; }
.navigation-rail { width: 76px; flex: 0 0 76px; position: sticky; top: 0; height: 100vh; box-sizing: border-box; padding: 25px 10px; display: flex; flex-direction: column; align-items: center; gap: 50px; background: var(--panel); border-right: 1px solid var(--border); }
.brand-seal { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 8px; background: var(--accent); color: var(--accent-ink); font: bold 27px serif; }
.workspace-tabs { display: flex; flex-direction: column; gap: 14px; }
.app .workspace-tabs button { width: 54px; height: 58px; flex-direction: column; gap: 5px; font-size: 10px; border-color: transparent; background: transparent; }
.app .workspace-tabs button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.app .theme-shortcut { margin-top: auto; border: 0; }
.workspace { min-width: 0; flex: 1; padding: 25px 30px; max-width: 1680px; box-sizing: border-box; margin: 0 auto; }
.app header { gap: 20px; align-items: center; padding-bottom: 18px; border-bottom: 1px solid var(--border); }
.brand-title { display: flex; flex-direction: column; gap: 3px; margin-right: auto; }
.app h1 { font-size: 23px; font-weight: 650; }
.brand-title > span { color: var(--muted); font-size: 12px; }
.model-selector { font-size: 12px; color: var(--muted); }
.model-selector select { width: 214px; padding: 9px; color: var(--ink); }
.conn-controls { display: flex; gap: 5px; }
.conn-controls button { margin: 0; width: 35px; padding: 0; }
.status-bar { padding: 9px 0; margin: 0 0 18px; font-size: 11px; color: var(--muted); gap: 10px; }
.status-bar .conn { color: var(--accent); display: flex; align-items: center; gap: 6px; }
.status-bar .conn::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.app main { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 30px; align-items: start; }
.board-column { min-width: 0; max-width: 780px; width: 100%; justify-self: center; }
.players-strip { display: flex; align-items: center; gap: 22px; padding: 0 24px 17px; }
.player { display: flex; align-items: center; gap: 8px; color: var(--muted); padding: 8px 0; border-bottom: 2px solid transparent; }
.player.active { color: var(--ink); border-color: var(--accent); }
.player-stone { display: block; width: 21px; height: 21px; border-radius: 50%; border: 1px solid #7778; box-shadow: 0 2px 3px #0002; }
.player-stone.black { background: var(--stone-black); }.player-stone.white { background: var(--stone-white); }
.player strong { font-size: 14px; font-variant-numeric: tabular-nums; }.player small { font-weight: normal; font-size: 12px; }
.move-count { margin-left: auto; display: flex; align-items: baseline; gap: 7px; }.move-count span { font-size: 10px; color: var(--muted); }.move-count strong { font-size: 26px; font-weight: 500; font-variant-numeric: tabular-nums; }
.board-wrap { width: 100%; }.board-stage { padding: 23px; background: var(--board); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 12px 28px #00000012; }
.app .board { width: 100%; max-width: none; border: 0; border-radius: 0; background: var(--board); }
.board-lines line { stroke: var(--line); }.board-lines circle { fill: var(--line); }
.board-coordinates { position: absolute; inset: 0; pointer-events: none; color: var(--line); font: 10px ui-monospace, monospace; }
.coordinate { position: absolute; }.coordinate.top { top: -17px; transform: translateX(-50%); }.coordinate.bottom { bottom: -17px; transform: translateX(-50%); }.coordinate.left { left: -16px; transform: translateY(-50%); }.coordinate.right { right: -16px; transform: translateY(-50%); }
.app .cell { min-height: 0; padding: 0; background: transparent; border: 0; border-radius: 0; cursor: crosshair; overflow: visible; }
.app .cell:disabled { opacity: 1; cursor: default; }.app .cell:hover:not(:disabled) { background: transparent; }
.app .cell .stone { position: relative; z-index: 1; }
.app .cell.black .stone { background: radial-gradient(circle at 32% 26%, #454949, var(--stone-black) 65%); border: 1px solid #0009; box-shadow: 1px 2px 3px #0005; }
.app .cell.white .stone { background: radial-gradient(circle at 32% 26%, #fff, var(--stone-white) 65%); border: 1px solid #6667; box-shadow: 1px 2px 3px #0003; }
.app[data-theme="minimal"] .cell.black .stone { background: #111; box-shadow: none; }.app[data-theme="minimal"] .cell.white .stone { background: #fff; box-shadow: none; border-color: #111; }
.app[data-theme="cyber"] .cell.black .stone { border-color: #5ae4d0; }.app[data-theme="cyber"] .cell.white .stone { border-color: #f3a3dc; }
.app .cell.legal:not(.black):not(.white) .stone { background: var(--accent); opacity: .7; }
.cell .mark { color: var(--accent); z-index: 4; top: 0; right: 0; font: bold 9px ui-monospace, monospace; background: var(--board); border-radius: 2px; padding: 0 1px; }
.app .cell.linked .stone { outline: 2px solid var(--accent); outline-offset: -2px; }
.cell.immortal-glow::before { content: ""; position: absolute; inset: 8%; border-radius: 45%; background: #f4c94799; box-shadow: 0 0 9px 6px #efb72e99; z-index: 0; }
.special-connections { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 0; }
.eightway-edge { stroke-width: .11; stroke-linecap: round; }.eightway-edge.black { stroke: var(--stone-black-border); }.eightway-edge.white { stroke: var(--stone-white-border); }.eightway-edge[data-connected="false"] { stroke-dasharray: .16 .07; }
.analysis-point { position: absolute; inset: 0; border-radius: 50%; z-index: 5; pointer-events: none; background: var(--accent); color: var(--accent-ink); display: flex; flex-direction: column; justify-content: center; align-items: center; line-height: 1.08; box-shadow: 0 0 0 1px var(--board); }
.analysis-point strong { font-size: 9px; font-weight: 650; }.analysis-point small { font-size: 8px; }
.board-footer { margin-top: 15px; justify-content: space-between; gap: 8px; }.mask-basis { color: var(--muted); font-size: 10px; }
.board-toolbar { display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: 10px; padding: 18px 0; }.board-toolbar .replay-bar { margin: 0; gap: 4px; }.replay-bar span { min-width: 65px; text-align: center; font: 12px ui-monospace, monospace; }.replay-bar[data-replay="true"] span { color: var(--accent); }
.coordinate-toggle { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }.move-timeline { display: flex; gap: 6px; flex-wrap: wrap; border-top: 1px solid var(--border); padding-top: 15px; }.move-timeline button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.double-notice { display: flex; gap: 10px; align-items: center; padding: 10px 15px; margin-bottom: 12px; background: var(--accent); color: var(--accent-ink); border-radius: 6px; }.double-notice strong { text-transform: uppercase; }
.control-panel { width: auto; max-width: 100%; min-width: 0; display: flex; flex-direction: column; background: var(--panel); padding: 22px; border: 1px solid var(--border); border-radius: 8px; box-sizing: border-box; }
.control-panel > section { padding: 19px 0; border-bottom: 1px solid var(--border); }.control-panel > section:first-child { padding-top: 0; }.control-panel h2, .sgf-panel h2 { display: flex; align-items: center; gap: 7px; font-size: 11px; font-weight: 650; color: var(--muted); margin: 0 0 13px; }
.theme-swatches { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 9px; }.app .theme-swatch { height: 40px; padding: 0; border: 2px solid transparent; }.app .theme-swatch[aria-pressed="true"] { outline: 2px solid var(--accent); outline-offset: 2px; }.app .theme-swatch.light { background: #dcb873; color: #403822; }.app .theme-swatch.dark { background: #46535d; color: #f1f3f6; }.app .theme-swatch.elegant { background: #e6dbc6; color: #5c5245; }.app .theme-swatch.minimal { background: #fff; color: #111; border-color: #ddd; }.app .theme-swatch.cyber { background: #10232a; color: #5ae4d0; }
.kind-selector { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }.kind-selector button { margin: 0; font-size: 11px; min-width: 0; padding: 8px 4px; }.kind-selector .selected { outline: none; background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.quota-bar { color: var(--muted); font-size: 10px; line-height: 1.7; }.quota-bar .pending-double { display: none; }
.analysis-settings { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 11px; }.analysis-settings label { display: flex; align-items: center; gap: 7px; }.analysis-settings input[type="number"] { width: 66px; padding: 5px; }
.analysis-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }.analysis-controls button { font-size: 12px; }.analysis-controls button:nth-child(3) { grid-column: 1 / -1; background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.analysis-panel { overflow-x: auto; }.analysis-panel table { font-size: 10px; }.analysis-panel td, .analysis-panel th { font-size: 10px; padding: 6px 5px 6px 0; border-bottom: 1px solid var(--border); }.analysis-panel td:last-child { overflow-wrap: anywhere; }.analysis-meta { font-size: 10px; line-height: 1.6; }
.analysis-meta, .analysis-error, .dim, .mask-basis { color: var(--muted); }.status-bar .fatal, .fatal, .analysis-error, .receipt-log .rejected { color: var(--danger); }.status-bar .pending, .status-bar .transport, .quota-bar .terminal, .quota-bar .pending-double, .loss-declaration { color: var(--accent); }
.sgf-panel { margin-top: 0; padding: 19px 0 0; border: 0; border-radius: 0; }.sgf-panel textarea { background: var(--app); color: var(--ink); border-color: var(--border); font-size: 11px; }.sgf-file { font-size: 11px; color: var(--muted); }.sgf-file input { width: 100%; padding: 5px; font-size: 10px; }.sgf-file input::file-selector-button { background: var(--soft); border: 0; border-radius: 3px; color: var(--ink); padding: 5px 8px; margin-right: 7px; }.sgf-panel button { font-size: 11px; }.sgf-export { color: var(--muted); font-size: 11px; }.receipt-log { border-top: 1px solid var(--border); padding-top: 12px; font-size: 10px; overflow-wrap: anywhere; }.receipt-log .accepted, .import-status { color: var(--accent); }.receipt-log .pending { color: var(--muted); }.export-log pre { background: var(--app); color: var(--ink); font-size: 10px; }.loss-declaration { font-size: 10px; line-height: 1.6; }
.app[data-tab="records"] .sgf-panel { order: -1; padding-top: 0; padding-bottom: 20px; margin-bottom: 20px; border-bottom: 1px solid var(--border); }.app[data-tab="analysis"] .engine-panel { order: -1; padding-top: 0; margin-bottom: 20px; }
@media (max-width: 1100px) { .workspace { padding: 20px; }.app main { grid-template-columns: minmax(0, 1fr) 300px; gap: 20px; }.control-panel { padding: 17px; }.players-strip { gap: 12px; padding-left: 0; padding-right: 0; }.player strong { display: none; }.analysis-point strong { font-size: 7px; }.analysis-point small { font-size: 6px; } }
@media (max-width: 820px) { .app { flex-direction: column; }.navigation-rail { position: relative; width: 100%; height: 62px; flex-basis: 62px; flex-direction: row; padding: 9px 16px; gap: 20px; border-right: 0; border-bottom: 1px solid var(--border); }.brand-seal { width: 34px; height: 34px; font-size: 23px; }.workspace-tabs { flex-direction: row; gap: 5px; }.app .workspace-tabs button { height: 40px; width: 56px; flex-direction: row; }.workspace-tabs button span { display: none; }.app .theme-shortcut { margin: 0 0 0 auto; }.workspace { width: 100%; padding: 17px; }.app main { grid-template-columns: minmax(0, 1fr); gap: 20px; }.board-column { max-width: 650px; }.control-panel { width: 100%; }.app header { gap: 12px; }.model-selector { margin-left: auto; }.model-selector select { width: 165px; }.conn-controls { margin-left: auto; }.brand-title { margin-right: 0; }.status-bar { margin-bottom: 10px; }.board-stage { padding: 20px; }.board-toolbar { gap: 6px; }.board-toolbar button { padding: 5px 8px; }.board-footer .mask-basis { max-width: 65%; overflow-wrap: anywhere; }.analysis-point strong { font-size: 7px; }.analysis-point small { font-size: 6px; } }
@media (prefers-reduced-motion: reduce) { .app * { transition: none !important; animation: none !important; } }
@media (min-width: 821px) { .board-column { max-width: min(780px, max(320px, calc(100dvh - 280px))); } }
.app button { transition: border-color .15s; }
.analysis-point { pointer-events: auto; }
.app[data-theme="light"] { --muted: #5b6a63; }
.app[data-theme="elegant"] { --muted: #736755; }
.no-board { color: var(--muted); }
.app { color-scheme: light; }
.app[data-theme="dark"], .app[data-theme="cyber"] { color-scheme: dark; }
.model-selector option { background: var(--panel); color: var(--ink); }
.app { --stone-black-border: #151818; --stone-white-border: #747a76; }
.app[data-theme="dark"] { --stone-black-border: #8b969f; --stone-white-border: #f0f4f7; }
.app[data-theme="elegant"] { --stone-black-border: #373027; --stone-white-border: #96856b; }
.app[data-theme="minimal"] { --stone-black-border: #111; --stone-white-border: #111; }
.app[data-theme="cyber"] { --stone-black-border: #5ae4d0; --stone-white-border: #c084fc; }
.app[data-theme] .cell.black .stone { border-color: var(--stone-black-border); }
.app[data-theme] .cell.white .stone { border-color: var(--stone-white-border); }
.engine-switches { display: grid; gap: 12px; margin: 14px 0; }
.engine-switches label { display: flex; align-items: center; gap: 10px; }
.engine-switches label span { margin-left: auto; color: var(--muted); font-size: 12px; }
.engine-switches input { appearance: none; width: 34px; height: 20px; border-radius: 10px; background: var(--muted); position: relative; flex: 0 0 34px; cursor: pointer; }
.engine-switches input::after { content: ""; position: absolute; width: 14px; height: 14px; top: 3px; left: 3px; border-radius: 50%; background: var(--panel); }
.engine-switches input:checked { background: var(--accent); }
.engine-switches input:checked::after { left: 17px; background: var(--accent-ink); }
.engine-switches input:disabled { opacity: .5; cursor: default; }
.engine-switches input:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
