/* ═══ Reset & Tokens ═══ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #f2f2f7;
  --bg-elev: #ffffff;
  --card: #ffffff;
  --text: #000000;
  --text2: #3c3c43;
  --text3: #8e8e93;
  --text4: #c7c7cc;
  --border: rgba(60,60,67,0.13);
  --separator: rgba(60,60,67,0.08);
  --accent: #ff9500;
  --blue: #007aff;
  --orange: #ff9500;
  --teal: #30b0c7;
  --green: #34c759;
  --red: #ff3b30;
  --purple: #af52de;
  --pink: #ff2d92;
  --bg-rgb: 242,242,247;
  --tabbar-h: 54px;
  --radius-card: 14px;
  --radius-control: 10px;
  --shadow-card: 0 1px 3px rgba(0,0,0,0.04), 0 2px 10px rgba(0,0,0,0.04);
  --max-w: 720px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --bg-elev: #1c1c1e;
    --card: #1c1c1e;
    --text: #ffffff;
    --text2: rgba(235,235,245,0.80);
    --text3: rgba(235,235,245,0.50);
    --text4: rgba(235,235,245,0.30);
    --border: rgba(84,84,88,0.35);
    --separator: rgba(84,84,88,0.25);
    --shadow-card: 0 1px 3px rgba(0,0,0,0.3);
    --bg-rgb: 0,0,0;
    --accent: #ff9f0a;
  }
}
html, body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'SF Pro', 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  font-size: 16px;
}
body { min-height: 100dvh; padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 16px) + 16px); }
a { color: var(--accent); text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; background: none; border: none; }

/* Accessibilité — focus clavier visible sur tous les contrôles. Reste discret
   à la souris/tactile grâce à :focus-visible (vs :focus). */
button:focus-visible,
[role="tab"]:focus-visible,
[role="button"]:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

/* Respect de prefers-reduced-motion : annule transitions et animations
   non essentielles pour les utilisateurs sensibles au mouvement. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
input, select { font: inherit; color: inherit; }

/* ═══ Header ═══ */
.nav-header {
  background: var(--bg);
  padding: 14px 16px 12px;
  text-align: center;
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
}
.nav-header h1 {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.2px;
}
.nav-header h1 span { color: var(--orange); }

/* ═══ Tab bar (iOS bottom) ═══ */
.tabs-wrap {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: rgba(var(--bg-rgb), 0.88);
  backdrop-filter: saturate(180%) blur(24px);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
  border-top: 0.5px solid var(--separator);
}
.tabs {
  display: flex;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0;
  background: none;
  border-radius: 0;
  gap: 0;
  height: var(--tabbar-h);
}
.tabs button {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 6px 4px 4px;
  font-size: 10px;
  font-weight: 500;
  color: var(--text3);
  border-radius: 0;
  transition: color 0.15s;
}
.tabs button span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}
.tabs button svg { width: 24px; height: 24px; flex-shrink: 0; }
.tabs button.active { color: var(--accent); font-weight: 600; }

/* ═══ Tab content ═══ */
.tab-content { display: none; max-width: var(--max-w); margin: 0 auto; padding: 0 16px; }
.tab-content.active { display: block; }

/* ═══ Card ═══ */
.card {
  background: var(--card);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 18px;
  margin-bottom: 14px;
}

/* ═══ Section labels ═══ */
.section-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text2);
  margin-bottom: 10px;
}
.section-label svg { width: 14px; height: 14px; opacity: 0.7; }

.divider {
  height: 1px;
  background: var(--separator);
  margin: 16px 0;
}

/* ═══ Distance grid ═══ */
.dist-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(78px, 1fr));
  gap: 8px;
}
.dist-btn {
  padding: 10px 4px;
  font-size: 14px;
  font-weight: 500;
  border-radius: 8px;
  background: rgba(60,60,67,0.06);
  color: var(--text);
  transition: all 0.15s;
  text-align: center;
}
.dist-btn.active {
  background: var(--accent);
  color: white;
  font-weight: 700;
}
@media (prefers-color-scheme: dark) {
  .dist-btn { background: rgba(120,120,128,0.24); }
}

