@font-face {
  font-family: 'Geist';
  src: url('vendor/geist-latin-wght-normal.woff2') format('woff2-variations');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

/* One palette, one accent. Status colours are semantic state, not decoration.
   Radius scale: containers 14, insets 10, interactive full. */
:root {
  --bg:        #070c10;
  --panel:     #0f171d;
  --panel-2:   #0b1116;
  --inset:     #060d11;
  --line:      #1b2831;
  --line-soft: #14202a;

  --text:      #e6edf2;
  --muted:     #8494a1;
  --muted-2:   #5e6e7a;

  --accent:    #4db4d8;
  --ok:        #4fb286;
  --warn:      #d49a4c;
  --bad:       #cf6670;

  --r-box:     14px;
  --r-inset:   10px;

  --gutter:    16px;
  --shell:     1180px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px var(--gutter) 24px;
  background: var(--bg);
  color: var(--text);
  font-family: 'Geist', ui-sans-serif, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  font-feature-settings: 'ss01';
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

.topbar, main, footer {
  width: 100%;
  max-width: var(--shell);
  margin: 0 auto;
}

/* ---------------------------------------------------------------- topbar */

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 14px;
}

.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }

.brand-mark {
  flex: none;
  width: 9px; height: 25px;
  border-radius: 1px;
  background: linear-gradient(
    #c8323a 0 18%, #eceff2 18% 36%,
    #c8323a 36% 54%, #eceff2 54% 72%,
    #c8323a 72% 100%);
  box-shadow: inset 0 0 0 1px #2b3a45;
}

.topbar h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 550;
  letter-spacing: -0.012em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chips { display: flex; flex-wrap: wrap; gap: 7px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px 5px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-2);
  font-size: 11.5px;
  font-weight: 560;
  letter-spacing: 0.045em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}

.chip i {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--muted-2);
  flex: none;
}

.chip[data-state="ok"]     { color: #a6d9c1; border-color: #22483a; }
.chip[data-state="ok"] i   { background: var(--ok); }
.chip[data-state="warn"]   { color: #e5c894; border-color: #453518; }
.chip[data-state="warn"] i { background: var(--warn); }
.chip[data-state="bad"]    { color: #e3b0b6; border-color: #452228; }
.chip[data-state="bad"] i  { background: var(--bad); }
.chip[data-state="wait"] i { animation: blink 1.5s ease-in-out infinite; }

@keyframes blink { 0%, 100% { opacity: .28; } 50% { opacity: 1; } }

/* ------------------------------------------------------------------ main */

main {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 400px) minmax(0, 1fr);
  gap: 14px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--r-box);
  background: var(--panel);
}

.gauge-panel {
  padding: 9px;
  background: var(--panel-2);
  display: flex;
}

#gauge {
  display: block;
  width: 100%;
  height: auto;
  max-height: min(66vh, 600px);
  margin: auto;
}

/* --------------------------------------------------------------- readout */

.readout {
  padding: 20px 24px 22px;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.readout-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 30px;
}

.field-label,
.meta dt {
  margin: 0;
  font-size: 11px;
  font-weight: 560;
  letter-spacing: 0.085em;
  text-transform: uppercase;
  color: var(--muted-2);
}

/* Segmented datum switch. The explicit [hidden] rule matters: a class-level
   display would otherwise outrank the UA stylesheet's [hidden] { display: none }
   and the switch would show even with no datum configured. */
.seg[hidden] { display: none; }

.seg {
  display: inline-flex;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--inset);
}

.seg button {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 5px 14px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12.5px;
  font-weight: 520;
  cursor: pointer;
  transition: color 140ms ease, background-color 140ms ease, transform 90ms ease;
}

.seg button:hover { color: var(--text); }
.seg button:active { transform: scale(.97); }

.seg button[aria-pressed="true"] {
  background: #1a2a34;
  color: var(--text);
  box-shadow: inset 0 0 0 1px #274050;
}

.seg button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.big {
  margin: 8px 0 0;
  font-size: clamp(56px, 9.5vw, 96px);
  font-weight: 200;
  line-height: .95;
  letter-spacing: -0.038em;
  font-variant-numeric: tabular-nums;
}

.big .unit {
  margin-left: 11px;
  font-size: 0.24em;
  font-weight: 560;
  letter-spacing: 0.02em;
  color: var(--muted);
}

.big-sub {
  margin: 8px 0 0;
  font-size: 16px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.meta {
  margin: 26px 0 0;
  padding: 18px 0 0;
  border-top: 1px solid var(--line-soft);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(136px, 1fr));
  gap: 18px 20px;
}

.meta dd {
  margin: 5px 0 0;
  font-size: 16.5px;
  font-variant-numeric: tabular-nums;
}

.meta dd.sub {
  margin-top: 2px;
  font-size: 12.5px;
  color: var(--muted);
}

.meta .rising  { color: var(--accent); }
.meta .falling { color: var(--text); }

