:root {
  --plane: #050a12;
  --surface: rgba(8, 17, 29, .88);
  --surface-solid: #0b1522;
  --surface-raised: #101d2c;
  --ink: #f5f9ff;
  --ink-2: #c7d4e3;
  --ink-mute: #7f92a7;
  --line: rgba(191, 220, 255, .12);
  --line-strong: rgba(191, 220, 255, .2);
  --accent: #4ba3ff;
  --accent-bright: #80dcff;
  --accent-soft: rgba(75, 163, 255, .14);
  --series-1: #3987e5;
  --series-2: #d95926;
  --good: #4bc784;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #e05252;
  --radius: 16px;
  --shadow: 0 20px 60px rgba(0, 0, 0, .34), 0 2px 10px rgba(0, 0, 0, .22);
  --sans: "Avenir Next", Avenir, Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--plane);
  color: var(--ink);
  font: 14px/1.5 var(--sans);
  overflow: hidden;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background:
    radial-gradient(circle at 18% 18%, rgba(50, 145, 255, .08), transparent 34%),
    linear-gradient(90deg, rgba(2, 7, 13, .2), transparent 25%, transparent 75%, rgba(2, 7, 13, .14));
  box-shadow: inset 0 0 120px rgba(0, 0, 0, .2);
}

#globe { position: absolute; inset: 0; }
.cesium-widget canvas { cursor: grab; }
.cesium-widget canvas:active { cursor: grabbing; }
.cesium-widget canvas.map-feature-hovered,
.cesium-widget canvas.map-feature-hovered:active { cursor: pointer; }

#credits {
  position: absolute;
  right: 12px;
  bottom: 8px;
  z-index: 4;
  max-width: 44vw;
  font-size: 9px;
  line-height: 1.4;
  color: var(--ink-mute);
  text-align: right;
  pointer-events: auto;
  opacity: .7;
}

#credits a, #credits span { color: var(--ink-mute) !important; }
#credits img { max-height: 18px; vertical-align: middle; opacity: .45; }
#credits .cesium-widget-credits {
  display: inline !important;
  /* widgets.css makes this absolute, which collapses #credits to zero width
   * and pushes the attribution off the right edge of the viewport. */
  position: static !important;
  background: none !important;
  border: 0 !important;
  font-size: 9px !important;
}

/* Floating glass surfaces */
#topbar, #rail, #legend, #panel {
  position: absolute;
  z-index: 5;
  overflow: hidden;
  background:
    linear-gradient(145deg, rgba(17, 31, 48, .94), rgba(7, 15, 26, .9));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px) saturate(145%);
  -webkit-backdrop-filter: blur(22px) saturate(145%);
}

#topbar::before, #rail::before, #legend::before, #panel::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  border-radius: inherit;
  background: linear-gradient(115deg, rgba(255, 255, 255, .045), transparent 32%);
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--ink-mute);
  font-size: 9.5px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: .13em;
  text-transform: uppercase;
}

/* Brand card */
#topbar {
  top: 16px;
  left: 16px;
  width: min(410px, calc(100vw - 32px));
  padding: 17px 18px 15px;
}

.brand { display: flex; align-items: center; gap: 13px; }

.brandmark {
  position: relative;
  display: grid;
  place-items: center;
  width: 43px;
  height: 43px;
  flex: none;
  overflow: hidden;
  border: 1px solid rgba(128, 220, 255, .3);
  border-radius: 13px;
  background:
    radial-gradient(circle at 70% 18%, rgba(255, 255, 255, .38), transparent 16%),
    linear-gradient(145deg, #2479d9, #205db7 45%, #0e315f);
  box-shadow: inset 0 1px rgba(255, 255, 255, .18), 0 8px 24px rgba(17, 102, 205, .28);
  transform: rotate(-3deg);
}

.brandmark::before, .brandmark::after, .brandmark i {
  content: "";
  position: absolute;
  left: -8px;
  width: 58px;
  height: 19px;
  border: 2px solid rgba(218, 246, 255, .82);
  border-color: rgba(218, 246, 255, .82) transparent transparent transparent;
  border-radius: 50%;
  transform: rotate(-8deg);
}

.brandmark::before { top: 16px; }
.brandmark::after { top: 23px; opacity: .55; }
.brandmark i { top: 9px; opacity: .3; }

.live-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 5px;
  border-radius: 50%;
  background: var(--good);
  box-shadow: 0 0 0 4px rgba(75, 199, 132, .1), 0 0 10px rgba(75, 199, 132, .5);
  vertical-align: 1px;
}

