:root {
  --bg: #f9f9f9;
  --sidebar: #ffffff;
  --ink: #080808;
  --muted: #595959;
  --line: #deded8;
  --accent: #02746a;
  --accent-dark: #005b54;
  --accent-soft: #e3f1ef;
  --error-bg: #fff0ed;
  --error-text: #8f2d1f;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.13);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Nunito Sans", ui-sans-serif, system-ui, -apple-system,
    BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.app-shell {
  display: grid;
  grid-template-columns: 380px minmax(0, 1fr);
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  background: var(--sidebar);
  border-right: 1px solid var(--line);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 20px;
  height: 100vh;
  min-height: 0;
  overflow-y: auto;
  padding: 32px;
  z-index: 500;
}

.sidebar-header {
  border-bottom: 1px solid var(--line);
  padding-bottom: 24px;
}

.filter-panel-close,
.mobile-search-open,
.location-panel-handle {
  display: none;
}

.eyebrow {
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  margin: 0 0 10px;
  text-transform: uppercase;
}

h1,
h2 {
  font-family: "Manrope", "Nunito Sans", sans-serif;
  letter-spacing: -0.025em;
  margin: 0;
}

h1 {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1.04;
}

h2 {
  font-size: 1.05rem;
  font-weight: 800;
}

.intro {
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.55;
  margin: 14px 0 0;
}

.panel {
  display: grid;
  gap: 10px;
}

.filters-panel {
  gap: 14px;
}

.filter-group {
  display: grid;
  gap: 7px;
}

label {
  color: var(--ink);
  font-size: 0.84rem;
  font-weight: 700;
}

input,
select {
  appearance: none;
  background: #ffffff;
  border: 1px solid #cecec8;
  border-radius: 12px;
  color: var(--ink);
  font: inherit;
  min-height: 42px;
  padding: 10px 12px;
  width: 100%;
}

select {
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 18px, calc(100% - 13px) 18px;
  background-repeat: no-repeat;
  background-size: 5px 5px, 5px 5px;
  padding-right: 34px;
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(2, 116, 106, 0.18);
  outline: none;
}

.count-panel {
  align-items: baseline;
  background: var(--accent-soft);
  border: 1px solid #b9dbd7;
  border-radius: 16px;
  color: var(--accent-dark);
  display: flex;
  gap: 8px;
  padding: 14px;
}

#visible-count {
  font-family: "Manrope", "Nunito Sans", sans-serif;
  font-size: 1.6rem;
  font-weight: 800;
}

.legend {
  display: grid;
  gap: 9px;
}

.legend-item {
  align-items: center;
  color: #272727;
  display: flex;
  gap: 9px;
  line-height: 1.25;
}

.legend-swatch {
  border: 2px solid #ffffff;
  border-radius: 999px;
  box-shadow: 0 0 0 1px rgba(34, 48, 38, 0.18);
  flex: 0 0 14px;
  height: 14px;
  width: 14px;
}

.error-message {
  background: var(--error-bg);
  border: 1px solid #f0b8af;
  border-radius: 12px;
  color: var(--error-text);
  font-weight: 700;
  line-height: 1.4;
  padding: 12px;
}

.map-wrap {
  height: 100vh;
  min-width: 0;
  position: relative;
}

/* Leaflet layout fallback.
   If the CDN Leaflet stylesheet is blocked or cached badly, tiles otherwise
   appear as scattered image squares instead of a map. */
