:root {
  color-scheme: dark;
  --panel: rgba(22, 22, 21, 0.92); --ink: #f0efec; --ink-2: #c3c2b7; --muted: #898781;
  --border: rgba(255, 255, 255, 0.12); --accent: #5598e7; --page: #0d0d0d;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
}
:root[data-base="light"] {
  color-scheme: light;
  --panel: rgba(252, 252, 251, 0.94); --ink: #0b0b0b; --ink-2: #52514e; --muted: #898781;
  --border: rgba(11, 11, 11, 0.12); --accent: #2a78d6; --page: #f9f9f7;
}
html, body { margin: 0; height: 100%; background: var(--page); font: 14px/1.45 var(--sans); color: var(--ink); }
#map { position: absolute; inset: 0; }
.panel {
  position: absolute; top: 12px; left: 12px; z-index: 2; width: 320px; max-width: calc(100vw - 24px);
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px;
  backdrop-filter: blur(6px); box-shadow: 0 8px 28px rgba(0,0,0,.25);
}
.panel h1 { font: 600 20px/1.2 var(--serif); margin: 0 0 2px; }
.panel .sub { color: var(--ink-2); font-size: 12.5px; margin: 0 0 12px; }
.panel a { color: var(--accent); text-decoration: none; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.row > label { font-size: 12px; color: var(--muted); min-width: 64px; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg button { font: inherit; font-size: 13px; padding: 5px 11px; border: 0; background: transparent; color: var(--ink-2); cursor: pointer; }
.seg button + button { border-left: 1px solid var(--border); }
.seg button.on { background: var(--ink); color: var(--page); }
input[type=range] { flex: 1; accent-color: var(--accent); }
.val { font-variant-numeric: tabular-nums; min-width: 34px; text-align: right; font-size: 13px; }
.legend { margin-top: 14px; }
.legend .bar { height: 12px; border-radius: 3px; position: relative; }
.legend .ticks { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 3px; font-variant-numeric: tabular-nums; }
.legend .avg { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--ink); border-radius: 1px; }
.legend .cap { font-size: 12px; color: var(--ink-2); margin-bottom: 5px; display: flex; justify-content: space-between; }
.stats { margin-top: 12px; font-size: 12px; color: var(--ink-2); border-top: 1px solid var(--border); padding-top: 10px; }
.stats b { color: var(--ink); font-variant-numeric: tabular-nums; }
.sizes { display: flex; align-items: flex-end; gap: 12px; margin-top: 8px; font-size: 11px; color: var(--muted); }
.sizes span { display: inline-flex; flex-direction: column; align-items: center; gap: 3px; }
.sizes i { display: block; border-radius: 50%; border: 1px solid var(--ink-2); }
#search { width: 100%; box-sizing: border-box; font: inherit; font-size: 13px; padding: 6px 9px; border-radius: 8px; border: 1px solid var(--border); background: transparent; color: var(--ink); }
#hits { list-style: none; margin: 4px 0 0; padding: 0; max-height: 180px; overflow: auto; }
#hits li { padding: 4px 6px; border-radius: 6px; cursor: pointer; font-size: 12.5px; }
#hits li:hover { background: var(--border); }
#hits small { color: var(--muted); }
.toggle { position: absolute; top: 8px; right: 8px; background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 16px; display: none; }
.maplibregl-popup-content { background: var(--panel); color: var(--ink); border-radius: 10px; padding: 10px 12px; font: 12.5px/1.45 var(--sans); box-shadow: 0 6px 20px rgba(0,0,0,.3); }
.maplibregl-popup-tip { display: none; }
.pop b { display: block; font-size: 13.5px; }
.pop .m { color: var(--muted); }
.pop .kv { display: flex; justify-content: space-between; gap: 18px; font-variant-numeric: tabular-nums; }
.pop i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: 0; }
@media (max-width: 640px) {
  .panel { width: auto; right: 12px; padding: 12px; }
  .panel.collapsed .body { display: none; }
  .toggle { display: block; }
}

/* ---- app additions ---- */
html, body { overscroll-behavior: none; }
.panel { top: max(12px, env(safe-area-inset-top)); max-height: calc(100dvh - 24px); overflow: auto; }
.val.wide { min-width: 70px; }
/* two range inputs stacked on one track = a low/high slider */
.range2 { position: relative; flex: 1; height: 22px; min-width: 120px; }
.range2::before { content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 4px; margin-top: -2px; border-radius: 2px; background: var(--border); }
.range2 .fill { position: absolute; top: 50%; height: 4px; margin-top: -2px; border-radius: 2px; background: var(--accent); }
.range2 input { position: absolute; inset: 0; width: 100%; margin: 0; background: none; pointer-events: none; -webkit-appearance: none; appearance: none; }
.range2 input::-webkit-slider-thumb { pointer-events: auto; -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%; background: var(--ink); border: 2px solid var(--accent); cursor: pointer; }
.range2 input::-moz-range-thumb { pointer-events: auto; width: 14px; height: 14px; border-radius: 50%; background: var(--ink); border: 2px solid var(--accent); cursor: pointer; }
.range2 input::-moz-range-track { background: none; }
.legend .shade { position: absolute; top: 0; bottom: 0; background: var(--page); opacity: .72; }
.legend .shade#shadeL { left: 0; border-radius: 3px 0 0 3px; }
.legend .shade#shadeR { right: 0; border-radius: 0 3px 3px 0; }
details.more { margin-top: 12px; border-top: 1px solid var(--border); padding-top: 8px; }
details.more summary { cursor: pointer; font-size: 12.5px; color: var(--ink-2); }
.check { display: flex; gap: 6px; align-items: center; font-size: 13px; color: var(--ink-2); }
.reset { font: inherit; font-size: 12.5px; padding: 5px 10px; border-radius: 8px; border: 1px solid var(--border); background: transparent; color: var(--ink-2); cursor: pointer; }
.foot { margin: 10px 0 0; font-size: 11.5px; color: var(--muted); }
@media (max-width: 640px) {
  .panel { max-height: 55dvh; }
  .panel.collapsed { max-height: none; }
}
#subject { font: inherit; font-size: 13.5px; padding: 6px 28px 6px 10px; border-radius: 8px; border: 1px solid var(--border); background: transparent; color: var(--ink); flex: 1; min-width: 0; cursor: pointer; }
#subject option { background: var(--page); color: var(--ink); }
@media (max-width: 640px) {
  /* bottom sheet on phones so the map controls stay reachable */
  .panel { top: auto; bottom: max(12px, env(safe-area-inset-bottom)); left: 8px; right: 8px; max-width: none; }
  .panel h1 { font-size: 17px; padding-right: 28px; }
  .panel.collapsed .sub { margin-bottom: 0; }
  .maplibregl-ctrl-bottom-right { display: none; }
}
.checks { display: flex; flex-wrap: wrap; gap: 4px 14px; }
