:root {
  --ink: #1f2933;
  --muted: #617181;
  --line: #dde4ec;
  --paper: #ffffff;
  --surface: rgba(255, 255, 255, 0.96);
  --green: #1f9d55;
  --orange: #d98212;
  --red: #cf3f47;
  --blue: #1769aa;
  --blue-deep: #10517f;
  --focus: rgba(23, 105, 170, 0.22);
  --shadow: 0 18px 40px rgba(21, 38, 55, 0.18), 0 3px 10px rgba(21, 38, 55, 0.12);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body,
.map-app,
#map {
  height: 100%;
}

html,
body {
  overflow: hidden;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: Inter, "Segoe UI", Roboto, Arial, Helvetica, sans-serif;
  background: #d8e7ee;
}

button,
input {
  font: inherit;
}

button {
  min-height: 36px;
  border: 1px solid rgba(23, 105, 170, 0.18);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 650;
  background: var(--paper);
  cursor: pointer;
  transition: background-color 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease, color 0.16s ease;
}

button:hover {
  border-color: var(--blue);
  box-shadow: 0 4px 14px rgba(23, 105, 170, 0.14);
}

button:focus-visible,
input:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

button:disabled {
  cursor: progress;
  opacity: 0.65;
}

.map-app {
  position: relative;
}

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

.search-panel {
  position: absolute;
  z-index: 1100;
  top: 18px;
  left: 18px;
  width: min(360px, calc(100vw - 36px));
  pointer-events: none;
}

.search-stack {
  display: grid;
  gap: 7px;
  padding: 8px;
  border: 1px solid rgba(31, 41, 51, 0.1);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  pointer-events: auto;
  backdrop-filter: blur(12px);
}

.search-row {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  min-height: 42px;
  border: 1px solid rgba(31, 41, 51, 0.12);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 1px 2px rgba(21, 38, 55, 0.06);
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.search-row:focus-within {
  border-color: rgba(23, 105, 170, 0.58);
  box-shadow: 0 0 0 4px var(--focus), 0 2px 8px rgba(21, 38, 55, 0.08);
}

.search-row::before {
  content: "";
  position: absolute;
  z-index: 1;
  left: 16px;
  top: 50%;
  width: 12px;
  height: 12px;
  border: 2px solid var(--muted);
  border-radius: 50%;
  transform: translateY(-50%);
  pointer-events: none;
}

.search-row-start::after {
  content: "";
  position: absolute;
  z-index: 1;
  left: 29px;
  top: 26px;
  width: 7px;
  height: 2px;
  border-radius: 2px;
  background: var(--muted);
  transform: rotate(45deg);
  pointer-events: none;
}

.search-row-end::before {
  width: 13px;
  height: 13px;
  border-color: var(--blue);
  background: radial-gradient(circle at center, var(--blue) 0 3px, transparent 4px);
}

.search-row input {
  min-width: 0;
  width: 100%;
  border: 0;
  border-radius: 8px 0 0 8px;
  padding: 0 12px 0 41px;
  color: var(--ink);
  font-size: 13px;
  background: transparent;
  outline: 0;
}

.search-row input::placeholder {
  color: #7b8996;
}

.search-row button {
  min-height: 40px;
  border-width: 0 0 0 1px;
  border-radius: 0 8px 8px 0;
  color: var(--blue);
  background: transparent;
}

.search-row button:hover {
  color: var(--blue-deep);
  background: #f2f7fb;
  box-shadow: none;
}

.panel-actions {
  display: flex;
  gap: 7px;
  align-items: center;
}

.primary-action {
  color: #ffffff;
  border-color: var(--blue);
  background: var(--blue);
  box-shadow: 0 8px 20px rgba(23, 105, 170, 0.24);
}

.primary-action:hover {
  color: #ffffff;
  border-color: var(--blue-deep);
  background: var(--blue-deep);
}

.text-action {
  min-height: 30px;
  border: 0;
  padding: 0 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  background: transparent;
}

.text-action:hover {
  color: var(--red);
  background: transparent;
  box-shadow: none;
}

.route-fields {
  display: grid;
  gap: 7px;
}

.route-options {
  display: grid;
  gap: 7px;
  border: 1px solid rgba(31, 41, 51, 0.1);
  border-radius: 8px;
  padding: 8px;
  background: #f7fafc;
}

.option-title {
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
}

.time-inputs {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 7px;
  align-items: end;
}

.time-inputs label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.time-inputs input {
  width: 100%;
  min-height: 34px;
  border: 1px solid rgba(31, 41, 51, 0.12);
  border-radius: 8px;
  padding: 0 10px;
  color: var(--ink);
  background: #ffffff;
}

.time-inputs button {
  min-height: 34px;
  color: var(--blue);
  background: #ffffff;
}

.traffic-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 8px;
  align-items: center;
}

