/* ============================================================
   Running Archive — Sport Data Edition
   Unified dark theme with athletic accents, big typography,
   subtle animations, and track-inspired textures.
   ============================================================ */

/* ---- Design Tokens ---- */
:root, [data-theme="dark"] {
  color-scheme: dark;

  /* Background */
  --bg: #080c12;
  --bg-deep: #05080e;
  --bg-elevated: #0e131d;
  --bg-medium: #0a0f18;
  --bg-card: rgba(14, 19, 29, 0.82);

  /* Text */
  --ink: #f0f3f8;
  --ink-dim: #8896a8;
  --ink-muted: #5c6878;
  --ink-inverse: #080c12;

  /* Accent — sport orange */
  --accent: #ff5e3a;
  --accent-glow: #ff8a6e;
  --accent-soft: rgba(255, 94, 58, 0.15);

  /* Data blue */
  --blue: #3b8bff;
  --blue-glow: #7ab8ff;
  --blue-soft: rgba(59, 139, 255, 0.12);

  /* Finish green */
  --green: #2dd4a8;
  --green-soft: rgba(45, 212, 168, 0.12);

  /* Borders */
  --line: rgba(255, 255, 255, 0.06);
  --line-strong: rgba(255, 255, 255, 0.12);

  /* Overlays / brand */
  --overlay: rgba(255, 255, 255, 0.12);
  --overlay-dim: rgba(255, 255, 255, 0.06);
  --overlay-strong: rgba(255, 255, 255, 0.3);
  --text-dim-overlay: rgba(255, 255, 255, 0.7);
  --text-muted-overlay: rgba(255, 255, 255, 0.45);
  --text-faint-overlay: rgba(255, 255, 255, 0.55);

  /* Map */
  --map-bg: #080c12;
  --panel-bg: rgba(8, 12, 18, 0.72);
  --panel-border: rgba(255, 255, 255, 0.08);

  /* Tooltip */
  --tooltip-bg: #ffffff;
  --tooltip-ink: #05070a;

  /* Misc */
  --white: #fff;
  --route-bg: #0a0f18;
  --fallback-bg-1: #0e131d;
  --fallback-bg-2: #0f1f38;

  /* Radius & shadows */
  --radius: 16px;
  --radius-sm: 10px;
  --radius-pill: 999px;
  --shadow-card: 0 2px 12px rgba(0, 0, 0, 0.25);
  --shadow-hover: 0 8px 32px rgba(0, 0, 0, 0.45);

  /* Transitions */
  --ease-out: 0.25s cubic-bezier(0.25, 0, 0, 1);
  --ease-spring: 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

[data-theme="light"] {
  color-scheme: light;

  --bg: #f4f5f7;
  --bg-deep: #e8eaef;
  --bg-elevated: #ffffff;
  --bg-medium: #ebedf0;
  --bg-card: rgba(255, 255, 255, 0.88);

  --ink: #1a1d24;
  --ink-dim: #6b7280;
  --ink-muted: #9ca3af;
  --ink-inverse: #f0f3f8;

  --accent: #e04a2a;
  --accent-glow: #d9441f;
  --accent-soft: rgba(224, 74, 42, 0.1);

  --blue: #2563eb;
  --blue-glow: #1d4ed8;
  --blue-soft: rgba(37, 99, 235, 0.1);

  --green: #10b981;
  --green-soft: rgba(16, 185, 129, 0.1);

  --line: rgba(0, 0, 0, 0.08);
  --line-strong: rgba(0, 0, 0, 0.15);

  --overlay: rgba(0, 0, 0, 0.06);
  --overlay-dim: rgba(0, 0, 0, 0.03);
  --overlay-strong: rgba(0, 0, 0, 0.3);
  --text-dim-overlay: rgba(0, 0, 0, 0.65);
  --text-muted-overlay: rgba(0, 0, 0, 0.4);
  --text-faint-overlay: rgba(0, 0, 0, 0.5);

  --map-bg: #f1f4f7;
  --panel-bg: rgba(250, 252, 255, 0.74);
  --panel-border: rgba(0, 0, 0, 0.08);

  --tooltip-bg: #1a1d24;
  --tooltip-ink: #f0f3f8;

  --white: #fff;
  --route-bg: linear-gradient(135deg, #f8fbff 0%, #eef8f3 54%, #fff3ec 100%);
  --fallback-bg-1: #e8eaef;
  --fallback-bg-2: #dde1e6;

  --shadow-card: 0 2px 12px rgba(0, 0, 0, 0.08);
  --shadow-hover: 0 8px 28px rgba(0, 0, 0, 0.15);
}

/* ---- Chart colors (theme-independent) ---- */
:root {
  --chart-bar-bg: linear-gradient(180deg, #72c4ff 0%, #3b82f6 58%, #1d4ed8 100%);
  --chart-bar-shadow: 0 0 0 1px rgba(114, 196, 255, 0.16);
  --chart-bar-hover-bg: linear-gradient(180deg, #ff8a6e 0%, #ff5e3a 56%, #d9441f 100%);
  --chart-bar-hover-shadow:
    0 0 0 1px rgba(255, 94, 58, 0.25),
    0 0 26px rgba(255, 94, 58, 0.2);
}

/* ---- Reset & Base ---- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
}

body {
  margin: 0;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(59, 139, 255, 0.08) 0%, transparent 60%),
    radial-gradient(ellipse at 85% 20%, rgba(255, 94, 58, 0.06) 0%, transparent 50%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-medium) 100%);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  line-height: 1.5;
  min-height: 100vh;
}

/* Subtle track-line texture overlay */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 2px,
      rgba(128, 128, 128, 0.03) 2px,
      rgba(128, 128, 128, 0.03) 4px
    ),
    repeating-linear-gradient(
      90deg,
      transparent,
      transparent 80px,
      rgba(128, 128, 128, 0.04) 80px,
      rgba(128, 128, 128, 0.04) 81px
    );
  mask-image: radial-gradient(ellipse at 50% 0%, black 40%, transparent 70%);
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
}

/* ---- Keyframe Animations ---- */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 0 0 0 var(--accent); }
  50%      { box-shadow: 0 0 16px 3px rgba(255, 94, 58, 0.35); }
}

@keyframes breathe {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.6; }
}

@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

/* ---- Hero Section ---- */
.hero {
  position: relative;
  height: 100vh;
  display: grid;
  align-content: space-between;
  overflow: hidden;
  background: var(--bg-deep);
  isolation: isolate;
}


.hero__map,
.hero__map-shade {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.hero__map {
  z-index: 0;
  background: var(--map-bg);
}

.hero__map .leaflet-container {
  background: var(--map-bg);
}

.hero__map-shade {
  z-index: 1;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.55) 0%, rgba(0, 0, 0, 0.35) 38%, transparent 68%),
    linear-gradient(0deg, rgba(0, 0, 0, 0.5) 0%, transparent 55%);
  pointer-events: none;
}

[data-theme="light"] .hero__map-shade {
  background:
    linear-gradient(90deg, rgba(246, 249, 252, 0.62) 0%, rgba(246, 249, 252, 0.30) 36%, rgba(246, 249, 252, 0.06) 64%, transparent 78%),
    linear-gradient(0deg, rgba(246, 249, 252, 0.48) 0%, rgba(246, 249, 252, 0.14) 44%, transparent 68%);
}

/* Health stats overlay on hero map */
.hero-stats-overlay {
  position: absolute;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius);
  background: rgba(10, 14, 22, 0.90);
  backdrop-filter: blur(18px);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
  overflow: hidden;
  pointer-events: none;
  max-width: 560px;
}

