:root {
  --page-bg: #ffffff;
  --text: #111111;
  --text-muted: #555555;
  --panel: #ececec;
  --panel-border: #d4d4d4;
  --panel-raised: #e0e0e0;
  --accent: #b07018;
  --signal: #FF0301;
  --signal-light: #ff8f8e;
  --signal-dark: #8b0201;
  --route: #FF0301;
  --route-light: #FF0301;
  --route-outline: #8b0201;
  --route-done: #ff8f8e;
  --profile: #95c21e;
  --profile-light: #b5d84a;
  --profile-soft: #d8efb8;
  --profile-dark: #6a9118;
  --profile-deep: #4f6d10;
  --profile-passed-opacity: 0.6;
  --shortcut: #7c4dff;
  --shortcut-light: #b794ff;
  --shortcut-dark: #4a2d99;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--page-bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 20px 60px;
}

.eyebrow {
  font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0 0 6px;
}

h1 {
  font-weight: 800;
  text-transform: uppercase;
  font-size: clamp(28px, 5vw, 44px);
  margin: 0 0 4px;
  letter-spacing: 0.01em;
  color: var(--text);
}

.subtitle {
  color: var(--text-muted);
  font-size: 15px;
  margin: 0 0 22px;
}

.stats {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  margin-bottom: 20px;
}

.stat {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 4px;
  padding: 10px 16px;
  min-width: 92px;
}

.stat .n {
  font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-weight: 600;
  font-size: 20px;
  color: var(--text);
}

.stat .l {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-top: 2px;
}

.map-card {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 12px;
}

.map-attrib {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 2px 4px 10px;
  flex-wrap: wrap;
}

.map-attrib a {
  display: inline-flex;
  align-items: center;
}

.map-attrib img {
  height: 22px;
  display: block;
}

.map-attrib .copy {
  font-size: 11.5px;
  color: var(--text-muted);
}

.map-attrib .copy a {
  color: var(--text-muted);
  text-decoration: underline;
  font-size: 11.5px;
}

.overlay-switch,
.layer-switch {
  display: flex;
  gap: 6px;
}

.layer-switch {
  margin-left: auto;
}

.overlay-switch button,
.layer-switch button {
  background: var(--panel-raised);
  border: 1px solid var(--panel-border);
  color: var(--text);
  border-radius: 4px;
  padding: 5px 10px;
  font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 11.5px;
  cursor: pointer;
}

.overlay-switch button {
  white-space: normal;
  line-height: 1.25;
  text-align: center;
}

.overlay-switch button.active,
.layer-switch button.active {
  background: var(--text);
  color: var(--page-bg);
  border-color: var(--text);
}

#map {
  width: 100%;
  height: 440px;
  min-height: 300px;
  border-radius: 6px;
  overflow: hidden;
  position: relative;
  z-index: 0;
  background: #ffffff;
  --map-label-scale: 1;
}

#map.leaflet-container { font: inherit; }

#map:focus-visible {
  outline: 2px solid var(--profile-dark);
  outline-offset: 2px;
}

.map-card .leaflet-control-attribution {
  display: none;
}

.profile-card {
  margin-top: 16px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 16px 16px 10px;
  position: relative;
}

.route-view {
  position: relative;
}

.profile-screen-actions {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 6;
  display: none;
  gap: 6px;
}

.profile-screen-btn {
  min-height: 34px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--page-bg);
  border: 1px solid var(--panel-border);
  color: var(--text);
  border-radius: 4px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.2;
  cursor: pointer;
  transition: background 0.15s;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.profile-screen-btn--expand {
  width: auto;
  padding: 6px 11px;
  white-space: nowrap;
}

.profile-screen-btn--close {
  display: none;
  width: 34px;
  font-size: 17px;
  font-weight: 400;
}

.profile-screen-btn:hover {
  background: #ececec;
}

.profile-screen-btn:focus-visible {
  outline: 2px solid var(--profile-dark);
  outline-offset: 2px;
}

.route-view--expanded .profile-screen-btn--expand {
  display: none;
}

.route-view--expanded .profile-screen-btn--close {
  display: inline-flex;
}

body.profile-fullscreen-open {
  overflow: hidden;
}