.traffic-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 32px;
  border: 1px solid rgba(31, 41, 51, 0.1);
  border-radius: 8px;
  padding: 0 10px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 750;
  background: #ffffff;
}

.traffic-toggle input {
  width: 15px;
  height: 15px;
  accent-color: var(--blue);
}

.traffic-row small {
  min-width: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.status-row {
  display: flex;
  align-items: stretch;
  gap: 6px;
}

.status-note {
  flex: 1;
  min-width: 0;
  margin: 0;
  border: 1px solid rgba(31, 41, 51, 0.08);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
  background: #ffffff;
}

.status-note:empty {
  display: none;
}

.show-parking-button {
  flex: 0 0 auto;
  min-height: 0;
  padding: 0 9px;
  color: var(--blue);
  font-size: 11px;
  background: #ffffff;
}

.parking-results {
  display: grid;
  gap: 6px;
  max-height: min(320px, calc(100vh - 300px));
  max-height: min(320px, calc(100dvh - 300px));
  overflow: auto;
  overscroll-behavior: contain;
}

.parking-result {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  border: 1px solid rgba(31, 41, 51, 0.1);
  border-left: 4px solid var(--blue);
  border-radius: 8px;
  padding: 8px;
  background: #ffffff;
}

.parking-result strong {
  display: block;
  color: var(--ink);
  font-size: 12px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.parking-result small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.3;
}

.parking-result button {
  min-height: 32px;
  padding: 0 9px;
  color: var(--blue);
  font-size: 11px;
}

.data-source-card {
  position: absolute;
  z-index: 1050;
  left: 18px;
  bottom: 18px;
  display: grid;
  gap: 3px;
  max-width: min(260px, calc(100vw - 36px));
  border: 1px solid rgba(31, 41, 51, 0.1);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 8px 24px rgba(21, 38, 55, 0.16);
  pointer-events: none;
}

.data-source-state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 800;
}

.data-source-state::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
}

.data-source-card.is-live .data-source-state::before {
  background: var(--green);
}

.data-source-card.is-snapshot .data-source-state::before {
  background: var(--orange);
}

.data-source-card.is-demo .data-source-state::before,
.data-source-card.is-error .data-source-state::before {
  background: var(--red);
}

.data-source-card small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.3;
}

.suggestions {
  position: absolute;
  z-index: 1200;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  display: none;
  max-height: 250px;
  overflow: auto;
  border: 1px solid rgba(31, 41, 51, 0.12);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: 0 14px 34px rgba(21, 38, 55, 0.2);
}

.suggestions.is-open {
  display: block;
}

.suggestion-item {
  display: block;
  width: 100%;
  min-height: 0;
  border: 0;
  border-radius: 0;
  padding: 8px 10px;
  color: var(--ink);
  font-weight: 400;
  font-size: 12px;
  line-height: 1.35;
  text-align: left;
  background: var(--paper);
}

.suggestion-item:hover {
  background: #edf5fb;
}

.marker-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border: 2px solid #ffffff;
  border-radius: 50%;
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  box-shadow: 0 3px 10px rgba(21, 38, 55, 0.24);
}

.marker-label.is-route-match {
  outline: 3px solid var(--blue);
  outline-offset: 2px;
}

.marker-label.is-route-muted {
  opacity: 0.34;
  filter: grayscale(1);
  box-shadow: none;
}

.search-pin {
  display: block;
  width: 26px;
  height: 26px;
  border: 3px solid #ffffff;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  background: var(--blue);
  box-shadow: 0 6px 16px rgba(21, 38, 55, 0.28);
}

.leaflet-control-zoom {
  margin: 16px;
  border: 1px solid rgba(31, 41, 51, 0.12);
  border-radius: 8px;
  overflow: hidden;
  background: #ffffff;
  box-shadow: 0 8px 24px rgba(21, 38, 55, 0.16);
}

.leaflet-control-zoom a {
  width: 36px;
  height: 36px;
  color: var(--ink);
  font: 700 22px/34px Arial, Helvetica, sans-serif;
  text-align: center;
  text-decoration: none;
  background: #ffffff;
}

.leaflet-control-zoom a:hover {
  color: var(--blue);
  background: #f2f7fb;
}