.hero-stats-overlay__values {
  display: flex;
  gap: 0;
  width: 100%;
  min-width: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-right: 42px;
}

.hero-stats-overlay__item {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 72px;
  padding: 10px 14px;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.hero-stats-overlay__item:last-child {
  border-right: 0;
}

.hero-stats-overlay__label {
  color: var(--accent);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.hero-stats-overlay__item strong {
  display: block;
  color: #ffffff;
  font-size: 1.05rem;
  font-weight: 850;
  letter-spacing: -0.01em;
}

.hero-stats-overlay__item small {
  display: block;
  color: #aab4c2;
  font-size: 0.7rem;
  font-weight: 600;
}

/* Sparkline chart grid — stacked vertically */
.hero-stats-overlay__charts {
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow: hidden;
  max-height: 300px;
  transition: max-height 0.25s ease, opacity 0.2s ease;
  opacity: 1;
}

/* Collapsed state */
.hero-stats-overlay--collapsed .hero-stats-overlay__charts {
  max-height: 0;
  opacity: 0;
}

@media (min-width: 761px) {
  .hero-stats-overlay--collapsed {
    max-width: 430px;
  }

  .hero-stats-overlay--collapsed .hero-stats-overlay__values {
    border-bottom: 0;
  }

  .hero-stats-overlay--collapsed .hero-stats-overlay__item {
    min-width: 64px;
    padding: 8px 12px;
  }

  .hero-stats-overlay--collapsed .hero-stats-overlay__item--optional {
    display: none;
  }

  .hero-stats-overlay--collapsed .hero-stats-overlay__item strong {
    font-size: 0.96rem;
  }

  .hero-stats-overlay--collapsed .hero-stats-overlay__item small {
    display: none;
  }
}

.hero-stats-overlay__chart {
  position: relative;
  width: 100%;
  height: 90px;
  padding: 4px 6px 2px;
}

.hero-stats-overlay__chart canvas {
  display: block;
}

/* Collapse toggle button */
.hero-stats-overlay__toggle {
  position: absolute;
  top: 22px;
  right: 6px;
  z-index: 2;
  width: 22px;
  height: 42px;
  border: 0;
  border-left: 1px solid rgba(255,255,255,0.15);
  border-radius: 0 8px 8px 0;
  background: transparent;
  color: rgba(255,255,255,0.55);
  box-shadow: none;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
  pointer-events: auto;
  transform: translateY(-50%);
  transition: color 0.15s, border-color 0.15s;
}
.hero-stats-overlay__toggle:hover {
  color: rgba(255,255,255,0.85);
  border-left-color: rgba(255,255,255,0.35);
  background: transparent;
}

@media (max-width: 760px) {
  .hero-stats-overlay {
    bottom: 12px;
    right: 12px;
    flex-wrap: wrap;
    max-width: calc(100vw - 24px);
    border: 0;
    border-radius: 0;
    background: transparent;
    backdrop-filter: none;
    box-shadow: none;
  }
  .hero-stats-overlay__values {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0;
    max-width: 100%;
    overflow: hidden;
    padding: 10px 30px 10px 12px;
    border-bottom: 0;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 18px;
    background: rgba(8, 12, 18, 0.94);
    box-shadow: 0 12px 34px rgba(0, 0, 0, 0.28);
  }
  .hero-stats-overlay__item {
    min-width: 0;
    padding: 4px 7px;
    border: 0;
    border-right: 1px solid rgba(255, 255, 255, 0.10);
    border-radius: 0;
    background: transparent;
    overflow: hidden;
  }
  .hero-stats-overlay__item:last-child {
    border-right: 0;
  }
  .hero-stats-overlay__label {
    overflow: hidden;
    font-size: 0.58rem;
    line-height: 1;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .hero-stats-overlay__item strong {
    overflow: hidden;
    margin-top: 2px;
    font-size: clamp(0.68rem, 2.8vw, 0.78rem);
    line-height: 1.08;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .hero-stats-overlay__item small {
    display: none;
    font-size: 0.62rem;
  }
  .hero-stats-overlay__toggle {
    top: 29px;
    right: 7px;
    width: 22px;
    height: 46px;
    border: 0;
    border-left: 1px solid rgba(255, 255, 255, 0.10);
    border-radius: 0 14px 14px 0;
    background: transparent;
    color: rgba(255, 255, 255, 0.56);
    box-shadow: none;
    font-size: 0.88rem;
    transform: translateY(-50%);
  }
  .hero-stats-overlay__toggle:hover,
  .hero-stats-overlay__toggle:focus,
  .hero-stats-overlay__toggle:focus-visible,
  .hero-stats-overlay__toggle:active {
    outline: 0;
    border-left-color: rgba(255, 255, 255, 0.10);
    background: transparent;
    color: rgba(255, 255, 255, 0.56);
    box-shadow: none;
  }
  .hero-stats-overlay__chart {
    height: 72px;
  }
  .hero-stats-overlay__charts {
    max-height: 240px;
    margin-top: 8px;
    border: 1px solid rgba(255, 255, 255, 0.10);
    border-radius: 16px;
    background: rgba(8, 12, 18, 0.92);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.24);
  }
}

/* Light theme overlay overrides */
[data-theme="light"] .hero-stats-overlay {
  background: rgba(255, 255, 255, 0.88);
  border-color: rgba(0, 0, 0, 0.10);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.10);
}
[data-theme="light"] .hero-stats-overlay__values {
  border-bottom-color: rgba(0, 0, 0, 0.08);
}
[data-theme="light"] .hero-stats-overlay__item {
  border-right-color: rgba(0, 0, 0, 0.08);
}
[data-theme="light"] .hero-stats-overlay__item:last-child {
  border-right-color: rgba(0, 0, 0, 0.08);
}
[data-theme="light"] .hero-stats-overlay__item strong {
  color: #1a1d24;
}
[data-theme="light"] .hero-stats-overlay__item small {
  color: #6b7280;
}
[data-theme="light"] .hero-stats-overlay__toggle {
  border-left-color: rgba(0, 0, 0, 0.12);
  background: transparent;
  color: rgba(0, 0, 0, 0.4);
}
[data-theme="light"] .hero-stats-overlay__toggle:hover {
  background: transparent;
  border-left-color: rgba(0, 0, 0, 0.28);
  color: rgba(0, 0, 0, 0.65);
}

@media (max-width: 760px) {
  [data-theme="light"] .hero-stats-overlay {
    background: transparent;
    backdrop-filter: none;
  }

  [data-theme="light"] .hero-stats-overlay__values {
    border-color: rgba(20, 28, 40, 0.08);
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 14px 36px rgba(28, 38, 58, 0.14);
  }

  [data-theme="light"] .hero-stats-overlay__item {
    border-right-color: rgba(20, 28, 40, 0.08);
    background: transparent;
  }

  [data-theme="light"] .hero-stats-overlay__item:last-child {
    border-right-color: transparent;
  }

  [data-theme="light"] .hero-stats-overlay__toggle {
    border-left-color: rgba(20, 28, 40, 0.08);
    background: transparent;
    color: rgba(24, 28, 36, 0.44);
    box-shadow: none;
  }

  [data-theme="light"] .hero-stats-overlay__toggle:hover,
  [data-theme="light"] .hero-stats-overlay__toggle:focus,
  [data-theme="light"] .hero-stats-overlay__toggle:focus-visible,
  [data-theme="light"] .hero-stats-overlay__toggle:active {
    outline: 0;
    border-left-color: rgba(20, 28, 40, 0.08);
    background: transparent;
    color: rgba(24, 28, 36, 0.44);
    box-shadow: none;
  }

  [data-theme="light"] .hero-stats-overlay__charts {
    border-color: rgba(20, 28, 40, 0.08);
    background: rgba(255, 255, 255, 0.94);
    box-shadow: 0 10px 26px rgba(28, 38, 58, 0.12);
  }
}

.topbar,
.hero__content {
  position: relative;
  z-index: 2;
  width: min(1180px, calc(100% - 40px));
  margin-inline: auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 76px;
  color: var(--white);
}

[data-theme="light"] .topbar {
  color: var(--ink);
}

.brand,
.topbar__links {
  display: flex;
  align-items: center;
}

.brand {
  gap: 12px;
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}

.brand__mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--overlay-strong);
  border-radius: 50%;
  color: var(--white);
  font-weight: 900;
  box-shadow: inset 0 0 0 5px var(--overlay-dim);
  flex-shrink: 0;
}

