/* Magnord's pages, on the design system's tokens (tokens.css, generated from
   sources/design/system/tokens.json: Paper when light, Night when dark). Only token variables here, no
   colours of our own. Results sit like a timing board: tabular figures, right-aligned times,
   every status an icon and a word. */

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 400 16px/24px var(--font-text); -webkit-font-smoothing: antialiased; }
main { max-width: 1040px; margin: 0 auto; padding: var(--space-4) var(--space-6) var(--space-16); }
h1 { font-size: 28px; line-height: 34px; letter-spacing: -0.01em; font-weight: 600; margin: var(--space-2) 0; }
h2 { font-size: 22px; line-height: 28px; font-weight: 600; margin: var(--space-6) 0 var(--space-3); display: flex; gap: var(--space-3); align-items: baseline; flex-wrap: wrap; }
h3 { font-size: 14px; line-height: 20px; font-weight: 600; margin: var(--space-3) 0 var(--space-1); }
p { margin: var(--space-2) 0; }
a { color: var(--text); text-underline-offset: 2px; }
a:hover { color: var(--accent-text); }
code { font-size: 14px; background: var(--surface-sunken); padding: 0 var(--space-1); border-radius: var(--radius-xs); }
:focus-visible { outline: none; box-shadow: 0 0 0 var(--focus-offset) var(--focus-gap), 0 0 0 calc(var(--focus-offset) + var(--focus-width)) var(--focus); border-radius: var(--radius-sm); }
.muted { color: var(--text-muted); }
.small { font-size: 14px; line-height: 20px; }
.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }
.error { color: var(--danger); display: flex; gap: var(--space-2); align-items: center; font-weight: 500; }

/* The header: the needle, the name, who is signed in. */
.top { background: var(--surface); border-bottom: var(--border-hairline) solid var(--border); }
.top-in { max-width: 1040px; margin: 0 auto; padding: 0 var(--space-6); min-height: 56px; display: flex; gap: var(--space-4); justify-content: space-between; align-items: center; }
.brand { display: inline-flex; gap: var(--space-2); align-items: center; text-decoration: none; }
.brand-name { font-weight: 700; font-size: 18px; letter-spacing: -0.01em; }
.brand a { display: inline-flex; gap: var(--space-2); align-items: center; text-decoration: none; }
.brand-sub { color: var(--text-muted); font-weight: 500; padding-left: var(--space-2); border-left: var(--border-hairline) solid var(--border); }
.brand-sub:hover { color: var(--text); text-decoration: underline; }
.top nav { display: flex; gap: var(--space-4); align-items: center; font-size: 14px; }
.top nav a { text-decoration: none; }
.top nav a:hover { text-decoration: underline; }
.top form { margin: 0; }
.me { display: inline-flex; gap: var(--space-2); align-items: center; font-weight: 600; }

/* Controls (sources/design/system/components: Button, TextField, Dropdown). */
.btn, button.link { font-family: inherit; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2); height: var(--control-h); min-width: var(--target-min);
  padding: 0 var(--space-4); font: 600 16px/20px var(--font-text); border-radius: var(--radius-sm); cursor: pointer;
  border: var(--border-hairline) solid var(--border-strong); background: var(--surface-raised); color: var(--text); }
.btn:hover { background: var(--surface-hover); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.primary:active { background: var(--accent-pressed); }
.btn.destructive { background: transparent; border: var(--border-strong-w) solid var(--danger); color: var(--danger); }
.btn.destructive:hover { background: var(--danger-soft); }
button.link { background: none; border: 0; padding: 0; font-size: inherit; color: var(--text); cursor: pointer; }
button.link:hover { text-decoration: underline; }
/* An icon-only button (Lucide; aria-label and title name it). */
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: var(--target-min); height: var(--target-min);
  background: none; border: 0; border-radius: var(--radius-sm); color: var(--text); cursor: pointer; }
.icon-btn:hover { background: var(--surface-hover); }
a.btn { text-decoration: none; }
input, textarea, select { font: 400 16px/20px var(--font-text); color: var(--text); background: var(--surface-raised);
  border: var(--border-hairline) solid var(--border-strong); border-radius: var(--radius-sm); }
