/* ═══════════════════════════════════════════════════════════
   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: keep left/center clear so the rucker + pack stay visible */
  --login-overlay:
    linear-gradient(
      105deg,
      rgba(6, 10, 8, 0.18) 0%,
      rgba(6, 10, 8, 0.12) 38%,
      rgba(8, 12, 10, 0.55) 58%,
      rgba(8, 12, 10, 0.82) 72%,
      rgba(6, 10, 8, 0.92) 100%
    ),
    linear-gradient(
      180deg,
      rgba(6, 10, 8, 0.35) 0%,
      transparent 28%,
      transparent 72%,
      rgba(6, 10, 8, 0.55) 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(
      105deg,
      rgba(243, 241, 235, 0.08) 0%,
      rgba(243, 241, 235, 0.12) 40%,
      rgba(250, 248, 242, 0.55) 62%,
      rgba(250, 248, 242, 0.82) 100%
    ),
    linear-gradient(
      180deg,
      rgba(243, 241, 235, 0.25) 0%,
      transparent 30%,
      transparent 75%,
      rgba(243, 241, 235, 0.4) 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;
}

/* App pages: prevent lateral “float” from accidental horizontal overflow */
html:has(#appShell:not(.hidden)),
body:has(#appShell:not(.hidden)) {
  overflow-x: hidden;
  max-width: 100%;
}

/* Lock document scroll while login is visible (login is fixed viewport) */
body:has(#loginScreen:not(.hidden)) {
  overflow: hidden;
  height: 100%;
}

button, input {
  font-family: inherit;
}

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

/* ─── Registration closed modal (invite-only) ─── */
.reg-closed-overlay {
  position: fixed;
  inset: 0;
  z-index: 11000;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(6, 10, 8, 0.72);
  backdrop-filter: blur(10px) saturate(1.1);
  -webkit-backdrop-filter: blur(10px) saturate(1.1);
  animation: reg-closed-fade 0.22s ease;
}
.reg-closed-overlay.hidden {
  display: none !important;
}
@keyframes reg-closed-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}
.reg-closed-card {
  position: relative;
  width: min(400px, 100%);
  padding: 28px 24px 22px;
  border-radius: 18px;
  border: 1px solid rgba(196, 163, 90, 0.32);
  background:
    linear-gradient(155deg, rgba(196, 163, 90, 0.1) 0%, transparent 42%),
    rgba(16, 20, 18, 0.94);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
  text-align: center;
  animation: reg-closed-pop 0.28s cubic-bezier(0.2, 0.9, 0.3, 1.15);
}
@keyframes reg-closed-pop {
  from { opacity: 0; transform: translateY(10px) scale(0.97); }
  to { opacity: 1; transform: none; }
}
.reg-closed-x {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  font-size: 1rem;
  cursor: pointer;
}
.reg-closed-x:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}
.reg-closed-icon {
  width: 52px;
  height: 52px;
  margin: 0 auto 12px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--border-strong);
}
.reg-closed-kicker {
  margin: 0 0 6px;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}
.reg-closed-title {
  margin: 0 0 10px;
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1.25;
}
.reg-closed-body {
  margin: 0 0 10px;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--text-secondary);
}
.reg-closed-body strong {
  color: var(--text);
  font-weight: 700;
}
.reg-closed-note {
  margin: 0 0 16px;
  font-size: 0.75rem;
  line-height: 1.4;
  color: var(--text-muted);
}
.reg-closed-cta {
  display: inline-flex;
  width: 100%;
  justify-content: center;
  text-decoration: none;
  margin-bottom: 8px;
}
.reg-closed-back {
  width: 100%;
}
[data-theme="light"] .reg-closed-card {
  background:
    linear-gradient(155deg, rgba(139, 105, 20, 0.08) 0%, transparent 42%),
    rgba(255, 252, 247, 0.96);
  box-shadow: 0 20px 48px rgba(40, 50, 44, 0.18);
}
[data-theme="light"] .reg-closed-overlay {
  background: rgba(40, 45, 42, 0.45);
}

/* ─── Boot splash (hard-refresh / session check) ───
   Covers login form until tryResume finishes — trail bg + brand + bar. */
.boot-splash {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: grid;
  place-items: center;
  background: #0a0e0c;
  transition: opacity 0.4s ease, visibility 0.4s ease;
}
.boot-splash.is-done {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.boot-splash-bg {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(
      105deg,
      rgba(6, 10, 8, 0.35) 0%,
      rgba(6, 10, 8, 0.45) 45%,
      rgba(6, 10, 8, 0.72) 100%
    ),
    url("/assets/login-bg.jpg") 28% 42% / cover no-repeat;
  filter: saturate(1.05) contrast(1.03);
  transform: scale(1.02);
}
.boot-splash-scrim {
  position: absolute;
  inset: 0;
  background: radial-gradient(
    ellipse 70% 55% at 50% 48%,
    rgba(8, 12, 10, 0.15) 0%,
    rgba(8, 12, 10, 0.55) 100%
  );
  pointer-events: none;
}
.boot-splash-inner {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 24px;
  text-align: center;
}
.boot-splash-mark {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid rgba(196, 163, 90, 0.35);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.45);
}
.boot-splash-mark img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.boot-splash-title {
  margin: 0;
  font-family: var(--font-display), system-ui, sans-serif;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #eef2ec;
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.45);
}
.boot-splash-title span {
  color: #c4a35a;
}
.boot-progress {
  width: min(180px, 48vw);
  height: 3px;
  margin-top: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.25);
}
.boot-progress-bar {
  height: 100%;
  width: 40%;
  border-radius: inherit;
  background: linear-gradient(90deg, #8b6914, #c4a35a, #d4b86a);
  animation: boot-progress-slide 1.15s ease-in-out infinite;
}
@keyframes boot-progress-slide {
  0%   { transform: translateX(-120%); }
  100% { transform: translateX(320%); }
}
@media (prefers-reduced-motion: reduce) {
  .boot-progress-bar {
    width: 100%;
    animation: none;
    opacity: 0.7;
  }
  .boot-splash {
    transition: none;
  }
}

/* ─── Login ───
   Fixed viewport (no page scroll). Photo is position:fixed so Create account
   never reflows / "resizes" the rucker. Panel uses the right rail only. */
.login-screen {
  position: fixed;
  inset: 0;
  z-index: 10;
  height: 100vh;
  height: 100dvh;
  width: 100%;
  overflow: hidden;
  background: #0a0e0c;
}

.login-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    var(--login-overlay),
    url("/assets/login-bg.jpg") 26% 42% / cover no-repeat;
  filter: saturate(1.05) contrast(1.03);
  pointer-events: none;
}

.login-stage {
  position: relative;
  z-index: 1;
  height: 100%;
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(380px, 480px);
  align-items: stretch;
}

.login-hero {
  min-width: 0;
}

.login-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 0;
  height: 100%;
  padding: clamp(16px, 3vh, 36px) clamp(16px, 2.5vw, 36px) clamp(16px, 3vh, 36px) 12px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(6, 10, 8, 0.25) 18%,
    rgba(6, 10, 8, 0.55) 100%
  );
  overflow: hidden;
}

[data-theme="light"] .login-panel {
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(250, 248, 242, 0.28) 20%,
    rgba(250, 248, 242, 0.62) 100%
  );
}

.login-card {
  width: 100%;
  max-height: 100%;
  overflow: hidden;
  background: rgba(12, 16, 14, 0.78);
  backdrop-filter: blur(16px) saturate(1.12);
  -webkit-backdrop-filter: blur(16px) saturate(1.12);
  border: 1px solid rgba(196, 163, 90, 0.3);
  border-radius: 18px;
  padding: clamp(16px, 2.4vh, 28px) clamp(16px, 2vw, 26px) clamp(12px, 2vh, 20px);
  box-shadow:
    0 18px 48px rgba(0, 0, 0, 0.42),
    inset 0 1px 0 rgba(196, 163, 90, 0.1);
  background-image: linear-gradient(
    145deg,
    rgba(196, 163, 90, 0.08) 0%,
    transparent 40%
  );
}

[data-theme="light"] .login-card {
  background: rgba(255, 252, 247, 0.9);
  border-color: rgba(139, 105, 20, 0.22);
  box-shadow: 0 16px 40px rgba(40, 50, 44, 0.12);
  background-image: linear-gradient(
    145deg,
    rgba(139, 105, 20, 0.07) 0%,
    transparent 40%
  );
}

.login-screen .brand {
  margin-bottom: 6px;
}

.login-screen .brand-mark {
  width: 44px;
  height: 44px;
}

.login-screen .brand-mark img {
  width: 44px;
  height: 44px;
}

.login-screen .login-tagline {
  margin: 0 0 10px;
  font-size: 0.86rem;
  line-height: 1.4;
  color: var(--text-secondary);
}

.login-chips {
  list-style: none;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 0 0 12px;
  padding: 0;
}

.login-chip {
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid rgba(196, 163, 90, 0.22);
  background: rgba(0, 0, 0, 0.22);
}

[data-theme="light"] .login-chip {
  background: rgba(255, 255, 255, 0.55);
  border-color: rgba(139, 105, 20, 0.16);
}

.login-chip strong {
  display: block;
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.01em;
  margin-bottom: 1px;
}

.login-chip span {
  display: block;
  font-size: 0.7rem;
  line-height: 1.3;
  color: var(--text-muted);
}

.login-screen .login-error {
  margin-bottom: 8px;
}

.login-screen .auth-tabs {
  margin-bottom: 10px;
}

.login-screen .field {
  margin-bottom: 10px;
}

.login-screen .field input {
  padding: 10px 12px;
  font-size: 0.95rem;
}

.login-screen .field label {
  margin-bottom: 4px;
  font-size: 0.72rem;
}

/* Password rules: reserve one line so register mode doesn't reflow */
.login-stable-hint.field-hint {
  display: block;
  margin: 4px 0 0;
  min-height: 1.35em;
  font-size: 0.72rem;
  opacity: 0;
  visibility: hidden;
}
.login-stable-hint.field-hint.show {
  display: block;
  opacity: 1;
  visibility: visible;
}

/* Display name always occupies space (collapsed on Sign in) */
.login-field-slot.is-collapsed {
  visibility: hidden;
  pointer-events: none;
}
.login-field-slot.is-collapsed input {
  opacity: 0;
}

.login-screen .btn-primary {
  width: 100%;
  padding: 11px 16px;
  margin-top: 2px;
}

.login-screen .login-sso-note {
  margin-top: 10px;
  padding: 8px 10px;
  font-size: 0.72rem;
  line-height: 1.4;
}

.login-actions-row {
  margin-top: 14px;
}

.login-actions-row .btn {
  width: 100%;
  padding: 9px 14px;
  font-size: 0.88rem;
}

.login-demo-kicker {
  margin: 0 0 6px;
  text-align: center;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}

