:root {
  --bg: #edf1f5;
  --panel: #f7f9fb;
  --ink: #13233a;
  --muted: #5a6a7e;
  --line: #c9d3de;
  --v4: #0e7c7b;
  --v6: #a86a12;
  --focus: #2f6fd6;
  --led: #16a34a;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1826; --panel: #13202f; --ink: #e4ebf3; --muted: #8fa0b5;
    --line: #26384e; --v4: #2bb3a8; --v6: #e3a03a; --focus: #7aa7ff; --led: #34d27b;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1826; --panel: #13202f; --ink: #e4ebf3; --muted: #8fa0b5;
  --line: #26384e; --v4: #2bb3a8; --v6: #e3a03a; --focus: #7aa7ff; --led: #34d27b;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 var(--sans);
  font-variant-numeric: tabular-nums;
}
main, .top, .foot { width: min(1040px, 100% - 32px); margin-inline: auto; }
a { color: inherit; text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* header */
.top {
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between;
  gap: 4px 24px; padding: 20px 0 0;
}
.brand { font-size: 1.05rem; font-weight: 650; letter-spacing: -0.01em; margin: 0; }
.server { margin: 0; color: var(--muted); font-size: 0.9rem; }

/* stage: gauge on the left, timeline and controls on the right */
.stage {
  display: grid; grid-template-columns: minmax(300px, 440px) 1fr;
  gap: 24px 48px; align-items: center; padding: 32px 0 8px;
}
.side { min-width: 0; }
#phase { margin: 0; color: var(--muted); min-height: 3em; }

/* the dial */
.gauge { position: relative; width: 100%; max-width: 440px; justify-self: center; }
.gauge[data-fam="v4"] { --cur: var(--v4); }
.gauge[data-fam="v6"] { --cur: var(--v6); }
.gauge { --cur: var(--ink); }
#dial { display: block; width: 100%; height: auto; overflow: visible; }
#dial .track { stroke: var(--line); }
#dial .fill { stroke: var(--cur); }
#dial .glow { stroke: var(--cur); opacity: 0.16; }
#dial .head { fill: var(--bg); stroke: var(--cur); }
#dial .peakmark { stroke: var(--cur); }
#dial .prog-track { stroke: var(--line); opacity: 0.6; }
#dial .prog { stroke: var(--muted); }
#dial .tick { stroke: var(--muted); }
#dial .tick.minor { opacity: 0.45; }
#dial .lbl { fill: var(--muted); font: 500 11.5px var(--sans); text-anchor: middle; dominant-baseline: middle; }
#dial .lbl.lit { fill: var(--ink); }
#dial .idle { opacity: 0; transition: opacity 0.3s; }
.gauge.live #dial .idle { opacity: 1; }

.dial-center {
  position: absolute; left: 50%; top: 59%; transform: translate(-50%, -50%);
  text-align: center; width: 62%; pointer-events: none;
}
.dial-center p { margin: 0; }
.dial-mode { color: var(--muted); font-size: 0.9rem; font-weight: 500; }
.dial-value { line-height: 1; margin-top: 6px !important; white-space: nowrap; }
#value {
  font-size: clamp(2.8rem, 10vw, 4.4rem); font-weight: 250; letter-spacing: -0.04em;
  color: var(--cur);
}
#unit { font-size: 1.05rem; font-weight: 500; color: var(--muted); }
.dial-peak { margin-top: 8px !important; color: var(--muted); font-size: 0.82rem; min-height: 1.3em; }

/* protocol lights */
.protos {
  position: absolute; left: 50%; bottom: 0; transform: translateX(-50%);
  display: flex; gap: 6px; margin: 0; padding: 0; list-style: none; white-space: nowrap;
}
.protos li {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 9px 4px 8px; border: 1px solid var(--line); border-radius: 999px;
  font-size: 0.75rem; font-weight: 550; color: var(--muted);
  transition: color 0.25s, border-color 0.25s, background-color 0.25s;
}
.protos i {
  width: 7px; height: 7px; border-radius: 50%; background: var(--line);
  transition: background-color 0.25s, box-shadow 0.25s;
}
.protos li.used { color: var(--ink); }
.protos li.used i { background: color-mix(in srgb, var(--led) 45%, var(--line)); }
.protos li.on { color: var(--ink); border-color: color-mix(in srgb, var(--led) 55%, var(--line)); background: color-mix(in srgb, var(--led) 9%, transparent); }
.protos li.on i { background: var(--led); box-shadow: 0 0 0 3px color-mix(in srgb, var(--led) 25%, transparent), 0 0 10px var(--led); }

