:root {
  --ink: #17211b;
  --muted: #667068;
  --paper: #f4f1e9;
  --card: #fffdf7;
  --line: #ddd9ce;
  --lime: #c9f05a;
  --forest: #1d4b36;
  --shadow: 0 18px 55px rgba(32, 45, 37, .10);
}

* { box-sizing: border-box; }
:where(main, section, aside, article, .route-card span, .panel-head > div) { min-width: 0; }
:where(h1, h2, p, .brand, .route-card) { overflow-wrap: anywhere; }
:where(button, a, input):focus-visible { outline: 3px solid var(--forest); outline-offset: 3px; }
html { scroll-behavior: auto; }
body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 12%, rgba(201, 240, 90, .18), transparent 27rem),
    var(--paper);
  font-family: "DM Sans", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; }
a { color: inherit; }

.topbar {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1480px;
  margin: auto;
  padding: env(safe-area-inset-top, 0px) max(42px, env(safe-area-inset-right, 0px)) 0 max(42px, env(safe-area-inset-left, 0px));
  border-bottom: 1px solid rgba(23, 33, 27, .10);
}
.brand { display: flex; align-items: center; gap: 11px; text-decoration: none; font-family: Manrope, sans-serif; font-size: 14px; }
.brand-mark { display: grid; place-items: center; width: 32px; height: 32px; flex-shrink: 0; border-radius: 50%; color: white; background: var(--forest); font-weight: 800; }
.osm-label { color: var(--muted); font-size: 12px; }

main { max-width: 1480px; margin: 0 auto; padding: 0 max(42px, env(safe-area-inset-right, 0px)) 44px max(42px, env(safe-area-inset-left, 0px)); }
.intro { min-height: 360px; padding: 72px 0 54px; display: grid; grid-template-columns: minmax(0, 1fr) 350px; gap: 70px; align-items: end; }
.eyebrow, .section-kicker { margin: 0 0 14px; color: var(--forest); font-size: 11px; font-weight: 800; letter-spacing: .15em; text-transform: uppercase; }
h1 { margin: 0; max-width: 790px; font-family: Manrope, sans-serif; font-size: clamp(44px, 5.5vw, 76px); line-height: .98; letter-spacing: -.055em; }
h1 em { color: var(--forest); font-weight: 600; }
.lede { max-width: 660px; margin: 24px 0 0; color: var(--muted); font-size: 17px; line-height: 1.65; }