/* ═══ Time picker (h:m:s) ═══ */
.time-picker {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
}
.time-unit {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.time-unit-inner {
  display: flex;
  align-items: center;
  background: rgba(60,60,67,0.06);
  border-radius: 8px;
  padding: 2px 4px;
}
@media (prefers-color-scheme: dark) { .time-unit-inner { background: rgba(120,120,128,0.16); } }
.time-chev {
  position: relative;
  width: 26px;
  height: 44px;
  color: var(--text3);
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
}
/* Cible tactile ≥ 44 × 44 (WCAG 2.5.5) sans modifier le visuel des chevrons. */
.time-chev::before {
  content: '';
  position: absolute;
  inset: 0 -9px;
}
.time-chev:active, .time-chev:hover { color: var(--text); }
.time-val {
  width: 52px;
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-size: 28px;
  font-weight: 600;
  text-align: center;
  border: none;
  background: none;
  padding: 0;
  -moz-appearance: textfield;
  color: var(--text);
}
/* `outline: none` masquait aussi le focus clavier — on ne le retire qu'au focus
   souris/tactile pour préserver la règle :focus-visible globale. */
.time-val:focus:not(:focus-visible) { outline: none; }
.time-val::-webkit-outer-spin-button, .time-val::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.time-lbl {
  font-size: 11px;
  color: var(--text3);
  text-transform: lowercase;
}
.time-colon {
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-size: 24px;
  font-weight: 700;
  padding: 0 2px;
  margin-bottom: 18px;
  color: var(--text2);
}

/* ═══ Drum picker (touch devices) ═══ */
.drum-outer {
  position: relative;
  width: 58px;
  height: 132px;
  overflow: hidden;
  border-radius: 8px;
  background: rgba(60,60,67,0.06);
}
@media (prefers-color-scheme: dark) {
  .drum-outer { background: rgba(120,120,128,0.16); }
}
.drum-scroll {
  height: 100%;
  overflow-y: scroll;
  scroll-snap-type: y mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, black 44px, black 88px, transparent 132px);
  mask-image: linear-gradient(to bottom, transparent 0, black 44px, black 88px, transparent 132px);
}
.drum-scroll::-webkit-scrollbar { display: none; }
.drum-pad { height: 44px; }
.drum-item {
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-size: 26px;
  font-weight: 600;
  color: var(--text);
  scroll-snap-align: center;
  user-select: none;
  -webkit-user-select: none;
}
.drum-sel {
  position: absolute;
  top: 44px; left: 4px; right: 4px; height: 44px;
  border-top: 0.5px solid var(--separator);
  border-bottom: 0.5px solid var(--separator);
  border-radius: 6px;
  pointer-events: none;
  z-index: 2;
}
/* Colon vertical alignment in drum mode */
.time-picker.drum-mode { align-items: flex-start; }
.time-picker.drum-mode .time-colon {
  margin-top: 50px;  /* visually centre with drum: (132-24)/2 ≈ 54, minus label offset */
  margin-bottom: 0;
}

/* ═══ Toggle (iOS switch) ═══ */
.toggle-row {
  display: flex;
  align-items: center;
  padding: 4px 0;
}
.toggle-row > .lbl {
  flex: 1;
  font-size: 15px;
}
.toggle {
  position: relative;
  width: 51px;
  height: 31px;
  flex-shrink: 0;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle .slider {
  position: absolute;
  inset: 0;
  background: rgba(120,120,128,0.32);
  border-radius: 16px;
  cursor: pointer;
  transition: 0.25s;
}
.toggle .slider::before {
  content: '';
  position: absolute;
  width: 27px;
  height: 27px;
  left: 2px;
  top: 2px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0,0,0,0.18);
  transition: 0.25s;
}
.toggle input:checked + .slider { background: var(--green); }
.toggle input:checked + .slider::before { transform: translateX(20px); }

/* ═══ Slider (iOS range) ═══ */
input[type=range] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: rgba(120,120,128,0.24);
  border-radius: 2px;
}
input[type=range]:focus:not(:focus-visible) { outline: none; }
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 28px;
  height: 28px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(0,0,0,0.18), 0 0 0 0.5px rgba(0,0,0,0.05);
  cursor: pointer;
}
input[type=range]::-moz-range-thumb {
  width: 28px;
  height: 28px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(0,0,0,0.18);
  border: none;
  cursor: pointer;
}

