/* turf planner demo · Jane Democrat. turnpike palette: sign green, reflective yellow. */
@font-face {
  font-family: "Overpass";
  src: url("/demos/turf/fonts/overpass-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: "Overpass Mono";
  src: url("/demos/turf/fonts/overpass-mono-latin-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Overpass Mono";
  src: url("/demos/turf/fonts/overpass-mono-latin-600-normal.woff2") format("woff2");
  font-weight: 600;
  font-display: swap;
}

/* overpass sets its middle dot tight on the right; borrow a system one so "a · b" spaces evenly. */
@font-face {
  font-family: "Overpass";
  src: local("Helvetica Neue"), local("HelveticaNeue"), local("Arial"), local("Roboto"), local("Segoe UI");
  unicode-range: U+00B7;
  font-weight: 100 900;
}

:root {
  --sign: #0b6b4f;
  --sign-dk: #0b3d2e;
  --sign-lt: #e3f1ea;
  --reflect: #f2c230;
  --reflect-lt: #fff4cc;
  --bg: #f4f5f2;
  --paper: #fff;
  --ink: #16241e;
  --mid: #3f4d46;
  --mute: #66706a;
  --rule: #e3e6e1;
  --rule-soft: #eff1ee;
  --p-high: #d62828;
  --p-med: #f77f00;
  --p-low: #3a5bd9;
  --p-mail: #2a9d8f;
  --p-none: #c3c9c4;
  --sans: "Overpass", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Overpass Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --shadow: 0 6px 24px rgba(22, 36, 30, 0.16), 0 1px 3px rgba(22, 36, 30, 0.1);
  --panel-w: 352px;
  --gap: 14px;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-size: 13px;
  overflow: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--sign); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--reflect); outline-offset: 2px; }

#map { position: absolute; inset: 0; background: #e8ebe6; }

/* ---------- map chrome ---------- */
.leaflet-container { font-family: var(--sans); }
.leaflet-control-attribution { font-size: 10px; background: rgba(255, 255, 255, 0.82) !important; border-radius: 4px 0 0 0; }
.leaflet-control-zoom { border: 0 !important; box-shadow: var(--shadow) !important; border-radius: 8px !important; overflow: hidden; }
.leaflet-control-zoom a { color: var(--sign-dk) !important; width: 34px !important; height: 34px !important; line-height: 34px !important; }
.leaflet-tooltip.tip {
  font-family: var(--sans); font-size: 12px; font-weight: 600; color: var(--ink);
  border: 0; border-radius: 6px; box-shadow: 0 2px 10px rgba(22, 36, 30, 0.2); padding: 5px 9px;
}
.leaflet-tooltip.tip small { display: block; font-family: var(--mono); font-weight: 400; font-size: 10px; color: var(--mute); }
.leaflet-tile-pane { filter: saturate(0.6) brightness(1.04) contrast(0.92); }

.synth {
  position: absolute; z-index: 1005; top: var(--gap); right: var(--gap);
  display: flex; align-items: center; gap: 8px;
  background: var(--sign-dk); color: #fff;
  border-radius: 999px; padding: 6px 6px 6px 12px;
  box-shadow: var(--shadow);
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.02em;
}
.synth-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--reflect); box-shadow: 0 0 0 3px rgba(242, 194, 48, 0.25); flex: none; }
.synth-why {
  border: 0; cursor: pointer; border-radius: 999px; padding: 3px 10px 2px;
  background: var(--reflect); color: var(--sign-dk); font-family: var(--mono); font-weight: 600; font-size: 11px;
}
.synth-pop {
  position: absolute; top: calc(100% + 8px); right: 0; width: 300px;
  background: var(--paper); color: var(--ink); border-radius: 10px; box-shadow: var(--shadow);
  border-top: 5px solid var(--reflect);
  padding: 12px 14px; font-family: var(--sans); font-size: 13px; line-height: 1.45; letter-spacing: 0;
}
.synth-pop p { margin: 0 0 8px; }
.synth-pop p:last-child { margin: 0; }

.mode-hint {
  position: absolute; z-index: 1001; top: calc(var(--gap) + 48px); left: calc(50% + var(--panel-w) / 2);
  transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px;
  background: var(--sign); color: #fff; font-weight: 700; font-size: 13px;
  padding: 6px 6px 6px 14px; border-radius: 999px; box-shadow: var(--shadow);
  border: 2px solid #fff; outline: 2px solid var(--sign);
}
.mode-hint button { border: 0; cursor: pointer; background: var(--reflect); color: var(--sign-dk); font-weight: 800; border-radius: 999px; padding: 4px 12px 3px; }