.login-demo-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px 16px;
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #0c100e;
  background: linear-gradient(135deg, #e0c56a, var(--accent) 55%, #b8923a);
  border: 1px solid rgba(255, 230, 160, 0.35);
  box-shadow:
    0 0 0 1px rgba(196, 163, 90, 0.25),
    0 8px 22px rgba(196, 163, 90, 0.32);
}
.login-demo-btn:hover:not(:disabled) {
  filter: brightness(1.07);
  box-shadow:
    0 0 0 1px rgba(196, 163, 90, 0.4),
    0 10px 26px rgba(196, 163, 90, 0.42);
}
.login-demo-ico {
  flex-shrink: 0;
}
[data-theme="light"] .login-demo-btn {
  color: #1a1408;
  background: linear-gradient(135deg, #d4b24a, #b88920);
  box-shadow: 0 8px 20px rgba(139, 105, 20, 0.28);
}

.login-screen .login-footer {
  margin-top: 8px;
  font-size: 0.7rem;
}

.login-offline {
  margin-top: 8px;
}

/* Desktop / tablet short windows only (not the phone bottom-sheet layout) */
@media (max-height: 780px) and (min-width: 721px) {
  .login-chips { margin-bottom: 8px; }
  .login-chip span { display: none; }
  .login-screen .login-sso-note { display: none; }
  .login-screen .login-footer { display: none; }
  .login-screen .field { margin-bottom: 8px; }
}

@media (max-height: 640px) and (min-width: 721px) {
  .login-chips { display: none; }
  .login-screen .login-tagline { display: none; }
}

@media (min-width: 1200px) {
  .login-stage {
    grid-template-columns: minmax(0, 1fr) minmax(420px, 520px);
  }
  .login-bg {
    background-position: 22% 40%;
  }
}

@media (max-width: 900px) and (min-width: 721px) {
  .login-stage {
    grid-template-columns: minmax(0, 1fr) minmax(340px, 42vw);
  }
}

/* ─── Mobile login: full-bleed rucker + bottom glass sheet ───
   Desktop (>720px) is unchanged. Phone: photo owns the upper
   viewport; form is a compact safe-area sheet so Sign in is never
   clipped. */
@media (max-width: 720px) {
  .login-screen {
    /* iOS Safari dynamic toolbars */
    height: 100vh;
    height: 100dvh;
    min-height: -webkit-fill-available;
  }

  .login-bg {
    /* Show head + pack/shoulders in the open upper band (not forehead-only) */
    background:
      linear-gradient(
        180deg,
        rgba(6, 10, 8, 0.42) 0%,
        rgba(6, 10, 8, 0.08) 18%,
        rgba(6, 10, 8, 0.05) 38%,
        rgba(6, 10, 8, 0.35) 58%,
        rgba(6, 10, 8, 0.78) 78%,
        rgba(6, 10, 8, 0.94) 100%
      ),
      url("/assets/login-bg.jpg") 42% 22% / cover no-repeat;
  }

  [data-theme="light"] .login-bg {
    background:
      linear-gradient(
        180deg,
        rgba(243, 241, 235, 0.35) 0%,
        rgba(243, 241, 235, 0.06) 20%,
        rgba(250, 248, 242, 0.08) 40%,
        rgba(250, 248, 242, 0.45) 62%,
        rgba(250, 248, 242, 0.88) 82%,
        rgba(250, 248, 242, 0.96) 100%
      ),
      url("/assets/login-bg.jpg") 42% 22% / cover no-repeat;
  }

  .login-stage {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    grid-template-columns: none;
    grid-template-rows: none;
    height: 100%;
    min-height: 0;
  }

  /* Full-bleed photo via .login-bg; hero flexes open above the sheet
     (≥~38% when card is capped at 62dvh) and can shrink for keyboard. */
  .login-hero {
    flex: 1 1 auto;
    min-height: 0;
    pointer-events: none;
  }

  .login-panel {
    flex: 0 1 auto;
    height: auto;
    max-height: min(62dvh, 100%);
    min-height: 0;
    justify-content: flex-end;
    padding:
      0
      max(14px, env(safe-area-inset-left, 0px))
      max(10px, env(safe-area-inset-bottom, 0px))
      max(14px, env(safe-area-inset-right, 0px));
    background: transparent;
    overflow: hidden;
  }

  [data-theme="light"] .login-panel {
    background: transparent;
  }

  .login-card {
    max-height: min(62dvh, 100%);
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    border-radius: 20px 20px 16px 16px;
    padding: 16px 16px 14px;
    box-shadow:
      0 -8px 40px rgba(0, 0, 0, 0.35),
      0 18px 48px rgba(0, 0, 0, 0.42),
      inset 0 1px 0 rgba(196, 163, 90, 0.12);
  }

  [data-theme="light"] .login-card {
    box-shadow:
      0 -6px 28px rgba(40, 50, 44, 0.1),
      0 16px 40px rgba(40, 50, 44, 0.12);
  }

  /* Compact chrome — keep brand, tabs, fields, primary CTA */
  .login-screen .brand {
    margin-bottom: 4px;
  }
  .login-screen .brand-mark,
  .login-screen .brand-mark img {
    width: 40px;
    height: 40px;
  }
  .login-screen .login-tagline {
    margin: 0 0 8px;
    font-size: 0.8rem;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
  }
  .login-chips {
    display: none;
  }
  .login-screen .login-sso-note {
    display: none;
  }
  .login-screen .login-footer {
    display: none;
  }
  .login-screen .auth-tabs {
    margin-bottom: 8px;
  }
  .login-screen .auth-tab {
    min-height: 44px;
    padding: 10px 10px;
    font-size: 0.9rem;
  }
  .login-screen .field {
    margin-bottom: 8px;
  }
  .login-screen .field input {
    padding: 12px 14px;
    font-size: 16px; /* iOS: avoid focus zoom */
    min-height: 44px;
  }
  .login-screen .btn-primary {
    padding: 13px 16px;
    min-height: 48px;
    margin-top: 4px;
    font-size: 1rem;
  }
  .login-actions-row {
    margin-top: 8px;
  }
  .login-actions-row .btn {
    min-height: 44px;
    padding: 10px 14px;
  }
  .login-demo-btn {
    min-height: 48px;
    font-size: 1.02rem;
    padding: 12px 16px;
  }

  /* Free vertical space on Sign in: no reserved display-name / password-hint */
  .login-field-slot.is-collapsed {
    display: none;
  }
  .login-stable-hint.field-hint:not(.show) {
    display: none;
    min-height: 0;
    margin: 0;
  }
  .login-stable-hint.field-hint.show {
    min-height: 0;
    margin-top: 4px;
  }

  .login-offline {
    margin-top: 6px;
  }
}

/* Very short phones / landscape: prioritize form over photo band */
@media (max-width: 720px) and (max-height: 560px) {
  .login-panel {
    max-height: 88dvh;
  }
  .login-card {
    max-height: 88dvh;
    border-radius: 16px;
    padding: 12px 14px 12px;
  }
  .login-screen .login-tagline {
    display: none;
  }
  .login-actions-row {
    margin-top: 6px;
  }
}

/* Tall phones: slightly shorter sheet → more rucker stage */
@media (max-width: 720px) and (min-height: 780px) {
  .login-panel {
    max-height: min(54dvh, 100%);
  }
  .login-card {
    max-height: min(54dvh, 100%);
  }
}


.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;
}


/* Standalone auth tabs */
.auth-tabs {
  display: flex;
  gap: 6px;
  margin: 0 0 14px;
  padding: 4px;
  background: rgba(0, 0, 0, 0.18);
  border-radius: 12px;
  border: 1px solid var(--border);
}
.auth-tab {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font-weight: 650;
  font-size: 0.88rem;
  padding: 8px 10px;
  border-radius: 9px;
  cursor: pointer;
}
.auth-tab.active {
  background: var(--bg-card);
  color: var(--text);
  box-shadow: var(--shadow);
}
.auth-tab.is-invite-only {
  position: relative;
}
.auth-tab.is-invite-only::after {
  content: "";
  position: absolute;
  top: 6px;
  right: 8px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.85;
  box-shadow: 0 0 0 2px rgba(196, 163, 90, 0.2);
}
.field-hint {
  display: none;
  margin: 6px 0 0;
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.35;
}
.field-hint.show { display: block; }
.field .opt { font-weight: 500; color: var(--text-muted); text-transform: none; letter-spacing: 0; }
.hp-field {
  position: absolute;
  left: -10000px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
}
.help-ikea .ikea-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.help-ikea .ikea-steps li {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.help-ikea .ikea-n {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-family: var(--font-display);
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid var(--border-strong);
}
.help-ikea .ikea-steps p {
  margin: 4px 0 0;
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.4;
}
.help-ikea code {
  font-size: 0.85em;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(0,0,0,0.15);
}

.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;
  max-width: 100%;
  overflow-x: hidden;
}

/* 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);
  max-width: 100%;
  min-width: 0;
}

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

.header-left .brand {
  min-width: 0;
  flex: 1 1 auto;
}

.header-left .brand-text {
  min-width: 0;
  overflow: hidden;
}

.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;
  display: block;
}

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

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

/* Desktop: more-wrap is transparent so secondary actions sit in the flat header row */
.header-more {
  display: contents;
}

.header-more-btn {
  display: none;
}

.header-more-panel {
  display: contents;
}

.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%);
  max-width: 100%;
  min-width: 0;
  margin: 0 auto;
  padding: 20px 16px 48px;
  box-sizing: border-box;
}

/* 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;
}

/* ─── Mobile app shell (desktop header/list chrome unchanged above 720px) ─── */
@media (max-width: 720px) {
  .app-header {
    gap: 8px;
    padding: 10px 12px;
    padding-left: max(12px, env(safe-area-inset-left, 0px));
    padding-right: max(12px, env(safe-area-inset-right, 0px));
    padding-top: max(10px, env(safe-area-inset-top, 0px));
  }

  .header-left {
    gap: 8px;
  }

  .header-left .brand-header {
    gap: 8px;
  }

  .header-left .brand-mark,
  .brand-header .brand-mark {
    width: 36px;
    height: 36px;
    border-radius: 10px;
  }

  .header-left .brand h1,
  .header-left .brand-title {
    font-size: 1.02rem;
    line-height: 1.15;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .profile-link {
    font-size: 0.78rem;
    max-width: min(42vw, 140px);
  }

  .header-actions {
    gap: 4px;
  }

  .header-actions .btn-icon {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
  }

  /* Overflow menu: units / photos / logout (fullscreen hidden on phone) */
  .header-more {
    display: block;
    position: relative;
    flex-shrink: 0;
  }

  .header-more-btn {
    display: inline-flex;
  }

  .header-more-panel {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 40;
    min-width: 200px;
    max-width: min(280px, calc(100vw - 24px));
    padding: 10px;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-strong);
    border-radius: 14px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(16px) saturate(1.15);
    -webkit-backdrop-filter: blur(16px) saturate(1.15);
  }

  .header-more.is-open .header-more-panel {
    display: flex;
  }

  .header-more-panel .units-toggle,
  .header-more-panel .photos-toggle {
    width: 100%;
    height: 44px;
    justify-content: stretch;
  }

  .header-more-panel .units-opt,
  .header-more-panel .photos-opt {
    flex: 1;
    justify-content: center;
    font-size: 0.78rem;
    padding: 0 8px;
  }

  .header-more-panel .btn-icon {
    width: 100%;
    height: 44px;
    justify-content: flex-start;
    gap: 10px;
    padding: 0 12px;
    border-radius: 10px;
  }

  /* Labeled logout row in the sheet */
  .header-more-panel #logoutBtn::after {
    content: "Log out";
    font-size: 0.88rem;
    font-weight: 650;
  }

  .header-more-panel .header-fs-btn,
  .header-more-panel #fsBtn {
    display: none !important;
  }

  .offline-pill {
    font-size: 0.68rem;
    padding: 5px 8px;
    max-width: 72px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .main {
    padding: 14px 12px max(40px, env(safe-area-inset-bottom, 0px));
    padding-left: max(12px, env(safe-area-inset-left, 0px));
    padding-right: max(12px, env(safe-area-inset-right, 0px));
  }

  .period-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    margin-bottom: 14px;
  }

  .period-bar .tabs {
    display: flex;
    width: 100%;
  }

  .period-bar .tab {
    flex: 1;
    padding: 10px 8px;
    font-size: 0.84rem;
    text-align: center;
  }

  .period-nav {
    justify-content: space-between;
    width: 100%;
  }

  .period-label {
    min-width: 0;
    flex: 1;
    font-size: 0.98rem;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 16px;
  }

  .stat-card {
    height: auto;
    min-height: 118px;
    max-height: none;
    padding: 12px 12px 10px;
  }

  .activity-section-head {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    margin-bottom: 12px;
  }

  .list-mode-cluster {
    width: 100%;
    display: flex;
    align-items: stretch;
    gap: 14px;
  }

  .list-mode-toggle {
    flex: 1 1 auto;
    width: auto;
    min-width: 0;
    display: flex;
  }

  .list-mode-btn {
    flex: 1;
    text-align: center;
    padding: 10px 8px;
    font-size: 0.84rem;
  }

  .list-mode-new-route {
    width: 40px;
    height: 40px;
    min-height: 40px;
    align-self: center;
  }

  .section-head-right {
    width: 100%;
    justify-content: space-between;
    gap: 8px;
  }

  .map-basemap-toggle.is-inline {
    flex: 1 1 auto;
    min-width: 0;
    max-width: 100%;
  }

  .map-basemap-toggle.is-inline .map-basemap-btn {
    flex: 1;
    min-width: 0;
    padding: 7px 8px;
    font-size: 0.78rem;
  }

  #activityCountLabel {
    font-size: 0.78rem;
    white-space: nowrap;
    flex-shrink: 0;
  }

  .demo-banner {
    font-size: 0.82rem;
    padding: 10px 12px;
    gap: 8px;
    max-width: 100%;
  }

  .activity-list,
  .course-card,
  .charts-row,
  .stats-grid {
    max-width: 100%;
    min-width: 0;
  }
}