.hint {
  margin: auto 0 0;
  padding-top: 22px;
  max-width: 62ch;
  font-size: 13px;
  color: var(--muted-2);
}

.hint.alert { color: var(--warn); }
.hint.error { color: var(--bad); }

/* ---------------------------------------------------------------- footer */

footer { display: flex; flex-direction: column; gap: 10px; }

details {
  border: 1px solid var(--line);
  border-radius: var(--r-box);
  background: var(--panel-2);
}

summary {
  padding: 11px 15px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 560;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}

summary:hover { color: var(--text); }
summary:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: var(--r-box); }

.dbg {
  padding: 2px 15px 15px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px 20px;
  border-top: 1px solid var(--line-soft);
}

.dbg .wide { grid-column: 1 / -1; }

.dbg span {
  display: block;
  margin: 11px 0 4px;
  font-size: 10.5px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted-2);
}

.dbg code, .dbg pre {
  margin: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
  color: #aec1cf;
  word-break: break-all;
}

.dbg pre {
  padding: 10px 12px;
  border: 1px solid var(--line-soft);
  border-radius: var(--r-inset);
  background: var(--inset);
  white-space: pre-wrap;
  max-height: 150px;
  overflow: auto;
}

.foot-note {
  margin: 0;
  padding-left: 2px;
  font-size: 12.5px;
  color: var(--muted-2);
}

/* ------------------------------------------------------------- svg gauge */

.board-face  { fill: url(#gradBoard); }
.board-cap   { fill: #aeb9c2; }
.board-shade { fill: #04121a; opacity: .5; }
.board-mark  { fill: #c8323a; }

.board-tick        { stroke: #5a6a75; stroke-width: 1; }
.board-tick.major  { stroke: #2d3b45; stroke-width: 1.4; }
.board-num         { fill: #3f4e59; font-size: 12.5px; font-weight: 640; text-anchor: end; }
.board-num.minor   { fill: #76848e; font-size: 10px; font-weight: 560; }

.water,
.marker { transition: transform 1000ms cubic-bezier(.22, .68, .28, 1), opacity 650ms ease; }

.wave-back  { fill: url(#gradWaterSoft); animation: driftB 13s linear infinite; }
.wave-front { fill: url(#gradWater);     animation: driftA  9s linear infinite; }
.wave-line  { fill: none; stroke: #9adcf1; stroke-width: 1.5; stroke-opacity: .8; animation: driftA 9s linear infinite; }

@keyframes driftA { to { transform: translateX(-100px); } }
@keyframes driftB { to { transform: translateX(-140px); } }

.marker-line { stroke: #9adcf1; stroke-width: 1; stroke-dasharray: 3 4; stroke-opacity: .55; }
.marker-pill { fill: #0c2129; stroke: #2a7690; stroke-width: 1; }
.marker-text { fill: #c6ebf7; font-size: 14.5px; font-weight: 560; font-variant-numeric: tabular-nums; }

.board-num, .board-num.minor, .marker-text { font-family: 'Geist', ui-sans-serif, sans-serif; }

.gauge-idle .water,
.gauge-idle .marker { opacity: 0; }

.gauge-stale .wave-front,
.gauge-stale .wave-back,
.gauge-stale .wave-line { animation-play-state: paused; }
.gauge-stale .water { opacity: .45; }

/* ------------------------------------------------------------ responsive */

/* md: gauge and readout stop fitting side by side. */
/* Stacked, keeping the desktop reading order: gauge first, then the numbers.
   The gauge is capped so the reading and the first meta row stay on the
   first screen of a phone. */
@media (max-width: 880px) {
  main { grid-template-columns: minmax(0, 1fr); }
  .readout { padding: 17px 18px 20px; }
  /* Size the scene from its height and let the panel shrink-wrap it. Capping
     height on a full-width SVG instead letterboxes the drawing, leaving the
     water as a narrow strip inside a wide empty panel. */
  .gauge-panel { width: fit-content; max-width: 100%; margin: 0 auto; }
  #gauge { width: auto; height: min(48vh, 460px); max-width: 100%; max-height: none; }
  .meta { margin-top: 20px; padding-top: 16px; }
  .hint { padding-top: 16px; }
}

/* sm: single column of meta pairs, tighter shell. */
@media (max-width: 640px) {
  :root { --gutter: 13px; }
  body { padding-top: 14px; gap: 11px; }
  .topbar { row-gap: 9px; }
  .big { font-size: clamp(50px, 15vw, 72px); }
  .big .unit { margin-left: 8px; }
  .meta { grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: 14px 16px; margin-top: 17px; padding-top: 14px; }
  .meta dd { font-size: 15.5px; }
  #gauge { height: min(44vh, 400px); }
}

@media (max-width: 400px) {
  .chip { padding: 4px 10px 4px 8px; font-size: 10.5px; }
  .readout-head { min-height: 28px; }
  .dbg { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .water, .marker { transition: none; }
  .wave-back, .wave-front, .wave-line, .chip i { animation: none; }
  .seg button { transition: none; }
}
