:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f3f7f4;
  color: #142018;
  --accent: #16803b;
}

* {
  box-sizing: border-box;
}

html,
body,
#app,
#map {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
}

html,
body {
  min-height: 100%;
  overflow: hidden;
}

#app {
  position: relative;
  height: 100vh;
  height: 100dvh;
  padding-top: env(safe-area-inset-top, 0);
  padding-right: env(safe-area-inset-right, 0);
  padding-bottom: env(safe-area-inset-bottom, 0);
  padding-left: env(safe-area-inset-left, 0);
  background: #e7eee9;
}

#map {
  position: relative;
  min-height: 240px;
  background: #dfe7e2;
}

#map > iframe,
#map > div {
  width: 100% !important;
  height: 100% !important;
}

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

.address-search {
  position: absolute;
  top: calc(10px + env(safe-area-inset-top, 0));
  left: calc(10px + env(safe-area-inset-left, 0));
  z-index: 6;
  width: min(460px, calc(100% - 20px - env(safe-area-inset-left, 0) - env(safe-area-inset-right, 0)));
  padding: 8px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 4px 18px rgba(20, 32, 24, 0.2);
}

.address-search-row {
  display: flex;
  gap: 8px;
}

#address-input,
#address-submit {
  min-height: 44px;
  border-radius: 10px;
  font: inherit;
}

#address-input {
  min-width: 0;
  flex: 1;
  padding: 0 12px;
  border: 1px solid #a8b5ac;
  background: #fff;
  color: #142018;
  font-size: 16px;
}

#address-input:focus-visible,
#address-submit:focus-visible {
  outline: 3px solid rgba(22, 128, 59, 0.35);
  outline-offset: 2px;
}

#address-submit {
  padding: 0 16px;
  border: 0;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

#address-submit:disabled {
  opacity: 0.65;
  cursor: wait;
}

.address-status {
  margin: 7px 4px 1px;
  color: #526058;
  font-size: 13px;
  line-height: 1.3;
}

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

.address-status[data-state="error"] {
  color: #a12525;
}

.address-suggestions {
  max-height: min(50vh, 420px);
  margin-top: 8px;
  overflow-y: auto;
  overscroll-behavior: contain;
  border-top: 1px solid #d8e0da;
  border-radius: 0 0 10px 10px;
  background: #fff;
  -webkit-overflow-scrolling: touch;
}

.address-suggestions[hidden] {
  display: none;
}

.address-suggestion {
  display: flex;
  width: 100%;
  min-height: 52px;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 2px;
  padding: 9px 12px;
  border: 0;
  border-bottom: 1px solid #e5ebe7;
  background: #fff;
  color: #142018;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.address-suggestion:last-child {
  border-bottom: 0;
}

.address-suggestion:hover,
.address-suggestion:focus-visible,
.address-suggestion.is-active {
  background: #edf6f0;
  outline: 0;
}

.address-suggestion-name {
  width: 100%;
  overflow: hidden;
  font-size: 16px;
  font-weight: 650;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.address-suggestion-address {
  width: 100%;
  overflow: hidden;
  color: #66736b;
  font-size: 13px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.address-suggestion-state {
  min-height: 52px;
  padding: 16px 12px;
  color: #66736b;
  font-size: 14px;
  line-height: 1.35;
}

.address-suggestion-state[data-state="error"] {
  color: #a12525;
}

.location-control {
  position: absolute;
  right: calc(14px + env(safe-area-inset-right, 0));
  bottom: calc(22px + env(safe-area-inset-bottom, 0));
  z-index: 7;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  pointer-events: none;
}

.location-button {
  display: grid;
  min-width: 48px;
  min-height: 48px;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.97);
  color: #29342d;
  box-shadow: 0 4px 16px rgba(20, 32, 24, 0.28);
  cursor: pointer;
  pointer-events: auto;
}

.location-button svg {
  width: 27px;
  height: 27px;
  fill: currentColor;
}

.location-button:focus-visible {
  outline: 3px solid rgba(22, 128, 59, 0.45);
  outline-offset: 3px;
}

.location-button[aria-busy="true"] {
  opacity: 0.62;
  cursor: wait;
}

.location-status {
  width: max-content;
  max-width: min(280px, calc(100vw - 28px));
  margin: 0;
  padding: 8px 11px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.97);
  color: #526058;
  box-shadow: 0 3px 12px rgba(20, 32, 24, 0.2);
  font-size: 13px;
  line-height: 1.3;
  pointer-events: none;
}

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

.location-status[data-state="error"] {
  color: #a12525;
}

.status-overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: calc(20px + env(safe-area-inset-top, 0))
    calc(20px + env(safe-area-inset-right, 0))
    calc(20px + env(safe-area-inset-bottom, 0))
    calc(20px + env(safe-area-inset-left, 0));
  background: rgba(243, 247, 244, 0.92);
  text-align: center;
}

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

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid rgba(22, 128, 59, 0.25);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

.error-card {
  width: min(360px, 100%);
  padding: 24px;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 14px 38px rgba(20, 32, 24, 0.16);
}

.error-card h1 {
  margin: 0 0 10px;
  font-size: 21px;
}

.error-card p {
  margin: 0 0 18px;
  line-height: 1.45;
  color: #526058;
}

#retry-button {
  min-height: 44px;
  padding: 0 20px;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

#retry-button:focus-visible {
  outline: 3px solid rgba(22, 128, 59, 0.35);
  outline-offset: 3px;
}

.leaflet-control-attribution {
  padding-bottom: env(safe-area-inset-bottom, 0) !important;
  font-size: 10px !important;
}

.parking-popup {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
  color: #142018;
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.parking-popup strong,
.parking-popup p {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.parking-popup strong {
  display: block;
  margin-bottom: 6px;
  font-size: 17px;
}

.parking-popup p {
  margin: 0 0 12px;
  color: #526058;
}

.route-button {
  display: block;
  min-height: 44px;
  padding: 11px 14px;
  border-radius: 11px;
  background: var(--accent);
  color: #ffffff !important;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
}

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

@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation: none;
  }
}

@media (max-width: 420px) {
  .address-search {
    right: calc(10px + env(safe-area-inset-right, 0));
    width: auto;
  }

  #address-submit {
    padding: 0 13px;
  }
}
