:root {
  --bg: #101216;
  --panel: #171a20;
  --panel-2: #1e232b;
  --line: #2a3038;
  --text: #e8e4dc;
  --muted: #8b867c;
  --yes: #d4a017;
  --mixed: #c8ccd2;
  --no: #8a4a4a;
  --live: #3d8b72;
  --uc: #c47a2c;
  --planned: #5b7aa8;
  --suspended: #b04a4a;
  --grid: #8a7cb8;
  --contrast: #e8e4dc;
  --accent: #d4a017;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font: 14px/1.45 "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

.app {
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1fr;
  grid-template-rows: auto 1fr;
  height: 100%;
}

header {
  grid-column: 1 / -1;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.7rem 1.1rem;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
header h1 {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  margin: 0;
}
header .as-of { color: var(--muted); font-size: 0.8rem; font-family: ui-sans-serif, system-ui, sans-serif; }

aside {
  overflow: auto;
  border-right: 1px solid var(--line);
  background: var(--panel);
  padding: 0.9rem 1rem 1.4rem;
}

.thesis {
  font-size: 0.95rem;
  margin: 0 0 0.85rem;
}
.caveat {
  font-size: 0.78rem;
  color: var(--muted);
  margin: 0 0 1rem;
  font-family: ui-sans-serif, system-ui, sans-serif;
}

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
  margin-bottom: 1rem;
}
.stat {
  background: var(--panel-2);
  border: 1px solid var(--line);
  padding: 0.45rem 0.55rem;
}
.stat b { display: block; font-size: 1rem; font-family: ui-sans-serif, system-ui, sans-serif; }
.stat span { color: var(--muted); font-size: 0.72rem; font-family: ui-sans-serif, system-ui, sans-serif; }

fieldset {
  border: 1px solid var(--line);
  margin: 0 0 0.7rem;
  padding: 0.45rem 0.55rem 0.55rem;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.78rem;
}
legend { color: var(--muted); padding: 0 0.3rem; }
label { display: flex; align-items: center; gap: 0.4rem; margin: 0.18rem 0; cursor: pointer; }
.swatch {
  width: 10px; height: 10px; border-radius: 50%;
  display: inline-block; flex-shrink: 0;
  border: 1px solid #0006;
}
.swatch.ring { background: transparent; border-width: 2px; border-radius: 50%; }

.views { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-bottom: 0.8rem; }
.views button, .clear {
  font: inherit;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.75rem;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  padding: 0.28rem 0.5rem;
  cursor: pointer;
}
.views button:hover, .clear:hover { border-color: var(--accent); }
.views button.is-active {
  border-color: var(--accent);
  background: #d4a01722;
}

.slider-hint {
  margin: 0 0 0.45rem;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.35;
}
.mw-range-values {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.15rem;
  font-variant-numeric: tabular-nums;
}
.mw-slider {
  position: relative;
  height: 28px;
  margin: 0.15rem 0 0.2rem;
}
.mw-slider-rail,
.mw-slider-fill {
  position: absolute;
  left: 0;
  right: 0;
  top: 12px;
  height: 4px;
  border-radius: 2px;
  pointer-events: none;
}
.mw-slider-rail { background: #2f3640; }
.mw-slider-fill { background: var(--accent); right: auto; }
.mw-slider input[type="range"] {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 28px;
  margin: 0;
  background: none;
  pointer-events: none;
  appearance: none;
  -webkit-appearance: none;
}
.mw-slider input[type="range"]::-webkit-slider-thumb {
  pointer-events: auto;
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--text);
  border: 2px solid var(--accent);
  cursor: pointer;
  box-shadow: 0 0 0 1px #0008;
}
.mw-slider input[type="range"]::-moz-range-thumb {
  pointer-events: auto;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--text);
  border: 2px solid var(--accent);
  cursor: pointer;
}
.gpu-live {
  margin: 0.4rem 0 0;
  color: var(--accent);
  font-size: 0.72rem;
  line-height: 1.35;
  font-variant-numeric: tabular-nums;
}
.gpu-table-wrap { overflow-x: auto; }
.gpu-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.7rem;
  font-variant-numeric: tabular-nums;
}
.gpu-table th, .gpu-table td {
  padding: 0.22rem 0.18rem;
  text-align: right;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.gpu-table th:first-child, .gpu-table td:first-child { text-align: left; }
.gpu-table thead th {
  color: var(--muted);
  font-weight: 600;
}
.gpu-table tbody tr.is-active td {
  color: var(--accent);
  background: #d4a01718;
}

.search {
  width: 100%;
  margin-bottom: 0.55rem;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--line);
  padding: 0.4rem 0.5rem;
  font: 0.8rem ui-sans-serif, system-ui, sans-serif;
}

.list { list-style: none; margin: 0; padding: 0; }
.list li {
  padding: 0.45rem 0;
  border-top: 1px solid var(--line);
  cursor: pointer;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.78rem;
}
.list li:hover { color: var(--accent); }
.list .name { display: block; font-weight: 600; font-size: 0.82rem; color: var(--text); }
.list .meta { color: var(--muted); }

#map { min-height: 0; }

.popup {
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.8rem;
  color: #1a1a1a;
  max-width: 280px;
}
.popup h3 { margin: 0 0 0.3rem; font-size: 0.95rem; }
.popup dl { margin: 0; display: grid; grid-template-columns: 7.2rem 1fr; gap: 0.15rem 0.4rem; }
.popup dt { color: #666; }
.popup dd { margin: 0; }
.popup .notes { margin-top: 0.45rem; color: #333; }

.maplibregl-popup-content { padding: 0.7rem 0.8rem; }
.maplibregl-ctrl-attrib { font-size: 10px; }

.legend-inline { display: flex; gap: 0.7rem; flex-wrap: wrap; margin: 0.3rem 0 0.7rem; font-family: ui-sans-serif, system-ui, sans-serif; font-size: 0.72rem; color: var(--muted); }
.legend-inline i { font-style: normal; }

.takeaway {
  font-size: 0.8rem;
  margin: 0.8rem 0 0;
  color: var(--muted);
}

@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; grid-template-rows: auto minmax(42vh, 1fr) minmax(38vh, 1fr); }
  header { grid-column: 1; }
  #map { grid-row: 2; min-height: 42vh; }
  aside { grid-row: 3; border-right: 0; border-top: 1px solid var(--line); }
}
