/* speed.tdcat.com: "bench instrument", from the mock-up (docs/design.md, Screens). Light only
   for now; the tokens are here so a dark set can follow. Geist comes later, served from here. */
:root {
  --bg: #F5F5F2;
  --panel: #FFFFFF;
  --ink: #141517;
  --ink-2: #565A61;
  --ink-3: #6B6F76;
  --line: #E2E2DC;
  --line-2: #ECECE7;
  --line-3: #CFCFC8;
  --chip: #F0F0EC;
  --warm: #F7F7F4;
  --down: #1F5FD6;
  --up: #E07A2E;
  --warn: #A4471A;
  --sans: Geist, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
}
a { color: var(--ink); }
a:hover { color: var(--down); }
button, input { font: inherit; color: inherit; }
.mono { font-family: var(--mono); }
.hint { font-size: 13px; color: var(--ink-3); margin: 0; }
.grow { flex: 1 1 240px; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
[hidden] { display: none !important; }

/* header */
.top { background: var(--panel); border-bottom: 1px solid var(--line); }
.top-in { max-width: 1120px; margin: 0 auto; padding: 8px 24px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 32px; }
.brand { text-decoration: none; font-weight: 600; font-size: 17px; letter-spacing: -0.01em; min-height: 44px; display: inline-flex; align-items: center; }
.brand span { color: var(--ink-3); font-weight: 400; }
.nav { display: flex; flex-wrap: wrap; gap: 4px; flex: 1 1 auto; }
.nav a { min-height: 44px; display: inline-flex; align-items: center; padding: 0 12px; border-radius: 10px; text-decoration: none; color: var(--ink-2); }
.nav a[aria-current="page"] { background: var(--chip); color: var(--ink); font-weight: 500; }
.where { font-size: 13px; color: var(--ink-2); }

.page { max-width: 1120px; margin: 0 auto; padding: 32px 24px 64px; display: flex; flex-direction: column; gap: 20px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; }

/* settings */
.settings { padding: 20px 24px; display: flex; flex-wrap: wrap; align-items: flex-end; gap: 20px 32px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field.grow { flex: 1 1 280px; }
.field > label, .field > span { font-size: 13px; color: var(--ink-2); font-weight: 500; }
#setup { height: 44px; padding: 0 14px; border: 1px solid var(--line-3); border-radius: 10px; background: var(--panel); font-size: 15px; width: 100%; }
.seg { display: flex; gap: 4px; padding: 4px; border-radius: 12px; background: var(--chip); }
.seg button { min-width: 52px; height: 44px; padding: 0 12px; border: 0; border-radius: 9px; cursor: pointer; font-family: var(--mono); font-size: 15px; background: transparent; color: var(--ink-2); }
.seg button[aria-pressed="true"] { background: var(--panel); color: var(--ink); box-shadow: 0 1px 2px rgba(20, 21, 23, 0.12); }
.seg button:disabled { cursor: default; }
.start { height: 52px; padding: 0 28px; border: 0; border-radius: 26px; cursor: pointer; display: inline-flex; align-items: center; gap: 10px; font-size: 16px; font-weight: 600; color: #FFFFFF; background: var(--ink); }
.start svg { fill: #FFFFFF; }
.start .icon-stop { display: none; }
.start.running { background: var(--ink-2); }
.start.running .icon-stop { display: block; }
.start.running .icon-play { display: none; }
.start:disabled { opacity: 0.4; cursor: default; }
.refs { flex: 1 1 100%; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 24px; padding-top: 12px; border-top: 1px solid var(--line-2); }
.switch { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; font-weight: 500; }
.switch input { width: 18px; height: 18px; margin: 0; accent-color: var(--ink); }
.ref-fields { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.ref-fields label { font-size: 13px; color: var(--ink-2); }
.ref-fields .gap { margin-left: 4px; }
.num { width: 96px; height: 44px; padding: 0 10px; border: 1px solid var(--line-3); border-radius: 10px; background: var(--panel); font-family: var(--mono); font-size: 14px; }
.num:disabled { background: var(--bg); }

.notice { background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--warn); border-radius: 12px; padding: 12px 18px; font-size: 14px; }
.notice code { font-family: var(--mono); font-size: 13px; }

/* progress */
.steps { list-style: none; margin: 0; padding: 0 4px; display: flex; flex-wrap: wrap; gap: 8px 28px; font-size: 14px; }
.steps li { display: flex; align-items: center; gap: 8px; color: var(--ink-3); }
.steps li span { width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--line-3); }
.steps li.now { color: var(--ink); font-weight: 600; }
.steps li.now span { border-color: var(--down); }
.steps li.done { color: var(--ink); }
.steps li.done span { background: var(--ink); border-color: var(--ink); }

/* readings */
.readings { display: flex; flex-wrap: wrap; gap: 16px; }
.card { flex: 1 1 300px; min-width: 0; padding: 22px 24px; display: flex; flex-direction: column; gap: 6px; }
.card-head { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 500; }
.swatch { width: 10px; height: 10px; border-radius: 3px; }
.swatch.down { background: var(--down); }
.swatch.up { background: var(--up); }
.ring { width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--ink-2); }
.big { font-size: 64px; font-weight: 500; letter-spacing: -0.03em; line-height: 1.05; font-variant-numeric: tabular-nums; }
.note { font-size: 13px; color: var(--ink-3); }
.sold { font-size: 13px; font-weight: 500; min-height: 19.5px; }
.card-foot { margin-top: 4px; padding-top: 12px; border-top: 1px solid var(--line-2); display: flex; justify-content: space-between; gap: 12px; font-size: 14px; }
.card-foot > span:first-child { color: var(--ink-2); }

/* graphs */
.graphs { display: flex; flex-wrap: wrap; gap: 16px; }
.graph { margin: 0; flex: 1 1 420px; min-width: 0; padding: 18px 20px 14px; display: flex; flex-direction: column; gap: 10px; }
.graph figcaption { display: flex; justify-content: space-between; font-size: 13px; color: var(--ink-2); }
.graph .title { font-weight: 500; color: var(--ink); }
.plot { position: relative; padding-left: 40px; }
.plot svg { display: block; width: 100%; height: 180px; }
.tick { position: absolute; left: 0; transform: translateY(-50%); font-family: var(--mono); font-size: 11px; color: var(--ink-3); }
.tick.t3 { top: 26.7%; }
.tick.t2 { top: 50%; }
.tick.t1 { top: 73.3%; }
.ref-label { position: absolute; right: 4px; transform: translateY(-115%); font-size: 11px; color: var(--ink-2); background: var(--panel); padding: 0 4px; display: none; }
.warm-label { position: absolute; left: 44px; top: 2px; font-size: 11px; color: var(--ink-3); display: none; }
.graph.live .warm-label { display: block; }
svg .warm { fill: var(--warm); }
svg .grid { stroke: var(--line-2); stroke-width: 1px; vector-effect: non-scaling-stroke; }
svg .axis { stroke: var(--line-3); stroke-width: 1px; vector-effect: non-scaling-stroke; }
svg .ref { stroke: var(--ink-3); stroke-width: 1px; stroke-dasharray: 3 4; vector-effect: non-scaling-stroke; display: none; }
svg .line { fill: none; stroke-width: 2px; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
svg .line.down { stroke: var(--down); }
svg .line.up { stroke: var(--up); }
.lat { display: flex; align-items: center; gap: 12px; padding-left: 40px; font-size: 12px; color: var(--ink-3); }
.lat > span:first-child { white-space: nowrap; }
.lat svg { display: block; flex: 1 1 auto; height: 32px; min-width: 0; }
svg .lat-line { fill: none; stroke: var(--ink-2); stroke-width: 1.5px; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.lat-scale { font-size: 11px; white-space: nowrap; min-width: 64px; text-align: right; }

/* the result */
.result { display: flex; flex-direction: column; gap: 16px; }
.grade-panel { padding: 20px 24px; display: flex; flex-wrap: wrap; align-items: center; gap: 12px 32px; }
.grade-box .big { font-size: 52px; line-height: 1.1; }
.grade-box .unit { font-size: 15px; color: var(--ink-3); }
.grade-note { margin: 0; flex: 1 1 320px; color: var(--ink-2); font-size: 14px; max-width: 640px; }
.table-panel { padding: 20px 24px; display: flex; flex-direction: column; gap: 12px; }
.table-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 4px 16px; }
h2 { margin: 0; font-size: 16px; font-weight: 600; }
.scroll { overflow-x: auto; }
table.streams { width: 100%; min-width: 560px; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
table.streams th { text-align: left; color: var(--ink-2); font-size: 13px; font-weight: 500; padding: 8px; border-bottom: 1px solid var(--line); }
table.streams th:first-child, table.streams td:first-child { padding-left: 0; }
table.streams th:last-child, table.streams td:last-child { padding-right: 0; }
table.streams .r { text-align: right; }
table.streams .bar-col { width: 30%; position: relative; }
table.streams tbody, table.streams tfoot { font-family: var(--mono); font-size: 13px; }
table.streams td { padding: 7px 8px; border-bottom: 1px solid var(--line-2); }
table.streams tfoot td { border-bottom: 0; padding-top: 9px; font-weight: 500; }
table.streams tfoot td:first-child { font-family: var(--sans); }
.bar { display: block; height: 6px; border-radius: 3px; }
.bar.down { background: var(--down); }
.bar.up { background: var(--up); }
.ends { display: flex; flex-wrap: wrap; gap: 16px; }
.end { flex: 1 1 360px; min-width: 0; padding: 20px 24px; display: flex; flex-direction: column; gap: 10px; }
.kv { margin: 0; display: grid; grid-template-columns: minmax(120px, auto) 1fr; gap: 8px 16px; font-size: 14px; }
.kv dt { color: var(--ink-2); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.kv .mono { font-size: 13px; }
.kv .warn { color: var(--warn); }

.foot { margin: 8px 4px 0; font-size: 13px; color: var(--ink-3); max-width: 720px; }

@media (max-width: 640px) {
  .top-in { padding: 4px 16px; gap: 0 16px; }
  .page { padding: 20px 16px 48px; gap: 16px; }
  .settings, .card, .table-panel, .end, .grade-panel { padding: 16px; }
  .graph { padding: 14px 14px 10px; }
  .big { font-size: 48px; }
  .start { width: 100%; justify-content: center; }
}