.route-view--expanded {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 9999;
  overflow: hidden;
  background: var(--page-bg);
  width: 100%;
  height: 100%;
  height: 100dvh;
  max-height: 100dvh;
  padding:
    max(10px, env(safe-area-inset-top))
    max(10px, env(safe-area-inset-right))
    max(10px, env(safe-area-inset-bottom))
    max(10px, env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}

.route-view--expanded .profile-screen-actions {
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  right: max(10px, env(safe-area-inset-right));
  z-index: 2;
}

.route-view--expanded .map-card {
  display: none;
}

html.in-iframe body.profile-fullscreen-open {
  overflow: hidden;
  touch-action: none;
}

html.in-iframe .route-view--expanded {
  max-height: none;
}

.route-view--expanded .profile-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  margin: 0;
  min-height: 0;
  border: none;
  border-radius: 0;
  padding:
    max(44px, calc(env(safe-area-inset-top) + 36px))
    max(4px, env(safe-area-inset-right))
    10px
    max(4px, env(safe-area-inset-left));
  background: var(--page-bg);
}

.route-view--expanded .profile-hint {
  display: none;
}

.route-view--expanded .profile-head {
  flex-shrink: 0;
  margin-bottom: 4px;
}

.route-view--expanded #svgWrap {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior: none;
  -webkit-overflow-scrolling: auto;
  touch-action: pan-x;
  cursor: grab;
  margin-top: 2px;
  scrollbar-width: thin;
}

.route-view--expanded #svgWrap:active,
.route-view--expanded #svgWrap.svg-wrap--scrubbing {
  cursor: grabbing;
  touch-action: none;
}

.route-view--expanded #svgWrap svg {
  display: block;
  height: 100%;
  width: auto;
  max-height: none;
}

.route-view--expanded .controls,
.route-view--expanded .legend {
  flex-shrink: 0;
}

.route-view--expanded .info-popover {
  z-index: 10002;
  pointer-events: auto;
  max-width: min(300px, calc(100vw - 24px));
}

.profile-fullscreen-scroll-hint {
  display: none;
  flex-shrink: 0;
  margin: 0 0 6px;
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
}

.route-view--expanded .profile-fullscreen-scroll-hint {
  display: block;
}

.profile-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
  padding-right: 0;
}

.profile-head h2 {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text);
  margin: 0;
}

@media (max-width: 640px), (orientation: landscape) and (max-height: 500px) {
  .profile-screen-actions {
    display: flex;
  }

  .profile-head {
    padding-right: 118px;
  }

  .profile-screen-btn--expand {
    font-size: 10px;
    padding: 5px 8px;
  }
}

#svgWrap {
  position: relative;
  cursor: pointer;
  user-select: none;
  touch-action: none;
}

svg { display: block; width: 100%; height: auto; }

.wp-name {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-weight: 600;
  fill: var(--text);
}

.wp-name--os {
  font-size: 13px;
}

.wp-gate {
  font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 9px;
  font-weight: 600;
  fill: var(--accent);
}

.wp-ele {
  font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-style: italic;
  fill: var(--text-muted);
}

.os-hit,
.gate-hit,
.peak-hit { cursor: pointer; }
.peak-hit .wp-ele,
.peak-hit .wp-name { pointer-events: none; }
.os-hit:hover .wp-name,
.os-hit:hover .wp-ele,
.os-hit:hover .wp-gate { fill: var(--signal); }

.gate-hit:not(.os-hit):hover .wp-name,
.gate-hit:not(.os-hit):hover .wp-ele,
.gate-hit:not(.os-hit):hover .wp-gate { fill: var(--profile-dark); }

.gate-popover,
.info-popover {
  position: absolute;
  z-index: 4;
  min-width: 188px;
  max-width: 300px;
  padding: 10px 12px;
  border-radius: 6px;
  border: 1px solid var(--panel-border);
  background: var(--page-bg);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  pointer-events: none;
}

.info-popover-body {
  margin-top: 8px;
  max-height: 220px;
  overflow-y: auto;
}

.info-popover-name,
.gate-popover-name {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.info-popover-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.info-popover-label,
.gate-popover-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.info-popover-highlight,
.gate-popover-time {
  font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 15px;
  font-weight: 600;
  color: var(--profile-dark);
}

.info-popover-section {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin: 0 0 4px;
}

.info-popover-list {
  margin: 0;
  padding-left: 16px;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--text);
}

.info-popover-list li + li {
  margin-top: 3px;
}

.info-popover-schedule {
  margin-top: 2px;
}

.info-popover-schedule .info-popover-section {
  margin-bottom: 8px;
}

.info-popover-schedule-item + .info-popover-schedule-item {
  margin-top: 10px;
}

.info-popover-schedule-item .info-popover-label {
  margin-bottom: 2px;
}

.info-popover-schedule-item .info-popover-highlight {
  font-size: 14px;
  line-height: 1.25;
}

.info-popover-note {
  margin: 8px 0 0;
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--text-muted);
}

