:root {
  color-scheme: light;
  --surface: #fcfcfb;
  --panel: #ffffff;
  --border: #dddcd7;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --low: #2a78d6;
  --high: #e34948;
  --middle: #c9c8c2;
  --missing: #f0efec;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--surface);
  color: var(--text-primary);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
}

header { padding: 16px 24px 4px; }
h1 { margin: 0; font-size: 20px; }
h2 { margin: 0; font-size: 16px; }
h3 { margin: 0 0 6px; font-size: 14px; }
.source, .muted { color: var(--text-secondary); margin: 2px 0 0; }

main { padding: 8px 24px 24px; }

.maps { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.panel, .control {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
}

.panel-head { display: flex; align-items: baseline; gap: 10px; min-height: 32px; margin-bottom: 8px; }

.map { height: 58vh; min-height: 320px; border-radius: 6px; }

select {
  font: inherit;
  padding: 4px 6px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel);
  max-width: 100%;
}
#indicator-select { font-weight: 600; font-size: 15px; }

.cutoff { padding: 40px 10px 0; }
.range { margin: 0 8px; }
.summary { margin: 14px 0 0; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.summary b { color: var(--text-primary); }

/* noUiSlider: shaded tails = Low (left) and High (right) */
.noUi-target { height: 8px; border: none; box-shadow: none; background: var(--missing); }
.noUi-connect.tail-low { background: var(--low); }
.noUi-connect.tail-high { background: var(--high); }
.noUi-connect.keep { background: #4d4c48; }
.noUi-horizontal .noUi-handle {
  width: 18px; height: 18px; right: -9px; top: -6px;
  border-radius: 50%; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); cursor: grab;
}
.noUi-handle::before, .noUi-handle::after { display: none; }
.noUi-tooltip { font-size: 12px; padding: 1px 5px; }

.legend { list-style: none; display: flex; flex-wrap: wrap; gap: 6px 18px; padding: 0; margin: 12px 0; color: var(--text-secondary); }
.legend li { display: flex; align-items: center; gap: 6px; }
.swatch { width: 14px; height: 14px; border-radius: 3px; display: inline-block; }
.swatch.low { background: var(--low); }
.swatch.high { background: var(--high); }
.swatch.middle { background: var(--middle); }
.swatch.missing { background: var(--missing); border: 1px solid var(--border); }
.swatch.excluded { background: #fff; border: 1px dashed #9a998f; }

.controls { display: grid; grid-template-columns: 1fr 1.4fr 1fr; gap: 16px; margin-bottom: 16px; }
.control label { display: block; font-weight: 600; margin: 4px 0 4px; }
.control select { width: 100%; margin-bottom: 6px; }
.control .range { margin-top: 34px; }

#tract-info dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; }
#tract-info dt { color: var(--text-secondary); }
#tract-info dd { margin: 0; font-variant-numeric: tabular-nums; }

.leaflet-tooltip { font-size: 12px; }

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

@media (max-width: 860px) {
  header, main { padding-left: 16px; padding-right: 16px; }
  .maps, .controls { grid-template-columns: 1fr; }
  .map { height: 46vh; }
}