.loading {
  position: absolute; z-index: 1002; left: calc(50% + var(--panel-w) / 2); top: 50%; transform: translate(-50%, -50%);
  background: var(--paper); border-radius: 999px; padding: 9px 16px; box-shadow: var(--shadow);
  font-family: var(--mono); font-size: 12px; color: var(--mid); display: flex; gap: 10px; align-items: center;
}
.spin { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--rule); border-top-color: var(--sign); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.map-legend {
  background: var(--paper); border-radius: 8px; box-shadow: var(--shadow); padding: 8px 10px 7px; min-width: 200px; font-size: 11px;
}
.map-legend b { font-weight: 700; font-size: 11.5px; }

/* ---------- panel ---------- */
.panel {
  position: absolute; z-index: 1000; top: var(--gap); left: var(--gap); bottom: var(--gap);
  width: var(--panel-w); background: var(--paper); border-radius: 12px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; overflow: hidden;
  border-top: 6px solid var(--sign);
}
.grab { display: none; }
.panel-head { padding: 14px 18px 0; flex: none; }
.head-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.exit {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  background: var(--reflect); color: var(--sign-dk); font-weight: 800; font-size: 11px; letter-spacing: 0.04em;
  padding: 3px 8px 2px 3px; border-radius: 4px;
}
.exit b { background: var(--sign-dk); color: #fff; padding: 1px 6px 0; border-radius: 3px; font-weight: 800; }
.back { font-family: var(--mono); font-size: 11px; text-decoration: none; color: var(--sign); white-space: nowrap; }
.back:hover { text-decoration: underline; }
h1 { font-weight: 900; font-size: 30px; line-height: 1; letter-spacing: -0.01em; margin: 12px 0 4px; color: var(--sign-dk); }
.sub { margin: 0; color: var(--mute); font-size: 13px; }
.stats {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px;
  margin-top: 12px; padding-bottom: 12px; border-bottom: 2px solid var(--sign);
}
.stat { background: var(--bg); border-radius: 8px; text-align: center; padding: 7px 2px 5px; }
.stat b { display: block; font-family: var(--mono); font-weight: 600; font-size: 16px; font-variant-numeric: tabular-nums; }
.stat span { display: block; font-size: 9.5px; font-weight: 700; letter-spacing: 0.06em; color: var(--mute); margin-top: 1px; }

.panel-body { overflow-y: auto; flex: 1; overscroll-behavior: contain; }
.sec { padding: 12px 18px; border-bottom: 1px solid var(--rule-soft); }
.lab {
  font-size: 10.5px; font-weight: 800; letter-spacing: 0.1em; color: var(--mute);
  margin: 0 0 8px; display: flex; justify-content: space-between; align-items: baseline;
}
.lab.sm { margin-top: 12px; }
.lab small, summary small { font-family: var(--mono); font-weight: 400; letter-spacing: 0; font-size: 10.5px; color: var(--mute); }
details.sec summary {
  cursor: pointer; list-style: none; display: flex; justify-content: space-between; align-items: baseline;
  font-size: 10.5px; font-weight: 800; letter-spacing: 0.1em; color: var(--mute);
}
details.sec summary::-webkit-details-marker { display: none; }
details.sec summary > span::before { content: "▸"; display: inline-block; width: 14px; color: var(--sign); transition: transform 0.15s; }
details[open].sec summary > span::before { transform: rotate(90deg); }
details[open].sec summary { margin-bottom: 10px; }

.search { position: relative; padding-top: 12px; }
input[type="search"] {
  width: 100%; font-size: 14px; padding: 9px 12px 8px; border: 1px solid var(--rule); border-radius: 8px; background: var(--bg);
}
input[type="search"]:focus { outline: 2px solid var(--sign); outline-offset: -1px; background: #fff; }
.results { margin-top: 6px; border: 1px solid var(--rule); border-radius: 8px; overflow: hidden; }
.results button {
  display: flex; width: 100%; justify-content: space-between; gap: 8px; text-align: left; border: 0; background: #fff;
  padding: 8px 10px; cursor: pointer; border-bottom: 1px solid var(--rule-soft); font-size: 13px;
}
.results button:last-child { border-bottom: 0; }
.results button:hover, .results button:focus-visible { background: var(--sign-lt); }
.results small { font-family: var(--mono); color: var(--mute); font-size: 10.5px; }

.row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.row label { font-size: 10.5px; font-weight: 800; letter-spacing: 0.08em; color: var(--mute); width: 64px; flex: none; }
select {
  flex: 1; min-width: 0; padding: 7px 28px 6px 10px; border: 1px solid var(--rule); border-radius: 8px; background: #fff;
  font-size: 13px; font-weight: 600; cursor: pointer; appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--sign) 50%), linear-gradient(135deg, var(--sign) 50%, transparent 50%);
  background-position: calc(100% - 15px) 50%, calc(100% - 10px) 50%; background-size: 5px 5px; background-repeat: no-repeat;
}

