:root {
  --ink: #10243d;
  --ink-strong: #081629;
  --canvas: #eef4f8;
  --surface: #ffffff;
  --surface-alt: #f7fafc;
  --surface-dark: #0c1b30;
  --text: #122135;
  --muted: #607087;
  --border: rgba(16, 36, 61, 0.1);
  --shadow: 0 22px 60px rgba(16, 36, 61, 0.12);
  --cyan: #0ea5c6;
  --teal: #0f766e;
  --gold: #f59e0b;
  --orange: #f97316;
  --rose: #f43f5e;
  --sky: #38bdf8;
  --violet: #8b5cf6;
  --mint: #10b981;
  --radius-lg: 28px;
  --radius-md: 22px;
  --radius-sm: 16px;
  --sans: "Avenir Next", "Segoe UI Variable", "Trebuchet MS", sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--text);
  font-family: var(--sans);
  background:
    radial-gradient(circle at top right, rgba(14, 165, 198, 0.14), transparent 24%),
    linear-gradient(180deg, #f5f9fc, #edf4f8 34%, #eaf0f5 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 15% 15%, rgba(249, 115, 22, 0.08), transparent 18%),
    linear-gradient(135deg, transparent 0 82%, rgba(255, 255, 255, 0.3) 82% 84%, transparent 84% 100%);
  min-height: 100svh;
}

canvas {
  max-width: 100%;
  height: auto;
}

.page-shell {
  width: min(1380px, calc(100vw - 36px));
  margin: 0 auto;
  padding: 28px 0 80px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(360px, 0.95fr);
  gap: 24px;
  margin-bottom: 24px;
}

.hero-copy,
.hero-panel,
.control-panel,
.summary-strip,
.surface-card,
.insight-card,
.run-card,
.empty-state {
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.hero-copy,
.hero-panel {
  position: relative;
  overflow: hidden;
  min-height: 360px;
  border-radius: var(--radius-lg);
  animation: lift-in 560ms ease both;
  min-width: 0;
}

.hero-copy {
  padding: 42px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.1), transparent),
    linear-gradient(135deg, rgba(255, 255, 255, 0.06), transparent 50%),
    linear-gradient(145deg, #10243d, #0d2036 46%, #0a1626 100%);
  color: #f3f8fb;
}

.hero-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.hero-logo-link {
  display: inline-flex;
  border-radius: 16px;
  color: inherit;
  text-decoration: none;
}

.hero-logo-link:focus-visible {
  outline: 3px solid rgba(56, 189, 248, 0.82);
  outline-offset: 4px;
}

.hero-logo {
  width: 56px;
  height: 56px;
  object-fit: contain;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.08);
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(10px);
}

.hero-copy::before {
  content: "";
  position: absolute;
  inset: auto -18% -16% auto;
  width: 58%;
  aspect-ratio: 1;
  border-radius: 50%;
  border: 1px solid rgba(125, 211, 252, 0.18);
  box-shadow: 0 0 0 24px rgba(125, 211, 252, 0.05), 0 0 0 48px rgba(125, 211, 252, 0.04);
}

.hero-copy h1 {
  margin: 16px 0 18px;
  max-width: 12ch;
  font-family: var(--serif);
  font-size: clamp(3rem, 5vw, 5.4rem);
  line-height: 0.94;
  letter-spacing: 0;
}

.hero-copy p {
  margin: 0;
  max-width: 60ch;
  color: rgba(243, 248, 251, 0.78);
  line-height: 1.7;
  font-size: 1.03rem;
}

.eyebrow,
.panel-kicker,
.metric-label,
.run-date {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.72rem;
  font-weight: 600;
}

.eyebrow,
.hero-copy .metric-label {
  color: rgba(156, 220, 255, 0.86);
}

.hero-badges {
  margin-top: 26px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.hero-badges span {
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  color: #f3f8fb;
  border: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(10px);
}

.hero-panel {
  background:
    linear-gradient(165deg, rgba(255, 255, 255, 0.9), rgba(244, 248, 251, 0.96)),
    linear-gradient(180deg, #ffffff, #edf4f8);
}

.hero-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(16, 36, 61, 0.1), transparent 38%),
    radial-gradient(circle at top center, rgba(14, 165, 198, 0.16), transparent 36%),
    linear-gradient(155deg, transparent 0 62%, rgba(16, 36, 61, 0.04) 62% 66%, transparent 66% 100%);
}

