:root {
  --bp-ink: #0f172a;
  --bp-muted: #475569;
  --bp-line: #e2e8f0;
  --bp-panel: #ffffff;
  --bp-accent: #0f766e;
  --bp-radius: 10px;
  --bp-shadow: 0 1px 3px rgba(15, 23, 42, .18), 0 4px 14px rgba(15, 23, 42, .12);
  --bp-font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: #e5e7eb;
  font-family: var(--bp-font);
  color: var(--bp-ink);
}

#map {
  position: absolute;
  inset: 0;
  height: 100%;
  height: 100dvh;
}

.leaflet-container { font-family: var(--bp-font); font-size: 14px; }

/* Keep controls clear of notches / home indicators on phones. */
.leaflet-top { top: env(safe-area-inset-top, 0); }
.leaflet-bottom { bottom: env(safe-area-inset-bottom, 0); }
.leaflet-left { left: env(safe-area-inset-left, 0); }
.leaflet-right { right: env(safe-area-inset-right, 0); }

/* ---- Markers ------------------------------------------------------------- */

.bp-marker-wrap, .bp-cluster-wrap { background: none; border: 0; }

.bp-marker {
  position: relative;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--c);
  color: #fff;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .35);
  display: grid;
  place-items: center;
  transition: transform .12s ease;
}
.bp-marker:hover, .leaflet-marker-icon:focus .bp-marker { transform: scale(1.12); }