input { height: var(--control-h); padding: 0 var(--space-4); }
input.is-error { border: var(--border-strong-w) solid var(--danger); padding-left: calc(var(--space-4) - 1px); }
textarea { padding: var(--space-3) var(--space-4); font-family: ui-monospace, monospace; }
.field { display: flex; flex-direction: column; gap: var(--space-1); }
.field-label { font: 600 14px/18px var(--font-text); color: var(--text); }
.select { position: relative; display: inline-flex; align-items: center; }
.select select { appearance: none; -webkit-appearance: none; height: var(--control-h); min-width: 180px; padding: 0 calc(var(--space-4) + 28px) 0 var(--space-4); font-weight: 500; cursor: pointer; }
.select select:hover { background: var(--surface-hover); }
.select .icon { position: absolute; right: var(--space-3); color: var(--text-muted); pointer-events: none; }
.stack { display: flex; flex-direction: column; gap: var(--space-2); }
.stack .btn { margin-top: var(--space-2); }
.stack .select { align-self: flex-start; }
.pickers > a { line-height: var(--control-h); }
.panel > h2:first-child { margin-top: 0; }
form.inline { display: flex; gap: var(--space-2); align-items: center; flex-wrap: wrap; margin: var(--space-2) 0 var(--space-4); }

.panel { background: var(--surface); border: var(--border-hairline) solid var(--border); border-radius: var(--radius-md); box-shadow: var(--elevation-1); padding: var(--space-4) var(--space-6); }
.notice { display: flex; gap: var(--space-2); align-items: center; }
.notice .icon { color: var(--ok); }
.badge { display: inline-flex; gap: var(--space-1); align-items: center; height: 24px; padding: 0 var(--space-2) 0 6px; border-radius: var(--radius-xs);
  font: 600 14px/18px var(--font-text); background: var(--abandoned-soft); color: var(--text); white-space: nowrap; }
.kicker { font: 600 12px/16px var(--font-text); letter-spacing: .08em; text-transform: uppercase; color: var(--text-muted); margin: 0; }
.kicker a { color: var(--text-muted); text-decoration: none; }
.kicker a:hover { color: var(--text); text-decoration: underline; }

/* Sign-in. */
.signin { max-width: 440px; margin: var(--space-12) auto; padding: var(--space-8) var(--space-6) var(--space-6); }
.signin h1 { margin-top: var(--space-3); }
.signin-mark { display: block; }
.key-input { font: 500 18px/24px var(--font-display); letter-spacing: .08em; text-transform: uppercase; }
.key-input::placeholder { color: var(--text-muted); letter-spacing: .08em; }
.quiet { margin-top: var(--space-6); padding-top: var(--space-4); border-top: var(--border-hairline) solid var(--border); }

