:root {
  color-scheme: light;
  --paper: #f7f3e8;
  --ink: #1e2a24;
  --muted: #617066;
  --panel: #fffdf6;
  --line: rgba(30, 42, 36, 0.18);
  --accent: #0f8b6f;
  --accent-dark: #08614d;
  --warn: #b94e26;
  --shadow: 0 18px 44px rgba(29, 39, 34, 0.22);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  background: var(--paper);
  color: var(--ink);
  overflow: hidden;
}

#app {
  position: fixed;
  inset: 0;
}

#map {
  touch-action: none;
}

.ol-zoom {
  top: calc(env(safe-area-inset-top) + 12px);
  left: 12px;
}

.ol-control button {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 6px 18px rgba(29, 39, 34, 0.16);
  font-size: 20px;
}

.ol-control button:focus,
button:focus-visible,
select:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(15, 139, 111, 0.35);
  outline-offset: 2px;
}

.icon-button,
.fab,
.primary-button,
.secondary-button,
.clear-button,
.stepper-button {
  border: 0;
  cursor: pointer;
  font: inherit;
}

.locate-button {
  position: fixed;
  top: calc(env(safe-area-inset-top) + 120px);
  left: 12px;
  z-index: 2;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 6px 18px rgba(29, 39, 34, 0.16);
  font-size: 22px;
}

.fab {
  position: fixed;
  right: calc(env(safe-area-inset-right) + 18px);
  bottom: calc(env(safe-area-inset-bottom) + 18px);
  z-index: 4;
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  box-shadow: var(--shadow);
  font-size: 24px;
  transition: transform 160ms ease, background 160ms ease;
}

.fab[aria-expanded="true"] {
  transform: rotate(90deg);
  background: var(--accent-dark);
}

.route-panel {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 3;
  display: grid;
  gap: 16px;
  max-height: calc(100vh - env(safe-area-inset-top) - 8px);
  max-height: calc(100dvh - env(safe-area-inset-top) - 8px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 10px 16px calc(env(safe-area-inset-bottom) + 92px);
  background: var(--panel);
  border-top: 1px solid var(--line);
  box-shadow: 0 -18px 50px rgba(29, 39, 34, 0.2);
  transform: translateY(105%);
  transition: transform 180ms ease;
}

.route-panel.is-open {
  transform: translateY(0);
}

.panel-grip {
  justify-self: center;
  width: 42px;
  height: 4px;
  border-radius: 999px;
  background: rgba(30, 42, 36, 0.22);
}

.panel-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 6px;
}

.meta-label,
.status-text {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

#minimumDistance {
  display: block;
  margin-top: 2px;
  font-size: 28px;
  line-height: 1.05;
}

.controls-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

select,
input[type="number"] {
  width: 100%;
}

select {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  padding: 0 34px 0 12px;
  font: inherit;
  font-weight: 650;
}

.distance-control {
  display: grid;
  gap: 6px;
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.distance-stepper {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) 56px;
  gap: 10px;
  align-items: stretch;
}

.stepper-button {
  min-height: 52px;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-size: 28px;
  font-weight: 900;
  line-height: 1;
}

.distance-input-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  min-height: 52px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  overflow: hidden;
}

.distance-input-wrap input {
  min-width: 0;
  height: 100%;
  border: 0;
  background: transparent;
  color: var(--ink);
  padding: 0 4px 0 12px;
  text-align: right;
  font: inherit;
  font-size: 22px;
  font-weight: 850;
}

.distance-input-wrap span {
  padding: 0 12px 0 4px;
  color: var(--muted);
  font-size: 15px;
  font-weight: 800;
}

.panel-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  align-items: start;
}

.action-stack {
  display: grid;
  gap: 6px;
}

.primary-button,
.secondary-button {
  appearance: none;
  display: grid;
  place-items: center;
  min-height: 48px;
  border-radius: 8px;
  font-weight: 800;
  text-align: center;
  text-decoration: none;
}

.primary-button {
  background: var(--accent);
  color: white;
}

.secondary-button {
  border: 1px solid var(--line);
  background: white;
  color: var(--ink);
}

.secondary-button.is-disabled,
.secondary-button[aria-disabled="true"] {
  appearance: none;
  cursor: not-allowed;
  opacity: 1;
  border-color: rgba(30, 42, 36, 0.16);
  background: #f1eee5;
  color: #7b857d;
  -webkit-text-fill-color: #7b857d;
}

.clear-button {
  justify-self: center;
  min-height: 28px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.marker-label {
  display: inline-grid;
  place-items: center;
  min-width: 34px;
  height: 34px;
  padding: 0 10px;
  border: 2px solid white;
  border-radius: 999px;
  background: var(--accent);
  color: white;
  box-shadow: 0 5px 14px rgba(29, 39, 34, 0.24);
  font-size: 13px;
  font-weight: 900;
  white-space: nowrap;
}

.marker-label.start,
.marker-label.finish,
.marker-label.start-finish {
  background: var(--warn);
}

@media (min-width: 760px) {
  .route-panel {
    right: 18px;
    bottom: 18px;
    left: auto;
    width: min(420px, calc(100vw - 36px));
    padding: 12px 16px 88px;
    border: 1px solid var(--line);
    border-radius: 8px;
  }
}
