:root {
  --panel-bg: rgba(255, 255, 255, 0.97);
  --panel-shadow: 0 2px 14px rgba(0, 0, 0, 0.25);
  --accent: #1d6fb8;
  --text: #1c2530;
  --muted: #5a6573;
  --pa: #f5a623;
  --radius: 12px;
  --icon-scale: 1; /* map pin / badge size multiplier, set from settings */
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
}

#map {
  position: absolute;
  inset: 0;
  z-index: 0;
}

/* ---------- Shared panel styling ---------- */
.panel {
  position: absolute;
  z-index: 1000;
  background: var(--panel-bg);
  box-shadow: var(--panel-shadow);
  border-radius: var(--radius);
}

/* ---------- Search box (top row, between zoom and the FABs) ---------- */
.poi-search {
  position: absolute;
  top: 12px;
  left: 52px;        /* clears the top-left zoom control */
  right: 60px;       /* clears the vertical FAB stack (~52px wide) */
  width: auto;
  max-width: 420px;
  margin: 0 auto;    /* centres within the gap once max-width caps it */
  z-index: 1000;
}
#poi-search-input {
  width: 100%;
  padding: 9px 14px;
  border: 1px solid #cdd4dc;
  border-radius: 999px;
  background: var(--panel-bg);
  box-shadow: var(--panel-shadow);
  font: inherit;
  font-size: 13.5px;
  color: var(--text);
  outline: none;
}
#poi-search-input::placeholder { color: var(--muted); }
#poi-search-input:focus { border-color: var(--accent); box-shadow: var(--panel-shadow), 0 0 0 2px rgba(29, 111, 184, 0.25); }
.poi-search-results {
  list-style: none;
  margin: 6px 0 0;
  padding: 4px;
  max-height: 52vh;
  overflow-y: auto;
  background: var(--panel-bg);
  box-shadow: var(--panel-shadow);
  border-radius: var(--radius);
}
.poi-search-results[hidden] { display: none; }
.poi-search-results li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 13.5px;
  cursor: pointer;
}
.poi-search-results li .s-emoji { flex: none; width: 20px; text-align: center; }
.poi-search-results li .s-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.poi-search-results li .s-park { flex: none; font-size: 11.5px; color: var(--muted); }
.poi-search-results li.active,
.poi-search-results li:hover { background: rgba(29, 111, 184, 0.1); }

/* ---------- Legend / filters ---------- */
#legend {
  top: 72px;        /* below the zoom control / search top row */
  left: 12px;
  width: 290px;
  max-height: calc(100% - 84px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.legend-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  border: 0;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  padding: 11px 14px;
  cursor: pointer;
  border-radius: var(--radius) var(--radius) 0 0;
}
/* Row of floating circular buttons, top-right of the map */
.map-fabs {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.map-fab {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 50%;
  background: var(--panel-bg);
  box-shadow: var(--panel-shadow);
  color: var(--text);
  font-size: 19px;
  line-height: 1;
  cursor: pointer;
}
.map-fab[hidden] { display: none; }
.map-fab:hover { background: #fff; }
.map-fab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* Active state for the location toggle while tracking is on */
.map-fab.active {
  background: var(--accent);
  color: #fff;
}
.map-fab.active:hover { background: var(--accent); }
.legend-toggle .chevron { transition: transform 0.2s ease; }
.legend-toggle[aria-expanded="false"] .chevron { transform: rotate(-90deg); }

.legend-body {
  padding: 6px 14px 12px;
  overflow-y: auto;
}
.legend-body[hidden] { display: none; }

.hint {
  font-size: 12px;
  color: var(--muted);
  margin: 8px 0 4px;
}

.filter-group { margin: 10px 0; }
.filter-group h3 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin: 0 0 6px;
  border-bottom: 1px solid #e3e7ec;
  padding-bottom: 3px;
}
.filter-group label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  padding: 3px 0;
  cursor: pointer;
}
.filter-group input { width: 16px; height: 16px; flex: none; accent-color: var(--accent); }
.swatch { width: 20px; text-align: center; flex: none; }

/* Clickable category name: looks like the label text, but isolates the
   category on click (the checkbox/swatch still just toggle it). */
.cat-name {
  flex: 1 1 auto;
  min-width: 0;
  text-align: left;
  background: none;
  border: 0;
  margin: 0;
  padding: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
}
.cat-name:hover,
.cat-name:focus-visible { color: var(--accent); text-decoration: underline; }
.cat-name:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }

.sub-hint { margin: 2px 0 6px; }

