/* ═══════════════════════════════════════════════════════════
   Ruck Map v0.1 — theme-aware design system
   Dark: night trail / tactical olive
   Light: alpine daylight / clean cartography
   ═══════════════════════════════════════════════════════════ */

:root,
[data-theme="dark"] {
  --bg: #0c100e;
  --bg-elevated: rgba(20, 26, 23, 0.9);
  --bg-card: rgba(26, 34, 30, 0.78);
  --bg-card-hover: rgba(33, 43, 38, 0.88);
  --border: rgba(196, 163, 90, 0.14);
  --border-strong: rgba(196, 163, 90, 0.28);
  --text: #eef2ec;
  --text-secondary: #a3b0a6;
  --text-muted: #6b7a70;
  --accent: #c4a35a;
  --accent-soft: rgba(196, 163, 90, 0.15);
  --accent-hover: #d4b86a;
  --good: #5dbe8a;
  --warn: #e0a458;
  --danger: #e06c75;
  --info: #6aa8c8;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  --radius: 16px;
  --radius-sm: 10px;
  --font: "DM Sans", system-ui, -apple-system, sans-serif;
  --font-display: "Outfit", var(--font);
  --map-route: #c4a35a;
  --map-route-glow: rgba(196, 163, 90, 0.45);
  --map-tiles: dark;
  --glass: rgba(20, 26, 23, 0.72);
  --login-overlay: linear-gradient(135deg, rgba(8,12,10,0.88) 0%, rgba(12,18,14,0.72) 50%, rgba(8,12,10,0.9) 100%);
  --chart-grid: rgba(255,255,255,0.06);
  --thumb-bg: #0f1512;
  --offline-bg: rgba(224, 164, 88, 0.12);
  --offline-border: rgba(224, 164, 88, 0.35);
  --header-blur: blur(16px) saturate(1.2);
  --app-bg-image: url("/assets/app-bg-dark.jpg?v=5");
  /* Illustrated night-trail art — moderate scrim keeps gold accents visible */
  --app-bg-overlay: linear-gradient(
    180deg,
    rgba(8, 12, 10, 0.55) 0%,
    rgba(12, 16, 14, 0.68) 45%,
    rgba(10, 14, 12, 0.82) 100%
  );
  --app-bg-vignette: radial-gradient(
    ellipse 90% 70% at 50% 35%,
    transparent 0%,
    rgba(0, 0, 0, 0.28) 100%
  );
  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #f3f1eb;
  --bg-elevated: rgba(255, 252, 247, 0.92);
  --bg-card: rgba(255, 255, 255, 0.82);
  --bg-card-hover: rgba(255, 252, 247, 0.92);
  --border: rgba(45, 55, 48, 0.1);
  --border-strong: rgba(45, 55, 48, 0.18);
  --text: #1a221e;
  --text-secondary: #4a5750;
  --text-muted: #7a8780;
  --accent: #8b6914;
  --accent-soft: rgba(139, 105, 20, 0.1);
  --accent-hover: #6d5210;
  --good: #1f8a55;
  --warn: #c47a12;
  --danger: #c43c48;
  --info: #2a7a9b;
  --shadow: 0 12px 36px rgba(40, 50, 44, 0.1);
  --map-route: #2d6a4f;
  --map-route-glow: rgba(45, 106, 79, 0.35);
  --map-tiles: light;
  --glass: rgba(255, 252, 247, 0.82);
  --login-overlay: linear-gradient(135deg, rgba(243,241,235,0.55) 0%, rgba(255,252,247,0.75) 100%);
  --chart-grid: rgba(0,0,0,0.06);
  --thumb-bg: #e8e6df;
  --offline-bg: rgba(196, 122, 18, 0.1);
  --offline-border: rgba(196, 122, 18, 0.3);
  --header-blur: blur(16px) saturate(1.4);
  --app-bg-image: url("/assets/app-bg-light.jpg?v=5");
  /* Illustrated spring-trail art — soft parchment scrim for glass UI */
  --app-bg-overlay: linear-gradient(
    180deg,
    rgba(248, 246, 240, 0.42) 0%,
    rgba(245, 242, 234, 0.58) 45%,
    rgba(243, 239, 230, 0.74) 100%
  );
  --app-bg-vignette: radial-gradient(
    ellipse 85% 65% at 50% 30%,
    transparent 0%,
    rgba(70, 60, 40, 0.1) 100%
  );
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  line-height: 1.5;
}

button, input {
  font-family: inherit;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* ─── Login ─── */
.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  position: relative;
  z-index: 10;
  overflow: hidden;
  background: #0a0e0c;
}

.login-bg {
  position: absolute;
  inset: 0;
  background:
    var(--login-overlay),
    url("/assets/login-bg.jpg") center/cover no-repeat;
  transform: scale(1.02);
  filter: saturate(0.95);
}

.login-card {
  position: relative;
  z-index: 2;
  width: min(420px, calc(100% - 32px));
  background: var(--glass);
  backdrop-filter: blur(24px) saturate(1.3);
  -webkit-backdrop-filter: blur(24px) saturate(1.3);
  border: 1px solid var(--border-strong);
  border-radius: 22px;
  padding: 36px 32px 28px;
  box-shadow: var(--shadow);
}

[data-theme="light"] .login-card {
  background: rgba(255, 252, 247, 0.92);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.brand-header {
  margin-bottom: 0;
  gap: 12px;
  align-items: center;
}

.brand-text {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  min-width: 0;
}

.brand-mark {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  overflow: hidden;
  flex-shrink: 0;
  background: #0f1411;
  border: 1px solid rgba(196, 163, 90, 0.35);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.35),
    0 4px 14px rgba(0, 0, 0, 0.35);
}

.brand-header .brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 12px;
}

.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
  /* Keep mark crisp and bright on both themes */
  filter: contrast(1.08) saturate(1.05);
}

.brand-title,
.brand h1 {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.05;
  margin: 0;
}

.brand-header .brand-title {
  font-size: 1.2rem;
  letter-spacing: -0.025em;
}