.leaflet-popup.info-popup .leaflet-popup-content-wrapper {
  border-radius: 6px;
  border: 1px solid var(--panel-border);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.14);
  padding: 0;
}

.leaflet-popup.info-popup .leaflet-popup-content {
  margin: 10px 12px;
  min-width: 200px;
  max-width: 300px;
}

.leaflet-popup.info-popup .info-popover-body {
  max-height: 260px;
  pointer-events: auto;
}

.profile-hint {
  margin: 0 0 8px;
  font-size: 12px;
  color: var(--text-muted);
}

.os-popup .os-gate {
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--text);
}

.os-popup .os-gate strong {
  font-weight: 600;
}

.leaflet-popup-content-wrapper { border-radius: 6px; }

.legend {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--panel-border);
}

.legend .item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
}

.legend .item .sw {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  display: inline-block;
}

.legend .item .sw.peak { background: var(--profile); }
.legend .item .sw.os { background: var(--signal); }

.legend .item .sw.shortcut-mark {
  border-top: 2px dashed #005EB8;
  height: 0;
  background: transparent;
}

.legend--marks {
  margin-top: 6px;
  padding-top: 8px;
}

.legend .item .sw.mark {
  width: 18px;
  height: 4px;
  border-radius: 2px;
}

.legend .item .sw.mark--red { background: #E4002B; }
.legend .item .sw.mark--blue { background: #005EB8; }
.legend .item .sw.mark--green { background: #008040; }
.legend .item .sw.mark--yellow { background: #E6B800; }
.legend .item .sw.mark--none { background: #222222; }

.profile-mark {
  pointer-events: none;
}

.profile-track {
  transition: opacity 0.2s ease;
}

.profile-track--passed {
  opacity: var(--profile-passed-opacity);
}

.profile-fill {
  pointer-events: none;
}

#scrubLine {
  pointer-events: none;
}

#scrubDot {
  pointer-events: none;
}

#scrubKmLabel {
  pointer-events: none;
  font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 15px;
  font-weight: 700;
  fill: var(--profile-dark);
  text-anchor: middle;
}

#scrubEleLabel {
  pointer-events: none;
  font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 10px;
  font-weight: 600;
  fill: var(--text-muted);
  text-anchor: middle;
}

.axis-km-label {
  transition: opacity 0.15s ease;
}

.axis-km-label--hidden {
  opacity: 0;
}

.profile-shortcut {
  pointer-events: none;
}

.shortcut-hit {
  cursor: pointer;
  pointer-events: stroke;
}

.shortcut-hit:hover + .profile-shortcut,
.profile-shortcut-wrap:hover .profile-shortcut {
  stroke-width: 5;
  opacity: 1;
}

.info-popover-highlight--warn {
  color: var(--shortcut-dark);
  background: color-mix(in srgb, var(--shortcut) 12%, #ffffff);
  border: 1px solid color-mix(in srgb, var(--shortcut) 28%, transparent);
}

.controls {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  flex-wrap: wrap;
}

button.ctl {
  background: var(--panel-raised);
  border: 1px solid var(--panel-border);
  color: var(--text);
  border-radius: 6px;
  padding: 5px 8px;
  font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 11px;
  cursor: pointer;
  transition: background 0.15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

button.ctl:hover { background: #d5d5d5; }

button.ctl.active {
  background: var(--text);
  color: var(--page-bg);
  border-color: var(--text);
}

#posLabel {
  font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 11px;
  color: var(--text);
  margin-left: auto;
  text-align: right;
  line-height: 1.35;
}

.position-marker-wrap {
  background: transparent;
  border: none;
}

.position-marker {
  position: relative;
  width: 28px;
  height: 28px;
}

.position-marker__ring {
  position: absolute;
  inset: 2px;
  border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--profile) 45%, transparent);
  animation: position-pulse 2.6s ease-out infinite;
}

.position-marker__core {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 13px;
  height: 13px;
  margin: -6.5px 0 0 -6.5px;
  border-radius: 50%;
  background: var(--profile);
  border: 2.5px solid #ffffff;
  box-shadow: 0 1px 4px color-mix(in srgb, var(--profile-deep) 35%, transparent);
}

@keyframes position-pulse {
  0% {
    transform: scale(0.9);
    opacity: 0.65;
  }

  70% {
    transform: scale(1.2);
    opacity: 0;
  }

  100% {
    transform: scale(1.2);
    opacity: 0;
  }
}

.os-marker-wrap,
.peak-marker-wrap,
.map-endpoint-wrap {
  background: transparent;
  border: none;
  transition: opacity 0.2s ease;
}

.os-marker-wrap.is-passed,
.peak-marker-wrap.is-passed,
.map-endpoint-wrap.is-passed {
  opacity: var(--profile-passed-opacity);
}

.wp-passable {
  transition: opacity 0.2s ease;
}

.wp-passable.is-passed {
  opacity: var(--profile-passed-opacity);
}

.map-os-marker {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  transform: scale(var(--map-label-scale, 1));
  transform-origin: 50% 22%;
  transition: transform 0.14s ease-out;
}

.map-os-marker__dot {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--signal);
  background: color-mix(in srgb, var(--signal) 78%, #ffffff);
  border: 2px solid rgba(255, 255, 255, 0.95);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.22);
  flex-shrink: 0;
}