/* Bottom right, so the top is free for the roof. */
.bp-badge {
  position: absolute;
  bottom: -9px;
  right: -12px;
  min-width: 22px;
  height: 20px;
  padding: 0 5px;
  border-radius: 10px;
  background: #fff;
  color: var(--bp-ink);
  border: 2px solid var(--c);
  font: 700 12px/16px var(--bp-font);
  text-align: center;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .25);
}
.bp-badge-unknown { color: #64748b; font-weight: 600; }

/* Roof over covered / indoor parking. */
.bp-roof { position: absolute; top: -11px; left: -4px; overflow: visible; }
.bp-roof path { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.bp-roof path:first-child { stroke: #fff; stroke-width: 6; }
.bp-roof path + path { stroke: var(--c, var(--bp-ink)); stroke-width: 3; }

/* Several nearby spots of one type: the pin with a second one peeking out
   bottom left, clear of the badge. */
.bp-marker.bp-stack {
  box-shadow: -4px 4px 0 -2px var(--c), -4px 4px 0 0 #fff, -4px 5px 5px rgba(0, 0, 0, .35);
}

.bp-mixed svg { filter: drop-shadow(0 0 1.5px rgba(15, 23, 42, .9)); }

/* Mixed types: a ring split by type colour around the total. */
.bp-cluster {
  position: relative;
  box-sizing: border-box;
  padding: 5px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .3);
}
.bp-cluster .bp-roof { top: -13px; left: 50%; margin-left: -19px; --c: var(--bp-accent); }
.bp-cluster-core {
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  border-radius: 50%;
  background: rgba(15, 118, 110, .95);
  color: #fff;
  border: 2px solid #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.bp-cluster b { font-size: 15px; }
.bp-cluster span { font-size: 9px; opacity: .9; margin-top: 2px; letter-spacing: .02em; }

/* ---- Title ---------------------------------------------------------------- */

.bp-title {
  background: var(--bp-panel);
  border-radius: var(--bp-radius);
  box-shadow: var(--bp-shadow);
  padding: 8px 12px;
  max-width: calc(100vw - 190px);
}
.bp-title { display: flex; align-items: center; gap: 10px; }
.bp-title h1 { margin: 0; font-size: 16px; line-height: 1.2; }
.bp-about-btn {
  flex: none; width: 24px; height: 24px; border-radius: 50%; border: 1.5px solid var(--bp-muted); background: none;
  color: var(--bp-muted); font: italic 700 13px/1 Georgia, serif; cursor: pointer; padding: 0;
}
.bp-about-btn:hover, .bp-about-btn:focus-visible { color: var(--bp-accent); border-color: var(--bp-accent); }

/* The ⋮ menu: release and cache. Later controls in the corner would paint over it. */
.bp-title.is-menu-open { z-index: 1001; }
.bp-menu-btn {
  position: relative; flex: none; width: 28px; height: 28px; margin: -2px -6px -2px -4px; border: 0; border-radius: 50%;
  background: none; color: var(--bp-muted); fill: currentColor; cursor: pointer; padding: 0; display: grid; place-items: center;
}
.bp-menu-btn:hover, .bp-menu-btn:focus-visible, .bp-menu-btn[aria-expanded="true"] { color: var(--bp-accent); background: #f1f5f9; }
.bp-menu-dot {
  position: absolute; top: 2px; right: 3px; width: 9px; height: 9px; border-radius: 50%;
  background: #ea580c; border: 2px solid var(--bp-panel);
}
.bp-menu-dot[hidden] { display: none; }
.bp-menu {
  position: absolute; top: calc(100% + 6px); left: 0; width: max-content; max-width: min(300px, calc(100vw - 20px));
  background: var(--bp-panel); border-radius: var(--bp-radius); box-shadow: var(--bp-shadow);
  padding: 12px 14px; font-size: 13px; line-height: 1.4;
}
.bp-menu[hidden] { display: none; }
.bp-menu p { margin: 0 0 8px; }
.bp-menu-version { color: var(--bp-muted); }
.bp-menu-new { font-weight: 600; }
.bp-menu-new span {
  display: inline-block; padding: 1px 6px; border-radius: 6px; background: #ea580c; color: #fff;
  font-size: 11px; text-transform: uppercase; letter-spacing: .04em; vertical-align: 1px;
}
.bp-menu-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.bp-menu-actions button {
  font: inherit; font-weight: 600; color: var(--bp-accent); background: #fff; border: 1.5px solid var(--bp-accent);
  border-radius: 8px; padding: 6px 12px; min-height: 36px; cursor: pointer;
}
.bp-menu-actions button[data-act="update"] { color: #fff; background: var(--bp-accent); }
.bp-menu-actions button:disabled { opacity: .55; cursor: default; }
.bp-menu-actions button:focus-visible { outline: 2px solid var(--bp-ink); outline-offset: 2px; }
.bp-menu .bp-menu-hint { margin: 8px 0 0; font-size: 12px; color: var(--bp-muted); }

/* ---- Search --------------------------------------------------------------- */

.bp-search { position: relative; width: 280px; max-width: calc(100vw - 20px); }
.bp-search form {
  display: flex; align-items: center; gap: 8px; height: 44px; padding: 0 12px;
  background: var(--bp-panel); border-radius: var(--bp-radius); box-shadow: var(--bp-shadow); color: var(--bp-muted);
}
.bp-search form:focus-within { outline: 2px solid var(--bp-accent); }
.bp-search svg { flex: none; }
.bp-search input {
  flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: none;
  font: 15px var(--bp-font); color: var(--bp-ink);
}
.bp-results {
  list-style: none; margin: 6px 0 0; padding: 4px 0; background: var(--bp-panel);
  border-radius: var(--bp-radius); box-shadow: var(--bp-shadow); max-height: 50vh; overflow-y: auto;
}
.bp-results li { padding: 8px 12px; cursor: pointer; font-size: 14px; line-height: 1.3; }
.bp-results li span { display: block; font-size: 12px; color: var(--bp-muted); }
.bp-results li:hover, .bp-results li.is-active { background: #f1f5f9; }
.bp-results li.bp-empty { cursor: default; color: var(--bp-muted); }
.bp-embed .bp-search form { height: 38px; }

/* ---- About ---------------------------------------------------------------- */

.bp-about {
  border: 0; padding: 0; border-radius: 14px; box-shadow: var(--bp-shadow);
  width: min(460px, calc(100vw - 32px)); max-height: calc(100dvh - 48px); color: var(--bp-ink);
}
.bp-about::backdrop { background: rgba(15, 23, 42, .45); }
.bp-about-inner { position: relative; padding: 20px 22px 16px; font-size: 14px; line-height: 1.5; }
.bp-about h2 { margin: 0 32px 8px 0; font-size: 19px; }
.bp-about h3 { margin: 14px 0 4px; font-size: 14px; }
.bp-about p { margin: 0 0 8px; }
.bp-about a { color: var(--bp-accent); }
.bp-offline-box button {
  font: inherit; font-weight: 600; color: #fff; background: var(--bp-accent);
  border: 0; border-radius: 8px; padding: 8px 14px; cursor: pointer; min-height: 40px;
}
.bp-offline-box button:focus-visible { outline: 2px solid var(--bp-ink); outline-offset: 2px; }
.bp-offline-box .bp-link-btn {
  background: none; color: var(--bp-accent); padding: 0; min-height: 0; font-weight: 400; text-decoration: underline;
}
.bp-offline-box progress { width: 100%; height: 8px; accent-color: var(--bp-accent); }
.bp-offline-error { color: #991b1b; font-size: 13px; }
.bp-offline-hint { font-size: 13px; color: var(--bp-muted); margin-top: 8px !important; }
.bp-about-foot { font-size: 12px; color: var(--bp-muted); border-top: 1px solid var(--bp-line); padding-top: 10px; margin-top: 12px !important; }
.bp-about-close {
  position: absolute; top: 10px; right: 10px; width: 36px; height: 36px; border: 0; border-radius: 50%;
  background: #f1f5f9; color: var(--bp-ink); font-size: 22px; line-height: 1; cursor: pointer;
}
.bp-title a { color: var(--bp-ink); text-decoration: none; font-weight: 600; font-size: 13px; white-space: nowrap; }
.bp-title a:hover { color: var(--bp-accent); }
.bp-embed .bp-title { padding: 6px 10px; }

/* ---- Legend / filter panel ------------------------------------------------ */

.leaflet-bar.bp-legend {
  background: var(--bp-panel);
  border: 0;
  border-radius: var(--bp-radius);
  box-shadow: var(--bp-shadow);
  width: 270px;
  max-width: calc(100vw - 20px);
  overflow: hidden;
}

.bp-legend-toggle {
  all: unset;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  cursor: pointer;
  font: 600 14px var(--bp-font);
  color: var(--bp-ink);
}
.bp-legend-toggle:focus-visible { outline: 2px solid var(--bp-accent); outline-offset: -2px; }
.bp-short { display: none; }
@media (max-width: 480px) { .bp-legend:not(.is-open) .bp-short { display: inline; } }
.bp-legend-total {
  margin-left: auto;
  font-weight: 500;
  font-size: 12px;
  color: var(--bp-muted);
  font-variant-numeric: tabular-nums;
}
.bp-legend-filtered {
  margin-left: auto;
  padding: 2px 7px;
  border-radius: 10px;
  background: var(--bp-accent);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
}
.bp-legend-filtered:not([hidden]) + .bp-legend-total { margin-left: 0; }
.bp-chevron {
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--bp-muted);
  border-bottom: 2px solid var(--bp-muted);
  transform: rotate(45deg) translate(-2px, -2px);
  transition: transform .15s ease;
}
.bp-legend.is-open .bp-chevron { transform: rotate(-135deg) translate(-2px, -2px); }

.bp-legend-body {
  display: none;
  border-top: 1px solid var(--bp-line);
  padding: 8px 12px 10px;
  max-height: calc(100dvh - 190px);
  overflow-y: auto;
}
.bp-legend.is-open .bp-legend-body { display: block; }

.bp-legend-help { margin: 0 0 6px; font-size: 12px; color: var(--bp-muted); line-height: 1.35; }
.bp-legend-help p { display: flex; align-items: center; gap: 8px; margin: 0 0 5px; }
.bp-legend-help p > span:first-child { flex: none; width: 30px; display: flex; justify-content: center; }
.bp-key-badge {
  min-width: 22px; height: 20px; padding: 0 5px; border-radius: 10px; border: 2px solid var(--bp-muted);
  font: 700 12px/16px var(--bp-font); color: var(--bp-ink); text-align: center;
}
.bp-key-roof .bp-marker, .bp-key-stack .bp-marker { width: 22px; height: 22px; border-width: 1.5px; }
.bp-key-roof .bp-marker { margin-top: 5px; }
/* The pin's roof scaled down with it (22/34). */
.bp-key-roof .bp-roof { top: -7.3px; left: -2.8px; width: 24.6px; height: 12.3px; }
.bp-key-stack .bp-marker {
  box-shadow: -3px 3px 0 -1.5px var(--c), -3px 3px 0 0 #fff, -2px 3px 3px rgba(0, 0, 0, .3);
}
.bp-key-cluster {
  display: flex; width: 26px; height: 26px; box-sizing: border-box; padding: 3px; border-radius: 50%;
  background: conic-gradient(#1d4ed8 0 60%, #7c3aed 60% 85%, #94a3b8 85%);
}
.bp-key-cluster b {
  flex: 1; display: grid; place-items: center; border-radius: 50%; border: 1.5px solid #fff;
  background: rgba(15, 118, 110, .95); color: #fff; font: 700 9px var(--bp-font);
}

.bp-types { list-style: none; margin: 0; padding: 0; }
.bp-types label, .bp-filter {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  cursor: pointer;
  font-size: 13px;
}
.bp-types input, .bp-filter input { margin: 0; width: 16px; height: 16px; accent-color: var(--bp-accent); flex: none; }
.bp-type-label { flex: 1; }
.bp-type-count { font-size: 12px; color: var(--bp-muted); font-variant-numeric: tabular-nums; }
.bp-types li:has(input:not(:checked)) .bp-swatch { opacity: .35; }

.bp-filter { border-top: 1px solid var(--bp-line); margin-top: 4px; padding-top: 4px; }

.bp-swatch {
  flex: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--c);
  color: #fff;
  display: grid;
  place-items: center;
}

.bp-source { margin: 6px 0 0; font-size: 11px; color: var(--bp-muted); line-height: 1.4; }
.leaflet-bar.bp-legend a {
  display: inline;
  width: auto;
  height: auto;
  line-height: inherit;
  border: 0;
  background: none;
  text-align: left;
}
.bp-source a, .bp-links a { color: var(--bp-accent); }

/* ---- Popup ---------------------------------------------------------------- */

.leaflet-popup-content-wrapper { border-radius: var(--bp-radius); }
.leaflet-popup-content { margin: 12px 14px; line-height: 1.4; }
.bp-popup-head { display: flex; gap: 10px; align-items: flex-start; }
.bp-popup-head .bp-swatch { width: 30px; height: 30px; }
.bp-popup-head strong { font-size: 15px; display: block; }
.bp-sub { font-size: 12px; color: var(--bp-muted); }
.bp-popup p { margin: 8px 0 0; }
.bp-cap { font-size: 14px; }
.bp-cap b { font-size: 20px; font-variant-numeric: tabular-nums; }
.bp-cap-unknown { color: var(--bp-muted); font-size: 13px; }
.bp-desc { font-size: 13px; }
.bp-meta { font-size: 12px; color: var(--bp-muted); }

.bp-chips { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px; }
.bp-chips li { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: #f1f5f9; color: #334155; }
.bp-chips li.good { background: #dcfce7; color: #166534; }
.bp-chips li.warn { background: #fef3c7; color: #92400e; }

.bp-links { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--bp-line); }
.bp-links a { font-size: 13px; font-weight: 600; text-decoration: none; padding: 4px 0; }
.bp-links a:hover { text-decoration: underline; }

/* ---- Controls ------------------------------------------------------------- */

.bp-locate, .bp-fullscreen { display: grid !important; place-items: center; color: var(--bp-ink) !important; }
.bp-locate.is-busy { color: #2563eb !important; animation: bp-pulse 1s ease-in-out infinite; }
@keyframes bp-pulse { 50% { opacity: .4; } }

.bp-status {
  position: absolute;
  z-index: 1000;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  background: var(--bp-panel);
  border-radius: 999px;
  box-shadow: var(--bp-shadow);
  padding: 8px 16px;
  font-size: 13px;
}
.bp-status.is-error { background: #fee2e2; color: #991b1b; border-radius: var(--bp-radius); }

/* Bigger touch targets on touch screens. */
@media (pointer: coarse) {
  .leaflet-bar a, .leaflet-touch .leaflet-bar a { width: 40px; height: 40px; line-height: 40px; }
  .leaflet-control-layers-toggle { width: 40px !important; height: 40px !important; }
}

@media (max-width: 480px) {
  .bp-title h1 { font-size: 14px; }
  .leaflet-bar.bp-legend { width: auto; min-width: 160px; }
  .bp-legend.is-open { width: calc(100vw - 20px); }
  .bp-legend:not(.is-open) .bp-long { display: none; }
  .leaflet-control-attribution { font-size: 10px; }
}

/* Layers button icon, so Leaflet's PNG sprite isn't needed. */
.leaflet-control-layers-toggle {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230f172a' stroke-width='2' stroke-linejoin='round'%3E%3Cpath d='M12 3l9 5-9 5-9-5z'/%3E%3Cpath d='M3 12.5l9 5 9-5M3 16.5l9 5 9-5'/%3E%3C/svg%3E") !important;
  background-size: 22px 22px !important;
}

.bp-offline {
  position: absolute;
  z-index: 1000;
  left: 50%;
  bottom: 10px;
  transform: translateX(-50%);
  background: #fef3c7;
  color: #78350f;
  border-radius: 999px;
  box-shadow: var(--bp-shadow);
  padding: 4px 12px;
  font-size: 12px;
  white-space: nowrap;
  pointer-events: none;
}
.bp-offline[hidden] { display: none; }