.brand-title span,
.brand h1 span {
  color: var(--accent);
  font-weight: 700;
}

/* Username under title */
.brand-text .profile-link {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: none;
  max-width: 200px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
  letter-spacing: 0.01em;
}

.brand-text .profile-link:hover {
  color: var(--accent);
}

[data-theme="light"] .brand-mark {
  border-color: rgba(139, 105, 20, 0.35);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.4),
    0 3px 10px rgba(40, 50, 44, 0.12);
}

[data-theme="light"] .brand-text .profile-link {
  color: var(--text-secondary);
}

.login-tagline {
  color: var(--text-secondary);
  font-size: 0.92rem;
  margin-bottom: 24px;
}

.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.field input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  color: var(--text);
  font-size: 1rem;
  transition: border-color .15s;
}

.field input:focus {
  outline: none;
  border-color: var(--accent);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: var(--radius-sm);
  padding: 12px 18px;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: transform .1s, background .15s, opacity .15s;
}

.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  width: 100%;
  background: linear-gradient(135deg, var(--accent), #a8893f);
  color: #0c100e;
  margin-top: 6px;
}

[data-theme="light"] .btn-primary {
  background: linear-gradient(135deg, #8b6914, #6d5210);
  color: #fff;
}

.btn-primary:hover:not(:disabled) { filter: brightness(1.06); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn-ghost:hover { background: var(--accent-soft); color: var(--text); }

.btn-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

.btn-icon:hover { border-color: var(--accent); color: var(--accent); }
.btn-icon.is-busy {
  opacity: 0.55;
  pointer-events: none;
}

/* Metric / Imperial segmented control */
.units-toggle {
  display: inline-flex;
  align-items: stretch;
  padding: 3px;
  border-radius: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  cursor: pointer;
  gap: 2px;
  height: 40px;
  box-sizing: border-box;
}

.units-toggle:hover { border-color: var(--border-strong); }

.units-opt {
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border-radius: 9px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text-muted);
  transition: background .15s, color .15s;
  user-select: none;
}

.units-toggle[data-units="metric"] .units-opt[data-u="metric"],
.units-toggle[data-units="imperial"] .units-opt[data-u="imperial"] {
  background: var(--accent-soft);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--border-strong);
}

@media (max-width: 640px) {
  .units-opt { padding: 0 7px; font-size: 0.68rem; }
}

/* Photo album on/off (default off for faster lists) */
.photos-toggle {
  display: inline-flex;
  align-items: stretch;
  padding: 3px;
  border-radius: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  cursor: pointer;
  gap: 2px;
  height: 40px;
  box-sizing: border-box;
}

.photos-toggle:hover {
  border-color: var(--border-strong);
}

.photos-toggle.hidden,
.photos-toggle[hidden],
body.photos-host-disabled .photos-toggle {
  display: none !important;
}

.photos-toggle:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.photos-toggle .photos-opt {
  display: inline-flex;
  align-items: center;
  padding: 0 9px;
  border-radius: 9px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text-muted);
  transition: background .15s, color .15s;
  user-select: none;
}

.photos-toggle[data-mode="on"] .photos-opt[data-mode="on"],
.photos-toggle[data-mode="off"] .photos-opt[data-mode="off"] {
  background: var(--accent-soft);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--border-strong);
}

@media (max-width: 720px) {
  .photos-toggle .photos-opt {
    padding: 0 6px;
    font-size: 0.65rem;
  }
}

.login-error {
  background: rgba(224, 108, 117, 0.12);
  border: 1px solid rgba(224, 108, 117, 0.35);
  color: var(--danger);
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 0.88rem;
  margin-bottom: 12px;
  display: none;
}

.login-error.show { display: block; }

.login-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0 14px;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.login-divider::before,
.login-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.login-footer {
  margin-top: 18px;
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.login-sso-note {
  margin-top: 12px;
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--text-muted);
  text-align: left;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--accent-soft);
  border: 1px solid var(--border);
}

.login-tagline strong {
  color: var(--accent);
  font-weight: 650;
}

.demo-banner {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--offline-bg);
  border: 1px solid var(--offline-border);
  color: var(--warn);
  font-size: 0.88rem;
}

.demo-banner.show { display: flex; }

.demo-banner button {
  white-space: nowrap;
}

.mfa-hint {
  font-size: 0.85rem;
  color: var(--warn);
  margin-bottom: 10px;
  display: none;
}

.mfa-hint.show { display: block; }

/* ─── App shell ─── */
.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  background: transparent;
  /* Keep content above the fixed scene layers */
  isolation: isolate;
}

/* Rucking theme background — real DOM layers with non-negative z-index
   (body::before with z-index:-1 paints under html/body background and vanishes) */
.app-bg,
.app-bg-scrim {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.app-bg {
  background-color: var(--bg);
  background-image: var(--app-bg-image);
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
  transform: scale(1.02);
  filter: saturate(0.92);
  will-change: transform;
}

.app-bg-scrim {
  z-index: 1;
  background:
    var(--app-bg-vignette),
    var(--app-bg-overlay);
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px;
  background: var(--glass);
  backdrop-filter: var(--header-blur);
  -webkit-backdrop-filter: var(--header-blur);
  border-bottom: 1px solid var(--border);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.header-left .brand h1 { font-size: 1.2rem; }

.profile-link {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  border-bottom: 1px dashed var(--border-strong);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}

.profile-link:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.offline-pill {
  display: none;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--offline-bg);
  border: 1px solid var(--offline-border);
  color: var(--warn);
}

.offline-pill.show { display: inline-flex; }

.offline-pill .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--warn);
  box-shadow: 0 0 0 3px rgba(224, 164, 88, 0.2);
}

/* ─── Main ─── */
.main {
  position: relative;
  z-index: 2;
  flex: 1;
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 20px 16px 48px;
}

/* Period tabs */
.period-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}

.tabs {
  display: inline-flex;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 4px;
  gap: 2px;
}