.brand__mark--photo {
  overflow: hidden;
  padding: 0;
  border-color: rgba(128, 128, 128, 0.3);
  background: var(--overlay-dim);
  box-shadow: none;
}

.brand__mark--photo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.topbar__links {
  gap: 4px;
  color: var(--text-dim-overlay);
  font-size: 0.92rem;
  font-weight: 700;
}

.topbar__links a {
  min-height: 36px;
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  transition: background var(--ease-out), color var(--ease-out);
}

.topbar__links a:hover,
.topbar__links a.is-active {
  background: var(--overlay);
  color: var(--white);
}

[data-theme="light"] .topbar__links a:hover,
[data-theme="light"] .topbar__links a.is-active {
  color: var(--ink);
}

/* ---- Theme Toggle ---- */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  margin-left: 4px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  transition: background var(--ease-out);
}

.theme-toggle:hover {
  background: var(--overlay);
}

.theme-toggle__icon {
  font-size: 1.1rem;
  line-height: 1;
}

/* ---- Stats full-width mode ---- */
.hero--stats-full .hero__map,
.hero--stats-full .hero__map-shade {
  display: none;
}

.hero--stats-full {
  height: auto;
  min-height: 100vh;
  overflow: visible;
  background:
    radial-gradient(ellipse at 50% 0%, var(--accent-soft) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 80%, var(--blue-soft) 0%, transparent 40%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-deep) 100%);
}

.hero--stats-full::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 60px,
      var(--line) 60px,
      var(--line) 61px
    ),
    repeating-linear-gradient(
      90deg,
      transparent,
      transparent 60px,
      var(--line) 60px,
      var(--line) 61px
    );
  mask-image: radial-gradient(ellipse at 50% 30%, black 30%, transparent 60%);
}

.hero--stats-full .topbar,
.hero--stats-full .hero__panel {
  position: relative;
  z-index: 1;
}

.hero--stats-full .hero__panel {
  width: 100%;
  max-width: 960px;
  max-height: none;
  margin: 16px auto 20px;
  border-right: 0;
  border-radius: var(--radius);
}

.hero--stats-full .hero__panel-body {
  overflow-y: visible;
}

.hero--stats-full .hero__panel-body .bar-chart {
  height: 240px;
  gap: 14px;
}

.hero--stats-full .hero__panel-body .bar i {
  width: 14px;
}

/* ---- Hero Route Panel ---- */
.hero__panel {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  width: 380px;
  max-height: calc(100vh - 80px);
  margin: 60px 0 20px;
  border-right: 1px solid var(--panel-border);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--panel-bg);
  backdrop-filter: blur(18px);
  color: var(--ink);
  overflow: hidden;
}

.hero__panel-header {
  position: relative;
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 10px;
  padding: 10px 32px 10px 18px;
  border-bottom: 1px solid var(--panel-border);
}

.hero__panel-header .eyebrow {
  margin: 0;
  font-size: 0.72rem;
}

.hero__panel-header h2 {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 850;
  letter-spacing: -0.01em;
}

.hero__panel-header span {
  margin: 0;
  color: var(--ink-dim);
  font-size: 0.76rem;
  font-weight: 650;
}

/* ---- Panel Collapse Toggle ---- */
.panel-collapse-toggle {
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  width: 24px;
  height: 40px;
  border: 0;
  border-left: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 0 8px 8px 0;
  background: transparent;
  color: rgba(255, 255, 255, 0.45);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
  pointer-events: auto;
  transition: color 0.15s, border-color 0.15s;
}

.panel-collapse-toggle:hover {
  color: rgba(255, 255, 255, 0.8);
  border-left-color: rgba(255, 255, 255, 0.3);
}

[data-theme="light"] .panel-collapse-toggle {
  border-left-color: rgba(0, 0, 0, 0.10);
  color: rgba(0, 0, 0, 0.35);
}

[data-theme="light"] .panel-collapse-toggle:hover {
  color: rgba(0, 0, 0, 0.65);
  border-left-color: rgba(0, 0, 0, 0.25);
}

@media (max-width: 760px) {
  .panel-collapse-toggle {
    display: none;
  }
}

/* Collapsed panel — header stays, body shows fewer items */
.hero__panel--collapsed .hero__panel-header {
  border-bottom: 1px solid var(--panel-border);
}

.panel-collapsed-hint {
  margin: 0;
  padding: 10px 12px;
  color: var(--ink-dim);
  font-size: 0.76rem;
  font-weight: 650;
  text-align: center;
}

.hero__panel-body {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 6px 12px 10px;
  scrollbar-width: thin;
  scrollbar-color: var(--overlay) transparent;
  contain: layout style;
}

/* ---- Panel Resize Handle ---- */
.panel-resize-handle {
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%);
  width: 48px;
  height: 16px;
  cursor: ns-resize;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
}

.panel-resize-handle::before {
  content: "";
  width: 28px;
  height: 4px;
  border-radius: 2px;
  background: var(--overlay);
  transition: background 0.15s, width 0.15s;
}

.panel-resize-handle:hover::before,
.panel-resize-handle.is-dragging::before {
  background: var(--overlay-strong);
  width: 40px;
}

@media (max-width: 760px) {
  .panel-resize-handle::before {
    width: 36px;
    height: 5px;
  }
}

.hero__panel-body::-webkit-scrollbar {
  width: 4px;
}

.hero__panel-body::-webkit-scrollbar-thumb {
  background: var(--overlay);
  border-radius: 4px;
}

.hero-route-item {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr);
  gap: 10px;
  width: 100%;
  padding: 6px 8px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  content-visibility: auto;
  contain-intrinsic-size: 66px;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.hero-route-item:hover {
  background: var(--overlay-dim);
  border-color: var(--line-strong);
}

.hero-route-item.is-active {
  background: var(--accent-soft);
  border-color: rgba(255, 94, 58, 0.35);
}

.hero-route-item__thumb {
  width: 84px;
  height: 50px;
  overflow: hidden;
  border-radius: 6px;
  background: var(--route-bg);
}

.hero-route-item__thumb .route-svg {
  width: 100%;
  height: 100%;
}

