:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --ink: #1f1d1a;
  --muted: #6b665d;
  --line: #e2ddd2;
  --accent: #8a5a12;
  --accent-ink: #ffffff;
  --good: #2f6b3a;
  --good-bg: #e5f4e4;
  --bad: #9b2c2c;
  --bad-bg: #fbebeb;
  --info-bg: #f9eeda;
  --wood: #e9c988;
  --wood-line: #6b5326;
  --played: #b4491f;
  --best: #1c5cab;
  --glow: #ffe9a8;
  --series: #2a78d6;
  --neutral: #6b6a66;
  --radius: 10px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans CJK SC", "Noto Sans CJK JP", "Noto Sans CJK KR", sans-serif;
  line-height: 1.5;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171614;
    --surface: #211f1c;
    --ink: #ece8e1;
    --muted: #a39d92;
    --line: #37332d;
    --accent: #e0a64a;
    --accent-ink: #1b1306;
    --good: #8fd19a;
    --good-bg: #1f3322;
    --bad: #f0a3a3;
    --bad-bg: #3a2020;
    --info-bg: #34291a;
    --wood: #c9a65e;
    --wood-line: #4a3a1a;
    --played: #d9661f;
    --best: #3987e5;
    --glow: #5a4a12;
    --series: #3987e5;
    --neutral: #a09f98;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--ink); }