#topbar h1 {
  margin: 0;
  font-size: clamp(21px, 2vw, 25px);
  font-weight: 680;
  line-height: 1.05;
  letter-spacing: -.035em;
}

#topbar h1 span { color: var(--accent-bright); font-weight: 560; }

#topbar .sub {
  max-width: 340px;
  margin: 12px 0 0 56px;
  color: var(--ink-2);
  font-size: 11.5px;
  line-height: 1.5;
}

#loadstate {
  display: flex;
  align-items: center;
  gap: 7px;
  width: fit-content;
  max-width: calc(100% - 56px);
  margin: 12px 0 0 56px;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(2, 8, 15, .34);
  color: var(--ink-mute);
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
}

#loadstate b { color: var(--ink-2); font-weight: 650; }
#loadstate[hidden] { display: none; }

.spin {
  width: 10px;
  height: 10px;
  flex: none;
  border: 1.5px solid rgba(255, 255, 255, .16);
  border-top-color: var(--accent-bright);
  border-radius: 50%;
  animation: spin .75s linear infinite;
}

.spin.done {
  display: block;
  border: 0;
  background: var(--good);
  box-shadow: 0 0 0 3px rgba(75, 199, 132, .1);
  animation: none;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Control rail */
#rail {
  top: 16px;
  right: 16px;
  width: 274px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

.rail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 17px 18px 15px;
}

.rail-head h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 630;
  line-height: 1.15;
  letter-spacing: -.02em;
}

/* The rail is docked to the bottom of the screen on phones, where it costs
 * half the map. The toggle only exists there; on desktop the rail always fits. */
#railtoggle { display: none; }

.control-count {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  color: var(--accent-bright);
  border: 1px solid rgba(75, 163, 255, .22);
  border-radius: 50%;
  background: var(--accent-soft);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: .06em;
}

.grp {
  display: grid;
  gap: 8px;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
}

.lbl {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  color: var(--ink-mute);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.lbl output {
  padding: 2px 7px;
  color: var(--ink);
  border-radius: 999px;
  background: var(--accent-soft);
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0;
  text-transform: none;
}

select, input[type="search"], input[type="password"], button {
  width: 100%;
  min-height: 39px;
  padding: 7px 10px;
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: rgba(2, 8, 15, .5);
  font: inherit;
  transition: border-color .18s ease, background .18s ease, box-shadow .18s ease, transform .18s ease;
}

select:hover, input[type="search"]:hover { border-color: rgba(128, 220, 255, .34); }
select:focus-visible, input:focus-visible, button:focus-visible, summary:focus-visible, #hits li:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

select { cursor: pointer; }
button { cursor: pointer; font-weight: 600; }
button:hover { border-color: var(--accent); background: var(--accent-soft); }

input[type="range"] {
  --range-fill: 33.333%;
  width: 100%;
  height: 4px;
  margin: 8px 0 5px;
  border-radius: 10px;
  background: linear-gradient(90deg, var(--accent) var(--range-fill), rgba(173, 204, 235, .16) var(--range-fill));
  appearance: none;
  -webkit-appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
  width: 16px;
  height: 16px;
  border: 3px solid var(--surface-solid);
  border-radius: 50%;
  background: var(--accent-bright);
  box-shadow: 0 0 0 1px rgba(128, 220, 255, .55), 0 3px 10px rgba(0, 0, 0, .35);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}

input[type="range"]::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border: 3px solid var(--surface-solid);
  border-radius: 50%;
  background: var(--accent-bright);
  box-shadow: 0 0 0 1px rgba(128, 220, 255, .55), 0 3px 10px rgba(0, 0, 0, .35);
  cursor: pointer;
}