.hero-route-item__info {
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.hero-route-item__info strong {
  display: block;
  font-size: 0.9rem;
  font-weight: 750;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hero-route-item__info span {
  display: block;
  margin-top: 3px;
  color: var(--ink-dim);
  font-size: 0.76rem;
  font-weight: 650;
}

/* ---- Panel Content (races / stats tabs) ---- */
.panel-section-header {
  padding: 8px 4px 6px;
}

.panel-section-header h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 800;
  color: var(--ink-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Races tab — stacked cards */
.hero__panel-body .timeline {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: visible;
}

.hero__panel-body .timeline-item__body {
  min-height: 0;
  padding: 16px;
}

.hero__panel-body .timeline-item__date span {
  font-size: 1.8rem;
}

.hero__panel-body .race-result span {
  font-size: clamp(1.5rem, 3vw, 2rem);
}

.hero__panel-body .record-grid {
  grid-template-columns: 1fr;
  gap: 8px;
}

.hero__panel-body .race-card {
  grid-template-columns: 1fr;
  min-height: 0;
}

.hero__panel-body .race-card__media {
  aspect-ratio: 16 / 7.5;
  height: auto;
}

.hero__panel-body .race-card__body {
  padding: 10px 12px 12px;
}

.hero__panel-body .race-card__meta {
  gap: 8px;
  font-size: 0.74rem;
}

.hero__panel-body .race-card h3 {
  font-size: 0.96rem;
  margin-top: 5px;
  line-height: 1.22;
}

.hero__panel-body .race-card__body p {
  margin-top: 3px;
  font-size: 0.78rem;
  line-height: 1.35;
}

.hero__panel-body .race-card--has-preview-stats .race-card__result {
  display: none;
}

.hero__panel-body .race-card__result {
  padding-top: 7px;
}

.hero__panel-body .race-card__result strong {
  font-size: 1.18rem;
}

.hero__panel-body .race-card__notes {
  margin-top: 6px;
  font-size: 0.76rem;
  line-height: 1.35;
}

.hero__panel-body .race-route-preview__stats {
  left: 10px;
  right: 10px;
  bottom: 10px;
  gap: 1px 8px;
  padding: 8px 12px;
}

.hero__panel-body .race-route-preview__stats span,
.hero__panel-body .race-route-preview__stats small {
  font-size: 0.72rem;
}

.hero__panel-body .race-route-preview__stats strong {
  font-size: 1.04rem;
}

/* Stats tab — compact layout */
.hero__panel-body .chart-block {
  padding: 12px;
}

.hero__panel-body .chart-block__header h3 {
  font-size: 1.1rem;
}

.hero__panel-body .chart-block__header {
  margin-bottom: 12px;
  padding-bottom: 12px;
}

.hero__panel-body .bar-chart {
  height: 200px;
  gap: 10px;
  min-width: 0;
  overflow: hidden;
}

.hero__panel-body .bar {
  min-width: 0;
  overflow: visible;
  grid-template-rows: minmax(0, 1fr) 26px;
}

.hero__panel-body .bar i {
  width: 10px;
}

.hero__panel-body .bar i::before {
  display: none;
}

/* ---- Bar Chart Reference Lines ---- */
.bar-ref-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 0;
  border-top: 1px dashed var(--line-strong);
  pointer-events: none;
  z-index: 1;
}

.bar-ref-line small {
  position: absolute;
  left: 4px;
  top: -9px;
  color: var(--ink-muted);
  font-size: 0.62rem;
  font-weight: 650;
  white-space: nowrap;
  background: var(--bg-card);
  padding: 0 4px;
}

/* ---- Bar Cursor Tooltip ---- */
.bar-tooltip {
  position: absolute;
  z-index: 50;
  padding: 5px 10px;
  border-radius: 6px;
  background: var(--tooltip-bg);
  color: var(--tooltip-ink);
  font-size: 0.76rem;
  font-weight: 700;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
  transition: opacity 0.1s;
}

.bar-tooltip[hidden] {
  display: none;
}

.hero__panel-body .insight-list {
  gap: 8px;
}

.hero__panel-body .insight-list strong {
  font-size: 1.3rem;
}

.hero__panel-body .month-detail-chart {
  min-height: 130px;
  padding: 12px 10px 10px;
  gap: 10px;
}

.hero__panel-body .month-activity-bar {
  flex-basis: 34px;
  width: 34px;
  min-width: 34px;
  height: 130px;
}

.eyebrow {
  display: inline-block;
  margin: 0 0 14px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.hero .eyebrow {
  color: var(--accent-glow);
}


/* ---- Buttons ---- */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 22px;
  border-radius: var(--radius-sm);
  font-weight: 750;
  font-size: 0.95rem;
  transition: transform var(--ease-out), box-shadow var(--ease-out);
}

.button:hover {
  transform: translateY(-1px);
}

.button:active {
  transform: translateY(0);
}

.button--primary {
  background: var(--white);
  color: var(--ink-inverse);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.3);
}

.button--primary:hover {
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
}

.button--ghost {
  border: 1px solid var(--overlay-strong);
  color: var(--ink);
  backdrop-filter: blur(8px);
}

.button--ghost:hover {
  border-color: var(--line-strong);
  background: var(--overlay-dim);
}

/* ---- Summary Strip (floating on map) ---- */
.summary-strip {
  position: absolute;
  top: 76px;
  left: 380px;
  right: 0;
  z-index: 2;
  display: flex;
  gap: 0;
  padding: 0 20px;
  pointer-events: none;
}

.summary-strip .metric {
  flex: 1;
  min-width: 0;
  padding: 14px 16px;
  color: var(--ink);
}

.summary-strip .metric + .metric {
  border-left: 1px solid var(--line-strong);
}

.summary-strip .metric::before {
  content: "";
  display: block;
  width: 24px;
  height: 2px;
  margin-bottom: 10px;
  border-radius: 2px;
  background: var(--accent);
}

.summary-strip .metric:nth-child(2)::before { background: var(--blue); }
.summary-strip .metric:nth-child(3)::before { background: var(--green); }
.summary-strip .metric:nth-child(4)::before { background: var(--accent); }
.summary-strip .metric:nth-child(5)::before { background: var(--blue); }

.summary-strip .metric__label {
  display: block;
  color: var(--ink-dim);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.summary-strip .metric strong {
  display: block;
  margin: 4px 0 2px;
  color: var(--ink);
  font-size: clamp(1.2rem, 2vw, 1.6rem);
  font-weight: 900;
  line-height: 1;
  letter-spacing: -0.02em;
}

.summary-strip .metric small {
  display: block;
  color: var(--ink-dim);
  font-size: 0.7rem;
  font-weight: 600;
}

/* ---- Marathon Timeline ---- */
.timeline {
  display: flex;
  gap: 20px;
  overflow-x: auto;
  padding: 4px 4px 24px;
  scroll-snap-type: x mandatory;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

.timeline::-webkit-scrollbar {
  height: 4px;
}

.timeline::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 4px;
}

.timeline-item {
  flex: 0 0 min(540px, 82vw);
  scroll-snap-align: start;
}

.timeline-item__marker {
  display: none;
}

.timeline-item__body {
  display: flex;
  flex-direction: column;
  min-height: 340px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  box-shadow: var(--shadow-card);
  transition: transform var(--ease-out), box-shadow var(--ease-out), border-color var(--ease-out);
}

.timeline-item__body:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-hover);
  border-color: var(--accent);
}