/* 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;
}

/* Lifetime: 4 hero metrics + 2 wide feature tiles (rucks, time) */
.stats-grid-lifetime {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.stats-grid-lifetime .stat-card-hero {
  height: auto;
  min-height: 168px;
  max-height: none;
  padding: 18px 18px 16px;
}

.stats-grid-lifetime .stat-card-hero .stat-value {
  font-size: clamp(1.7rem, 3.2vw, 2.35rem);
  letter-spacing: -0.035em;
}

.stats-grid-lifetime .stat-card-sm {
  height: 118px;
  min-height: 118px;
  max-height: 118px;
  padding: 14px 14px 12px;
}

.stats-grid-lifetime .stat-card-sm .stat-value {
  font-size: clamp(1.15rem, 2vw, 1.4rem);
}

.stats-grid-lifetime .stat-card-sm,
.stats-grid-lifetime .stat-card-wide {
  grid-column: span 2;
}

.stats-grid-lifetime .stat-card-wide {
  height: auto;
  min-height: 168px;
  max-height: none;
  padding: 18px 18px 16px;
}

.stats-grid-lifetime .stat-card-wide .stat-value {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.85rem, 3.4vw, 2.55rem);
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 840px) {
  .stats-grid-lifetime {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .stats-grid-lifetime .stat-card-sm,
  .stats-grid-lifetime .stat-card-wide {
    grid-column: span 1;
  }
  .stats-grid-lifetime .stat-card-wide {
    min-height: 148px;
    padding: 14px 14px 12px;
  }
  .stats-grid-lifetime .stat-card-wide .stat-value {
    font-size: clamp(1.45rem, 4.5vw, 1.9rem);
  }
}

/* Phone: keep 2-up grid — 2×2 hero tiles, then Rucks | Time on the 3rd row.
   (Do not collapse to a single column; that wastes vertical space.) */
@media (max-width: 480px) {
  .stats-grid-lifetime {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  .stats-grid-lifetime .stat-card-hero {
    min-height: 132px;
    padding: 12px 12px 10px;
  }
  .stats-grid-lifetime .stat-card-hero .stat-value {
    font-size: clamp(1.25rem, 6.5vw, 1.65rem);
  }
  .stats-grid-lifetime .stat-card-sm,
  .stats-grid-lifetime .stat-card-wide {
    grid-column: span 1;
    height: auto;
    min-height: 96px;
    max-height: none;
    padding: 12px 12px 10px;
  }
  .stats-grid-lifetime .stat-card-sm .stat-value {
    font-size: clamp(1.05rem, 5vw, 1.25rem);
  }
  .stats-grid-lifetime .stat-card-wide {
    min-height: 132px;
  }
  .stats-grid-lifetime .stat-card-wide .stat-value {
    font-size: clamp(1.35rem, 6.2vw, 1.7rem);
  }
}

/* Transparent on Month/Year and desktop. On phone Lifetime it becomes the
   first screen: tabs, stat cards, and the two odometer panes. */
.life-fold {
  display: contents;
}

/* Phone Lifetime: keep the empty month row collapsed, and give the cards
   and odometer panes their padding back. Portrait stretches this block to
   the visible window so Personal records starts on the next screen. */
@media (max-width: 720px) {
  .period-bar.is-lifetime {
    gap: 0;
    margin-bottom: 12px;
  }
  .period-bar.is-lifetime .period-nav {
    display: none;
  }
  body.is-lifetime .main {
    padding-top: 10px;
    padding-bottom: 20px;
  }
  body.is-lifetime .stats-grid.stats-grid-lifetime {
    gap: 8px;
    margin-bottom: 12px;
  }
  body.is-lifetime .stats-grid-lifetime .stat-card-hero,
  body.is-lifetime .stats-grid-lifetime .stat-card-wide {
    height: auto;
    min-height: 0;
    max-height: none;
    padding: 12px 12px 10px;
  }
  body.is-lifetime .stats-grid-lifetime .stat-label {
    margin-bottom: auto;
    padding-bottom: 6px;
  }
  body.is-lifetime .stats-grid-lifetime .stat-value {
    margin-top: auto;
  }
  body.is-lifetime .stats-grid-lifetime .stat-footer {
    margin-top: 6px;
  }
  body.is-lifetime .stats-grid-lifetime .stat-bar-slot {
    display: none;
  }
  body.is-lifetime .stats-grid-lifetime .stat-card-hero .stat-value,
  body.is-lifetime .stats-grid-lifetime .stat-card-wide .stat-value {
    font-size: clamp(1.28rem, 5.6vw, 1.65rem);
  }
  body.is-lifetime .lifetime-dash {
    margin-bottom: 0;
  }
  body.is-lifetime .lifetime-tiles {
    gap: 10px;
    margin-bottom: 0;
  }
  body.is-lifetime .life-tile {
    padding: 12px 10px 11px;
  }
  body.is-lifetime .life-tile-head {
    margin-bottom: 8px;
  }
  body.is-lifetime .odo {
    margin: 2px 0;
    gap: 4px;
  }
  body.is-lifetime .life-tile-remain {
    margin-top: 8px;
  }
  body.is-lifetime .life-tile-sub {
    margin-top: 6px;
  }
}

@media (max-width: 720px) and (orientation: portrait) {
  body.is-lifetime .life-fold {
    display: flex;
    flex-direction: column;
    /* Header row is the 40px controls plus 10px bottom padding and a 1px
       border. padding-top already includes the notch. JS replaces this
       with the measured visual viewport once the header has laid out. */
    min-height: var(
      --life-fold-h,
      calc(100dvh - max(10px, env(safe-area-inset-top, 0px)) - 53px)
    );
    box-sizing: border-box;
  }
  body.is-lifetime .life-fold > .period-bar {
    flex: 0 0 auto;
  }
  body.is-lifetime .life-fold > .stats-grid {
    flex: 1.2 1 auto;
    min-height: 0;
    grid-template-rows: repeat(3, minmax(0, 1fr));
  }
  body.is-lifetime .life-fold > #lifetimeTiles {
    flex: 1 1 auto;
    min-height: 0;
    grid-template-rows: minmax(0, 1fr);
  }
  body.is-lifetime .life-fold .stat-card-hero,
  body.is-lifetime .life-fold .stat-card-wide {
    height: 100%;
  }
  body.is-lifetime .life-fold .life-tile {
    height: 100%;
    justify-content: space-between;
  }
  body.is-lifetime .life-fold .odo {
    flex: 1 1 auto;
    align-items: center;
    min-height: 0;
  }
}

.stat-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0;
  /* Fixed height so Month/Year (Everests bar) tiles 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-marathon { --stat-accent: #5eb8ff; }
.stat-steps  { --stat-accent: #a78bfa; }

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

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

/* Lifetime hero neon values */
.stat-value.neon-dist {
  color: #ff2d55;
  text-shadow:
    0 0 8px rgba(255, 45, 85, 0.75),
    0 0 18px rgba(255, 45, 85, 0.4);
}
.stat-value.neon-elev {
  color: #3dbbff;
  text-shadow:
    0 0 8px rgba(61, 187, 255, 0.8),
    0 0 18px rgba(61, 187, 255, 0.4);
}
.stat-value.neon-kcal {
  color: #39ff8a;
  text-shadow:
    0 0 8px rgba(57, 255, 138, 0.8),
    0 0 18px rgba(57, 255, 138, 0.4);
}
.stat-value.neon-rucks {
  color: #f0c14a;
  text-shadow:
    0 0 8px rgba(240, 193, 74, 0.8),
    0 0 18px rgba(196, 163, 90, 0.45);
}
.stat-value.neon-time {
  color: #e879f9;
  text-shadow:
    0 0 8px rgba(232, 121, 249, 0.8),
    0 0 18px rgba(192, 80, 220, 0.4);
}

[data-theme="light"] .stat-value.neon-dist {
  color: #e6002e;
  text-shadow: 0 0 6px rgba(255, 40, 70, 0.45);
}
[data-theme="light"] .stat-value.neon-elev {
  color: #0088e6;
  text-shadow: 0 0 6px rgba(0, 150, 255, 0.4);
}
[data-theme="light"] .stat-value.neon-kcal {
  color: #00b84a;
  text-shadow: 0 0 6px rgba(0, 200, 90, 0.4);
}
[data-theme="light"] .stat-value.neon-rucks {
  color: #8b6914;
  text-shadow: 0 0 6px rgba(196, 163, 90, 0.45);
}
[data-theme="light"] .stat-value.neon-time {
  color: #a21caf;
  text-shadow: 0 0 6px rgba(192, 38, 211, 0.35);
}

/* Everests: number + "complete" on one baseline */
.stat-everest .stat-value,
.stat-marathon .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;
}
.marathon-bar-fill {
  background: #5eb8ff;
}

/* 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;
}

/* Marathons + Everesting — completed count + % to next */
.lifetime-tiles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 28px;
}
.period-tiles {
  margin-top: -8px;
}