.toggles { gap: 2px; }

.chk {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 34px;
  color: var(--ink-2);
  font-size: 12px;
  cursor: pointer;
}

.chk input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.chk > i {
  position: relative;
  width: 32px;
  height: 18px;
  flex: none;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: rgba(166, 192, 218, .12);
  transition: .2s ease;
}

.chk > i::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--ink-mute);
  transition: .2s ease;
}

.chk input:checked + i {
  border-color: rgba(75, 163, 255, .45);
  background: rgba(75, 163, 255, .3);
}

.chk input:checked + i::after {
  left: 17px;
  background: var(--accent-bright);
  box-shadow: 0 0 8px rgba(128, 220, 255, .6);
}

.chk input:focus-visible + i { outline: 2px solid var(--accent); outline-offset: 2px; }

.toggle-name { display: flex; align-items: center; gap: 9px; }

.poi-symbol {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  flex: none;
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 7px;
  color: white;
  font-size: 11px;
  font-weight: 750;
  box-shadow: inset 0 1px rgba(255, 255, 255, .16);
}

.poi-symbol.gauge { background: linear-gradient(145deg, #35a7eb, #196fc0); }
.poi-symbol.reservoir { background: linear-gradient(145deg, #35cedd, #137d98); }
.poi-symbol.power { background: linear-gradient(145deg, #ffb04c, #d26b25); }
.poi-symbol.label { background: linear-gradient(145deg, #76889d, #455669); }

.energy-live {
  margin: 8px 0 1px;
  padding: 8px 9px;
  border: 1px solid rgba(53, 206, 221, .17);
  border-radius: 9px;
  background: rgba(53, 206, 221, .07);
  color: var(--ink-mute);
  font-size: 9.5px;
  line-height: 1.45;
}

.energy-live b { color: #76e4ed; font-weight: 650; }

.search-wrap { position: relative; }

.search-wrap > span {
  position: absolute;
  top: 12px;
  left: 11px;
  z-index: 1;
  width: 11px;
  height: 11px;
  border: 1.5px solid var(--ink-mute);
  border-radius: 50%;
  pointer-events: none;
}

.search-wrap > span::after {
  content: "";
  position: absolute;
  right: -5px;
  bottom: -3px;
  width: 6px;
  height: 1.5px;
  border-radius: 2px;
  background: var(--ink-mute);
  transform: rotate(45deg);
}

#search { padding-left: 32px; }
#search::placeholder { color: #6b7c8f; }

#hits {
  max-height: min(320px, 38vh);
  margin: 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
}

#hits:empty { display: none; }

#hits li {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 3px;
  padding: 7px 8px;
  border: 1px solid transparent;
  border-radius: 9px;
  color: var(--ink-2);
  font-size: 11.5px;
  cursor: pointer;
}

#hits li:hover, #hits li:focus-visible {
  border-color: var(--line);
  background: var(--accent-soft);
  outline: none;
}

#hits .hit-icon {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  flex: none;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 8px;
  color: white;
  font-size: 11px;
  font-weight: 750;
}

#hits .hit-icon.river { background: linear-gradient(145deg, #367fd4, #174d91); }
#hits .hit-icon.gauge { background: linear-gradient(145deg, #35a7eb, #196fc0); }
#hits .hit-icon.reservoir { background: linear-gradient(145deg, #35cedd, #137d98); }
#hits .hit-icon.power { background: linear-gradient(145deg, #ffb04c, #d26b25); }
#hits .hit-copy { min-width: 0; flex: 1; }
#hits .hit-copy b, #hits .hit-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#hits .hit-copy b { color: var(--ink); font-size: 11px; font-weight: 600; }
#hits .hit-copy small { color: var(--ink-mute); font-size: 8.5px; }
#hits .hit-arrow { flex: none; color: var(--ink-mute); font-size: 15px; }

.adv { padding-block: 13px 15px; }

.adv summary {
  color: var(--ink-mute);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: .1em;
  list-style: none;
  text-transform: uppercase;
  cursor: pointer;
}

.adv summary::-webkit-details-marker { display: none; }
.adv summary::after { content: "+"; float: right; color: var(--accent-bright); font-size: 15px; line-height: 1; }
.adv[open] summary::after { content: "−"; }
.adv > *:not(summary) { margin-top: 9px; }
.hint { margin: 8px 0 2px; color: var(--ink-mute); font-size: 10.5px; line-height: 1.55; }
.hint b { color: var(--ink-2); font-weight: 600; }
.hint a { color: var(--accent-bright); }

/* Map affordance */
#maphint {
  position: absolute;
  left: 50%;
  bottom: 17px;
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 7px 12px;
  color: rgba(220, 232, 245, .64);
  border: 1px solid rgba(191, 220, 255, .1);
  border-radius: 999px;
  background: rgba(4, 11, 20, .56);
  box-shadow: 0 6px 22px rgba(0, 0, 0, .18);
  backdrop-filter: blur(12px);
  font-size: 9.5px;
  pointer-events: none;
  transform: translateX(-50%);
}

#maphint > span { color: var(--accent-bright); font-size: 12px; }
#maphint i { width: 2px; height: 2px; border-radius: 50%; background: currentColor; }
.detail-open #maphint { opacity: 0; }

#maptip {
  position: fixed;
  z-index: 12;
  min-width: 145px;
  max-width: 250px;
  padding: 9px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: rgba(5, 12, 21, .94);
  box-shadow: 0 12px 34px rgba(0, 0, 0, .38);
  backdrop-filter: blur(14px);
  color: var(--ink-2);
  font-size: 10px;
  line-height: 1.4;
  pointer-events: none;
  transform: translate(14px, 14px);
}

#maptip[hidden] { display: none; }
#maptip b { display: block; margin-bottom: 2px; color: var(--ink); font-size: 11.5px; font-weight: 650; }
#maptip .tip-kind { color: var(--accent-bright); font-size: 8px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
#maptip.power .tip-kind { color: #ffbd66; }
#maptip.reservoir .tip-kind { color: #76e4ed; }
#maptip.river .tip-kind { color: #ffd75d; }

/* Legend */
#legend {
  left: 16px;
  bottom: 16px;
  width: 260px;
  padding: 15px 16px 14px;
}

#legend h2 {
  margin: 0 0 10px;
  color: var(--ink);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: .08em;
  text-transform: uppercase;
}

#legend h2::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 7px;
  border-radius: 50%;
  background: var(--accent-bright);
  box-shadow: 0 0 8px rgba(128, 220, 255, .55);
  vertical-align: 1px;
}