.legend { margin: 2px 0 10px; }
.legend-bar { height: 9px; border-radius: 5px; border: 1px solid rgba(22, 36, 30, 0.08); }
.legend-ends { display: flex; justify-content: space-between; margin-top: 3px; font-family: var(--mono); font-size: 10.5px; color: var(--mid); font-variant-numeric: tabular-nums; }
.legend-note { font-size: 11px; color: var(--mute); margin-top: 3px; }
.legend-cats { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; }

.toggle {
  display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 8px; background: var(--bg);
  cursor: pointer; user-select: none; font-size: 12.5px; font-weight: 600; margin-bottom: 4px;
}
.toggle input { margin: 0; accent-color: var(--sign); }
.toggle small { margin-left: auto; color: var(--mute); font-weight: 400; font-size: 10.5px; }

.prios { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px 8px; }
.prios label { display: flex; align-items: center; gap: 6px; cursor: pointer; font-size: 12.5px; user-select: none; }
.prios input { margin: 0; accent-color: var(--sign); }
.pdot { width: 10px; height: 10px; border-radius: 50%; flex: none; border: 1px solid rgba(22, 36, 30, 0.2); }
.prios .n { font-family: var(--mono); font-size: 10px; color: var(--mute); }

.filters { display: grid; gap: 10px; margin-bottom: 10px; }
.filt-top { display: flex; justify-content: space-between; font-size: 12px; font-weight: 600; }
.filt-top output { font-family: var(--mono); font-weight: 400; color: var(--sign); font-size: 11.5px; }
input[type="range"] { width: 100%; accent-color: var(--sign); margin: 4px 0 0; }