.life-tile {
  position: relative;
  min-height: 0;
  padding: 16px 18px 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: 16px;
  /* Clip the accent to the corner radius, same as the stat cards. */
  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-marathons { --life-accent: #5eb8ff; }
.life-tile-everest { --life-accent: #5dbe8a; }

.life-tile-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

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

.life-tile-kicker {
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--life-accent, var(--text-secondary));
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Classic brass odometer — three digit wheels and a progress dial */
.odo {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 6px;
  margin: 2px 0 4px;
}

.odo-dial {
  flex: 1 1 0;
  min-width: 0;
  max-width: 78px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.odo-dial-progress {
  margin-left: 6px;
}

.odo-bezel {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 50%;
  padding: 3px;
  background:
    radial-gradient(circle at 32% 28%, #f4e4bc 0%, #d4b56a 28%, #a6843c 58%, #5c4318 100%);
  box-shadow:
    0 8px 16px rgba(0, 0, 0, 0.32),
    inset 0 1px 0 rgba(255, 255, 255, 0.65),
    inset 0 -2px 3px rgba(60, 40, 8, 0.45);
}

.odo-glass,
.odo-face {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 38%, #24302a 0%, #101612 62%, #070a08 100%);
  box-shadow:
    inset 0 10px 14px rgba(0, 0, 0, 0.55),
    inset 0 -8px 10px rgba(255, 255, 255, 0.04),
    inset 0 0 0 1px rgba(0, 0, 0, 0.65);
}

.odo-glass {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.odo-glass::after,
.odo-face::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(
    155deg,
    rgba(255, 255, 255, 0.28) 0%,
    rgba(255, 255, 255, 0.05) 32%,
    transparent 48%
  );
  pointer-events: none;
}

.odo-num,
.odo-ghost {
  font-family: var(--font-display);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  letter-spacing: -0.04em;
}

.odo-num {
  position: relative;
  z-index: 1;
  font-size: clamp(1.05rem, 2.5vw, 1.65rem);
  color: #f7f0e0;
  text-shadow:
    0 1px 0 rgba(255, 255, 255, 0.28),
    0 6px 10px rgba(0, 0, 0, 0.45);
}

.odo-ghost {
  position: absolute;
  left: 0;
  right: 0;
  text-align: center;
  font-size: clamp(0.62rem, 1.4vw, 0.85rem);
  color: rgba(247, 240, 224, 0.22);
  z-index: 1;
}

.odo-prev { top: 11%; }
.odo-next { bottom: 11%; }

.odo-caption {
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.odo-svg {
  display: block;
  width: 100%;
  height: 100%;
}

.odo-ring-track,
.odo-ring-value {
  fill: none;
  stroke-width: 3.25;
  stroke-linecap: round;
}

.odo-ring-track {
  stroke: rgba(247, 240, 224, 0.14);
}

.odo-ring-value {
  stroke: var(--life-accent, #c4a35a);
  filter: drop-shadow(0 0 2px color-mix(in srgb, var(--life-accent, #c4a35a) 70%, transparent));
}

.odo-needle {
  stroke: #f4e4bc;
  stroke-width: 1.4;
  stroke-linecap: round;
}

.odo-hub {
  fill: #f4e4bc;
  stroke: #6e5424;
  stroke-width: 0.6;
}

.odo-progress-pct {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 18%;
  z-index: 1;
  text-align: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(0.58rem, 1.5vw, 0.78rem);
  letter-spacing: -0.03em;
  color: #f7f0e0;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.65);
}

[data-theme="light"] .odo-bezel {
  background:
    radial-gradient(circle at 32% 28%, #fff8ea 0%, #e4cf9a 30%, #b8924e 62%, #7a5e2c 100%);
}

[data-theme="light"] .odo-glass,
[data-theme="light"] .odo-face {
  background:
    radial-gradient(circle at 50% 38%, #fffdf8 0%, #f3ead6 68%, #e6dcc4 100%);
  box-shadow:
    inset 0 8px 12px rgba(90, 70, 30, 0.12),
    inset 0 0 0 1px rgba(90, 70, 30, 0.18);
}

[data-theme="light"] .odo-num,
[data-theme="light"] .odo-progress-pct {
  color: #2c2416;
  text-shadow: none;
}

[data-theme="light"] .odo-ghost {
  color: rgba(44, 36, 22, 0.22);
}

[data-theme="light"] .odo-ring-track {
  stroke: rgba(44, 36, 22, 0.14);
}

[data-theme="light"] .odo-needle,
[data-theme="light"] .odo-hub {
  stroke: #6e5424;
}

[data-theme="light"] .odo-needle { stroke: #3d3424; }
[data-theme="light"] .odo-hub { fill: #3d3424; }

@media (max-width: 720px) {
  .odo { gap: 3px; }
  .odo-dial { gap: 4px; max-width: none; }
  .odo-dial-progress { margin-left: 2px; }
  .odo-bezel { padding: 2px; }
  .odo-caption { font-size: 0.48rem; letter-spacing: 0.08em; }
  .odo-prev { top: 8%; }
  .odo-next { bottom: 8%; }
}

@media (prefers-reduced-motion: reduce) {
  .odo-ring-value { transition: none; }
}

/* Summit / distance ledger — topographic waypoint stones */
.life-blocks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: stretch;
  margin-top: 2px;
}

.life-block {
  position: relative;
  appearance: none;
  -webkit-appearance: none;
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  padding: 0;
  border: 0;
  border-radius: 16px;
  cursor: default;
  font: inherit;
  color: #f4f7fa;
  overflow: hidden;
  isolation: isolate;
  flex: 0 0 auto;
  transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
}

.life-block:hover,
.life-block:focus,
.life-block:focus-visible {
  transform: translateY(-3px);
  outline: none;
  z-index: 3;
}

.life-block.is-done {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.34),
    inset 0 -12px 18px rgba(0, 0, 0, 0.2),
    0 8px 18px color-mix(in srgb, var(--life-accent, #5eb8ff) 28%, transparent);
}

.life-block.is-done:hover,
.life-block.is-done:focus,
.life-block.is-done:focus-visible,
.life-block.is-done.is-peek {
  filter: brightness(1.08);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.42),
    inset 0 -12px 18px rgba(0, 0, 0, 0.16),
    0 14px 24px color-mix(in srgb, var(--life-accent, #5eb8ff) 40%, transparent);
}

.life-tile-marathons .life-block.is-done {
  background:
    linear-gradient(165deg,
      hsl(calc(198 + var(--i, 1) * 6), 86%, calc(64% - var(--i, 1) * 2.4%)) 0%,
      hsl(calc(216 + var(--i, 1) * 5), 80%, calc(42% - var(--i, 1) * 1.8%)) 100%);
}

.life-tile-everest .life-block.is-done {
  background:
    linear-gradient(165deg,
      hsl(calc(148 + var(--i, 1) * 10), 58%, calc(58% - var(--i, 1) * 2%)) 0%,
      hsl(calc(162 + var(--i, 1) * 8), 48%, calc(34% - var(--i, 1) * 1.2%)) 100%);
}

/* Contour lines — each stone reads like a cairn on a topo map */
.life-block.is-done::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: repeating-radial-gradient(
    circle at 50% 130%,
    rgba(255, 255, 255, 0) 0 9px,
    rgba(255, 255, 255, 0.12) 10px 11px
  );
  opacity: 0.5;
  pointer-events: none;
  z-index: 0;
}

.life-block-n {
  position: relative;
  z-index: 1;
  font-family: var(--font-display);
  font-size: 1.28rem;
  font-weight: 750;
  letter-spacing: -0.04em;
  line-height: 1;
  text-shadow: 0 1px 8px rgba(8, 14, 18, 0.35);
  font-variant-numeric: tabular-nums;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

/* Grouped stones (5, 25, 125, …) and running totals with more digits */
.life-block.is-bundle {
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 0.42),
    inset 0 1px 0 rgba(255, 255, 255, 0.34),
    inset 0 -12px 18px rgba(0, 0, 0, 0.2),
    0 8px 18px color-mix(in srgb, var(--life-accent, #5eb8ff) 28%, transparent);
}

.life-block.is-count-2 .life-block-n { font-size: 1.08rem; }
.life-block.is-count-3 { width: 66px; }
.life-block.is-count-3 .life-block-n { font-size: 0.92rem; }
.life-block.is-count-4,
.life-block.is-count-5 { width: 76px; }
.life-block.is-count-4 .life-block-n,
.life-block.is-count-5 .life-block-n {
  font-size: 0.72rem;
  letter-spacing: -0.06em;
}

.life-block-when {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  opacity: 0;
  transform: translateY(7px);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.life-block-mo {
  font-family: var(--font-display);
  font-size: 0.66rem;
  font-weight: 750;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  line-height: 1;
  text-shadow: 0 1px 6px rgba(8, 14, 18, 0.4);
}

.life-block-yr {
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  text-shadow: 0 1px 6px rgba(8, 14, 18, 0.4);
  opacity: 0.94;
}

.life-block.is-done:hover .life-block-n,
.life-block.is-done:focus .life-block-n,
.life-block.is-done:focus-visible .life-block-n,
.life-block.is-done.is-peek .life-block-n {
  opacity: 0;
  transform: scale(0.82);
}

.life-block.is-done:hover .life-block-when,
.life-block.is-done:focus .life-block-when,
.life-block.is-done:focus-visible .life-block-when,
.life-block.is-done.is-peek .life-block-when {
  opacity: 1;
  transform: translateY(0);
}

.life-block.is-now {
  width: 70px;
  color: var(--text);
  background:
    linear-gradient(180deg,
      color-mix(in srgb, var(--life-accent) 12%, var(--bg-elevated)),
      var(--bg-elevated));
  border: 1px dashed color-mix(in srgb, var(--life-accent) 50%, var(--border));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.life-block-fill {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--fill, 0%);
  background:
    linear-gradient(180deg,
      color-mix(in srgb, var(--life-accent) 78%, #fff) 0%,
      var(--life-accent) 100%);
  opacity: 0.9;
  z-index: 0;
  pointer-events: none;
  transition: height 0.55s ease;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.42);
}

.life-block.is-now .life-block-fill::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.22), transparent);
  background-size: 180% 100%;
  animation: life-block-sheen 3.6s ease-in-out infinite;
}

@keyframes life-block-sheen {
  0% { background-position: 120% 0; }
  100% { background-position: -80% 0; }
}

.life-block-now-stack {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

.life-block.is-now .life-block-n {
  font-size: 1.05rem;
  color: var(--text);
  text-shadow: none;
}

.life-block-pct {
  position: relative;
  z-index: 1;
  font-family: var(--font-display);
  font-size: 0.98rem;
  font-weight: 750;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
  padding: 3px 7px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--bg-elevated) 72%, transparent);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.08);
}

.life-block.is-now.is-count-2 .life-block-pct,
.life-block.is-now.is-count-3 .life-block-pct,
.life-block.is-now.is-count-4 .life-block-pct,
.life-block.is-now.is-count-5 .life-block-pct {
  font-size: 0.68rem;
  padding: 1px 5px;
}

@media (prefers-reduced-motion: reduce) {
  .life-block,
  .life-block-n,
  .life-block-when,
  .life-block-fill {
    transition: none;
  }
  .life-block.is-now .life-block-fill::after {
    animation: none;
  }
}

.life-blocks.is-cozy .life-block {
  width: 50px;
  height: 50px;
  border-radius: 14px;
}
.life-blocks.is-cozy .life-block.is-now { width: 64px; }
.life-blocks.is-cozy .life-block-n { font-size: 1.12rem; }
.life-blocks.is-cozy .life-block-mo { font-size: 0.58rem; }
.life-blocks.is-cozy .life-block-yr { font-size: 0.7rem; }

.life-blocks.is-compact .life-block {
  width: 42px;
  height: 42px;
  border-radius: 12px;
}
.life-blocks.is-compact .life-block.is-now { width: 56px; }
.life-blocks.is-compact .life-block-n { font-size: 0.98rem; }
.life-blocks.is-compact .life-block-pct { font-size: 0.8rem; padding: 2px 5px; }
.life-blocks.is-compact .life-block-mo { font-size: 0.5rem; letter-spacing: 0.06em; }
.life-blocks.is-compact .life-block-yr { font-size: 0.62rem; }

[data-theme="light"] .life-block.is-done {
  color: #fff;
}
[data-theme="light"] .life-block-n,
[data-theme="light"] .life-block-mo,
[data-theme="light"] .life-block-yr {
  text-shadow: 0 1px 6px rgba(20, 30, 24, 0.28);
}
[data-theme="light"] .life-block.is-now {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.7), var(--bg-elevated));
}
[data-theme="light"] .life-block-pct {
  background: color-mix(in srgb, var(--bg-elevated) 82%, transparent);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.65);
}

.life-tile-split {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px 14px;
  min-width: 0;
}

.life-done-n {
  font-family: var(--font-display);
  font-size: clamp(2.1rem, 5vw, 2.85rem);
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 0.95;
  color: var(--life-accent, var(--text));
  font-variant-numeric: tabular-nums;
}

.life-done-l,
.life-next-l {
  margin-top: 4px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.life-next {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
}

.life-ring {
  display: block;
  transform: rotate(-90deg);
}

.life-ring-track {
  fill: none;
  stroke: var(--border);
  stroke-width: 8;
}

.life-ring-progress {
  fill: none;
  stroke: var(--life-accent, var(--accent));
  stroke-width: 8;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.5s ease;
  filter: drop-shadow(0 0 7px color-mix(in srgb, var(--life-accent) 55%, transparent));
}

.life-ring-pct {
  fill: var(--text);
  font-size: 18px;
  font-weight: 750;
  font-family: var(--font-display), system-ui, sans-serif;
  letter-spacing: -0.04em;
  transform: rotate(90deg);
  transform-origin: 50px 50px;
}

.life-next-l {
  margin-top: 2px;
}

.life-tile-bar {
  height: 6px;
  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));
  box-shadow: 0 0 8px color-mix(in srgb, var(--life-accent) 45%, transparent);
  transition: width 0.45s ease;
}

.life-tile-remain {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  margin-top: 10px;
  font-size: 0.82rem;
  line-height: 1.3;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.life-remain-now strong,
.life-remain-left strong {
  font-weight: 700;
  color: var(--text);
}

.life-remain-left {
  text-align: right;
}

.life-remain-left strong {
  color: var(--life-accent, var(--text));
}

.life-tile-sub {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-top: 8px;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
  line-height: 1.3;
}

.life-lifetime {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.02rem;
  letter-spacing: -0.03em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.life-lifetime strong {
  font-weight: 700;
  color: var(--life-accent, var(--text));
}

.life-lifetime-each {
  flex: none;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-muted);
}

@media (max-width: 720px) {
  .lifetime-tiles {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 18px;
  }
  .life-tile {
    padding: 12px 10px 10px;
    border-radius: 14px;
  }
  .life-tile-label {
    font-size: 0.6rem;
    margin-bottom: 0;
  }
  .life-tile-split {
    gap: 6px 4px;
  }
  .life-done-n {
    font-size: clamp(1.55rem, 7vw, 2rem);
  }
  .life-done-l,
  .life-next-l {
    font-size: 0.58rem;
  }
  .life-ring {
    width: 68px;
    height: 68px;
  }
  .life-ring-pct {
    font-size: 16px;
  }
  .life-tile-bar {
    margin-top: 8px;
    height: 5px;
  }
  .life-tile-sub {
    margin-top: 6px;
    font-size: 0.66rem;
  }
  .life-lifetime {
    font-size: 0.86rem;
  }
  .life-lifetime-each {
    font-size: 0.62rem;
  }
  .life-tile-remain {
    margin-top: 8px;
    font-size: 0.7rem;
    gap: 6px;
  }
  .life-tile-head {
    margin-bottom: 8px;
  }
  .life-tile-kicker {
    font-size: 0.66rem;
  }
  .life-blocks {
    gap: 6px;
  }
  .life-block {
    width: 48px;
    height: 48px;
    border-radius: 13px;
  }
  .life-block.is-now {
    width: 60px;
  }
  .life-block-n {
    font-size: 1.08rem;
  }
  .life-block-pct {
    font-size: 0.82rem;
    padding: 2px 6px;
  }
  .life-block-mo { font-size: 0.56rem; }
  .life-block-yr { font-size: 0.68rem; }
}

/* 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 | Routes | Build + compact New action */
.list-mode-cluster {
  display: inline-flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  min-width: 0;
  flex-shrink: 0;
}

.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;
}

/* “+” action — solid icon-only CTA, clearly not a tab */
.list-mode-new-route {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 10px;
  border: 1px solid transparent;
  background: var(--accent);
  color: #0f1412;
  font-family: var(--font);
  cursor: pointer;
  line-height: 1;
  flex-shrink: 0;
  transition: filter 0.15s ease, transform 0.12s ease, box-shadow 0.15s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.22), 0 4px 12px rgba(196, 163, 90, 0.22);
}
.list-mode-new-route:hover {
  filter: brightness(1.08);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.25), 0 6px 16px rgba(196, 163, 90, 0.32);
  color: #0a0e0c;
}
.list-mode-new-route:active {
  transform: scale(0.97);
  filter: brightness(0.98);
}
.list-mode-new-route-ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1;
}
[data-theme="light"] .list-mode-new-route {
  background: #b48314;
  color: #fffdf6;
  box-shadow: 0 1px 2px rgba(90, 60, 10, 0.18), 0 4px 12px rgba(180, 131, 20, 0.22);
}
[data-theme="light"] .list-mode-new-route:hover {
  filter: brightness(1.05);
  color: #fff;
}

.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 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;
  flex: 1 1 auto;
  text-align: center;
  min-width: 0;
}

.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;
}

/* Peak altitude — slight neon lift so Trailhead vs Max elev is scannable */
.course-chip.is-max-elev {
  border-color: rgba(93, 190, 138, 0.35);
  background: linear-gradient(
    155deg,
    rgba(93, 190, 138, 0.1) 0%,
    var(--bg-elevated) 55%
  );
}
.course-chip.is-max-elev .course-chip-v {
  color: var(--good);
}
[data-theme="light"] .course-chip.is-max-elev {
  border-color: rgba(31, 138, 85, 0.28);
  background: linear-gradient(
    155deg,
    rgba(31, 138, 85, 0.08) 0%,
    var(--bg-elevated) 55%
  );
}

@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 {
  position: relative;
  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: 200px;
}

.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: 200px;
  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: 200px;
}

.activity-body {
  display: flex;
  flex-direction: column;
  padding: 18px 18px 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;
}

.kind-chip {
  appearance: none;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 100%;
  padding: 4px 10px 4px 4px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--accent-soft);
  color: var(--accent);
  cursor: pointer;
  font-family: var(--font);
  line-height: 1;
  white-space: nowrap;
}
.kind-chip-ico {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  background: rgba(196, 163, 90, 0.18);
  flex-shrink: 0;
}
.kind-chip-ico svg {
  width: 15px;
  height: 15px;
}
.kind-chip-word {
  font-family: var(--font-display);
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.kind-chip-meta {
  font-size: 0.74rem;
  font-weight: 650;
  color: var(--text-muted);
  padding-left: 7px;
  margin-left: 1px;
  border-left: 1px solid var(--border);
}
.kind-chip.is-hike {
  color: #7eb8d4;
  background: rgba(106, 168, 200, 0.12);
  border-color: rgba(106, 168, 200, 0.32);
}
.kind-chip.is-hike .kind-chip-ico {
  background: rgba(106, 168, 200, 0.2);
}
.kind-chip.is-run {
  color: #e2b06a;
  background: rgba(224, 164, 88, 0.12);
  border-color: rgba(224, 164, 88, 0.34);
}
.kind-chip.is-run .kind-chip-ico {
  background: rgba(224, 164, 88, 0.2);
}
.kind-chip:hover {
  filter: brightness(1.08);
}
.activity-card.is-ruck::after,
.activity-card.is-hike::after,
.activity-card.is-run::after {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  z-index: 2;
}
.activity-card.is-ruck::after { background: var(--accent); }
.activity-card.is-hike::after { background: #6aa8c8; }
.activity-card.is-run::after { background: #e0a458; }
.activity-card.is-hike {
  background: linear-gradient(90deg, rgba(106, 168, 200, 0.06), transparent 42%), var(--bg-card);
}
.activity-card.is-run {
  background: linear-gradient(90deg, rgba(224, 164, 88, 0.07), transparent 42%), var(--bg-card);
}
.effort-filter {
  display: inline-flex;
  padding: 3px;
  border-radius: 10px;
  gap: 2px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
}
.effort-filter-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  padding: 5px 9px;
  border-radius: 8px;
  cursor: pointer;
}
.effort-filter-btn.active {
  color: var(--text);
  background: var(--bg-card);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.18);
}
.kind-editor {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  min-width: 0;
}
.kind-seg {
  display: inline-flex;
  padding: 2px;
  gap: 2px;
  border-radius: 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
}
.kind-seg-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 5px 8px;
  border-radius: 8px;
  cursor: pointer;
}
.kind-seg-btn.active {
  color: var(--text);
  background: var(--bg-card);
}
.kind-seg-btn[data-kind="hike"].active { color: #6aa8c8; }
.kind-seg-btn[data-kind="run"].active { color: #e0a458; }
.kind-pack-row {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--accent-soft);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 4px 8px 4px 10px;
}
.kind-pack-row.hidden { display: none; }
.kind-cancel {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 4px 6px;
  cursor: pointer;
  border-radius: 8px;
}
.kind-cancel:hover {
  color: var(--text);
  background: var(--bg-elevated);
}

/* Labeled metric cells — distance, time, gain, calories, pace */
.activity-metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px 10px;
}

.am {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  min-width: 0;
  min-height: 3.4rem;
  padding: 10px 10px;
  border-radius: 12px;
  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.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 650;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.15;
}

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

/* Elevation gain — neon blue */
.am-v.am-elev-gain {
  color: #3dbbff;
  text-shadow:
    0 0 6px rgba(61, 187, 255, 0.8),
    0 0 14px rgba(61, 187, 255, 0.45);
}

[data-theme="light"] .am-v.am-elev-gain {
  color: #0088e6;
  text-shadow:
    0 0 5px rgba(0, 150, 255, 0.55),
    0 0 12px rgba(0, 150, 255, 0.35);
}

/* Calories — neon green */
.am-v.am-cal {
  color: #39ff8a;
  text-shadow:
    0 0 6px rgba(57, 255, 138, 0.8),
    0 0 14px rgba(57, 255, 138, 0.45);
}

[data-theme="light"] .am-v.am-cal {
  color: #00b84a;
  text-shadow:
    0 0 5px rgba(0, 200, 90, 0.55),
    0 0 12px rgba(0, 200, 90, 0.35);
}

/* Peak heart rate — neon red for scanability */
.am-v.am-max-hr {
  color: #ff2d55;
  text-shadow:
    0 0 6px rgba(255, 45, 85, 0.75),
    0 0 14px rgba(255, 45, 85, 0.45);
}

[data-theme="light"] .am-v.am-max-hr {
  color: #e6002e;
  text-shadow:
    0 0 5px rgba(255, 40, 70, 0.55),
    0 0 12px rgba(255, 40, 70, 0.35);
}

/* Photo-add only — grade/steps/type legend removed for metric tiles */
.activity-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 4px 6px;
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-top: auto;
  padding-top: 2px;
}