.hero-overlay {
  position: absolute;
  inset: 22px;
  border-radius: calc(var(--radius-lg) - 10px);
  background:
    linear-gradient(180deg, rgba(14, 165, 198, 0.08), transparent 42%),
    radial-gradient(circle at 50% 110%, rgba(16, 36, 61, 0.08), transparent 44%);
  border: 1px solid rgba(16, 36, 61, 0.06);
}

.inventory-card {
  position: relative;
  z-index: 1;
  padding: 30px;
  height: 100%;
  display: grid;
  align-content: end;
}

.inventory-grid {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.inventory-grid article {
  padding: 18px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid rgba(16, 36, 61, 0.08);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55);
}

.inventory-grid strong {
  display: block;
  font-size: 1rem;
}

.inventory-grid p {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.dashboard-main {
  min-width: 0;
  margin-top: 24px;
}

.control-panel {
  position: relative;
  border-radius: var(--radius-lg);
  padding: 28px;
  margin-top: 24px;
  animation: lift-in 640ms ease both;
}

.scroll-mt {
  scroll-margin-top: 80px;
}

.sticky-nav {
  position: sticky;
  top: 0px;
  z-index: 100;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(16, 36, 61, 0.1);
  margin: 0;
  padding: 12px 24px;
  box-shadow: 0 4px 20px rgba(16, 36, 61, 0.05);
  border-radius: var(--radius-lg);
}

.nav-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-links {
  display: flex;
  gap: 16px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-links a {
  text-decoration: none;
  color: var(--muted);
  font-weight: 600;
  padding: 8px 12px;
  border-radius: 8px;
  transition: background 150ms ease, color 150ms ease;
}

.nav-links a:hover, .nav-links a.active {
  background: rgba(14, 165, 198, 0.1);
  color: var(--cyan);
}

.nav-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--ink);
  padding: 8px;
}

.condensed-calendar-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.condensed-run-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(16, 36, 61, 0.04);
  transition: transform 150ms ease;
  cursor: pointer;
}

.condensed-run-item:hover {
  transform: translateY(-1px);
  border-color: rgba(14, 165, 198, 0.3);
}

.condensed-run-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.condensed-run-icon {
  font-size: 1.3rem;
}

.condensed-run-date {
  font-weight: 600;
  color: var(--ink);
}

.condensed-run-metrics {
  display: flex;
  gap: 18px;
  align-items: center;
}

.condensed-run-distance {
  font-weight: 700;
  color: var(--cyan);
}

@media (max-width: 768px) {
  .nav-toggle {
    display: block;
  }
  .nav-links {
    display: none;
    flex-direction: column;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--surface);
    padding: 16px;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    box-shadow: 0 10px 20px rgba(16, 36, 61, 0.1);
    z-index: 90;
  }
  .nav-links.open {
    display: flex;
  }
}

.panel-header h2,
.summary-strip h2,
.section-header h2,
.empty-state h2 {
  margin: 8px 0 10px;
  font-size: 1.78rem;
}

.panel-header p {
  margin: 0;
}

.muted {
  color: var(--muted);
}

.upload-form {
  margin-top: 24px;
  display: grid;
  gap: 18px;
}

.field {
  display: grid;
  gap: 10px;
}

.field span {
  font-size: 0.92rem;
  font-weight: 600;
}

.field input,
.field select {
  width: 100%;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid rgba(16, 36, 61, 0.1);
  background: var(--surface-alt);
  color: var(--text);
  font: inherit;
  transition: border-color 180ms ease, transform 180ms ease, box-shadow 180ms ease;
}

.field-file input {
  padding: 18px 16px;
}

