:root {
  --bg: #0f1419;
  --panel: #1a2129;
  --card: #222c37;
  --accent: #5728b4;     /* primary: purple */
  --accent-ink: #ffffff; /* text on purple (dark accent → white) */
  --climb: #5728b4;      /* climb highlight */
  --accent2: #2dd4bf;
  --text: #e7edf3;
  --muted: #93a1b0;
  --line: #2c3947;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 15px/1.5 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg); color: var(--text);
  display: flex; flex-direction: column; height: 100vh;
}
/* Per-mode accent, driven by body[data-mode]: loops purple, challenge gold, climbs cyan. */
body { --mode: #5728b4; --mode2: #8b5cf6; --mode-ink: #fff; --mode-glow: rgba(87,40,180,.45); }
body[data-mode="challenge"] { --mode: #f59e0b; --mode2: #fbbf24; --mode-ink: #3a2606; --mode-glow: rgba(245,158,11,.45); }
body[data-mode="climbs"] { --mode: #2dd4bf; --mode2: #14b8a6; --mode-ink: #06231f; --mode-glow: rgba(45,212,191,.45); }
header { padding: 0; height: 76px; border-bottom: 1px solid var(--line); display: flex; align-items: stretch; }
/* Logo: a full-height purple square with the white "Stiip" name centred inside */
.logo-mark {
  flex: 0 0 auto; height: 100%; aspect-ratio: 1; background: linear-gradient(150deg, var(--mode), var(--mode2)); transition: background .25s;
  display: flex; align-items: center; justify-content: center; overflow: hidden;
  text-decoration: none; color: inherit;
}
.logo-mark img { width: 78%; height: auto; display: block; }
header .mode-head { align-self: center; padding: 0 20px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
header .mode-title { margin: 0; font-size: 19px; font-weight: 800; letter-spacing: .2px; color: var(--text); white-space: nowrap; }
header .mode-sub { margin: 0; font-size: 12.5px; line-height: 1.25; color: var(--muted); }
@media (max-width: 560px) {
  header .mode-head { padding: 0 12px; }
  header .mode-title { font-size: 16px; }
  header .mode-sub { display: none; }
}
.settings { position: relative; margin-left: auto; align-self: center; margin-right: 14px; display: flex; align-items: center; gap: 10px; }

/* Feedback button + modal */
.fb-btn { display: inline-flex; align-items: center; gap: 7px; background: var(--card);
  border: 1px solid var(--line); color: var(--text); border-radius: 10px; padding: 8px 12px;
  cursor: pointer; font: inherit; font-size: 14px; transition: color .15s, border-color .15s; }
.fb-btn:hover { color: #fff; border-color: var(--accent2); }
.fb-btn svg { width: 16px; height: 16px; }
@media (max-width: 560px) { .fb-btn span { display: none; } }
.modal { position: fixed; inset: 0; z-index: 3000; display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.55); padding: 20px; }
.modal.hidden { display: none; }
.modal-card { position: relative; width: 100%; max-width: 420px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 16px; padding: 24px; box-shadow: 0 20px 50px rgba(0,0,0,.5); }
.modal-card h2 { margin: 0 0 8px; font-size: 20px; }
.modal-intro { margin: 0 0 16px; color: var(--muted); font-size: 14px; line-height: 1.5; }
.modal-card textarea, .modal-card input { width: 100%; box-sizing: border-box; background: var(--card);
  border: 1px solid var(--line); border-radius: 10px; color: var(--text); padding: 10px 12px; font: inherit; margin-bottom: 10px; }
.modal-card textarea { resize: vertical; min-height: 96px; }
.modal-card textarea:focus, .modal-card input:focus { outline: none; border-color: var(--accent2); }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 6px; }
.modal-actions button { padding: 9px 18px; border-radius: 10px; font: inherit; font-weight: 600; cursor: pointer; border: 1px solid var(--line); }
.fb-cancel { background: transparent; color: var(--muted); }
.fb-cancel:hover { color: var(--text); }
.fb-send { background: var(--accent); color: #fff; border-color: var(--accent); }
.fb-send:hover { filter: brightness(1.1); }
.modal-close { position: absolute; top: 10px; right: 14px; background: none; border: 0; color: var(--muted);
  font-size: 24px; line-height: 1; cursor: pointer; }
.modal-close:hover { color: var(--text); }
.fb-hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.fb-status { margin: 0 0 8px; font-size: 14px; }
.fb-status.ok { color: var(--accent2); }
.fb-status.err { color: #ff8088; }

/* Share this ride */
.share-btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  margin: 4px 0 14px; padding: 12px 16px; border-radius: 12px; border: 0; cursor: pointer;
  font: inherit; font-weight: 700; font-size: 15px; letter-spacing: .02em; color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  box-shadow: 0 8px 20px rgba(87,40,180,.35); transition: filter .15s, transform .12s; }
.share-btn:hover { filter: brightness(1.08); transform: translateY(-1px); }
.share-btn:active { transform: none; }
.share-btn.hidden { display: none; }
.share-btn svg { width: 18px; height: 18px; }
/* ---- Share modal: the conversion moment (turn a ride into a share) ---- */
.share-modal .modal-card { max-width: 400px; text-align: center; max-height: 92vh; overflow-y: auto; }
.share-left { display: flex; flex-direction: column; align-items: center; }
.share-stage { position: relative; display: inline-flex; justify-content: center; }
.share-preview { display: block; width: 100%; max-width: 300px; min-height: 280px; border-radius: 14px;
  border: 1px solid var(--line); background: var(--card); margin: 4px auto 8px; transition: opacity .2s; }
.share-preview.story { max-width: 216px; min-height: 384px; }
/* Loader shown while the visual generates */
.share-loading { position: absolute; inset: 4px 0 8px; display: none; align-items: center; justify-content: center;
  border-radius: 14px; background: rgba(8, 6, 16, .55); }
.share-modal.is-loading .share-loading { display: flex; }
.share-modal.is-loading .share-preview { opacity: .35; }
/* Format toggle (1:1 / 9:16) under the preview */
.share-formats, .share-templates { display: flex; gap: 8px; justify-content: center; margin: 0 0 14px; flex-wrap: wrap; }
.share-format, .share-template { padding: 7px 13px; border-radius: 9px; border: 1px solid var(--line); background: var(--card);
  color: var(--muted); font: inherit; font-weight: 600; font-size: 12.5px; cursor: pointer; transition: border-color .15s, color .15s, box-shadow .15s; }
.share-format:hover, .share-template:hover { color: var(--text); }
.share-format.active, .share-template.active { border-color: var(--accent2); color: var(--text); box-shadow: inset 0 0 0 1px var(--accent2); }
.share-right h2 { margin: 0 0 4px; }
.share-explain { margin: 0 0 14px; color: var(--muted); font-size: 14px; line-height: 1.4; }
.share-invite { margin: -6px 0 12px; color: var(--accent2); font-size: 13.5px; font-weight: 600; }
/* Small section labels before each row of buttons */
.share-label { margin: 0 0 7px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.share-left .share-label { margin-top: 8px; }
/* Theme: icon-only toggles */
.share-themes { display: flex; gap: 8px; justify-content: center; margin: 0 0 14px; }
.share-theme { width: 44px; height: 38px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 9px; border: 1px solid var(--line); background: var(--card); color: var(--muted); cursor: pointer;
  transition: border-color .15s, color .15s, box-shadow .15s; }
.share-theme svg { width: 18px; height: 18px; }
.share-theme:hover { color: var(--text); }
.share-theme.active { border-color: var(--accent2); color: var(--text); box-shadow: inset 0 0 0 1px var(--accent2); }
/* Native share = mobile primary CTA */
.share-native { display: inline-flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  margin: 0 0 12px; padding: 12px; border-radius: 11px; border: 0; cursor: pointer; font: inherit; font-weight: 800; font-size: 15px;
  background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; }
.share-native svg { width: 18px; height: 18px; }
.share-native:hover { filter: brightness(1.08); }
.share-native[hidden] { display: none; }
/* Social = brand logo buttons */
.share-row { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-bottom: 14px; }
.share-net { width: 46px; height: 46px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 11px; border: 1px solid var(--line); background: var(--card); color: var(--text); cursor: pointer;
  transition: border-color .15s, transform .12s, background .15s, color .15s; }
.share-net svg { width: 22px; height: 22px; }
.share-net:hover { transform: translateY(-1px); border-color: transparent; }
.net-x:hover { background: #000; color: #fff; }
.net-facebook:hover { background: #1877f2; color: #fff; }
.net-bluesky:hover { background: #1185fe; color: #fff; }
.net-whatsapp:hover { background: #25d366; color: #fff; }
/* Secondary actions: copy link (basic) + download (basic icon, not primary) */
.share-actions { display: flex; gap: 8px; justify-content: center; align-items: center; }
.share-actions button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 10px 14px;
  border-radius: 10px; font: inherit; font-weight: 600; font-size: 13.5px; cursor: pointer; border: 1px solid var(--line);
  background: transparent; color: var(--muted); transition: color .15s, border-color .15s; }
.share-actions button svg { width: 17px; height: 17px; }
.share-actions button:hover { color: var(--text); border-color: var(--muted); }
.share-copy { flex: 1 1 auto; }
.share-dl { flex: 0 0 auto; }
/* Desktop: wider modal, visual on the left, actions + explainer on the right */
@media (min-width: 720px) {
  .share-modal .modal-card { max-width: 760px; display: flex; gap: 26px; align-items: flex-start; text-align: left; }
  .share-left { flex: 0 0 auto; }
  .share-right { flex: 1 1 auto; min-width: 0; align-self: stretch; }
  .share-preview { max-width: 340px; min-height: 320px; }
  .share-preview.story { max-width: 280px; min-height: 498px; }
  .share-right .share-formats, .share-right .share-templates, .share-right .share-row, .share-right .share-actions { justify-content: flex-start; }
}
.share-invite { margin: 2px 0 14px; font-size: 14.5px; color: var(--text); line-height: 1.45; }
.share-native { width: 100%; margin: 0 0 12px; padding: 11px; border-radius: 10px; border: 0;
  background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; font: inherit; font-weight: 700; cursor: pointer; }
.share-native:hover { filter: brightness(1.08); }
.share-native[hidden] { display: none; }
.finish-flag { color: var(--accent2); font-size: 16px; line-height: 1; text-align: center;
  text-shadow: 0 0 4px #000, 0 0 2px #000; }
/* Pin shown on the route while hovering the elevation profile */
.profile-pin { box-sizing: border-box; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; border: 4px solid var(--mode);
  box-shadow: 0 0 0 2px rgba(0,0,0,.45), 0 2px 6px rgba(0,0,0,.45); }
.cog {
  display: flex; align-items: center; justify-content: center; padding: 7px;
  background: transparent; border: 0; border-radius: 8px; color: var(--muted); cursor: pointer;
  transition: color .15s, background .15s, transform .3s ease;
}
.cog:hover { color: var(--text); background: #0d1217; }
.cog[aria-expanded="true"] { color: var(--accent); transform: rotate(60deg); }
.cog svg { width: 20px; height: 20px; }
.settings-menu {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 1300; min-width: 160px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 6px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, .45);
}
.settings-menu.hidden { display: none; }
.menu-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 4px 8px 6px; }
.lang-opt {
  display: block; width: 100%; text-align: left; padding: 8px; border: 0; border-radius: 7px;
  background: transparent; color: var(--text); font-size: 14px; cursor: pointer;
}
.lang-opt:hover { background: #0d1217; }
.lang-opt.active { background: rgba(87, 40, 180, .35); font-weight: 700; }

main { flex: 1; display: grid; grid-template-columns: 360px 1fr; min-height: 0; }

.powered { flex: 0 0 auto; height: 28px; display: flex; align-items: center; justify-content: center;
  border-top: 1px solid var(--line); background: var(--panel); }
.powered a { display: inline-flex; align-items: center; gap: 6px; color: var(--muted);
  text-decoration: none; font-size: 12px; letter-spacing: .02em; }
.powered a:hover { color: var(--text); }
.powered img { height: 14px; width: auto; display: block; opacity: .85; }
.powered a:hover img { opacity: 1; }

.panel { display: flex; flex-direction: column; min-height: 0; overflow: hidden; border-right: 1px solid var(--line); }
.panel-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 16px; }

.find-row { display: block; margin-bottom: 14px; }
.find-label { display: block; margin-bottom: 8px; color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.tabs {
  position: relative; display: flex; flex: 1;
  background: #0d1217; padding: 4px; border-radius: 10px; border: 1px solid var(--line);
}
/* Sliding highlight behind the active tab */
.tab-thumb {
  position: absolute; top: 4px; bottom: 4px; left: 4px; width: calc((100% - 8px) / 3);
  background: linear-gradient(135deg, #5728b4, #8b5cf6); border-radius: 7px;
  box-shadow: 0 2px 8px rgba(87, 40, 180, 0.45);
  transition: transform .25s cubic-bezier(.4, 0, .2, 1), background .2s, box-shadow .2s;
}
/* Per-mode colour, matching the landing: loops purple, challenge gold, climbs cyan. */
.tabs[data-mode="challenge"] .tab-thumb { transform: translateX(100%); background: linear-gradient(135deg, #fbbf24, #f59e0b); box-shadow: 0 2px 8px rgba(245, 158, 11, 0.45); }
.tabs[data-mode="climbs"] .tab-thumb { transform: translateX(200%); background: linear-gradient(135deg, #2dd4bf, #14b8a6); box-shadow: 0 2px 8px rgba(45, 212, 191, 0.45); }
.tab {
  position: relative; z-index: 1; flex: 1;
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px;
  padding: 9px 4px; border: 0; border-radius: 7px; background: transparent;
  color: var(--muted); font-weight: 700; font-size: 13px; cursor: pointer;
  transition: color .2s;
}
.tab.active { color: var(--accent-ink); }
.tabs[data-mode="challenge"] .tab.active { color: #3a2606; } /* dark ink on gold */
.tabs[data-mode="climbs"] .tab.active { color: #06231f; }    /* dark ink on cyan */
.tab:not(.active):hover { color: var(--text); }
.tab svg { width: 19px; height: 19px; }
form label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
form .row { display: flex; gap: 10px; }
form .row label { flex: 1; }
label.check { display: flex; align-items: center; gap: 8px; color: var(--text); cursor: pointer; }
label.check input { width: auto; margin: 0; accent-color: var(--accent); }
input, select {
  width: 100%; margin-top: 4px; padding: 9px 10px; border-radius: 8px;
  border: 1px solid var(--line); background: #0d1217; color: var(--text); font-size: 14px;
}
button#go {
  width: 100%; padding: 11px; margin-top: 4px; border: 0; border-radius: 9px;
  background: linear-gradient(135deg, var(--mode), var(--mode2)); color: var(--mode-ink); font-weight: 700; font-size: 15px; cursor: pointer;
  box-shadow: 0 6px 18px var(--mode-glow); transition: background .25s, box-shadow .25s;
}
button#go:disabled { opacity: .6; cursor: progress; }
.hint { color: var(--muted); font-size: 12px; margin: 8px 0 0; }

/* Compact summary shown when the search criteria are collapsed (after results).
   Tap it to bring the full form back. */
.search-summary { display: none; width: 100%; align-items: center; justify-content: space-between; gap: 10px;
  margin-bottom: 14px; padding: 11px 14px; border-radius: 10px; cursor: pointer; text-align: left;
  border: 1px solid color-mix(in srgb, var(--mode) 38%, var(--line)); background: #0d1217; color: var(--text); font: inherit;
  transition: border-color .15s; }
.search-summary:hover { border-color: var(--mode); }
.search-summary .ss-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-weight: 700; font-size: 14px; }
.search-summary .ss-edit { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 700; color: var(--mode2); }
.search-summary .ss-edit svg { width: 14px; height: 14px; }
body.search-collapsed .find-row, body.search-collapsed #form { display: none; }
body.search-collapsed .search-summary { display: flex; }

/* Climb live-refine controls */
.climb-filters { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 10px; }
.climb-filters .filters-title { font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); font-weight: 700; }
.climb-filters label > span { font-size: 12px; color: var(--muted); }

/* Options: a toggle button on the input row; the panel expands beneath it */
.field-row { display: flex; gap: 10px; align-items: flex-end; margin-bottom: 12px; }
.field-row label { margin-bottom: 0; }
.field-row label.grow { flex: 1; }
.options-toggle { display: inline-flex; align-items: center; gap: 7px; padding: 9px 13px; border: 1px solid var(--line);
  border-radius: 8px; background: #0d1217; color: var(--text); font: inherit; font-size: 13px; font-weight: 600;
  cursor: pointer; white-space: nowrap; transition: color .15s, border-color .15s; }
.options-toggle:hover, .options-toggle[aria-expanded="true"] { border-color: var(--accent2); color: #fff; }
.options-toggle svg { width: 17px; height: 17px; }
.options-panel { margin: 0 0 12px; padding: 12px; border: 1px solid var(--line); border-radius: 9px; background: #0d1217;
  display: flex; flex-direction: column; gap: 10px; }
.options-panel.hidden { display: none; }
.options-panel .climb-filters { margin: 0; }

.via-chip {
  display: flex; align-items: center; gap: 8px; margin-bottom: 10px;
  padding: 7px 10px; border-radius: 8px; font-size: 13px;
  background: rgba(87, 40, 180, 0.15); border: 1px solid var(--climb); color: var(--text);
}
.via-chip b { color: var(--climb); }
.via-chip button { margin-left: auto; background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 14px; }
.via-chip button:hover { color: var(--text); }

.status { margin: 14px 0; font-size: 13px; min-height: 18px; }
.status.err { color: #ff8a8a; }
.status.ok { color: var(--accent2); }

.loop-card {
  background: var(--card); border: 1px solid color-mix(in srgb, var(--mode) 30%, var(--line)); border-radius: 11px;
  padding: 12px; margin-bottom: 12px; cursor: pointer; transition: border-color .15s, box-shadow .15s;
}
.loop-card:hover { border-color: var(--mode); }
.loop-card.active { border-color: var(--mode); box-shadow: 0 0 0 1px var(--mode); }
.loop-card .top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.loop-card .rtitle { flex: 1; min-width: 0; font-size: 14.5px; font-weight: 700; line-height: 1.25; }
.loop-card .dplus { flex: 0 0 auto; white-space: nowrap; font-size: 20px; font-weight: 800; color: var(--mode-ink);
  background: var(--mode); padding: 2px 11px; border-radius: 999px; line-height: 1.35; transition: background .25s, color .25s; }
.loop-card .dplus small { font-size: 11px; font-weight: 600; color: currentColor; opacity: .72; }
.loop-card .meta { color: var(--muted); font-size: 13px; margin-top: 4px; }
/* Stats row: icon-led chips spread across the card width. */
.loop-card .stats { display: flex; justify-content: space-between; align-items: center;
  gap: 6px 10px; flex-wrap: wrap; margin-top: 9px; }
.loop-card .stat { display: inline-flex; align-items: center; gap: 5px; min-width: 0;
  color: var(--muted); font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.loop-card .stat svg { flex: 0 0 auto; width: 13px; height: 13px; color: var(--mode2);
  stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Difficulty grade in front of the title: a tier-coloured trophy with 1-3 stars
   (the I/II/III sub-level). Tooltip (title attr) carries the grade name. */
.grade-chip { flex: 0 0 auto; display: inline-flex; flex-direction: column; align-items: center; gap: 1px;
  width: 26px; cursor: help; user-select: none; }
.grade-chip svg { display: block; fill: currentColor; }
.gc-trophy { line-height: 0; color: var(--tier, #9aa7b4); filter: drop-shadow(0 1px 1.5px rgba(0,0,0,.5)); }
.gc-trophy svg { width: 21px; height: 21px; }
.gc-stars { display: inline-flex; gap: 1px; color: #f5c518; line-height: 0; }
.gc-star { width: 8px; height: 8px; }
/* Tier colour ramp: easy green -> brutal gold. */
.g-tier-1 { --tier: #74b06a; }
.g-tier-2 { --tier: #57a6c9; }
.g-tier-3 { --tier: #14b8a6; }
.g-tier-4 { --tier: #f59e0b; }
.g-tier-5 { --tier: #ef6c2e; }
.g-tier-6 { --tier: #b06ad6; }
.g-tier-7 { --tier: #f5c518; }
.g-tier-7 .gc-trophy { filter: drop-shadow(0 0 4px rgba(245,197,24,.55)); }
.ow-menu.hidden { display: none; }

/* "Open with" dropdown list (shared by the footer action bar) */
.ow-menu { display: flex; flex-direction: column; gap: 1px; margin-top: 6px; padding: 6px;
  border: 1px solid var(--line); border-radius: 9px; background: var(--bg); }
.ow-menu .ow-grp { font-size: 10px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); padding: 8px 8px 3px; }
.ow-menu a, .ow-menu button {
  display: flex; align-items: center; gap: 6px; width: 100%; text-align: left;
  text-decoration: none; padding: 8px 9px; border-radius: 6px; font-size: 13px;
  font-weight: 600; border: 0; background: transparent; color: var(--text); cursor: pointer;
}
.ow-menu a:hover, .ow-menu button:hover { background: var(--card); color: var(--accent2); }
.ow-menu .ow-note { margin-left: auto; font-size: 10px; font-weight: 600; color: var(--muted);
  text-transform: none; letter-spacing: 0; }

/* Map click-info popup */
.map-info { font-size: 13px; color: #1a1a1a; min-width: 150px; }
.map-info b { display: block; margin-bottom: 8px; }
.map-info .popup-start {
  width: 100%; padding: 7px 10px; border: 0; border-radius: 7px; cursor: pointer;
  background: var(--accent); color: #fff; font-weight: 700; font-size: 13px;
}
.map-info .popup-start:hover { filter: brightness(1.1); }

/* Direction arrowhead (SVG points north; the wrapper rotates to the bearing).
   The swept-back tail makes the front tip obvious. */
.climb-arrow, .loop-arrow { background: none; border: 0; }
.climb-arrow .arr, .loop-arrow .arr { width: 22px; height: 22px; line-height: 0; }
.climb-arrow .arr svg, .loop-arrow .arr svg { display: block; width: 22px; height: 22px;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,.55)); }
.climb-arrow .arr path { fill: var(--climb); stroke: #fff; stroke-width: 1.8; stroke-linejoin: round; paint-order: stroke; }
.loop-arrow .arr path { fill: var(--accent2); stroke: #0f1419; stroke-width: 1.8; stroke-linejoin: round; paint-order: stroke; }

.mapwrap { position: relative; display: flex; flex-direction: column; min-height: 0; }

/* Loading overlay — covers the map and blocks clicks while working */
.loading {
  position: absolute; inset: 0; z-index: 1200;
  display: flex; align-items: center; justify-content: center; gap: 12px;
  background: rgba(15, 20, 25, 0.55); color: var(--text); font-weight: 600;
}
.loading.hidden { display: none; }
.spinner {
  width: 34px; height: 34px; border-radius: 50%;
  border: 4px solid rgba(87, 40, 180, 0.3); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Capacity queue modal — centred spinner + reassuring copy */
.queue-card { text-align: center; max-width: 380px; }
.queue-spinner { margin: 4px auto 14px; }
.queue-card .modal-actions { justify-content: center; }

/* Results appear one by one */
.loop-card { animation: fadeUp .28s ease both; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.load-more {
  width: 100%; padding: 10px; margin-top: 2px; border: 1px dashed var(--line);
  border-radius: 9px; background: transparent; color: var(--muted); font-weight: 700; cursor: pointer;
}
.load-more:hover { color: var(--text); border-color: var(--muted); }
#map { flex: 1; background: #0d1217; }
.map-tip { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 500;
  max-width: 88%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  background: rgba(13,18,23,.92); color: var(--text); border: 1px solid var(--line);
  border-radius: 999px; padding: 7px 14px; font-size: 13px; box-shadow: 0 4px 14px rgba(0,0,0,.4); pointer-events: none; }
#profile-wrap { height: 200px; padding: 10px 12px; border-top: 1px solid var(--line); background: var(--panel);
  display: flex; gap: 14px; align-items: stretch; }
#profile-wrap.hidden { display: none; }
/* Dedicated, relatively-positioned box so Chart.js (responsive) sizes against
   a stable container instead of the flex row that also holds the CTA — that
   feedback loop made the chart grow forever and thrash the map's tile loads. */
.profile-canvas-wrap { flex: 1; min-width: 0; position: relative; }
#profile-wrap canvas { position: absolute; inset: 0; width: 100% !important; height: 100% !important; }

/* Selected-route footer — a single compact action bar (GPX / Open with / Share)
   pinned to the bottom of the sidebar. Replaces the per-card buttons; mode-aware.
   The "Open with" menu pops upward above the row. */
.route-foot { flex: 0 0 auto; position: relative; margin: 0; padding: 10px 16px;
  border-top: 1px solid var(--line); background: var(--panel);
  box-shadow: 0 -8px 22px rgba(0,0,0,.30); transition: background .25s; }
.route-foot.hidden { display: none; }
.route-actions { display: flex; gap: 8px; align-items: stretch; }
.ract { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 11px 8px; border-radius: 9px; border: 1px solid var(--line); background: #0d1217;
  color: var(--text); font: inherit; font-size: 14px; font-weight: 700; cursor: pointer; white-space: nowrap;
  transition: border-color .15s, color .15s, filter .2s, transform .12s; }
.ract:hover { border-color: var(--mode); color: var(--mode2); }
.ract.ow-toggle[aria-expanded="true"] { border-color: var(--mode); color: var(--mode2); }
.ract-share { flex: 1.25; border: 0; color: var(--mode-ink);
  background: linear-gradient(135deg, var(--mode), var(--mode2)); box-shadow: 0 4px 14px var(--mode-glow); }
.ract-share:hover { color: var(--mode-ink); filter: brightness(1.06); transform: translateY(-1px); }
.ract svg { flex: 0 0 auto; width: 18px; height: 18px; }
.ract .t-full { display: none; } /* compact bar (mobile) uses the short labels */
.ow-caret { opacity: .75; font-size: 12px; }
/* Colour the secondary action buttons (Download GPX / Open with). */
#route-gpx, #route-ow { border-color: var(--mode2); }
#route-gpx svg, #route-ow svg { color: var(--mode2); }
/* Climbs have no downloadable route yet → Share only */
.route-foot.no-route #route-gpx, .route-foot.no-route #route-ow { display: none; }
/* The Open-with menu floats up above the action row */
#route-ow-menu { position: absolute; left: 16px; right: 16px; bottom: 100%; margin: 0 0 6px;
  max-height: 52vh; overflow-y: auto; box-shadow: 0 -10px 30px rgba(0,0,0,.5); z-index: 6; }
.hidden { display: none; }

/* Desktop: float the action box at the TOP-CENTRE of the map (the panel is
   360px wide, so the map's centre is 50% + 180px), buttons side by side. */
@media (min-width: 761px) {
  .route-foot { position: fixed; top: 90px; left: calc(50% + 180px); transform: translateX(-50%);
    right: auto; bottom: auto; z-index: 1000; width: auto; padding: 8px; border-top: 0;
    border: 1px solid color-mix(in srgb, var(--mode) 40%, var(--line)); border-radius: 14px;
    background: color-mix(in srgb, var(--panel) 95%, transparent);
    -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); box-shadow: 0 10px 30px rgba(0,0,0,.45); }
  .route-actions { flex-direction: row; gap: 8px; }
  .ract { flex: 0 0 auto; width: auto; justify-content: center; gap: 9px; padding: 11px 16px; font-size: 14.5px; border-radius: 10px; }
  .ract .t-min { display: none; }
  .ract .t-full { display: inline; }
  /* dropdown drops below the centred Open-with button */
  #route-ow-menu { left: 50%; right: auto; transform: translateX(-50%); min-width: 240px;
    top: 100%; bottom: auto; margin: 8px 0 0; box-shadow: 0 14px 30px rgba(0,0,0,.5); }
}

@media (max-width: 760px) {
  /* Panel on top (flex column so the action bar stays pinned + visible), map below.
     The map is big at first so you can pick a start, then shrinks to give the
     results room once a start point is set. */
  main { grid-template-columns: 1fr; grid-template-rows: 1fr 56vh; }
  body.has-start main { grid-template-rows: 1fr 40vh; }
  .mapwrap { min-height: 0; }
}
@media (max-width: 560px) {
  #profile-wrap { height: auto; flex-direction: column; gap: 10px; }
  .profile-canvas-wrap { height: 140px; flex: 0 0 140px; }
  .ract { font-size: 13px; padding: 10px 6px; }
}

/* ---- Playful voice: the logo's Sriracha hand on the bits with personality ----
   The cheeky route/climb names, the mode tagline and the status + loading lines
   speak in a friendly handwriting; numbers and data stay in the crisp UI font so
   nothing important gets harder to read. */
.loop-card .rtitle,
.loop-card .ctitle { font-family: 'Sriracha', cursive; font-weight: 400; font-size: 16px; line-height: 1.3; }
header .mode-sub   { font-family: 'Sriracha', cursive; font-size: 13px; }
.status            { font-family: 'Sriracha', cursive; font-size: 14px; }
#loading-msg       { font-family: 'Sriracha', cursive; font-size: 14px; }