.activity-footer-photos {
  min-height: 0;
}

/* 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;
}

@media (max-width: 720px) {
  .activity-card {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    min-height: 0;
    max-width: 100%;
  }
  .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-body {
    padding: 14px 14px 12px;
    gap: 12px;
  }
  .activity-body h4 {
    font-size: 1.08rem;
  }
  /* 2-column metric tiles — readable; no 5-col squeeze / overflow */
  .activity-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  .am {
    min-height: 3.1rem;
    padding: 8px 7px;
  }
  .am-l {
    font-size: 0.62rem;
    letter-spacing: 0.04em;
  }
  .am-v {
    font-size: 0.98rem;
  }
  .activity-body {
    padding: 14px 14px 14px;
  }
}

@media (min-width: 900px) {
  .activity-metrics {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 12px 11px;
  }
  .map-thumb {
    min-height: 220px;
  }
  .map-thumb .leaflet-container {
    min-height: 220px;
  }
  .activity-card {
    min-height: 220px;
  }
  .am {
    min-height: 3.75rem;
    padding: 12px 12px;
  }
  .am-l {
    font-size: 0.78rem;
  }
  .am-v {
    font-size: 1.28rem;
  }
}

.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;
  overflow-x: hidden;
  max-width: 100vw;
}

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

.detail-fs-header {
  flex-shrink: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  /* Tighter chrome — saved height transfers to the chart dock so map stays put */
  padding: 8px 16px;
  padding-top: max(8px, env(safe-area-inset-top, 0px));
  padding-left: max(12px, env(safe-area-inset-left, 0px));
  padding-right: max(12px, env(safe-area-inset-right, 0px));
  background: var(--glass);
  backdrop-filter: var(--header-blur);
  -webkit-backdrop-filter: var(--header-blur);
  border-bottom: 1px solid var(--border);
  z-index: 5;
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
}

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

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

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

