:root {
  --ink: #0f172a;
  --ink-soft: #334155;
  --muted: #64748b;
  --line: rgba(148, 163, 184, .28);
  --green: #16a34a;
  --green-bright: #22c55e;
  --zone: #56db40;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(15, 23, 42, .18);
  --bar-h: 60px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-synthesis-weight: none;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #eef1f5;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}

#map {
  position: fixed;
  inset: 0;
  z-index: 0;
  background: #e8ebef;
}

/* ---------------------------------------------------------------- top bar */

.bar {
  position: fixed;
  z-index: 900;
  top: calc(10px + var(--safe-top));
  left: 50%;
  transform: translateX(-50%);
  width: min(1180px, calc(100vw - 20px));
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 18px;
  background: rgba(255, 255, 255, .82);
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  border: 1px solid rgba(255, 255, 255, .7);
  box-shadow: 0 12px 34px rgba(15, 23, 42, .16);
}

.bar__brand {
  display: flex;
  align-items: center;
  gap: 9px;
  padding-left: 4px;
  flex: 0 0 auto;
}

.bar__logo {
  color: var(--green);
  display: grid;
  place-items: center;
  line-height: 0;
}

.bar__title {
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -.2px;
  white-space: nowrap;
}

.cities {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 12px;
  background: rgba(15, 23, 42, .06);
  flex: 0 0 auto;
}

.cities__tab {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  padding: 8px 15px;
  border-radius: 9px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .18s ease, color .18s ease, box-shadow .18s ease;
}

.cities__tab:hover { background: rgba(15, 23, 42, .06); }

.cities__tab[aria-selected="true"] {
  background: var(--ink);
  color: #fff;
  box-shadow: 0 4px 12px rgba(15, 23, 42, .25);
}

.search {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  height: 40px;
  border-radius: 12px;
  background: rgba(15, 23, 42, .055);
  border: 1px solid transparent;
  transition: border-color .18s ease, background .18s ease;
}

.search:focus-within {
  background: #fff;
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, .16);
}

.search__icon { color: var(--muted); flex: 0 0 auto; }

.search__input {
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  background: none;
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  outline: none;
}

.search__input::placeholder { color: var(--muted); }
.search__input::-webkit-search-cancel-button { display: none; }

.search__clear {
  border: 0;
  background: rgba(15, 23, 42, .1);
  color: var(--ink-soft);
  width: 20px;
  height: 20px;
  border-radius: 50%;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  flex: 0 0 auto;
}

.bar__actions { display: flex; gap: 6px; flex: 0 0 auto; }

.icon-btn {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 12px;
  background: rgba(15, 23, 42, .055);
  color: var(--ink-soft);
  cursor: pointer;
  transition: background .18s ease, color .18s ease;
}

.icon-btn:hover { background: rgba(15, 23, 42, .1); color: var(--ink); }
.icon-btn[aria-expanded="true"], .icon-btn--on { background: var(--green); color: #fff; }

/* ------------------------------------------------------------ search list */

.results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  margin: 0;
  padding: 6px;
  list-style: none;
  max-height: min(52vh, 420px);
  overflow-y: auto;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 18px 44px rgba(15, 23, 42, .22);
  border: 1px solid var(--line);
}

.results__item {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: none;
  font: inherit;
  padding: 9px 11px;
  border-radius: 10px;
  cursor: pointer;
  color: var(--ink);
}

.results__item:hover, .results__item:focus-visible { background: rgba(34, 197, 94, .1); }

.results__name { display: block; font-size: 13.5px; font-weight: 600; }

.results__addr {
  display: block;
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.results__empty { padding: 12px; font-size: 13.5px; color: var(--muted); text-align: center; }

/* ---------------------------------------------------------------- legend */

.legend {
  position: fixed;
  z-index: 800;
  left: calc(12px + env(safe-area-inset-left, 0px));
  bottom: calc(24px + var(--safe-bottom));
  padding: 10px 13px;
  border-radius: 13px;
  background: rgba(255, 255, 255, .88);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, .7);
  box-shadow: var(--shadow);
  font-size: 12.5px;
  color: var(--ink-soft);
  display: grid;
  gap: 6px;
  pointer-events: none;
}

.legend__row { display: flex; align-items: center; gap: 8px; }

.legend__swatch {
  width: 15px;
  height: 15px;
  border-radius: 4px;
  flex: 0 0 auto;
}

.legend__swatch--zone { background: rgba(86, 219, 64, .55); border: 2px solid #1bad03; }
.legend__swatch--alt { background: rgba(130, 205, 255, .6); border: 2px solid #1e98ff; }
.legend__swatch--line { height: 3px; border-radius: 2px; background: #ed4543; }

.legend__row--count { border-top: 1px solid var(--line); padding-top: 6px; font-weight: 600; color: var(--ink); }

.legend__dot {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--green-bright);
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, .9);
  border: 1px solid var(--green);
  flex: 0 0 auto;
}

/* ----------------------------------------------------------------- panel */

.panel {
  position: fixed;
  z-index: 880;
  top: calc(var(--bar-h) + 26px + var(--safe-top));
  right: calc(12px + env(safe-area-inset-right, 0px));
  border-radius: 14px;
  background: rgba(255, 255, 255, .93);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, .75);
  box-shadow: var(--shadow);
  animation: drop .16s ease;
}

