:root {
  --bg: #13100e;
  --bg-2: #17130f;
  --ink: #f2ece2;
  --ink-2: #d8cec1;
  --muted: #baac9d;
  --dim: #a99b8c;
  --line: #33291f;
  --line-2: #423528;
  --line-hover: #574637;
  --bar-top: #171310;
  --panel: #1e1813;
  --panel-2: #191410;
  --hover: #221c16;
  --kbd: #1c1712;
  --chip-bg: rgba(19, 16, 14, 0.6);
  --gauge-fade: rgba(19, 16, 14, 0.92);
  --scene-bg: #1d1814;
  --scenery: #303a32;
  --soil-top: #634a35;
  --soil-bottom: #38291f;
  --surface: #ae8960;
  --level: #b09a83;
  --svg-text: #b09a83;
  --shadow: rgba(0, 0, 0, 0.55);
  --chart-grid: #2b231c;
  --chart-zero: #5c4939;
  --chart-threshold: rgba(239, 95, 60, 0.55);
  --chart-cursor: rgba(242, 236, 226, 0.35);
  --chart-dot: #f2ece2;
  --chart-soil: #c4b6a6;
  --chart-rain: rgba(79, 143, 154, 0.7);
  --chart-band: rgba(239, 95, 60, 0.16);
  --mark-rain: #4f8f9a;
  --rain: #7fa7b0;
  --ok: #63c39b;
  --warn: #e6a94f;
  --bad: #ef5f3c;
  --stale-ink: #f3c7a0;
  --stale-bg: rgba(66, 33, 20, 0.88);
  --stale-line: rgba(239, 95, 60, 0.45);
  --backdrop: rgba(8, 6, 5, 0.72);
  --state-stable: #63c39b;
  --state-watch: #e6a94f;
  --state-risk: #ef5f3c;
  --state-unknown: #9a8f84;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sig: #9a8f84;
  --sig-tint: #ffffff;
  color-scheme: dark;
}

html[data-theme="light"] {
  --bg: #f6f1e9;
  --bg-2: #ece5d9;
  --ink: #1b1611;
  --ink-2: #3f342a;
  --muted: #5e5245;
  --dim: #746657;
  --line: #ded3c3;
  --line-2: #c9bba8;
  --line-hover: #b6a58f;
  --bar-top: #fbf7f0;
  --panel: #fbf7f0;
  --panel-2: #f3ede3;
  --hover: #e9e0d3;
  --kbd: #efe7da;
  --chip-bg: rgba(255, 253, 249, 0.58);
  --gauge-fade: rgba(246, 241, 233, 0.92);
  --scene-bg: #ece4d7;
  --scenery: #d3ddcd;
  --soil-top: #dcc7ab;
  --soil-bottom: #cdb695;
  --surface: #96795a;
  --level: #8a7762;
  --svg-text: #6d5b46;
  --shadow: rgba(70, 50, 30, 0.18);
  --chart-grid: #e2d8ca;
  --chart-zero: #b3a390;
  --chart-threshold: rgba(185, 58, 28, 0.65);
  --chart-cursor: rgba(27, 22, 17, 0.35);
  --chart-dot: #1b1611;
  --chart-soil: #8a6a45;
  --chart-rain: rgba(47, 109, 117, 0.55);
  --chart-band: rgba(185, 58, 28, 0.14);
  --mark-rain: #2f6d75;
  --rain: #5e8790;
  --ok: #237a56;
  --warn: #9a6413;
  --bad: #b93a1c;
  --stale-ink: #7a3312;
  --stale-bg: rgba(244, 222, 199, 0.95);
  --stale-line: rgba(185, 58, 28, 0.35);
  --backdrop: rgba(60, 50, 40, 0.5);
  --state-stable: #237a56;
  --state-watch: #8f5c10;
  --state-risk: #b93a1c;
  --state-unknown: #6e6257;
  --sig: #7c7064;
  --sig-tint: #000000;
  color-scheme: light;
}