/* Desktop: overflow wrap is transparent so Plan/GPX/… sit in the flat row */
.detail-more {
  display: contents;
}
.detail-more-btn {
  display: none;
}
.detail-more-panel {
  display: contents;
}

.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;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.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-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;
}

/* Grade spectrum only on elevation chart (activity + course detail) */
.detail-fs-charts[data-mode="elev"] .grade-legend {
  display: flex;
}
.detail-fs-charts[data-mode="hr"] .grade-legend {
  display: none;
}
/* Crosshair cursor while scrubbing elev on activity / routes detail */
.detail-fs-charts[data-mode="elev"] .detail-chart-wrap {
  cursor: crosshair;
}
.detail-chart-wrap canvas {
  touch-action: none;
}

/* HR zone chips — only on heart-rate chart */
.hr-zone-legend {
  display: none;
  align-items: center;
  gap: 5px;
  flex: 0 1 auto;
  min-width: 0;
}
.detail-fs-charts[data-mode="hr"] .hr-zone-legend {
  display: flex;
}
.hzl-item {
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  padding: 3px 7px;
  border-radius: 6px;
  line-height: 1;
  border: 1px solid transparent;
}
.hzl-item.z1 {
  color: #94a3b8;
  background: rgba(100, 116, 139, 0.2);
  border-color: rgba(100, 116, 139, 0.35);
}
.hzl-item.z2 {
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.15);
  border-color: rgba(56, 189, 248, 0.35);
}
.hzl-item.z3 {
  color: #5dbe8a;
  background: rgba(93, 190, 138, 0.16);
  border-color: rgba(93, 190, 138, 0.35);
}
.hzl-item.z4 {
  color: #e0a458;
  background: rgba(224, 164, 88, 0.16);
  border-color: rgba(224, 164, 88, 0.4);
}
.hzl-item.z5 {
  color: #e06c75;
  background: rgba(224, 88, 100, 0.16);
  border-color: rgba(224, 88, 100, 0.4);
}
[data-theme="light"] .hzl-item.z1 {
  color: #475569;
}
[data-theme="light"] .hzl-item.z2 {
  color: #0284c7;
}
[data-theme="light"] .hzl-item.z3 {
  color: #15803d;
}
[data-theme="light"] .hzl-item.z4 {
  color: #b45309;
}
[data-theme="light"] .hzl-item.z5 {
  color: #be123c;
}

/* HR empty state (no stream in this import) */
.detail-chart-wrap {
  position: relative;
}
.detail-hr-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 16px 20px;
  gap: 6px;
  background:
    radial-gradient(ellipse 70% 60% at 50% 40%, rgba(224, 108, 117, 0.08), transparent 70%),
    var(--bg-card);
  z-index: 2;
}
.detail-hr-empty.hidden {
  display: none !important;
}
.dhe-icon {
  color: #e06c75;
  opacity: 0.85;
  margin-bottom: 4px;
}
.dhe-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text);
  margin: 0;
}
.dhe-body {
  font-size: 0.78rem;
  line-height: 1.4;
  color: var(--text-muted);
  max-width: 28em;
  margin: 0;
}
.dhe-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 10px;
}
.dhe-chip {
  font-size: 0.78rem;
  font-weight: 650;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid rgba(224, 108, 117, 0.28);
  background: rgba(224, 108, 117, 0.1);
  color: var(--text);
}
.dhe-chip em {
  font-style: normal;
  color: #e06c75;
  font-weight: 800;
  margin-right: 4px;
}
.dhe-chip.muted {
  color: var(--text-muted);
  border-color: var(--border);
  background: var(--bg-elevated);
}

.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);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .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);
}

.profile-modal {
  max-width: 520px;
}

.profile-backup {
  margin-top: 8px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.profile-backup .btn + .btn,
.profile-backup .field + .btn {
  margin-top: 8px;
}

.year-review {
  margin: 8px 0 18px;
}

.year-review-body {
  display: grid;
  gap: 10px;
}

.year-review-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.year-review-stats div {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-card);
}

.year-review-stats span {
  display: block;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.year-review-stats strong {
  font-size: 1.05rem;
}

.year-review-mix,
.year-review-empty,
.year-review-notes {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.88rem;
}

.year-review-notes p {
  margin: 0 0 4px;
}

.year-review-bars {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 4px;
  align-items: end;
  height: 72px;
}

.yr-bar {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  height: 100%;
  gap: 4px;
}

.yr-bar span {
  display: block;
  width: 100%;
  border-radius: 4px 4px 2px 2px;
  background: var(--accent, #c4a35a);
  min-height: 0;
}

.yr-bar em {
  font-style: normal;
  font-size: 0.65rem;
  color: var(--text-muted);
}

.compare-splits {
  margin-top: 8px;
}

.compare-splits-title {
  margin: 8px 0 4px;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

@media (max-width: 720px) {
  .year-review-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.profile-section-title {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  margin: 0 0 6px;
  color: var(--text);
}

.profile-backup-copy {
  font-size: 0.8rem;
  line-height: 1.45;
  color: var(--text-secondary);
  margin: 0 0 12px;
}

.profile-backup-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin: 8px 0 0;
  min-height: 1.2em;
}

/* 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;
}


/* ── Import modal (consumer upload UX) ── */
.import-modal { max-width: 520px; width: min(520px, 94vw); }
.import-lead {
  margin: 0 0 14px;
  color: var(--text-muted);
  font-size: 0.92rem;
  line-height: 1.45;
}
.import-drop {
  border: 1.5px dashed var(--border-strong);
  border-radius: 16px;
  padding: 28px 18px 22px;
  text-align: center;
  background: rgba(0,0,0,0.12);
  cursor: pointer;
  transition: border-color .15s, background .15s, transform .12s;
}
.import-drop:hover, .import-drop.is-dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.import-drop.is-busy { opacity: 0.55; pointer-events: none; }
.import-drop-icon { color: var(--accent); margin-bottom: 8px; }
.import-drop-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.1rem;
  margin: 0 0 4px;
}
.import-drop-sub {
  margin: 0 0 14px;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.import-browse-btn { min-width: 140px; }
.import-progress { margin-top: 16px; }
.import-progress-bar {
  height: 6px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
}
.import-progress-fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), #5dbe8a);
  transition: width .25s ease;
}
.import-progress-label {
  margin: 8px 0 0;
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: center;
}
.import-result { margin-top: 16px; }
.import-result-ok, .import-result-empty, .import-result-err {
  border-radius: 12px;
  padding: 14px 14px 12px;
  border: 1px solid var(--border);
  background: rgba(0,0,0,0.14);
}
.import-result-ok { border-color: rgba(93,190,138,0.45); }
.import-result-err { border-color: rgba(224,108,117,0.5); }
.import-result-ok p, .import-result-empty p, .import-result-err p {
  margin: 6px 0 0;
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.4;
}
.import-result-names {
  margin: 10px 0 0;
  padding-left: 1.1rem;
  font-size: 0.9rem;
  color: var(--text);
}
.import-result-meta { font-size: 0.82rem !important; opacity: 0.85; }
.import-result-ok .btn { margin-top: 12px; width: 100%; }
.import-help-details {
  margin-top: 16px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.12);
  overflow: hidden;
}
.import-help-details summary {
  cursor: pointer;
  list-style: none;
  font-weight: 650;
  font-size: 0.88rem;
  color: var(--text-secondary);
  padding: 12px 14px;
  user-select: none;
  transition: color 0.15s, background 0.15s;
}
.import-help-details summary::-webkit-details-marker {
  display: none;
}
.import-help-details summary::after {
  content: "＋";
  float: right;
  font-weight: 700;
  color: var(--text-muted);
  font-size: 0.85rem;
}
.import-help-details[open] summary {
  color: var(--text);
  border-bottom: 1px solid var(--border);
  background: rgba(196, 163, 90, 0.06);
}
.import-help-details[open] summary::after {
  content: "−";
  color: var(--accent);
}
.import-help-details summary:hover {
  color: var(--text);
}

.import-help-panel {
  padding: 12px 14px 14px;
}

.import-help-intro {
  margin: 0 0 12px;
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--text-muted);
}
.import-help-intro a {
  font-weight: 650;
}

.import-help-paths {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.import-help-card {
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  padding: 12px 12px 11px;
  min-width: 0;
}

.import-help-card-head {
  margin-bottom: 8px;
}
.import-help-card-head h3 {
  margin: 6px 0 0;
  font-family: var(--font-display);
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
}

.import-help-badge {
  display: inline-block;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 3px 7px;
  border-radius: 999px;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--border-strong);
}
.import-help-badge.is-bulk {
  color: var(--info);
  background: rgba(106, 168, 200, 0.14);
  border-color: rgba(106, 168, 200, 0.35);
}

.import-help-flow {
  margin: 0 0 8px;
  font-size: 0.8rem;
  line-height: 1.45;
  color: var(--text-secondary);
  font-weight: 550;
}
.import-help-flow em {
  font-style: normal;
  font-weight: 750;
  color: var(--text);
  background: rgba(196, 163, 90, 0.12);
  padding: 1px 5px;
  border-radius: 4px;
}
.import-help-arrow {
  display: inline-block;
  margin: 0 2px;
  color: var(--text-muted);
  opacity: 0.75;
  font-weight: 600;
}

.import-help-note {
  margin: 0;
  font-size: 0.75rem;
  line-height: 1.4;
  color: var(--text-muted);
}
.import-help-note code {
  font-size: 0.9em;
  font-weight: 650;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.18);
  color: var(--text-secondary);
}

[data-theme="light"] .import-help-details {
  background: rgba(255, 255, 255, 0.45);
}
[data-theme="light"] .import-help-card {
  background: rgba(255, 255, 255, 0.75);
}
[data-theme="light"] .import-help-note code {
  background: rgba(0, 0, 0, 0.06);
}

@media (max-width: 520px) {
  .import-help-paths {
    grid-template-columns: 1fr;
  }
}



/* Inline pack / title edit on activity cards */
.activity-pack-pill {
  cursor: pointer;
}
.activity-pack-pill:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.activity-pack-pill.is-hike:hover {
  border-color: #6aa8c8;
  background: rgba(106, 168, 200, 0.22);
}
.activity-pack-pill.is-run:hover {
  border-color: #e0a458;
  background: rgba(224, 164, 88, 0.24);
}
.activity-name {
  cursor: text;
  border-radius: 6px;
}
.activity-name:hover {
  outline: 1px dashed var(--border-strong);
  outline-offset: 2px;
}
.pack-editor {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--accent-soft);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 4px 8px 4px 10px;
}
.pack-editor-input {
  width: 4.2rem;
  border: 0;
  background: transparent;
  color: var(--text);
  font-weight: 700;
  font-family: var(--font-display);
  font-size: 0.9rem;
  outline: none;
}
.pack-editor-unit {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
}
.pack-editor-save {
  border: 0;
  background: var(--accent);
  color: #0c100e;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  font-weight: 800;
  cursor: pointer;
  line-height: 1;
}
.name-editor {
  width: 100%;
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 4px 8px;
  background: var(--bg-card);
  color: var(--text);
  outline: none;
}