#app { min-height: 100vh; display: flex; flex-direction: column; }
a { color: var(--accent); }
h1 { font-size: 1.6rem; margin: 0 0 .5rem; }
h2 { font-size: 1.2rem; margin: 0 0 .75rem; }
h3 { font-size: 1.05rem; margin: 0 0 .5rem; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.big { font-size: 2rem; font-weight: 600; margin: .25rem 0; }

.top {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding: .75rem 16px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.top a { text-decoration: none; }
.brand { font-weight: 700; color: var(--ink); font-size: 1.1rem; }
.top nav { display: flex; gap: 1rem; flex: 1; }
.balance { font-weight: 600; white-space: nowrap; }

main { width: 100%; max-width: 880px; margin: 1.5rem auto; padding: 0 16px; display: grid; gap: 1.25rem; align-content: start; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; }

.landing { max-width: 620px; margin-top: 12vh; text-align: center; justify-items: center; }
.landing h1 { font-size: 2.4rem; }
.lead { font-size: 1.15rem; }
.points { text-align: left; }

button, .button {
  font: inherit; cursor: pointer; display: inline-block; text-decoration: none;
  padding: .55rem 1rem; border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink);
}
button.primary, .button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button:disabled { opacity: .5; cursor: not-allowed; }

form { display: grid; gap: .9rem; }
label { display: grid; gap: .3rem; }
input[type=text], textarea, select, input[type=file] {
  font: inherit; color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: 8px; padding: .5rem;
}
textarea { font-family: ui-monospace, monospace; font-size: .85rem; }
fieldset { border: 0; padding: 0; margin: 0; }
fieldset.inline { display: flex; gap: 1.25rem; flex-wrap: wrap; align-items: center; }
fieldset.inline legend { padding: 0; margin-bottom: .3rem; }
fieldset.inline label, .tab { display: inline-flex; gap: .4rem; align-items: center; }
.tabs { display: flex; gap: .5rem; flex-wrap: wrap; }
.tab { border: 1px solid var(--line); border-radius: 999px; padding: .3rem .8rem; cursor: pointer; }
.tab:has(input:checked) { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.tab input { position: absolute; opacity: 0; pointer-events: none; }

.notice { margin: 0; padding: .6rem .8rem; border-radius: 8px; background: var(--info-bg); }
.notice.error { background: var(--bad-bg); color: var(--bad); }
.notice.success { background: var(--good-bg); color: var(--good); }

.rows { list-style: none; margin: 0; padding: 0; }
.rows li { display: flex; gap: .75rem; flex-wrap: wrap; align-items: baseline; padding: .6rem 0; border-top: 1px solid var(--line); }
.rows li:first-child { border-top: 0; }
.players { display: inline-flex; gap: .2rem; align-items: center; flex-wrap: wrap; overflow-wrap: anywhere; }
.versus { color: var(--muted); margin: 0 .4rem; }
.you { color: var(--muted); font-size: .85rem; }
.stone { width: .85em; height: .85em; border-radius: 50%; display: inline-block; border: 1px solid #555; }
.stone.black { background: #111; }
.stone.white { background: #fafafa; }

.status { font-size: .8rem; padding: .1rem .5rem; border-radius: 999px; background: var(--info-bg); }
.status.done { background: var(--good-bg); color: var(--good); }
.status.failed { background: var(--bad-bg); color: var(--bad); }

.options { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); margin: .75rem 0; }
.option { display: grid; gap: .5rem; align-content: start; }
.option p { margin: 0; }
.price { font-size: 1.3rem; font-weight: 600; }

.steps { padding-left: 1.25rem; }
.steps li { margin: .3rem 0; color: var(--muted); }
.steps li.current { color: var(--ink); font-weight: 600; }

table { width: 100%; border-collapse: collapse; }
td { padding: .45rem .25rem; border-top: 1px solid var(--line); }
tr:first-child td { border-top: 0; }
td.amount { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

@media (max-width: 560px) {
  .top nav { order: 3; flex-basis: 100%; }
  h1 { font-size: 1.35rem; }
}

/* The review page: one goban and a side panel. The page does not scroll. Only the panel's body does. */

#app.fixed { height: 100dvh; min-height: 0; overflow: hidden; }
.fixed .top { padding: .4rem 16px; }
main.review {
  max-width: none; margin: 0; padding: 0; gap: 0; flex: 1; min-height: 0;
  grid-template-columns: minmax(0, 1fr) clamp(360px, 38vw, 560px); grid-template-rows: minmax(0, 1fr); align-content: stretch;
}
.board-col { container-type: size; display: grid; place-items: center; padding: 10px; min-width: 0; min-height: 0; }
.board-stack { display: grid; gap: 6px; justify-items: center; }
.board-box { --side: min(100cqw, 100cqh - 42px); width: var(--side); height: var(--side); }
.board-bar { display: flex; gap: 4px; align-items: center; justify-content: center; height: 36px; }
.board-bar button { padding: .2rem .55rem; min-width: 2.2rem; font-size: .9rem; border-radius: 6px; white-space: nowrap; }
.counter { min-width: 5.2rem; text-align: center; font-size: .9rem; color: var(--muted); }
.numbers { font-variant-numeric: tabular-nums; }

.goban { display: block; width: 100%; height: 100%; cursor: crosshair; user-select: none; -webkit-user-select: none; touch-action: manipulation; }
.goban .wood { fill: var(--wood); }
.goban .grid { stroke: var(--wood-line); stroke-width: 1; }
.goban .star { fill: var(--wood-line); }
.goban .coord { font-size: 9.5px; fill: var(--wood-line); text-anchor: middle; }
.goban .stone.black { fill: #111; stroke: #000; }
.goban .stone.white { fill: #fafafa; stroke: #333; }
.goban .num { font-size: 12px; font-weight: 700; text-anchor: middle; }
.goban .on-black { fill: #fff; }
.goban .on-white { fill: #111; }
.goban .last { fill: none; stroke-width: 2; }
.goban .last.on-black { stroke: #fff; }
.goban .last.on-white { stroke: #111; }
.goban .mark-bg { fill: var(--wood); }
.goban .mark { fill: none; stroke-width: 2.6; }
.goban .mark-a { stroke: #b4491f; }
.goban .mark-b { stroke: #1c5cab; }
.goban .mark-x { stroke: #2b2415; }
.goban .mark-text-a { fill: #8f3511; }
.goban .mark-text-b { fill: #14467f; }
.goban .mark-text-x { fill: #2b2415; }
.goban .badge { stroke: #fff; stroke-width: 1.2; }
.goban .badge-a { fill: #b4491f; }
.goban .badge-b { fill: #1c5cab; }
.goban .badge-x { fill: #2b2415; }
.goban .badge-text { font-size: 9px; font-weight: 700; fill: #fff; text-anchor: middle; }
.goban .group-ring { fill: none; stroke: #1baf7a; stroke-width: 2.4; }
.goban .heat.lost { fill: #b4321f; }
.goban .heat.gain { fill: #1c5cab; }
.goban .hi { fill: none; stroke: #ffd400; stroke-width: 3; opacity: .85; }
.goban .hi-main { stroke-width: 4.5; opacity: 1; }
.goban .sel { fill: rgba(255, 212, 0, .18); stroke: #111; stroke-width: 2.2; stroke-dasharray: 5 3; }
.goban .sel-tag-bg { fill: #111; }
.goban .sel-tag-text, .goban .hover-tag-text { font-size: 11px; font-weight: 700; text-anchor: middle; fill: #fff; }
.goban .hover { fill: rgba(17, 17, 17, .35); pointer-events: none; }
.goban .hover.on-stone { fill: none; stroke: #ffd400; stroke-width: 2; }
.goban .hover-tag-bg { fill: rgba(17, 17, 17, .7); }
.goban .layer-hover, .goban .layer-sel, .goban .layer-hi { pointer-events: none; }
@media (prefers-reduced-motion: no-preference) {
  .goban .hi-main { animation: pulse 1s ease-in-out infinite; }
}
@keyframes pulse { 50% { opacity: .35; } }

.panel { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--surface); border-left: 1px solid var(--line); }
.panel button { padding: .25rem .65rem; font-size: .9rem; border-radius: 6px; }
.panel button[aria-pressed=true] { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.panel h2 { font-size: 1.05rem; margin: 0 0 .4rem; }
.panel h3 { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 1.1rem 0 .4rem; }
.panel p { margin: 0 0 .6rem; }
.panel-head { display: grid; gap: 6px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.head-row { display: flex; gap: .75rem; align-items: center; font-size: .9rem; }
.head-row > a { white-space: nowrap; text-decoration: none; }
.head-row .players { flex: 1; min-width: 0; flex-wrap: nowrap; white-space: nowrap; overflow: hidden; }
.side { display: inline-flex; gap: .25rem; align-items: center; min-width: 0; }
.head-row .versus { margin: 0 .25rem; }
.menu { position: relative; }
.menu summary { cursor: pointer; list-style: none; color: var(--accent); white-space: nowrap; }
.menu summary::-webkit-details-marker { display: none; }
.menu summary::after { content: " ▾"; }
.menu-items {
  position: absolute; right: 0; top: 1.6rem; z-index: 5; display: grid; gap: .1rem; min-width: 12rem; padding: .4rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 6px 20px rgba(0, 0, 0, .18);
}
.menu-items a { padding: .3rem .5rem; border-radius: 6px; text-decoration: none; }
.menu-items a:hover { background: var(--info-bg); }

.graph { display: block; width: 100%; height: auto; touch-action: pan-y; cursor: ew-resize; }
.graph .gridline { stroke: var(--line); stroke-width: 1; }
.graph .zero { stroke: var(--neutral); stroke-width: 1; }
.graph .tick { font-size: 10px; fill: var(--muted); }
.graph .note-tick { stroke: var(--neutral); stroke-width: 1.5; }
.graph .series { fill: none; stroke: var(--series); stroke-width: 2; stroke-linejoin: round; }
.graph .guide { stroke: var(--neutral); stroke-width: 1; stroke-dasharray: 3 3; }
.graph .cursor { stroke: var(--ink); stroke-width: 1.5; }
.graph .cursor-dot { fill: var(--ink); stroke: var(--surface); stroke-width: 2; }
.graph .mistake circle { fill: var(--series); stroke: var(--surface); stroke-width: 2; }
.graph .mistake text { font-size: 10px; font-weight: 600; fill: var(--ink); }
.graph .good-move rect { fill: var(--good); stroke: var(--surface); stroke-width: 1.5; }
.graph .readout { font-size: 10px; fill: var(--ink); }

.now { min-height: 3rem; display: grid; gap: 2px; align-content: start; }
.move-line { display: flex; flex-wrap: wrap; gap: 2px 10px; align-items: center; justify-content: space-between; }
.a .row { display: flex; gap: 6px; flex-wrap: wrap; margin: 2px 0 6px; }
.loss { font-weight: 600; color: var(--played); }
.score { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; }
.score-value { font-size: 1.15rem; font-weight: 700; }
.score-value.ahead { color: var(--good); }
.score-value.behind { color: var(--played); }
.panel button.want {
  display: inline-flex; align-items: center; gap: 2px; justify-self: start; padding: 2px 8px 2px 4px; text-align: left;
  color: var(--muted); background: none; border: 1px solid transparent;
}
.panel button.want:hover:not(:disabled), .panel button.want:focus-visible { border-color: var(--line); color: var(--ink); }
.panel button.want[aria-pressed=true] { color: var(--ink); background: none; border-color: var(--best); }
.want-ring { display: inline-block; flex: none; width: 12px; height: 12px; border: 2.5px solid var(--best); border-radius: 50%; margin-right: 6px; }
.want-ring.played { border-color: var(--played); }
label.check { display: flex; gap: .4rem; align-items: center; }
.key { display: inline-block; width: 11px; height: 11px; vertical-align: -1px; opacity: .6; margin-right: 3px; }
.key.lost { background: #b4321f; }
.key.gain { background: #1c5cab; }

.tabs-row { display: flex; gap: 0; border-bottom: 1px solid var(--line); padding: 0 8px; }
.panel .tabs-row button {
  border: 0; border-bottom: 3px solid transparent; border-radius: 0; background: none; padding: .35rem .9rem; font-size: 1rem; color: var(--muted);
}
.panel .tabs-row button[aria-selected=true] { color: var(--ink); font-weight: 600; border-bottom-color: var(--accent); }
.count { font-size: .75rem; color: var(--muted); }
.panel-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.pane { padding: 12px 14px 20px; }

.move-card { padding: .9rem; margin-bottom: .9rem; background: var(--bg); }
.move-card.note { border-left: 3px solid var(--line); }
.move-card.note.kind-praise { border-left-color: var(--good); }
.move-card.note.kind-blunder, .move-card.note.kind-mistake { border-left-color: var(--played); }
.move-card.note p { margin: 0; }
.chips { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.chips .loss { margin-left: 0; }
.views { display: flex; flex-wrap: wrap; gap: 4px; margin: 0 0 .8rem; }
.headline { font-size: 1.05rem; font-weight: 600; }
.story { margin: 0 0 .6rem; padding-left: 1.2rem; }
.story li { margin: .2rem 0; }
.badge { display: inline-block; border: 1px solid currentColor; border-radius: 999px; padding: 0 .55rem; font-size: .8rem; font-weight: 600; }
.rating-excellent { color: #2a78d6; }
.rating-great { color: #1baf7a; }
.rating-good { color: var(--good); }
.rating-inaccuracy { color: #b98600; }
.rating-mistake { color: #d9661f; }
.rating-blunder { color: #d03b3b; }
.confidence-verified { color: var(--good); }
.confidence-partly-verified { color: var(--series); }
.confidence-unexplained { color: var(--neutral); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: currentColor; margin-right: 8px; }
.tested { display: inline-block; font-size: .75rem; font-weight: 600; color: var(--good); border: 1px solid currentColor; border-radius: 999px; padding: 0 7px; white-space: nowrap; }
.table-wrap { overflow-x: auto; margin-bottom: .6rem; }
table.data { font-size: .85rem; font-variant-numeric: tabular-nums; }
table.data th { text-align: left; color: var(--muted); font-weight: 600; padding: .3rem .5rem .3rem 0; }
table.data td { padding: .3rem .5rem .3rem 0; vertical-align: top; }
table.data tr:first-child td { border-top: 1px solid var(--line); }
.grade-pass { color: var(--good); font-weight: 600; }
.grade-fail { color: var(--played); font-weight: 600; }
.grade-inconclusive { color: var(--neutral); }
.panel button.replay { padding: 0 .4rem; font-size: .75rem; line-height: 1.6; }
.panel details { margin: .6rem 0; }
.panel details > summary { cursor: pointer; color: var(--muted); font-size: .9rem; }
.warn { border-left: 3px solid var(--played); padding: .2rem .7rem; color: var(--muted); font-size: .9rem; }

.summary p { line-height: 1.55; }
.course { list-style: none; margin: 0; padding: 0; }
.course li { margin: .35rem 0; }
.panel button.link { border: 0; background: none; padding: 0; color: var(--accent); margin-right: .4rem; }
.keymoves { display: flex; flex-wrap: wrap; gap: 5px; }
.keymove small { color: var(--muted); }
.panel button.keymove[aria-pressed=true] small { color: var(--surface); }
.notes-list { border: 1px solid var(--line); border-radius: 8px; }
.panel button.note-row {
  display: grid; grid-template-columns: 2.4em 1em 1fr; gap: 4px; width: 100%; text-align: left;
  border: 0; border-bottom: 1px solid var(--line); border-radius: 0; padding: .35rem .5rem; background: none;
}
.panel button.note-row:last-child { border-bottom: 0; }
.panel button.note-row[aria-current=true] { background: var(--glow); }
.note-row .n { color: var(--muted); }
.kind-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-top: .45em; background: var(--neutral); }
.kind-dot.kind-blunder { background: #d03b3b; }
.kind-dot.kind-mistake { background: #d9661f; }
.kind-dot.kind-inaccuracy { background: #b98600; }
.kind-dot.kind-reviewed, .kind-dot.kind-annotation { background: var(--series); }
.kind-dot.kind-praise { background: var(--good); border-radius: 0; transform: rotate(45deg); }

/* A point named in the text. Point at it to find it on the board. Click it to ask about it. */
.pt { white-space: nowrap; font-size: .9em; color: var(--muted); border-radius: 999px; padding: 1px 3px 1px 2px; cursor: pointer; text-decoration: underline dotted; text-underline-offset: 3px; }
.pt i {
  font-style: normal; display: inline-flex; align-items: center; justify-content: center; text-decoration: none;
  width: 1.45em; height: 1.45em; border-radius: 50%; margin-right: 3px; font-weight: 700; background: var(--ink); color: var(--surface);
}
.pt-a i { background: var(--played); color: #fff; }
.pt-b i { background: var(--best); color: #fff; }
.pt-want i { background: transparent; border: 2.5px solid var(--best); width: 1em; height: 1em; }
.pt:hover, .pt:focus { background: var(--glow); color: var(--ink); outline: none; }
button[aria-pressed=true] .pt { color: inherit; }

/* Questions. */
.thread { display: grid; gap: .7rem; align-content: start; }
.q { justify-self: end; max-width: 92%; background: var(--info-bg); border-radius: 12px 12px 2px 12px; padding: .5rem .7rem; }
.q p, .a p:last-child { margin: 0; }
.panel button.context { display: block; margin: 0 0 .25rem auto; padding: 0 .5rem; font-size: .75rem; border-radius: 999px; color: var(--muted); background: var(--surface); }
.a { max-width: 96%; }
.a p { line-height: 1.55; }
.a .draft { white-space: pre-wrap; }
.a.pending .status::before { content: ""; display: inline-block; width: .6em; height: .6em; margin-right: .45em; border-radius: 50%; background: var(--accent); }
@media (prefers-reduced-motion: no-preference) {
  .a.pending .status::before { animation: pulse 1s ease-in-out infinite; }
}
.thinking { font-style: italic; white-space: pre-wrap; }
.thinking:empty { display: none; }
.unsupported { text-decoration: underline wavy var(--played); text-decoration-skip-ink: none; text-underline-offset: 3px; }
.unsupported-note { color: var(--muted); }
.panel button.show-line { border-color: var(--best); color: var(--best); }

.composer { gap: 6px; padding: 8px 14px 10px; border-top: 1px solid var(--line); background: var(--surface); }
.about { display: inline-flex; flex: none; align-items: center; gap: .2rem; padding: 0 .15rem 0 .6rem; border-radius: 999px; font-size: .85rem; font-weight: 600; background: var(--ink); color: var(--surface); }
.panel .about button.clear { border: 0; background: none; color: inherit; padding: 0 .35rem; font-size: 1rem; line-height: 1.3; }
.suggestions { display: flex; gap: 5px; overflow-x: auto; scrollbar-width: none; }
.suggestions::-webkit-scrollbar { display: none; }
.panel button.suggest { flex: none; font-size: .8rem; padding: .1rem .6rem; border-radius: 999px; color: var(--muted); }
.ask-row { display: flex; gap: 8px; align-items: stretch; }
.ask-row textarea { flex: 1; min-width: 0; resize: none; font-family: inherit; font-size: 1rem; }
.ask-send { display: grid; gap: 1px; justify-items: center; align-content: start; }
.panel .ask-send button { padding: .3rem 1rem; font-size: 1rem; }
.ask-note { font-size: .72rem; white-space: nowrap; }

@media (max-width: 860px) {
  main.review { grid-template-columns: minmax(0, 1fr); grid-template-rows: min(100vw + 42px, 48dvh) minmax(0, 1fr); }
  .board-col { padding: 6px; }
  .board-stack { gap: 2px; }
  .panel { border-left: 0; border-top: 1px solid var(--line); }
  .panel-head { padding: 6px 12px; gap: 4px; }
  .graph-host { display: none; }
  .now { min-height: 0; }
  .panel button.suggest { display: none; }
  .board-bar { max-width: 100cqw; overflow-x: auto; }
  .board-bar button { min-width: 1.9rem; padding: .2rem .4rem; }
  .counter { min-width: 4rem; }
}

