:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #eef1f5;
  --ink: #10151c;
  --ink-2: #4c5765;
  --ink-3: #78838f;
  --line: #dfe4ea;
  --accent: #1f5fa5;
  --live: #12793f;
  --live-bg: #e3f3e9;
  --warn: #9a5b06;
  --warn-bg: #fbeed8;
  --off: #5a6472;
  --off-bg: #e6e9ed;
  --radius: 12px;
  --max: 900px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1319;
    --surface: #161d26;
    --surface-2: #1e2732;
    --ink: #eef2f6;
    --ink-2: #aab4c0;
    --ink-3: #7b8794;
    --line: #2a3440;
    --accent: #6aa8e4;
    --live: #4dd08a;
    --live-bg: #10301f;
    --warn: #f0b44e;
    --warn-bg: #33270f;
    --off: #8a949f;
    --off-bg: #222a34;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 0 16px 48px;
  background: var(--bg);
  color: var(--ink);
  font: 400 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-variant-numeric: tabular-nums;
  -webkit-text-size-adjust: 100%;
}

main, .masthead, footer, .banner { max-width: var(--max); margin-inline: auto; }

.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

/* Masthead ---------------------------------------------------------------- */

.masthead {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; padding: 20px 0 16px; border-bottom: 1px solid var(--line);
}
h1 { margin: 0; font-size: 20px; font-weight: 600; letter-spacing: -0.01em; }
.place { margin: 2px 0 0; color: var(--ink-2); font-size: 14px; }

.pill {
  display: inline-flex; align-items: center; gap: 7px; flex: none;
  padding: 5px 12px; border-radius: 999px;
  font-size: 13px; font-weight: 500; white-space: nowrap;
}
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.pill-live { background: var(--live-bg); color: var(--live); }
.pill-delayed { background: var(--warn-bg); color: var(--warn); }
.pill-offline, .pill-loading, .pill-error { background: var(--off-bg); color: var(--off); }
.pill-live .dot { animation: pulse 2.4s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
@media (prefers-reduced-motion: reduce) { .pill-live .dot { animation: none; } }

/* Banner ------------------------------------------------------------------ */

.banner {
  margin-top: 12px; padding: 10px 14px; border-radius: var(--radius);
  background: var(--warn-bg); color: var(--warn); font-size: 14px;
}

/* Hero -------------------------------------------------------------------- */

.hero {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 24px 0 8px;
}
.dial-wrap { width: min(260px, 72vw); }
.dial { display: block; width: 100%; }
#dial { width: 100%; height: auto; }
.dial-face { fill: var(--surface); stroke: var(--line); stroke-width: 1.5; }
.dial-inner { fill: none; stroke: var(--line); stroke-width: 1; }
.dial-ticks line { stroke: var(--ink-3); stroke-width: 1; }
.dial-rose { fill: var(--ink-3); font-size: 11px; font-weight: 500; }
.needle-shape { fill: var(--accent); }
.needle-stem { stroke: var(--accent); stroke-width: 2; }
.dial-hub { fill: var(--accent); }
.dial-speed { fill: var(--ink); font-size: 40px; font-weight: 600; letter-spacing: -0.02em; }
.dial-unit { fill: var(--ink-3); font-size: 13px; }

#dial.stale .needle-shape, #dial.stale .needle-stem, #dial.stale .dial-hub { opacity: 0.28; }
#dial.stale .dial-speed { fill: var(--ink-3); }

.readout { text-align: center; }
.direction { margin: 8px 0 0; font-size: 19px; font-weight: 600; }
.beaufort { margin: 2px 0 0; color: var(--ink-2); font-size: 15px; }
.updated { margin: 4px 0 0; color: var(--ink-3); font-size: 13px; }

/* Tiles ------------------------------------------------------------------- */

.tiles {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px; margin: 20px 0;
}
@media (min-width: 620px) { .tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.tile { background: var(--surface); border-radius: var(--radius); padding: 12px 14px; }
.tile-label { margin: 0; font-size: 12px; color: var(--ink-3); }
.tile-value { margin: 3px 0 0; font-size: 21px; font-weight: 600; }

/* Controls ---------------------------------------------------------------- */

.controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 20px; }
.field { display: flex; flex-direction: column; gap: 3px; }
.field-label { font-size: 12px; color: var(--ink-3); }
select, .btn {
  font: inherit; font-size: 14px; padding: 8px 12px;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px; min-height: 40px;
}
.btn { cursor: pointer; }
.btn:hover { background: var(--surface-2); }
.btn-quiet { color: var(--ink-2); }
select:focus-visible, .btn:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

/* Panels ------------------------------------------------------------------ */

.panel {
  background: var(--surface); border-radius: var(--radius);
  padding: 16px; margin-bottom: 16px;
}
.panel h2 {
  margin: 0 0 12px; font-size: 15px; font-weight: 600;
  display: flex; align-items: center; gap: 8px;
}
.mag-tag {
  font-size: 11px; font-weight: 500; color: var(--ink-3);
  border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px;
}
.chart-box { position: relative; width: 100%; }
.chart-speed { height: 220px; }
.chart-dir { height: 150px; }
.note { margin: 10px 0 0; font-size: 12.5px; color: var(--ink-3); }
.empty { margin: 24px 0; text-align: center; color: var(--ink-3); }

/* Rose -------------------------------------------------------------------- */

.rose-box { display: flex; justify-content: center; }
.rose { width: min(340px, 100%); height: auto; }
.rose-ring { fill: none; stroke: var(--line); stroke-width: 1; }
.rose-spoke { stroke: var(--line); stroke-width: 1; }
.rose-ring-label { fill: var(--ink-3); font-size: 9px; }
.rose-cardinal { fill: var(--ink-3); font-size: 12px; font-weight: 500; }
.rose-seg { stroke: var(--surface); stroke-width: 0.75; }

.legend { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 8px; font-size: 12px; color: var(--ink-2); }
.legend-item { display: inline-flex; align-items: center; gap: 5px; }
.legend-swatch { width: 11px; height: 11px; border-radius: 2px; }

/* Footer ------------------------------------------------------------------ */

footer {
  margin-top: 28px; padding-top: 16px; border-top: 1px solid var(--line);
  color: var(--ink-3); font-size: 13px;
}
footer p { margin: 0 0 6px; }
footer strong { color: var(--ink-2); }
.footer-caveat { font-size: 12px; }
