html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: Arial, sans-serif;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
}

.sidebar {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 10;
  max-height: 65vh;
  max-height: 65dvh;
  padding: 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
  border-top: 1px solid #ddd;
  background: #fff;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.12);
  -webkit-overflow-scrolling: touch;
  transition: max-height 180ms ease, height 180ms ease;
}

.sidebar.is-collapsed {
  height: 104px;
  max-height: 104px;
  overflow: hidden;
}

.sheet-header {
  position: relative;
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  min-height: 56px;
  flex-shrink: 0;
  touch-action: none;
  user-select: none;
}

.sheet-content {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  touch-action: pan-y;
}

.sheet-grip {
  position: absolute;
  top: 0;
  left: 50%;
  width: 44px;
  height: 4px;
  border-radius: 999px;
  background: #c7c7c7;
  transform: translateX(-50%);
}

.sheet-header h2 {
  grid-column: 2;
  margin: 8px 0 0;
  font-size: 17px;
  font-weight: 700;
  text-align: center;
}

.sheet-toggle {
  grid-column: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin: 8px 0 0;
  border: 1px solid #d1d5db;
  border-radius: 999px;
  background: #fff;
  cursor: pointer;
  touch-action: manipulation;
}

.sheet-toggle-icon {
  width: 10px;
  height: 10px;
  border-top: 2px solid #222;
  border-left: 2px solid #222;
  transform: translateY(3px) rotate(45deg);
  transition: transform 180ms ease;
}

.sidebar:not(.is-collapsed) .sheet-toggle-icon {
  transform: translateY(-2px) rotate(225deg);
}

.sidebar.is-collapsed .sheet-content {
  display: none;
}

.sidebar h1 {
  margin: 0 0 8px 0;
  font-size: 22px;
}

.sidebar p {
  margin: 0 0 16px 0;
  color: #555;
}

.legend div {
  display: flex;
  align-items: center;
  margin-bottom: 8px;
  font-size: 14px;
}

.swatch {
  display: inline-block;
  width: 18px;
  height: 18px;
  margin-right: 10px;
  border-radius: 4px;
}

#map {
  width: 100%;
  height: 100vh;
  height: 100dvh;
}

.legal-consent-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(17, 24, 39, 0.62);
  box-sizing: border-box;
}

.legal-consent-overlay[hidden] {
  display: none;
}

.legal-consent-dialog {
  width: min(100%, 440px);
  max-height: calc(100vh - 40px);
  max-height: calc(100dvh - 40px);
  padding: 22px;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.28);
  box-sizing: border-box;
  overflow-y: auto;
}

.legal-consent-dialog h2 {
  margin: 0 0 12px;
  font-size: 22px;
  line-height: 1.2;
}

.legal-consent-dialog p {
  margin: 0 0 12px;
  color: #374151;
  font-size: 15px;
  line-height: 1.5;
}

.legal-consent-warning {
  padding: 12px;
  border-left: 4px solid #f97316;
  border-radius: 6px;
  background: #fff7ed;
  color: #111827;
  font-weight: 700;
}

.legal-consent-links {
  display: grid;
  gap: 8px;
  margin: 16px 0;
}

.legal-consent-links a {
  color: #2563eb;
  font-size: 15px;
  font-weight: 700;
}

.legal-consent-checkbox {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 16px 0;
  color: #111827;
  font-size: 15px;
  line-height: 1.4;
}

.legal-consent-checkbox input {
  width: 20px;
  height: 20px;
  margin-top: 1px;
  flex: 0 0 auto;
}

#legal-consent-accept {
  width: 100%;
  min-height: 46px;
  padding: 11px 14px;
  border: 1px solid #111827;
  border-radius: 6px;
  background: #111827;
  color: #ffffff;
  cursor: pointer;
  font-size: 15px;
  font-weight: 700;
}

#legal-consent-accept:disabled {
  border-color: #d1d5db;
  background: #e5e7eb;
  color: #6b7280;
  cursor: not-allowed;
}

.maplibregl-popup-content {
  font-size: 13px;
  line-height: 1.4;
  padding: 14px 16px 16px;
}

.filters {
  margin-top: 12px;
}

.filters label {
  display: block;
  margin-bottom: 6px;
  font-size: 14px;
}

.filters select {
  width: 100%;
  min-height: 44px;
  padding: 8px;
  margin-bottom: 12px;
  box-sizing: border-box;
  font-size: 16px;
}

