:root {
  --green: #238636;
  --green-dark: #116329;
  --ink: #17212b;
  --muted: #5f6b76;
  --line: #c7cfd6;
  --panel: #ffffff;
  --page: #eef1f3;
  --focus: #0969da;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; }
body {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--page);
}
button, input { font: inherit; }

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.skip-link {
  position: fixed;
  left: .5rem;
  top: -5rem;
  z-index: 3000;
  padding: .7rem .9rem;
  border: 2px solid var(--focus);
  border-radius: 4px;
  background: #fff;
  color: #000;
  font-weight: 700;
}
.skip-link:focus { top: .5rem; }

.map-toolbar {
  position: relative;
  z-index: 1100;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: .7rem 1rem;
  padding: .65rem 1rem .75rem;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .12);
}

.search-tools {
  display: grid;
  grid-template-columns: repeat(2, minmax(210px, 1fr));
  gap: .65rem;
  min-width: 0;
}
.search-container { position: relative; min-width: 0; }
.search-form { min-width: 0; }
.search-form label { display: block; margin-bottom: .25rem; font-size: .9rem; font-weight: 700; }
.search-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .4rem; }
input[type="search"] {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  padding: .55rem .65rem;
  border: 1px solid #7d8993;
  border-radius: 4px;
  color: var(--ink);
  background: #fff;
}

.button {
  min-height: 42px;
  border: 1px solid var(--green-dark);
  border-radius: 4px;
  padding: .52rem .78rem;
  background: var(--green);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}