.trace-wrap { margin-top: 18px; }
#trace {
  display: block; width: 100%; height: 180px;
  border-bottom: 1px solid var(--line);
}
.legend {
  display: flex; flex-wrap: wrap; gap: 4px 18px;
  margin: 8px 0 0; padding: 0; list-style: none;
  color: var(--muted); font-size: 0.82rem;
}
.lg i { display: inline-block; width: 18px; height: 0; margin-right: 6px; vertical-align: middle; border-top: 3px solid; }
.lg.v4 i { border-color: var(--v4); }
.lg.v6 i { border-color: var(--v6); }
.lg.dl i { border-color: var(--muted); }
.lg.ul i { border-top-style: dashed; border-color: var(--muted); }

.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 16px 28px; margin-top: 24px; }
#start {
  font: inherit; font-weight: 600; font-size: 1.05rem;
  padding: 14px 34px; border: 0; border-radius: 6px;
  background: var(--ink); color: var(--bg); cursor: pointer;
}
#start:hover:not(:disabled) { opacity: 0.88; }
#start:disabled { opacity: 0.45; cursor: default; }
.families { display: flex; gap: 20px; border: 0; margin: 0; padding: 0; }
.families label { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.families input { width: 18px; height: 18px; margin: 0; accent-color: var(--ink); }
.families label:has(input:disabled) { color: var(--muted); cursor: default; }

/* lanes: one column per protocol */
.lanes {
  display: grid; grid-template-columns: 1fr 1fr;
  margin-top: 48px; border-top: 1px solid var(--line);
}
.lane { padding: 24px 32px 28px 0; position: relative; }
.lane + .lane { padding: 24px 0 28px 32px; border-left: 1px solid var(--line); }
.lane::before {
  content: ""; position: absolute; top: -1px; height: 4px; width: 56px;
  background: var(--v4);
}
.lane + .lane::before { left: 32px; }
.lane[data-fam="v6"]::before { background: var(--v6); }
.lane h2 { margin: 0 0 10px; font-size: 1.35rem; font-weight: 650; letter-spacing: -0.01em; }
.lane p { margin: 0; }
.addr { font-family: var(--mono); font-size: 0.98rem; overflow-wrap: anywhere; }
.net, .loc, .via { color: var(--muted); font-size: 0.92rem; }
.lane.off .addr { font-family: var(--sans); color: var(--muted); }
.lane.off .metrics { opacity: 0.4; }
.lane.active h2::after {
  content: "testing"; margin-left: 10px; font-size: 0.8rem; font-weight: 500;
  color: var(--muted); vertical-align: 0.2em;
}

.metrics {
  display: grid; grid-template-columns: 1fr 1fr; gap: 18px 24px;
  margin: 24px 0 0;
}
.metrics dt { color: var(--muted); font-size: 0.85rem; }
.metrics dd { margin: 2px 0 0; font-size: 1.6rem; font-weight: 350; letter-spacing: -0.02em; line-height: 1.2; }
.metrics dd small { font-size: 0.85rem; font-weight: 450; color: var(--muted); letter-spacing: 0; margin-left: 3px; }
.metrics dd .note { display: block; margin: 2px 0 0; font-size: 0.78rem; }

/* explainer + footer */
.about { margin-top: 40px; padding: 16px 0; border-top: 1px solid var(--line); color: var(--muted); max-width: 68ch; }
.about summary { cursor: pointer; color: var(--ink); font-weight: 550; }
.about p { margin: 10px 0 0; font-size: 0.93rem; }
.foot { padding: 24px 0 40px; color: var(--muted); font-size: 0.82rem; }
.foot p { margin: 0; max-width: 68ch; }

@media (max-width: 860px) {
  .stage { grid-template-columns: 1fr; padding-top: 20px; }
  .gauge { max-width: 400px; }
}
@media (max-width: 720px) {
  #trace { height: 140px; }
  .lanes { grid-template-columns: 1fr; margin-top: 36px; }
  .lane, .lane + .lane { padding: 24px 0; border-left: 0; }
  .lane + .lane { border-top: 1px solid var(--line); }
  .lane + .lane::before { left: 0; }
  #start { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .protos li, .protos i, #dial .idle { transition: none; }
}
