/* The page: the Tool's black ground and greys (board.js SHADES), system fonts only. It loads nothing
   from another site. Inline styles are refused by the CSP, so every rule lives here. */
:root {
  color-scheme: dark;
  --bg: #000;
  --ink: #f0f0f0;
  --soft: #8c8c8c;
  /* Small secondary text: at least 4.5:1 on the black ground and on the panels' #111. */
  --faint: #7e7e7e;
  /* Lines, borders and tracks only, never text. */
  --edge: #5a5a5a;
  --rule: #262626;
  --panel: #111;
  --panel2: #1a1a1a;
  --ok: #3fb950;
  --bad: #f0605a;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; min-width: 0; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--sans); }
body { overflow-x: clip; }
a { color: inherit; }
button, input { font: inherit; color: inherit; }
code { font-family: var(--mono); }

/* Top bar. */
.bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px max(4vw, 16px); border-bottom: 1px solid var(--rule); }
.bar h1 { margin: 0; font-size: 17px; font-weight: 700; letter-spacing: -0.01em; display: flex; align-items: center; gap: 10px; }
.bar h1 .mark { width: 22px; height: 22px; display: inline-block; }
.bar h1 small { font-weight: 400; color: var(--soft); font-size: 13px; }
.what { background: none; border: 1px solid var(--edge); border-radius: 999px; padding: 6px 14px; cursor: pointer; font-size: 14px; white-space: nowrap; }
.what:hover, .what:focus-visible { border-color: var(--ink); outline: none; }
main { padding: clamp(18px, 3vw, 36px) max(4vw, 16px) 48px; max-width: 1320px; margin: 0 auto; }
.note { color: var(--soft); font-size: 14px; margin: 0 0 18px; max-width: 68ch; }
.lbl { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--soft); margin: 0; font-weight: 600; }
.ok-c { color: var(--ok); }
.bad-c { color: var(--bad); }