body[data-state="STABLE"] { --sig: #63c39b; }
body[data-state="WATCH"] { --sig: #e6a94f; }
body[data-state="MOVEMENT_RISK"] { --sig: #ef5f3c; }
body[data-state="CRITICAL"] { --sig: #ff4438; }
body[data-state="UNKNOWN"] { --sig: #9a8f84; }
html[data-theme="light"] body[data-state="STABLE"] { --sig: #237a56; }
html[data-theme="light"] body[data-state="WATCH"] { --sig: #8f5c10; }
html[data-theme="light"] body[data-state="MOVEMENT_RISK"] { --sig: #b93a1c; }
html[data-theme="light"] body[data-state="CRITICAL"] { --sig: #b0241c; }
html[data-theme="light"] body[data-state="UNKNOWN"] { --sig: #6e6257; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
  font: 14px/1.5 var(--sans);
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--sig); color: var(--bg); }

*:focus-visible {
  outline: 2px solid var(--sig);
  outline-offset: 2px;
  border-radius: 2px;
}

.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip {
  position: absolute; left: 12px; top: -40px; z-index: 20;
  background: var(--ink); color: var(--bg); padding: 8px 12px; text-decoration: none;
}
.skip:focus { top: 10px; }

/* ---------- top bar ---------- */

.bar {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 20px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(var(--bar-top), var(--bg));
}
.brand { display: flex; align-items: baseline; gap: 14px; min-width: 0; }
.brand-mark {
  font: 600 13px/1 var(--sans);
  letter-spacing: 0.2em;
  text-transform: uppercase;
}
.brand-sub {
  font: 12px/1 var(--sans);
  letter-spacing: 0.03em;
  color: var(--dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  opacity: 0;
  transition: opacity 160ms ease;
}
.brand:hover .brand-sub,
.brand:focus-within .brand-sub { opacity: 1; }
.bar-meta { margin-left: auto; display: flex; align-items: center; gap: 18px; font-size: 12px; color: var(--muted); }
.chip {
  border: 1px solid var(--line-2);
  padding: 3px 8px;
  border-radius: 2px;
  letter-spacing: 0.06em;
  color: var(--ink-2);
}
.ingest { display: inline-flex; align-items: center; gap: 7px; letter-spacing: 0.04em; }
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--dim); flex: 0 0 auto; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 14%, transparent); }
.dot.off { background: var(--bad); }
#clock { color: var(--ink-2); letter-spacing: 0.04em; }

/* ---------- buttons ---------- */

button {
  font: 500 11px/1 var(--sans);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-2);
  background: transparent;
  border: 1px solid var(--line-2);
  border-radius: 2px;
  padding: 8px 12px;
  cursor: pointer;
  transition: background-color 120ms ease, color 120ms ease, border-color 120ms ease;
}
button:hover { background: var(--hover); color: var(--ink); border-color: var(--line-hover); }
button:active { transform: translateY(1px); }
button:disabled { opacity: 0.45; cursor: progress; }
button.primary {
  border-color: var(--sig);
  color: var(--bg);
  background: var(--sig);
}
button.primary:hover { background: color-mix(in oklab, var(--sig) 86%, var(--sig-tint)); border-color: var(--sig); }
button.ghost { border-color: transparent; color: var(--muted); }
button.ghost:hover { border-color: var(--line-2); color: var(--ink); }
kbd {
  font: 10px/1 var(--mono);
  border: 1px solid var(--line-2);
  border-bottom-width: 2px;
  border-radius: 3px;
  padding: 2px 4px;
  color: var(--ink-2);
  background: var(--kbd);
}

/* ---------- shell ---------- */

.shell {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(340px, 1fr);
  grid-template-rows: minmax(0, 1fr) auto;
}
.scene { grid-column: 1; grid-row: 1; }
.rail { grid-column: 2; grid-row: 1; }
.strip { grid-column: 1 / -1; grid-row: 2; }

/* ---------- scene ---------- */

.scene {
  position: relative;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  color: var(--sig);
  border-right: 1px solid var(--line);
  background: radial-gradient(120% 90% at 70% 10%, var(--scene-bg) 0%, var(--bg) 70%);
}
#slope { order: 1; flex: 1 1 0; min-height: 0; width: 100%; display: block; }
.scenery { fill: var(--scenery); pointer-events: none; }
.svg-label {
  font: 12px var(--sans);
  letter-spacing: 0.04em;
  fill: var(--svg-text);
  pointer-events: none;
}
.node-tag { font-size: 14px; font-weight: 600; fill: var(--ink-2); }
.angle-tag { font: 14px var(--mono); fill: var(--sig); }
.sky { pointer-events: none; }
.sky-sun { fill: var(--warn); }
.sun-rays { fill: none; stroke: var(--warn); stroke-width: 2; stroke-linecap: round; opacity: 0.65; }
.sky-moon { fill: var(--level); }
.sensor-parts { opacity: 1; transition: opacity 260ms ease; }
.scene.is-unverified .sensor-parts { opacity: 0.38; }
.sensor-question {
  font: 700 24px var(--sans);
  fill: var(--sig);
  opacity: 0;
  transition: opacity 260ms ease;
}
.scene.is-unverified .sensor-question { opacity: 1; }
.mast {
  transform-box: view-box;
  transform-origin: 0 0; /* Local foot: independent of antenna/head bounds. */
  transition: transform 650ms cubic-bezier(0.16, 1, 0.3, 1);
}
#soil-moving { transform: translate(0, 0) rotate(0deg); transform-box: view-box; transform-origin: 390px 267px; transition: transform 850ms cubic-bezier(0.16, 1, 0.3, 1); }
#slope[data-ground="risk"] #soil-moving { transform: translate(5px, 3px) rotate(1deg); }
#slope[data-ground="critical"] #soil-moving { transform: translate(38px, 24px) rotate(3deg); }
.soil-fixed, .soil-mass { fill: url(#slope-soil); }
.soil-mass { stroke: url(#slope-soil); stroke-width: 1.5; stroke-linejoin: round; }
.crest, .slope-surface { fill: none; stroke: var(--surface); stroke-width: 3; stroke-linecap: round; }
.soil-crack { fill: none; stroke: var(--sig); stroke-width: 2; opacity: 0; }
#slope[data-ground="watch"] .slope-surface { stroke: var(--warn); }
#slope[data-ground="risk"] .slope-surface,
#slope[data-ground="critical"] .slope-surface { stroke: var(--bad); }
#slope[data-ground="risk"] .soil-crack,
#slope[data-ground="critical"] .soil-crack { opacity: 1; }
.sensor { pointer-events: none; }
.sensor-shadow { fill: var(--shadow); }
.sensor-foot { fill: var(--panel-2); stroke: currentColor; stroke-width: 1.5; }
.sensor-move { color: var(--sig); }
.sensor-pole { fill: currentColor; }
.sensor-shine { fill: none; stroke: var(--panel); stroke-width: 1; }
.sensor-anchor { fill: none; stroke: currentColor; stroke-width: 2; }
.sensor-body { fill: var(--panel); stroke: currentColor; stroke-width: 2; }
.sensor-cap { fill: currentColor; }
.sensor-seam, .sensor-vents, .sensor-aerial { fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; }
.sensor-leader { fill: none; stroke: currentColor; stroke-width: 1; }
.sensor-led { fill: currentColor; }
.plumb { fill: none; stroke: var(--level); stroke-width: 1; stroke-dasharray: 3 5; opacity: 0.6; transform-box: view-box; transform-origin: 0 0; transition: transform 650ms cubic-bezier(0.16, 1, 0.3, 1); }
#angle-arc { fill: none; stroke: var(--sig); stroke-width: 2; }

.verdict {
  order: 0;
  flex: 0 0 auto;
  padding: 24px 28px 8px;
  pointer-events: none;
}
.state {
  margin: 0;
  font: 600 34px/1.1 var(--sans);
  letter-spacing: 0.01em;
  color: var(--sig);
  display: flex; align-items: center; gap: 12px;
}
.state::before {
  content: "";
  width: 10px; height: 10px;
  background: var(--sig);
  border-radius: 1px;
  box-shadow: 0 0 18px 0 var(--sig);
}
.sentence {
  margin: 12px 0 0;
  font: italic 17px/1.45 var(--serif);
  color: var(--ink-2);
  max-width: 34ch;
  text-wrap: balance;
}
.reasons { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; margin: 14px 0 0; padding: 0; }
.reasons li {
  font: 12px/1.2 var(--mono);
  letter-spacing: 0.06em;
  color: var(--muted);
  border: 1px solid var(--line-2);
  padding: 4px 6px;
  border-radius: 2px;
  background: var(--chip-bg);
}

.gauges {
  order: 3;
  flex: 0 0 auto;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  padding: 20px 28px 18px;
  border-top: 1px solid var(--line);
  background: linear-gradient(transparent, var(--gauge-fade) 46%);
}
.gauges div { min-width: 0; }
.gauges dt {
  font: 12px/1 var(--sans);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--dim);
  margin-bottom: 8px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.gauges dd {
  margin: 0;
  font: 500 22px/1 var(--mono);
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  white-space: nowrap;
}

.scene-note {
  order: 2;
  flex: 0 0 auto;
  margin: 0 28px 14px;
  font: 12px/1.5 var(--sans);
  letter-spacing: 0.03em;
  color: var(--dim);
  pointer-events: none;
}
.stale {
  order: -1;
  flex: 0 0 auto;
  z-index: 3;
  margin: 0;
  padding: 8px 28px;
  font: 12px/1.5 var(--mono);
  letter-spacing: 0.03em;
  color: var(--stale-ink);
  background: var(--stale-bg);
  border-bottom: 1px solid var(--stale-line);
}
.scene.is-stale #slope { filter: saturate(0.55); }

/* ---------- rail ---------- */

.rail {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px 22px 6px;
  display: flex;
  flex-direction: column;
}
.block { padding: 0 0 14px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.block:last-child { border-bottom: 0; margin-bottom: 0; }
.block h2 {
  display: flex; align-items: baseline; gap: 10px;
  margin: 0 0 12px;
  font: 600 11px/1 var(--sans);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.hsub {
  margin-left: auto;
  font: 12px/1 var(--mono);
  letter-spacing: 0.03em;
  text-transform: none;
  color: var(--dim);
}
.chart-legend {
  list-style: none;
  display: flex; flex-wrap: wrap; gap: 8px 14px;
  margin: 0 0 8px; padding: 0;
  font: 11px/1.3 var(--mono);
  color: var(--dim);
}
.chart-legend li { display: inline-flex; align-items: center; gap: 6px; }
.sw { display: inline-block; width: 18px; border-top: 2px solid transparent; }
.sw-tilt { border-color: var(--sig); }
.sw-threshold { border-top-style: dashed; border-color: var(--chart-threshold); }
.sw-cursor { border-top-style: dotted; border-color: var(--chart-cursor); }
.sw-rain { width: 8px; height: 8px; border: 0; background: var(--chart-rain); }
.sw-soil { border-color: var(--chart-soil); }
.sw-band { border-top-width: 8px; border-color: var(--chart-band); }
canvas { display: block; width: 100%; }
#chart-tilt { height: 150px; }
#chart-load { height: 118px; }
#chart-forecast { height: 118px; }
.chart-note {
  margin: 8px 0 0;
  font: 12px/1.6 var(--mono);
  letter-spacing: 0.03em;
  color: var(--dim);
  min-height: 1.6em;
  opacity: 0;
  transition: opacity 160ms ease;
}
.block:hover .chart-note,
.block:focus-within .chart-note { opacity: 1; }
.chart-note b { color: var(--sig); font-weight: 500; }

.weather-note { margin: 6px 0; font-size: 0.8125rem; line-height: 1.45; color: var(--ink-2); }
#weather-status { font-weight: 600; overflow-wrap: anywhere; }
.weather-table { margin-top: 10px; }
.weather-table :is(th, td) + :is(th, td) { padding-inline-start: 8px; }
.weather-table :is(th, td):nth-child(n+3) { text-align: right; }
.weather-table td:nth-child(2) { font-family: var(--sans); overflow-wrap: anywhere; }

.site-config { margin-top: 10px; padding-top: 9px; border-top: 1px solid var(--line); }
.site-config summary { cursor: pointer; font: 600 11px/1 var(--sans); letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.site-config summary:hover { color: var(--ink); }
.site-config[open] summary { margin-bottom: 9px; }
.site-config label { display: block; margin-bottom: 6px; font: 11px/1.3 var(--sans); color: var(--ink-2); }
.site-row { display: flex; gap: 6px; }
.site-row input {
  flex: 1; min-width: 0; padding: 8px; border: 1px solid var(--line-2); border-radius: 2px;
  background: var(--bg-2); color: var(--ink); font: 12px/1 var(--mono);
}
.site-row input::placeholder { color: var(--dim); }
.site-row button { flex: 0 0 auto; }
.site-msg:empty { display: none; }
.site-msg { color: var(--ink); }

.nodes { width: 100%; border-collapse: collapse; font: 12px/1.45 var(--mono); font-variant-numeric: tabular-nums; }
.nodes th {
  text-align: left; font: 11px/1 var(--sans); letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--dim); padding: 0 0 8px; font-weight: 500;
}
.nodes td { padding: 7px 0; border-top: 1px solid var(--line); color: var(--ink-2); }
.nodes td:first-child { color: var(--ink); }
.nodes tr[data-role="movement"] td:first-child::before {
  content: ""; display: inline-block; width: 5px; height: 5px; margin-right: 7px;
  border-radius: 50%; background: var(--sig); vertical-align: middle;
}
.nodes .age-stale { color: var(--bad); }
.nodes .empty { color: var(--dim); font-family: var(--sans); }

.facts { list-style: none; margin: 14px 0 0; padding: 0; font-size: 12px; }
.facts li {
  display: flex; justify-content: space-between; gap: 16px;
  padding: 6px 0; border-top: 1px solid var(--line);
}
.facts span { color: var(--dim); letter-spacing: 0.05em; text-transform: uppercase; font-size: 12px; }
.facts b { font: 500 12px/1.4 var(--mono); color: var(--ink-2); text-align: right; }

.more { padding: 0 0 4px; border-bottom: 0; margin-bottom: 0; }
.more summary {
  display: flex; align-items: baseline; gap: 10px;
  cursor: pointer;
  list-style: none;
  font: 600 11px/1 var(--sans);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-2);
  padding: 2px 0 4px;
}
.more summary::-webkit-details-marker { display: none; }
.more summary::before {
  content: "+";
  font: 12px/1 var(--mono);
  color: var(--dim);
}
.more[open] summary::before { content: "−"; }
.more[open] summary { margin-bottom: 10px; }
.more .nodes { margin-top: 2px; }
.more .facts { margin-top: 16px; }

@media (hover: none) {
  .brand-sub, .scene-note, .chart-note { opacity: 1; }
}

/* ---------- strip ---------- */

.strip {
  border-top: 1px solid var(--line);
  padding: 12px 24px 10px;
  background: var(--bg-2);
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
}
.strip-head { display: flex; align-items: center; gap: 12px; }
.strip-label { font-size: 12px; letter-spacing: 0.14em; color: var(--dim); }
.strip-label.at { color: var(--sig); }
.strip-actions { margin-left: auto; display: flex; gap: 8px; }

.scrub-wrap { position: relative; display: flex; align-items: center; height: 26px; }
#scrub {
  appearance: none; -webkit-appearance: none;
  width: 100%; height: 26px; margin: 0; background: transparent; cursor: ew-resize;
}
#scrub::-webkit-slider-runnable-track { height: 2px; background: var(--line-2); }
#scrub::-moz-range-track { height: 2px; background: var(--line-2); }
#scrub::-webkit-slider-thumb {
  -webkit-appearance: none; width: 9px; height: 20px; margin-top: -9px;
  background: var(--sig); border: 0; border-radius: 1px;
}
#scrub::-moz-range-thumb { width: 9px; height: 20px; background: var(--sig); border: 0; border-radius: 1px; }
#scrub:disabled { cursor: default; }
#scrub:disabled::-webkit-slider-thumb { background: var(--dim); }
.marks { position: absolute; inset: 7px 0; pointer-events: none; }
.mark { position: absolute; top: 50%; width: 1px; height: 12px; transform: translate(-50%, -50%); opacity: 0.75; }
.mark-rain { background: var(--mark-rain); }
.mark-tilt { background: var(--sig); }
.strip-scale { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 12px; color: var(--dim); }
.strip-keys { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.strip-keys .mk { display: inline-block; width: 2px; height: 10px; border-radius: 1px; margin-left: 8px; }
.strip-keys .mk:first-child { margin-left: 0; }
.mk-rain { background: var(--mark-rain); }
.mk-tilt { background: var(--sig); }

.ghost-link {
  font: 500 11px/1 var(--sans);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  border: 1px solid transparent;
  border-radius: 2px;
  padding: 8px 12px;
  text-decoration: none;
  transition: background-color 120ms ease, color 120ms ease, border-color 120ms ease;
}
.ghost-link:hover { border-color: var(--line-2); color: var(--ink); }

/* ---------- dialog ---------- */

.help {
  border: 1px solid var(--line-2); background: var(--panel-2); color: var(--ink);
  padding: 22px; max-width: 460px; border-radius: 3px;
}
.help::backdrop { background: var(--backdrop); }
.help h2 { margin: 0 0 14px; font: 600 12px/1 var(--sans); letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-2); }
.help-intro { margin: 0 0 14px; font: 14px/1.6 var(--sans); color: var(--ink-2); }
.help dl { margin: 0 0 16px; display: grid; gap: 10px; }
.help dl div { display: grid; grid-template-columns: 74px 1fr; gap: 12px; align-items: baseline; }
.help dt { margin: 0; }
.help dd { margin: 0; font-size: 12px; color: var(--muted); }
.help-note { font: 12px/1.6 var(--sans); color: var(--dim); border-top: 1px solid var(--line); padding-top: 12px; }
.help-keys { margin: 0 0 14px; border-top: 1px solid var(--line); padding-top: 12px; }
.help-keys summary {
  cursor: pointer;
  font: 600 12px/1 var(--sans);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.help-keys summary:hover { color: var(--ink); }
.help-keys dl { margin: 12px 0 0; }
.help .primary { margin: 2px 0 16px; }
.legend { list-style: none; margin: 0 0 16px; padding: 0; display: grid; gap: 8px; }
.legend li { display: grid; grid-template-columns: 8px auto 1fr; gap: 9px; align-items: baseline; font-size: 13px; color: var(--muted); }
.legend i { width: 8px; height: 8px; border-radius: 1px; align-self: center; }
.legend b { font: 600 11px/1 var(--sans); letter-spacing: 0.07em; color: var(--ink-2); white-space: nowrap; }
.s-stable { background: var(--state-stable); }
.s-watch { background: var(--state-watch); }
.s-risk { background: var(--state-risk); }
.s-unknown { background: var(--state-unknown); }
.lang-pick h2 { text-transform: none; font-size: 15px; letter-spacing: 0.02em; }
.lang-sub { margin: -6px 0 16px; font: 13px/1.5 var(--sans); color: var(--muted); }
.lang-buttons { display: grid; gap: 10px; }
.lang-buttons button { padding: 12px 14px; font-size: 12px; text-align: left; }
.lang-buttons button:hover { border-color: var(--line-hover); background: var(--hover); }
.lang-buttons button.is-current { border-color: var(--sig); color: var(--ink); }
.lang-note { margin: 14px 0 0; font: 12px/1.5 var(--sans); color: var(--dim); }
.lang-pick::backdrop { background: var(--backdrop); }
.noscript { padding: 20px; color: var(--muted); }

/* ---------- tour ---------- */

.touring .bar, .touring .shell { pointer-events: none; }
.tour { position: fixed; inset: 0; z-index: 50; }
.tour-spot {
  position: absolute;
  border-radius: 3px;
  box-shadow: 0 0 0 9999px var(--backdrop), 0 0 0 1px color-mix(in srgb, var(--ink) 40%, transparent);
  transition: left 220ms ease, top 220ms ease, width 220ms ease, height 220ms ease;
  pointer-events: none;
}
.tour-panel {
  position: fixed;
  left: 50%; bottom: 24px;
  transform: translateX(-50%);
  width: min(460px, calc(100vw - 32px));
  background: var(--panel);
  border: 1px solid var(--line-2);
  border-left: 2px solid var(--sig);
  padding: 18px 20px;
  box-shadow: 0 18px 50px color-mix(in srgb, var(--ink) 22%, transparent);
}
.tour-panel.top { top: 24px; bottom: auto; }
.tour-count { margin: 0 0 6px; font-size: 12px; letter-spacing: 0.12em; color: var(--dim); }
.tour-panel h2 { margin: 0 0 8px; font: 600 17px/1.3 var(--sans); color: var(--ink); }
.tour-body { margin: 0 0 16px; font: 14px/1.6 var(--sans); color: var(--ink-2); }
.tour-actions { display: flex; align-items: center; gap: 8px; }
.tour-nav { margin-left: auto; display: flex; gap: 8px; }

/* ---------- rain ---------- */

.rain { opacity: 0; transition: opacity 600ms ease; }
.rain line { stroke: var(--rain); stroke-width: 1; }
.rain.on { opacity: 0.55; transition-duration: 120ms; }

/* ---------- theme-bound scene + chart paint ---------- */

#slope-soil stop:first-child { stop-color: var(--soil-top); }
#slope-soil stop:last-child { stop-color: var(--soil-bottom); }

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

@media (max-width: 980px) {
  body { height: auto; min-height: 100dvh; overflow: auto; }
  .shell { display: flex; flex-direction: column; }
  .scene { flex: 0 0 auto; height: auto; min-height: 0; border-right: 0; border-bottom: 1px solid var(--line); }
  #slope { flex: 0 0 auto; height: clamp(220px, 42vw, 360px); }
  .verdict { padding: 20px 18px 10px; }
  .state { font-size: 26px; }
  .sentence { font-size: 15px; }
  .gauges { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 16px 18px 14px; gap: 12px 16px; }
  .scene-note { margin: 4px 18px 14px; }
  .gauges dd { font-size: 18px; }
  .rail { overflow: visible; padding: 18px 18px 0; }
  .strip { position: sticky; bottom: 0; z-index: 10; padding: 10px 18px 8px; }
  .brand-sub { display: none; }
  .bar { padding: 10px 18px; gap: 12px; }
  .bar-meta { gap: 12px; }
  #clock { display: none; }
}

@media (max-width: 420px) {
  .bar { align-items: flex-start; }
  .brand { flex: 0 0 auto; }
  .brand-mark { letter-spacing: 0.12em; }
  .bar-meta { gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
  .bar-meta .ingest { order: 3; width: 100%; justify-content: flex-end; }
  .bar-meta .ghost-link,
  .bar-meta button { padding: 7px 6px; font-size: 11px; }
  .state { font-size: 24px; }
  .sentence { font-size: 14px; }
  .gauges { padding-left: 16px; padding-right: 16px; }
  .gauges dt { font-size: 11px; letter-spacing: 0.08em; }
  .gauges dd { font-size: 16px; }
  .node-tag { font-size: 21px; }
  .angle-tag { font-size: 24px; }
  .strip-scale { font-size: 11px; }
  .strip-keys { gap: 4px; white-space: nowrap; font-size: 11px; }
  .strip-actions button { padding: 8px 9px; letter-spacing: 0.06em; }
  .chip { display: none; }
}

@media (max-height: 720px) and (min-width: 981px) {
  .state { font-size: 26px; }
  .sentence { font-size: 15px; margin-top: 8px; }
  .gauges dd { font-size: 18px; }
  #chart-tilt { height: 118px; }
  #chart-load { height: 96px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
  .rain.on { opacity: 0; }
}

@media (forced-colors: active) {
  .dot, .mark, .state::before { forced-color-adjust: none; }
}
