:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #17211b;
  background: #e8eee8;
}

* {
  box-sizing: border-box;
}

html,
body,
main {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

main {
  position: relative;
}

#map {
  position: absolute;
  inset: 0 0 0 360px;
  min-height: 100%;
}

.panel {
  position: absolute;
  z-index: 500;
  inset: 0 auto 0 0;
  width: 360px;
  padding: 28px;
  overflow-y: auto;
  background: #f7f4ea;
  box-shadow: 12px 0 35px rgb(20 43 29 / 14%);
}

.panel-toggle,
.map-action {
  display: none;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.eyebrow {
  margin: 0 0 8px;
  color: #39734f;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 40px;
  line-height: .95;
}

.coverage {
  padding: 5px 8px;
  border-radius: 999px;
  color: #39734f;
  background: #dfe9df;
  font-size: 11px;
  font-weight: 800;
}

.intro {
  margin: 16px 0 0;
  color: #536258;
  line-height: 1.45;
}

.mode {
  display: grid;
  gap: 7px;
  margin: 20px 0;
  color: #536258;
  font-size: 13px;
  font-weight: 700;
}

.mode select {
  width: 100%;
  min-height: 46px;
  padding: 11px;
  border: 1px solid #ccd9ce;
  border-radius: 12px;
  background: white;
  color: #17211b;
  font: inherit;
}

.steps {
  display: grid;
  gap: 9px;
  margin-bottom: 14px;
}

.steps div {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 11px;
  padding: 11px;
  border: 1px solid #ccd9ce;
  border-radius: 12px;
  background: white;
}

.steps span {
  display: grid;
  flex: 0 0 30px;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 50%;
  color: white;
  background: #39734f;
}

.steps strong {
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

button {
  min-height: 46px;
  padding: 11px 14px;
  border: 0;
  border-radius: 12px;
  color: white;
  background: #17211b;
  font: inherit;
  font-weight: 750;
  cursor: pointer;
}

button.secondary {
  color: #17211b;
  background: #dfe9df;
}

button.active {
  color: white;
  background: #b4442f;
}

button:disabled {
  cursor: not-allowed;
  opacity: .45;
}

.location-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.location-actions .wide {
  grid-column: 1 / -1;
}

.location-actions .supported {
  color: #235b37;
  background: #cfe5d3;
}

.location-actions .unsupported {
  color: #6e655d;
  background: #e4dfda;
}

.custom-controls {
  margin-bottom: 12px;
  padding: 11px;
  border: 1px solid #cbb9da;
  border-radius: 12px;
  background: #f4ecfa;
}

.custom-controls p {
  margin: 0 0 9px;
  color: #69427e;
  font-size: 12px;
  line-height: 1.35;
}

.custom-controls > div {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.custom-controls button:last-child {
  background: #74429a;
}

.custom-waypoint-label {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border: 2px solid white;
  border-radius: 50%;
  color: white;
  background: #74429a;
  box-shadow: 0 2px 8px rgb(0 0 0 / 28%);
  font-size: 11px;
  font-weight: 800;
}

.location-summary {
  display: grid;
  gap: 5px;
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid #b8cdbd;
  border-radius: 12px;
  background: #edf5ed;
  font-size: 13px;
}

.location-summary span {
  color: #536258;
}

.summary {
  margin-bottom: 12px;
  padding: 14px;
  border-radius: 12px;
  color: white;
  background: #39734f;
  font-size: 19px;
  font-weight: 800;
}

.summary small {
  display: block;
  margin-top: 7px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.4;
}

.panel-footer {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
}

.status {
  margin: 0;
  color: #536258;
  font-size: 13px;
  line-height: 1.4;
}

.reset-button {
  min-height: 38px;
  padding: 8px 11px;
  color: #7a2e20;
  background: #f0d9d2;
  font-size: 12px;
}

.notes {
  margin-top: 16px;
  color: #6c776f;
  font-size: 12px;
  line-height: 1.4;
}

.notes summary {
  cursor: pointer;
  font-weight: 700;
}

.leaflet-interactive {
  stroke-linecap: round;
  stroke-linejoin: round;
}

@media (max-width: 720px) {
  #map {
    inset: 0;
  }

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

  .leaflet-control-attribution {
    max-width: 70vw;
    font-size: 8px;
  }

  .panel {
    position: fixed;
    inset: auto 8px calc(8px + env(safe-area-inset-bottom)) 8px;
    width: auto;
    max-height: min(68vh, 610px);
    padding: 9px 14px 14px;
    overflow-y: auto;
    border: 1px solid rgb(23 33 27 / 8%);
    border-radius: 22px;
    box-shadow: 0 12px 40px rgb(20 43 29 / 24%);
    transition: max-height .22s ease, transform .22s ease;
  }

  .panel.collapsed {
    max-height: 132px;
    overflow: hidden;
  }

  .panel.collapsed:has(.location-summary:not([hidden])) {
    max-height: 205px;
  }

  .panel-toggle {
    display: grid;
    width: 100%;
    min-height: 26px;
    padding: 0;
    place-items: center;
    gap: 1px;
    color: #6c776f;
    background: transparent;
    font-size: 10px;
  }

  .handle {
    display: block;
    width: 42px;
    height: 4px;
    border-radius: 999px;
    background: #b9c2bb;
  }

  .panel-header {
    align-items: center;
  }

  h1 {
    font-size: 26px;
  }

  .eyebrow {
    margin-bottom: 3px;
    font-size: 9px;
  }

  .intro {
    display: none;
  }

  .route-controls {
    transition: opacity .15s ease;
  }

  .panel.collapsed .route-controls,
  .panel.collapsed .summary,
  .panel.collapsed .notes {
    display: none;
  }

  .panel.collapsed .location-summary {
    margin: 8px 0 0;
    padding: 8px 10px;
    font-size: 11px;
  }

  .panel.collapsed .panel-footer {
    margin-top: 10px;
  }

  .mode {
    margin: 12px 0 10px;
  }

  .mode select {
    min-height: 44px;
    font-size: 15px;
  }

  .steps {
    grid-template-columns: 1fr 1fr;
    gap: 7px;
    margin-bottom: 9px;
  }

  .steps div {
    padding: 8px;
  }

  .steps span {
    flex-basis: 25px;
    width: 25px;
    height: 25px;
    font-size: 12px;
  }

  .steps strong {
    font-size: 11px;
  }

  .location-actions {
    margin-bottom: 9px;
  }

  button {
    min-height: 44px;
    padding: 9px 10px;
    font-size: 13px;
  }

  .summary {
    padding: 11px;
    font-size: 17px;
  }

  .summary small {
    max-height: 48px;
    overflow: auto;
  }

  .panel-footer {
    min-height: 38px;
  }

  .status {
    display: -webkit-box;
    overflow: hidden;
    font-size: 11px;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  .map-action {
    position: fixed;
    z-index: 450;
    right: 16px;
    bottom: calc(156px + env(safe-area-inset-bottom));
    display: grid;
    width: 52px;
    min-height: 52px;
    padding: 0;
    place-items: center;
    border: 3px solid white;
    border-radius: 50%;
    background: #1769aa;
    box-shadow: 0 7px 22px rgb(0 0 0 / 24%);
    font-size: 29px;
  }

  .map-action.panel-open {
    bottom: calc(70vh + env(safe-area-inset-bottom));
  }
}