/* Hover and tap text. */
.tip { position: fixed; z-index: 30; pointer-events: none; background: #f0f0f0; color: #000; font-size: 12.5px; line-height: 1.35; padding: 6px 9px; border-radius: 4px; max-width: 300px; box-shadow: 0 4px 16px rgb(0 0 0 / 0.5); }
.tip code { font-size: 11.5px; word-break: break-all; }
[data-tip]:focus-visible { outline: 1px solid var(--ink); outline-offset: 2px; }

/* The strip. */
.strip { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 34px; padding-bottom: 18px; border-bottom: 1px solid var(--rule); margin-bottom: 26px; }
.sfig { display: flex; flex-direction: column; }
.sfig b { font-size: 22px; font-weight: 600; line-height: 1.1; font-variant-numeric: tabular-nums; }
.sfig span { font-size: 11.5px; color: var(--soft); white-space: nowrap; }
.sep { width: 1px; align-self: stretch; background: var(--rule); }
.spark { flex: 1 1 200px; height: 34px; min-width: 160px; }

.layout { display: grid; grid-template-columns: minmax(0, 360px) minmax(0, 1fr); gap: clamp(24px, 4vw, 56px); align-items: start; }

/* Sample data: a fixed banner across the top, and staging's switch in the footer. */
.samplebar { position: fixed; top: 0; left: 0; right: 0; z-index: 25; background: #e3b341; color: #000; font-size: 13.5px; font-weight: 600; text-align: center; padding: 7px 16px; }
.samplebar a { color: #000; margin-left: 10px; font-weight: 400; }
body.sample { padding-top: 34px; }
body.sample .about { top: 34px; }
.pagefoot .samples { margin-top: 12px; font-size: 12.5px; }
.pagefoot .samples b { color: var(--ink); font-weight: 600; }

.callbl { margin-bottom: 2px; }

/* The calendar. Scroll containers pad by at least an outline's width and offset (2px + 2px), so the
   ring of a selected or focused child at an edge is not clipped; the negative margin keeps the
   contents aligned with the column. */
.calwrap { overflow-x: auto; padding: 6px; margin: 0 -6px; }
.cal { display: grid; grid-template-rows: repeat(7, var(--c, 20px)); grid-auto-flow: column; grid-auto-columns: var(--c, 20px); gap: 4px; width: max-content; }
.cal button { position: relative; width: var(--c, 20px); height: var(--c, 20px); border: 0; padding: 0; border-radius: 2px; cursor: pointer; background: #1c1c1c; }
/* The hit area reaches into the gap: 24px a cell, touching its neighbours' but not overlapping them. */
.cal button::after { content: ""; position: absolute; inset: -2px; }
.cal button:hover, .cal button:focus-visible { outline: 1px solid var(--ink); outline-offset: 1px; }
.cal button[aria-pressed="true"] { outline: 2px solid var(--ink); outline-offset: 2px; }
.cal button.ok { box-shadow: inset 0 -3px 0 var(--ok); }
.cal button.bad { box-shadow: inset 0 0 0 2px var(--bad); }
.months { display: grid; grid-auto-flow: column; grid-auto-columns: calc(var(--c, 20px) + 4px); font-size: 11px; color: var(--soft); height: 16px; width: max-content; }
.months span { white-space: nowrap; width: 0; }

/* The finders. */
.finds { display: grid; gap: 8px; margin: 18px 0 16px; }
.find { display: flex; align-items: center; gap: 8px; background: var(--panel); border: 1px solid var(--rule); border-radius: 6px; padding: 0 10px; }
.find svg { width: 15px; height: 15px; flex: none; stroke: var(--soft); }
.find input { flex: 1; background: none; border: 0; font: 14px var(--mono); padding: 9px 0; }
.find input:focus { outline: none; }
.find:focus-within { border-color: var(--soft); }
.find:has(input.bad) { border-color: var(--bad); }
.sugg { display: flex; flex-wrap: wrap; gap: 6px; }
.sugg:empty { display: none; }
.sugg button { background: var(--panel); border: 1px solid var(--rule); border-radius: 999px; padding: 2px 10px; cursor: pointer; font: 13px var(--mono); }
.sugg button:hover, .sugg button:focus-visible { border-color: var(--ink); outline: none; }
.fcap { font-size: 11.5px; color: var(--faint); margin: 4px 0 14px; }

/* A list of Games. */
.dayhead { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 8px; }
.dayhead b { font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dayhead span { color: var(--soft); font-size: 12.5px; text-align: right; }
.games { display: grid; gap: 6px; max-height: 380px; overflow: auto; padding: 6px; margin: 0 -6px; }
/* More rows below: the list fades out at its foot instead of cutting a row in half (parts.js). */
.games.more { mask-image: linear-gradient(to bottom, #000 calc(100% - 56px), transparent); }
.games button:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.games button { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 0 12px; text-align: left; background: var(--panel); border: 1px solid var(--rule); border-radius: 6px; padding: 9px 12px; cursor: pointer; }
.games button:hover { border-color: var(--edge); }
.games button:disabled { cursor: default; border-style: dashed; }
.games button[aria-pressed="true"] { border-color: var(--ink); background: var(--panel2); }
.games .res { font: 600 15px var(--mono); width: 3.2em; grid-row: span 2; }
.games .op { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.games small { color: var(--soft); font-size: 12.5px; white-space: nowrap; }
.games .wide { grid-column: 2 / -1; white-space: normal; }
.games .bad-c { color: var(--bad); }
.games .gone { color: var(--soft); font-style: italic; }
.empty { color: var(--soft); font-size: 14px; padding: 14px 0; margin: 0; }

/* The replay. */
.viewer { display: grid; grid-template-columns: minmax(0, 520px) 150px; justify-content: start; gap: 14px; align-items: start; }
.frame { background: #000; border: 1px solid var(--rule); padding: 3%; border-radius: 4px; max-width: 520px; }
.frame svg { display: block; width: 100%; height: auto; }
.viewer.none .frame { opacity: 0.45; }
.frame:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
.board text { font-family: var(--sans); }
.scrub { display: flex; align-items: center; gap: 8px; margin-top: 10px; max-width: 520px; }
.scrub button { flex: none; width: 40px; height: 40px; border: 1px solid var(--edge); background: none; font-size: 20px; border-radius: 4px; cursor: pointer; }
.scrub button:disabled { opacity: 0.3; cursor: default; }
input[type="range"] { flex: 1; appearance: none; -webkit-appearance: none; background: transparent; height: 40px; margin: 0; }
input[type="range"]::-webkit-slider-runnable-track { height: 2px; background: var(--edge); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 12px; height: 26px; background: var(--ink); margin-top: -12px; border-radius: 2px; }
input[type="range"]::-moz-range-track { height: 2px; background: var(--edge); }
input[type="range"]::-moz-range-thumb { width: 12px; height: 26px; background: var(--ink); border: 0; border-radius: 2px; }
input[type="range"]:disabled { opacity: 0.3; }
.vstatus { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; color: var(--soft); margin-top: 6px; min-height: 1.5em; max-width: 520px; }
.vstatus b { color: var(--ink); font-weight: 600; }
.vstatus .code { font-family: var(--mono); color: var(--ink); user-select: text; }
.moves { max-height: 520px; overflow: auto; font-size: 13.5px; font-variant-numeric: tabular-nums; border-left: 1px solid var(--rule); }
.moves:empty { border: 0; }
.mrow { display: grid; grid-template-columns: 2.2em 1fr 1fr; }
.mrow > span { color: var(--faint); padding: 4px 0 0 6px; }
.moves button { background: none; border: 0; text-align: left; padding: 3px 6px; cursor: pointer; border-radius: 3px; }
/* Inside the cell, so the list's own scroll edge never clips it. */
.moves button:focus-visible { outline: 2px solid var(--ink); outline-offset: -2px; }
.moves button small { display: block; font-size: 10.5px; color: var(--faint); }
.moves button[aria-current="true"] { background: var(--ink); color: #000; }
.moves button[aria-current="true"] small { color: #444; }

/* The Fingerprints row. */
.chainrow { margin-top: 34px; padding-top: 18px; border-top: 1px solid var(--rule); display: flex; align-items: center; gap: 14px; }
.chainrow .lbl { flex: none; }
.mini { display: flex; align-items: center; overflow-x: auto; flex: 1; padding: 6px; margin: 0 -6px; scrollbar-width: none; }
.mini div { flex: none; font: 11px var(--mono); padding: 4px 7px; border: 1px solid var(--rule); border-radius: 4px; background: var(--panel); color: var(--soft); white-space: nowrap; }
.mini div b { color: var(--ink); font-weight: 400; }
.mini i { flex: none; width: 10px; height: 2px; background: var(--edge); }
.mini div.ok { border-color: rgb(63 185 80 / 0.6); }
.mini div.ok b { color: var(--ok); }
.mini i.ok { background: var(--ok); }
.mini div.bad { border-color: var(--bad); }
.mini div.bad b { color: var(--bad); }
.mini i.bad { background: var(--bad); }
.res { font-size: 12px; color: var(--soft); flex: none; white-space: nowrap; }
.btn { background: var(--ink); color: #000; border: 0; border-radius: 4px; padding: 6px 12px; font-size: 13px; font-weight: 600; cursor: pointer; flex: none; }
.btn.ghost { background: none; color: var(--ink); border: 1px solid var(--edge); font-weight: 400; }
.btn:hover:not(:disabled), .btn:focus-visible { border-color: var(--ink); outline: none; }
.btn:disabled { opacity: 0.4; cursor: default; }

/* The panel: all the page's explanation. */
.scrim { position: fixed; inset: 0; background: rgb(0 0 0 / 0.6); opacity: 0; pointer-events: none; z-index: 20; }
.about { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100vw); background: #0d0d0d; border-left: 1px solid var(--rule); transform: translateX(100%); visibility: hidden; z-index: 21; overflow-y: auto; padding: 22px 26px 40px; }
body.open .scrim { opacity: 1; pointer-events: auto; }
body.open .about { transform: none; visibility: visible; }
@media (prefers-reduced-motion: no-preference) {
  .scrim { transition: opacity 0.2s; }
  .about { transition: transform 0.25s ease, visibility 0.25s; }
}
.about h2 { font-size: 20px; margin: 0 0 14px; letter-spacing: -0.01em; }
.about h3 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--soft); margin: 26px 0 10px; display: flex; justify-content: space-between; gap: 12px; }
.about h3 .sample { text-transform: none; letter-spacing: 0; font-weight: 400; color: #e3b341; border: 1px solid #6b5418; border-radius: 3px; padding: 0 6px; }
.about p { margin: 0 0 10px; color: #d0d0d0; }
.about .x { position: absolute; top: 14px; right: 14px; width: 36px; height: 36px; border: 1px solid var(--edge); border-radius: 50%; background: none; cursor: pointer; font-size: 18px; line-height: 1; }
.about .foot { font-size: 13px; color: var(--soft); margin-top: 26px; }
.pagefoot { --pad: max(4vw, 16px); padding: 18px var(--pad) 28px; max-width: 1320px; margin: 0 auto; }
/* The rule spans the text column only, like main's rules above it (main pads by the same amount). */
.pagefoot { background: linear-gradient(var(--rule), var(--rule)) top center / calc(100% - 2 * var(--pad)) 1px no-repeat; }
.pagefoot p { margin: 0; font-size: 13px; color: var(--soft); max-width: 68ch; }
.about .foot b { font: 400 13px var(--mono); color: var(--ink); }

/* The diagram: two phones over the Relay, the Public Log under it. */
.dia { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px; }
.node { border: 1px solid var(--edge); border-radius: 10px; padding: 10px 12px; background: var(--panel); display: flex; flex-direction: column; gap: 5px; }
.node > b { font-size: 14px; margin-bottom: 3px; }
.node > b small { color: var(--soft); font-weight: 400; margin-left: 4px; }
.node.relay { grid-column: 1 / -1; border-color: var(--ink); display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px 8px; }
.node.relay > b { grid-column: 1 / -1; }
.chip { font-size: 12.5px; padding: 4px 8px; border-radius: 4px; background: #1d1d1d; border: 1px solid var(--rule); display: flex; flex-direction: column; line-height: 1.3; }
.chip em { font-style: normal; color: var(--soft); font-size: 11px; }
.chip.no { background: none; border-style: dashed; color: var(--faint); }
.wire { position: relative; height: 46px; display: flex; justify-content: center; align-items: center; }
.wire i { position: absolute; top: 4px; bottom: 4px; left: calc(50% - 1px); width: 2px; background: var(--edge); }
.wire i::before, .wire i::after { content: ""; position: absolute; left: -4px; border: 5px solid transparent; }
.wire i::before { top: -6px; border-bottom-color: var(--edge); }
.wire i::after { bottom: -6px; border-top-color: var(--edge); }
.wire span { position: relative; background: #0d0d0d; font-size: 10.5px; color: var(--soft); padding: 0 4px; }
.stem { grid-column: 1 / -1; justify-self: center; width: 2px; height: 22px; background: var(--edge); }
.node.logn { grid-column: 1 / -1; justify-self: center; text-align: center; font-size: 12.5px; color: var(--soft); padding: 8px 18px; gap: 0; }
.node.logn b { color: var(--ink); margin: 0; }

/* The sample record and entry. */
.kv { margin: 0 0 8px; display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 3px 14px; font-size: 12.5px; }
.kv dt { color: var(--soft); }
.kv dd { margin: 0; font-family: var(--mono); overflow-wrap: anywhere; }
.scroll { overflow-x: auto; }
.sample-t { width: 100%; border-collapse: collapse; font: 12px var(--mono); }
.sample-t th { text-align: left; color: var(--soft); font: 600 10.5px var(--sans); text-transform: uppercase; letter-spacing: 0.06em; padding: 6px 10px 4px 0; }
.sample-t td { padding: 3px 10px 3px 0; border-top: 1px solid #1c1c1c; white-space: nowrap; }
.sample-t tr.hl td { background: #1f1f1f; }
.sample-t td.dim { color: var(--faint); }
.about .json { font: 11px/1.6 var(--mono); color: var(--soft); overflow-wrap: anywhere; margin-top: 10px; }
.about .json b { color: var(--ink); font-weight: 400; }

@media (max-width: 860px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .sep { display: none; }
  .strip { gap: 10px 22px; }
  .spark { flex-basis: 100%; }
  .chainrow { flex-wrap: wrap; }
  .mini { flex-basis: 100%; order: 3; }
  .games { max-height: 300px; }
}
@media (max-width: 640px) {
  .viewer { grid-template-columns: minmax(0, 1fr); }
  .moves { max-height: 200px; border-left: 0; border-top: 1px solid var(--rule); }
  /* Full width here: the columns keep a Move's width, not a share of the row. */
  .mrow { grid-template-columns: 2.2em 6em 6em; }
  .bar h1 small { display: none; }
  .about { padding: 18px 16px 36px; }
}
@media (prefers-reduced-motion: no-preference) { .moves { scroll-behavior: smooth; } }