.timeline-item__date {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 14px;
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.timeline-item__date span {
  color: var(--ink);
  font-size: 2.6rem;
  font-weight: 900;
  line-height: 1;
  letter-spacing: -0.02em;
}

.timeline-item__copy h3 {
  margin: 0;
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  font-weight: 850;
  line-height: 1.1;
  letter-spacing: -0.01em;
}

.timeline-item__copy p {
  margin: 8px 0 0;
  color: var(--ink-dim);
  font-size: 0.95rem;
}

.race-result {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: auto;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.race-result span {
  color: var(--ink);
  font-size: clamp(2rem, 4vw, 3rem);
  font-weight: 900;
  line-height: 1;
  letter-spacing: -0.02em;
}

.race-result small {
  color: var(--ink-dim);
  font-weight: 650;
}

/* PB Badge */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 26px;
  padding: 0 8px;
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: var(--white);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  animation: pulseGlow 2.5s ease-in-out infinite;
}

.badge--small {
  min-width: 30px;
  height: 22px;
  font-size: 0.72rem;
}

/* ---- Race Cards ---- */
.record-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}

.race-card {
  display: grid;
  grid-template-columns: minmax(200px, 0.85fr) minmax(0, 1.15fr);
  min-height: 260px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  box-shadow: var(--shadow-card);
  content-visibility: auto;
  contain-intrinsic-size: 260px;
  transition: transform var(--ease-out), box-shadow var(--ease-out), border-color var(--ease-out);
}

.race-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-hover);
  border-color: var(--accent);
}

/* Clickable race card (has route target) */
.race-card[data-route-target] {
  cursor: pointer;
}

.race-card.is-active {
  border-color: var(--accent);
  box-shadow:
    var(--shadow-hover),
    0 0 0 1px rgba(255, 94, 58, 0.3);
}

.race-card__media {
  height: 100%;
  border-right: 1px solid var(--line);
  background: var(--route-bg);
}

.race-card__media img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.race-card__fallback {
  display: grid;
  place-items: center;
  height: 100%;
  color: var(--white);
  background:
    radial-gradient(circle at 70% 20%, rgba(255, 94, 58, 0.25), transparent 35%),
    linear-gradient(135deg, var(--fallback-bg-1), var(--fallback-bg-2));
  text-align: center;
}

.race-card__fallback span {
  display: block;
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-dim);
}

.race-card__fallback strong {
  display: block;
  margin-top: 8px;
  font-size: 2rem;
  font-weight: 900;
  letter-spacing: -0.02em;
}

.race-route-preview {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--route-bg);
}

.race-route-preview .route-svg {
  height: 100%;
}

.race-route-preview__stats {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2px 10px;
  align-items: end;
  padding: 10px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--panel-bg);
  backdrop-filter: blur(12px);
}

.race-route-preview__stats span,
.race-route-preview__stats small {
  color: var(--ink-dim);
  font-size: 0.76rem;
  font-weight: 700;
}

.race-route-preview__stats strong {
  grid-row: span 2;
  color: var(--ink);
  font-size: 1.15rem;
  font-weight: 850;
  letter-spacing: -0.01em;
}

.race-card__body {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 22px;
}

.race-card__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--ink-dim);
  font-size: 0.8rem;
  font-weight: 700;
}

.race-card__meta span:first-child {
  color: var(--accent);
}

.race-card__body h3 {
  margin: 12px 0 0;
  font-size: clamp(1.15rem, 2vw, 1.5rem);
  font-weight: 800;
  line-height: 1.2;
}

.race-card__body p {
  margin: 8px 0 0;
  color: var(--ink-dim);
  font-size: 0.9rem;
}

.race-card__result {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: auto;
  padding-top: 16px;
}

.race-card__result strong {
  color: var(--ink);
  font-size: clamp(1.6rem, 2.5vw, 2.2rem);
  font-weight: 900;
  letter-spacing: -0.02em;
}

.race-card__result span {
  color: var(--ink-dim);
  font-weight: 650;
}

.race-card__notes {
  margin-top: 12px;
  color: var(--ink-dim);
  font-size: 0.88rem;
  line-height: 1.5;
}

/* ---- Route Link & Text Actions ---- */
.route-link,
.text-action {
  display: inline-flex;
  align-items: center;
  border: 0;
  background: transparent;
  color: var(--blue);
  cursor: pointer;
  font-weight: 750;
  font-size: 0.9rem;
  transition: color var(--ease-out);
}

.route-link:hover,
.text-action:hover {
  color: var(--blue-glow);
}

.route-link {
  min-height: 30px;
  padding: 0 12px;
  border: 1px solid rgba(59, 139, 255, 0.25);
  border-radius: var(--radius-pill);
  background: var(--blue-soft);
}

.text-action {
  margin-top: 12px;
  padding: 0;
}

.text-action--compact {
  margin-top: 0;
}

/* ---- Leaflet Container ---- */
.leaflet-container {
  font: inherit;
  background: var(--bg-medium);
}

.leaflet-control-zoom {
  border: 0 !important;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
}

.leaflet-control-zoom a {
  width: 28px !important;
  height: 28px !important;
  line-height: 26px !important;
  border-color: var(--line) !important;
  background: var(--panel-bg) !important;
  color: var(--ink) !important;
  font-size: 16px !important;
  font-weight: 700;
  backdrop-filter: blur(12px);
}

.leaflet-control-zoom a:hover {
  background: var(--overlay) !important;
}

.race-city-area {
  filter: drop-shadow(0 0 22px rgba(255, 94, 58, 0.28));
  mix-blend-mode: screen;
}

/* ---- Empty State ---- */
.empty {
  margin: 0;
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--ink-dim);
  text-align: center;
  font-weight: 650;
}

.empty--compact {
  border: 0;
  background: transparent;
}

/* ---- Stats Layout ---- */
.stats-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(280px, 0.7fr);
  gap: 20px;
}

/* ---- Stats: Year Navigator ---- */
.stats-year-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 0 8px;
}

.stats-year-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.stats-year-nav strong {
  font-size: 1.15rem;
  font-weight: 850;
  letter-spacing: -0.01em;
  min-width: 46px;
  text-align: center;
}

.stats-year-arrow {
  width: 32px;
  height: 32px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: transparent;
  color: var(--ink-dim);
  font-size: 0.9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: border-color 0.15s, color 0.15s;
}

.stats-year-arrow:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

.stats-year-arrow:disabled {
  opacity: 0.25;
  cursor: default;
}

/* ---- Stats: Hero Number ---- */
.stats-hero-number {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.stats-hero-number strong {
  color: var(--ink);
  font-size: 1.4rem;
  font-weight: 900;
  line-height: 1;
  letter-spacing: -0.02em;
}

.stats-hero-number span {
  color: var(--ink-dim);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ---- Stats: Meta Row ---- */
.stats-meta-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 6px 0;
  min-width: 0;
}

.stats-meta-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  text-align: center;
  min-width: 0;
  overflow: hidden;
}

.stats-meta-item span {
  color: var(--ink-dim);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.stats-meta-item strong {
  color: var(--ink);
  font-size: 1.05rem;
  font-weight: 850;
  letter-spacing: -0.01em;
}

.stats-meta-item small {
  color: var(--ink-muted);
  font-size: 0.66rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

/* Stats KPI row — compact cards above chart (deprecated, keep for compatibility) */
.stats-kpi-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}

.stats-kpi {
  display: grid;
  grid-template-columns: 80px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  backdrop-filter: blur(12px);
}

.stats-kpi span {
  color: var(--ink-dim);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.stats-kpi strong {
  color: var(--ink);
  font-size: 1.1rem;
  font-weight: 850;
  letter-spacing: -0.01em;
}

.stats-kpi small {
  color: var(--ink-dim);
  font-size: 0.7rem;
  font-weight: 650;
  text-align: right;
}

.hero--stats-full .hero__panel {
  background: transparent;
  border: 0;
  box-shadow: none;
  backdrop-filter: none;
}

.hero--stats-full .hero__panel-body {
  display: grid;
  gap: 12px;
  padding: 0;
}

.hero--stats-full .stats-kpi-row {
  gap: 10px;
  margin-bottom: 0;
}

.hero--stats-full .stats-kpi,
.hero--stats-full .chart-block,
.hero--stats-full .month-records {
  border-radius: var(--radius-sm);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.045), transparent 42%),
    var(--bg-card);
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.22);
}