/* ═══ Segmented control ═══ */
.segmented {
  display: flex;
  background: rgba(118,118,128,0.12);
  border-radius: 9px;
  padding: 3px;
  gap: 2px;
  margin-bottom: 12px;
}
.segmented button {
  flex: 1;
  padding: 7px 4px;
  font-size: 13px;
  font-weight: 500;
  border-radius: 7px;
  color: var(--text);
  transition: background 0.2s;
}
.segmented button.active {
  background: var(--bg-elev);
  font-weight: 600;
  box-shadow: 0 3px 8px rgba(0,0,0,0.12), 0 1px 3px rgba(0,0,0,0.04);
}
@media (prefers-color-scheme: dark) {
  .segmented { background: rgba(118,118,128,0.24); }
}

/* ═══ Buttons ═══ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 22px;
  font-size: 15px;
  font-weight: 600;
  border-radius: 12px;
  transition: opacity 0.15s;
}
.btn:active { opacity: 0.7; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-orange { background: var(--orange); color: #fff; }
.btn-bordered {
  background: rgba(255,149,0,0.1);
  color: var(--accent);
}
.btn-sm { padding: 6px 14px; font-size: 13px; border-radius: 8px; }

/* ═══ VDOT Badge ═══ */
.vdot-badge {
  text-align: center;
  padding: 14px 0 4px;
}
.vdot-badge .label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text3);
  letter-spacing: 0.8px;
}
.vdot-badge .value {
  font-size: 56px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.05;
  font-family: -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
  letter-spacing: -1.5px;
  margin-top: 2px;
}
.vdot-badge .sub {
  font-size: 12px;
  color: var(--text4);
  margin-top: 2px;
}

/* ═══ Zone cards (Training paces) ═══ */
.zones-wrap { padding: 4px 0; }
.zone-card {
  display: block;
  background: var(--zone-bg, rgba(52,199,89,0.08));
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 10px;
  transition: background 0.2s;
}
.zone-card:hover { filter: brightness(1.02); }
.zone-head {
  display: flex;
  align-items: center;
  gap: 12px;
}
.zone-bar {
  width: 4px;
  height: 48px;
  background: var(--zone-color, var(--green));
  border-radius: 3px;
  flex-shrink: 0;
}
.zone-info { flex: 1; min-width: 0; }
.zone-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 16px;
  font-weight: 600;
}
.zone-desc {
  font-size: 12px;
  color: var(--text2);
  margin-top: 2px;
}
.zone-pace {
  text-align: right;
  flex-shrink: 0;
}
.zone-pace .val {
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-size: 19px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.zone-pace .val .unit { font-size: 11px; color: var(--text3); font-weight: 500; margin-left: 1px; }
.zone-pace .range {
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-size: 11px;
  color: var(--text3);
  margin-top: 1px;
}
.zone-chev {
  color: var(--text3);
  font-size: 10px;
  margin-left: 2px;
}
.zone-detail { display: none; margin-top: 10px; }
.zone-card.open .zone-detail { display: block; }

.hr-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  margin-top: 8px;
  background: rgba(255,59,48,0.08);
  border-radius: 999px;
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
}
.hr-badge .heart { color: rgba(255,59,48,0.7); font-size: 11px; }
.hr-badge .pct { color: var(--text2); font-family: -apple-system, system-ui, sans-serif; font-size: 11px; font-weight: 400; }

.interval-table {
  background: rgba(60,60,67,0.04);
  border-radius: 8px;
  padding: 8px 12px;
  margin-top: 6px;
}
@media (prefers-color-scheme: dark) { .interval-table { background: rgba(120,120,128,0.12); } }
.interval-row {
  display: flex;
  justify-content: space-between;
  padding: 3px 0;
  font-size: 14px;
}
.interval-row .d { color: var(--text2); }
.interval-row .t {
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.interval-head {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--separator);
}