.leaflet-container {
  background: #dfe7df;
  overflow: hidden;
  position: relative;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

.leaflet-pane,
.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow,
.leaflet-tile-container,
.leaflet-pane > svg,
.leaflet-pane > canvas,
.leaflet-zoom-box,
.leaflet-image-layer,
.leaflet-layer {
  left: 0;
  position: absolute;
  top: 0;
}

.leaflet-container img,
.leaflet-container canvas {
  max-height: none;
  max-width: none;
}

.leaflet-pane > svg {
  pointer-events: none;
}

.leaflet-pane > svg path,
.leaflet-tile-container {
  pointer-events: none;
}

.leaflet-interactive {
  pointer-events: auto;
}

.leaflet-tile {
  user-select: none;
  visibility: hidden;
}

.leaflet-tile-loaded {
  visibility: inherit;
}

.leaflet-map-pane {
  z-index: 400;
}

.leaflet-tile-pane {
  z-index: 200;
}

.leaflet-overlay-pane {
  z-index: 400;
}

.leaflet-shadow-pane {
  z-index: 500;
}

.leaflet-marker-pane {
  z-index: 600;
}

.leaflet-tooltip-pane {
  z-index: 650;
}

.leaflet-user-location-pane,
.leaflet-user-location-pane-pane {
  pointer-events: none;
  z-index: 650;
}

.leaflet-user-location-pane svg,
.leaflet-user-location-pane path,
.leaflet-user-location-pane-pane svg,
.leaflet-user-location-pane-pane path {
  pointer-events: none;
}

.leaflet-popup-pane {
  z-index: 700;
}

.leaflet-control {
  position: relative;
  z-index: 800;
}

.leaflet-top,
.leaflet-bottom {
  pointer-events: none;
  position: absolute;
  z-index: 1000;
}

.leaflet-top {
  top: 0;
}

.leaflet-right {
  right: 0;
}

.leaflet-bottom {
  bottom: 0;
}

.leaflet-left {
  left: 0;
}

.leaflet-control {
  clear: both;
  float: left;
  pointer-events: auto;
}

.leaflet-right .leaflet-control {
  float: right;
}

.leaflet-top .leaflet-control {
  margin-top: 10px;
}

.leaflet-bottom .leaflet-control {
  margin-bottom: 10px;
}

.leaflet-left .leaflet-control {
  margin-left: 10px;
}

.leaflet-right .leaflet-control {
  margin-right: 10px;
}

.user-location-control {
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.18);
  border-radius: 999px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
  overflow: hidden;
}

.user-location-button {
  background: #ffffff;
  border: 0;
  border-radius: 999px;
  color: var(--ink);
  cursor: pointer;
  display: block;
  font: inherit;
  font-size: 0.84rem;
  font-weight: 800;
  min-height: 42px;
  padding: 9px 16px;
  text-transform: uppercase;
}

.user-location-button:hover,
.user-location-button:focus-visible {
  background: var(--accent-soft);
  color: var(--accent-dark);
  outline: none;
}

.leaflet-control-zoom {
  border: 0 !important;
  border-radius: 14px !important;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15) !important;
  overflow: hidden;
}

.leaflet-control-zoom a {
  background: #ffffff;
  border-color: var(--line) !important;
  color: var(--ink);
  font-family: "Nunito Sans", sans-serif;
}

.leaflet-control-zoom a:hover,
.leaflet-control-zoom a:focus-visible {
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.user-location-button:disabled {
  color: var(--muted);
  cursor: wait;
}

#map {
  background: #dfe7df;
  height: 100vh;
  overscroll-behavior: none;
  touch-action: none;
  width: 100%;
}

.location-panel {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: 0 20px 55px rgba(0, 0, 0, 0.2);
  max-height: calc(100vh - 40px);
  max-width: min(380px, calc(100% - 40px));
  min-width: 300px;
  overflow: hidden;
  position: fixed;
  right: 20px;
  top: 20px;
  width: 360px;
  z-index: 1200;
}

.location-panel-close {
  align-items: center;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  font-size: 1.35rem;
  font-weight: 700;
  height: 32px;
  justify-content: center;
  line-height: 1;
  position: absolute;
  right: 12px;
  top: 12px;
  width: 32px;
  z-index: 1;
}

.location-panel-close:hover {
  border-color: var(--accent);
  color: var(--accent-dark);
}

.location-panel-content {
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  padding: 18px;
  padding-right: 52px;
}

.leaflet-popup-content {
  color: var(--ink);
  font-size: 0.92rem;
  line-height: 1.45;
  margin: 16px;
  min-width: 230px;
}

.popup-title {
  color: var(--accent-dark);
  font-family: "Manrope", "Nunito Sans", sans-serif;
  font-size: 1.08rem;
  font-weight: 800;
  margin-bottom: 6px;
}

