:root {
  color-scheme: light;
  --page: #f0f5fa;
  --surface: #ffffff;
  --ink: #334155;
  --ink-2: #5b6878;
  --muted: #8a95a3;
  --grid: #e2e8f0;
  --axis: #cbd5e1;
  --border: #d1d5db;
  --heading: #014b92;
  --accent: #014b92;
  --accent-ink: #014b92;
  --accent-wash: rgba(1, 75, 146, 0.08);
  --on-accent: #ffffff;
  --current: #b50404;
  --pb: #b50404;
  --pb-wash: rgba(181, 4, 4, 0.10);
  --good: #1a8a47;
  --std-neo: #7a4fd0;
  --std-jr: #b86e00;
  --std-qc: #c0398f;
  --bar: #014b92;
  --radius: 4px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0b1220;
    --surface: #131c2b;
    --ink: #e2e8f0;
    --ink-2: #a7b3c4;
    --muted: #7d8899;
    --grid: #223047;
    --axis: #33445e;
    --border: rgba(255, 255, 255, 0.12);
    --heading: #8cbcf0;
    --accent: #5aa0e8;
    --accent-ink: #8cbcf0;
    --accent-wash: rgba(90, 160, 232, 0.18);
    --on-accent: #0b1220;
    --current: #f06464;
    --pb: #f06464;
    --pb-wash: rgba(240, 100, 100, 0.18);
    --good: #4cc27c;
    --std-neo: #a88bf0;
    --std-jr: #f0a640;
    --std-qc: #e77bbf;
    --bar: #5aa0e8;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0b1220;
  --surface: #131c2b;
  --ink: #e2e8f0;
  --ink-2: #a7b3c4;
  --muted: #7d8899;
  --grid: #223047;
  --axis: #33445e;
  --border: rgba(255, 255, 255, 0.12);
  --heading: #8cbcf0;
  --accent: #5aa0e8;
  --accent-ink: #8cbcf0;
  --accent-wash: rgba(90, 160, 232, 0.18);
  --on-accent: #0b1220;
  --current: #f06464;
  --pb: #f06464;
  --pb-wash: rgba(240, 100, 100, 0.18);
  --good: #4cc27c;
  --std-neo: #a88bf0;
  --std-jr: #f0a640;
  --std-qc: #e77bbf;
  --bar: #5aa0e8;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  line-height: 1.45;
  font-size: 16px;
}
a { color: var(--accent-ink); }
a:focus-visible, button:focus-visible, summary:focus-visible, [tabindex]:focus-visible,
input:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.top {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 16px;
  min-height: 60px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--heading); font-weight: 600; font-size: 1.1rem; text-decoration: none; min-width: 0; }
.brand img { height: 40px; width: auto; flex: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .brand img { background: #ffffff; border-radius: var(--radius); padding: 2px 4px; }
}
:root[data-theme="dark"] .brand img { background: #ffffff; border-radius: var(--radius); padding: 2px 4px; }
/* On narrow screens the logo stands in for the name (still read by screen readers). */
@media (max-width: 420px) {
  .brand-name { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}
.top nav { display: flex; gap: 4px; }
.top nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 10px;
  color: var(--ink-2);
  text-decoration: none;
  border-radius: var(--radius);
}
.top nav a { font-weight: 500; }
.top nav a:hover { color: var(--accent-ink); }
.top nav a[aria-current="page"] { color: var(--current); font-weight: 600; }
/* Three links beside the logo on the smallest phones. */
@media (max-width: 360px) { .top nav { gap: 0; } .top nav a { padding: 0 5px; } }

main { max-width: 760px; margin: 0 auto; padding: 8px 16px 40px; }
h1, h2 { color: var(--heading); font-weight: 600; }
h1 { font-size: 1.75rem; line-height: 1.25; margin: 16px 0 4px; }
h2 { font-size: 1.25rem; margin: 28px 0 8px; }
h3 { font-size: 1rem; margin: 18px 0 6px; color: var(--ink-2); font-weight: 600; }
.lede { margin: 0 0 12px; color: var(--ink-2); }
.crumb { margin: 12px 0 0; }
.crumb a { text-decoration: none; display: inline-block; padding: 8px 0; }
.muted { color: var(--ink-2); }
.small { font-size: 0.85rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin: 12px 0;
}
.card > :first-child { margin-top: 0; }
.card > :last-child { margin-bottom: 0; }

.search {
  width: 100%;
  font: inherit;
  font-size: 16px;
  padding: 12px 14px;
  margin: 8px 0 12px;
  border: 1px solid var(--axis);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
}

.list {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.list li + li { border-top: 1px solid var(--grid); }
.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 56px;
  padding: 10px 14px;
  color: inherit;
  text-decoration: none;
}
a.row:hover { background: var(--accent-wash); }
.who { display: flex; flex-direction: column; min-width: 0; }
.who .sub { color: var(--ink-2); font-size: 0.9rem; }
.chev { color: var(--muted); flex: none; }

/* PB badges: ink text on a red wash, with a red dot to match the charts. */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex: none;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--pb-wash);
  color: var(--ink);
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--pb); flex: none; }