#ramp {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px 13px;
  margin: 0;
  padding: 0;
  list-style: none;
}

#ramp li {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--ink-2);
  font-size: 9.5px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

#ramp i {
  width: 18px;
  height: 4px;
  flex: none;
  border-radius: 999px;
  box-shadow: 0 0 7px currentColor;
}

#legend .note {
  margin: 11px 0 0;
  padding-top: 10px;
  color: var(--ink-mute);
  border-top: 1px solid var(--line);
  font-size: 9.5px;
  line-height: 1.5;
}

#legend .note strong { color: var(--accent-bright); font-weight: 600; }
#legend .hover-note { display: block; margin-top: 5px; color: #f1d879; }
#legend .hover-note::before { content: ""; display: inline-block; width: 18px; height: 3px; margin-right: 7px; border-radius: 999px; background: #ffd75d; box-shadow: 0 0 7px rgba(255, 215, 93, .55); vertical-align: 2px; }

/* River detail drawer */
#panel {
  top: 16px;
  bottom: 16px;
  left: 16px;
  z-index: 7;
  width: min(450px, calc(100vw - 32px));
  padding: 0;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
  animation: panel-in .3s cubic-bezier(.2, .8, .2, 1);
}

#panel[hidden] { display: none; }
@keyframes panel-in { from { opacity: 0; transform: translateX(-14px) scale(.985); } }