/* Releases. */
.list { list-style: none; padding: 0; margin: var(--space-4) 0; border-top: var(--border-hairline) solid var(--border); }
.list-row { display: flex; gap: var(--space-4); align-items: center; min-height: var(--row-h); padding: var(--space-2) var(--space-3); border-bottom: var(--border-hairline) solid var(--border); text-decoration: none; }
.list-row:hover { background: var(--surface-hover); color: var(--text); }
.list-main { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.list-title { font-weight: 600; font-size: 18px; }

/* The board: the release, the pickers, one leaderboard. */
.release-head { display: flex; gap: var(--space-3); align-items: center; min-height: var(--control-h); }
.release-head form { margin: 0 0 0 auto; }
.pickers { display: flex; gap: var(--space-3) var(--space-4); align-items: flex-end; flex-wrap: wrap; margin: var(--space-3) 0 var(--space-4); }
.board-head h1 { margin: 0; }
.board-sub { display: flex; gap: var(--space-3); align-items: baseline; flex-wrap: wrap; margin: var(--space-1) 0 var(--space-3); }
.board-course { font-size: 18px; line-height: 24px; font-weight: 600; }
.you-line { display: flex; gap: var(--space-2); align-items: center; padding: var(--space-2) var(--space-3); background: var(--surface-selected); border-radius: var(--radius-sm); font-weight: 500; }
.you-chip { display: inline-flex; align-items: center; height: 20px; padding: 0 6px; border-radius: var(--radius-xs); border: var(--border-hairline) solid var(--accent-text);
  color: var(--accent-text); font: 600 12px/16px var(--font-text); letter-spacing: .04em; text-transform: uppercase; vertical-align: middle; }

/* Rows: # · name · time · behind · date · tries. Times right-aligned in Barlow, the timing
   board's numerals; every other row washed so the eye can follow it across. */
.board { border-top: var(--border-hairline) solid var(--border); }
.row { display: grid; grid-template-columns: 2.5rem minmax(0, 1fr) 6rem 5rem 9.5rem 4rem; gap: var(--space-3); align-items: center;
  min-height: var(--row-h-dense); padding: var(--space-1) var(--space-3); border-bottom: var(--border-hairline) solid var(--border); }
.row.head { min-height: 32px; background: var(--surface-sunken); font: 600 12px/16px var(--font-text); letter-spacing: .08em; text-transform: uppercase; color: var(--text-muted); }
.entry:nth-of-type(even) > summary { background: var(--surface); }
summary.row { cursor: pointer; list-style: none; }
summary.row::-webkit-details-marker { display: none; }
summary.row:hover { background: var(--surface-hover); }
.entry.is-you > summary, .entry.is-you > summary:hover { background: var(--surface-selected); box-shadow: inset 3px 0 0 var(--accent); }
.c-rank, .c-time, .c-behind, .c-tries { text-align: right; }
.c-rank { font-weight: 600; }
.c-name { min-width: 0; display: flex; flex-direction: column; }
.name-line { display: flex; gap: var(--space-2); align-items: center; min-width: 0; }
.name-line a { font-weight: 600; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.name-line a:hover { text-decoration: underline; }
.sub-line { display: none; font-size: 14px; line-height: 18px; white-space: nowrap; }
.c-time { font: 500 20px/24px var(--font-display); }
.c-time .status { font: 600 14px/18px var(--font-text); justify-content: flex-end; }
.c-behind { font-size: 14px; }
.c-date { font-size: 14px; }
.c-tries { display: flex; justify-content: flex-end; gap: var(--space-1); align-items: center; color: var(--text-muted); }
.row.head > span { font: inherit; }
.entry[open] .i-chevron { transform: rotate(180deg); }
.entry[open] > summary { border-bottom-color: transparent; }
.tries-list { background: var(--surface-sunken); border-bottom: var(--border-hairline) solid var(--border); padding: var(--space-2) var(--space-3) var(--space-3) calc(2.5rem + var(--space-6)); }

.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--space-1); padding: var(--space-12) var(--space-6); border-top: var(--border-hairline) solid var(--border); }
.empty h2 { margin: var(--space-2) 0 0; }

/* A person's runs: each try, then its splits as control code and split time. */
.try-list { list-style: none; padding: 0; margin: 0; }
.try { padding: var(--space-2) 0; border-bottom: var(--border-hairline) solid var(--border); }
.try:last-child { border-bottom: 0; }
.try-head { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-4); align-items: center; min-height: 32px; }
.try-time { font: 500 20px/24px var(--font-display); min-width: 4.5rem; }
.splits { list-style: none; padding: 0; margin: var(--space-2) 0 0; display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-3); font-size: 14px; color: var(--text-muted); }
.split { display: inline-flex; gap: var(--space-1); align-items: center; }
.code { display: inline-flex; align-items: center; justify-content: center; min-width: 32px; height: 24px; padding: 0 4px; border-radius: var(--radius-xs);
  background: var(--control-soft); color: var(--text); font: 600 16px/1 var(--font-display); letter-spacing: .02em; font-variant-numeric: tabular-nums; }
.course h2 { justify-content: space-between; margin-top: 0; }
.panel.course { margin: var(--space-4) 0; }
.person-name { display: flex; gap: var(--space-3); align-items: center; }

.status { display: inline-flex; gap: var(--space-1); align-items: center; font-weight: 600; }
.st-ok { color: var(--ok); } .st-mp { color: var(--danger); } .st-dsq { color: var(--danger); } .st-paused { color: var(--paused); } .st-dnf { color: var(--abandoned); }
.pb { color: var(--pb); font-weight: 600; display: inline-flex; gap: var(--space-1); align-items: center; font-size: 16px; }
.flag { color: var(--warning); background: var(--warning-soft); font: 600 14px/18px var(--font-text); padding: 2px 6px; border-radius: var(--radius-xs); display: inline-flex; gap: var(--space-1); align-items: center; }

.feedback { margin: var(--space-3) 0; }
.feedback header { display: flex; gap: var(--space-3); align-items: baseline; flex-wrap: wrap; }
.feedback .text { white-space: pre-wrap; margin: 0; }
.rating { font-weight: 600; }

