:root {
  color-scheme: light;
  --bg: #f7f8f4;
  --surface: #fff;
  --text: #21392f;
  --muted: #647369;
  --accent: #25634d;
  --accent-soft: #e9f1e9;
  --line: #dfe5dc;
  --danger: #a33f2d;
  --shadow: 0 3px 16px #20382b14;
  --radius: 16px;
  font-family: Inter,ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html,body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

body {
  --app-safe-bottom: env(safe-area-inset-bottom, 0px);
  height: 100vh;
  height: 100dvh;
  width: 100%;
  position: fixed;
  inset: 0;
  overflow: hidden;
  padding-bottom: var(--app-safe-bottom);
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
  display: flex;
  flex-direction: column;
  overscroll-behavior: none;
}

button,input,summary {
  font: inherit;
}

button,a,input,summary {
  touch-action: manipulation;
}

button,a,summary {
  -webkit-tap-highlight-color: transparent;
}

button,a,input,summary,[tabindex] {
  outline-offset: 4px;
}

:focus-visible {
  outline: 3px solid #478d73;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
}

[hidden] {
  display: none!important;
}

.iconDefinitions {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.icon {
  width: 21px;
  height: 21px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: middle;
}

.eyebrow {
  display: block;
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 1.65px;
  color: var(--muted);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 650;
  text-decoration: none;
  line-height: 1.3;
  transition: background .15s,box-shadow .15s;
}

.btn:hover {
  background: #edf2ea;
  border-color: #c1cfc0;
}

.btn:active {
  background: #e0e9df;
}

.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn--primary:hover {
  background: #194e3b;
  border-color: #194e3b;
}

.btn--primary:active {
  background: #123f2e;
}

.btn--secondary {
  background: transparent;
  color: var(--muted);
}

.btn[aria-pressed=true] {
  background: var(--accent-soft);
  color: #1e6248;
  border-color: #79a88e;
  box-shadow: inset 0 0 0 1px #79a88e;
}

.btn:disabled {
  cursor: default;
  opacity: .55;
}

.btn:disabled:hover {
  box-shadow: none;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  flex: none;
  min-height: 74px;
  padding: 10px max(24px,env(safe-area-inset-right)) 10px max(24px,env(safe-area-inset-left));
  padding-top: max(10px,env(safe-area-inset-top));
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  flex: none;
  min-height: 44px;
}

.brand__mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: var(--accent);
  color: white;
}

.brand__mark .icon {
  width: 27px;
  height: 27px;
}

.brand__name {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -.5px;
}

.brand__name span {
  font-weight: 450;
  color: var(--muted);
}

.topbar__context {
  min-width: 0;
  flex: 1;
  border-left: 1px solid var(--line);
  padding-left: 24px;
}

.topbar__context .eyebrow {
  font-size: 9px;
  margin-bottom: 3px;
  letter-spacing: 1.4px;
}

.topbar__title {
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.topbar__status {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  color: #526a57;
  background: #eaf0e5;
  border: 1px solid #dde6d6;
  border-radius: 100px;
  padding: 7px 10px;
}

.topbar__status:before,.statusDot {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #63865c;
  flex: none;
}

.topbar__status[data-offline=true] {
  background: #fff1dc;
  color: #825c25;
  border-color: #efdfbf;
}

.topbar__status[data-offline=true]:before {
  background: #a97c36;
}

.btn--back {
  border: 0;
  background: transparent;
  padding: 10px 0;
  color: var(--muted);
}

.app {
  display: flex;
  flex: 1;
  min-height: 0;
  min-width: 0;
}

.libraryPanel {
  width: 100%;
  overflow: auto;
  padding: 54px max(32px,calc((100vw - 1120px)/2)) 30px;
  scrollbar-gutter: stable;
}

.libraryHero {
  display: grid;
  grid-template-columns: 1fr 350px;
  gap: 50px;
  align-items: center;
  padding-bottom: 46px;
  border-bottom: 1px solid var(--line);
}

.libraryHero__copy>.eyebrow {
  color: var(--accent);
  margin-bottom: 18px;
}

.libraryHero h1 {
  font-size: clamp(30px,3.6vw,46px);
  line-height: 1.15;
  letter-spacing: -1.6px;
  font-weight: 700;
  margin: 0 0 20px;
}

.libraryHero h1 span {
  color: #74816b;
}

.libraryHero p {
  font-size: 14px;
  line-height: 1.75;
  color: var(--muted);
  margin: 0 0 20px;
}

.localNote {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--muted);
}

.importBox {
  position: relative;
  text-align: center;
  border: 1px dashed #b8c7b4;
  border-radius: 20px;
  padding: 26px;
  background: #eef2e9;
}

.importBox__icon {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  margin: 0 auto 12px;
  border: 1px solid #d4dfcc;
  background: #f8faf5;
  border-radius: 14px;
  color: var(--accent);
}

.importBox__icon .icon {
  width: 25px;
  height: 25px;
}

.importBox h2 {
  font-size: 17px;
  margin: 0 0 6px;
}

.importBox p {
  font-size: 12px;
  line-height: 1.6;
  margin: 0 0 16px;
}

.importControl {
  position: relative;
  display: inline-flex;
}

.importControl input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.importControl:focus-within {
  outline: 3px solid #478d73;
  outline-offset: 4px;
  border-radius: 11px;
}

.importControl input:disabled+.btn {
  opacity: .55;
}

.importControl:hover .btn {
  background: #194e3b;
}

.importHelp {
  display: block;
  font-size: 10px;
  color: var(--muted);
  margin-top: 10px;
}

#importStatus:empty {
  display: none;
}