.leaflet-control-zoom a + a {
  border-top: 1px solid var(--line);
}

.leaflet-control-attribution {
  padding: 3px 7px;
  color: var(--muted);
  font-size: 11px;
  background: rgba(255, 255, 255, 0.86);
}

.leaflet-control-attribution a {
  color: var(--blue);
}

.search-pin::after {
  content: "";
  position: absolute;
  inset: 6px;
  border-radius: 50%;
  background: #ffffff;
}

.leaflet-popup-content {
  min-width: 230px;
  margin: 14px 16px;
  line-height: 1.38;
}

.popup-title {
  display: block;
  overflow-wrap: anywhere;
}

.popup-grid {
  display: grid;
  gap: 6px;
  margin-top: 10px;
  font-size: 13px;
}

.popup-grid div {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 8px;
}

.popup-grid dt {
  color: var(--muted);
}

.popup-grid dd {
  margin: 0;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.popup-gps dd {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.popup-gps code {
  border: 1px solid rgba(31, 41, 51, 0.1);
  border-radius: 6px;
  padding: 3px 5px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  background: #f7fafc;
}

.copy-gps-button {
  min-height: 26px;
  padding: 0 8px;
  color: var(--blue);
  font-size: 11px;
}

.traffic-description {
  max-height: 150px;
  margin: 10px 0 0;
  overflow: auto;
  white-space: pre-line;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

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

@media (max-width: 640px) {
  .search-panel {
    top: auto;
    right: 10px;
    bottom: calc(10px + env(safe-area-inset-bottom));
    left: 10px;
    width: auto;
    max-height: min(68vh, 560px);
    max-height: min(68dvh, 560px);
  }

  .search-stack {
    max-height: inherit;
    overflow: auto;
    overscroll-behavior: contain;
    padding: 8px;
    border-radius: 12px;
    box-shadow: 0 16px 34px rgba(21, 38, 55, 0.22), 0 3px 10px rgba(21, 38, 55, 0.14);
  }

  .search-row {
    min-height: 44px;
  }

  .search-row button,
  button {
    min-height: 40px;
    padding: 0 10px;
  }

  .search-row input {
    font-size: 16px;
  }

  .panel-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
  }

  .panel-actions button {
    min-width: 0;
  }

  .time-inputs {
    grid-template-columns: 1fr 1fr;
  }

  .time-inputs button {
    grid-column: 1 / -1;
  }

  .traffic-row {
    grid-template-columns: 1fr;
  }

  .status-row {
    display: grid;
    grid-template-columns: 1fr;
  }

  .show-parking-button {
    width: 100%;
    min-height: 38px;
  }

  .parking-results {
    max-height: min(32vh, 250px);
    max-height: min(32dvh, 250px);
    padding-right: 2px;
  }

  .parking-result {
    grid-template-columns: minmax(0, 1fr);
    gap: 7px;
  }

  .parking-result button {
    width: 100%;
    min-height: 36px;
  }

  .data-source-card {
    top: 12px;
    right: 12px;
    bottom: auto;
    left: auto;
    max-width: min(210px, calc(100vw - 24px));
    padding: 7px 9px;
    pointer-events: none;
  }

  .leaflet-bottom.leaflet-right {
    top: 68px;
    right: 0;
    bottom: auto;
  }

  .leaflet-control-zoom {
    margin: 12px;
  }

  .leaflet-control-attribution {
    display: none;
  }

  .leaflet-popup-content {
    min-width: 210px;
    max-width: calc(100vw - 72px);
  }

  .popup-grid div {
    grid-template-columns: 78px 1fr;
  }
}

@media (max-width: 390px) {
  .search-panel {
    right: 8px;
    bottom: calc(8px + env(safe-area-inset-bottom));
    left: 8px;
    max-height: min(72vh, 560px);
    max-height: min(72dvh, 560px);
  }

  .search-stack {
    gap: 6px;
    padding: 7px;
  }

  .search-row {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .search-row button {
    padding: 0 9px;
    font-size: 12px;
  }

  .panel-actions {
    grid-template-columns: 1fr 1fr auto;
  }

  .route-options {
    padding: 7px;
  }

  .parking-results {
    max-height: min(30vh, 220px);
    max-height: min(30dvh, 220px);
  }
}

@media (min-width: 641px) and (max-width: 960px) {
  .search-panel {
    width: min(340px, calc(100vw - 36px));
  }

  .parking-results {
    max-height: min(300px, calc(100vh - 300px));
    max-height: min(300px, calc(100dvh - 300px));
  }
}