.pb-list { list-style: none; margin: 8px 0 0; padding: 0; }
.pb-list li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 8px 0;
  border-top: 1px solid var(--grid);
}
.pb-list .time { font-weight: 600; font-variant-numeric: tabular-nums; }
.gain { color: var(--ink-2); font-size: 0.9rem; font-variant-numeric: tabular-nums; }

table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { padding: 8px 6px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--grid); }
th { font-size: 0.8rem; font-weight: 600; color: var(--ink-2); }
td.num, th.num { text-align: right; white-space: nowrap; }
.nowrap { white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td .sub { display: block; color: var(--ink-2); font-size: 0.85rem; }
.time-best { font-weight: 600; }

details.meet { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin: 10px 0; }
details.meet > summary {
  cursor: pointer;
  list-style: none;
  padding: 12px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
details.meet > summary::-webkit-details-marker { display: none; }
details.meet > summary .badge { margin-left: auto; }
details.meet > summary::after { content: "▸"; color: var(--muted); }
details.meet[open] > summary::after { content: "▾"; }
details.meet > .body { padding: 0 14px 10px; }

.controls { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 4px; }
.controls label { display: flex; flex-direction: column; font-size: 0.8rem; color: var(--ink-2); gap: 2px; }
select {
  font: inherit;
  font-size: 16px;
  padding: 8px 10px;
  border: 1px solid var(--axis);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  min-height: 44px;
}

.legend { display: flex; flex-wrap: wrap; gap: 4px 16px; align-items: center; font-size: 0.85rem; color: var(--ink-2); margin: 4px 0 8px; }
.key { display: inline-flex; align-items: center; gap: 6px; }
.key-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--pb); display: inline-block; }
.key-line { width: 16px; height: 2px; background: var(--accent); display: inline-block; border-radius: 1px; }