.hero--stats-full .stats-kpi {
  position: relative;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "label meta"
    "value value";
  padding: 14px 16px;
  overflow: hidden;
}

.hero--stats-full .stats-kpi::before {
  content: "";
  position: absolute;
  left: 0;
  top: 12px;
  bottom: 12px;
  width: 3px;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--blue), var(--accent));
}

.hero--stats-full .stats-kpi span {
  grid-area: label;
  font-size: 0.68rem;
}

.hero--stats-full .stats-kpi strong {
  grid-area: value;
  font-size: clamp(1.25rem, 2vw, 1.65rem);
}

.hero--stats-full .stats-kpi small {
  grid-area: meta;
  align-self: start;
  color: var(--accent);
  font-size: 0.72rem;
}

.hero--stats-full .chart-block {
  padding: 16px;
}

.hero--stats-full .chart-block__header {
  margin-bottom: 10px;
  padding-bottom: 10px;
}

.hero--stats-full .chart-block__header h3 {
  font-size: clamp(1.1rem, 2vw, 1.35rem);
}

.hero--stats-full .year-total-inline {
  color: var(--ink-dim);
  font-size: 0.76rem;
}

.hero--stats-full .year-total-inline strong {
  color: var(--accent);
  font-size: 1rem;
}

.hero--stats-full .bar-chart {
  height: 300px;
  padding-top: 8px;
}

.hero--stats-full .month-records {
  margin-top: 0;
  padding: 0;
  overflow: hidden;
}

.hero--stats-full .month-records__header {
  padding: 13px 16px;
}

.hero--stats-full .month-records__header strong {
  font-size: 1rem;
}

[data-theme="light"] .hero--stats-full .stats-kpi,
[data-theme="light"] .hero--stats-full .chart-block,
[data-theme="light"] .hero--stats-full .month-records {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.62), transparent 48%),
    rgba(255, 255, 255, 0.76);
  box-shadow: 0 10px 28px rgba(28, 38, 58, 0.10);
}

/* Chart header right side (year total + year selector) */
.chart-block__header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.year-total-inline {
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 750;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.year-total-inline strong {
  color: var(--ink);
  font-size: 1.15rem;
  font-weight: 900;
  margin-left: 2px;
}

/* Two-column insight row */
.insight-list--row {
  grid-template-columns: 1fr 1fr;
}

/* Stats page — tighter month records spacing */
.hero__panel-body .month-records {
  margin-top: 10px;
  padding: 14px;
}

.hero__panel-body .month-records__header {
  gap: 8px;
  padding: 10px 14px;
}

.hero__panel-body .month-records__header span {
  font-size: 0.68rem;
}

.hero__panel-body .month-records__header strong {
  font-size: 0.9rem;
}

.hero__panel-body .month-records__header small {
  font-size: 0.66rem;
  white-space: nowrap;
  flex-shrink: 0;
}

.chart-block,
.month-records {
  position: relative;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, var(--overlay-dim), transparent),
    var(--bg-card);
  backdrop-filter: blur(20px);
  box-shadow: var(--shadow-card);
}

.chart-block__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.chart-block__header h3 {
  margin: 0;
  font-size: clamp(1.4rem, 2.5vw, 1.9rem);
  font-weight: 850;
}

#chartYear {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.year-select {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-pill);
  color: var(--ink-dim);
  font-size: 0.84rem;
  font-weight: 700;
}

.year-select select {
  border: 0;
  background: transparent;
  color: var(--ink);
  font-weight: 800;
  cursor: pointer;
  outline: none;
}

.year-select select option {
  background: var(--bg-elevated);
}

/* ---- Bar Chart ---- */
.bar-chart {
  position: relative;
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 16px;
  height: 340px;
  align-items: stretch;
  padding: 14px 4px 0;
}

.bar {
  position: relative;
  display: grid;
  grid-template-rows: 30px minmax(0, 1fr) 26px;
  justify-items: center;
  gap: 10px;
  height: 100%;
  min-width: 42px;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: center;
}

.bar span {
  color: var(--ink-dim);
  font-size: 0.74rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.bar i {
  position: relative;
  display: block;
  align-self: end;
  width: 12px;
  overflow: visible;
  border-radius: 999px;
  background: var(--chart-bar-bg);
  box-shadow: var(--chart-bar-shadow);
  height: var(--bar-height, 4px);
  min-height: 4px;
  transition: background 0.3s ease, box-shadow 0.3s ease;
}

.bar:hover i,
.bar:focus-visible i {
  background: var(--chart-bar-hover-bg);
  box-shadow: var(--chart-bar-hover-shadow);
}

.bar.is-active i {
  background: var(--chart-bar-hover-bg);
  box-shadow:
    0 0 0 1px rgba(255, 94, 58, 0.25),
    0 0 24px rgba(255, 94, 58, 0.2);
}

.bar small {
  align-self: start;
  color: var(--ink-muted);
  font-size: 0.76rem;
  font-weight: 700;
}

/* Tooltip on hover — monthly bars only (disabled, now uses JS floating tooltip) */
.bar::after {
  display: none;
}

/* ---- Insight List ---- */
.insight-list {
  display: grid;
  gap: 12px;
}

.insight-list article {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  box-shadow: var(--shadow-card);
  transition: transform var(--ease-out), border-color var(--ease-out);
}

.insight-list article:first-child {
  background: var(--bg-card);
  color: var(--ink);
}

.insight-list article:first-child span,
.insight-list article:first-child p {
  color: var(--ink-dim);
}

.insight-list article:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
}

.insight-list span {
  display: block;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 750;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.insight-list strong {
  display: block;
  margin-top: 8px;
  color: var(--ink);
  font-size: clamp(1.6rem, 3vw, 2.4rem);
  font-weight: 900;
  line-height: 1;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
}

.insight-list p {
  margin: 8px 0 0;
  color: var(--ink-dim);
  font-size: 0.88rem;
}

/* ---- Month Records ---- */
.month-records {
  margin-top: 20px;
  overflow: hidden;
}

.month-records__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
}

.month-records__header > div {
  display: grid;
  gap: 2px;
}

.month-records__header span {
  color: var(--ink-dim);
  font-size: 0.8rem;
  font-weight: 700;
}

.month-records__header strong {
  font-size: 1.3rem;
  font-weight: 850;
}

.month-records__header small {
  color: var(--ink-dim);
  font-size: 0.84rem;
  font-weight: 650;
}

.month-detail-chart {
  display: flex;
  align-items: end;
  justify-content: flex-start;
  gap: 14px;
  min-height: 160px;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 14px 16px 12px;
  scrollbar-color: var(--overlay) transparent;
}

.month-detail-chart::-webkit-scrollbar {
  height: 4px;
}

.month-detail-chart::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 4px;
}

.month-detail-chart.is-sparse {
  justify-content: center;
}