.btns { display: flex; gap: 6px; flex-wrap: wrap; }
.btn {
  flex: 1; min-width: 90px; cursor: pointer; border-radius: 999px; border: 2px solid var(--sign);
  background: #fff; color: var(--sign); font-weight: 800; font-size: 12.5px; padding: 7px 12px 6px;
}
.btn:hover { background: var(--sign-lt); }
.btn.go { background: var(--reflect); border-color: var(--reflect); color: var(--sign-dk); }
.btn.go:hover { background: #ffd451; }
.btn.go.armed { background: var(--sign); border-color: var(--sign); color: #fff; }
.btn.ghost { border-color: var(--rule); color: var(--mid); }
.btn.ghost:hover { background: var(--bg); }
.btn.small { flex: none; min-width: 0; padding: 4px 10px 3px; font-size: 11.5px; }
#turf-start { flex-basis: 100%; }
.hint { margin: 0 0 10px; color: var(--mute); font-size: 12.5px; line-height: 1.4; }

.turf-sum {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 10px;
}
.turf-sum .t { background: var(--reflect-lt); border-radius: 8px; padding: 7px 10px 6px; }
.turf-sum .t b { display: block; font-family: var(--mono); font-weight: 600; font-size: 17px; font-variant-numeric: tabular-nums; color: var(--sign-dk); }
.turf-sum .t span { font-size: 10px; font-weight: 700; letter-spacing: 0.06em; color: #6b5200; }
.turf-sum .wide { grid-column: 1 / -1; font-size: 12px; color: var(--mid); background: none; padding: 0 2px; }
.turfs { list-style: none; margin: 10px 0 0; padding: 0; }
.turfs li {
  display: flex; align-items: center; gap: 8px; padding: 7px 4px; border-top: 1px solid var(--rule-soft); cursor: pointer; border-radius: 6px;
}
.turfs li:hover { background: var(--bg); }
.turfs .sw { width: 14px; height: 14px; border-radius: 4px; flex: none; border: 2px solid; background: transparent; }
.turfs .nm { flex: 1; min-width: 0; font-weight: 600; font-size: 13px; }
.turfs .nm small { display: block; font-family: var(--mono); font-weight: 400; font-size: 10.5px; color: var(--mute); }
.turfs .x { border: 0; background: none; cursor: pointer; color: var(--mute); font-size: 16px; padding: 2px 6px; border-radius: 4px; }
.turfs .x:hover { color: var(--p-high); background: #fff; }

.top { margin: 0; padding: 0; list-style: none; counter-reset: top; }
.top li {
  counter-increment: top; display: flex; gap: 8px; align-items: baseline; padding: 6px 4px; border-bottom: 1px solid var(--rule-soft);
  cursor: pointer; font-size: 12.5px; border-radius: 4px;
}
.top li::before { content: counter(top); font-family: var(--mono); font-size: 10.5px; color: var(--mute); width: 18px; text-align: right; flex: none; }
.top li:hover { background: var(--bg); }
.top .nm { flex: 1; min-width: 0; }
.top .nm small { color: var(--mute); }
.top .v { font-family: var(--mono); font-size: 11.5px; color: var(--sign-dk); font-weight: 600; }

.towns { margin: 0 -4px; }
.town {
  display: flex; align-items: center; gap: 10px; padding: 7px 6px; border-bottom: 1px solid var(--rule-soft);
  cursor: pointer; border-radius: 6px; width: 100%; text-align: left; background: none; border-left: 0; border-right: 0; border-top: 0;
}
.town:hover, .town:focus-visible { background: var(--bg); }
.town.on { background: var(--sign-lt); }
.town .sw { width: 12px; height: 12px; border-radius: 3px; flex: none; }
.town .nm { flex: 1; min-width: 0; font-size: 13.5px; font-weight: 600; line-height: 1.25; }
.town .meta { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 3px; font-weight: 400; }
.pill { font-family: var(--mono); font-size: 10px; padding: 1px 6px 0; border-radius: 4px; white-space: nowrap; background: var(--rule-soft); color: var(--mute); }
.pill.k { background: var(--sign-lt); color: var(--sign-dk); }
.pill.m { background: #fde7e7; color: #8f1b1b; }
.pill.h { background: #f2e7f7; color: #5a2a82; }
.town .ct { font-family: var(--mono); font-size: 10.5px; color: var(--mute); flex: none; }
.more { width: 100%; margin-top: 8px; }

.credits p { margin: 0 0 6px; font-size: 11.5px; color: var(--mute); line-height: 1.45; }
.credits b { color: var(--mid); font-weight: 700; }

/* ---------- precinct card ---------- */
.card {
  position: absolute; z-index: 1001; top: calc(var(--gap) + 48px); right: var(--gap); width: 330px;
  max-height: calc(100% - var(--gap) * 2 - 48px - 40px); overflow-y: auto;
  background: var(--paper); border-radius: 12px; box-shadow: var(--shadow); border-top: 6px solid var(--sign);
  padding: 14px 16px 14px;
}
.card .close {
  position: absolute; top: 8px; right: 8px; border: 0; background: var(--bg); width: 28px; height: 28px; border-radius: 50%;
  cursor: pointer; font-size: 16px; line-height: 1; color: var(--mid);
}
.card .close:hover { background: var(--rule); }
.eye { font-family: var(--mono); font-size: 10.5px; color: var(--mute); letter-spacing: 0.02em; padding-right: 30px; }
.card h2 { font-weight: 900; font-size: 20px; line-height: 1.1; margin: 4px 0 2px; color: var(--sign-dk); padding-right: 24px; }
.card .where { font-size: 13px; color: var(--mid); margin-bottom: 10px; }
.hoa { display: flex; align-items: center; gap: 8px; border-radius: 8px; padding: 7px 10px; font-size: 12.5px; margin-bottom: 10px; background: var(--bg); color: var(--mid); }
.hoa.part { background: #f6eefa; color: #5a2a82; }
.hoa.dom { background: #fde7e7; color: #8f1b1b; font-weight: 600; }
.hoa .bar { flex: 1; height: 6px; border-radius: 3px; background: rgba(0, 0, 0, 0.08); overflow: hidden; }
.hoa .bar i { display: block; height: 100%; background: currentColor; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 10px; }
.tiles .t { background: var(--bg); border-radius: 8px; padding: 7px 10px 6px; }
.tiles .t.hi { background: var(--reflect-lt); }
.tiles b { display: block; font-family: var(--mono); font-weight: 600; font-size: 17px; font-variant-numeric: tabular-nums; }
.tiles span { font-size: 10px; font-weight: 700; letter-spacing: 0.06em; color: var(--mute); }
.meters { margin-bottom: 10px; }
.meter { display: grid; grid-template-columns: 112px 1fr 38px; align-items: center; gap: 8px; padding: 4px 0; font-size: 12.5px; }
.meter .track { height: 8px; border-radius: 4px; background: var(--rule-soft); position: relative; overflow: hidden; }
.meter .track i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 4px; }
.meter .val { font-family: var(--mono); font-size: 11.5px; text-align: right; font-variant-numeric: tabular-nums; }
.walk { font-size: 12.5px; color: var(--mid); margin-bottom: 12px; }
.walk b { color: var(--ink); }
.picker { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; margin-bottom: 10px; }
.picker button {
  border: 1px solid var(--rule); background: #fff; border-radius: 6px; padding: 6px 0 5px; cursor: pointer;
  font-size: 11.5px; font-weight: 700; position: relative;
}
.picker button:hover { background: var(--bg); }
.picker button.on { color: #fff; border-color: transparent; }
.picker button .def { position: absolute; top: -7px; left: 50%; transform: translateX(-50%); font-family: var(--mono); font-size: 8.5px; font-weight: 400; background: var(--ink); color: #fff; border-radius: 3px; padding: 0 3px; }
.card textarea {
  width: 100%; min-height: 58px; resize: vertical; border: 1px solid var(--rule); border-radius: 8px; padding: 8px 10px; font-size: 13px; background: var(--bg);
  margin-bottom: 10px;
}
.card textarea:focus { outline: 2px solid var(--sign); outline-offset: -1px; background: #fff; }
.card .sublab { font-size: 10.5px; font-weight: 800; letter-spacing: 0.1em; color: var(--mute); margin: 0 0 6px; }
.card .fine { font-family: var(--mono); font-size: 10px; color: var(--mute); margin: 10px 0 0; }

/* ---------- small screens: the panel becomes a bottom sheet ---------- */
@media (max-width: 720px) {
  :root { --gap: 10px; --sheet-peek: 178px; }
  body { font-size: 14px; }
  .panel {
    top: auto; left: 0; right: 0; bottom: 0; width: auto; height: var(--sheet-peek);
    border-radius: 16px 16px 0 0; border-top-width: 5px; transition: height 0.22s ease;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .panel.open { height: min(82vh, calc(100% - 64px)); height: min(82dvh, calc(100% - 64px)); }
  .grab {
    display: flex; justify-content: center; align-items: center; width: 100%; height: 22px; border: 0; background: none; cursor: pointer; flex: none; padding: 0;
  }
  .grab-bar { width: 42px; height: 5px; border-radius: 3px; background: var(--rule); }
  .panel-head { padding: 0 14px 0; }
  h1 { font-size: 24px; margin: 8px 0 2px; }
  .sub { font-size: 12px; }
  .stats { margin-top: 8px; padding-bottom: 10px; gap: 5px; }
  .stat b { font-size: 15px; }
  .sec { padding: 12px 14px; }
  .leaflet-bottom { bottom: var(--sheet-peek); }
  .leaflet-control-zoom { display: none; }
  .synth { left: var(--gap); right: var(--gap); top: calc(var(--gap) + env(safe-area-inset-top)); font-size: 10.5px; padding-left: 10px; justify-content: flex-start; }
  .synth-text { flex: 1; min-width: 0; }
  .synth-pop { left: 0; right: 0; width: auto; }
  .mode-hint { left: 50%; top: calc(var(--gap) + 46px); font-size: 12px; }
  .loading { left: 50%; top: 40%; }
  .card {
    top: auto; bottom: 0; left: 0; right: 0; width: auto; max-height: 64vh; max-height: 64dvh;
    border-radius: 16px 16px 0 0; z-index: 1003; padding-bottom: calc(14px + env(safe-area-inset-bottom));
    box-shadow: 0 -6px 28px rgba(22, 36, 30, 0.22);
  }
  .map-legend { display: none; }
  select, input[type="search"] { font-size: 16px; }
  .town { padding: 9px 6px; }
}

@media (prefers-reduced-motion: reduce) {
  .panel { transition: none; }
  .spin { animation: none; }
}