/* ─── Site admin console ─── */
.profile-admin-link {
  margin-top: 12px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.admin-modal {
  max-width: min(1100px, calc(100vw - 24px));
  width: 100%;
  max-height: min(92vh, 900px);
  display: flex;
  flex-direction: column;
}
.admin-modal .modal-header {
  flex-shrink: 0;
}
.admin-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.admin-modal-body {
  overflow: auto;
  min-height: 0;
  flex: 1;
}
.admin-lead {
  margin: 0 0 14px;
  font-size: 0.9rem;
  color: var(--text-secondary);
}
.admin-server-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}
.admin-tile {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
}
.admin-tile-l {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.admin-tile-v {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.admin-tile-sub {
  margin-top: 6px;
  font-size: 0.72rem;
  line-height: 1.35;
  color: var(--text-muted);
}
.admin-tile-hosting {
  border-color: rgba(196, 163, 90, 0.4);
  background: linear-gradient(
    165deg,
    rgba(196, 163, 90, 0.12),
    var(--bg-elevated)
  );
  grid-column: 1 / -1;
  max-width: 100%;
}
.admin-tile-hosting .admin-tile-v {
  color: var(--accent, #c4a35a);
  font-size: 1.35rem;
}
.admin-tile-muted {
  opacity: 0.85;
  border-style: dashed;
}
.admin-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg-card);
}
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
  min-width: 820px;
}
.admin-table th,
.admin-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.admin-table th {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 700;
  background: rgba(0, 0, 0, 0.12);
  position: sticky;
  top: 0;
  z-index: 1;
}
.admin-table tbody tr:last-child td {
  border-bottom: none;
}
.admin-table tbody tr:hover td {
  background: var(--bg-card-hover);
}
.admin-user-cell {
  min-width: 160px;
}
.admin-user-name {
  font-weight: 700;
  color: var(--text);
}
.admin-user-email {
  font-size: 0.78rem;
  color: var(--text-muted);
  word-break: break-all;
}
.admin-badge {
  display: inline-block;
  margin-left: 6px;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid var(--border-strong);
  vertical-align: middle;
}
.admin-num {
  font-variant-numeric: tabular-nums;
  font-weight: 650;
  white-space: nowrap;
}
.admin-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 24px !important;
}
.admin-footnote {
  margin: 14px 0 0;
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.4;
}
.admin-loc-sub {
  display: block;
  font-size: 0.72rem;
  color: var(--text-muted);
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
@media (max-width: 720px) {
  .admin-modal {
    max-width: 100%;
    max-height: 100dvh;
    border-radius: 0;
    margin: 0;
  }
  .admin-modal-body {
    padding-bottom: max(16px, env(safe-area-inset-bottom, 0px));
  }
}

/* Admin sections + status badges */
.admin-section {
  margin-top: 18px;
}
.admin-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.admin-section-head h3 {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  margin: 0;
}
.admin-section-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
}
.admin-badge-admin {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--border-strong);
}
.admin-badge-active {
  background: rgba(93, 190, 138, 0.14);
  color: var(--good);
  border-color: rgba(93, 190, 138, 0.35);
}
.admin-badge-inactive {
  background: rgba(224, 108, 117, 0.12);
  color: var(--danger);
  border-color: rgba(224, 108, 117, 0.3);
}
.admin-badge-pending_invite {
  background: rgba(224, 164, 88, 0.14);
  color: var(--warn);
  border-color: rgba(224, 164, 88, 0.4);
}
.admin-row-pending td {
  background: rgba(224, 164, 88, 0.04);
}
.admin-table-pending {
  min-width: 0;
}

/* ── Custom route builder ───────────────────────────────────────── */
.route-builder-fs {
  z-index: 90;
}
.route-builder-fs.open {
  display: flex;
}
.route-builder-header {
  padding-right: 12px;
}
@media (max-width: 420px) {
  .route-builder-header .detail-fs-titles p {
    display: none;
  }
}
.route-builder-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}
.route-tool-cluster {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border-radius: 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.12);
  flex-shrink: 0;
}
.route-tool-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 30px;
  padding: 0 11px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  cursor: pointer;
  white-space: nowrap;
  line-height: 1;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease,
    opacity 0.15s ease;
}
.route-tool-btn:hover:not(:disabled) {
  color: var(--text);
  background: rgba(148, 163, 184, 0.1);
}
.route-tool-btn:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}
.route-tool-ico {
  flex-shrink: 0;
  opacity: 0.9;
}
/* Out & back toggle — matches active list-mode / New pill language */
.route-tool-btn.route-oab-btn[aria-pressed="true"] {
  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"] .route-tool-btn.route-oab-btn[aria-pressed="true"] {
  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);
}
.route-builder-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.route-head-tools {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border-radius: 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.12);
  flex-shrink: 0;
}
.route-head-tool {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 0;
  flex-shrink: 0;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease,
    opacity 0.15s ease;
}
.route-head-tool:hover:not(:disabled) {
  color: var(--accent);
  background: rgba(196, 163, 90, 0.12);
}
.route-head-tool:focus-visible {
  outline: none;
  color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(196, 163, 90, 0.45);
}
.route-head-tool:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}
.route-head-tool[aria-pressed="true"] {
  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"] .route-head-tool[aria-pressed="true"] {
  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);
}
.route-head-ico {
  display: block;
  flex-shrink: 0;
}
.route-head-tool .ico-fs-exit {
  display: none;
}
.route-head-tool[aria-pressed="true"] .ico-fs-enter {
  display: none;
}
.route-head-tool[aria-pressed="true"] .ico-fs-exit {
  display: block;
}
.route-save-btn {
  appearance: none;
  width: auto;
  min-width: 5.4rem;
  height: 40px;
  margin: 0;
  padding: 0 16px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), #a8893f);
  color: #0c100e;
  font-family: var(--font);
  font-size: 0.84rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  white-space: nowrap;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.18) inset,
    0 6px 14px rgba(196, 163, 90, 0.18);
  transition: filter 0.15s ease, transform 0.1s ease, opacity 0.15s ease;
}
.route-save-btn:hover:not(:disabled) {
  filter: brightness(1.06);
}
.route-save-btn:active:not(:disabled) {
  transform: scale(0.98);
}
.route-save-btn:disabled {
  opacity: 0.42;
  cursor: not-allowed;
  box-shadow: none;
}
[data-theme="light"] .route-save-btn {
  background: linear-gradient(135deg, #8b6914, #6d5210);
  color: #fff;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.18) inset,
    0 6px 14px rgba(109, 82, 16, 0.16);
}
@media (max-width: 640px) {
  .route-builder-actions {
    gap: 8px;
  }
  .route-head-tool {
    width: 32px;
    height: 32px;
  }
  .route-save-btn {
    min-width: 4.6rem;
    height: 38px;
    padding: 0 13px;
    font-size: 0.8rem;
  }
}
.route-location-field {
  flex: 0 1 188px;
  width: 188px;
  max-width: 188px;
  min-width: 128px;
  display: flex;
  align-items: stretch;
  gap: 0;
  border: 1px solid var(--border-strong);
  background: var(--bg);
  border-radius: 10px;
  overflow: hidden;
}
.route-location-field input {
  flex: 1 1 auto;
  min-width: 0;
  border: none;
  background: transparent;
  color: var(--text);
  padding: 8px 10px 8px 12px;
  font-size: 0.9rem;
  font-family: var(--font);
  outline: none;
}
.route-location-field input::placeholder {
  color: var(--text-muted);
  opacity: 0.85;
}
.route-location-go {
  appearance: none;
  border: none;
  border-left: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-muted);
  padding: 0 11px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s ease, background 0.15s ease;
}
.route-location-go:hover {
  color: var(--accent);
  background: rgba(196, 163, 90, 0.12);
}
.route-location-go:disabled {
  opacity: 0.45;
  cursor: wait;
}
.route-builder-stats {
  flex: 0 1 auto;
  min-width: 0;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}
.route-builder-map {
  flex: 1 1 auto;
  min-height: 220px;
  cursor: crosshair;
}
.route-builder-charts {
  flex: 0 0 auto;
  max-height: 42vh;
}
/* Always show grade spectrum on the builder elev chart */
.route-builder-charts .grade-legend {
  display: flex;
  flex: 0 1 160px;
  min-width: 100px;
  max-width: 180px;
}
.route-chart-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  padding: 6px 12px 4px;
}
.route-chart-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 6px;
  flex: 1 1 auto;
  min-width: 0;
}
.route-sum-chip {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1px;
  min-width: 0;
  padding: 5px 9px;
  border-radius: 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  box-sizing: border-box;
}
.route-sum-l {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
  line-height: 1.1;
}
.route-sum-v {
  font-family: var(--font-display);
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
  white-space: nowrap;
}
.route-sum-chip.is-gain .route-sum-v {
  color: var(--good);
}
.route-sum-chip.is-loss .route-sum-v {
  color: var(--info, #56b0d4);
}
.route-sum-chip.is-peak {
  border-color: rgba(93, 190, 138, 0.35);
  background: linear-gradient(
    155deg,
    rgba(93, 190, 138, 0.1) 0%,
    var(--bg-elevated) 55%
  );
}
.route-sum-chip.is-peak .route-sum-v {
  color: var(--good);
}
[data-theme="light"] .route-sum-chip.is-peak {
  border-color: rgba(31, 138, 85, 0.28);
  background: linear-gradient(
    155deg,
    rgba(31, 138, 85, 0.08) 0%,
    var(--bg-elevated) 55%
  );
}
.route-builder-charts .detail-chart-readouts {
  width: auto;
  max-width: 100%;
  flex: 0 0 auto;
  gap: 8px 10px;
}
.route-builder-charts .detail-chart-wrap {
  min-height: 132px;
  height: 18vh;
  max-height: 200px;
  cursor: crosshair;
}
/* Scrub cursor on builder map */
.route-scrub-cursor {
  filter: drop-shadow(0 1px 4px rgba(0, 0, 0, 0.45));
}
.route-builder-hint {
  margin: 0;
  padding: 6px 14px 10px;
  font-size: 0.78rem;
  line-height: 1.35;
}
@media (max-width: 640px) {
  .route-chart-toolbar {
    gap: 6px 8px;
  }
  .route-builder-charts .grade-legend {
    max-width: 120px;
    min-width: 88px;
  }
  .route-sum-v {
    font-size: 0.84rem;
  }
  .route-sum-chip {
    padding: 4px 7px;
  }
}

.route-wp-marker {
  background: var(--accent);
  color: #0b1210;
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 800;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  cursor: pointer;
}
.route-wp-marker.is-start {
  background: var(--good);
}
.route-wp-marker.is-end:not(.is-start) {
  background: var(--warn);
}
/* Build tab — same map-first card language as Routes catalog */
.route-built-card .route-oab-badge {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 35%, var(--border));
  background: color-mix(in srgb, var(--accent) 12%, var(--bg-elevated));
}
.route-built-card .route-approx-badge {
  color: var(--warn, #d4a017);
}
.route-delete-icon:hover,
.route-delete-icon:focus-visible {
  color: #e85d5d !important;
  background: rgba(232, 93, 93, 0.14) !important;
}
[data-theme="light"] .route-delete-icon:hover,
[data-theme="light"] .route-delete-icon:focus-visible {
  color: #c0392b !important;
  background: rgba(192, 57, 43, 0.1) !important;
}
.route-empty {
  padding: 28px 16px 32px;
}
.route-empty-sub {
  margin-top: 8px;
  font-size: 0.9rem;
  color: var(--text-muted);
  max-width: 28rem;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.45;
}
.routes-list-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  padding: 0 2px;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}
.leaflet-container.route-building {
  cursor: crosshair;
}

/* ── List search ─────────────────────────────────────────── */
.list-search {
  display: inline-flex;
  align-items: center;
  min-width: 0;
}
.list-search input {
  width: min(220px, 42vw);
  height: 34px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.86rem;
}
.list-search input::placeholder {
  color: var(--text-muted);
}
.list-search input:focus {
  outline: none;
  border-color: var(--accent);
}