.month-activity-bar {
  position: relative;
  display: grid;
  grid-template-rows: minmax(0, 1fr) 24px;
  justify-items: center;
  gap: 6px;
  flex: 0 0 44px;
  width: 44px;
  min-width: 44px;
  height: 140px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink-dim);
  cursor: pointer;
  text-align: center;
}

div.month-activity-bar {
  cursor: default;
}

.month-activity-bar i {
  position: relative;
  display: block;
  align-self: end;
  width: 11px;
  overflow: visible;
  border-radius: 999px;
  background: var(--chart-bar-bg);
  box-shadow: var(--chart-bar-shadow);
  height: var(--activity-height, 6px);
  min-height: 6px;
  transition: background 0.3s ease, box-shadow 0.3s ease;
}

.month-activity-bar:hover i,
.month-activity-bar:focus-visible i {
  background: var(--chart-bar-hover-bg);
  box-shadow: var(--chart-bar-hover-shadow);
}

.month-activity-bar small {
  align-self: start;
  color: var(--ink-muted);
  font-size: 0.72rem;
  font-weight: 700;
}

.month-records .empty--compact {
  background: transparent;
}

/* ---- Route SVG map rendering in dark theme ---- */
.route-svg {
  display: block;
  width: 100%;
}

.route-svg--large,
.route-svg--mini {
  height: 100%;
}

/* SVG route maps now use dark theme colors natively via app.js */

.route-empty {
  display: grid;
  height: 100%;
  place-items: center;
  color: var(--ink-muted);
  font-weight: 650;
}

/* ---- Footer ---- */
.footer {
  padding: 28px 20px 42px;
  color: var(--ink-muted);
  text-align: center;
  font-size: 0.84rem;
}

.footer p {
  margin: 0;
}

/* ---- Muted Utility ---- */
.muted {
  color: var(--ink-muted);
}

/* ============================================================
   Responsive Breakpoints
   ============================================================ */