/* The admin's tester keys (ticket 110). */
.keys { border-top: var(--border-hairline) solid var(--border); margin-bottom: var(--space-8); }
.key { display: grid; grid-template-columns: 11rem 7rem minmax(0, 1fr) auto; gap: var(--space-3); align-items: center; min-height: var(--row-h-dense); padding: var(--space-1) var(--space-3); border-bottom: var(--border-hairline) solid var(--border); }
.key.head { min-height: 32px; background: var(--surface-sunken); font: 600 12px/16px var(--font-text); letter-spacing: .08em; text-transform: uppercase; color: var(--text-muted); }
.key .actions { display: flex; gap: var(--space-2); justify-content: flex-end; }
.key form { margin: 0; }

/* The admin's invite requests (ticket 133), on the keys' rows. */
.invites .key { grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr) 10rem calc(3 * var(--target-min) + 2 * var(--space-2)); padding-top: var(--space-2); padding-bottom: var(--space-2); }
.invites .note { white-space: pre-wrap; overflow-wrap: anywhere; }

/* The admin's testers (ticket 129), on the keys' rows. */
.testers .key { grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr) 9rem; }
.installs .key { grid-template-columns: minmax(0, 1fr) 9rem 9rem 7rem; }
.installs .key > :first-child { display: flex; gap: var(--space-2); align-items: center; min-width: 0; white-space: nowrap; overflow: hidden; }
.tester-runs .key { grid-template-columns: 9rem minmax(0, 1fr) 6rem var(--target-min); }
/* An upload's client build (ticket 143), after the text it belongs to. */
.tester-runs .build, .benchmarks .build { margin-left: var(--space-2); white-space: nowrap; }
/* The admin's benchmarks (ticket 132), on the keys' rows: a table per GPU. */
.bench-gpu { margin: var(--space-6) 0 var(--space-2); }
.benchmarks { margin-bottom: var(--space-4); }
.benchmarks .key { grid-template-columns: minmax(0, 1fr) 5rem 12rem 4rem 4rem; }
.benchmarks .p99 { display: flex; gap: var(--space-2); align-items: baseline; }
.bench-word { font-weight: 600; }
.bw-Smooth { color: var(--ok); } .bw-OK { color: var(--warning); } .bw-Heavy { color: var(--danger); }
.notice.new-key-panel { display: block; }
.notice.new-key-panel h2 { display: flex; gap: var(--space-2); align-items: center; }
.new-key { font: 600 22px/28px var(--font-display); letter-spacing: .08em; user-select: all; overflow-wrap: anywhere; }
.inline-form { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: end; margin-bottom: var(--space-6); }

/* Icons from sources/design/system/assets/Icons, tinted to the text colour. */
.icon { width: 20px; height: 20px; display: inline-block; background: currentColor; mask: var(--i) center / contain no-repeat; -webkit-mask: var(--i) center / contain no-repeat; flex: none; }
.icon.sm { width: 16px; height: 16px; }
.icon.lg { width: 48px; height: 48px; color: var(--text-muted); }
.i-ok { --i: url(status-ok.svg); } .i-mp { --i: url(status-mp.svg); } .i-dsq { --i: url(status-dsq.svg); }
.i-paused { --i: url(status-paused.svg); } .i-dnf { --i: url(status-abandoned.svg); }
.i-pb { --i: url(pb.svg); } .i-warning { --i: url(warning.svg); } .i-error { --i: url(error.svg); } .i-lock { --i: url(lock.svg); }
.i-log-out { --i: url(lucide/log-out.svg); } .i-download { --i: url(lucide/download.svg); }
.i-chevron { --i: url(chevron-down.svg); } .i-chevron-right { --i: url(chevron-right.svg); } .i-check { --i: url(check.svg); } .i-flag { --i: url(flag.svg); }
/* Lucide (static/lucide, ISC) where an action's icon is generally understood. */
.i-key { --i: url(lucide/key-round.svg); } .i-send { --i: url(lucide/send.svg); }
.i-invited { --i: url(lucide/user-round-check.svg); } .i-decline { --i: url(lucide/x.svg); }
.i-release { --i: url(lucide/unlink.svg); } .i-revoke { --i: url(lucide/ban.svg); } .i-restore { --i: url(lucide/rotate-ccw.svg); }
.i-remove { --i: url(lucide/trash-2.svg); } .i-download { --i: url(lucide/download.svg); } .i-monitor { --i: url(lucide/monitor.svg); }

@media (prefers-reduced-motion: no-preference) {
  .i-chevron { transition: transform 120ms ease-out; }
}