.filters input[type="time"] {
  width: 100%;
  min-height: 44px;
  padding: 8px;
  margin-bottom: 12px;
  box-sizing: border-box;
  font-size: 16px;
}

#location-status {
  margin: 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: white;
  box-shadow: 0 2px 10px #0002;
  font-size: 13px;
  line-height: 1.4;
  max-width: 240px;
}
#location-status:empty { display: none; }
.location-control {
  position: fixed; right: 12px;
  bottom: calc(120px + env(safe-area-inset-bottom));
  z-index: 20;
  display: flex; align-items: flex-end; gap: 8px;
  max-width: calc(100vw - 24px);
}
.floating-locate-btn {
  position: relative; flex-shrink: 0;
  display: grid; place-items: center;
  width: 48px; height: 48px;
  border: 1px solid #cbd5e1; border-radius: 50%;
  background: white; color: #1f2937;
  box-shadow: 0 4px 14px #0003;
  cursor: pointer; touch-action: manipulation;
}
.floating-locate-icon { width: 24px; height: 24px; }
.location-state-badge { position: absolute; right: -2px; bottom: -2px; border-radius: 50%; background: white; font-weight: bold; }
.location-state-badge:not(:empty) { width: 20px; height: 20px; border: 1px solid currentColor; }
.floating-locate-btn[data-state="locating"] { color: #2563eb; border: 3px dotted #2563eb; cursor: wait; }
.floating-locate-btn[data-state="active"] { color: #1265ae; background: #eff6ff; border: 2px solid #1265ae; }
.floating-locate-btn[data-state="unavailable"] { color: #9a3412; background: #fff7ed; }
.floating-locate-btn:focus-visible { outline: 3px solid #2563eb; outline-offset: 3px; }

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

.app-footer {
  margin-top: 18px;
  padding-top: 12px;
  border-top: 1px solid #e5e7eb;
  color: #6b7280;
  font-size: 12px;
  line-height: 1.4;
}

.legend {
  text-align: left;
}

#legend-items {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.legend-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 14px;
}


.user-location-heading {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-left: 9px solid transparent;
  border-right: 9px solid transparent;
  border-bottom: 22px solid rgba(10, 132, 255, 0.28);
  transform: translate(-50%, -100%) rotate(0deg);
  transform-origin: 50% 85%;
  pointer-events: none;
  z-index: 2;
  transition: transform 180ms linear, opacity 140ms ease;
}

.user-location-heading.hidden {
  opacity: 0;
}

.user-location-marker {
  position: relative;
  width: 20px;
  height: 20px;
  overflow: visible;
}

.user-location-pulse {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 34px;
  height: 34px;
  background: rgba(59, 130, 246, 0.22);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  animation: gps-pulse 1.8s ease-out infinite;
  pointer-events: none;
  z-index: 1;
}

.user-location-dot {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 16px;
  height: 16px;
  background: #0a84ff;
  border: 3px solid #ffffff;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-sizing: border-box;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.18);
  z-index: 2;
}

@keyframes gps-pulse {
  0% {
    transform: translate(-50%, -50%) scale(0.55);
    opacity: 0.8;
  }
  70% {
    transform: translate(-50%, -50%) scale(1.2);
    opacity: 0.18;
  }
  100% {
    transform: translate(-50%, -50%) scale(1.35);
    opacity: 0;
  }
}



.maplibregl-popup-content button:not(.maplibregl-popup-close-button) {
  width: 100%;
  min-height: 44px;
  padding: 8px 10px;
  margin-top: 6px;
  border: 1px solid #ccc;
  border-radius: 6px;
  background: #f7f7f7;
  cursor: pointer;
  font-size: 14px;
}

.maplibregl-popup-content button:not(.maplibregl-popup-close-button):hover {
  background: #efefef;
}

@media (min-width: 768px) {
  body {
    display: flex;
  }

  .sidebar {
    position: static;
    display: block;
    overflow-y: auto;
    z-index: auto;
    flex: 0 0 280px;
    width: 280px;
    max-height: none;
    height: 100vh;
    padding: 16px;
    border-top: 0;
    border-right: 1px solid #ddd;
    box-shadow: none;
    transition: none;
  }

  .sidebar.is-collapsed {
    height: 100vh;
    max-height: none;
    overflow-y: auto;
  }

  .sheet-header {
    display: none;
  }

  .sidebar.is-collapsed .sheet-content {
    display: block;
  }

  #map {
    flex: 1;
    width: auto;
    height: 100vh;
  }

  .location-control {
    top: 112px;
    right: 12px;
    bottom: auto;
  }

  .sidebar:not(.is-collapsed) ~ .location-control {
    bottom: auto;
  }

  .filters select,
  .filters input[type="time"] {
    min-height: 0;
    padding: 6px;
    font-size: 14px;
  }
}

.parking-popup { font-size: 14px; line-height: 1.4; max-height: 55vh; overflow-y: auto; }
.parking-popup h3 { margin: 0 40px 6px 0; font-size: 17px; }
.parking-popup p { margin: 6px 0; }
.parking-popup .parking-street-extent { color: #4b5563; }
.parking-popup .parking-rule { font-size: 16px; font-weight: 700; margin-top: 12px; }
.parking-popup .parking-reminder { color: #4b5563; font-size: 12px; margin-top: 12px; }
.parking-popup dt { font-weight: 700; margin-top: 8px; }
.parking-popup dd { margin: 0; }
.parking-actions { display: flex; gap: 8px; }

@media (max-width: 767px) {
  .parking-popup { max-height: calc(50dvh - 130px); }
}

.maplibregl-popup-close-button {
  width: 44px;
  height: 44px;
  font-size: 28px;
  line-height: 44px;
  padding: 0;
  color: #111827;
  border-radius: 6px;
  touch-action: manipulation;
  z-index: 1;
}
.maplibregl-popup-close-button:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: -3px;
}

.map-legend {
  position: fixed; top: max(10px, env(safe-area-inset-top)); left: 10px;
  width: calc(100% - 68px); max-width: 460px;
  box-sizing: border-box; padding: 8px 10px;
  z-index: 5; border-radius: 10px; background: #fff;
  box-shadow: 0 2px 12px #0003;
  font-size: 11px; line-height: 1.3;
}
.map-legend h2 { font-size: 12px; margin: 0 0 5px; }
.legend-scale { display: flex; align-items: center; gap: 6px; margin-bottom: 5px; }
.legend-scale strong { width: 46px; flex-shrink: 0; }
.legend-steps { display: flex; flex: 1; gap: 3px; }
.legend-step { flex: 1; text-align: center; white-space: nowrap; }
.legend-step i { display: block; height: 7px; border-radius: 2px; margin-bottom: 2px; }
.legend-categories { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 6px; padding-top: 3px; border-top: 1px solid #e5e7eb; }
.legend-categories span { display: flex; align-items: center; gap: 5px; }
.legend-categories i { width: 12px; height: 5px; border-radius: 2px; flex-shrink: 0; }
@media (min-width: 768px) {
  .map-legend { left: 292px; width: calc(100% - 360px); }
}

@media (max-width: 767px) {
  .sidebar:not(.is-collapsed) ~ .location-control {
    bottom: calc(65dvh + 16px + env(safe-area-inset-bottom));
  }
}

.map-legend #legend-items { display: block; }
.location-message { position: relative; min-width: 0; }
.location-message[hidden] { display: none; }
.location-message #location-status { padding-right: 38px; }
#location-dismiss {
  position: absolute; top: 0; right: 0;
  width: 36px; height: 44px; border: 0; background: transparent;
  font-size: 24px; color: #475569; cursor: pointer;
}

.legend-scale strong small { display: block; font-size: 10px; font-weight: 400; color: #475569; }

.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.place-search-section { margin: 8px 0 18px; }
#place-search-form { display: flex; flex-wrap: nowrap; gap: 6px; }
#place-search { flex: 1; width: 0; min-width: 0; box-sizing: border-box; min-height: 44px; padding: 10px; font-size: 16px; border: 1px solid #94a3b8; border-radius: 7px; }
#place-search::placeholder { color: #6b7280; opacity: 1; font-size: 12px; }
#place-search-submit { flex: 0 0 44px; min-height: 44px; padding: 4px; border: 0; border-radius: 6px; background: #EB5FD1; color: #243247; font-size: 26px; cursor: pointer; }
#place-search-submit:disabled { opacity: 0.6; cursor: wait; }
#place-search-status { font-size: 13px; line-height: 1.4; margin: 8px 0; }
#place-search-status:empty { display: none; }
#place-search-results { list-style: none; margin: 8px 0; padding: 0; max-height: 220px; overflow-y: auto; }
#place-search-results:empty { display: none; }
#place-search-results button { width: 100%; text-align: left; font-size: 14px; line-height: 1.4; min-height: 44px; padding: 10px; border: 0; border-bottom: 1px solid #e2e8f0; background: #f8fafc; cursor: pointer; }
#place-search-results button:hover, #place-search-results button:focus-visible { background: #dbeafe; }
.sidebar .search-attribution { font-size: 11px; margin: 8px 0; }
.search-map-notice { position: fixed; z-index: 6; left: 12px; right: 76px; bottom: calc(120px + env(safe-area-inset-bottom)); padding: 12px 42px 12px 12px; background: white; border-radius: 8px; box-shadow: 0 2px 12px #0003; font-size: 14px; }
.search-map-notice[hidden] { display: none; }
.search-map-notice p { margin: 0; }
#search-map-notice-dismiss { position: absolute; top: 0; right: 0; width: 40px; height: 44px; background: transparent; border: 0; font-size: 24px; cursor: pointer; }
@media (min-width: 768px) { .search-map-notice { left: 296px; bottom: 40px; max-width: 420px; } }

#place-search-clear { min-height: 44px; border: 0; background: transparent; color: #1d4ed8; text-decoration: underline; cursor: pointer; padding: 6px 0; }
#place-search-clear[hidden] { display: none; }

/* A consistent type scale and control treatment for the filters panel. */
.sidebar { color: #243247; font-size: 14px; line-height: 1.5; }
.sidebar button, .sidebar input, .sidebar select { font-family: inherit; }
.sheet-header h2 { font-size: 17px; font-weight: 600; }
.sheet-toggle { background: #f8fafc; border-color: #e2e8f0; }
.sheet-content { padding-top: 12px; }
.sidebar .desktop-filter-title { display: none; }
.place-search-section { margin: 0 0 20px; padding-bottom: 16px; border-bottom: 1px solid #e2e8f0; }
#place-search, .filters select, .filters input[type="time"] {
  min-height: 46px; border: 1px solid #cbd5e1; border-radius: 8px;
  background-color: #f8fafc; color: #243247; font-size: 16px; font-weight: 400;
  padding: 10px 12px; box-sizing: border-box;
}
.filters { margin-top: 0; }
.filters label { font-size: 14px; font-weight: 500; margin-bottom: 6px; }
.filters select, .filters input[type="time"] { margin-bottom: 18px; }
.filters select {
  appearance: none; -webkit-appearance: none; padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath d='m4 6 4 4 4-4' fill='none' stroke='%2364748b' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
.filters input[type="time"] { appearance: none; -webkit-appearance: none; text-align: left; }
.filters input[type="time"]::-webkit-date-and-time-value { text-align: left; }
.filters select:disabled, .filters input:disabled {
  background-color: #f1f5f9; color: #64748b; border-color: #e2e8f0; opacity: 1; -webkit-text-fill-color: #64748b;
}
.filters label.checkbox { display: flex; align-items: center; gap: 10px; min-height: 44px; margin: 0; font-weight: 400; }
.filters .checkbox input { width: 18px; height: 18px; margin: 0; accent-color: #EB5FD1; flex-shrink: 0; }
.sidebar .search-attribution { font-size: 12px; line-height: 1.5; margin: 8px 0 0; color: #64748b; }
.search-attribution a { color: inherit; text-underline-offset: 2px; }
#place-search-submit { border-radius: 8px; }
#place-search-clear { font-size: 14px; text-underline-offset: 3px; }
.sidebar :is(input, select, button, a):focus-visible { outline: 2px solid #2563eb; outline-offset: 2px; }
.app-footer { margin-top: 20px; padding-top: 16px; font-size: 12px; color: #64748b; }
.app-footer span { display: block; }
.app-footer .footer-brand { font-size: 14px; font-weight: 600; color: #243247; margin-bottom: 2px; }
@media (min-width: 768px) {
  .sidebar .desktop-filter-title { display: block; font-size: 17px; font-weight: 600; margin: 0 0 16px; }
}

/* Mutually exclusive view-mode buttons, with native radio keyboard support. */
.view-mode-control { border: 0; padding: 0; margin: 0 0 18px; min-width: 0; }
.view-mode-control legend { font-size: 14px; font-weight: 500; padding: 0; margin-bottom: 6px; }
.view-mode-options { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.filters .view-mode-options label {
  margin: 0; min-height: 46px; display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: #64748b; font-weight: 500; border: 1px solid #cbd5e1;
  border-radius: 8px; background: #f8fafc; box-sizing: border-box;
}
.filters .view-mode-options input:checked + label { color: #243247; border-color: #EB5FD1; background: #EB5FD1; font-weight: 600; }
.view-mode-options input:focus-visible + label { outline: 2px solid #2563eb; outline-offset: 2px; }

#tour-help { position: fixed; right: 14px; top: 172px; z-index: 21; width: 44px; height: 44px; border: 1px solid #cbd5e1; border-radius: 50%; background: white; color: #243247; font: 600 22px system-ui; cursor: pointer; box-shadow: 0 2px 8px #0002; }
#tour-panel { position: fixed; bottom: 110px; left: 12px; right: 12px; z-index: 30; max-width: 380px; padding: 18px; box-sizing: border-box; border: 1px solid #cbd5e1; border-radius: 14px; background: white; color: #243247; box-shadow: 0 4px 24px #0003; font: 14px/1.5 system-ui; max-height: 45dvh; overflow-y: auto; }
#tour-panel[hidden] { display: none; }
#tour-panel h2 { font-size: 18px; margin: 4px 0 8px; }
#tour-panel p { margin: 0 0 10px; }
#tour-progress { color: #64748b; font-size: 12px; }
#tour-welcome { font-weight: 600; }
.tour-actions { display: flex; gap: 8px; }
.tour-actions button { min-height: 44px; padding: 8px 12px; border: 1px solid #cbd5e1; border-radius: 8px; background: white; color: #243247; font: inherit; cursor: pointer; }
#tour-skip { margin-right: auto; border-color: transparent; }
#tour-next { background: #1d4ed8; border-color: #1d4ed8; color: white; }
#tour-back:disabled { opacity: .45; cursor: default; }
.tour-highlight { outline: 3px solid #2563eb; outline-offset: -3px; }
#tour-help:focus-visible, .tour-actions button:focus-visible { outline: 2px solid #2563eb; outline-offset: 2px; }
@media (max-width: 767px) { #tour-panel.tour-above-sheet { top: max(10px, env(safe-area-inset-top)); bottom: auto; max-height: calc(100dvh - 130px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); } }
@media (min-width: 768px) { #tour-panel { left: 300px; bottom: 24px; } }

.sheet-logo { grid-column: 1; grid-row: 1; width: 30px; height: 50px; object-fit: contain; margin-top: 6px; }
#tour-welcome { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
#tour-welcome[hidden] { display: none; }
#tour-welcome img { width: 36px; height: 60px; object-fit: contain; flex-shrink: 0; }
#tour-welcome p { margin: 0; }
@media (min-width: 768px) {
  .sidebar .desktop-filter-title { display: flex; align-items: center; gap: 12px; }
  .desktop-filter-title img { width: 36px; height: 60px; object-fit: contain; }
}

/* Draw attention to the current walkthrough target without moving it. */
.tour-highlight {
  animation: tour-highlight-pulse 1.8s ease-in-out infinite;
}
@keyframes tour-highlight-pulse {
  0%, 100% { box-shadow: inset 0 0 0 2px rgb(37 99 235 / 25%), 0 0 0 2px rgb(37 99 235 / 15%), 0 0 8px rgb(37 99 235 / 20%); }
  50% { box-shadow: inset 0 0 12px 2px rgb(37 99 235 / 30%), 0 0 0 5px rgb(37 99 235 / 25%), 0 0 22px 5px rgb(37 99 235 / 45%); }
}
@media (prefers-reduced-motion: reduce) {
  .tour-highlight { animation: none; box-shadow: inset 0 0 0 2px rgb(37 99 235 / 30%), 0 0 10px rgb(37 99 235 / 35%); }
}

/* Animate a rounded wrapper: native checkbox rendering can hide box shadows. */
.checkbox-tour-target { display: inline-flex; width: 18px; height: 18px; flex-shrink: 0; border-radius: 5px; }
.checkbox-tour-target.tour-highlight { outline-offset: 2px; }
@media (min-width: 768px) {
  /* Give the complete search prompt enough room on the desktop sidebar. */
  .sidebar { flex-basis: 360px; width: 360px; }
  .map-legend { left: 372px; width: calc(100% - 440px); }
  .search-map-notice { left: 376px; }
  #tour-panel { left: 380px; }
  #place-search { padding-left: 8px; padding-right: 8px; }
  #place-search::placeholder { font-size: 12px; }
}

/* Keep highlight halos inside the scrollable panel's clipping boundary. */
.sheet-content {
  padding-left: 12px;
  padding-right: 12px;
  margin-left: -12px;
  margin-right: -12px;
}

#parking-data-status { margin: 6px 0 0; font-size: 11px; line-height: 1.35; color: #92400e; }
