:root {
  color-scheme: light dark;
  --page: #f4f7f6;
  --surface: #ffffff;
  --surface-soft: #edf3f1;
  --text: #17211f;
  --muted: #5e6b68;
  --line: #ced9d6;
  --primary: #086b62;
  --primary-soft: #d7efeb;
  --low: #2b83ba;
  --mid-low: #80bfab;
  --mid: #f1d56b;
  --mid-high: #e88a4b;
  --high: #c8423a;
  --focus: #1b7eae;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --page: #101816;
    --surface: #18231f;
    --surface-soft: #22312d;
    --text: #edf6f3;
    --muted: #aabbb6;
    --line: #3b4d48;
    --primary: #70d2c5;
    --primary-soft: #213f39;
    --low: #5aa8d6;
    --mid-low: #73b9a3;
    --mid: #d9be5f;
    --mid-high: #e08d55;
    --high: #ed7168;
    --focus: #82c9eb;
  }
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--page); color: var(--text); }
main { width: min(1180px, calc(100% - 32px)); margin: 0 auto; padding: 34px 0 28px; }
header { max-width: 820px; }
.eyebrow { margin: 0 0 6px; color: var(--primary); font-size: 0.82rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
h1 { margin: 0; font-size: clamp(2rem, 5vw, 3.5rem); letter-spacing: -0.045em; line-height: 1.02; }
h2 { margin: 0; font-size: 1.04rem; }
.subtitle { color: var(--muted); font-size: 1.05rem; line-height: 1.55; margin: 14px 0 26px; }

.controls { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 18px; }
.controls-heading { display: flex; justify-content: space-between; align-items: start; gap: 16px; }
.controls-heading p { color: var(--muted); margin: 4px 0 0; font-size: 0.9rem; }
button, select { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px 11px; }
button { cursor: pointer; }
button:hover { background: var(--surface-soft); }
button:focus-visible, select:focus-visible, input:focus-visible { outline: 3px solid color-mix(in srgb, var(--focus) 40%, transparent); outline-offset: 2px; }
.weight-grid { display: grid; grid-template-columns: repeat(5, minmax(120px, 1fr)); gap: 16px; margin-top: 18px; }
.weight-control label { display: flex; justify-content: space-between; gap: 8px; font-size: 0.88rem; font-weight: 650; }
.weight-control output { color: var(--primary); font-variant-numeric: tabular-nums; }
.weight-control input { width: 100%; accent-color: var(--primary); margin-top: 8px; }

.summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 14px 0; }
.summary > div { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 13px 15px; }
.metric { display: block; font-size: 1.55rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.metric-label { display: block; color: var(--muted); font-size: 0.82rem; margin-top: 2px; }

.map-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 14px; align-items: stretch; }
.map-column, aside { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; }
.map-column { min-width: 0; overflow: hidden; }
.map-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 14px; padding: 16px; border-bottom: 1px solid var(--line); }
.map-toolbar label { font-size: 0.86rem; font-weight: 650; }
#legend { display: flex; flex: 1 0 100%; flex-wrap: wrap; gap: 9px 18px; color: var(--text); font-size: 0.9rem; font-weight: 600; padding-top: 2px; }
.legend-item { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.legend-swatch { width: 15px; height: 15px; border: 1px solid rgb(0 0 0 / 0.18); border-radius: 50%; display: inline-block; flex: 0 0 auto; }
.zoom-controls { display: inline-flex; align-items: center; gap: 7px; margin-left: auto; }
.zoom-controls label { color: var(--muted); }
.zoom-controls input { width: 130px; accent-color: var(--primary); }
.zoom-controls button { min-width: 38px; padding: 7px 10px; font-weight: 700; }
#zoom-reset { min-width: auto; font-weight: 600; }
#map { min-height: 620px; background: color-mix(in srgb, var(--surface-soft) 25%, var(--surface)); }
#map svg { width: 100%; height: auto; display: block; }
.county { fill: var(--surface-soft); fill-opacity: 0.36; stroke: var(--line); stroke-width: 0.5; vector-effect: non-scaling-stroke; }
.county:hover { fill-opacity: 0.54; }
.school { stroke: var(--surface); stroke-width: 1.15; cursor: pointer; opacity: 0.92; vector-effect: non-scaling-stroke; }
.school:hover, .school.selected { stroke: var(--text); stroke-width: 2; opacity: 1; }

aside { padding: 18px; }
aside > p { color: var(--muted); line-height: 1.5; }
.school-meta { color: var(--muted); margin: 5px 0 18px; font-size: 0.88rem; }
.detail-metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 14px 0; }
.detail-metrics div { background: var(--surface-soft); padding: 10px; border-radius: 9px; }
.detail-metrics strong { display: block; font-size: 1.2rem; font-variant-numeric: tabular-nums; }
.detail-metrics span { color: var(--muted); font-size: 0.75rem; }
.score-definition { display: grid; gap: 3px; border-left: 4px solid var(--primary); background: var(--primary-soft); border-radius: 7px; padding: 10px 12px; }
.score-definition strong { font-size: 0.88rem; }
.score-definition span { color: var(--muted); font-size: 0.76rem; line-height: 1.35; }
.domain-list { display: grid; gap: 9px; margin-top: 16px; }
.domain-row { display: grid; grid-template-columns: 78px 1fr 28px; gap: 8px; align-items: center; font-size: 0.78rem; }
.bar-track { height: 7px; background: var(--surface-soft); border-radius: 10px; overflow: hidden; }
.bar { height: 100%; background: var(--primary); border-radius: inherit; }
.method-note { color: var(--muted); font-size: 0.75rem; line-height: 1.45; margin-top: 16px; }
footer { color: var(--muted); font-size: 0.8rem; line-height: 1.5; margin-top: 14px; }
#tooltip { position: fixed; pointer-events: none; z-index: 10; max-width: 260px; padding: 8px 10px; border-radius: 8px; background: var(--text); color: var(--surface); font-size: 0.78rem; line-height: 1.4; box-shadow: 0 6px 20px rgb(0 0 0 / 0.2); }

@media (max-width: 820px) {
  .weight-grid { grid-template-columns: repeat(2, minmax(120px, 1fr)); }
  .map-layout { grid-template-columns: 1fr; }
  #map { min-height: 420px; }
  .zoom-controls { margin-left: 0; }
}
@media (max-width: 520px) {
  main { width: min(100% - 20px, 1180px); padding-top: 20px; }
  .controls-heading { display: grid; }
  .weight-grid { grid-template-columns: 1fr; }
  .summary { grid-template-columns: 1fr; }
  #legend { width: 100%; margin-left: 0; }
  .zoom-controls { width: 100%; flex-wrap: wrap; }
  .zoom-controls input { flex: 1; min-width: 100px; }
}