/* A phone: one line of numbers, the date under the name, no date or tries columns. */
@media (max-width: 640px) {
  main { padding: var(--space-2) var(--space-4) var(--space-12); }
  .top-in { padding: 0 var(--space-4); }
  .me-name { display: none; }
  .top nav { gap: var(--space-1) var(--space-3); flex-wrap: wrap; justify-content: flex-end; padding: var(--space-2) 0; }
  .top nav > * { white-space: nowrap; }
  h1 { font-size: 22px; line-height: 28px; }
  .row { grid-template-columns: 1.75rem minmax(0, 1fr) 4.5rem 3.75rem 1.25rem; gap: var(--space-2); padding: var(--space-1) var(--space-2); min-height: var(--row-h); }
  .row .c-date { display: none; }
  .row .tries-n { display: none; }
  .sub-line { display: block; }
  .row.head .c-tries { visibility: hidden; }
  .c-time { font-size: 18px; }
  .tries-list { padding-left: var(--space-3); }
  .pickers .field { flex: 1 1 0; min-width: 0; }
  .select, .select select { width: 100%; min-width: 0; }
  .panel { padding: var(--space-4); }
  .key { grid-template-columns: minmax(0, 1fr) auto; }
  .key.head { display: none; }
  .invites .key { grid-template-columns: minmax(0, 1fr) auto; }
  .invites .key > :nth-child(3) { order: 2; grid-column: 1 / -1; }
  .invites .key > .note { order: 3; grid-column: 1 / -1; }
  .invites .key > .note:empty { display: none; }
  .testers .key { grid-template-columns: minmax(0, 1fr) auto; }
  .installs .key, .tester-runs .key { grid-template-columns: minmax(0, 1fr) auto auto; }
  .testers .key > .holds { order: 3; grid-column: 1 / -1; }
  .installs .key > .first, .tester-runs .key > .date { display: none; }
  .pickers.two .field { flex-basis: 40%; }
  .benchmarks .key { grid-template-columns: minmax(0, 1fr) auto; }
  .benchmarks .key > .runs, .benchmarks .key > .worst, .benchmarks .key > .avg { display: none; }
  .benchmarks .build { display: block; margin-left: 0; white-space: normal; }
  .list-row .num { display: none; }
}
/* A narrow phone with the admin's links: the needle alone names the site. */
@media (max-width: 400px) { .top:has(a[href="/admin/keys"]) .brand-name { display: none; } }
/* The replay page (ticket 149): the map with its play bar, then the runners' legs. */
.i-route { --i: url(lucide/route.svg); } .i-play { --i: url(lucide/play.svg); } .i-pause { --i: url(lucide/pause.svg); }
.i-chevron-left { --i: url(chevron-right.svg); transform: scaleX(-1); }
.board-sub .icon-btn { vertical-align: middle; }
.replay-head { display: flex; gap: var(--space-2); align-items: center; }
.replay { border: var(--border-hairline) solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; background: #fff; }
.replay-map { height: min(70vh, 720px); }
.replay-bar { display: flex; gap: var(--space-2); align-items: center; flex-wrap: wrap; padding: var(--space-2); background: var(--surface-raised);
  border-top: var(--border-hairline) solid var(--border-strong); }
.replay-bar input[type=range] { flex: 1 1 200px; min-width: 120px; }
.rp-clock { min-width: 4.5em; text-align: right; }
.replay-legs { overflow-x: auto; margin-top: var(--space-4); }
.replay-legs table { border-collapse: collapse; font-size: 14px; }
.replay-legs th, .replay-legs td { padding: var(--space-1) var(--space-2); text-align: right; white-space: nowrap; }
.replay-legs .rp-name { text-align: left; }
.replay-legs tbody tr { border-top: var(--border-hairline) solid var(--border-strong); }
.rp-swatch { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: var(--space-2); vertical-align: -1px; }
.rp-leg { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
.rp-leg:hover { text-decoration: underline; }
.rp-leg.is-best { font-weight: 600; }
@media (max-width: 640px) { .replay-map { height: 60vh; } }
.rp-dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, .35); }
.rp-number { font: 600 15px/1 var(--font-text); text-shadow: 0 0 2px #fff, 0 0 2px #fff; pointer-events: none; }
.replay-bar .select select { width: auto; min-width: 0; }
/* Replay picks (ticket 150): tick testers on the board and tries anywhere, replay them together. */
.i-layers { --i: url(lucide/layers.svg); }
form.compare { display: inline-flex; gap: 0; align-self: center; margin: 0; }
h2 form.compare { margin-left: auto; }
input.pick { width: 16px; height: 16px; margin: 0 var(--space-2) 0 0; accent-color: var(--accent, currentColor); cursor: pointer; vertical-align: middle; }
