/* Full-screen route map. Loaded only on /routes/:slug. Everything is scoped
   under .mapapp / .page-map so nothing leaks between pages. */

.page-map {
  position: fixed;
  inset: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--paper);
  --top: max(14px, env(safe-area-inset-top));
  --side: 14px;
  --panel-w: 400px;
  /* collapsed sheet height on phones: sheet.js fits it to end just below
     the route stats or the place name */
  --peek: var(--peek-fit, 124px);
}

.mapapp { position: absolute; inset: 0; }
.map { position: absolute; inset: 0; background: var(--paper); }
.map canvas { outline: none; }

/* ---------- loader ---------- */
.loader {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: var(--paper);
  color: var(--muted);
  font-size: .9rem;
  font-weight: 550;
  letter-spacing: .02em;
  transition: opacity .5s var(--ease), visibility .5s;
}
.loader.is-done { opacity: 0; visibility: hidden; pointer-events: none; }
.loader.is-error p { color: var(--red-deep); }
.loader-seal {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  filter: drop-shadow(0 8px 14px rgba(214, 69, 42, .35));
  animation: breathe 1.6s var(--ease) infinite;
}
.loader-seal .icon { width: 100%; height: 100%; }
@keyframes breathe { 50% { transform: scale(.92) rotate(-6deg); } }

/* ---------- top bar (mobile) ---------- */
.map-top {
  position: absolute;
  z-index: 10;
  top: var(--top);
  left: var(--side);
  right: calc(var(--side) + 60px);
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: none;
}
.map-top > * { pointer-events: auto; }