@keyframes drop { from { opacity: 0; transform: translateY(-6px); } }

.panel__inner { padding: 12px 14px; display: grid; gap: 10px; }
.panel__title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }

.switch { display: flex; align-items: center; gap: 9px; font-size: 13.5px; cursor: pointer; user-select: none; }
.switch input { accent-color: var(--green); width: 16px; height: 16px; cursor: pointer; }

/* ---------------------------------------------------------------- popups */

.leaflet-popup-content-wrapper {
  border-radius: 14px;
  box-shadow: 0 14px 36px rgba(15, 23, 42, .24);
  padding: 2px;
}

.leaflet-popup-content { margin: 12px 14px; width: 258px !important; line-height: 1.45; }
.leaflet-popup-tip { box-shadow: 0 14px 36px rgba(15, 23, 42, .24); }

.pop__title { font-size: 15px; font-weight: 700; letter-spacing: -.2px; margin-bottom: 5px; }
.pop__addr { font-size: 13px; color: var(--ink-soft); display: flex; gap: 6px; }
.pop__addr svg { flex: 0 0 auto; margin-top: 2px; color: var(--muted); }

.pop__note {
  margin-top: 9px;
  padding: 8px 10px;
  border-radius: 9px;
  background: rgba(250, 204, 21, .16);
  border: 1px solid rgba(234, 179, 8, .34);
  font-size: 12.5px;
  color: #713f12;
}

.pop__meta { margin-top: 9px; font-size: 12px; color: var(--muted); }

.pop__route {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  margin-top: 11px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--green);
  color: #fff;
  font-size: 13.5px;
  font-weight: 650;
  text-decoration: none;
  transition: background .18s ease;
}

.pop__route:hover { background: #15803d; }

/* ------------------------------------------------------------- user pin */

.user-pin {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #2563eb;
  border: 3px solid #fff;
  box-shadow: 0 0 0 6px rgba(37, 99, 235, .22), 0 3px 10px rgba(0, 0, 0, .28);
}

.park-pin {
  background: none;
  border: 0;
}

.park-pin__dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--green-bright);
  border: 2.5px solid #fff;
  box-shadow: 0 2px 8px rgba(15, 23, 42, .35);
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  font-family: inherit;
}

.park-pin--active .park-pin__dot {
  background: var(--ink);
  transform: scale(1.18);
}

/* clusters */

.marker-cluster-small, .marker-cluster-medium, .marker-cluster-large { background: rgba(22, 163, 74, .22); }
.marker-cluster-small div, .marker-cluster-medium div, .marker-cluster-large div {
  background: var(--green);
  color: #fff;
  font-weight: 700;
  font-family: inherit;
}
.marker-cluster div { width: 32px; height: 32px; margin: 4px; line-height: 32px; font-size: 12.5px; }
.marker-cluster { width: 40px; height: 40px; margin: -20px 0 0 -20px; border-radius: 50%; }

/* ---------------------------------------------------------------- toast */

.toast {
  position: fixed;
  z-index: 1000;
  left: 50%;
  bottom: calc(28px + var(--safe-bottom));
  transform: translateX(-50%);
  padding: 11px 18px;
  border-radius: 12px;
  background: rgba(15, 23, 42, .93);
  color: #fff;
  font-size: 13.5px;
  box-shadow: var(--shadow);
  animation: toast-in .2s ease;
}

@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } }

/* --------------------------------------------------------------- loader */

.loader {
  position: fixed;
  z-index: 1100;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  background: rgba(238, 241, 245, .92);
  backdrop-filter: blur(3px);
  transition: opacity .25s ease;
}

.loader--hide { opacity: 0; pointer-events: none; }

.loader__spinner {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid rgba(22, 163, 74, .25);
  border-top-color: var(--green);
  animation: spin .8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loader__text { font-size: 13.5px; color: var(--ink-soft); }

/* ------------------------------------------------------------ responsive */

@media (max-width: 860px) {
  .bar__title { display: none; }
  .bar { gap: 8px; }
}

@media (max-width: 640px) {
  .bar {
    flex-wrap: wrap;
    width: calc(100vw - 16px);
    top: calc(8px + var(--safe-top));
    padding: 8px;
    gap: 8px;
    border-radius: 16px;
  }

  .bar__brand { order: 1; }
  .bar__actions { order: 2; margin-left: auto; }
  .search { order: 3; flex: 1 1 100%; height: 42px; }
  .cities { order: 4; flex: 1 1 100%; }
  .cities__tab { flex: 1; text-align: center; padding: 9px 8px; }

  .panel { top: auto; bottom: calc(90px + var(--safe-bottom)); right: 8px; }

  .legend {
    left: 8px;
    right: 8px;
    bottom: calc(26px + var(--safe-bottom));
    grid-auto-flow: column;
    grid-auto-columns: max-content;
    justify-content: start;
    gap: 14px;
    padding: 8px 12px;
    overflow-x: auto;
    font-size: 12px;
  }

  .legend__row--count { border: 0; padding: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