.map-os-marker--label-above {
  transform-origin: 50% 78%;
}

.map-peak-marker {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  transform: scale(var(--map-label-scale, 1));
  transform-origin: 50% 22%;
  transition: transform 0.14s ease-out;
}

.map-peak-marker__dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--profile);
  border: 1.5px solid rgba(255, 255, 255, 0.95);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  flex-shrink: 0;
}

.map-peak-marker__label {
  display: none;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text);
  background: rgba(255, 255, 255, 0.88);
  padding: 1px 4px;
  border-radius: 3px;
  border: 1px solid rgba(0, 0, 0, 0.07);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  white-space: nowrap;
  max-width: 68px;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.15;
}

#map.map--peak-os-labels .map-peak-marker__label {
  display: block;
  max-width: none;
  overflow: visible;
  text-overflow: unset;
}

#map.map--peak-os-labels-large .map-peak-marker__label {
  font-size: 9.5px;
  padding: 2px 5px;
}

.map-os-marker__label {
  display: none;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text);
  background: rgba(255, 255, 255, 0.9);
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
  white-space: nowrap;
  max-width: 72px;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}

#map.map--peak-os-labels .map-os-marker__label {
  display: block;
  max-width: none;
  overflow: visible;
  text-overflow: unset;
}

#map.map--peak-os-labels-large .map-os-marker__label {
  font-size: 10.5px;
  padding: 2px 7px;
}

@media (prefers-reduced-motion: reduce) {
  .position-marker__ring {
    animation: none;
  }

  .map-os-marker,
  .map-peak-marker {
    transition: none;
  }
}

.map-endpoint {
  display: flex;
  flex-direction: column;
  align-items: center;
  transform: scale(var(--map-label-scale, 1));
  transform-origin: 50% 100%;
  transition: transform 0.14s ease-out;
}

.map-endpoint__card {
  display: none;
  background: #ffffff;
  border-radius: 4px;
  padding: 5px 10px 6px;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
  white-space: nowrap;
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
}

#map.map--endpoint-labels .map-endpoint__card {
  display: block;
}

#map.map--endpoint-labels-large .map-endpoint__card {
  max-width: none;
  overflow: visible;
  text-overflow: unset;
  padding: 6px 12px 7px;
}

#map.map--endpoint-labels-large .map-endpoint__name {
  font-size: 13px;
}

.map-endpoint--start .map-endpoint__card {
  border: 2px solid var(--profile);
}

.map-endpoint--finish .map-endpoint__card {
  border: 2px solid var(--signal);
}

.map-endpoint__tag {
  display: block;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  line-height: 1.2;
}

.map-endpoint__name {
  display: block;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.25;
  margin-top: 1px;
}

.map-endpoint__pin {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  border: 2px solid #ffffff;
  margin-top: 4px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

.map-endpoint--start .map-endpoint__pin {
  background: var(--profile);
}

.map-endpoint--finish .map-endpoint__pin {
  background: var(--signal);
}

.os-marker {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--signal);
  border: 2px solid rgba(255, 255, 255, 0.95);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.22);
}

.os-popup { font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }

.os-popup h3 {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  margin: 0 0 6px;
  font-size: 15px;
  color: var(--text);
}

.os-popup ul {
  margin: 0;
  padding-left: 16px;
  font-size: 13px;
}

.leaflet-interactive.route-line { pointer-events: stroke; }

.footnote {
  margin-top: 18px;
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.5;
}

.footnote a {
  color: var(--text);
}

.footnote code {
  background: var(--panel-raised);
  padding: 1px 5px;
  border-radius: 4px;
  color: var(--text);
}

.b7-error {
  padding: 20px;
  color: var(--signal);
  font: 14px Inter, sans-serif;
}

.page-copy {
  display: block;
  margin-bottom: 20px;
}