.tab {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.88rem;
  padding: 8px 16px;
  border-radius: 10px;
  cursor: pointer;
}

.tab.active {
  background: var(--accent-soft);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--border-strong);
}

[data-theme="dark"] .tab.active {
  background: linear-gradient(180deg, rgba(196,163,90,0.18), rgba(196,163,90,0.08));
  color: #e8d5a3;
}

.period-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.period-label {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.05rem;
  min-width: 140px;
  text-align: center;
}

/* Stats grid — typography-first tiles, no icons */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
  gap: 10px;
  margin-bottom: 24px;
}

.stat-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0;
  /* Fixed height so Month/Year (Everests bar) and Lifetime (Steps) don't reflow */
  height: 138px;
  min-height: 138px;
  max-height: 138px;
  padding: 16px 16px 14px;
  background: var(--bg-card);
  backdrop-filter: blur(14px) saturate(1.15);
  -webkit-backdrop-filter: blur(14px) saturate(1.15);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  transition: border-color .18s, box-shadow .18s, background .18s;
  box-sizing: border-box;
}

/* Quiet top accent hairline */
.stat-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--stat-accent, var(--border-strong));
  opacity: 0.85;
}

.stat-card:hover {
  border-color: var(--border-strong);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.18);
  background: var(--bg-card-hover);
}

[data-theme="light"] .stat-card:hover {
  box-shadow: 0 8px 24px rgba(40, 50, 44, 0.08);
}

.stat-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  font-weight: 650;
  margin-bottom: auto;
  padding-bottom: 10px;
}

.stat-value {
  font-family: var(--font-display);
  font-size: clamp(1.35rem, 2.4vw, 1.65rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.15;
  color: var(--text);
  margin-top: auto;
  font-variant-numeric: tabular-nums;
}

/* Footer stack: reserved bar slot + sub — same height on every tile */
.stat-footer {
  margin-top: 10px;
  flex-shrink: 0;
}

.stat-bar-slot {
  height: 13px;
  display: flex;
  align-items: center;
  margin-bottom: 2px;
}

.stat-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0;
  line-height: 1.3;
  font-weight: 500;
  min-height: 1.3em;
}

/* Per-tile accent (subtle identity without icons) */
.stat-rucks  { --stat-accent: var(--accent); }
.stat-distance { --stat-accent: #6aa8c8; }
.stat-time   { --stat-accent: #a78bfa; }
.stat-elev   { --stat-accent: #5dbe8a; }
.stat-kcal   { --stat-accent: #e0a458; }
.stat-everest { --stat-accent: var(--info); }
.stat-steps  { --stat-accent: #a78bfa; }

.stat-value.pandolf { color: var(--good); }
.stat-value.everest { color: var(--info); }
.stat-value.steps { color: #a78bfa; }

[data-theme="light"] .stat-value.steps { color: #6d28d9; }

/* Everests: number + "complete" on one baseline */
.stat-everest .stat-value {
  margin-bottom: 0;
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.28em;
}

.everest-count {
  font-variant-numeric: tabular-nums;
}

/* Affix on Year / Lifetime: "0 complete" — same type/color family as the number */
.everest-affix {
  font-family: var(--font-display);
  font-size: 0.55em;
  font-weight: 700;
  letter-spacing: -0.02em;
  text-transform: none;
  color: inherit;
  line-height: 1;
}

.stat-value.everest .everest-affix {
  color: var(--info);
}

.life-tile-everest .everest-affix {
  color: var(--good);
  font-size: 0.45em;
}

.life-tile-value:has(.everest-affix) {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.2em;
}

.everest-bar {
  width: 100%;
  height: 3px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
  margin: 0;
}

.everest-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--info);
  opacity: 0.9;
  transition: width 0.45s ease;
}

/* Charts — equal-width Distance & Elevation panels */
.charts-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 22px;
  max-width: 100%;
  min-width: 0;
}

.charts-row > .panel {
  min-width: 0; /* allow grid shrink after leaving fullscreen */
  max-width: 100%;
  overflow: hidden;
}

@media (max-width: 840px) {
  .charts-row { grid-template-columns: 1fr; }
}

/* ── Lifetime career dashboard ── */
.lifetime-dash {
  margin-bottom: 12px;
}

.life-section {
  margin-bottom: 28px;
}

.lifetime-tiles {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 28px;
}

@media (max-width: 720px) {
  .lifetime-tiles { grid-template-columns: 1fr; }
}

.life-tile {
  position: relative;
  min-height: 140px;
  padding: 20px 20px 18px;
  background: var(--bg-card);
  backdrop-filter: blur(14px) saturate(1.15);
  -webkit-backdrop-filter: blur(14px) saturate(1.15);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
}

.life-tile::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--life-accent, var(--accent));
  opacity: 0.9;
}

.life-tile-rucks { --life-accent: var(--accent); }
.life-tile-marathons { --life-accent: var(--info); }
.life-tile-everest { --life-accent: var(--good); }

.life-tile-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 650;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.life-tile-value {
  font-family: var(--font-display);
  font-size: clamp(1.75rem, 3.5vw, 2.15rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  margin-top: auto;
}

.life-tile-rucks .life-tile-value { color: var(--accent); }
.life-tile-marathons .life-tile-value { color: var(--info); }
.life-tile-everest .life-tile-value { color: var(--good); }

.life-tile-sub {
  margin-top: 8px;
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
  line-height: 1.35;
}

.life-tile-bar {
  height: 3px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
  margin-top: 12px;
}

.life-tile-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--life-accent, var(--accent));
  transition: width 0.4s ease;
}

/* Personal records */
.pr-grid,
.effort-grid,
.pack-grid,
.milestone-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
}

.pr-card,
.effort-card,
.pack-card,
.milestone-card {
  background: var(--bg-card);
  backdrop-filter: blur(14px) saturate(1.15);
  -webkit-backdrop-filter: blur(14px) saturate(1.15);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 14px 12px;
  box-shadow: var(--shadow);
  min-height: 100px;
  display: flex;
  flex-direction: column;
}