.field input:focus,
.field select:focus {
  outline: none;
  border-color: rgba(14, 165, 198, 0.4);
  box-shadow: 0 0 0 4px rgba(14, 165, 198, 0.12);
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.setup-details {
  border-radius: 16px;
  border: 1px solid rgba(16, 36, 61, 0.1);
  background: var(--surface-alt);
  padding: 12px;
}

.setup-details summary {
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
}

.setup-details .field-grid {
  margin-top: 12px;
}

.nested-details {
  margin-top: 18px;
  background: rgba(255, 255, 255, 0.4);
  border-color: rgba(16, 36, 61, 0.05);
}

.optional-hint-text {
  margin: 16px 0 12px;
  font-size: 0.9rem;
  line-height: 1.4;
}

.optional-hint {
  font-weight: 500;
  font-style: italic;
  color: var(--muted);
  font-size: 0.9em;
  margin-left: 6px;
}

.time-input-group {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.time-separator {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--muted);
  line-height: 1;
  padding-bottom: 2px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.export-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.report-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.primary-button,
.secondary-button,
.secondary-link-button {
  border: 0;
  border-radius: 999px;
  padding: 14px 18px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.secondary-button,
.secondary-link-button {
  min-height: 46px;
}

.primary-button {
  color: #ffffff;
  background: linear-gradient(135deg, var(--cyan), #0284c7);
  box-shadow: 0 14px 28px rgba(14, 165, 198, 0.22);
}

.secondary-button,
.secondary-link-button {
  color: var(--ink);
  background: linear-gradient(180deg, #ffffff, #edf4f8);
  border: 1px solid rgba(16, 36, 61, 0.1);
}

.primary-button:hover,
.secondary-button:hover,
.secondary-link-button:hover {
  transform: translateY(-1px);
}

.secondary-link-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
}

.button-icon {
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  border-radius: 6px;
  object-fit: contain;
}

.primary-button:disabled,
.secondary-button:disabled {
  cursor: progress;
  opacity: 0.66;
  transform: none;
}

.analysis-progress {
  margin-top: 12px;
  padding: 12px;
  border-radius: 16px;
  background: rgba(14, 165, 198, 0.08);
  border: 1px solid rgba(14, 165, 198, 0.14);
}

.analysis-progress-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  color: var(--ink);
  font-size: 0.86rem;
  font-weight: 700;
}

.analysis-progress-header span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.analysis-progress-header strong {
  color: var(--teal);
  font-size: 0.82rem;
}

.analysis-progress-track {
  position: relative;
  height: 9px;
  margin-top: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(16, 36, 61, 0.12);
}

.analysis-progress-track span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--cyan));
  transition: width 160ms ease;
}

.analysis-progress.is-indeterminate .analysis-progress-track span {
  position: absolute;
  width: 42%;
  animation: progress-slide 1.1s ease-in-out infinite;
}

.dashboard {
  min-width: 0;
}

.empty-state {
  min-height: 540px;
  border-radius: var(--radius-lg);
  display: grid;
  place-items: center;
  text-align: center;
  padding: 38px;
  animation: lift-in 760ms ease both;
}

