:root,
:root[data-theme="dark"] {
  --bg: #0b0f14;
  --bg-2: #121821;
  --bg-input: #0e141c;
  --line: #243041;
  --text: #e7eef7;
  --muted: #8b97a8;
  --accent: #5ee0c3;
  --accent-ink: #06231c;
  --chip: #1b2430;
  --glow: #1a2a33;
  --plot: #101822;
  --grid: rgba(255, 255, 255, 0.02);
  --toolbar: rgba(18, 24, 33, 0.72);
  --tooltip-line: #3a4a5e;
  --shadow: rgba(0, 0, 0, 0.35);
  --axis: #3a4a5e;
  --axis-label: #c5d0dc;
  --plan-label: #8b97a8;
  --tick-major: rgba(255, 255, 255, 0.08);
  --tick-minor: rgba(255, 255, 255, 0.04);
  --marker: rgba(255, 255, 255, 0.18);
  --marker-call: #fbbf24;
  --marker-iss: #f472b6;
  --marker-aprs: #86efac;
  --minimap-bar: #d7e2ee;
  --minimap-input: #fbbf24;
  --viewport-fill: rgba(94, 224, 195, 0.12);
  --viewport-stroke: #5ee0c3;
  --chip-ink: #0b0f14;
  --chip-edge: rgba(0, 0, 0, 0.35);
  --chip-selected: #f8fafc;
  --kind-weak: rgba(167, 139, 250, 0.16);
  --kind-ssb: rgba(125, 211, 252, 0.10);
  --kind-beacon: rgba(250, 204, 21, 0.12);
  --kind-satellite: rgba(244, 114, 182, 0.12);
  --kind-translator-in: rgba(251, 146, 60, 0.10);
  --kind-repeater-in: rgba(251, 146, 60, 0.16);
  --kind-simplex: rgba(163, 230, 53, 0.10);
  --kind-translator-out: rgba(56, 189, 248, 0.10);
  --kind-repeater-out: rgba(56, 189, 248, 0.16);
  --kind-repeater-pair: rgba(129, 140, 248, 0.16);
  --kind-experimental: rgba(148, 163, 184, 0.10);
  --kind-gap: transparent;
  --kind-oob: rgba(148, 163, 184, 0.07);
  --error-bg: #1a1013;
  --error-line: #5a2a33;
  --pill-off: #fb7185;
  --pill-off-line: #5a2a33;
  --pill-local: #f5c542;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #eef2f6;
  --bg-2: #ffffff;
  --bg-input: #f7f9fc;
  --line: #cfd8e3;
  --text: #1b2430;
  --muted: #5c6b7c;
  --accent: #0f766e;
  --accent-ink: #f4fffc;
  --chip: #e8eef5;
  --glow: #dbe7f3;
  --plot: #f8fafc;
  --grid: rgba(15, 23, 42, 0.04);
  --toolbar: rgba(255, 255, 255, 0.86);
  --tooltip-line: #c5d0dc;
  --shadow: rgba(15, 23, 42, 0.12);
  --axis: #94a3b8;
  --axis-label: #334155;
  --plan-label: #64748b;
  --tick-major: rgba(15, 23, 42, 0.08);
  --tick-minor: rgba(15, 23, 42, 0.04);
  --marker: rgba(15, 23, 42, 0.22);
  --marker-call: #b45309;
  --marker-iss: #be185d;
  --marker-aprs: #15803d;
  --minimap-bar: #475569;
  --minimap-input: #d97706;
  --viewport-fill: rgba(15, 118, 110, 0.10);
  --viewport-stroke: #0f766e;
  --chip-ink: #0b0f14;
  --chip-edge: rgba(15, 23, 42, 0.28);
  --chip-selected: #0f172a;
  --kind-weak: rgba(124, 58, 237, 0.12);
  --kind-ssb: rgba(2, 132, 199, 0.10);
  --kind-beacon: rgba(202, 138, 4, 0.14);
  --kind-satellite: rgba(219, 39, 119, 0.10);
  --kind-translator-in: rgba(234, 88, 12, 0.10);
  --kind-repeater-in: rgba(234, 88, 12, 0.16);
  --kind-simplex: rgba(77, 124, 15, 0.12);
  --kind-translator-out: rgba(2, 132, 199, 0.10);
  --kind-repeater-out: rgba(2, 132, 199, 0.16);
  --kind-repeater-pair: rgba(79, 70, 229, 0.12);
  --kind-experimental: rgba(71, 85, 105, 0.10);
  --kind-gap: transparent;
  --kind-oob: rgba(100, 116, 139, 0.10);
  --error-bg: #fff1f2;
  --error-line: #fecdd3;
  --pill-off: #be123c;
  --pill-off-line: #fda4af;
  --pill-local: #b45309;
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background:
    radial-gradient(1200px 500px at 50% -10%, var(--glow) 0%, transparent 55%),
    var(--bg);
  color: var(--text);
  font: 14px/1.45 ui-sans-serif, system-ui, "Segoe UI", sans-serif;
}