/* ═══ Race predictions table ═══ */
.race-table { width: 100%; border-collapse: collapse; }
.race-table tr.head th {
  font-size: 11px;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 500;
  padding: 8px 4px;
  text-align: right;
}
.race-table tr.head th:first-child { text-align: left; }
.race-table td {
  padding: 10px 4px;
  font-size: 15px;
  border-bottom: 0.5px solid var(--separator);
}
.race-table td:first-child { font-weight: 500; }
.race-table td.mono {
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.race-table td.hr-col {
  color: rgba(255,59,48,0.85);
  text-align: right;
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-weight: 500;
}

/* ═══ Projection ═══ */
.proj-hero {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 14px 0;
}
.proj-hero .left, .proj-hero .right {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.proj-hero .v {
  font-size: 42px;
  font-weight: 700;
  font-family: -apple-system, system-ui;
  font-variant-numeric: tabular-nums;
  letter-spacing: -1px;
  line-height: 1;
}
.proj-hero .v.now { color: var(--accent); }
.proj-hero .v.target { color: var(--green); }
.proj-hero .cap { font-size: 11px; color: var(--text3); text-transform: uppercase; letter-spacing: 0.5px; }
.proj-hero .arrow { font-size: 20px; color: var(--text4); }
.proj-gain {
  text-align: center;
  font-size: 13px;
  color: var(--green);
  font-weight: 600;
  margin-top: 2px;
}

/* ═══ Chart canvas ═══ */
canvas { width: 100%; height: 180px; display: block; border-radius: 8px; }
#projChart { height: 220px; }

/* ═══ Empty state ═══ */
.empty-state {
  text-align: center;
  padding: 56px 20px;
  color: var(--text2);
}
.empty-state .icon { font-size: 44px; opacity: 0.35; margin-bottom: 12px; }
.empty-state h3 { font-size: 17px; font-weight: 600; margin-bottom: 6px; }
.empty-state p { font-size: 13px; line-height: 1.5; max-width: 320px; margin: 0 auto; color: var(--text3); }

/* ═══ Estimator ═══ */
.est-hero {
  text-align: center;
  padding: 10px 0;
}
.est-hero .time {
  font-size: 44px;
  font-weight: 700;
  color: var(--orange);
  font-variant-numeric: tabular-nums;
  letter-spacing: -1px;
  line-height: 1;
}
.est-hero .pace { font-size: 13px; color: var(--text3); margin-top: 4px; }
.est-hero .label { font-size: 11px; color: var(--text3); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 3px; }
.est-stats {
  display: flex;
  gap: 12px;
  justify-content: space-around;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 0.5px solid var(--separator);
}
.est-stat { text-align: center; flex: 1; }
.est-stat .val {
  font-size: 17px;
  font-weight: 700;
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-variant-numeric: tabular-nums;
}
.est-stat .lbl { font-size: 10px; color: var(--text3); text-transform: uppercase; letter-spacing: 0.5px; margin-top: 2px; }

.seg-row {
  display: grid;
  grid-template-columns: 32px 100px 64px 1fr;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: background 0.12s;
}
.seg-row:hover { background: rgba(60,60,67,0.06); }
.seg-row.selected { background: rgba(255,149,0,0.14); }
.seg-row .km { font-weight: 600; }
.seg-row .grad { font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 11px; }
.seg-row .pace {
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-weight: 700;
  text-align: right;
}
.seg-row .cum {
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  color: var(--text3);
  text-align: right;
  font-size: 12px;
}
.seg-head {
  display: grid;
  grid-template-columns: 32px 100px 64px 1fr;
  gap: 8px;
  padding: 0 8px 6px;
  font-size: 10px;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 0.5px solid var(--separator);
  margin-bottom: 4px;
}
.seg-head > *:nth-child(3), .seg-head > *:nth-child(4) { text-align: right; }

/* ═══ Footer ═══ */
.footer {
  text-align: center;
  padding: 32px 16px;
  font-size: 12px;
  color: var(--text3);
}

/* ═══ Responsive ═══ */
@media (max-width: 520px) {
  .tabs button { font-size: 9.5px; }
  .tabs button svg { width: 22px; height: 22px; }
  .tab-content { padding: 0 10px; }
  .card { padding: 14px; border-radius: 12px; margin-bottom: 10px; }

  .section-label { font-size: 12px; margin-bottom: 8px; }
  .divider { margin: 12px 0; }

  /* Distance grid — fit more columns on narrow screens */
  .dist-grid { grid-template-columns: repeat(4, 1fr); gap: 6px; }
  .dist-btn { padding: 8px 2px; font-size: 13px; border-radius: 7px; }

  /* Time/Pace picker — make it compact */
  .time-picker { gap: 2px; }
  .time-unit-inner { padding: 1px 2px; }
  .time-chev { width: 18px; height: 38px; font-size: 16px; }
  .time-val {
    width: 36px;
    font-size: 22px;
  }
  .time-lbl { font-size: 10px; }
  .time-colon {
    font-size: 20px;
    padding: 0 1px;
    margin-bottom: 16px;
  }

  /* Pace label alignment */
  #pacePicker ~ span { font-size: 13px; margin-bottom: 14px; }

  /* VDOT badge */
  .vdot-badge { padding: 8px 0 2px; }
  .vdot-badge .value { font-size: 46px; letter-spacing: -1px; }
  .vdot-badge .label { font-size: 10px; }

  /* Segmented control */
  .segmented button { font-size: 12px; padding: 6px 2px; }

  /* Zone cards compact */
  .zone-card { padding: 10px 12px; border-radius: 10px; margin-bottom: 8px; }
  .zone-bar { height: 40px; }
  .zone-title { font-size: 15px; }
  .zone-desc { font-size: 11px; }
  .zone-pace .val { font-size: 17px; }
  .zone-pace .range { font-size: 10px; }
  .hr-badge { font-size: 11px; padding: 3px 8px; }
  .hr-badge .pct { font-size: 10px; }

  /* Race table */
  .race-table td { padding: 8px 3px; font-size: 13.5px; }
  .race-table tr.head th { font-size: 10px; padding: 6px 3px; }
  .race-table td:first-child { font-size: 13px; }

  /* Projection hero */
  .proj-hero { gap: 12px; padding: 10px 0; }
  .proj-hero .v { font-size: 30px; letter-spacing: -0.5px; }
  .proj-hero .cap { font-size: 10px; }
  .proj-hero .arrow { font-size: 16px; }

  /* Estimator */
  .est-hero .time { font-size: 34px; }
  .est-stat .val { font-size: 14px; }
  .est-stat .lbl { font-size: 9px; }

  /* Segment rows */
  .seg-row, .seg-head {
    grid-template-columns: 24px 1fr 52px 56px;
    gap: 4px;
    padding: 5px 6px;
    font-size: 12px;
  }
  .seg-row .grad { font-size: 10px; }

  /* Buttons */
  .btn { padding: 11px 18px; font-size: 14px; }
  .btn-sm { padding: 5px 12px; font-size: 12px; }

  /* Canvas */
  canvas { height: 160px; }

  /* Footer */
  .footer { padding: 20px 12px; font-size: 11px; }
}

@media (max-width: 360px) {
  .tabs button { font-size: 9px; }
  .tabs button svg { width: 20px; height: 20px; }
  .dist-grid { grid-template-columns: repeat(3, 1fr); }
  .time-val { width: 32px; font-size: 20px; }
  .time-chev { width: 16px; }
  .drum-outer { width: 46px; }
  .drum-item { font-size: 22px; }
}

/* ═══ Force dark theme ═══ */
html[data-theme="dark"] {
  --bg: #000000; --bg-elev: #1c1c1e; --card: #1c1c1e;
  --text: #ffffff; --text2: rgba(235,235,245,0.80);
  --text3: rgba(235,235,245,0.50); --text4: rgba(235,235,245,0.30);
  --border: rgba(84,84,88,0.35); --separator: rgba(84,84,88,0.25);
  --shadow-card: 0 1px 3px rgba(0,0,0,0.3);
  --bg-rgb: 0,0,0;
}
html[data-theme="dark"] .dist-btn { background: rgba(120,120,128,0.24); }
html[data-theme="dark"] .time-unit-inner { background: rgba(120,120,128,0.16); }
html[data-theme="dark"] .drum-outer { background: rgba(120,120,128,0.16); }
html[data-theme="dark"] .segmented { background: rgba(118,118,128,0.24); }
html[data-theme="dark"] .interval-table { background: rgba(120,120,128,0.12); }

/* ═══ Force light theme ═══ */
html[data-theme="light"] {
  --bg: #f2f2f7; --bg-elev: #ffffff; --card: #ffffff;
  --text: #000000; --text2: #3c3c43;
  --text3: #8e8e93; --text4: #c7c7cc;
  --border: rgba(60,60,67,0.13); --separator: rgba(60,60,67,0.08);
  --shadow-card: 0 1px 3px rgba(0,0,0,0.04), 0 2px 10px rgba(0,0,0,0.04);
  --bg-rgb: 242,242,247;
}
html[data-theme="light"] .dist-btn { background: rgba(60,60,67,0.08); }
html[data-theme="light"] .time-unit-inner { background: rgba(60,60,67,0.06); }
html[data-theme="light"] .drum-outer { background: rgba(60,60,67,0.06); }
html[data-theme="light"] .segmented { background: var(--bg-elev); }
html[data-theme="light"] .interval-table { background: rgba(60,60,67,0.04); }

/* ═══ Objectif Course ═══════════════════════════════════════ */

/* Distance pills (sélecteur défilable) */
.goal-dist-scroll {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 10px 0 4px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.goal-dist-scroll::-webkit-scrollbar { display: none; }

.dist-pill {
  flex-shrink: 0;
  padding: 7px 14px;
  border-radius: 20px;
  border: none;
  background: rgba(120,120,128,0.14);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.dist-pill.active {
  background: var(--accent);
  color: #fff;
}

/* Config rows */
.goal-config-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  gap: 10px;
}
.goal-config-lbl {
  font-size: 14px;
  font-weight: 500;
  color: var(--text2);
  white-space: nowrap;
}
.goal-session-btns {
  display: flex;
  gap: 6px;
}
.goal-session-btns button {
  width: 38px;
  padding: 7px 0;
  border-radius: 8px;
  border: none;
  background: rgba(120,120,128,0.14);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.goal-session-btns button.active {
  background: var(--accent);
  color: #fff;
}

/* Countdown card */
.goal-countdown-card {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  gap: 0;
}
.goal-cd-left {
  text-align: center;
  flex: 0 0 80px;
}
.goal-cd-num {
  font-size: 38px;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.goal-cd-wlbl {
  font-size: 11px;
  color: var(--text2);
  margin-top: 3px;
}
.goal-cd-days {
  font-size: 11px;
  color: var(--text3);
  margin-top: 2px;
}
.goal-cd-sep {
  width: 1px;
  height: 52px;
  background: var(--separator);
  margin: 0 16px;
  flex-shrink: 0;
}
.goal-cd-right { flex: 1; min-width: 0; }
.goal-cd-race {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.goal-cd-trophy { font-size: 14px; }
.goal-cd-dist { font-size: 15px; font-weight: 600; }
.goal-cd-dot { color: var(--text3); }
.goal-cd-date { font-size: 14px; color: var(--text2); }
.goal-cd-detail { font-size: 12px; color: var(--text3); }

/* Info cards partagées */
.goal-info-card { padding: 16px; }
.goal-info-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
}
.goal-needs-calc {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text2);
}

/* Temps actuel → projeté */
.goal-times-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.goal-time-col {
  text-align: center;
  flex: 1;
}
.goal-time-cap {
  font-size: 11px;
  color: var(--text3);
  margin-bottom: 2px;
}
.goal-time-val {
  font-family: ui-monospace, monospace;
  font-size: 22px;
  font-weight: 700;
  line-height: 1.1;
}
.goal-time-pace {
  font-family: ui-monospace, monospace;
  font-size: 11px;
  color: var(--text3);
  margin-top: 2px;
}
.goal-time-gain {
  font-family: ui-monospace, monospace;
  font-size: 12px;
  color: var(--green);
  margin-top: 3px;
}
.goal-arrow {
  font-size: 20px;
  color: var(--green);
  flex-shrink: 0;
}
.goal-proj-basis {
  font-size: 11px;
  color: var(--text3);
  text-align: center;
  margin-top: 8px;
}

/* Allures clés */
.goal-paces-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.goal-pace-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border-radius: 8px;
}
.goal-pace-bar {
  width: 3px;
  height: 32px;
  border-radius: 2px;
  flex-shrink: 0;
}
.goal-pace-val {
  font-family: ui-monospace, monospace;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.2;
}
.goal-pace-lbl {
  font-size: 11px;
  color: var(--text3);
  margin-top: 2px;
}

/* Semaine type */
.goal-sessions { display: flex; flex-direction: column; }
.goal-session { }
.goal-session-div { border-bottom: 0.5px solid var(--separator); }
.goal-session-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
}
.goal-session-clickable { cursor: pointer; }
.goal-snum {
  font-size: 12px;
  font-weight: 700;
  color: var(--text3);
  width: 22px;
  text-align: center;
  flex-shrink: 0;
}
.goal-sbar {
  width: 3px;
  height: 36px;
  border-radius: 2px;
  flex-shrink: 0;
}
.goal-sinfo { flex: 1; min-width: 0; }
.goal-slabel { font-size: 14px; font-weight: 500; }
.goal-sdur   { font-size: 12px; color: var(--text3); margin-top: 1px; }
.goal-schev  { font-size: 11px; color: var(--text3); }

.goal-session-detail {
  padding: 4px 0 12px 32px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Workout card */
.goal-workout {
  border-radius: 10px;
  background: var(--wc, var(--accent));
  background: color-mix(in srgb, var(--wc, var(--accent)) 4%, transparent);
  border: 1px solid color-mix(in srgb, var(--wc, var(--accent)) 12%, transparent);
  padding: 12px;
}
.goal-workout-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 5px;
}
.goal-workout-title {
  font-size: 14px;
  font-weight: 600;
}
.goal-workout-vol {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 20px;
  white-space: nowrap;
}
.goal-workout-desc {
  font-size: 13px;
  color: var(--text2);
  line-height: 1.45;
}

/* Interval table inside workout */
.goal-intv-table {
  margin-top: 8px;
  border-radius: 6px;
  overflow: hidden;
}
.goal-intv-head {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: .3px;
}
.goal-intv-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  padding: 5px 8px;
  font-family: ui-monospace, monospace;
  font-size: 12px;
  margin-top: 3px;
  border-radius: 5px;
}

/* Phases de préparation */
.goal-phases-bar {
  display: flex;
  gap: 3px;
  border-radius: 6px;
  overflow: hidden;
  height: 28px;
  margin-bottom: 16px;
}
.goal-phase-seg {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  opacity: 0.82;
}
.goal-phase-seg-lbl {
  font-size: 9px;
  font-weight: 700;
  color: #fff;
  overflow: hidden;
  white-space: nowrap;
}
.goal-phases-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.goal-phase-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.goal-phase-tl {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 8px;
  flex-shrink: 0;
  padding-top: 4px;
}
.goal-phase-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.goal-phase-line {
  width: 2px;
  flex: 1;
  min-height: 16px;
  margin: 3px 0;
}
.goal-phase-body {
  flex: 1;
  padding-bottom: 12px;
}
.goal-phase-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 3px;
}
.goal-phase-name { font-size: 14px; font-weight: 600; }
.goal-phase-badge {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 20px;
}
.goal-phase-advice {
  font-size: 12px;
  color: var(--text3);
  line-height: 1.4;
}

/* Hover GPX (remplace les onmouseenter/leave inline retirés pour la CSP) */
.act-row:hover { opacity: 0.8; }
.act-del:hover { background: var(--bg2); }

/* Dark overrides */
html[data-theme="dark"] .dist-pill { background: rgba(120,120,128,0.24); }
html[data-theme="dark"] .goal-session-btns button { background: rgba(120,120,128,0.24); }
@media (prefers-color-scheme: dark) {
  .dist-pill { background: rgba(120,120,128,0.24); }
  .goal-session-btns button { background: rgba(120,120,128,0.24); }
}