.charts { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 680px) { .charts { grid-template-columns: 1fr 1fr; } }
figure.chart { margin: 0; }
figure.chart figcaption, .board-head { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
figure.chart figcaption strong, .board-head strong { font-size: 0.95rem; }
.board-head { margin: 12px 0 8px; }
.plot { position: relative; margin-top: 6px; touch-action: pan-y; }
.plot svg { display: block; width: 100%; overflow: visible; }
.plot text { font-size: 11px; fill: var(--muted); font-variant-numeric: tabular-nums; }
.tip {
  position: absolute;
  top: 0;
  pointer-events: none;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  border-radius: var(--radius);
  padding: 8px 10px;
  font-size: 0.85rem;
  min-width: 150px;
  max-width: 220px;
  z-index: 2;
}
.tip .tip-head { color: var(--ink-2); margin-bottom: 4px; }
.tip .tip-row { display: flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }
.tip .tip-row strong { min-width: 58px; }
.tip .tip-row span { color: var(--ink-2); }
.tip .tip-key { width: 10px; height: 2px; background: var(--accent); flex: none; }
.tip .tip-key.pb { width: 8px; height: 8px; margin: 0 1px; border-radius: 50%; background: var(--pb); }
.chart details { margin-top: 4px; font-size: 0.9rem; }
.chart details summary { cursor: pointer; color: var(--ink-2); padding: 6px 0; }

.bars { list-style: none; margin: 8px 0 0; padding: 0; }
.bars li { display: grid; grid-template-columns: minmax(96px, 40%) 1fr; gap: 10px; align-items: center; padding: 6px 0; }
.bars .sub { font-size: 0.8rem; }
.bars a { color: inherit; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bars a:hover { text-decoration: underline; }
.bar-track { display: flex; align-items: center; gap: 8px; min-width: 0; }
.bar { height: 16px; background: var(--bar); border-radius: 0 4px 4px 0; flex: none; }
.bar-value { font-size: 0.85rem; color: var(--ink-2); white-space: nowrap; font-variant-numeric: tabular-nums; }

.note { font-size: 0.85rem; color: var(--ink-2); }
.good { color: var(--good); font-weight: 700; }
.std-neo { color: var(--std-neo); }
.std-jr { color: var(--std-jr); }
.std-qc { color: var(--std-qc); }
.foot { max-width: 760px; margin: 0 auto; padding: 16px 16px 40px; color: var(--ink-2); font-size: 0.85rem; border-top: 1px solid var(--border); }
.empty { color: var(--ink-2); font-style: italic; }

.card-title { margin: 0 0 6px; font-size: 1rem; }
h3.card-title { color: var(--ink); padding-top: 8px; }
.table-card { padding: 2px 12px; overflow-x: auto; }  /* a tight table scrolls in its card, not the page */
.charts .card { margin: 0; }
td.rank { width: 2em; color: var(--ink-2); }

.plot .grid { stroke: var(--grid); stroke-width: 1; }
.plot .axis { stroke: var(--axis); stroke-width: 1; }
.plot .cross { stroke: var(--axis); stroke-width: 1; }
.plot .result-line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.plot .dot { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.plot .dot.pb { fill: var(--pb); }
.plot:focus-visible { outline-offset: 4px; border-radius: 4px; }

.toggle { display: inline-flex; flex: none; border: 1px solid var(--axis); border-radius: var(--radius); overflow: hidden; }
.toggle button {
  font: inherit;
  font-size: 0.85rem;
  min-width: 44px;
  min-height: 36px;
  padding: 0 10px;
  border: 0;
  background: var(--surface);
  color: var(--ink-2);
  cursor: pointer;
}
.toggle button + button { border-left: 1px solid var(--axis); }
.toggle button[aria-pressed="true"] { background: var(--accent-wash); color: var(--ink); font-weight: 600; }
.toggle button:disabled { color: var(--muted); cursor: not-allowed; }

.plot .norm-band { fill: var(--muted); opacity: 0.2; }
.plot .norm-line { fill: none; stroke: var(--ink-2); stroke-width: 2; stroke-linejoin: round; }
.key-band { width: 16px; height: 10px; background: var(--muted); opacity: 0.35; display: inline-block; border-radius: 2px; }
.key-dot.blue { background: var(--accent); }
.plot .trend-band { fill: var(--accent); opacity: 0.15; }
.plot .trend-others { fill: none; stroke: var(--ink-2); stroke-width: 1.5; stroke-dasharray: 4 3; }
.key-line.others { height: 0; background: none; border-top: 2px dashed var(--ink-2); }
.plot .trend-band.others { fill: var(--ink-2); opacity: 0.12; }
.pm { color: var(--ink-2); font-size: 0.85rem; }
.tip .tip-key.others { background: var(--ink-2); }
.notes { padding-left: 18px; color: var(--ink-2); font-size: 0.9rem; }
.notes li { margin: 6px 0; }
.season-picker { margin-top: 28px; padding-top: 16px; border-top: 1px solid var(--border); }

.button {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 16px;
  font: inherit;
  font-weight: 600;
  color: var(--on-accent);
  background: var(--accent);
  border: 2px solid var(--accent);
  border-radius: var(--radius);
  text-decoration: none;
  cursor: pointer;
}
.button:hover { filter: brightness(1.1); }
.buttons { display: flex; flex-wrap: wrap; gap: 8px; }

.pin-form { display: flex; gap: 8px; margin: 16px 0 4px; }
.pin-form input {
  width: 8em;
  font: inherit;
  font-size: 16px;
  padding: 0 12px;
  min-height: 44px;
  border: 1px solid var(--axis);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
}

/* Race days: banners on the main pages, bibs, and the coaches' seed tables. */
.banners { display: flex; flex-direction: column; gap: 8px; margin: 12px 0 4px; }
.banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 56px;
  padding: 10px 14px;
  color: var(--ink);
  text-decoration: none;
  background: var(--accent-wash);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
}
.banner:hover { filter: brightness(1.05); }
.banner .sub { color: var(--ink-2); font-size: 0.9rem; }
.bib { color: var(--ink-2); font-size: 0.85rem; white-space: nowrap; }
.button.secondary { color: var(--accent-ink); background: var(--surface); }
table.seeds td, table.seeds th { padding: 6px 4px; }
table.seeds tr.ours td { font-weight: 600; background: var(--accent-wash); }
table.compact td, table.compact th { padding: 5px 6px; }
table.compact td .sub { font-size: 0.8rem; }
table.seeds { font-size: 0.85rem; }
table.seeds td, table.seeds th { padding: 5px 3px; }
table.seeds td.pick { position: relative; line-height: 1.2; }
table.seeds .pick-value, table.seeds .pick-label { display: block; white-space: nowrap; }
table.seeds .pick-label { font-size: 0.75rem; font-weight: 400; color: var(--accent-ink); }
table.seeds .pick-select { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; font-size: 16px; }
table.seeds td.pick:focus-within { outline: 2px solid var(--accent); outline-offset: -2px; }
table.seeds .hit { color: var(--good); }

/* Laptop leaderboard: wider than the page column, centred on it. */
.wide-board { position: relative; left: 50%; transform: translateX(-50%); width: min(1240px, calc(100vw - 48px)); overflow-x: auto; }
.wide-board table { font-size: 0.85rem; }
.wide-board th, .wide-board td { padding: 6px 4px; }
.wide-board th.group { text-align: center; border-bottom: 1px solid var(--axis); }
.wide-board th { vertical-align: bottom; }
.wide-board td a, .wide-board td .sub { white-space: nowrap; }
.wide-board .sorted { background: var(--accent-wash); }
th button.sort { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline dotted; text-underline-offset: 3px; }

/* Lap calculator: for a phone at the rink, gloves on. */
.calc { display: grid; gap: 10px; margin-top: 8px; }
.calc-out { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; text-align: center; }
.calc-answer { margin: 0; font-size: 3.5rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; color: var(--heading); }
.calc-sub { margin: 2px 0 0; color: var(--ink-2); font-size: 0.95rem; }
.calc-answer.laps { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 14px; font-size: 1.9rem; }
.calc-lap { display: inline-flex; flex-direction: column; align-items: center; min-width: 2.6em; }
.calc-lap-n { font-size: 0.75rem; font-weight: 400; color: var(--ink-2); }
.calc-row { display: grid; grid-template-columns: 1fr 72px 72px; gap: 8px; }
.calc-field, .calc-key, .calc-chip {
  font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--axis);
  border-radius: var(--radius); min-height: 60px; cursor: pointer; touch-action: manipulation;
}
.calc-field { display: flex; justify-content: space-between; align-items: center; padding: 0 14px; text-align: left; }
.calc-field[aria-pressed="true"] { border: 3px solid var(--accent); background: var(--accent-wash); }
.calc-label { color: var(--ink-2); font-size: 0.95rem; margin: 0; }
.calc-value { font-size: 1.8rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.calc-value.model { color: var(--ink-2); font-weight: 400; }
.calc-key { font-size: 1.6rem; font-weight: 600; }
.calc-key.small { font-size: 1.15rem; }
.calc-keys { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.calc-keys .calc-key { min-height: 64px; }
.calc-pick { margin: 10px 0 0; }
.calc-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.calc-chip { min-height: 52px; padding: 0 16px; font-size: 1.1rem; }
.calc-chip[aria-pressed="true"] { border: 3px solid var(--accent); background: var(--accent-wash); font-weight: 600; }

/* Meet history: PBs and season bests. */
.table-scroll { overflow-x: auto; }
table.history { font-size: 0.82rem; }
details.meet > .body.table-scroll { padding: 0 4px 10px; }
table.history td, table.history th { padding-left: 3px; padding-right: 3px; }
.hist-pb { background: var(--pb-wash); color: var(--pb); font-weight: 700; }
.hist-sb { font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.hist-key { padding: 1px 5px; border-radius: 4px; }

/* This season so far, on the skater list. */
.season-card { margin: 12px 0; }
.figures { display: flex; gap: 8px; margin: 6px 0 8px; }
.figures > div { flex: 1; background: var(--accent-wash); border-radius: var(--radius); padding: 8px 10px; }
.figures dd { margin: 0; font-size: 1.5rem; font-weight: 700; color: var(--heading); font-variant-numeric: tabular-nums; }
.figures dt { font-size: 0.85rem; color: var(--ink-2); }
.recent { list-style: none; margin: 0; padding: 0; font-size: 0.95rem; }
.recent li { padding: 3px 0; }

/* A race well off the skater's pace that meet (a fall, usually): a grey square at the chart's top edge. */
.plot .dot.slow { fill: var(--muted); stroke: var(--surface); stroke-width: 1.5; }
.key-slow { display: inline-block; width: 9px; height: 9px; background: var(--muted); vertical-align: baseline; }