#importStatus:not(:empty) {
  margin: 12px 0 0;
  color: var(--accent);
}

.libraryHeading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin: 32px 0 20px;
}

.libraryHeading h2 {
  font-size: 22px;
  letter-spacing: -.5px;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 6px 0 0;
}

.countBadge {
  border: 1px solid var(--line);
  border-radius: 7px;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 8px;
  color: var(--muted);
}

.searchBox {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 0 12px;
  background: #fff;
  color: var(--muted);
  width: 245px;
}

.searchBox input {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 12px;
  outline: none;
}

.searchBox:focus-within {
  outline: 3px solid #478d73;
  outline-offset: 3px;
}

.searchBox input::placeholder {
  color: #738071;
}

.trackList {
  display: grid;
  grid-template-columns: repeat(auto-fill,minmax(270px,1fr));
  gap: 18px;
}

.trackCard {
  padding: 22px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 16px;
  min-width: 0;
  box-shadow: 0 2px 4px #20382b03;
}

.trackCard__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.trackCard__icon {
  display: grid;
  place-items: center;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 11px;
  width: 42px;
  height: 42px;
}

.trackCard__tag {
  font-size: 10px;
  letter-spacing: 1px;
  font-weight: 650;
  color: var(--muted);
}

.trackCard h2 {
  font-size: 19px;
  line-height: 1.4;
  letter-spacing: -.4px;
  overflow-wrap: anywhere;
  margin: 0 0 12px;
}

.trackCard p {
  font-size: 12px;
  line-height: 1.6;
  margin: 8px 0;
  color: var(--muted);
}

.trackCard .trackDistance {
  font-size: 23px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.8px;
}

.trackDistance small {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0;
}

.trackState {
  min-height: 40px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.trackCard__actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.trackCard__actions>.btn:first-child {
  flex: 1;
}

.trackCard__actions>.iconButton {
  color: var(--muted);
}

.emptyLibrary {
  text-align: center;
  padding: 38px 20px 44px;
  border: 1px dashed var(--line);
  border-radius: 16px;
  background: #fff9;
}

.emptyLibrary>.icon {
  width: 40px;
  height: 40px;
  color: #8c9c80;
}

.emptyLibrary h3 {
  font-size: 17px;
  font-weight: 600;
  margin: 14px 0 8px;
}

.emptyLibrary p,.emptySearch {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.7;
  margin: 0;
}

.emptySearch {
  padding: 30px;
  text-align: center;
}

.librarySettings {
  margin-top: 28px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
}

.librarySettings summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 52px;
  cursor: pointer;
  list-style: none;
}

.librarySettings[open] summary>.icon {
  transform: rotate(180deg);
}

.libraryActions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  padding-bottom: 12px;
}

.libraryHelp {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-top: 20px;
  padding: 18px 20px;
  background: #eef2e9;
  border-radius: 12px;
  color: var(--muted);
}

.libraryHelp .icon {
  margin-top: 3px;
}

.libraryHelp p {
  margin: 0;
  font-size: 11px;
  line-height: 1.8;
}

.libraryHelp strong {
  display: block;
  color: #425744;
  font-size: 12px;
  font-weight: 600;
}

.mapShell {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0,1fr) 340px;
  min-width: 0;
  min-height: 0;
}

