:root {
  --bg: #0e1117;
  --panel: #161a22;
  --panel2: #1d2230;
  --line: #2a3040;
  --text: #e6e8ee;
  --muted: #9aa3b2;
  --accent: #f97316;
  --accent2: #c2410c;
  --top: #e11d48;
  --smaller: #0891b2;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--text); background: var(--bg);
  font-size: 14px;
}
#app { display: flex; height: 100vh; width: 100vw; }

/* ── Panel ── */
#panel {
  width: 360px; min-width: 360px; height: 100%;
  background: var(--panel); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; overflow-y: auto;
}
#panel > * { padding-left: 14px; padding-right: 14px; }
#brand { padding-top: 12px; }
#brand h1 { font-size: 17px; margin: 0 0 8px; font-weight: 650; }
#legend { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 11.5px; color: var(--muted); }
#legend span { display: inline-flex; align-items: center; gap: 5px; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.pin { width: 9px; height: 9px; display: inline-block; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); }

/* ── Mode tabs ── */
#modes { display: flex; gap: 6px; margin: 12px 0 4px; }
#modes button {
  flex: 1; padding: 8px 6px; font-size: 13px; cursor: pointer;
  background: var(--panel2); color: var(--muted);
  border: 1px solid var(--line); border-radius: 8px;
}
#modes button.active { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; }

.mode-panel { padding-top: 8px; padding-bottom: 8px; flex: 1; }
.hint { color: var(--muted); font-size: 12px; margin: 4px 0 10px; line-height: 1.4; }

/* ── Search ── */
.searchrow { display: flex; gap: 6px; }
#addr {
  flex: 1; padding: 8px 10px; border-radius: 7px; border: 1px solid var(--line);
  background: var(--panel2); color: var(--text); font-size: 13px;
}
#addr-go, .pickerbar button, #addr-cands button {
  padding: 8px 12px; border-radius: 7px; border: 1px solid var(--line);
  background: var(--panel2); color: var(--text); cursor: pointer; font-size: 12.5px;
}
#addr-go:hover, .pickerbar button:hover { border-color: var(--accent); }
#addr-cands { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
#addr-cands button { text-align: left; }
#addr-cands:empty { margin: 0; }

/* ── Fields ── */
.field { margin: 10px 0 4px; }
.field > label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.field.inline { display: flex; align-items: center; gap: 8px; }
.field.inline > label { margin: 0; min-width: 64px; }
.row2 { display: flex; gap: 10px; }
.row2 .field { flex: 1; }
select, input[type=range] { width: 100%; }
select {
  padding: 6px 8px; border-radius: 7px; border: 1px solid var(--line);
  background: var(--panel2); color: var(--text); font-size: 12.5px;
}
input[type=range] { accent-color: var(--accent); }
.check, label.check { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--text); margin: 8px 0; cursor: pointer; }

/* ── Segmented controls ── */
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.seg button {
  padding: 6px 9px; font-size: 12px; background: var(--panel2); color: var(--muted);
  border: none; border-right: 1px solid var(--line); cursor: pointer;
}
.seg button:last-child { border-right: none; }
.seg button.active { background: var(--accent); color: #fff; font-weight: 600; }

/* ── Filters / criteria disclosure ── */
details.filters, details.crit { margin: 8px 0; border: 1px solid var(--line); border-radius: 8px; background: var(--panel2); padding: 6px 10px; }
details summary { cursor: pointer; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 2px 0; }
.crit-block { border-top: 1px solid var(--line); margin-top: 8px; padding-top: 6px; }
.crit-block:first-of-type { border-top: none; }
.crit-h { font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 7px; }
.crit-h .always { font-size: 10.5px; color: var(--muted); font-weight: 400; text-transform: uppercase; letter-spacing: .04em; }

/* ── Picker ── */
.pickerbar { display: flex; align-items: center; gap: 6px; margin: 10px 0 6px; }
.pickerbar .count { margin-left: auto; font-size: 11.5px; color: var(--muted); }
.scroll { max-height: 230px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--panel2); }
.srow { display: flex; align-items: center; gap: 8px; padding: 5px 9px; border-bottom: 1px solid var(--line); font-size: 12.5px; cursor: pointer; }
.srow:last-child { border-bottom: none; }
.srow:hover { background: rgba(255,255,255,0.03); }
.srow input { margin: 0; }
.srow .tdot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.srow .nm { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.srow .bdg { color: var(--muted); font-size: 11px; white-space: nowrap; }
.srow.sec .nm { font-style: italic; }

/* ── Result cards ── */
.card {
  margin: 10px 0; padding: 10px 12px; border-radius: 9px;
  border: 1px solid var(--accent2); background: rgba(249,115,22,0.07);
  font-size: 12.5px; line-height: 1.5;
}
.card.empty { color: var(--muted); border-color: var(--line); background: var(--panel2); }
.card h3 { margin: 0 0 6px; font-size: 13.5px; }
.card .sub { color: var(--muted); font-size: 11.5px; }
.card hr { border: none; border-top: 1px solid var(--line); margin: 8px 0; }
.card a { color: var(--accent); text-decoration: none; font-weight: 600; }
.card a:hover { text-decoration: underline; }
.card .ok { color: #34d399; } .card .no { color: var(--muted); }
.card .rng { display: flex; flex-direction: column; gap: 2px; }
.card .rng .it { display: flex; gap: 8px; }
.card .rng .t { color: var(--accent); font-variant-numeric: tabular-nums; min-width: 52px; }

/* ── Footer ── */
#foot { padding: 8px 14px 14px; font-size: 11px; color: var(--muted); }

/* ── School pin markers (divIcon) ── */
.school-marker { background: none; border: none; }
.spin svg { display: block; overflow: visible; filter: drop-shadow(0 1px 2px rgba(0,0,0,0.45)); transition: transform .08s; }
.spin .pinbody { fill: var(--c); stroke: #fff; stroke-width: 1.6; }
.spin .cap { fill: #fff; }
.spin.anc .pinbody { stroke: #0b0e14; stroke-width: 2.2; }
.spin.anc { transform: scale(1.22); transform-origin: 13px 32px; }
.spin:hover { transform: scale(1.15); transform-origin: 13px 32px; }

/* ── Map ── */
#map { flex: 1; height: 100%; background: #aab; }
.leaflet-popup-content { font-size: 12.5px; line-height: 1.45; margin: 10px 12px; }
.leaflet-popup-content h3 { margin: 0 0 5px; font-size: 13.5px; }
.leaflet-popup-content .sub { color: #666; font-size: 11.5px; }
.leaflet-popup-content a { color: var(--accent2); font-weight: 600; text-decoration: none; }
.leaflet-popup-content .chip { display: inline-block; padding: 1px 7px; border-radius: 10px; color: #fff; font-size: 10.5px; font-weight: 600; }
.leaflet-popup-content .bars { display: grid; grid-template-columns: auto 1fr; gap: 2px 7px; align-items: center; margin: 5px 0; }
.leaflet-popup-content .bar { height: 7px; border-radius: 4px; background: #ddd; position: relative; }
.leaflet-popup-content .bar > i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 4px; }

/* Mobile: stack panel over map */
@media (max-width: 720px) {
  #app { flex-direction: column; }
  #panel { width: 100%; min-width: 0; height: 46%; }
  #map { height: 54%; }
}