body {
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

a { color: var(--accent); }

code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.92em;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.top {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 24px;
  padding: 18px 22px 12px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 11px;
}

h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.bands,
.view-tabs,
.regions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.bands button,
.view-tabs button,
.regions button,
.ghost,
.filter-group button {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--text);
  border-radius: 999px;
  padding: 5px 11px;
  cursor: pointer;
}

.bands button.active,
.regions button.active,
.view-tabs button[aria-pressed="true"] {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: transparent;
}

.bands button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.stats {
  margin: 0 0 2px auto;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  align-items: center;
  padding: 10px 22px;
  border-bottom: 1px solid var(--line);
  background: var(--toolbar);
}

.search input,
.color-mode select {
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 10px;
}

.search input { width: min(240px, 70vw); }

.filter-group {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.filter-group button[aria-pressed="false"] { opacity: 0.4; }
.filter-group button[data-state="CT"] { --swatch: #f5c542; }
.filter-group button[data-state="MA"] { --swatch: #5b9dff; }
.filter-group button[data-state="ME"] { --swatch: #3dd68c; }
.filter-group button[data-state="NH"] { --swatch: #c084fc; }
.filter-group button[data-state="RI"] { --swatch: #fb7185; }
.filter-group button[data-state="VT"] { --swatch: #2dd4bf; }
.filter-group button[data-state="NY"] { --swatch: #fb923c; }
.filter-group button[data-state="NJ"] { --swatch: #818cf8; }
.filter-group button[data-state]::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--swatch);
}

.check, .color-mode {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
}

.minimap-wrap {
  padding: 8px 22px 0;
}

.minimap {
  position: relative;
  height: 56px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-input);
  overflow: hidden;
}

.minimap svg,
.spectrum svg {
  display: block;
  width: 100%;
  height: 100%;
}

.stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 8px 22px 0;
}

.minimap,
.spectrum {
  user-select: none;
}

.spectrum,
.geo-map {
  position: relative;
  flex: 1;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background:
    linear-gradient(var(--plot), var(--plot)),
    repeating-linear-gradient(
      90deg,
      transparent 0 39px,
      var(--grid) 39px 40px
    );
  overflow: hidden;
  touch-action: none;
}

.hint {
  margin: 6px 2px 10px;
  color: var(--muted);
  font-size: 12px;
}

.legend-call { color: var(--marker-call); font-weight: 600; }
.legend-aprs { color: var(--marker-aprs); font-weight: 600; }
.legend-iss { color: var(--marker-iss); font-weight: 600; }

.detail {
  flex: 0 0 auto;
  margin: 0 22px 12px;
  min-height: 118px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-2);
}

.detail-empty { margin: 0; color: var(--muted); }

.detail-card {
  display: grid;
  grid-template-columns: minmax(160px, 220px) 1fr;
  gap: 8px 28px;
}

.detail-card h2 {
  margin: 0 0 4px;
  font-size: 20px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}

.pair {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 15px;
}

.pair strong { color: var(--accent); }

.meta { margin: 0; color: var(--muted); }

.pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0 0;
}

.pill {
  border-radius: 999px;
  padding: 2px 8px;
  background: var(--bg-input);
  border: 1px solid var(--line);
  font-size: 12px;
}

.pill.off { color: var(--pill-off); border-color: var(--pill-off-line); }
.pill.local { color: var(--pill-local); }

footer {
  padding: 0 22px 16px;
  color: var(--muted);
  font-size: 12px;
}

.source {
  padding: 14px 22px 16px;
  background: color-mix(in srgb, var(--accent) 14%, var(--bg-2));
  border-bottom: 2px solid var(--accent);
}

.source-kicker {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.source-lead {
  margin: 0 0 12px;
  max-width: 92ch;
  font-size: 16px;
  line-height: 1.4;
}

.source-lead a {
  font-weight: 700;
}

.source-files {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.source-files li {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 240px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
}

.source-files li[data-active="true"] {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.source-files .file-name {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
}

.source-files .file-url {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 12px;
  color: var(--muted);
}

.source-files li[data-active="true"] .file-name { color: var(--accent); }

.source-files .file-note {
  color: var(--muted);
  font-size: 12px;
  text-decoration: none;
}

.source-files .file-name:hover,
.source-files .file-note:hover { text-decoration: underline; }

.source-files .file-badge {
  margin-top: 4px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.pair-mode button[aria-pressed="true"] {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: transparent;
}

.tooltip {
  position: fixed;
  z-index: 5;
  max-width: min(260px, calc(100vw - 24px));
  padding: 7px 9px;
  border-radius: 8px;
  background: var(--bg-2);
  border: 1px solid var(--tooltip-line);
  box-shadow: 0 8px 24px var(--shadow);
  pointer-events: none;
  font-size: 12px;
}

.tooltip strong {
  display: block;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}

.error {
  margin: 24px;
  padding: 16px;
  border: 1px solid var(--error-line);
  border-radius: 10px;
  background: var(--error-bg);
}

.theme-toggle { margin-bottom: 2px; }

body[data-view="map"] .minimap-wrap,
body[data-view="map"] .spectrum,
body[data-view="map"] #spectrum-hint { display: none; }

body[data-view="spectrum"] .geo-map,
body[data-view="spectrum"] #map-hint { display: none; }

.geo-map {
  background: var(--plot);
  z-index: 0;
}

.leaflet-container {
  background: var(--plot);
  font: inherit;
}

:root:not([data-theme="light"]) .leaflet-tile-pane {
  filter: invert(1) hue-rotate(180deg) saturate(0.55) brightness(0.95);
}

.leaflet-control-zoom a,
.leaflet-control-attribution {
  background: var(--bg-2) !important;
  color: var(--muted) !important;
  border-color: var(--line) !important;
}

.leaflet-control-zoom a:hover { color: var(--text) !important; }

.leaflet-bar { border-color: var(--line) !important; }

.leaflet-tooltip {
  background: var(--bg-2);
  border: 1px solid var(--tooltip-line);
  color: var(--text);
  box-shadow: 0 8px 24px var(--shadow);
}

.leaflet-tooltip-top:before { border-top-color: var(--tooltip-line); }

.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  background: var(--bg-2);
  color: var(--text);
  box-shadow: 0 8px 24px var(--shadow);
}

.leaflet-popup-content { margin: 10px 12px; }

.map-popup {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 180px;
}

.map-popup strong { margin-bottom: 4px; }

.map-popup button {
  appearance: none;
  text-align: left;
  border: 1px solid var(--line);
  background: var(--bg-input);
  color: var(--text);
  border-radius: 6px;
  padding: 4px 8px;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
}

.map-popup button[aria-current="true"] {
  border-color: var(--accent);
  color: var(--accent);
}

@media (max-width: 820px) {
  .top { flex-wrap: wrap; }
  .stats { margin-left: 0; }
  .detail-card { grid-template-columns: 1fr; }
}