.mapViewport {
  position: relative;
  overflow: clip;
  touch-action: none;
  background: #e0e5da;
  min-height: 0;
  outline-offset: -4px;
}

.mapStage {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: 0 0;
  will-change: transform;
}

.mapImg {
  display: block;
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
}

.mapLabel {
  position: absolute;
  z-index: 4;
  left: 20px;
  top: 20px;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 10px 12px;
  border: 1px solid #d7ded0;
  border-radius: 8px;
  background: #fbfcf6f2;
  box-shadow: var(--shadow);
  font-size: 11px;
  font-weight: 650;
  pointer-events: none;
}

.mapLabel>span:last-child {
  font-weight: 400;
  color: var(--muted);
}

.mapTools {
  position: absolute;
  right: 18px;
  top: 18px;
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.mapTools>.btn,.zoomGroup {
  box-shadow: var(--shadow);
}

.iconButton {
  width: 44px;
  height: 44px;
  padding: 10px;
  flex: none;
}

.zoomGroup {
  display: flex;
  flex-direction: column;
  border: 1px solid #cfd9c8;
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
}

.zoomGroup>.btn {
  border: 0;
  border-radius: 0;
}

.zoomGroup>.btn:first-child {
  border-bottom: 1px solid var(--line);
}

.compassButton {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 46px;
  height: 56px;
  gap: 1px;
  padding: 4px;
  border-radius: 12px;
}

.compassDial {
  display: block;
  width: 30px;
  height: 30px;
  flex: none;
  overflow: visible;
}

.compassDial__ring {
  fill: #f5f8f2;
  stroke: #d5dfcf;
  stroke-width: 1;
}

.compassDial__ticks {
  fill: none;
  stroke: #94a58e;
  stroke-width: 1.2;
  stroke-linecap: round;
}

.compassDial__north {
  fill: #d47659;
}

.compassDial__facet {
  fill: #ad4f3a;
}

.compassDial__south {
  fill: #8a9f91;
}

.compassDial__hub {
  fill: #fff;
  stroke: #718873;
  stroke-width: 1.2;
}

.compassLabel {
  font-size: 8px;
  font-weight: 750;
  line-height: 1;
  letter-spacing: .5px;
}

.compassButton[aria-pressed=true] {
  opacity: 1;
}

.compassButton[aria-pressed=true] .compassDial__ring {
  fill: #f4faf0;
  stroke: #a9c49f;
}

.compassButton[aria-pressed=true]:after {
  content: "";
  position: absolute;
  right: 5px;
  top: 5px;
  width: 5px;
  height: 5px;
  background: var(--accent);
  border-radius: 50%;
}

.compassButton[data-compass-state=waiting]:after {
  background: #b58137;
  box-shadow: 0 0 0 2px #f9e9ce;
}

.mapBottom {
  position: absolute;
  z-index: 5;
  left: 20px;
  right: 20px;
  bottom: 36px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  pointer-events: none;
}

.locationControls {
  display: flex;
  gap: 8px;
  pointer-events: auto;
}

.locationControls .btn {
  box-shadow: var(--shadow);
  min-height: 46px;
}

.gpsInfo {
  background: #fcfdf7f0;
  color: #4c5d4b;
  border: 1px solid #d5decc;
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 11px;
  line-height: 1.5;
  max-width: min(100%,460px);
  box-shadow: 0 1px 6px #23372b08;
}

.info {
  font-size: 12px;
  line-height: 1.55;
  padding: 10px 12px;
  border-radius: 10px;
  margin: 0;
  background: #fff6ec;
  border: 1px solid #e3c7ad;
  color: #86502c;
}

.info--error {
  background: #fff2ec;
  border-color: #e5c5b6;
  color: var(--danger);
}

.mapBottom .info {
  max-width: 460px;
  pointer-events: auto;
  max-height: 90px;
  overflow: auto;
  touch-action: pan-y;
}

.mapAttribution {
  position: absolute;
  z-index: 4;
  bottom: 0;
  left: 0;
  right: 0;
  text-align: right;
  font-size: 9px;
  line-height: 1.45;
  padding: 4px 8px;
  background: #f7f8eff0;
  color: #516049;
  pointer-events: none;
}

.tilePane,.mapOverlays {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.tilePane {
  z-index: 0;
}

.mapOverlays {
  z-index: 1;
  overflow: hidden;
}

.tilePane img {
  position: absolute;
  display: block;
  max-width: none;
  user-select: none;
  pointer-events: none;
}

/* Multiply the two alpha ramps; internal joins stay opaque. Unsupported masks
   leave the original tile intact. Distances are screen pixels, independent of zoom. */
.tilePane img.tileFeathered {
  -webkit-mask-image:
    linear-gradient(to right, transparent, black var(--fade-left), black calc(100% - var(--fade-right)), transparent),
    linear-gradient(to bottom, transparent, black var(--fade-top), black calc(100% - var(--fade-bottom)), transparent);
  -webkit-mask-composite: source-in;
  mask-image:
    linear-gradient(to right, transparent, black var(--fade-left), black calc(100% - var(--fade-right)), transparent),
    linear-gradient(to bottom, transparent, black var(--fade-top), black calc(100% - var(--fade-bottom)), transparent);
  mask-composite: intersect;
}

.routeLine {
  fill: none;
  stroke: #d2523c;
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 1px 1px white);
}

.gpsAccuracy {
  fill: #3285ce30;
  stroke: #287dbbb3;
  stroke-width: 2;
}

.peakLabel {
  position: absolute;
  z-index: 2;
  transform: translate(-50%,-120%);
  font-size: 12px;
  font-weight: 650;
  color: #283341;
  white-space: nowrap;
  pointer-events: none;
  text-shadow: 0 0 3px white,0 0 3px white;
  background: #ffffffb3;
  border-radius: 4px;
  padding: 2px 4px;
}

.marker {
  position: absolute;
  z-index: 3;
  left: 0;
  top: 0;
  width: 44px;
  height: 44px;
  transform: translate(-50%,-50%);
  pointer-events: none;
}

.marker__dot {
  position: absolute;
  z-index: 1;
  left: 50%;
  top: 50%;
  width: 18px;
  height: 18px;
  transform: translate(-50%,-50%);
  background: #287dbb;
  border: 3px solid white;
  border-radius: 50%;
  box-shadow: 0 0 0 1px #1f639140;
}

.marker__arrow {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 72px;
  height: 72px;
  transform: translate(-50%,-50%);
}

.marker__arrow svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.marker__direction-edge,.marker__direction {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.marker__direction-edge {
  stroke: #fff;
  stroke-width: 5;
}

.marker__direction {
  stroke: #287dbb;
  stroke-width: 2.5;
}

.marker.is-no-heading .marker__arrow {
  display: none;
}

.accuracy {
  position: absolute;
  left: 0;
  top: 0;
  width: 2px;
  height: 2px;
  transform: translate(-50%,-50%);
  border-radius: 50%;
  background: #3285ce25;
  border: 2px solid #3285ce50;
  pointer-events: none;
  display: none;
}

.routePanel {
  background: var(--bg);
  border-left: 1px solid var(--line);
  overflow: auto;
  min-height: 0;
  padding: 26px 22px;
  padding-bottom: max(22px,env(safe-area-inset-bottom));
}

.routePanel:has(> :not([hidden])) {
  display: block;
}

.routePanel:not(:has(> :not([hidden]))) {
  display: none;
}

.mapShell:has(.routePanel:not(:has(> :not([hidden])))) {
  grid-template-columns: 1fr;
}

.profilePanel {
  min-width: 0;
}

.profileHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.profileHeader h2 {
  font-size: 13px;
  font-weight: 700;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.profileHeader h2 .icon {
  color: var(--accent);
  width: 18px;
  height: 18px;
}

.profileToggle {
  min-height: 44px;
  padding: 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
}

.profileToggle .icon {
  width: 15px;
  height: 15px;
  transition: transform .15s;
}

.profileToggle[aria-expanded=true] .icon {
  transform: rotate(180deg);
}

.profileSummary {
  display: grid;
  grid-template-columns: 1.1fr 1fr 1fr;
  margin: 16px 0 20px;
  gap: 12px;
}

.profileMetric dt {
  font-size: 10px;
  color: var(--muted);
  margin-bottom: 6px;
}

.profileMetric dd {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -.8px;
  white-space: nowrap;
}

.profileMetric dd small {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--muted);
  margin-left: 3px;
}

.profileMetric+.profileMetric {
  border-left: 1px solid var(--line);
  padding-left: 14px;
}

.profileChart {
  position: relative;
  padding-left: 35px;
}

.profileChart svg {
  display: block;
  width: 100%;
  height: 118px;
  overflow: visible;
  touch-action: none;
  cursor: crosshair;
}

.profileAxis {
  position: absolute;
  left: 0;
  font-size: 9px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.profileAxis--max {
  top: 10px;
}

.profileAxis--min {
  bottom: 22px;
}

.profileDistances {
  display: flex;
  justify-content: space-between;
  font-size: 9px;
  color: var(--muted);
  margin-top: 3px;
}

.profileGrid {
  stroke: #dbe3d5;
  stroke-width: 1;
  stroke-dasharray: 4 5;
  vector-effect: non-scaling-stroke;
}

.profileArea {
  fill: #c2d7ad55;
}

.profileLine {
  fill: none;
  stroke: #60894d;
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.profileCursor {
  stroke: #c17e36;
  stroke-width: 1.5;
  stroke-dasharray: 3 3;
  vector-effect: non-scaling-stroke;
}

.profileGPS {
  stroke: #287dbb;
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

.inspectionMarker {
  fill: #e9b95f;
  stroke: #fff;
  stroke-width: 2;
  filter: drop-shadow(0 1px 3px #0005);
}

.profileSlider {
  display: block;
  width: 100%;
  appearance: none;
  background: transparent;
  height: 44px;
  margin: -6px 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.profileSlider::-moz-range-track {
  height: 3px;
  border: 0;
  border-radius: 3px;
  background: #d9e2d2;
}

.profileSlider::-moz-range-progress {
  height: 3px;
  background: var(--accent);
  border-radius: 3px;
}

.profileSlider::-moz-range-thumb {
  width: 15px;
  height: 15px;
  border: 3px solid white;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 1px 5px #20382b30;
}

.profileSlider::-webkit-slider-runnable-track {
  height: 3px;
  border: 0;
  border-radius: 3px;
  background: #d9e2d2;
}

.profileSlider::-webkit-slider-thumb {
  appearance: none;
  width: 21px;
  height: 21px;
  margin-top: -9px;
  border: 3px solid white;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 1px 5px #20382b30;
}

.profileDetails {
  display: block;
  min-height: 17px;
  font-size: 10px;
  line-height: 1.5;
  color: var(--muted);
}

.profileDetails.is-inspecting {
  color: #875c24;
}

.profileLocation {
  font-size: 10px;
  line-height: 1.5;
  margin: 8px 0 0;
  color: #326b8d;
}

.profileNoElevation {
  font-size: 12px;
  line-height: 1.6;
  background: #edf0e8;
  padding: 16px;
  border-radius: 10px;
  color: var(--muted);
}

.offlinePanel {
  margin-top: 26px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: white;
  overflow: hidden;
}

.offlinePanel summary {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 76px;
  padding: 14px;
  list-style: none;
  cursor: pointer;
}

.offlinePanel summary::-webkit-details-marker,.librarySettings summary::-webkit-details-marker {
  display: none;
}

.offlineIcon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
  flex: none;
}

.offlineIcon .icon {
  width: 18px;
  height: 18px;
}

.offlineHeading {
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 1;
  min-width: 0;
}

.offlineHeading strong {
  font-size: 12px;
  font-weight: 700;
}

.offlineHeading>span {
  font-size: 10px;
  line-height: 1.4;
  color: var(--muted);
}

.offlinePanel summary>.chevron {
  width: 16px;
  height: 16px;
  color: var(--muted);
}

.offlinePanel[open] summary>.chevron {
  transform: rotate(180deg);
}

.offlineContent {
  padding: 0 14px 16px;
}

.packageInfo {
  font-size: 12px;
  line-height: 1.6;
  color: var(--text);
  margin: 0 0 10px;
}

.downloadInfo {
  font-size: 11px;
  line-height: 1.6;
  color: var(--muted);
  margin: 10px 0 14px;
}

.downloadActions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.downloadActions>.btn {
  flex: 1;
  white-space: nowrap;
}

.offlineHelp {
  font-size: 10px;
  line-height: 1.6;
  color: var(--muted);
  margin: 12px 0 0;
}

progress {
  width: 100%;
  height: 7px;
  border: 0;
  border-radius: 8px;
  background: #edf1e8;
  accent-color: var(--accent);
  overflow: hidden;
}

progress::-webkit-progress-bar {
  background: #edf1e8;
}

progress::-webkit-progress-value {
  background: var(--accent);
}

progress::-moz-progress-bar {
  background: var(--accent);
}

.offlinePanel[data-state=ready] .offlineIcon {
  background: #dcecd7;
}

.offlinePanel[data-state=unavailable] .offlineIcon {
  background: #f4eee1;
  color: #8b713f;
}

@media(min-width:1100px) {
  .routePanel {
    padding: 30px 26px;
  }
  .mapShell {
    grid-template-columns: minmax(0,1fr) 370px;
  }
  .profileChart svg {
    height: 145px;
  }
}

@media(max-width:760px) {
  .topbar {
    min-height: 64px;
    gap: 12px;
    padding: 8px 16px;
    padding-top: max(8px,env(safe-area-inset-top));
  }
  .brand__mark {
    width: 34px;
    height: 34px;
    border-radius: 10px;
  }
  .brand__name {
    font-size: 15px;
  }
  .topbar__context {
    border-left: 0;
    padding-left: 0;
  }
  .topbar__context .eyebrow {
    font-size: 8px;
  }
  .topbar__title {
    font-size: 14px;
  }
  .topbar:has(#btnLibrary:not([hidden])) .brand {
    display: none;
  }
  .btn--back {
    width: 40px;
    min-width: 40px;
    padding: 8px;
    border: 1px solid var(--line);
    background: #fff;
  }
  .btn--back>span {
    display: none;
  }
  .topbar__status {
    font-size: 10px;
    padding: 6px 8px;
    gap: 5px;
  }
  .topbar:has(#btnLibrary[hidden]) .topbar__context {
    display: none;
  }
  .topbar:has(#btnLibrary[hidden]) .topbar__status {
    margin-left: auto;
  }
  .libraryPanel {
    padding: 28px 20px;
  }
  .libraryHero {
    grid-template-columns: 1fr;
    gap: 24px;
    padding-bottom: 28px;
  }
  .libraryHero h1 {
    font-size: 35px;
    letter-spacing: -1.4px;
    margin-bottom: 14px;
  }
  .libraryHero__copy>.eyebrow {
    margin-bottom: 14px;
  }
  .libraryHero p {
    font-size: 13px;
    margin-bottom: 16px;
  }
  .importBox {
    padding: 20px;
  }
  .importBox__icon {
    width: 38px;
    height: 38px;
    margin-bottom: 10px;
  }
  .importBox h2 {
    font-size: 16px;
  }
  .importBox p {
    font-size: 12px;
    max-width: 250px;
    margin: 0 auto 14px;
  }
  .importControl {
    width: 100%;
  }
  .importControl .btn {
    width: 100%;
  }
  .libraryHeading {
    margin: 26px 0 16px;
    flex-wrap: wrap;
    gap: 16px;
  }
  .libraryHeading h2 {
    font-size: 20px;
  }
  .searchBox {
    width: 100%;
  }
  .trackList {
    grid-template-columns: 1fr;
  }
  .libraryHelp {
    padding: 16px;
  }
  .emptyLibrary {
    padding: 28px 16px;
  }
  .desktopOnly {
    display: none;
  }
  .mapShell {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(160px,1fr) auto;
  }
  .mapShell:has(.routePanel:not(:has(> :not([hidden])))) {
    grid-template-rows: 1fr;
  }
  .mapLabel {
    top: 14px;
    left: 14px;
    padding: 8px 10px;
    font-size: 10px;
  }
  .mapLabel>span:last-child {
    display: none;
  }
  .mapTools {
    top: 14px;
    right: 14px;
    gap: 8px;
  }
  .mapBottom {
    left: 14px;
    right: 14px;
    bottom: 31px;
    gap: 8px;
  }
  .gpsInfo {
    font-size: 10px;
    padding: 6px 9px;
    max-width: calc(100% - 45px);
  }
  .locationControls .btn {
    font-size: 12px;
    min-height: 44px;
    padding: 10px 14px;
  }
  .mapAttribution {
    font-size: 8px;
  }
  .routePanel {
    border-left: 0;
    border-top: 1px solid var(--line);
    border-radius: 20px 20px 0 0;
    margin-top: -1px;
    z-index: 6;
    max-height: 55dvh;
    padding: 5px 18px 0;
    padding-bottom: env(safe-area-inset-bottom);
    box-shadow: 0 -4px 18px #2435250d;
  }
  .profileHeader h2 {
    font-size: 12px;
  }
  .profileToggle {
    font-size: 10px;
  }
  .profileSummary {
    margin: 0 0 8px;
    gap: 10px;
  }
  .profileMetric dt {
    font-size: 9px;
    margin-bottom: 3px;
  }
  .profileMetric dd {
    font-size: 20px;
  }
  .profileMetric+.profileMetric {
    padding-left: 15px;
  }
  .profileChart {
    padding-left: 32px;
  }
  .profileChart svg {
    height: 72px;
  }
  .profileAxis {
    font-size: 8px;
  }
  .profileAxis--max {
    top: 4px;
  }
  .profileAxis--min {
    bottom: 18px;
  }
  .profileDistances {
    font-size: 8px;
    margin-top: 0;
  }
  .profileDetails {
    font-size: 9px;
    min-height: 14px;
  }
  .profileLocation {
    font-size: 9px;
    margin: 3px 0 5px;
  }
  .profileNoElevation {
    padding: 10px;
    margin: 6px 0;
    font-size: 11px;
  }
  .offlinePanel {
    border: 0;
    border-top: 1px solid var(--line);
    border-radius: 0;
    margin: 8px 0 0;
    background: transparent;
  }
  .offlinePanel summary {
    min-height: 61px;
    padding: 9px 0;
    gap: 10px;
  }
  .offlineHeading strong {
    font-size: 11px;
  }
  .offlineHeading>span {
    font-size: 9px;
  }
  .offlineIcon {
    width: 32px;
    height: 32px;
  }
  .offlineContent {
    padding: 0 0 14px;
  }
  .offlineHelp {
    margin-bottom: 0;
  }
}

@media(max-width:350px) {
  .topbar {
    padding-left: 10px;
    padding-right: 10px;
    gap: 8px;
  }
  .topbar__title {
    font-size: 12px;
  }
  .topbar__status {
    font-size: 9px;
  }
  .libraryPanel {
    padding: 22px 14px;
  }
  .libraryHero h1 {
    font-size: 30px;
  }
  .routePanel {
    padding-left: 14px;
    padding-right: 14px;
  }
  .profileMetric dd {
    font-size: 18px;
  }
  .mapLabel {
    font-size: 9px;
    padding: 7px 8px;
  }
  .gpsInfo {
    max-width: calc(100% - 50px);
  }
}

@media(max-height:600px) and (orientation:landscape) {
  .topbar {
    min-height: 56px;
  }
  .mapShell {
    grid-template-columns: minmax(0,1fr) 290px;
    grid-template-rows: 1fr;
  }
  .routePanel {
    max-height: none;
    border-radius: 0;
    margin: 0;
    border-top: 0;
    border-left: 1px solid var(--line);
    padding: 8px 16px 16px;
  }
  .mapLabel {
    display: none;
  }
  .mapBottom {
    left: 12px;
    bottom: 30px;
    right: 65px;
  }
  .locationControls {
    flex-wrap: wrap;
  }
  .gpsInfo {
    max-width: 100%;
  }
  .profileSummary {
    margin: 0 0 8px;
  }
  .offlinePanel {
    margin-top: 14px;
  }
  .mapShell:has(.routePanel:not(:has(> :not([hidden])))) {
    grid-template-columns: 1fr;
  }
}

@media(prefers-reduced-motion:reduce) {
  *,*:before,*:after {
    transition: none!important;
    scroll-behavior: auto!important;
  }
}

/* Short portrait screens keep all map actions reachable, even with the profile open. */
@media (max-height: 700px) and (orientation: portrait) {
  .mapLabel {
    display: none;
  }
  .mapTools {
    flex-direction: row;
    align-items: center;
    gap: 6px;
    top: 12px;
    right: 12px;
  }
  .compassButton {
    height: 46px;
  }
  .zoomGroup {
    flex-direction: row;
  }
  .zoomGroup > .btn:first-child {
    border-bottom: 0;
    border-right: 1px solid var(--line);
  }
}

.generationPanel { padding: 12px 16px; border-bottom: 1px solid #dce4dc; font-size: 14px; }
.generationPanel p { margin: 0 0 8px; }

/* Panels float over the map; their closed state occupies only the side buttons. */
.mapShell { position: relative; grid-template-columns: 1fr; grid-template-rows: 1fr; }
.mapShell .routePanel { display: contents; }
.mapShell .profilePanel, .mapShell .offlinePanel[open] {
  position: absolute; z-index: 8; left: 70px; top: 70px;
  width: min(400px, calc(100% - 140px)); max-height: calc(100% - 88px);
  overflow: auto; padding: 12px 16px; margin: 0;
  background: var(--bg); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 8px 32px #20382b26;
}
.mapShell .offlinePanel:not([open]) { display: none; }
.panelTools { position: absolute; left: 14px; top: 70px; z-index: 9; display: grid; gap: 8px; }
.panelTools .btn { box-shadow: var(--shadow); }
.panelTools .btn[aria-expanded=true] { color: white; background: var(--accent); }
#btnOfflinePanel[data-state=downloading] { border: 2px solid var(--accent); }
#btnOfflinePanel[data-state=ready]::after { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #34845e; position: absolute; right: 5px; bottom: 5px; }
#btnOfflinePanel { position: relative; }
.mapShell .offlinePanel summary { padding: 0; min-height: 44px; }
.mapShell .offlineContent { padding: 10px 0 0; }
.mapShell .generationPanel { padding: 8px 0; font-size: 12px; }
.mapUIHidden .mapViewport { outline: none; }
@media(max-width:760px) {
  .mapShell .profilePanel, .mapShell .offlinePanel[open] {
    left: 70px; width: calc(100% - 84px); max-height: calc(100% - 150px);
  }
}
@media(max-height:600px) and (orientation:landscape) {
  .panelTools { top: 14px; }
  .mapShell .profilePanel, .mapShell .offlinePanel[open] { top: 14px; max-height: calc(100% - 28px); }
}

/* Elevation opens above the bottom controls, on every screen size. */
.mapShell .profilePanel {
  top: auto; bottom: 92px; left: 14px;
  width: min(560px, calc(100% - 28px)); max-height: calc(100% - 112px);
}
#btnProfilePanel { margin-left: 4px; }
#btnProfilePanel[aria-expanded=true], #btnOfflinePanel[aria-expanded=true] { background: var(--accent); color: white; }
.topbar { transition: margin-top .22s ease, transform .22s ease, opacity .22s ease, visibility .22s; }
.mapLabel, .mapTools, .mapBottom, .mapAttribution, .panelTools, .routePanel > * {
  transition: opacity .22s ease, transform .22s ease, visibility .22s;
}
.mapUIHidden .topbar {
  margin-top: calc(0px - var(--map-header-height, 80px));
  transform: translateY(-100%); opacity: 0; visibility: hidden; pointer-events: none;
}
.mapUIHidden .mapLabel, .mapUIHidden .mapTools, .mapUIHidden .mapBottom,
.mapUIHidden .mapAttribution, .mapUIHidden .panelTools, .mapUIHidden .routePanel > * {
  opacity: 0; visibility: hidden; pointer-events: none; transform: translateY(8px);
}

@media(max-width:400px) {
  .locationControls #btnLocate, .locationControls #btnFollow { width: 44px; padding: 10px; }
  .locationControls #btnLocate > span, .locationControls #btnFollow > span { display: none; }
}

.waypointLabel { color: #244a74; background: #f8fbffed; border-color: #9db4cf; }

/* Opt-in XYZ diagnostics (?debug=1), outside the tile stacking context. */
.tileDebugGrid { position:absolute; inset:0; z-index:4; pointer-events:none; overflow:hidden; }
.tileDebugBox { position:absolute; box-sizing:border-box; border:1px solid #c026d3; }
.tileDebugBox span { position:absolute; top:2px; left:2px; padding:2px 4px; background:#111e; color:#fff; font:11px/1.3 monospace; white-space:nowrap; }
.tileDebugBox[data-state="error"], .tileDebugBox[data-state="dimensiones inválidas"] { border:2px dashed #dc2626; }
.tileDebug.info { position:absolute; top:64px; left:12px; z-index:8; width:min(460px,calc(100% - 88px)); max-height:40%; overflow:auto; box-sizing:border-box; padding:8px; background:#111e; color:#fff; font:12px/1.4 monospace; pointer-events:auto; border-radius:6px; }
.tileDebug summary { cursor:pointer; }
.tileDebug p { margin:8px 0; }
.tileDebug ul { padding-left:18px; }
.tileDebug li { margin:6px 0; overflow-wrap:anywhere; }
.tileDebug a { color:#93c5fd; }
.tileDebugGrid,.tileDebug { transition:opacity 220ms ease,visibility 220ms; }
.mapUIHidden .tileDebugGrid,.mapUIHidden .tileDebug { opacity:0; visibility:hidden; pointer-events:none; }
@media (prefers-reduced-motion:reduce) { .tileDebugGrid,.tileDebug { transition:none; } }