.pr-card {
  cursor: pointer;
  transition: border-color .15s, transform .12s, background .15s;
}

.pr-card:hover {
  border-color: var(--border-strong);
  background: var(--bg-card-hover);
  transform: translateY(-1px);
}

.pr-card.pr-empty,
.effort-card.pr-empty {
  opacity: 0.55;
  cursor: default;
}

.pr-label,
.effort-label,
.pack-label,
.milestone-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 650;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.pr-value,
.effort-value,
.pack-value,
.milestone-value {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  margin-top: auto;
}

.pr-meta,
.effort-meta,
.pack-meta,
.milestone-meta {
  margin-top: 6px;
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.35;
}

/* HR zone stacked bar */
.hz-panel {
  margin-top: 12px;
  padding: 16px 18px 14px;
}

.hz-panel h3 {
  margin-bottom: 12px;
}

.hz-bar {
  display: flex;
  height: 14px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--border);
  margin-bottom: 12px;
}

.hz-seg {
  height: 100%;
  min-width: 0;
  transition: width .4s ease;
}

.hz-seg.z1 { background: #6b7a70; }
.hz-seg.z2 { background: #5dbe8a; }
.hz-seg.z3 { background: #c4a35a; }
.hz-seg.z4 { background: #e0a458; }
.hz-seg.z5 { background: #e06c75; }

.hz-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.hz-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.hz-swatch {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  display: inline-block;
}

.hz-swatch.z1 { background: #6b7a70; }
.hz-swatch.z2 { background: #5dbe8a; }
.hz-swatch.z3 { background: #c4a35a; }
.hz-swatch.z4 { background: #e0a458; }
.hz-swatch.z5 { background: #e06c75; }

.panel {
  background: var(--bg-card);
  backdrop-filter: blur(14px) saturate(1.15);
  -webkit-backdrop-filter: blur(14px) saturate(1.15);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}

.panel h3 {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text-secondary);
}

.chart-wrap {
  position: relative;
  height: 220px;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
}

.chart-wrap canvas {
  max-width: 100% !important;
}

/* Activity list */
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: 12px;
}

.section-head h2 {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
}

.section-head span {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.activity-section-head {
  align-items: center;
  flex-wrap: wrap;
}

.section-head-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  flex-wrap: wrap;
  min-width: 0;
}

/* Rucks | Courses feature toggle (replaces static "Rucks" heading) */
.list-mode-toggle {
  display: inline-flex;
  padding: 3px;
  border-radius: 12px;
  gap: 2px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.12);
  flex-shrink: 0;
}

.list-mode-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 0.88rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  padding: 8px 16px;
  border-radius: 9px;
  cursor: pointer;
  transition: background 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
  white-space: nowrap;
  line-height: 1.1;
}

.list-mode-btn:hover {
  color: var(--text);
}

.list-mode-btn.active {
  background: linear-gradient(180deg, rgba(196, 163, 90, 0.36), rgba(196, 163, 90, 0.16));
  color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(196, 163, 90, 0.4);
}

[data-theme="light"] .list-mode-btn.active {
  background: linear-gradient(180deg, rgba(180, 131, 20, 0.16), rgba(180, 131, 20, 0.08));
  color: #8a5a0a;
  box-shadow: inset 0 0 0 1px rgba(180, 131, 20, 0.32);
}

/* Show / focus hidden courses (Courses tab only) */
.courses-hidden-toggle {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  padding: 7px 12px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  line-height: 1.1;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.courses-hidden-toggle:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

.courses-hidden-toggle.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--border-strong);
}

.courses-hidden-toggle.hidden,
.courses-hidden-toggle[hidden] {
  display: none !important;
}

/* Course catalog cards — map-first, no activity metrics */
.course-card {
  display: grid;
  grid-template-columns: minmax(220px, 42%) 1fr;
  gap: 0;
  align-items: stretch;
  background: var(--bg-card);
  backdrop-filter: blur(14px) saturate(1.15);
  -webkit-backdrop-filter: blur(14px) saturate(1.15);
  border: 1px solid var(--border);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: var(--shadow);
  min-height: 160px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.12s, box-shadow 0.15s;
}

.course-card:hover {
  border-color: var(--border-strong);
  background: var(--bg-card-hover);
  transform: translateY(-2px);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.22);
}

.course-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.course-card.is-hidden-course {
  opacity: 0.72;
}

.course-body {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 16px 14px;
  min-width: 0;
  justify-content: center;
}

.course-body-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.course-body-top .course-name {
  margin: 0;
  min-width: 0;
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-family: var(--font-display);
  font-size: 1.12rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.course-name-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.course-hidden-badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 7px;
  flex-shrink: 0;
}

/* Course attribute tiles — aligned grid, larger for glanceability */
.course-chips {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  width: 100%;
  align-items: stretch;
}

.course-chip {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  min-width: 0;
  min-height: 3.65rem;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  box-sizing: border-box;
}

.course-chip-l {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
  line-height: 1.15;
}

.course-chip-v {
  font-family: var(--font-display);
  font-size: 1.14rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (min-width: 520px) {
  .course-chips {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 900px) {
  .course-chips {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
  }
  .course-chip {
    min-height: 4rem;
    padding: 14px 16px;
  }
  .course-chip-v {
    font-size: 1.22rem;
  }
  .course-chip-l {
    font-size: 0.72rem;
  }
}

/* Hide/unhide — icon only, quiet until hover/focus */
.course-vis-icon {
  appearance: none;
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  margin: -4px -6px 0 0;
  padding: 0;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0.35;
  transition: opacity 0.15s, color 0.15s, background 0.15s;
}

.course-card:hover .course-vis-icon,
.course-card:focus-within .course-vis-icon,
.course-vis-icon:focus-visible {
  opacity: 0.9;
}

.course-vis-icon:hover,
.course-vis-icon:focus-visible {
  color: var(--accent);
  background: var(--accent-soft);
  outline: none;
  opacity: 1;
}

.course-card.is-hidden-course .course-vis-icon {
  opacity: 0.75;
}

.course-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}

.course-meta.course-trail-src {
  font-size: 0.72rem;
  opacity: 0.85;
}

/* Course detail: elevation only (no heart-rate chrome) */
.detail-fs[data-context="course"] .chart-toggle-btn[data-chart="hr"],
.detail-fs[data-context="course"] #detailHrVal {
  display: none !important;
}

.detail-fs[data-context="course"] .chart-toggle.is-course-elev-only {
  /* Single metric — still readable as a static elev pill */
  pointer-events: none;
}

.course-thumb {
  min-height: 160px;
  border-right: 1px solid var(--border);
}

/* Legacy course-body rules merged into the richer card layout above */

@media (max-width: 720px) {
  .course-card {
    grid-template-columns: 1fr;
    min-height: 0;
  }
  .course-thumb {
    min-height: 140px;
    height: 140px;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .course-body {
    padding: 14px 16px;
  }
  .list-mode-btn {
    padding: 7px 12px;
    font-size: 0.82rem;
  }
}

/* Activity list — spacious cards for Month / Year (fewer items) */
.activity-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.activity-card {
  display: grid;
  grid-template-columns: minmax(200px, 34%) 1fr;
  grid-template-rows: auto auto;
  gap: 0;
  align-items: stretch;
  background: var(--bg-card);
  backdrop-filter: blur(14px) saturate(1.15);
  -webkit-backdrop-filter: blur(14px) saturate(1.15);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 0;
  overflow: hidden;
  cursor: pointer;
  transition: border-color .15s, background .15s, transform .12s, box-shadow .15s;
  box-shadow: var(--shadow);
  min-height: 168px;
}

.activity-card > .map-thumb {
  grid-column: 1;
  grid-row: 1;
}

.activity-card > .activity-body {
  grid-column: 2;
  grid-row: 1;
}

.activity-card > .activity-photos {
  grid-column: 1 / -1;
  grid-row: 2;
}

.activity-card:hover {
  border-color: var(--border-strong);
  background: var(--bg-card-hover);
  transform: translateY(-2px);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.22);
}

[data-theme="light"] .activity-card:hover {
  box-shadow: 0 12px 32px rgba(40, 50, 44, 0.1);
}

.map-thumb {
  width: 100%;
  min-height: 168px;
  height: 100%;
  border-radius: 0;
  overflow: hidden;
  background: var(--thumb-bg);
  border: none;
  border-right: 1px solid var(--border);
  position: relative;
}

.map-thumb .leaflet-container {
  background: var(--thumb-bg);
  font: inherit;
  width: 100% !important;
  height: 100% !important;
  min-height: 168px;
}

.activity-body {
  display: flex;
  flex-direction: column;
  padding: 18px 20px 16px;
  min-width: 0;
  gap: 14px;
}

.activity-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.activity-head-text {
  min-width: 0;
}

.activity-body h4 {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.activity-date {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-bottom: 0;
  font-weight: 500;
}

.activity-pack-pill {
  flex-shrink: 0;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 6px 12px;
  white-space: nowrap;
}

/* Labeled metric cells — easy to scan */
.activity-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px 12px;
}

.am {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.12);
  border: 1px solid var(--border);
}

[data-theme="light"] .am {
  background: rgba(255, 255, 255, 0.55);
}

.am-l {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 650;
  color: var(--text-muted);
}

.am-v {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.am-v.am-cal {
  color: var(--good);
}

.activity-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 6px;
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-top: auto;
  padding-top: 2px;
}

/* Quiet add when ruck has zero photos (no empty strip) */
.activity-photo-add-footer {
  margin-left: auto;
  width: 28px;
  height: 28px;
  opacity: 0.55;
}

.activity-photo-add-footer:hover,
.activity-photo-add-footer:focus-visible {
  opacity: 1;
}

/* Production / RUCKMAP_PHOTOS=0 — never reserve photo chrome */
body.photos-disabled .activity-photos,
body.photos-disabled .activity-photo-add,
body.photos-disabled #photoFileInput,
body.photos-disabled #photoLightbox {
  display: none !important;
}

.af-dot {
  opacity: 0.5;
  margin: 0 2px;
}

.af-type {
  text-transform: capitalize;
}

@media (max-width: 720px) {
  .activity-card {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    min-height: 0;
  }
  .activity-card > .map-thumb {
    grid-column: 1;
    grid-row: 1;
  }
  .activity-card > .activity-body {
    grid-column: 1;
    grid-row: 2;
  }
  .activity-card > .activity-photos {
    grid-column: 1;
    grid-row: 3;
  }
  .map-thumb {
    min-height: 140px;
    height: 140px;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .map-thumb .leaflet-container {
    min-height: 140px;
  }
  .activity-metrics {
    grid-template-columns: repeat(2, 1fr);
  }
  .activity-body {
    padding: 14px 16px 14px;
  }
}

@media (min-width: 900px) {
  .activity-metrics {
    grid-template-columns: repeat(6, 1fr);
  }
  .map-thumb {
    min-height: 180px;
  }
  .activity-card {
    min-height: 180px;
  }
}

.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

/* ── Toast notifications (sync status, etc.) ── */
.toast-host {
  position: fixed;
  top: max(16px, env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 500;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: min(420px, calc(100vw - 24px));
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: start;
  gap: 12px;
  width: 100%;
  padding: 14px 14px 14px 16px;
  border-radius: 16px;
  border: 1px solid var(--border-strong);
  background: var(--glass);
  backdrop-filter: var(--header-blur);
  -webkit-backdrop-filter: var(--header-blur);
  box-shadow: var(--shadow);
  color: var(--text);
  font-family: var(--font);
  opacity: 0;
  transform: translateY(-12px) scale(0.98);
  transition: opacity .22s ease, transform .22s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.toast-icon {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--accent-soft);
  color: var(--accent);
}

.toast-icon svg {
  width: 18px;
  height: 18px;
}

.toast.success .toast-icon {
  background: rgba(93, 190, 138, 0.16);
  color: var(--good);
}

.toast.error .toast-icon {
  background: rgba(224, 108, 117, 0.14);
  color: var(--danger);
}

.toast.info .toast-icon {
  background: rgba(106, 168, 200, 0.16);
  color: var(--info);
}

.toast-body {
  min-width: 0;
  padding-top: 2px;
}

.toast-title {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
  margin: 0 0 3px;
}

.toast-msg {
  margin: 0;
  font-size: 0.84rem;
  line-height: 1.4;
  color: var(--text-secondary);
  font-weight: 500;
}

.toast-meta {
  margin: 6px 0 0;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.toast-close {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  margin: -4px -4px 0 0;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.05rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color .15s, background .15s;
}

.toast-close:hover,
.toast-close:focus-visible {
  color: var(--text);
  background: var(--bg-elevated);
  outline: none;
}

/* Detail modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

@media (min-width: 720px) {
  .modal-overlay {
    align-items: center;
    padding: 24px;
  }
}

.modal {
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: 20px 20px 0 0;
  width: min(920px, 100%);
  max-height: 92vh;
  overflow: auto;
  box-shadow: var(--shadow);
  transform: translateY(20px);
  transition: transform .22s;
}

.modal-overlay.open .modal { transform: translateY(0); }

@media (min-width: 720px) {
  .modal { border-radius: 20px; }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 18px 20px 10px;
  position: sticky;
  top: 0;
  background: var(--bg-elevated);
  z-index: 2;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  font-family: var(--font-display);
  font-size: 1.25rem;
}

.modal-body { padding: 16px 20px 28px; }

/* ── Full-screen activity detail ── */
.detail-fs {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity .22s ease, transform .22s ease;
}

.detail-fs.open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.detail-fs-header {
  flex-shrink: 0;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  /* Tighter chrome — saved height transfers to the chart dock so map stays put */
  padding: 8px 16px;
  background: var(--glass);
  backdrop-filter: var(--header-blur);
  -webkit-backdrop-filter: var(--header-blur);
  border-bottom: 1px solid var(--border);
  z-index: 5;
}

.detail-fs-titles {
  min-width: 0;
}

.detail-fs-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.detail-fs-actions .btn-icon {
  /* Match header glass chrome */
  background: var(--bg-elevated);
}

.detail-fs-titles h2 {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0;
  line-height: 1.2;
}

.detail-fs-titles p {
  margin: 1px 0 0;
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
  line-height: 1.25;
}

.detail-fs-map {
  /* Course is the hero — charts sit as a compact control strip below */
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
  background: var(--thumb-bg);
  border-bottom: 1px solid var(--border);
}

/* ── Local photos on activity list cards ── */
.activity-photos {
  border-top: 1px solid var(--border);
  background: transparent;
  min-width: 0;
}

.activity-photo-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  /* Scroll without a visible scrollbar */
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* legacy Edge */
}

.activity-photo-strip::-webkit-scrollbar {
  display: none; /* Chrome, Safari */
  width: 0;
  height: 0;
}

.photo-thumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 auto;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.photo-thumbs::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

.photo-thumb {
  flex: 0 0 auto;
  width: 56px;
  height: 56px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--thumb-bg);
  padding: 0;
  cursor: pointer;
  position: relative;
  transition: transform .12s, border-color .15s, opacity .15s;
}

.photo-thumb:hover,
.photo-thumb:focus-visible {
  transform: translateY(-1px);
  border-color: var(--accent, #5dbe8a);
  outline: none;
}

.photo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}

.photo-thumb-broken {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  font-size: 0.7rem;
  color: var(--text-muted);
  padding: 4px;
  text-align: center;
}

/* Icon-only add control — no button chrome */
.activity-photo-add {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 32px;
  height: 56px;
  margin: 0;
  padding: 0;
  font: inherit;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-radius: 6px;
  box-shadow: none;
  cursor: pointer;
  line-height: 0;
  opacity: 0.72;
  transition: color .15s, opacity .15s;
  -webkit-appearance: none;
  appearance: none;
}

.activity-photo-add svg {
  width: 20px;
  height: 20px;
  display: block;
  flex-shrink: 0;
}

.activity-photo-add:hover,
.activity-photo-add:focus-visible {
  color: var(--accent, #5dbe8a);
  opacity: 1;
  background: transparent;
  outline: none;
}

.activity-photo-add:focus-visible {
  box-shadow: 0 0 0 2px var(--accent-soft, rgba(93, 190, 138, 0.35));
}

.activity-photo-add.is-busy {
  opacity: 0.35;
  pointer-events: none;
}

.activity-footer-meta {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 2px;
  min-width: 0;
}

.activity-head-end {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  flex-shrink: 0;
}

/* Full-screen photo lightbox */
.photo-lightbox {
  position: fixed;
  inset: 0;
  z-index: 400;
  display: flex;
  flex-direction: column;
  background: rgba(6, 10, 8, 0.94);
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease;
}

.photo-lightbox.open {
  opacity: 1;
  pointer-events: auto;
}

[data-theme="light"] .photo-lightbox {
  background: rgba(20, 24, 22, 0.92);
}

.photo-lightbox-chrome {
  flex-shrink: 0;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  color: #f2f5f3;
  z-index: 2;
}

.photo-lightbox-chrome .btn-icon {
  background: rgba(255, 255, 255, 0.08);
  color: #f2f5f3;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.photo-lightbox-chrome .btn-icon:hover {
  background: rgba(255, 255, 255, 0.16);
}

.photo-lb-counter {
  text-align: center;
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: rgba(242, 245, 243, 0.85);
}

.photo-lightbox-stage {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 56px 24px;
}

.photo-lightbox-stage img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.45);
  user-select: none;
  -webkit-user-drag: none;
}

.photo-lb-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  width: 48px;
  height: 64px;
  border: none;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  color: #f2f5f3;
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
  padding: 0;
}

.photo-lb-nav:hover,
.photo-lb-nav:focus-visible {
  background: rgba(255, 255, 255, 0.18);
  outline: none;
}

.photo-lb-prev { left: 10px; }
.photo-lb-next { right: 10px; }

.photo-lb-nav.hidden {
  visibility: hidden;
  pointer-events: none;
}

@media (max-width: 560px) {
  .photo-lightbox-stage {
    padding: 8px 8px 20px;
  }
  .photo-lb-nav {
    width: 40px;
    height: 52px;
    font-size: 1.6rem;
  }
  .photo-thumb {
    width: 48px;
    height: 48px;
  }
  .activity-photo-add {
    height: 48px;
  }
}

.detail-fs-map .leaflet-container {
  width: 100%;
  height: 100%;
  background: var(--thumb-bg);
  font-family: var(--font);
}

/* Map | Satellite basemap toggle — floats over detail course map by default */
.map-basemap-toggle {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 1000;
  display: inline-flex;
  padding: 3px;
  border-radius: 12px;
  gap: 2px;
  background: rgba(18, 24, 20, 0.72);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow:
    0 4px 18px rgba(0, 0, 0, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

/* Inline variant — Rucks list header (page chrome, not over map) */
.map-basemap-toggle.is-inline {
  position: static;
  top: auto;
  right: auto;
  z-index: auto;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.12);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

[data-theme="light"] .map-basemap-toggle {
  background: rgba(255, 252, 247, 0.88);
  border-color: rgba(0, 0, 0, 0.1);
  box-shadow:
    0 4px 16px rgba(0, 0, 0, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

[data-theme="light"] .map-basemap-toggle.is-inline {
  background: var(--bg-elevated);
  border-color: var(--border);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.06);
}

.map-basemap-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: rgba(241, 245, 249, 0.72);
  font-family: var(--font);
  font-size: 0.78rem;
  font-weight: 650;
  letter-spacing: 0.02em;
  padding: 7px 12px;
  border-radius: 9px;
  cursor: pointer;
  transition: background 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
  white-space: nowrap;
  line-height: 1.1;
}

.map-basemap-toggle.is-inline .map-basemap-btn {
  color: var(--text-muted);
}

[data-theme="light"] .map-basemap-btn {
  color: rgba(26, 34, 30, 0.55);
}

[data-theme="light"] .map-basemap-toggle.is-inline .map-basemap-btn {
  color: var(--text-muted);
}

.map-basemap-btn:hover {
  color: #f8fafc;
}

.map-basemap-toggle.is-inline .map-basemap-btn:hover {
  color: var(--text);
}

[data-theme="light"] .map-basemap-btn:hover {
  color: #1a221e;
}

.map-basemap-btn.active {
  background: linear-gradient(180deg, rgba(196, 163, 90, 0.42), rgba(196, 163, 90, 0.22));
  color: #f5e6c0;
  box-shadow: inset 0 0 0 1px rgba(196, 163, 90, 0.45);
}

.map-basemap-toggle.is-inline .map-basemap-btn.active {
  color: var(--accent);
}

[data-theme="light"] .map-basemap-btn.active {
  background: linear-gradient(180deg, rgba(180, 131, 20, 0.18), rgba(180, 131, 20, 0.1));
  color: #8a5a0a;
  box-shadow: inset 0 0 0 1px rgba(180, 131, 20, 0.35);
}

/* Satellite tiles: slightly warmer container so loading gaps blend */
.leaflet-container[data-basemap="satellite"] {
  background: #1a1f1c;
}

/*
 * Satellite route stroke is set in JS (amber-gold + dark rim) so it stays
 * readable over forest canopy. Street maps keep theme --map-route.
 */

.map-sat-labels {
  /* Soften hybrid labels so they don't compete with the route */
  filter: contrast(0.95) brightness(1.05);
}

@media (max-width: 720px) {
  .map-basemap-toggle:not(.is-inline) {
    top: 10px;
    right: 10px;
  }
  .map-basemap-btn {
    padding: 6px 10px;
    font-size: 0.74rem;
  }
}

.detail-fs-charts {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  /*
   * Chart dock height: +~10–12px vs prior clamp, matched by header tighten
   * so map flex area is effectively unchanged. Plot area also gains from
   * thinner toolbar/panel chrome below.
   */
  height: clamp(218px, calc(32vh + 12px), 300px);
}

.detail-chart-toolbar {
  flex-shrink: 0;
  /* [toggle] [Descent—Climb] …… [fixed scrub readouts] */
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 14px 2px;
  min-width: 0;
}

.detail-chart-toolbar .chart-toggle {
  flex: 0 0 auto;
}

/* Segmented control — elev / HR */
.chart-toggle {
  display: inline-flex;
  padding: 2px;
  border-radius: 11px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  gap: 2px;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.12);
}

.chart-toggle-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 0.8rem;
  font-weight: 650;
  letter-spacing: 0.02em;
  padding: 6px 14px;
  border-radius: 9px;
  cursor: pointer;
  transition: background .18s, color .18s, box-shadow .18s;
  white-space: nowrap;
}

.chart-toggle-btn:hover {
  color: var(--text);
}

.chart-toggle-btn.active[data-chart="elev"] {
  background: linear-gradient(180deg, rgba(93, 190, 138, 0.28), rgba(93, 190, 138, 0.14));
  color: var(--good);
  box-shadow: inset 0 0 0 1px rgba(93, 190, 138, 0.35);
}

.chart-toggle-btn.active[data-chart="hr"] {
  background: linear-gradient(180deg, rgba(224, 108, 117, 0.28), rgba(224, 108, 117, 0.14));
  color: #e06c75;
  box-shadow: inset 0 0 0 1px rgba(224, 108, 117, 0.35);
}

[data-theme="light"] .chart-toggle-btn.active[data-chart="elev"] {
  background: linear-gradient(180deg, rgba(31, 138, 85, 0.16), rgba(31, 138, 85, 0.08));
  color: var(--good);
}

[data-theme="light"] .chart-toggle-btn.active[data-chart="hr"] {
  background: linear-gradient(180deg, rgba(196, 60, 72, 0.14), rgba(196, 60, 72, 0.07));
  color: var(--danger);
}

.detail-chart-readouts {
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  flex-wrap: nowrap;
  gap: 10px 12px;
  /* Fixed strip + ml:auto pins readouts right; scrubbing won't shove legend */
  flex: 0 0 auto;
  width: 36.5rem;
  max-width: 100%;
  min-width: 0;
  margin-left: auto;
}

.detail-chart-val {
  font-family: var(--font-display);
  font-size: 1.08rem;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  text-align: right;
  white-space: nowrap;
  letter-spacing: -0.02em;
  line-height: 1.15;
  /* Reserve a stable slot; overflow clips rare long outliers */
  display: inline-block;
  overflow: hidden;
  text-overflow: clip;
  box-sizing: border-box;
  flex: 0 0 auto;
}

/* Distinct colors + fixed ch widths so digits never shove neighbors */
.detail-chart-val.is-time {
  color: var(--info); /* cool blue — elapsed time */
  width: 7.5ch; /* 0:00:00 … 9:59:59 */
}

.detail-chart-val.is-dist {
  color: var(--accent); /* gold — distance along course */
  width: 8.5ch; /* 12.34 km / 12.34 mi */
}

.detail-chart-val.is-elev {
  color: var(--good); /* green — elevation */
  width: 9ch; /* 12,345 ft / 3,999 m */
}

.detail-chart-val.is-hr {
  color: #e06c75; /* rose — heart rate */
  width: 7.5ch; /* 999 bpm */
}

.detail-chart-val.is-grade {
  /* Color set live from grade palette in JS */
  color: #c4a35a;
  width: 6ch; /* +12.3% / −12.3% */
  transition: color 0.12s ease;
}

[data-theme="light"] .detail-chart-val.is-time {
  color: #0369a1;
}

[data-theme="light"] .detail-chart-val.is-hr {
  color: var(--danger);
}

/* Grade difficulty spectrum — immediately right of elev/HR toggle */
.grade-legend {
  display: none;
  align-items: center;
  gap: 8px;
  flex: 0 1 200px;
  min-width: 120px;
  max-width: 220px;
  margin: 0;
}

/* Spectrum visible for both elev and HR chart modes */
.detail-fs-charts[data-mode="elev"] .grade-legend,
.detail-fs-charts[data-mode="hr"] .grade-legend {
  display: flex;
}

.gl-label {
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  flex-shrink: 0;
  opacity: 0.9;
  white-space: nowrap;
}

.gl-label-start {
  color: #38bdf8;
}

.gl-label-end {
  color: #e06c75;
}

[data-theme="light"] .gl-label-start {
  color: #0369a1;
}

[data-theme="light"] .gl-label-end {
  color: var(--danger);
}

.gl-spectrum-bar {
  flex: 1 1 auto;
  min-width: 48px;
  height: 5px;
  border-radius: 999px;
  /* Continuous effort spectrum: descent → flat → climb */
  background: linear-gradient(
    90deg,
    rgb(14, 116, 180) 0%,
    rgb(56, 189, 248) 12%,
    rgb(125, 211, 252) 22%,
    rgb(148, 163, 152) 38%,
    rgb(93, 190, 138) 52%,
    rgb(196, 163, 90) 66%,
    rgb(224, 164, 88) 78%,
    rgb(232, 120, 90) 88%,
    rgb(224, 88, 100) 100%
  );
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.18),
    0 0 0 1px rgba(0, 0, 0, 0.12);
  opacity: 0.92;
}