.gpx-download {
  display: inline-flex;
  align-items: center;
  margin-top: 10px;
  padding: 8px 14px;
  background: var(--panel-raised);
  border: 1px solid var(--panel-border);
  border-radius: 4px;
  color: var(--text);
  font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 12.5px;
  text-decoration: none;
  transition: background 0.15s;
}

.gpx-download:hover {
  background: #d5d5d5;
}

.gpx-download:focus-visible {
  outline: 2px solid var(--profile-dark);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ── Responzivita ─────────────────────────────────────────── */

@media (max-width: 768px) {
  .wrap {
    padding: 20px 16px 48px;
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
  }

  h1 {
    font-size: clamp(24px, 7vw, 36px);
  }

  .subtitle {
    font-size: 14px;
    margin-bottom: 18px;
  }

  .stat {
    min-width: 0;
    flex: 1 1 calc(50% - 5px);
    padding: 9px 12px;
  }

  .stat .n {
    font-size: 18px;
  }

  .map-card {
    padding: 10px;
    border-radius: 6px;
  }

  #map {
    height: min(48vh, 400px);
    min-height: 260px;
  }

  .profile-card {
    padding: 14px 12px 10px;
  }

  .profile-head h2 {
    font-size: 14px;
  }

  .legend {
    gap: 10px 14px;
  }

  .legend .item {
    font-size: 11.5px;
  }
}

@media (max-width: 640px) {
  .wrap {
    padding: 16px 12px 40px;
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
  }

  .stats {
    gap: 8px;
    margin-bottom: 16px;
  }

  .stat .l {
    font-size: 10px;
    letter-spacing: 0.06em;
  }

  .map-attrib {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 10px 12px;
    padding: 0 2px 8px;
  }

  .map-attrib > a {
    grid-column: 1;
    grid-row: 1;
  }

  .map-attrib > .copy {
    grid-column: 2;
    grid-row: 1;
    font-size: 10.5px;
    line-height: 1.4;
  }

  .map-attrib > .overlay-switch,
  .map-attrib > .layer-switch {
    grid-column: 1 / -1;
  }

  .overlay-switch,
  .layer-switch {
    margin-left: 0;
    width: 100%;
    flex-wrap: wrap;
  }

  .overlay-switch button,
  .layer-switch button {
    flex: 1 1 0;
    min-width: 0;
    min-height: 40px;
    padding: 8px 6px;
    font-size: 11px;
    -webkit-tap-highlight-color: transparent;
  }

  #map {
    height: min(52vh, 360px);
    min-height: 240px;
    border-radius: 4px;
  }

  .profile-hint {
    font-size: 11.5px;
    line-height: 1.45;
    margin-bottom: 10px;
  }

  .controls {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 6px;
    margin-top: 8px;
  }

  button.ctl {
    min-height: 36px;
    padding: 6px 4px;
    font-size: 13px;
    -webkit-tap-highlight-color: transparent;
  }

  .ctl__word {
    display: none;
  }

  #posLabel {
    grid-column: 1 / -1;
    width: 100%;
    margin-left: 0;
    text-align: center;
    font-size: 11.5px;
    line-height: 1.4;
    padding: 4px 0 2px;
  }

  .gate-popover,
  .info-popover {
    min-width: 0;
    max-width: min(300px, calc(100vw - 32px));
  }

  .leaflet-popup.info-popup .leaflet-popup-content {
    min-width: 0;
    max-width: min(300px, calc(100vw - 48px));
  }

  /* Kompaktní profil na telefonu — jen názvy, větší font */
  .profile--compact .wp-name {
    font-size: 14px !important;
  }

  .profile--compact .wp-name--os {
    font-size: 13px !important;
  }

  .profile-card--compact .profile-hint {
    font-size: 11px;
  }

  .footnote {
    font-size: 12px;
  }
}

@media (max-width: 400px) {
  .wrap {
    padding: 14px 10px 36px;
    padding-left: max(10px, env(safe-area-inset-left));
    padding-right: max(10px, env(safe-area-inset-right));
  }

  h1 {
    font-size: 22px;
  }

  .stat {
    padding: 8px 10px;
  }

  .stat .n {
    font-size: 16px;
  }

  .stat .l {
    font-size: 9px;
  }

  .overlay-switch button,
  .layer-switch button {
    font-size: 10px;
    padding: 8px 4px;
  }

  button.ctl {
    font-size: 10.5px;
    padding: 6px 6px;
    min-height: 34px;
  }

  #posLabel {
    font-size: 10.5px;
  }

  .legend {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
}

@media (max-width: 640px) and (orientation: landscape) {
  #map {
    height: min(62vh, 320px);
    min-height: 200px;
  }
}