/* ── Grade source + vs-plan ──────────────────────────────── */
.grade-source {
  margin: 0;
  flex: 1 1 100%;
  font-size: 0.68rem;
  letter-spacing: 0.02em;
  color: var(--text-muted);
  line-height: 1.3;
}
.vs-plan-banner {
  margin: 0 12px 8px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  font-size: 0.82rem;
  color: var(--text-secondary);
}
.vs-plan-banner.is-faster {
  border-color: rgba(93, 190, 138, 0.4);
  color: var(--good);
}
.vs-plan-banner.is-slower {
  border-color: rgba(224, 108, 117, 0.35);
  color: var(--danger);
}

.detail-act-btn {
  white-space: nowrap;
  font-size: 0.78rem;
  padding: 6px 10px;
}

.course-visit-badge {
  display: inline-flex;
  align-items: center;
  margin-left: 8px;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--border);
  vertical-align: middle;
}

.route-plan-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  flex: 1 1 auto;
  min-width: 0;
  justify-content: flex-start;
}
.route-plan-chip {
  display: inline-flex;
  flex-direction: column;
  padding: 3px 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  line-height: 1.15;
}
.route-plan-chip em {
  font-style: normal;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.route-plan-chip strong {
  font-size: 0.82rem;
  font-weight: 700;
}
.route-plan-chip.is-easy strong { color: var(--good); }
.route-plan-chip.is-moderate strong { color: var(--warn); }
.route-plan-chip.is-hard strong { color: var(--danger); }

/* ── Lifetime repeat courses ─────────────────────────────── */
.life-courses {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}
.life-course-card {
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  cursor: pointer;
}
.life-course-card:hover {
  background: var(--bg-card-hover);
}
.life-course-name {
  font-family: var(--font-display);
  font-weight: 700;
  margin: 0 0 6px;
  font-size: 0.98rem;
}
.life-course-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  font-size: 0.78rem;
  color: var(--text-secondary);
}

/* ── Compare sheet ───────────────────────────────────────── */
.compare-overlay {
  position: fixed;
  inset: 0;
  z-index: 260;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(6, 10, 8, 0.62);
  backdrop-filter: blur(14px) saturate(1.15);
  -webkit-backdrop-filter: blur(14px) saturate(1.15);
}
.compare-overlay.hidden { display: none; }
.compare-sheet {
  width: min(440px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 16px 14px;
  border-radius: 22px;
  background:
    linear-gradient(180deg, rgba(196, 163, 90, 0.08) 0%, transparent 28%),
    var(--bg-elevated);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow), 0 0 0 1px rgba(255, 255, 255, 0.03) inset;
}
.compare-head {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas:
    "copy close"
    "headline headline";
  align-items: start;
  gap: 2px 10px;
}
.compare-head-copy { grid-area: copy; min-width: 0; }
.compare-close { grid-area: close; }
.compare-kicker {
  margin: 0;
  font-size: 0.64rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
}
.compare-head h2 {
  margin: 1px 0 0;
  font-family: var(--font-display);
  font-size: 1.18rem;
  letter-spacing: -0.03em;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.compare-headline {
  grid-area: headline;
  margin: 8px 0 0;
  padding: 7px 10px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--text);
  font-family: var(--font-display);
  font-size: 0.88rem;
  font-weight: 650;
  letter-spacing: -0.01em;
  line-height: 1.25;
}
.compare-headline.is-win-b {
  background: rgba(93, 190, 138, 0.14);
  color: var(--good);
}
.compare-headline.is-win-a {
  background: rgba(224, 108, 117, 0.12);
  color: var(--danger);
}
.compare-duel {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: stretch;
  gap: 8px;
}
.compare-pick {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 8px 8px 8px 8px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--bg-card);
}
.compare-pick.is-winner {
  border-color: rgba(93, 190, 138, 0.5);
  box-shadow: 0 0 0 1px rgba(93, 190, 138, 0.18);
}
.compare-letter {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  background: var(--accent-soft);
  color: var(--accent);
}
.compare-pick.is-b .compare-letter {
  background: rgba(93, 190, 138, 0.16);
  color: var(--good);
}
.compare-pick select {
  flex: 1 1 auto;
  min-width: 0;
  height: 28px;
  border: 0;
  background: transparent;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.78rem;
  font-weight: 650;
  padding: 0;
}
.compare-pick select:focus { outline: none; }
.compare-vs {
  align-self: center;
  font-family: var(--font-display);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.compare-board {
  display: grid;
  gap: 0;
  border-radius: 14px;
  border: 1px solid var(--border);
  overflow: hidden;
  background: var(--bg-card);
}
.cb-row {
  display: grid;
  grid-template-columns: 72px 1fr 1fr 68px;
  align-items: center;
  gap: 4px;
  min-height: 32px;
  padding: 0 10px;
  font-variant-numeric: tabular-nums;
  font-size: 0.8rem;
  border-top: 1px solid var(--border);
}
.cb-row:first-child { border-top: 0; }
.cb-row.is-head {
  min-height: 24px;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: rgba(0, 0, 0, 0.12);
}
.cb-l { color: var(--text-muted); font-weight: 650; font-size: 0.7rem; }
.cb-a, .cb-b { font-weight: 650; color: var(--text); }
.cb-d {
  justify-self: end;
  font-weight: 750;
  font-size: 0.74rem;
  color: var(--text-secondary);
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
}
.cb-row.is-win-b .cb-b,
.cb-row.is-win-b .cb-d { color: var(--good); }
.cb-row.is-win-a .cb-a { color: var(--good); }
.cb-row.is-win-a .cb-d { color: var(--danger); }
.compare-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 0;
}
.compare-pills:empty { display: none; }
.compare-pill {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 650;
  line-height: 1.2;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  background: var(--bg-card);
}
.compare-pill.is-gain {
  color: var(--good);
  border-color: rgba(93, 190, 138, 0.32);
  background: rgba(93, 190, 138, 0.1);
}
.compare-pill.is-loss {
  color: var(--danger);
  border-color: rgba(224, 108, 117, 0.28);
  background: rgba(224, 108, 117, 0.08);
}
[data-theme="light"] .compare-overlay {
  background: rgba(18, 24, 20, 0.38);
}
[data-theme="light"] .compare-sheet {
  background:
    linear-gradient(180deg, rgba(196, 163, 90, 0.1) 0%, transparent 30%),
    var(--bg-elevated);
}
[data-theme="light"] .cb-row.is-head {
  background: rgba(0, 0, 0, 0.04);
}
[data-theme="light"] .cb-d {
  background: rgba(0, 0, 0, 0.04);
}

@media (max-width: 640px) {
  .list-search input {
    width: 100%;
  }
  .section-head-right .list-search {
    flex: 1 1 140px;
  }
}

/* Activity detail header — phone: title + theme + ⋯, actions in a sheet */
@media (max-width: 720px) {
  .detail-fs-header {
    gap: 8px;
    padding: 8px 10px;
    padding-top: max(8px, env(safe-area-inset-top, 0px));
    padding-left: max(10px, env(safe-area-inset-left, 0px));
    padding-right: max(10px, env(safe-area-inset-right, 0px));
  }

  .detail-back {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
  }

  .detail-fs-titles h2 {
    white-space: normal;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 1.02rem;
    line-height: 1.22;
    letter-spacing: -0.015em;
  }

  .detail-fs-titles p {
    font-size: 0.74rem;
    margin-top: 2px;
  }

  .detail-fs-actions {
    gap: 4px;
  }

  .detail-fs-actions > .btn-icon {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
  }

  .detail-more {
    display: block;
    position: relative;
    flex-shrink: 0;
  }

  .detail-more-btn {
    display: inline-flex;
    width: 44px;
    height: 44px;
  }

  .detail-more-panel {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 40;
    min-width: 196px;
    max-width: min(280px, calc(100vw - 20px));
    padding: 8px;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-strong);
    border-radius: 14px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.42);
    backdrop-filter: blur(16px) saturate(1.15);
    -webkit-backdrop-filter: blur(16px) saturate(1.15);
  }

  .detail-more.is-open .detail-more-panel {
    display: flex;
  }

  .detail-more-panel .detail-act-btn {
    width: 100%;
    justify-content: flex-start;
    min-height: 44px;
    padding: 10px 12px;
    font-size: 0.9rem;
    font-weight: 650;
    border-radius: 10px;
    white-space: nowrap;
  }

  .detail-more-panel #detailGpxBtn {
    font-size: 0;
  }
  .detail-more-panel #detailGpxBtn::before {
    content: "Download GPX";
    font-size: 0.9rem;
    font-weight: 650;
  }

  .detail-more-panel .btn-icon {
    width: 100%;
    height: 44px;
    justify-content: flex-start;
    gap: 10px;
    padding: 0 12px;
    border-radius: 10px;
  }

  .detail-more-panel #detailFsBtn::after {
    content: "Fullscreen";
    font-size: 0.9rem;
    font-weight: 650;
    color: var(--text);
  }

  .detail-more-panel #detailDeleteBtn::after {
    content: "Delete ruck";
    font-size: 0.9rem;
    font-weight: 650;
  }

  .detail-more-panel #detailFsBtn,
  .detail-more-panel #detailDeleteBtn:not(.hidden) {
    color: var(--text-secondary);
  }

  .activity-head {
    gap: 8px;
    align-items: flex-start;
  }

  .activity-body h4 {
    white-space: normal;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
  }

  .kind-chip {
    max-width: min(46vw, 168px);
  }
}

/* ── Delete ruck (activity detail only) ───────────────────── */
.detail-fs[data-context="course"] .detail-delete-btn {
  display: none !important;
}
.detail-delete-btn {
  color: var(--text-muted);
}
.detail-delete-btn:hover,
.detail-delete-btn:focus-visible {
  color: var(--danger);
  background: rgba(224, 108, 117, 0.12);
}
.confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(6, 10, 8, 0.62);
  backdrop-filter: blur(14px) saturate(1.12);
  -webkit-backdrop-filter: blur(14px) saturate(1.12);
}
.confirm-overlay.hidden { display: none; }
.confirm-sheet {
  width: min(400px, calc(100vw - 32px));
  padding: 26px 22px 18px;
  border-radius: 20px;
  text-align: center;
  background:
    linear-gradient(165deg, rgba(224, 108, 117, 0.12) 0%, transparent 42%),
    var(--bg-elevated);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow), 0 0 0 1px rgba(255, 255, 255, 0.03) inset;
}
.confirm-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 12px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  color: var(--danger);
  background: rgba(224, 108, 117, 0.12);
  border: 1px solid rgba(224, 108, 117, 0.28);
}
.confirm-kicker {
  margin: 0 0 6px;
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--danger);
}
.confirm-title {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: 1.22rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}
.confirm-body {
  margin: 0 0 18px;
  font-size: 0.9rem;
  line-height: 1.45;
  color: var(--text-secondary);
}
.confirm-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.confirm-delete-btn {
  appearance: none;
  border: 0;
  border-radius: 12px;
  padding: 10px 14px;
  font-family: var(--font);
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  color: #fff;
  background: var(--danger);
  box-shadow: 0 6px 18px rgba(224, 108, 117, 0.28);
}
.confirm-delete-btn:hover:not(:disabled) {
  filter: brightness(1.06);
}
.confirm-delete-btn:disabled {
  opacity: 0.65;
  cursor: wait;
}
[data-theme="light"] .confirm-overlay {
  background: rgba(18, 24, 20, 0.4);
}
[data-theme="light"] .confirm-sheet {
  background:
    linear-gradient(165deg, rgba(196, 60, 72, 0.08) 0%, transparent 42%),
    var(--bg-elevated);
}