.fab, .ctl {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  flex: none;
  padding: 0;
  border: 0;
  border-radius: 15px;
  background: rgba(255, 255, 255, .96);
  color: var(--ink);
  box-shadow: var(--shadow-md);
  cursor: pointer;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform .2s var(--ease), background .2s, color .2s, box-shadow .2s;
}
.fab:hover, .ctl:hover { background: #fff; box-shadow: var(--shadow-lg); }
.fab:active, .ctl:active { transform: scale(.94); }
.fab .icon, .ctl .icon { width: 22px; height: 22px; }

/* ---------- map controls ---------- */
.controls {
  position: absolute;
  z-index: 10;
  top: var(--top);
  right: var(--side);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.ctl-group {
  display: flex;
  flex-direction: column;
  border-radius: 15px;
  background: rgba(255, 255, 255, .96);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}
.ctl-group .ctl { border-radius: 0; box-shadow: none; background: transparent; }
.ctl-group .ctl:hover { background: var(--paper-2); }
.ctl-group .ctl + .ctl { border-top: 1px solid var(--line-2); }
.ctl:disabled { color: #c3bbb0; cursor: default; }

.ctl-compass .needle {
  display: grid;
  place-items: center;
  transform: rotate(var(--bearing, 0deg));
  transition: transform .08s linear;
}
.ctl-compass .icon { width: 26px; height: 26px; stroke: none; }
.ctl-compass { position: relative; }

.ctl-locate .i-heading { display: none; }
.ctl-locate[data-state='searching'] .icon { animation: spin 1.2s linear infinite; color: var(--red); }
.ctl-locate[data-state='active'] { color: var(--red); }
.ctl-locate[data-state='follow'], .ctl-locate[data-state='heading'] { background: var(--red); color: #fff; }
.ctl-locate[data-state='follow'] .i-locate .icon { fill: rgba(255, 255, 255, .25); }
.ctl-locate[data-state='heading'] .i-locate { display: none; }
.ctl-locate[data-state='heading'] .i-heading { display: grid; }
.ctl-locate[data-state='error'] { color: #a39a8f; }
.ctl-locate > span { display: grid; place-items: center; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- toast ---------- */
.toast {
  position: absolute;
  z-index: 30;
  top: calc(var(--top) + 60px);
  left: 50%;
  max-width: min(420px, calc(100vw - 32px));
  padding: 11px 18px;
  border-radius: 14px;
  background: rgba(29, 42, 51, .94);
  color: #fff;
  font-size: .875rem;
  font-weight: 550;
  text-align: center;
  box-shadow: var(--shadow-lg);
  transform: translate(-50%, 0);
  animation: toast-in .35s var(--ease);
}
.toast[hidden] { display: none; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, -10px); } }

/* ---------- sheet / panel ---------- */
.sheet {
  position: absolute;
  z-index: 20;
  left: 0;
  right: 0;
  bottom: 0;
  height: calc(100% - var(--top) - 62px);
  display: flex;
  flex-direction: column;
  background: var(--card);
  border-radius: 24px 24px 0 0;
  box-shadow: 0 -8px 40px rgba(29, 42, 51, .16);
  transform: translateY(calc(100% - var(--peek) - env(safe-area-inset-bottom)));
  transition: transform .45s var(--ease);
  will-change: transform;
  touch-action: pan-y;
}
.sheet[data-state='half'] { transform: translateY(46%); }
.sheet[data-state='full'] { transform: translateY(0); }
.sheet.is-dragging { transition: none; }

.sheet-handle {
  flex: none;
  display: grid;
  place-items: center;
  width: 100%;
  height: 26px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: grab;
  touch-action: none;
}
.sheet-handle span {
  width: 42px;
  height: 5px;
  border-radius: 3px;
  background: #d9d0c3;
}
.panel-toggle { display: none; }

.sheet-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  /* Clip the cover image and scrollbar to the panel's rounded corners
     (the panel itself can't clip: its collapse toggle sits outside it). */
  border-radius: inherit;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
  scrollbar-width: thin;
  scrollbar-color: #dcd3c6 transparent;
}
.sheet[data-state='peek'] .sheet-scroll { overflow: hidden; }

.view { display: flex; flex-direction: column; }
.view[hidden] { display: none; }
.view-head { padding: 2px 22px 0; }
.view-body { padding: 0 22px; }

.route-name {
  margin: 6px 0 14px;
  font-family: var(--font-serif);
  font-size: 1.65rem;
  font-weight: 550;
  letter-spacing: -.02em;
  line-height: 1.1;
  font-variation-settings: 'opsz' 72;
}

.stats {
  /* one row, equal columns, however many stats the route has */
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 1px;
  margin: 0;
  padding: 0;
  list-style: none;
  border-radius: 14px;
  background: var(--line-2);
  overflow: hidden;
  border: 1px solid var(--line-2);
}
.stats li {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 12px;
  background: var(--paper-2);
  min-width: 0;
}
/* four stats on a narrow panel: drop the label icons so the labels fit */
.stats:has(li:nth-child(4)) li { padding: 10px 9px; }
.stats:has(li:nth-child(4)) .stat-k { letter-spacing: .05em; }
.stats:has(li:nth-child(4)) .stat-k .icon { display: none; }
.stat-k {
  display: inline-flex;
  align-items: center;
  gap: .35em;
  font-size: .68rem;
  font-weight: 650;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}
.stat-k .icon { width: 12px; height: 12px; color: var(--red); }
.stats strong { font-size: .95rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }


.start-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  margin-top: 18px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  text-align: left;
  cursor: pointer;
  transition: border-color .2s, background .2s;
}
.start-row:hover { border-color: var(--jade); background: var(--jade-soft); }
.start-row > .icon:first-child { color: var(--jade); width: 20px; height: 20px; }
.start-row > span { flex: 1; min-width: 0; font-weight: 600; font-size: .925rem; }
.start-row small { display: block; font-size: .72rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.start-row > .icon:last-child { color: var(--muted); }

.intro {
  margin-top: 18px;
  font-size: .95rem;
  line-height: 1.65;
  color: var(--ink-2);
  white-space: pre-line;
}

/* Sized like the player that fills it, so the panel doesn't jump when it loads. */
.route-audio { min-height: 70px; margin-top: 18px; }
.route-audio .player { margin-top: 0; }

.actions { display: flex; gap: 10px; margin-top: 20px; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5em;
  padding: 12px 18px;
  border: 0;
  border-radius: 999px;
  font-size: .9rem;
  font-weight: 650;
  cursor: pointer;
  transition: background .2s, transform .15s;
}
.btn:active { transform: scale(.97); }
.btn-primary { flex: 1; background: var(--red); color: #fff; box-shadow: 0 6px 18px rgba(214, 69, 42, .3); }
.btn-primary:hover { background: var(--red-deep); }
.btn-soft { background: var(--paper); color: var(--ink); }
.btn-soft:hover { background: #ece4d7; }

/* "Save for offline" (shown by offline.js when a service worker is running) */
.save-offline {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  margin-top: 12px;
  padding: 12px 14px;
  border: 1px dashed var(--line);
  border-radius: 14px;
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: border-color .2s, background .2s;
}
.save-offline[hidden] { display: none; }
.save-offline:hover { border-color: var(--jade); background: var(--jade-soft); }
.save-offline > .icon { width: 20px; height: 20px; color: var(--jade); }
.save-offline > span { flex: 1; min-width: 0; }
.save-offline strong { display: block; font-size: .9rem; }
.save-offline small { display: block; font-size: .78rem; color: var(--muted); }
.save-offline .i-saved, .save-offline.is-saved .i-save { display: none; }
.save-offline.is-saved .i-saved { display: block; }
.save-offline.is-saved { border-style: solid; border-color: color-mix(in srgb, var(--jade) 35%, var(--line)); }
.save-offline.is-busy { cursor: progress; }
.save-offline.is-busy .i-save { animation: save-pulse 1.2s ease-in-out infinite; }
@keyframes save-pulse { 50% { transform: translateY(3px); opacity: .5; } }

.section-title {
  margin: 30px 0 12px;
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
}

/* stop list as a walking timeline */
.stops { position: relative; margin: 0; padding: 0; list-style: none; }
.stops:not(.stops-plain)::before {
  content: '';
  position: absolute;
  left: 21px;
  top: 22px;
  bottom: 22px;
  border-left: 2px dashed #e2d8ca;
}
.stop {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 8px 4px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: background .2s;
}
.stop:hover, .stop.is-active { background: var(--paper-2); }
.stop-dot {
  position: relative;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: none;
  border-radius: 50%;
  background: var(--c, var(--red));
  color: #fff;
  box-shadow: 0 0 0 3px #fff, 0 2px 6px rgba(0, 0, 0, .15);
}
.stop-dot.is-square { border-radius: 10px; }
/* A place's photo covers its icon, under a stop's number (app.js removes it
   if it fails to load). */
.dot-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
}
.stop-dot .icon { width: 18px; height: 18px; }
.stop-dot b {
  position: absolute;
  top: -5px;
  right: -7px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 9px;
  background: var(--ink);
  color: #fff;
  font-size: .66rem;
  line-height: 18px;
  text-align: center;
  box-shadow: 0 0 0 2px #fff;
}
.stop-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.stop-text strong { font-size: .95rem; font-weight: 620; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stop-text small { display: inline-flex; align-items: center; gap: .3em; font-size: .8rem; color: var(--muted); }
.stop-text small .icon { width: .95em; height: .95em; }
.stop .chev { color: #c4bbae; }

.related { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.related a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px;
  border-radius: 14px;
  border: 1px solid var(--line-2);
  text-decoration: none;
  transition: border-color .2s, box-shadow .2s;
}
.related a:hover { border-color: var(--line); box-shadow: var(--shadow-sm); }
.related-img {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  flex: none;
  border-radius: 10px;
  overflow: hidden;
  background: var(--red);
  color: #fff;
}
.related-img img { width: 100%; height: 100%; object-fit: cover; }
.related-img .icon { width: 26px; height: 26px; }
.related strong { display: block; font-size: .92rem; }
.related small { font-size: .8rem; color: var(--muted); }

/* ---------- place detail ---------- */
.place-nav {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 16px 10px;
  background: var(--card);
}
.place-nav .spacer { flex: 1; }
.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  transition: background .2s;
}
.icon-btn:hover { background: #ece4d7; }
.icon-btn:disabled { opacity: .35; cursor: default; }
.icon-btn .icon { width: 20px; height: 20px; }
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: .35em;
  height: 38px;
  padding: 0 14px 0 10px;
  border: 0;
  border-radius: 12px;
  background: var(--paper);
  font-size: .85rem;
  font-weight: 650;
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
}
.back-btn:hover { background: #ece4d7; }
/* the overview's "Home Page" link: styled as .back-btn, only shown on desktop */
.panel-back { display: none; margin-bottom: 18px; }
.place-count { font-size: .8rem; font-weight: 600; color: var(--muted); padding: 0 4px; }

.place-body { padding: 0 22px; }
.place-media {
  margin: 0 0 14px;
  border-radius: 18px;
  overflow: hidden;
  aspect-ratio: 16 / 10;
  background: #ebe3d6;
}
.place-media img { width: 100%; height: 100%; object-fit: cover; }
.place-kicker { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.class-chip {
  display: inline-flex;
  align-items: center;
  gap: .4em;
  padding: .35em .75em .35em .4em;
  border-radius: 999px;
  background: color-mix(in srgb, var(--c) 13%, #fff);
  color: color-mix(in srgb, var(--c) 85%, #000);
  font-size: .78rem;
  font-weight: 700;
}
.class-chip i {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--c);
  color: #fff;
}
.class-chip .icon { width: 13px; height: 13px; }
.meta-chip { font-size: .8rem; font-weight: 600; color: var(--muted); }
.place-name {
  margin: 2px 0 14px;
  font-family: var(--font-serif);
  font-size: 1.55rem;
  font-weight: 550;
  letter-spacing: -.015em;
  line-height: 1.15;
}
.place-desc { margin-top: 14px; font-size: .95rem; line-height: 1.65; color: var(--ink-2); white-space: pre-line; }
.place-actions { display: flex; gap: 10px; margin-top: 20px; }

/* audio player */
.player {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 18px;
  padding: 12px 16px 12px 12px;
  border-radius: 18px;
  background: linear-gradient(135deg, #2a3943, var(--ink));
  color: #fff;
}
.player-btn {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  flex: none;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--red);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(214, 69, 42, .45);
}
.player-btn .icon { width: 20px; height: 20px; }
.player-main { flex: 1; min-width: 0; }
.player-title { display: flex; align-items: center; gap: .4em; font-size: .78rem; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; opacity: .75; }
.player-title .icon { width: 14px; height: 14px; }
.player-row { display: flex; align-items: center; gap: 10px; margin-top: 4px; }
.player-time { font-size: .75rem; font-variant-numeric: tabular-nums; opacity: .8; }
.player input[type='range'] {
  flex: 1;
  min-width: 0;
  height: 18px;
  margin: 0;
  background: transparent;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  --p: 0%;
}
.player input[type='range']::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(90deg, #fff var(--p), rgba(255, 255, 255, .25) var(--p));
}
.player input[type='range']::-moz-range-track { height: 4px; border-radius: 2px; background: rgba(255, 255, 255, .25); }
.player input[type='range']::-moz-range-progress { height: 4px; border-radius: 2px; background: #fff; }
.player input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  margin-top: -5px;
  border: 0;
  border-radius: 50%;
  background: #fff;
}
.player input[type='range']::-moz-range-thumb { width: 14px; height: 14px; border: 0; border-radius: 50%; background: #fff; }

/* ---------- attribution ---------- */
.attribution {
  position: absolute;
  z-index: 5;
  right: var(--side);
  bottom: calc(var(--peek) + 10px + env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: calc(100% - 28px);
  padding: 3px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .85);
  font-size: .68rem;
  color: var(--muted);
  transition: bottom .45s var(--ease);
}
.attrib-btn {
  width: 22px;
  height: 22px;
  flex: none;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  font: italic 700 12px/22px var(--font-serif);
  color: var(--muted);
  cursor: pointer;
}
.attrib-text { display: none; padding-right: 8px; white-space: nowrap; }
.attribution.is-open .attrib-text { display: inline; }
.attrib-text a { color: inherit; }

/* ---------- markers ---------- */
.mk { cursor: pointer; -webkit-tap-highlight-color: transparent; }
.mk-stop, .mk-wpt {
  --size: 34px;
  position: relative;
  display: grid;
  place-items: center;
  width: var(--size);
  height: var(--size);
  border-radius: 50%;
  background: var(--c, var(--red));
  color: #fff;
  box-shadow: 0 0 0 3px #fff, 0 3px 10px rgba(29, 42, 51, .3);
  transition: transform .25s var(--ease), box-shadow .25s;
}
.mk-wpt { --size: 30px; border-radius: 9px; }
.mk-wpt.has-img { --size: 36px; }
.mk-stop.has-img { --size: 40px; }
.mk-stop .icon, .mk-wpt .icon { width: 17px; height: 17px; }
.mk-stop b {
  position: absolute;
  top: -7px;
  right: -8px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 9px;
  background: var(--ink);
  font-size: 10.5px;
  font-weight: 750;
  line-height: 18px;
  text-align: center;
  box-shadow: 0 0 0 2px #fff;
}
.mk:hover .mk-stop, .mk:hover .mk-wpt { transform: scale(1.1); }
.mk.is-active { z-index: 3; }
.mk.is-active .mk-stop, .mk.is-active .mk-wpt {
  transform: scale(1.22);
  box-shadow: 0 0 0 3px #fff, 0 0 0 7px color-mix(in srgb, var(--c) 35%, transparent), 0 6px 16px rgba(29, 42, 51, .35);
}
.mk-tip {
  position: absolute;
  bottom: calc(100% + 10px);
  left: 50%;
  padding: 5px 10px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  transform: translate(-50%, 4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s var(--ease);
}
@media (hover: hover) {
  .mk:hover .mk-tip { opacity: 1; transform: translate(-50%, 0); }
}

.mk-flag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px 5px 7px;
  border-radius: 999px;
  background: var(--jade);
  color: #fff;
  font-size: 11.5px;
  font-weight: 750;
  letter-spacing: .03em;
  box-shadow: 0 0 0 2.5px #fff, 0 4px 12px rgba(29, 42, 51, .3);
  white-space: nowrap;
}
.mk-flag .icon { width: 13px; height: 13px; }
.mk-flag.is-end { background: var(--ink); }
.mk-anchor { display: flex; flex-direction: column; align-items: center; }
.mk-anchor::after {
  content: '';
  width: 10px;
  height: 10px;
  margin-top: 3px;
  border-radius: 50%;
  background: var(--jade);
  box-shadow: 0 0 0 2.5px #fff;
}
.mk-anchor.is-end::after { background: var(--ink); }
.mk-anchor.no-dot::after { display: none; }

/* user location */
.mk-me { position: relative; width: 22px; height: 22px; pointer-events: none; }
.mk-me .dot {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: #2f7cf6;
  box-shadow: 0 0 0 3px #fff, 0 2px 8px rgba(0, 0, 0, .35);
}
.mk-me .dot::after {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 2px solid rgba(47, 124, 246, .5);
  animation: ping 2s ease-out infinite;
}
@keyframes ping { to { transform: scale(2.6); opacity: 0; } }
.mk-me .cone {
  position: absolute;
  left: 50%;
  bottom: 50%;
  width: 70px;
  height: 56px;
  margin-left: -35px;
  background: radial-gradient(ellipse 50% 100% at 50% 100%, rgba(47, 124, 246, .45), rgba(47, 124, 246, 0) 100%);
  clip-path: polygon(50% 100%, 0 0, 100% 0);
  display: none;
}
.mk-me.has-heading .cone { display: block; }
.mk-me.is-stale .dot { background: #8aa4c8; }

/* ---------- elevation profile ---------- */
.ctl[aria-pressed='true']:not(.ctl-locate) { background: var(--ink); color: #fff; }

.elevation {
  position: absolute;
  z-index: 15;
  left: var(--side);
  right: var(--side);
  bottom: calc(var(--peek) + 10px + env(safe-area-inset-bottom));
  padding: 10px 12px 6px 14px;
  border-radius: 20px;
  background: rgba(255, 255, 255, .97);
  box-shadow: var(--shadow-lg);
  animation: elev-in .35s var(--ease);
}
.elevation[hidden] { display: none; }
@keyframes elev-in { from { opacity: 0; transform: translateY(12px); } }

.elev-head { display: flex; align-items: center; gap: 12px; }
.elev-title { display: inline-flex; align-items: center; gap: .45em; font-size: .9rem; font-weight: 700; }
.elev-title .icon { color: var(--red); }
.elev-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 14px;
  flex: 1;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: .8rem;
  font-weight: 600;
  color: var(--ink-2);
}
.elev-stats li { display: inline-flex; align-items: center; gap: .3em; }
.elev-stats .icon { width: 15px; height: 15px; color: var(--muted); }
.elev-range { color: var(--muted); }
.elev-head .icon-btn { width: 32px; height: 32px; border-radius: 10px; }
.elev-head .icon-btn .icon { width: 17px; height: 17px; }

.elev-chart { position: relative; height: 124px; margin-top: 4px; touch-action: none; user-select: none; -webkit-user-select: none; }
.elev-chart svg { display: block; cursor: crosshair; outline: none; }
.elev-chart svg:focus-visible { outline: 2px solid color-mix(in srgb, var(--red) 50%, transparent); border-radius: 8px; }
.elev-grid line { stroke: var(--line-2); stroke-dasharray: 2 3; }
.elev-grid text { font-size: 10.5px; font-weight: 550; fill: var(--muted); font-variant-numeric: tabular-nums; }
.elev-line { fill: none; stroke: var(--red); stroke-width: 2.25; stroke-linejoin: round; stroke-linecap: round; }
.elev-stops circle { stroke: #fff; stroke-width: 2; }
.elev-stops text { font-size: 8.5px; font-weight: 800; fill: #fff; pointer-events: none; }
.elev-cursor line { stroke: var(--ink); stroke-width: 1; stroke-dasharray: 3 2; }
.elev-cursor circle { fill: var(--red); stroke: #fff; stroke-width: 2.5; }
.elev-tip {
  position: absolute;
  top: -2px;
  padding: 3px 8px;
  border-radius: 7px;
  background: var(--ink);
  color: #fff;
  font-size: 11.5px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  transform: translateX(-50%);
  pointer-events: none;
}
.elev-tip[hidden] { display: none; }

/* keep the map credits above the card */
.has-elevation .attribution { bottom: calc(var(--peek) + var(--elev-h, 170px) + 18px + env(safe-area-inset-bottom)); }

@media (max-width: 899px) {
  /* the expanded sheet takes over the bottom of the screen */
  .sheet:not([data-state='peek']) ~ .elevation { display: none; }
  .has-elevation .sheet:not([data-state='peek']) ~ .attribution { bottom: calc(var(--peek) + 10px); }
  .elev-range { display: none; }
}
@media (min-width: 900px) {
  /* Grows and shrinks in step with the side panel sliding in and out. */
  .elevation { left: calc(var(--panel-w) + 32px); right: 16px; bottom: 16px; transition: left .45s var(--ease); }
  .has-collapsed .elevation { left: 16px; }
  .has-elevation .attribution { bottom: calc(var(--elev-h, 170px) + 26px); }
}

/* ---------- desktop ---------- */
@media (min-width: 900px) {
  .page-map { --top: 16px; --side: 16px; --peek: 0px; }
  .map-top { display: none; }
  .panel-back { display: inline-flex; }

  .sheet {
    top: 16px;
    left: 16px;
    right: auto;
    bottom: 16px;
    width: var(--panel-w);
    height: auto;
    border-radius: 24px;
    box-shadow: var(--shadow-lg);
    transform: none;
    transition: transform .45s var(--ease);
  }
  .sheet[data-state] { transform: none; }
  .sheet.is-collapsed { transform: translateX(calc(-100% - 24px)); }
  .sheet[data-state] .sheet-scroll { overflow-y: auto; }
  .sheet-handle { display: none; }
  .view-head { padding-top: 22px; }
  .view { padding-bottom: 8px; }
  .view-head, .view-body, .place-body { padding-left: 26px; padding-right: 26px; }
  .place-nav { padding: 18px 20px 12px; }
  .route-name { font-size: 1.9rem; }

  .panel-toggle {
    position: absolute;
    top: 18px;
    right: -52px;
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 0;
    border-radius: 12px;
    background: rgba(255, 255, 255, .96);
    color: var(--ink);
    box-shadow: var(--shadow-md);
    cursor: pointer;
    transition: transform .45s var(--ease);
  }
  .panel-toggle .icon { width: 20px; height: 20px; transition: transform .45s var(--ease); }
  .sheet.is-collapsed .panel-toggle { transform: translateX(8px); }
  .sheet.is-collapsed .panel-toggle .icon { transform: rotate(180deg); }

  .attribution { bottom: 16px; }
  .toast { top: 24px; left: calc(50% + var(--panel-w) / 2); }
  .has-collapsed .toast { left: 50%; }
}

@media (max-width: 899px) {
  .sheet.is-collapsed { transform: translateY(calc(100% - var(--peek) - env(safe-area-inset-bottom))); }

  /* compact overview head, so the collapsed sheet (down to the stats) stays short */
  .view-head .eyebrow { font-size: .7rem; }
  .view-head .eyebrow .icon { width: 13px; height: 13px; }
  .route-name { margin: 4px 0 10px; font-size: 1.4rem; }
  .stats { border-radius: 12px; }
  .stats li { gap: 0; padding: 6px 10px; }
  .stat-k { font-size: .62rem; letter-spacing: .06em; }
  .stat-k .icon { width: 11px; height: 11px; }
  .stats strong { font-size: .88rem; }
}