.legend-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #e3e7ec;
}
.legend-actions button {
  border: 1px solid var(--accent);
  background: #fff;
  color: var(--accent);
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 12.5px;
  cursor: pointer;
}
.legend-actions button:hover { background: var(--accent); color: #fff; }
.count { font-size: 12px; color: var(--muted); }

/* ---------- Marker icons ---------- */
.dlp-marker {
  background: none;
  border: none;
}
.dlp-marker .pin {
  position: relative;
  width: calc(34px * var(--icon-scale));
  height: calc(34px * var(--icon-scale));
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--accent);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(19px * var(--icon-scale));
  line-height: 1;
}
.dlp-marker .badge {
  position: absolute;
  width: calc(17px * var(--icon-scale));
  height: calc(17px * var(--icon-scale));
  border-radius: 50%;
  background: #fff;
  border: 1px solid #cdd4dc;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(11px * var(--icon-scale));
  line-height: 1;
}
.dlp-marker .badge.queue { bottom: calc(-3px * var(--icon-scale)); left: calc(-4px * var(--icon-scale)); }
.dlp-marker .badge.venue { bottom: calc(-3px * var(--icon-scale)); right: calc(-4px * var(--icon-scale)); }
.dlp-marker .badge.pa { top: calc(-3px * var(--icon-scale)); right: calc(-4px * var(--icon-scale)); border-color: var(--pa); background: #fff7e8; }
.dlp-marker .badge.height { top: calc(-3px * var(--icon-scale)); left: calc(-4px * var(--icon-scale)); }
.dlp-marker .badge.height.ok { border-color: #3aa55c; background: #eef9f1; }
.dlp-marker .badge.height.no { border-color: #d9534f; background: #fdecea; }

/* ---------- Current-location (GPS) dot ---------- */
.dlp-location {
  background: none;
  border: none;
}
.dlp-location .dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #1a73e8;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25), 0 1px 4px rgba(0, 0, 0, 0.4);
}

/* permanent name labels */
.dlp-label {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid #cdd4dc;
  border-radius: 6px;
  padding: 1px 6px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
}
.dlp-label::before { display: none; } /* hide tooltip arrow */

/* hidden when labels are toggled off or the map is zoomed out */
#map.labels-off .leaflet-tooltip.dlp-label { display: none; }

/* ---------- Detail panel ---------- */
.detail {
  top: 12px;
  right: 12px;
  width: 320px;
  max-width: calc(100% - 24px);
  max-height: calc(100% - 24px);
  overflow-y: auto;
  padding: 16px 18px 18px;
}
.detail[hidden] { display: none; }
.detail-close {
  position: absolute;
  top: 8px;
  right: 10px;
  border: 0;
  background: none;
  font-size: 26px;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
}
.detail-close:hover { color: var(--text); }

.detail h2 {
  font-size: 18px;
  margin: 2px 36px 4px 0;
}
.detail .subtitle {
  font-size: 12.5px;
  color: var(--muted);
  margin: 0 0 12px;
}
.detail .summary {
  font-size: 13.5px;
  font-style: italic;
  font-weight: 600;
  color: var(--accent);
  margin: -6px 0 12px;
}
.detail .attr {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  font-size: 13.5px;
  padding: 5px 0;
  border-top: 1px solid #eef1f4;
}
.detail .attr .k { flex: none; width: 18px; text-align: center; }
.detail .attr .v { flex: 1; }
.detail .attr .v strong { font-weight: 600; }
.detail .heatnote {
  margin-top: 12px;
  padding: 10px 12px;
  background: #fff5e6;
  border: 1px solid #f3dcb0;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.45;
}
.tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 999px;
  margin-left: 4px;
}
.tag.yes { background: #e7f6ec; color: #1f7a3d; }
.tag.no { background: #f3f4f6; color: #6b7280; }

/* ---------- Settings modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1500;
  background: rgba(0, 0, 0, 0.4);
}
.modal-backdrop[hidden] { display: none; }
.modal {
  position: fixed;
  z-index: 1600;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 300px;
  max-width: calc(100% - 32px);
  padding: 16px 18px 18px;
}
.modal[hidden] { display: none; }
.modal h2 { font-size: 17px; margin: 2px 30px 10px 0; }
.settings-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13.5px;
  font-weight: 600;
}
.settings-row input {
  font: inherit;
  font-weight: 400;
  width: 100%;
  padding: 7px 9px;
  border: 1px solid #cdd4dc;
  border-radius: 8px;
}
.settings-row input[type="range"] {
  padding: 0;
  border: 0;
  accent-color: var(--accent);
  cursor: pointer;
}
.settings-help {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
  margin: 10px 0 0;
}
.settings-reset {
  margin-top: 16px;
  width: 100%;
  border: 1px solid var(--accent);
  background: #fff;
  color: var(--accent);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.settings-reset:hover { background: var(--accent); color: #fff; }
.settings-reset:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Mobile: panels become bottom sheets ---------- */
@media (max-width: 620px) {
  #legend {
    top: auto;
    bottom: 0;
    left: 0;
    width: 100%;
    max-height: 62%;
    border-radius: var(--radius) var(--radius) 0 0;
  }
  .legend-toggle { border-radius: var(--radius) var(--radius) 0 0; }
  .detail {
    top: auto;
    bottom: 0;
    right: 0;
    width: 100%;
    max-width: 100%;
    max-height: 70%;
    border-radius: var(--radius) var(--radius) 0 0;
  }
  .modal {
    top: auto;
    bottom: 0;
    left: 0;
    transform: none;
    width: 100%;
    max-width: 100%;
    border-radius: var(--radius) var(--radius) 0 0;
  }
}