[data-theme="light"] .gl-spectrum-bar {
  opacity: 0.88;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.5),
    0 0 0 1px rgba(0, 0, 0, 0.08);
}

.detail-chart-panel {
  display: none;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  /* Minimal outer chrome so canvas owns the dock */
  padding: 0 10px 4px;
  background: transparent;
}

.detail-chart-panel.active {
  display: flex;
}

.detail-chart-wrap {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
  padding-bottom: 0;
}

/* Chart.js axis label polish inside detail dock */
.detail-chart-wrap canvas {
  max-height: 100%;
}

@media (max-width: 720px) {
  .detail-fs-charts {
    /* Same map-preserving transfer as desktop */
    height: clamp(210px, calc(34vh + 8px), 280px);
  }
  .detail-chart-toolbar {
    flex-wrap: wrap;
    padding: 5px 12px 2px;
  }
  .detail-chart-readouts {
    width: 100%;
    margin-left: 0;
    justify-content: space-between;
    gap: 6px 8px;
  }
  .chart-toggle-btn {
    padding: 6px 12px;
    font-size: 0.76rem;
  }
  /* Spectrum needs room; hide on narrow — scrub grade % still color-codes */
  .grade-legend {
    display: none !important;
  }
  .detail-chart-panel {
    padding: 0 8px 3px;
  }
}

.detail-stat {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
}

.detail-stat .l {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 600;
}

.detail-stat .v {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  margin-top: 2px;
}

.pandolf-callout {
  background: linear-gradient(135deg, rgba(93,190,138,0.1), rgba(196,163,90,0.08));
  border: 1px solid rgba(93,190,138,0.25);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 16px;
  font-size: 0.9rem;
}

.pandolf-callout strong { color: var(--good); }

/* Profile modal */
.profile-grid {
  display: grid;
  gap: 12px;
}

.profile-grid .field input {
  background: var(--bg-card);
}

/* Fullscreen */
body.fullscreen .app-header { display: none; }
body.fullscreen .main {
  width: 100%;
  max-width: none;
  padding: 12px 16px 32px;
}

/* Leaflet theme tweaks */
.leaflet-container {
  background: var(--thumb-bg);
  font-family: var(--font);
}

.leaflet-control-attribution {
  font-size: 9px !important;
  background: rgba(0,0,0,0.35) !important;
  color: #ccc !important;
}

[data-theme="light"] .leaflet-control-attribution {
  background: rgba(255,255,255,0.7) !important;
  color: #444 !important;
}

/* Loading */
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,0.2);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.hidden { display: none !important; }

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