@media (max-width: 1120px) {
  .record-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .race-card {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .race-card__media {
    aspect-ratio: 16 / 9;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
}

@media (max-width: 760px) {
  .leaflet-control-zoom {
    display: none !important;
  }

  .topbar {
    min-height: 68px;
  }

  .topbar__links {
    gap: 0;
  }

  .topbar__links a {
    padding-inline: 8px;
    font-size: 0.82rem;
  }

  .hero {
    min-height: 86vh;
  }

  .hero__panel {
    width: 100%;
    max-height: 40vh;
    margin: 72px 0 0;
    border-right: 0;
    border-bottom: 1px solid var(--panel-border);
  }

  .summary-strip {
    top: 68px;
    left: 0;
    right: 0;
    flex-wrap: nowrap;
    gap: 0;
    padding: 0 6px;
  }

  .summary-strip .metric {
    flex: 1 1 20%;
    min-width: 0;
    padding: 7px 4px;
    text-align: center;
  }

  .summary-strip .metric + .metric {
    border-left-color: rgba(255, 255, 255, 0.08);
  }

  .summary-strip .metric::before,
  .summary-strip .metric small {
    display: none;
  }

  .summary-strip .metric__label {
    overflow: hidden;
    font-size: 0.52rem;
    line-height: 1.1;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .summary-strip .metric strong {
    margin-top: 2px;
    font-size: clamp(0.68rem, 2.8vw, 0.84rem);
    line-height: 1.1;
  }

  .hero__panel-body .race-card {
    grid-template-columns: 96px minmax(0, 1fr);
    min-height: 96px;
    max-height: 100px;
    border-radius: var(--radius-sm);
    contain-intrinsic-size: 100px;
    scroll-snap-align: start;
  }

  .hero__panel-body .race-card__media {
    height: 100%;
    aspect-ratio: auto;
    border-right: 1px solid var(--line);
    border-bottom: 0;
  }

  .hero__panel-body .race-route-preview,
  .hero__panel-body .race-card__fallback {
    min-height: 100%;
  }

  .hero__panel-body .race-route-preview__stats {
    display: none;
  }

  .hero__panel-body .race-card__body {
    min-width: 0;
    padding: 9px 10px;
  }

  .hero__panel-body .race-card__meta {
    margin: 0;
    gap: 6px;
    font-size: 0.62rem;
    line-height: 1.1;
  }

  .hero__panel-body .race-card h3 {
    display: -webkit-box;
    margin: 4px 0 0;
    overflow: hidden;
    font-size: 0.88rem;
    line-height: 1.22;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  .hero__panel-body .race-card__body p,
  .hero__panel-body .race-card__notes {
    display: none;
  }

  .hero__panel-body .race-card__result {
    display: flex;
    gap: 8px;
    margin-top: 6px;
    padding-top: 6px;
  }

  .hero__panel-body .race-card__result strong {
    font-size: 0.98rem;
    line-height: 1;
  }

  .hero__panel-body .race-card__result span {
    font-size: 0.68rem;
    line-height: 1.1;
    white-space: nowrap;
  }

  .hero--route-selected:not(.hero--stats-full) .hero__panel {
    position: absolute;
    top: auto;
    bottom: 8px;
    left: 0;
    right: 0;
    max-height: 118px;
    margin: 0;
    overflow: hidden;
  }

  .hero--route-selected:not(.hero--stats-full) .hero__panel-header {
    display: none;
  }

  .hero--route-selected:not(.hero--stats-full) .hero__panel-body {
    padding: 8px;
    overflow-y: auto;
    scroll-snap-type: y mandatory;
    overscroll-behavior: contain;
  }

  .hero--race-selected:not(.hero--stats-full) .panel-section-header {
    display: none;
  }

  .hero--route-selected:not(.hero--stats-full) .hero-route-item {
    grid-template-columns: 78px minmax(0, 1fr);
    min-height: 74px;
    padding: 8px;
    scroll-snap-align: start;
  }

  .hero--route-selected:not(.hero--stats-full) .hero-route-item__thumb {
    width: 78px;
    height: 54px;
  }

  .hero--route-selected:not(.hero--stats-full) .race-card {
    grid-template-columns: 96px minmax(0, 1fr);
    min-height: 96px;
    max-height: 100px;
    border-radius: var(--radius-sm);
    scroll-snap-align: start;
  }

  .hero--route-selected:not(.hero--stats-full) .race-card__media {
    height: 100%;
    aspect-ratio: auto;
    border-right: 1px solid var(--line);
    border-bottom: 0;
  }

  .hero--route-selected:not(.hero--stats-full) .race-route-preview,
  .hero--route-selected:not(.hero--stats-full) .race-card__fallback {
    min-height: 100%;
  }

  .hero--route-selected:not(.hero--stats-full) .race-route-preview__stats {
    display: none;
  }

  .hero--route-selected:not(.hero--stats-full) .race-card__body {
    min-width: 0;
    padding: 9px 10px;
  }

  .hero--route-selected:not(.hero--stats-full) .race-card__meta {
    margin: 0;
    gap: 6px;
    font-size: 0.62rem;
    line-height: 1.1;
  }

  .hero--route-selected:not(.hero--stats-full) .race-card h3 {
    display: -webkit-box;
    margin: 4px 0 0;
    overflow: hidden;
    font-size: 0.88rem;
    line-height: 1.22;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  .hero--route-selected:not(.hero--stats-full) .race-card__body p,
  .hero--route-selected:not(.hero--stats-full) .race-card__notes {
    display: none;
  }

  .hero--route-selected:not(.hero--stats-full) .race-card__result {
    display: flex;
    gap: 8px;
    margin-top: 6px;
    padding-top: 6px;
  }

  .hero--route-selected:not(.hero--stats-full) .race-card__result strong {
    font-size: 0.98rem;
    line-height: 1;
  }

  .hero--route-selected:not(.hero--stats-full) .race-card__result span {
    font-size: 0.68rem;
    line-height: 1.1;
    white-space: nowrap;
  }

  .hero--route-selected:not(.hero--stats-full) .hero-stats-overlay {
    bottom: 142px;
    right: 8px;
    left: 8px;
    max-width: none;
    pointer-events: auto;
  }

  .hero--route-selected:not(.hero--stats-full) .hero-stats-overlay__values {
    overflow-x: auto;
  }

  .hero--route-selected:not(.hero--stats-full) .hero-stats-overlay__item {
    min-width: 74px;
    padding: 8px 9px;
  }

  .hero--route-selected:not(.hero--stats-full) .hero-stats-overlay__item strong {
    font-size: 0.88rem;
  }

  .hero--route-selected:not(.hero--stats-full) .hero-stats-overlay__item small {
    font-size: 0.64rem;
  }

  .hero--route-selected:not(.hero--stats-full) .hero-stats-overlay__chart {
    height: 64px;
  }

  .hero--stats-full {
    width: 100%;
    max-width: 100vw;
    min-height: 100vh;
    overflow-x: hidden;
  }

  .hero--stats-full .topbar {
    width: min(100% - 24px, 960px);
  }

  .hero--stats-full .hero__panel {
    flex: none;
    width: calc(100vw - 24px);
    max-width: none;
    min-width: 0;
    max-height: none;
    margin: 8px auto 16px;
    border: 0;
    border-radius: 0;
    background: transparent;
  }

  .hero--stats-full .hero__panel-body {
    min-width: 0;
    overflow-x: hidden;
    gap: 10px;
    padding: 0;
  }

  .stats-hero-number strong {
    font-size: clamp(1.1rem, 4vw, 1.4rem);
  }

  .stats-year-header {
    gap: 8px;
    padding: 2px 0 6px;
  }

  .stats-year-nav {
    gap: 4px;
  }

  .stats-year-nav strong {
    font-size: 1rem;
    min-width: 38px;
  }

  .stats-year-arrow {
    width: 26px;
    height: 26px;
    font-size: 0.75rem;
  }

  .stats-hero-number span {
    font-size: 0.55rem;
  }

  .stats-meta-row {
    gap: 5px;
  }

  .stats-meta-item {
    padding: 8px 4px;
  }

  .stats-meta-item strong {
    font-size: 0.9rem;
  }

  .stats-meta-item small {
    font-size: 0.6rem;
  }

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

  .stats-kpi {
    gap: 5px;
    min-width: 0;
    padding: 12px;
  }

  .hero--stats-full .stats-kpi span {
    font-size: 0.58rem;
  }

  .hero--stats-full .stats-kpi strong {
    font-size: clamp(0.98rem, 4.2vw, 1.22rem);
  }

  .hero--stats-full .stats-kpi small {
    font-size: 0.58rem;
    white-space: normal;
  }

  .chart-block,
  .month-records {
    min-width: 0;
    padding: 12px;
  }

  .month-records {
    overflow: hidden;
  }

  .chart-block__header {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  .chart-block__header-right {
    width: 100%;
    justify-content: space-between;
    gap: 10px;
  }

  .year-total-inline {
    white-space: normal;
  }

  .timeline-item {
    flex-basis: 82vw;
  }

  .timeline-item__body {
    min-height: 300px;
    padding: 22px;
  }

  .stats-layout {
    grid-template-columns: 1fr;
  }

  .bar-chart {
    gap: 8px;
    overflow: hidden;
    padding: 40px 0 0;
    height: 180px;
    min-width: 0;
  }

  .hero__panel-body .bar-chart {
    height: 160px;
    gap: 6px;
    min-width: 0;
    overflow: hidden;
  }

  .hero--stats-full .hero__panel-body .bar-chart {
    height: 210px;
    gap: 8px;
    overflow-x: hidden;
  }

  .bar,
  .hero__panel-body .bar {
    min-width: 0;
    overflow: hidden;
    grid-template-rows: minmax(0, 1fr) 22px;
  }

  .bar span,
  .hero__panel-body .bar span {
    font-size: 0.66rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
  }

  .bar small {
    font-size: 0.6rem;
    white-space: nowrap;
  }

  .hero--stats-full .hero__panel-body .bar {
    min-width: 0;
  }

  .hero__panel-body .bar small {
    font-size: 0.6rem;
    white-space: nowrap;
  }

  .hero__panel-body .month-records__header {
    flex-wrap: wrap;
    gap: 4px;
    padding: 8px 10px;
  }

  .hero__panel-body .month-records__header strong {
    font-size: 0.82rem;
  }

  .hero__panel-body .month-records__header small {
    font-size: 0.62rem;
  }

  .month-detail-chart,
  .month-detail-chart.is-sparse,
  .hero__panel-body .month-detail-chart,
  .hero__panel-body .month-detail-chart.is-sparse {
    justify-content: flex-start;
    gap: 6px;
    width: 100%;
    max-width: 100%;
    padding-inline: 6px;
    min-height: 100px;
  }

  .month-activity-bar,
  .hero__panel-body .month-activity-bar {
    flex-basis: 24px;
    width: 24px;
    min-width: 24px;
    height: 100px;
  }

  .month-activity-bar small {
    font-size: 0.62rem;
  }

  .month-activity-bar i {
    width: 8px;
  }
}

@media (max-width: 460px) {
  .brand span:last-child {
    display: none;
  }

  .hero__panel {
    max-height: 36vh;
  }

  .hero--stats-full .hero__panel {
    width: calc(100vw - 16px);
    max-height: none;
    margin-inline: auto;
  }

  .hero--stats-full .hero__panel-body {
    padding: 0;
  }

  .stats-kpi-row {
    grid-template-columns: 1fr;
  }

  .stats-meta-row {
    gap: 4px;
  }

  .stats-meta-item {
    padding: 6px 3px;
  }

  .stats-meta-item strong {
    font-size: 0.82rem;
  }

  .stats-meta-item span {
    font-size: 0.55rem;
  }

  .summary-strip .metric {
    padding-inline: 3px;
  }

  .timeline-item__body {
    min-height: 280px;
    padding: 18px;
  }

  .record-grid {
    grid-template-columns: 1fr;
  }

  .month-detail-chart,
  .month-detail-chart.is-sparse,
  .hero__panel-body .month-detail-chart,
  .hero__panel-body .month-detail-chart.is-sparse {
    justify-content: flex-start;
    gap: 5px;
    padding-inline: 4px;
    min-height: 90px;
  }

  .month-activity-bar,
  .hero__panel-body .month-activity-bar {
    flex-basis: 22px;
    width: 22px;
    min-width: 22px;
    height: 85px;
  }

  .month-activity-bar i {
    width: 7px;
  }

  .stats-year-header {
    gap: 4px;
  }

  .stats-year-nav {
    gap: 2px;
  }

  .stats-year-nav strong {
    font-size: 0.92rem;
    min-width: 32px;
  }

  .stats-year-arrow {
    width: 24px;
    height: 24px;
  }

  .stats-hero-number {
    gap: 3px;
  }

  .stats-hero-number strong {
    font-size: 1.05rem;
  }

  .stats-hero-number span {
    font-size: 0.52rem;
  }
}