.button:hover { background: var(--green-dark); }
.button:disabled { cursor: not-allowed; opacity: .65; }
.button-secondary { background: #fff; color: var(--ink); border-color: #77838d; }
.button-secondary:hover { background: #f1f3f5; }

input[type="search"]:focus-visible,
button:focus-visible,
a:focus-visible,
summary:focus-visible,
#map:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.toolbar-actions { display: flex; gap: .45rem; align-items: flex-end; flex-wrap: wrap; }

.search-results {
  position: absolute;
  top: calc(100% + .35rem);
  left: 0;
  right: 0;
  z-index: 1500;
  max-height: min(45vh, 330px);
  overflow-y: auto;
  padding: .35rem;
  border: 1px solid #7d8993;
  border-radius: 4px;
  background: #fff;
  box-shadow: 0 5px 16px rgba(0, 0, 0, .22);
}
.search-results[hidden] { display: none; }
.search-results-heading { margin: .2rem .35rem .4rem; color: var(--muted); font-size: .82rem; font-weight: 700; }
.result-button {
  display: block;
  width: 100%;
  min-height: 44px;
  margin: 0;
  padding: .55rem .65rem;
  text-align: left;
  border: 0;
  border-radius: 3px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}
.result-button:hover, .result-button:focus-visible { background: #eef4f0; }
.result-button + .result-button { border-top: 1px solid #e3e7ea; }
.result-primary, .result-meta { display: block; }
.result-primary { font-weight: 700; }
.result-meta { margin-top: .12rem; color: var(--muted); font-size: .8rem; }
.no-results { margin: .35rem; font-size: .9rem; }

.map-region { height: auto; min-height: 0; }
.map-panel, #map { width: 100%; height: 100%; min-height: 0; }
.map-panel { position: relative; }

.status[hidden] { display: none; }
.status {
  position: absolute;
  left: 50%;
  bottom: 1rem;
  z-index: 800;
  max-width: calc(100% - 2rem);
  transform: translateX(-50%);
  padding: .48rem .72rem;
  border: 1px solid #7d8993;
  border-radius: 4px;
  background: rgba(255, 255, 255, .96);
  color: #34404a;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .18);
  font-size: .86rem;
}
.status.success { border-color: var(--green-dark); }
.status.error { border-color: #b42318; color: #7a1b12; }
.status.is-quiet { opacity: .9; }

.legend {
  position: absolute;
  left: .65rem;
  bottom: 2.25rem;
  z-index: 800;
  display: flex;
  align-items: center;
  gap: .45rem;
  padding: .45rem .55rem;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: rgba(255, 255, 255, .95);
  box-shadow: 0 1px 5px rgba(0, 0, 0, .14);
  font-size: .82rem;
  font-weight: 650;
}
.legend-swatch { width: 24px; height: 15px; border: 2px solid var(--green-dark); background: rgba(35, 134, 54, .54); }

.map-info {
  position: absolute;
  right: .65rem;
  bottom: 2.25rem;
  z-index: 800;
  width: min(330px, calc(100% - 1.3rem));
  border: 1px solid var(--line);
  border-radius: 4px;
  background: rgba(255, 255, 255, .97);
  box-shadow: 0 1px 5px rgba(0, 0, 0, .14);
  font-size: .82rem;
}
.map-info summary { padding: .48rem .6rem; font-weight: 700; cursor: pointer; }
.map-info-content { padding: 0 .65rem .55rem; }
.map-info-content p { margin: .35rem 0; line-height: 1.4; }

.park-popup { min-width: min(250px, 65vw); }
.park-popup .popup-kicker { margin: 0 0 .1rem; color: var(--muted); font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .025em; }
.park-popup h2 { margin: 0 0 .5rem; font-size: 1.08rem; line-height: 1.25; }
.park-popup dl { display: grid; grid-template-columns: auto 1fr; gap: .2rem .5rem; margin: .3rem 0 .6rem; }
.park-popup dt { font-weight: 700; }
.park-popup dd { margin: 0; }
.park-popup a { color: #075aa8; font-weight: 700; }
.leaflet-popup { max-width: calc(100vw - 36px); }
.leaflet-popup-content-wrapper { max-width: calc(100vw - 36px); }
.leaflet-popup-content { width: auto !important; margin: 13px 16px; }
.leaflet-control-attribution { font-size: 10px; }
.leaflet-container a.leaflet-popup-close-button { width: 32px; height: 32px; padding: 7px 7px 0 0; font-size: 24px; }

@media (max-width: 900px) {
  .map-toolbar {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "searches searches"
      ". actions";
    align-items: center;
    gap: .45rem .65rem;
    padding: .55rem .65rem .65rem;
  }
  .search-tools { grid-area: searches; }
  .toolbar-actions { grid-area: actions; justify-content: flex-end; }
  .toolbar-actions .button { min-height: 38px; padding: .42rem .58rem; font-size: .86rem; }
  .search-form label { font-size: .82rem; }
  .search-row .button { padding-inline: .65rem; }
  .legend { left: .45rem; bottom: 1.8rem; }
  .map-info { right: .45rem; bottom: 1.8rem; }
  .status { bottom: .45rem; }
}

@media (max-width: 600px) {
  .search-tools { grid-template-columns: 1fr; gap: .5rem; }
  .map-toolbar {
    grid-template-columns: 1fr;
    grid-template-areas:
      "searches"
      "actions";
  }
  .toolbar-actions { justify-content: stretch; }
  .toolbar-actions .button { flex: 1; }
  .search-results { max-height: min(36vh, 260px); }
}

@media (max-width: 420px) {
  .toolbar-actions { gap: .35rem; }
  .toolbar-actions .button { min-height: 36px; padding: .38rem .45rem; font-size: .8rem; }
  .map-info { width: auto; }
  .map-info[open] { left: .45rem; }
  .legend { bottom: 2.25rem; }
}

@media (max-height: 520px) {
  .map-toolbar { padding-top: .4rem; padding-bottom: .45rem; }
  .search-form label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }
  .search-tools { gap: .45rem; }
  .toolbar-actions .button, input[type="search"], .button { min-height: 36px; }
  .legend { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}

@media (forced-colors: active) {
  .legend-swatch { forced-color-adjust: none; }
}