.pace-card { padding: 25px 27px 21px; border: 1px solid rgba(23, 33, 27, .1); border-radius: 22px; background: rgba(255, 253, 247, .72); box-shadow: var(--shadow); backdrop-filter: blur(8px); }
.pace-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.pace-caption { display: block; margin-bottom: 5px; color: var(--muted); font-size: 12px; font-weight: 600; }
#pace-output { font-family: Manrope, sans-serif; font-size: 34px; font-weight: 800; letter-spacing: -.04em; }
#pace-output small { font-family: "DM Sans", sans-serif; color: var(--muted); font-size: 13px; font-weight: 600; letter-spacing: 0; }
.pace-icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 13px; color: white; background: var(--forest); font-size: 20px; }
#pace { --pace-progress: 30%; display: block; width: 100%; height: 44px; margin: 0; appearance: none; background: transparent; cursor: pointer; }
#pace::-webkit-slider-runnable-track { height: 5px; border-radius: 9px; background: linear-gradient(to right, var(--forest) 0 var(--pace-progress), #d8d8d0 var(--pace-progress) 100%); }
#pace::-moz-range-track { height: 5px; border-radius: 9px; background: linear-gradient(to right, var(--forest) 0 var(--pace-progress), #d8d8d0 var(--pace-progress) 100%); }
#pace::-webkit-slider-thumb { width: 24px; height: 24px; margin-top: -9.5px; appearance: none; border: 4px solid var(--card); border-radius: 50%; background: var(--forest); box-shadow: 0 2px 7px #777; }
#pace::-moz-range-thumb { box-sizing: border-box; width: 24px; height: 24px; border: 4px solid var(--card); border-radius: 50%; background: var(--forest); box-shadow: 0 2px 7px #777; }
.pace-scale { display: flex; justify-content: space-between; margin-top: 0; color: #8b918c; font-size: 10px; }

.explorer { display: grid; grid-template-columns: minmax(0, 1fr); min-height: 690px; overflow: hidden; border: 1px solid rgba(23, 33, 27, .12); border-radius: 27px; background: var(--card); box-shadow: var(--shadow); }
.routes-panel { min-width: 0; padding: 34px 28px 24px; }
.panel-head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.panel-head h2 { margin: 0; font: 800 25px/1.15 Manrope, sans-serif; letter-spacing: -.035em; }
.filters { display: flex; gap: 5px; flex-wrap: wrap; justify-content: end; }
.filter { min-height: 44px; min-width: 44px; padding: 10px 14px; border: 0; border-radius: 999px; color: var(--muted); background: #eeece4; font-size: 11px; font-weight: 700; cursor: pointer; }
.filter:hover, .filter.active { color: white; background: var(--forest); }
.route-list { display: grid; gap: 10px; }
.route-card { border: 1px solid transparent; border-radius: 17px; color: inherit; background: #f5f3ec; transition: background .18s ease, border-color .18s ease; }
.route-card:hover { border-color: #d4d1c8; }
.route-card.active { border-color: var(--route-color); background: white; box-shadow: 0 8px 25px rgba(20, 35, 25, .08); }
.route-select { display: grid; grid-template-columns: 5px minmax(0, 1fr); gap: 12px; align-items: center; width: 100%; min-width: 0; padding: 16px 12px; border: 0; border-radius: 16px; color: inherit; background: transparent; text-align: left; cursor: pointer; overflow-wrap: anywhere; }
.route-bar { grid-column: 1; grid-row: 1 / 3; align-self: stretch; border-radius: 99px; background: var(--route-color); }
.route-title { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 6px; }
.route-title strong { font: 800 15px/1.35 Manrope, sans-serif; }
.difficulty { max-width: 100%; padding: 4px 6px; border-radius: 6px; color: var(--muted); background: #e9e7df; font-size: 9px; font-weight: 700; text-transform: uppercase; }
.route-tagline { display: block; margin: 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.route-stats { grid-column: 2; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; text-align: left; }
.route-stats strong { display: block; font: 800 18px/1.3 Manrope, sans-serif; }
.route-stats small { display: block; margin-top: 4px; color: var(--muted); font-size: 9px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.route-detail { padding: 0 12px 16px 29px; }
.route-detail[hidden] { display: none; }
.route-detail p { margin: 0 0 10px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.detail-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 11px; line-height: 1.5; }
.detail-row > span { flex: 1 1 130px; }
.osm-link { display: inline-flex; align-items: center; min-height: 44px; max-width: 100%; padding: 10px 12px; border-radius: 8px; color: white; background: var(--forest); text-decoration: none; font-weight: 700; }
.route-note { margin: 18px 4px 0; color: #898e89; font-size: 10px; line-height: 1.45; }

.map-shell { position: relative; isolation: isolate; z-index: 0; min-width: 0; height: clamp(280px, 55svh, 460px); overflow: hidden; background: #dfe7db; }
#map { position: absolute; inset: 0; width: 100%; height: 100%; }
.leaflet-bottom { max-width: 100%; }
.leaflet-control-attribution { max-width: 100%; white-space: normal; overflow-wrap: anywhere; font-size: 9px !important; }
.leaflet-touch .leaflet-bar a, .leaflet-bar a { width: 44px; height: 44px; line-height: 44px; }
.leaflet-tooltip { max-width: min(240px, 70vw); white-space: normal; overflow-wrap: anywhere; }
.leaflet-popup-content { max-width: min(220px, 60vw); overflow-wrap: anywhere; }
.map-overlay { position: absolute; z-index: 500; border: 1px solid rgba(23,33,27,.12); background: rgba(255,253,247,.92); box-shadow: 0 7px 25px rgba(25,40,31,.13); backdrop-filter: blur(10px); }
.map-legend { left: 18px; bottom: 36px; display: flex; align-items: center; gap: 11px; padding: 11px 15px; border-radius: 13px; }
.map-legend strong, .map-legend small { display: block; }
.map-legend strong { font-size: 11px; }
.map-legend small { margin-top: 2px; color: var(--muted); font-size: 10px; }
.pulse-dot { width: 12px; height: 12px; border: 3px solid white; border-radius: 50%; background: var(--forest); box-shadow: 0 0 0 5px rgba(29,75,54,.18); }
.fit-button { top: 18px; right: 18px; width: 44px; height: 44px; border-radius: 13px; color: var(--forest); font-size: 20px; cursor: pointer; }
.start-marker { display: grid; place-items: center; width: 32px !important; height: 32px !important; margin: -16px 0 0 -16px !important; border: 4px solid white; border-radius: 50%; color: white; background: var(--forest); box-shadow: 0 4px 15px rgba(20,40,30,.3); font: 800 11px Manrope, sans-serif; }

footer { display: flex; flex-wrap: wrap; gap: 0 24px; justify-content: space-between; max-width: 1480px; margin: auto; padding: 24px max(20px, env(safe-area-inset-right, 0px)) max(20px, env(safe-area-inset-bottom, 0px)) max(20px, env(safe-area-inset-left, 0px)); color: var(--muted); font-size: 11px; }

@media (min-width: 821px) {
  .explorer { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .map-shell { height: auto; min-height: 690px; }
}
@media (min-width: 1200px) {
  .explorer { grid-template-columns: minmax(0, .95fr) minmax(0, 1.05fr); }
  .route-select { grid-template-columns: 5px minmax(0, 1fr) minmax(130px, auto); }
  .route-bar { grid-row: 1; }
  .route-stats { grid-column: 3; gap: 8px; text-align: right; }
}
@media (min-width: 821px) and (max-width: 1050px) {
  .intro { grid-template-columns: minmax(0, 1fr) 300px; gap: 36px; }
  .routes-panel { padding: 28px 18px; }
}
@media (max-width: 820px) {
  .topbar { min-height: 64px; padding: env(safe-area-inset-top, 0px) max(20px, env(safe-area-inset-right, 0px)) 0 max(20px, env(safe-area-inset-left, 0px)); }
  .osm-label { display: none; }
  main { padding: 0 max(12px, env(safe-area-inset-right, 0px)) 28px max(12px, env(safe-area-inset-left, 0px)); }
  .intro { min-height: auto; padding: 40px 5px 30px; grid-template-columns: minmax(0, 1fr); gap: 28px; }
  h1 { font-size: clamp(34px, 10.8vw, 62px); line-height: 1.06; }
  .pace-card { padding: 22px; }
  .explorer { min-height: 0; border-radius: 21px; }
  .routes-panel { padding: 26px 12px 21px; grid-row: 2; }
  .map-shell { grid-row: 1; height: 360px; height: clamp(280px, 55svh, 460px); }
  .panel-head { display: block; }
  .panel-head h2 { font-size: 24px; }
  .filters { justify-content: start; margin-top: 17px; gap: 8px; }
  .map-legend { left: 12px; padding: 10px 12px; }
  .fit-button { top: 12px; right: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .route-card { transition: none; }
}