.popup-heading {
  align-items: flex-start;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.popup-heading-text {
  min-width: 0;
}

.location-profile {
  border: 2px solid #ffffff;
  border-radius: 50%;
  box-shadow: 0 0 0 1px #d8d0c4;
  display: block;
  flex: 0 0 52px;
  height: 52px;
  overflow: hidden;
  transition: box-shadow 120ms ease, transform 120ms ease;
  width: 52px;
}

.location-profile:hover,
.location-profile:focus-visible {
  box-shadow: 0 0 0 2px var(--accent);
  transform: scale(1.04);
}

.location-profile-image {
  background: #ebe4da;
  display: block;
  height: 100%;
  object-fit: cover;
  width: 100%;
}

.popup-category {
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 800;
  margin-bottom: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.popup-row {
  border-top: 1px solid #ebe4da;
  padding: 7px 0;
}

.popup-row strong {
  display: block;
  font-size: 0.78rem;
}

.popup-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 9px;
}

.popup-links a {
  border: 1px solid #aed3cf;
  border-radius: 999px;
  color: var(--accent-dark);
  font-weight: 800;
  padding: 7px 10px;
  text-decoration: none;
}

.popup-links a:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.popup-links .directions-link {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.popup-links .directions-link:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
  color: #ffffff;
}

@media (max-width: 760px) {
  html,
  body {
    height: 100%;
    overflow: hidden;
  }

  .app-shell {
    display: block;
    height: 100dvh;
    min-height: 100dvh;
    overflow: hidden;
  }

  .sidebar {
    border-right: 0;
    bottom: 0;
    box-shadow: 0 -18px 45px rgba(0, 0, 0, 0.18);
    gap: 16px;
    height: 100dvh;
    left: 0;
    max-height: none;
    opacity: 0;
    overflow-y: auto;
    padding: 22px;
    padding-top: max(22px, env(safe-area-inset-top));
    pointer-events: none;
    position: fixed;
    right: 0;
    top: 0;
    transform: translateY(18px);
    transition: opacity 160ms ease, transform 160ms ease;
    width: 100%;
    z-index: 1600;
  }

  .mobile-filter-open .sidebar {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
  }

  .filter-panel-close {
    align-items: center;
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--muted);
    cursor: pointer;
    display: flex;
    font-size: 1.35rem;
    font-weight: 700;
    height: 34px;
    justify-content: center;
    line-height: 1;
    position: fixed;
    right: 18px;
    top: max(18px, env(safe-area-inset-top));
    width: 34px;
    z-index: 1;
  }

  .sidebar-header {
    padding-right: 42px;
  }

  .map-wrap,
  #map {
    height: 100dvh;
    min-height: 100dvh;
  }

  .mobile-search-open {
    align-items: center;
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.16);
    border-radius: 999px;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.18);
    color: var(--ink);
    cursor: pointer;
    display: flex;
    font: inherit;
    font-weight: 700;
    left: 12px;
    min-height: 46px;
    overflow: hidden;
    padding: 11px 14px;
    position: fixed;
    right: 12px;
    text-align: left;
    text-overflow: ellipsis;
    top: max(12px, env(safe-area-inset-top));
    white-space: nowrap;
    z-index: 1100;
  }

  .leaflet-top {
    top: calc(62px + env(safe-area-inset-top));
  }

  .location-panel {
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    border-top-left-radius: 24px;
    border-top-right-radius: 24px;
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
    bottom: 0;
    left: 0;
    max-height: 132px;
    max-width: none;
    min-width: 0;
    overflow: hidden;
    right: 0;
    top: auto;
    transition: max-height 180ms ease;
    width: auto;
    z-index: 1300;
  }

  .location-panel:not(.is-expanded) {
    cursor: grab;
    touch-action: none;
  }

  .location-panel.is-expanded {
    max-height: min(82dvh, 620px);
    touch-action: pan-y;
  }

  .location-panel-handle {
    display: block;
    height: 24px;
    position: relative;
    touch-action: none;
  }

  .location-panel-handle::before {
    background: #c9c0b3;
    border-radius: 999px;
    content: "";
    height: 4px;
    left: 50%;
    position: absolute;
    top: 10px;
    transform: translateX(-50%);
    width: 42px;
  }

  .location-panel-close {
    height: 30px;
    right: 12px;
    top: 12px;
    width: 30px;
  }

  .location-panel-content {
    max-height: calc(min(82dvh, 620px) - 24px);
    overflow-y: hidden;
    padding-top: 0;
  }

  .location-panel.is-expanded .location-panel-content {
    overflow-y: auto;
    padding-bottom: max(18px, env(safe-area-inset-bottom));
  }

  .popup-title {
    padding-right: 38px;
  }

  .popup-heading .popup-title {
    padding-right: 0;
  }

  .location-panel:not(.is-expanded) .popup-row,
  .location-panel:not(.is-expanded) .popup-links {
    display: none;
  }
}