#close {
  position: sticky;
  top: 12px;
  float: right;
  z-index: 2;
  width: 34px;
  min-height: 34px;
  height: 34px;
  margin: 12px 12px 0 0;
  padding: 0 0 2px;
  border-radius: 50%;
  background: rgba(6, 13, 23, .74);
  font-size: 21px;
  font-weight: 350;
  line-height: 1;
}

#panelbody { padding: 24px 22px 28px; }

.p-h {
  max-width: calc(100% - 42px);
  margin: 0 0 4px;
  font-size: 25px;
  font-weight: 670;
  line-height: 1.15;
  letter-spacing: -.035em;
}

.p-sub { margin: 0 0 22px; color: var(--ink-mute); font-size: 10.5px; }

.poi-detail-head { display: flex; align-items: center; gap: 12px; padding-right: 40px; }
.poi-detail-head .p-h { max-width: none; }

.poi-detail-icon {
  display: grid;
  place-items: center;
  width: 43px;
  height: 43px;
  flex: none;
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 13px;
  color: white;
  font-size: 17px;
  box-shadow: inset 0 1px rgba(255,255,255,.18), 0 9px 24px rgba(0,0,0,.25);
}

.poi-detail-head.power .poi-detail-icon { background: linear-gradient(145deg, #ffaf49, #cc6424); }
.poi-detail-head.reservoir .poi-detail-icon { background: linear-gradient(145deg, #35cedd, #137d98); }
.poi-detail-head.gauge .poi-detail-icon { background: linear-gradient(145deg, #35a7eb, #196fc0); }

.energy-hero { position: relative; margin: 4px 0 20px; padding: 15px 17px; overflow: hidden; border: 1px solid rgba(220, 121, 47, .2); border-radius: 13px; background: linear-gradient(120deg, rgba(220, 121, 47, .15), rgba(220, 121, 47, .035)); }
.energy-hero::after { content: ""; position: absolute; right: -20px; bottom: -52px; width: 112px; height: 112px; border: 22px solid rgba(255, 177, 79, .055); border-radius: 50%; }
.energy-hero b { color: #ffbd66; font-size: 37px; font-weight: 650; line-height: 1; letter-spacing: -.04em; }
.energy-hero > span { margin-left: 5px; color: #ffcf91; font-size: 13px; }
.energy-hero p { margin: 5px 0 0; color: var(--ink-mute); font-size: 10px; }

.gauge-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 4px 0 20px;
  padding: 15px 17px;
  overflow: hidden;
  border: 1px solid rgba(75, 163, 255, .22);
  border-radius: 13px;
  background: linear-gradient(120deg, rgba(75, 163, 255, .16), rgba(75, 163, 255, .035));
}

.gauge-hero b { color: #80dcff; font-size: 37px; font-weight: 650; line-height: 1; letter-spacing: -.04em; }
.gauge-hero span { margin-left: 5px; color: #b7eaff; font-size: 13px; }
.gauge-hero p { margin: 5px 0 0; color: var(--ink-mute); font-size: 10px; }
.gauge-hero > i { color: rgba(128, 220, 255, .22); font-size: 34px; }

.energy-badge {
  display: flex;
  align-items: center;
  gap: 11px;
  margin: 2px 0 18px;
  padding: 12px;
  border: 1px solid rgba(53, 206, 221, .2);
  border-radius: 12px;
  background: linear-gradient(120deg, rgba(53, 206, 221, .13), rgba(53, 206, 221, .035));
}

.energy-badge > span { display: grid; place-items: center; width: 33px; height: 33px; flex: none; border-radius: 10px; background: rgba(53, 206, 221, .16); color: #76e4ed; }
.energy-badge b { color: #b6f6fb; font-size: 13px; font-weight: 650; }
.energy-badge p { margin: 2px 0 0; color: var(--ink-mute); font-size: 9.5px; }

.detail-row { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; padding: 9px 1px; border-bottom: 1px solid var(--line); font-size: 10.5px; }
.detail-row span { color: var(--ink-mute); }
.detail-row b { color: var(--ink-2); font-weight: 600; text-align: right; }
.source-links { margin-top: 12px; }
.source-links a { color: var(--accent-bright); text-decoration: none; }
.source-links a:hover { text-decoration: underline; }

.context-card {
  min-height: 48px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(3, 9, 17, .36);
}

.context-card > .muted { display: block; padding: 4px 1px; }
.context-lead { display: flex; align-items: center; gap: 10px; }
.context-lead > div { min-width: 0; }
.context-icon { display: grid; place-items: center; width: 34px; height: 34px; flex: none; border-radius: 10px; background: var(--accent-soft); color: var(--accent-bright); }
.context-lead small, .context-grid small, .series-list > small { display: block; color: var(--ink-mute); font-size: 8.5px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; }
.context-lead b { display: block; margin-top: 1px; color: var(--ink); font-size: 13px; font-weight: 650; }
.context-lead p { margin: 1px 0 0; color: var(--ink-mute); font-size: 9.5px; }
.nearby-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; margin-top: 11px; padding-top: 10px; border-top: 1px solid var(--line); }
.nearby-list span { min-width: 0; }
.nearby-list b, .nearby-list small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nearby-list b { color: var(--ink-2); font-size: 10.5px; font-weight: 600; }
.nearby-list small { color: var(--ink-mute); font-size: 8.5px; }
.context-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 14px; }
.context-grid b { display: block; margin-top: 2px; overflow: hidden; color: var(--ink-2); font-size: 11px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.series-list { margin-top: 12px; padding-top: 11px; border-top: 1px solid var(--line); }
.series-list > div { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 7px; }
.series-list span { padding: 4px 7px; border: 1px solid rgba(75, 163, 255, .18); border-radius: 999px; background: var(--accent-soft); color: var(--ink-2); font-size: 9.5px; }
.series-list i { color: var(--ink-mute); font-style: normal; }
.context-link { display: inline-block; margin-top: 11px; color: var(--accent-bright); font-size: 9.5px; text-decoration: none; }
.context-link:hover { text-decoration: underline; }

.hero {
  display: flex;
  align-items: baseline;
  gap: 9px;
  margin: 0 0 4px;
}

.hero b { font-size: 48px; font-weight: 620; line-height: .95; letter-spacing: -.055em; }
.hero i { color: var(--ink-mute); font-size: 14px; font-style: normal; }
.hero-cap { margin: 0 0 18px; color: var(--ink-2); font-size: 11.5px; }
.hero-cap b { color: var(--ink); font-weight: 600; }

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
  margin: 0 0 17px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(3, 9, 17, .35);
}

.stats div { padding: 11px 12px; border-right: 1px solid var(--line); }
.stats div:last-child { border-right: 0; }
.stats dt { margin: 0 0 3px; color: var(--ink-mute); font-size: 8.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.stats dd { margin: 0; font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }

.badge {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 39px;
  margin: 0 0 19px;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(3, 9, 17, .36);
  font-size: 11px;
}

.badge .dot { width: 8px; height: 8px; flex: none; border-radius: 50%; box-shadow: 0 0 8px currentColor; }
.badge b { font-weight: 620; }
.badge span { color: var(--ink-mute); }

h3.sec {
  margin: 24px 0 9px;
  color: var(--ink-2);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
}

h3.sec:first-of-type { margin-top: 8px; }
.chart { width: 100%; height: 196px; }
.cap { margin: 6px 0 0; color: var(--ink-mute); font-size: 10.5px; line-height: 1.5; }
.cap b { color: var(--ink-2); font-weight: 600; }

table.st { width: 100%; border-collapse: collapse; font-size: 11px; }
table.st th {
  padding: 0 7px 7px 0;
  color: var(--ink-mute);
  border-bottom: 1px solid var(--line);
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: .08em;
  text-align: left;
  text-transform: uppercase;
}

table.st th.num, table.st td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.st td { padding: 7px 7px 7px 0; color: var(--ink-2); border-bottom: 1px solid var(--line); }
table.st tr:last-child td { border-bottom: 0; }
table.st td.nm { color: var(--ink); }
table.st i.sw { display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; box-shadow: 0 0 6px currentColor; }

.err { color: var(--serious); font-size: 11px; }
.muted { color: var(--ink-mute); font-size: 11px; }

/* Fallback */
#fallback {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: grid;
  place-content: center;
  margin: 0;
  padding: 40px;
  background: var(--plane);
  color: var(--ink-2);
  font-size: 14px;
  line-height: 1.6;
  text-align: center;
}

#fallback[hidden] { display: none; }
#fallback code { display: block; margin-top: 10px; color: var(--accent-bright); font-family: ui-monospace, monospace; }

.dim { opacity: .68; }

@media (max-width: 900px) {
  #rail { width: 242px; }
  #legend { display: none; }
  #panel { width: calc(100vw - 32px); max-width: 450px; }
  #maphint { left: 42%; }
}

@media (max-width: 650px) {
  #topbar {
    top: 10px;
    left: 10px;
    width: calc(100vw - 20px);
    padding: 13px 14px;
    border-radius: 14px;
  }

  .brandmark { width: 37px; height: 37px; border-radius: 11px; }
  .brandmark::before { top: 13px; }
  .brandmark::after { top: 20px; }
  .brandmark i { top: 6px; }
  #topbar h1 { font-size: 20px; }
  #topbar .sub { display: none; }
  #loadstate { max-width: calc(100% - 49px); margin: 8px 0 0 50px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  #rail {
    top: auto;
    right: 10px;
    bottom: 10px;
    left: 10px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: auto;
    max-height: 48vh;
    border-radius: 18px;
  }

  .rail-head, .toggles, .search-group, .adv { grid-column: 1 / -1; }
  .rail-head { position: sticky; top: 0; z-index: 2; padding: 13px 15px 11px; background: rgba(9, 18, 30, .92); backdrop-filter: blur(18px); }
  .rail-head h2 { font-size: 14px; }
  .grp { padding: 11px 14px; }
  .grp:nth-of-type(3) { border-left: 1px solid var(--line); }
  .control-count { display: none; }

  #railtoggle {
    display: grid;
    place-items: center;
    /* 39px matches the shared control min-height, so the circle stays round
     * and the tap target stays thumb-sized. */
    width: 39px;
    height: 39px;
    padding: 0;
    color: var(--accent-bright);
    border: 1px solid rgba(75, 163, 255, .22);
    border-radius: 50%;
    background: var(--accent-soft);
    font-size: 15px;
    line-height: 1;
  }

  #railtoggle::after { content: "−"; }
  #rail.collapsed #railtoggle::after { content: "+"; }
  #rail.collapsed { max-height: none; }
  #rail.collapsed > :not(.rail-head) { display: none; }
  /* Credits sit clear of the expanded rail; follow it down when it collapses. */
  body:has(#rail.collapsed) #credits { bottom: 74px; }

  .toggles { grid-template-columns: 1fr 1fr; column-gap: 18px; }
  .toggles .lbl, .toggles .energy-live { grid-column: 1 / -1; }
  .adv { padding-bottom: 13px; }

  #maphint, #legend { display: none; }
  #credits { right: 10px; bottom: calc(48vh + 16px); max-width: 70vw; }

  #panel {
    top: 10px;
    right: 10px;
    bottom: 10px;
    left: 10px;
    width: auto;
    max-width: none;
    border-radius: 18px;
  }

  #panelbody { padding: 20px 17px 24px; }
  .p-h { font-size: 23px; }
  .hero b { font-size: 42px; }
}

@media (max-height: 620px) and (min-width: 651px) {
  #topbar .sub { display: none; }
  #loadstate { margin-top: 8px; }
  #rail { max-height: calc(100vh - 24px); }
  #legend { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