.empty-state p {
  max-width: 54ch;
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.hidden {
  display: none !important;
}

.dashboard-content {
  display: grid;
  gap: 22px;
}

.site-footer {
  margin-top: 26px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.footer-card-link {
  display: grid;
  gap: 8px;
  min-width: 0;
  padding: 20px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid var(--border);
  box-shadow: 0 14px 34px rgba(16, 36, 61, 0.08);
  color: var(--text);
  text-decoration: none;
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.footer-card-link:hover,
.footer-card-link:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(14, 165, 198, 0.32);
  box-shadow: 0 18px 42px rgba(16, 36, 61, 0.12);
}

.footer-card-link strong {
  color: var(--ink);
  font-size: 1.05rem;
}

.footer-card-link > span:last-child {
  min-width: 0;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.summary-strip,
.surface-card {
  border-radius: var(--radius-lg);
  padding: 28px;
  animation: lift-in 520ms ease both;
  min-width: 0;
}

.highlight-grid,
.pace-grid,
.run-grid,
.compact-grid,
.prediction-grid {
  display: grid;
  gap: 16px;
}

.highlight-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.highlight-card {
  padding: 18px;
  border-radius: 18px;
  background: linear-gradient(180deg, #ffffff, #f6fafc);
  border: 1px solid rgba(16, 36, 61, 0.08);
}

.metric-label,
.run-date,
.panel-kicker {
  color: var(--cyan);
}

.highlight-card strong {
  display: block;
  margin: 8px 0 8px;
  font-size: 1.45rem;
}

.highlight-card p {
  margin: 0;
  color: var(--muted);
}

.insight-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.insight-card {
  border-radius: var(--radius-md);
  padding: 24px;
  animation: lift-in 560ms ease both;
  min-width: 0;
}

.threshold-card {
  background:
    radial-gradient(circle at top right, rgba(14, 165, 198, 0.12), transparent 36%),
    linear-gradient(145deg, #10243d, #0d1d31 52%, #0b1827);
  color: #f4f9fb;
}

.threshold-card .panel-kicker {
  color: rgba(156, 220, 255, 0.82);
}

.threshold-card .muted,
.threshold-card p {
  color: rgba(244, 249, 251, 0.78);
}

.threshold-card h3 {
  margin: 16px 0 8px;
  font-size: clamp(2rem, 3.6vw, 3.1rem);
}

.fitness-stat {
  margin-top: 18px;
}

.fitness-stat strong {
  display: block;
  font-size: 3rem;
  line-height: 1;
  color: var(--ink);
}

.fitness-stat span {
  color: var(--muted);
}

.fitness-row {
  margin-top: 16px;
  padding-top: 16px;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  border-top: 1px solid rgba(16, 36, 61, 0.08);
}

.zone-list {
  margin-top: 18px;
  display: grid;
  gap: 12px;
}

.zone-item {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 14px;
  border-radius: 16px;
  background: var(--surface-alt);
  border: 1px solid rgba(16, 36, 61, 0.08);
}

.zone-item div {
  display: grid;
  gap: 4px;
}

.zone-purpose {
  color: var(--muted);
}

.section-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: end;
  margin-bottom: 20px;
}

.pace-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.compact-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.prediction-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.plan-phase-grid {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.plan-phase-card {
  padding: 16px;
  border-radius: 18px;
  background: linear-gradient(180deg, #ffffff, #f6fafc);
  border: 1px solid rgba(16, 36, 61, 0.08);
}

.plan-phase-card strong {
  display: block;
  margin: 8px 0;
  font-size: 1.3rem;
}

.plan-phase-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.limiter-layout {
  margin-top: 18px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.85fr);
  gap: 18px;
  align-items: start;
}

.limiter-layout h3 {
  margin: 0 0 12px;
  font-size: 1.05rem;
}

.question-bank-list {
  display: grid;
  gap: 10px;
}

.question-bank {
  border-radius: 16px;
  border: 1px solid rgba(16, 36, 61, 0.08);
  background: var(--surface-alt);
  overflow: hidden;
}

.question-bank summary {
  padding: 14px 16px;
  color: var(--ink);
  font-weight: 800;
  cursor: pointer;
}

.question-bank ul {
  margin: 0;
  padding: 0 18px 16px 34px;
  color: var(--muted);
  line-height: 1.55;
}

.prediction-card {
  padding: 16px;
  border-radius: 18px;
  background: linear-gradient(180deg, #ffffff, #f6fafc);
  border: 1px solid rgba(16, 36, 61, 0.08);
}

.pace-card {
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr);
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid rgba(16, 36, 61, 0.08);
  background: linear-gradient(180deg, #ffffff, #f6fafc);
}

.pace-swatch {
  background: var(--sky);
}

.pace-body {
  padding: 18px;
}

.pace-card strong {
  display: block;
  margin: 8px 0 4px;
  font-size: 1.52rem;
}

.rep-label {
  margin: 0 0 6px;
  color: var(--ink);
  font-weight: 600;
}

.pace-body .muted {
  margin: 0;
}

.chart-panel {
  border-radius: 24px;
  padding: 16px;
  background:
    radial-gradient(circle at top left, rgba(56, 189, 248, 0.12), transparent 20%),
    linear-gradient(160deg, #10243d, #0c1b30 46%, #081629);
  transition: box-shadow 200ms ease, transform 200ms ease;
  min-width: 0;
}

.chart-panel:hover {
  box-shadow: 0 12px 36px rgba(16, 36, 61, 0.12);
}

.chart-panel-light {
  margin-top: 18px;
  background:
    linear-gradient(180deg, #ffffff, #f7fafc);
  border: 1px solid rgba(16, 36, 61, 0.08);
}

.chart-window-control {
  margin: 12px 0 0;
  display: grid;
  grid-template-columns: minmax(170px, auto) minmax(180px, 1fr);
  align-items: center;
  gap: 14px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.chart-window-control input[type="range"] {
  width: 100%;
  accent-color: var(--cyan);
}

.metric-chart-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 18px;
}

#pace-histogram,
#weekly-chart,
#weekly-time-chart,
#weekly-hr-chart,
#weekly-elevation-chart,
#weekly-cadence-chart,
#weekly-vertical-oscillation-chart,
#weekly-ground-contact-chart,
#weekly-stride-length-chart,
#race-projection-chart,
#intensity-pie-chart,
#efficiency-trend-chart,
#decoupling-trend-chart,
#workout-route-map,
#workout-timeseries,
#workout-efficiency {
  width: 100%;
  height: auto;
  display: block;
}

.chart-interactive {
  cursor: crosshair;
}

.chart-tooltip {
  position: fixed;
  z-index: 80;
  max-width: min(280px, calc(100vw - 18px));
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(8, 22, 41, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #f8fafc;
  box-shadow: 0 18px 38px rgba(8, 22, 41, 0.28);
  border: 1px solid rgba(214, 233, 248, 0.16);
  pointer-events: none;
  opacity: 1;
  transition: opacity 160ms ease, transform 160ms ease;
}

.chart-tooltip.hidden {
  display: block !important;
  opacity: 0;
  transform: translateY(4px);
  pointer-events: none;
}

.chart-tooltip strong {
  display: block;
  margin-bottom: 5px;
  color: #ffffff;
  font-size: 0.88rem;
}

.chart-tooltip-lines {
  display: grid;
  gap: 3px;
  color: rgba(248, 250, 252, 0.82);
  font-size: 0.78rem;
  line-height: 1.35;
}

.chart-tooltip-pinned {
  border-color: rgba(56, 189, 248, 0.5);
  pointer-events: auto;
}

.chart-coaching-tip, .coaching-tip {
  margin-top: 14px;
  padding: 12px 16px;
  font-size: 0.88rem;
  font-style: italic;
  color: var(--muted);
  background: var(--surface-alt);
  border-left: 3px solid var(--sky);
  border-radius: 0 8px 8px 0;
  line-height: 1.4;
}

.coaching-tip {
  margin-top: 0;
  margin-bottom: 18px;
}

.route-chart-panel {
  margin-bottom: 18px;
}

.intensity-layout {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(320px, 1.05fr);
  gap: 18px;
  align-items: stretch;
  margin-top: 18px;
}

.adaptation-panel {
  padding: 18px;
  border: 1px solid rgba(16, 36, 61, 0.08);
  border-radius: 18px;
  background: #f8fafc;
}

.adaptation-panel h3 {
  margin: 0 0 8px;
}

.adaptation-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.adaptation-card {
  padding: 14px;
  border-radius: 14px;
  border: 1px solid rgba(16, 36, 61, 0.08);
  background: #ffffff;
}

.adaptation-card-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.adaptation-card-header span {
  color: var(--teal);
  font-size: 0.82rem;
  font-weight: 800;
}

.adaptation-interrupted .adaptation-card-header span {
  color: #f97316;
}

.adaptation-not-started .adaptation-card-header span {
  color: var(--muted);
}

.adaptation-progress {
  height: 9px;
  margin: 12px 0 8px;
  border-radius: 999px;
  background: #e6edf3;
  overflow: hidden;
}

.adaptation-progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--cyan));
}

.adaptation-card small {
  display: block;
  color: var(--muted);
  line-height: 1.45;
}

.efficiency-trend-header {
  margin-top: 22px;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
}

.efficiency-trend-header h3,
.detail-stack h3,
.detail-layout h3,
.export-panel h3 {
  margin: 8px 0 12px;
  font-size: 1.05rem;
}

.run-grid {
  display: grid;
  gap: 16px;
}

.run-week-group {
  display: grid;
  gap: 10px;
}

.run-week-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 0 2px;
}

.run-week-header h3 {
  margin: 0;
  font-size: 1.08rem;
}

.run-week-header span {
  color: var(--muted);
  font-weight: 700;
}

.run-week-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.run-more,
.flag-more {
  border-radius: var(--radius-sm);
  border: 1px solid rgba(16, 36, 61, 0.08);
  background: rgba(255, 255, 255, 0.62);
}

.run-more summary,
.flag-more summary {
  cursor: pointer;
  padding: 14px 16px;
  color: var(--ink);
  font-weight: 800;
}

.run-more-body,
.flag-list-nested {
  padding: 0 14px 14px;
}

.run-more-body {
  display: grid;
  gap: 16px;
}

.run-card {
  border-radius: var(--radius-sm);
  padding: 0;
  width: 100%;
  min-width: 0;
  color: inherit;
  font: inherit;
  text-align: left;
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.run-card-select {
  display: block;
  width: 100%;
  padding: 10px;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.run-card:hover,
.run-card.active {
  transform: translateY(-2px);
  border-color: rgba(14, 165, 198, 0.34);
  box-shadow: 0 24px 62px rgba(14, 165, 198, 0.16);
}

.run-card.active {
  grid-column: 1 / -1;
  outline: 3px solid rgba(14, 165, 198, 0.16);
}

.run-header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: start;
}

.run-header > div {
  min-width: 0;
}

.run-header h3 {
  display: -webkit-box;
  margin: 5px 0 0;
  overflow: hidden;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  font-size: 0.86rem;
  line-height: 1.2;
}

.run-device {
  color: var(--muted);
  max-width: 84px;
  overflow: hidden;
  overflow-wrap: anywhere;
  text-align: right;
  font-size: 0.72rem;
  line-height: 1.25;
}

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

.run-route-mini-wrap {
  margin-top: 8px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(16, 36, 61, 0.1);
  background: #081629;
}

.run-route-mini {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 5;
  pointer-events: none;
}

.metric-pill {
  min-width: 0;
  padding: 14px;
  border-radius: 16px;
  background: var(--surface-alt);
  border: 1px solid rgba(16, 36, 61, 0.08);
}

.run-card-select .metric-pill {
  padding: 7px;
  border-radius: 10px;
}

.run-card-select .metric-label {
  font-size: 0.52rem;
  letter-spacing: 0.1em;
}

.run-card-select .metric-pill strong {
  margin-top: 4px;
  font-size: 0.78rem;
  line-height: 1.15;
}

.metric-pill strong {
  display: block;
  margin-top: 6px;
  min-width: 0;
  overflow-wrap: anywhere;
}

.metric-pill small,
.table-row small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.run-badges {
  margin-top: 7px;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.run-expanded-detail {
  padding: 0 10px 10px;
}

.run-badges span {
  padding: 5px 7px;
  border-radius: 999px;
  background: rgba(14, 165, 198, 0.08);
  color: var(--ink);
  border: 1px solid rgba(14, 165, 198, 0.12);
  font-size: 0.68rem;
  font-weight: 700;
}

.flag-list {
  display: grid;
  gap: 12px;
}

.flag-card {
  padding: 16px;
  border-radius: 18px;
  background: var(--surface-alt);
  border: 1px solid rgba(16, 36, 61, 0.08);
}

.flag-card strong {
  display: block;
  margin: 8px 0 4px;
  font-size: 1.35rem;
}

.flag-card p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.flag-warning {
  border-color: rgba(244, 63, 94, 0.22);
  background: rgba(244, 63, 94, 0.06);
}

.flag-caution {
  border-color: rgba(249, 115, 22, 0.2);
  background: rgba(249, 115, 22, 0.06);
}

.flag-good {
  border-color: rgba(16, 185, 129, 0.2);
  background: rgba(16, 185, 129, 0.06);
}

.export-textarea {
  width: 100%;
  min-height: 280px;
  resize: vertical;
  border-radius: 18px;
  border: 1px solid rgba(16, 36, 61, 0.1);
  background: #f8fafc;
  color: var(--text);
  padding: 16px;
  font: 0.9rem/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.copy-status {
  min-height: 1.4em;
  margin: 10px 0 0;
  color: var(--teal);
  font-weight: 700;
}

.workout-detail {
  scroll-margin-top: 20px;
}

.detail-layout {
  margin-top: 22px;
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
  gap: 20px;
  align-items: start;
}

.detail-layout-even {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.workout-trend-flags {
  margin-top: 12px;
}

.question-bank p {
  margin: 0;
  padding: 0 16px 16px;
  color: var(--muted);
  line-height: 1.55;
}

.chart-stack,
.detail-stack {
  display: grid;
  gap: 18px;
}

.table-list {
  display: grid;
  gap: 10px;
}

.table-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 13px 14px;
  border-radius: 16px;
  background: var(--surface-alt);
  border: 1px solid rgba(16, 36, 61, 0.08);
}

.table-row > span {
  color: var(--muted);
}

.table-row > div {
  text-align: right;
}

.export-panel {
  margin-top: 22px;
}

.status {
  margin-top: 18px;
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(14, 165, 198, 0.08);
  border: 1px solid rgba(14, 165, 198, 0.12);
  color: var(--ink);
}

.status.error {
  color: #8a1d35;
  background: rgba(244, 63, 94, 0.08);
  border-color: rgba(244, 63, 94, 0.14);
}

@keyframes lift-in {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes progress-slide {
  0% {
    transform: translateX(-110%);
  }
  50% {
    transform: translateX(70%);
  }
  100% {
    transform: translateX(245%);
  }
}

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

  .control-panel {
    position: static;
  }

  .highlight-grid,
  .insight-grid,
  .pace-grid,
  .run-week-grid,
  .compact-grid,
  .prediction-grid,
  .plan-phase-grid,
  .run-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .intensity-layout,
  .limiter-layout,
  .detail-layout,
  .detail-layout-even {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .page-shell {
    width: calc(100% - 24px);
    max-width: 100%;
    padding-top: 16px;
  }

  .hero-copy,
  .inventory-card,
  .control-panel,
  .summary-strip,
  .surface-card,
  .insight-card,
  .empty-state {
    padding: 20px;
  }

  .hero,
  .training-cycle-shell,
  .run-header,
  .run-detail-shell,
  .field-grid,
  .inventory-grid,
  .site-footer,
  .highlight-grid,
  .insight-grid,
  .metric-chart-grid,
  .pace-grid,
  .run-week-grid,
  .compact-grid,
  .prediction-grid,
  .plan-phase-grid,
  .run-metrics {
    grid-template-columns: 1fr;
  }

  .section-header,
  .efficiency-trend-header,
  .run-header {
    flex-direction: column;
    align-items: start;
  }

  .export-actions {
    justify-content: flex-start;
  }

  .hero-copy h1 {
    max-width: none;
    font-size: 2.9rem;
  }

  .run-week-header {
    align-items: flex-start;
    flex-direction: column;
  }
}

/* Heart App Specific Styles */
.summary-strip {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.6fr);
  gap: 24px;
  align-items: center;
  background:
    radial-gradient(circle at top right, rgba(14, 165, 198, 0.12), transparent 34%),
    linear-gradient(180deg, #ffffff, #f7fbfd);
}

.summary-copy h2 {
  margin-bottom: 8px;
  font-size: clamp(1.7rem, 3vw, 2.5rem);
}

.mode-control {
  display: grid;
  gap: 8px;
  padding: 18px;
  border-radius: 18px;
  background: rgba(14, 165, 198, 0.06);
  border: 1px solid rgba(14, 165, 198, 0.14);
}

.mode-control label {
  color: var(--ink);
  font-size: 0.84rem;
  font-weight: 800;
}

.mode-control select {
  width: 100%;
  border: 1px solid rgba(16, 36, 61, 0.14);
  border-radius: 12px;
  background: #ffffff;
  color: var(--ink);
  padding: 11px 12px;
  font: inherit;
  font-weight: 700;
}

.mode-control p {
  margin: 0;
  line-height: 1.45;
}

.confidence-badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 28px;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(14, 165, 198, 0.1);
  color: var(--teal);
  font-size: 0.75rem;
  font-weight: 800;
}

.compact-grid-secondary {
  margin-top: 12px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.mode-section + .mode-section {
  margin-top: 28px;
  padding-top: 28px;
  border-top: 1px solid var(--border);
}

.mode-section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin: 8px 0 16px;
}

.mode-section-heading h3 {
  margin: 6px 0 0;
  font-size: 1.45rem;
}

.metric-card {
  position: relative;
  overflow: hidden;
  min-height: 126px;
}

.metric-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--cyan);
}

.metric-card.tone-good::before { background: var(--mint); }
.metric-card.tone-warn::before { background: var(--gold); }
.metric-card.tone-alert::before { background: var(--rose); }
.metric-card.tone-violet::before { background: var(--violet); }

.metric-detail {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
}

.metric-explanation {
  margin-top: 10px;
  padding-top: 9px;
  border-top: 1px solid rgba(16, 36, 61, 0.08);
  color: var(--muted);
}

.metric-explanation summary {
  width: fit-content;
  color: var(--teal);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 800;
}

.metric-explanation p {
  margin: 8px 0 0;
  font-size: 0.8rem;
  line-height: 1.45;
}

.metric-explanation strong {
  display: inline;
  margin: 0;
  font-size: inherit;
  line-height: inherit;
}

.metric-current-note {
  color: var(--ink);
}

.metric-reference {
  padding: 8px 10px;
  border-left: 3px solid rgba(15, 139, 141, 0.48);
  border-radius: 0 8px 8px 0;
  background: rgba(15, 139, 141, 0.07);
  color: #38536c;
}

.metric-reference strong {
  color: var(--ink);
}

.metric-bar {
  height: 6px;
  margin-top: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(16, 36, 61, 0.08);
}

.metric-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--cyan), var(--mint));
}

.medical-disclaimer {
  margin: 16px 0 0;
  padding: 14px 16px;
  border-radius: 14px;
  background: rgba(249, 115, 22, 0.08);
  color: #8a3f0a;
  font-weight: 700;
  line-height: 1.5;
}

.alert-banner-container {
  padding: 14px 18px;
  border-radius: 12px;
  margin-top: 12px;
  font-weight: 700;
  color: #fff;
  font-size: 1rem;
}

.alert-green { background: linear-gradient(135deg, #2e7d32, #388e3c); }
.alert-yellow { background: linear-gradient(135deg, #f9a825, #fbc02d); color: #000; }
.alert-orange { background: linear-gradient(135deg, #ef6c00, #f57c00); }
.alert-red { background: linear-gradient(135deg, #c62828, #d32f2f); }

.report-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}

/* ---- Expandable details ---- */
.expandable-details {
  margin-top: 16px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
}
.expandable-details summary {
  font-weight: 600;
  cursor: pointer;
}
.expandable-details .compact-grid {
  margin-top: 12px;
}

/* ---- Chart layout ---- */
.chart-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-top: 20px;
}
.chart-single {
  margin-top: 20px;
}
.chart-tall canvas {
  width: 100%;
  height: 280px;
  display: block;
}
.chart-panel canvas {
  width: 100%;
  height: 260px;
  display: block;
}

@media (max-width: 760px) {
  .summary-strip {
    grid-template-columns: 1fr;
  }

  .mode-section-heading {
    align-items: flex-start;
    flex-direction: column;
  }

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

@media (max-width: 1180px) {
  .compact-grid-secondary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .compact-grid-secondary {
    grid-template-columns: 1fr;
  }
}

/* ---- Range slider ---- */
.explorer-navigation {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
}

.navigation-label,
.timeline-start-field span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.selection-readout {
  min-width: 220px;
  padding: 12px 14px;
  border: 1px solid rgba(245, 158, 11, 0.24);
  border-radius: 14px;
  background: rgba(245, 158, 11, 0.07);
  text-align: right;
}

.selection-readout strong {
  display: block;
  margin-top: 4px;
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.95rem;
}

.range-slider-wrapper {
  margin-top: 14px;
  padding: 12px 4px 6px;
}

.range-slider {
  position: relative;
  height: 46px;
  user-select: none;
  touch-action: none;
  border-radius: 12px;
}

.range-slider:focus-within {
  box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.18);
}

.range-track {
  position: absolute;
  top: 50%;
  left: 1px;
  right: 1px;
  height: 12px;
  transform: translateY(-50%);
  background: #dde5ed;
  border: 1px solid rgba(16, 36, 61, 0.08);
  border-radius: 999px;
}

.range-bar {
  position: absolute;
  top: 50%;
  height: 18px;
  transform: translateY(-50%);
  background: linear-gradient(90deg, #f59e0b, #fbbf24);
  border-radius: 999px;
  box-shadow: 0 2px 8px rgba(180, 83, 9, 0.25);
  pointer-events: none;
  transition: left 80ms linear, width 80ms linear;
}

.range-bar::after {
  content: "";
  position: absolute;
  inset: 4px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: inherit;
}

.range-bar-magnified::before {
  content: "";
  position: absolute;
  top: -6px;
  left: 50%;
  width: 1px;
  height: 30px;
  background: rgba(180, 83, 9, 0.72);
}

.range-position {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 46px;
  margin: 0;
  cursor: grab;
  opacity: 0.001;
  touch-action: pan-y;
}

.range-position:active {
  cursor: grabbing;
}

.range-labels {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78rem;
  color: var(--muted);
}

.range-label-window {
  font-weight: 700;
  color: #9a5b00;
}

.timeline-controls {
  display: grid;
  grid-template-columns: repeat(3, auto) minmax(150px, 1fr) repeat(4, auto);
  align-items: end;
  gap: 8px;
  margin-top: 12px;
}

.timeline-button {
  min-height: 42px;
  padding: 9px 12px;
  border: 1px solid rgba(16, 36, 61, 0.12);
  border-radius: 10px;
  background: linear-gradient(180deg, #ffffff, #edf4f8);
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 800;
}

.timeline-button:hover {
  border-color: rgba(245, 158, 11, 0.5);
  background: rgba(245, 158, 11, 0.08);
}

.timeline-start-field input {
  width: 100%;
  min-height: 42px;
  border: 1px solid rgba(16, 36, 61, 0.14);
  border-radius: 10px;
  background: #ffffff;
  color: var(--ink);
  padding: 9px 11px;
  font: 0.9rem ui-monospace, SFMono-Regular, Menlo, monospace;
}

.timeline-reset-button {
  color: var(--teal);
}

.timeline-help {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.5;
}

.zoom-presets {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.zoom-presets button {
  min-height: 34px;
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  font-size: 0.78rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease;
}
.zoom-presets button:hover {
  background: var(--surface-hover, #e0e7ff);
  border-color: var(--accent, #6366f1);
}
.zoom-presets button.active {
  background: #f59e0b;
  color: #fff;
  border-color: #f59e0b;
}

@media (max-width: 1000px) {
  .timeline-controls {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .timeline-start-field {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .explorer-navigation {
    align-items: stretch;
    flex-direction: column;
  }

  .selection-readout {
    min-width: 0;
    text-align: left;
  }

  .timeline-controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .timeline-start-field {
    grid-column: 1 / -1;
  }
}
