/* Allure : une colonne mobile, un « bandeau de séance » coloré par intensité comme élément fort, le reste sobre */
:root {
  --bg: #edf1f6;
  --surface: #ffffff;
  --surface-2: #f4f6fa;
  --ink: #13233d;
  --ink-2: #44546b;
  --ink-3: #6f7d93;
  --line: #d8dfe9;
  --accent: #2350e6;
  --accent-ink: #ffffff;
  --accent-soft: #e3e9fd;
  --z-easy: #12927d;
  --z-mod: #cf8417;
  --z-hard: #d93d47;
  --z-race: #6c43d6;
  --z-rest: #b3bdca;
  --z-base: #c8d2df;
  --warn: #b86e0a;
  --bad: #c9323c;
  --good: #12927d;
  --f-display: "Barlow Semi Condensed", "Arial Narrow", system-ui, -apple-system, sans-serif;
  --f-body: "Barlow", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --r-lg: 18px;
  --r-md: 12px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c1420;
    --surface: #142033;
    --surface-2: #1a273d;
    --ink: #e5ebf4;
    --ink-2: #a9b6c9;
    --ink-3: #7d8aa1;
    --line: #26354d;
    --accent: #7393ff;
    --accent-ink: #0c1420;
    --accent-soft: #1f2d4f;
    --z-easy: #2bb79d;
    --z-mod: #eea23a;
    --z-hard: #f1606a;
    --z-race: #9b7af2;
    --z-rest: #3b4b64;
    --z-base: #2d3c56;
    --warn: #eea23a;
    --bad: #f1606a;
    --good: #2bb79d;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0c1420;
  --surface: #142033;
  --surface-2: #1a273d;
  --ink: #e5ebf4;
  --ink-2: #a9b6c9;
  --ink-3: #7d8aa1;
  --line: #26354d;
  --accent: #7393ff;
  --accent-ink: #0c1420;
  --accent-soft: #1f2d4f;
  --z-easy: #2bb79d;
  --z-mod: #eea23a;
  --z-hard: #f1606a;
  --z-race: #9b7af2;
  --z-rest: #3b4b64;
  --z-base: #2d3c56;
  --warn: #eea23a;
  --bad: #f1606a;
  --good: #2bb79d;
  color-scheme: dark;
}

* { box-sizing: border-box; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--f-body);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

.wrap {
  max-width: 560px;
  margin: 0 auto;
  padding-block: 14px 110px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  display: flex;
  flex-direction: column;
  gap: 16px;
}

h1, h2, h3 { font-family: var(--f-display); margin: 0; text-wrap: balance; }
h1 { font-size: 30px; font-weight: 700; line-height: 1.05; letter-spacing: -0.01em; }
h3 { font-size: 19px; font-weight: 600; }
p { margin: 0; }
.muted { color: var(--ink-3); }
.small { font-size: 13.5px; line-height: 1.4; }
.label { font-size: 13.5px; color: var(--ink-2); font-weight: 500; margin-top: 4px; }
b { font-weight: 600; }

/* en-tête */
.top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.top > div { min-width: 0; }
.top .icon-btn:first-child { margin-left: -6px; }
.sync-line { margin-top: -10px; }
.icon-btn {
  width: 42px; height: 42px; display: grid; place-items: center; flex: none;
  border: 1px solid var(--line); background: var(--surface); border-radius: 50%; color: var(--ink-2);
}
.icon-btn:disabled { opacity: 0.35; }
.ic { width: 20px; height: 20px; }
.icon-btn.spin .ic { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.pager { display: flex; gap: 8px; }

/* séance (élément fort) */
.hero {
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 1px 0 var(--line);
}
.hero.is-skipped { opacity: 0.6; }
.hero-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.when { font-size: 14px; color: var(--ink-2); font-weight: 500; }
.hero-title { font-size: 36px; font-weight: 700; line-height: 1; letter-spacing: -0.015em; }
.pill { font-family: var(--f-display); font-weight: 600; font-size: 14px; padding: 3px 10px; border-radius: 999px; color: var(--surface); background: var(--z-rest); }
.pill.z-easy { background: var(--z-easy); }
.pill.z-mod { background: var(--z-mod); }
.pill.z-hard { background: var(--z-hard); }
.pill.z-race { background: var(--z-race); }
.pill.z-rest { background: var(--z-rest); color: var(--ink); }

.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.stats.big { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stats > div { display: flex; flex-direction: column; min-width: 0; }
.stats b { font-family: var(--f-display); font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.15; }
.stats.big b { font-size: 28px; }
.stats span { font-size: 12.5px; color: var(--ink-3); }

.profile { width: 100%; height: 64px; display: block; }
.pb { fill: var(--z-base); }
.pb.z-easy { fill: var(--z-easy); }
.pb.z-mod { fill: var(--z-mod); }
.pb.z-hard { fill: var(--z-hard); }
.pb.z-race { fill: var(--z-race); }
.hero.z-easy .pb.z-base, .hero.rest .pb.z-base { fill: color-mix(in srgb, var(--z-easy) 55%, var(--z-base)); }

.steps { display: flex; flex-direction: column; border-top: 1px solid var(--line); }
.step { display: grid; grid-template-columns: 72px minmax(0, 1fr) auto; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); align-items: baseline; }
.step .qty { font-family: var(--f-display); font-weight: 600; font-variant-numeric: tabular-nums; }
.step .lbl { color: var(--ink-2); min-width: 0; }
.step .tgt { font-variant-numeric: tabular-nums; font-size: 14.5px; text-align: right; }
.rep { display: grid; grid-template-columns: 44px minmax(0, 1fr); border-bottom: 1px solid var(--line); }
.rep-n { font-family: var(--f-display); font-weight: 700; font-size: 20px; padding-top: 7px; color: var(--ink); }
.rep-body .step:last-child { border-bottom: 0; }
.rep-body .step { grid-template-columns: 56px minmax(0, 1fr) auto; }
.step.k-work .qty, .step.k-work .tgt { color: var(--ink); font-weight: 600; }

.watch { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink-2); }
.watch .ic { width: 18px; height: 18px; }
.watch.on { color: var(--good); }
.watch.pending { color: var(--warn); }
.note { font-size: 14px; color: var(--ink-2); background: var(--surface-2); border-radius: var(--r-md); padding: 10px 12px; }
.note.warn { color: var(--warn); }

.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  min-height: 42px; padding: 0 16px; border-radius: 999px; border: 0;
  background: var(--accent); color: var(--accent-ink); font-weight: 600; font-size: 15px;
}
.btn .ic { width: 18px; height: 18px; }
.a-btn, a.btn { text-decoration: none; }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn.danger { background: var(--bad); color: #fff; }
.btn.ghost.danger { background: transparent; color: var(--bad); border-color: var(--bad); }
.btn.wide { width: 100%; }
.btn:disabled { opacity: 0.45; }
.chooser { display: flex; flex-wrap: wrap; gap: 6px; }

/* séance faite */
.done { display: flex; flex-direction: column; gap: 12px; }
.done-head { display: flex; align-items: center; gap: 8px; color: var(--good); font-weight: 600; }
.done-head .muted { font-weight: 400; }
.verdict { font-size: 15px; }
.rpe-box { display: flex; flex-direction: column; gap: 6px; }
.rpe-q { font-size: 14px; font-weight: 600; }
.rpe-row { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 4px; }
.rpe { height: 38px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface-2); font-family: var(--f-display); font-weight: 600; font-variant-numeric: tabular-nums; }
.rpe.sel { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.rpe-ends { display: flex; justify-content: space-between; font-size: 12px; color: var(--ink-3); }

/* forme du jour */
.ready { display: flex; flex-direction: column; gap: 6px; padding: 12px 14px; border-radius: var(--r-md); background: var(--surface); }
.ready-head { display: flex; align-items: center; gap: 8px; }
.ready-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--good); }
.r-ok .ready-dot { background: var(--warn); }
.r-low .ready-dot { background: var(--bad); }
.offer { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; align-items: flex-start; }

/* blocs */
.block { display: flex; flex-direction: column; gap: 10px; }
.block-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.list { display: flex; flex-direction: column; background: var(--surface); border-radius: var(--r-md); overflow: hidden; }
.row {
  display: grid; grid-template-columns: 62px minmax(0, 1fr) auto 22px; gap: 10px; align-items: center;
  padding: 11px 12px; border: 0; border-bottom: 1px solid var(--line); background: transparent; text-align: left; width: 100%;
}
.row:last-child { border-bottom: 0; }
.list > .row:only-child { border-bottom: 0; }
.row-d { color: var(--ink-3); font-size: 14px; font-variant-numeric: tabular-nums; }
.row-t { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-k { font-variant-numeric: tabular-nums; color: var(--ink-2); font-size: 14.5px; }
.row.st-skipped .row-t, .row.st-missed .row-t { color: var(--ink-3); text-decoration: line-through; }
.st { width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; justify-self: end; }
.st .ic { width: 14px; height: 14px; }
.st.done { background: var(--good); color: var(--surface); }
.st.missed { border: 2px solid var(--bad); }
.st.skipped { border: 2px dashed var(--ink-3); }
.st.today { border: 2px solid var(--accent); }
.st.planned { border: 2px solid var(--line); }
.pad { padding: 12px; }

/* semaine */
.strip { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; background: var(--surface); border-radius: var(--r-md); padding: 10px 6px; }
.day { display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; }
.dn { font-size: 12px; color: var(--ink-3); }
.dk { font-size: 11.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; min-height: 15px; }
.dot { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--z-rest); background: transparent; padding: 0; display: block; }
.day.rest .dot { width: 8px; height: 8px; margin: 9px 0; background: var(--z-rest); border: 0; }
.day.z-easy .dot { border-color: var(--z-easy); }
.day.z-mod .dot { border-color: var(--z-mod); }
.day.z-hard .dot { border-color: var(--z-hard); }
.day.z-race .dot { border-color: var(--z-race); }
.day.st-done.z-easy .dot { background: var(--z-easy); }
.day.st-done.z-mod .dot { background: var(--z-mod); }
.day.st-done.z-hard .dot { background: var(--z-hard); }
.day.st-done.z-race .dot { background: var(--z-race); }
.day.st-missed .dot { border-style: dashed; opacity: 0.6; }
.day.is-today .dn { color: var(--ink); font-weight: 600; }
.day.is-today .dot { box-shadow: 0 0 0 3px var(--accent-soft); }

/* course */
.race-mini {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: center;
  background: var(--surface); border-radius: var(--r-md); padding: 14px; border: 0; text-align: left; width: 100%;
}
.race-mini > div:first-child { display: flex; flex-direction: column; min-width: 0; }
.race-j { display: flex; flex-direction: column; align-items: flex-end; }
.race-j b { font-family: var(--f-display); font-size: 30px; line-height: 1; font-variant-numeric: tabular-nums; }
.race-j span { font-size: 12px; color: var(--ink-3); }
.race-p { grid-column: 1 / -1; display: flex; justify-content: space-between; border-top: 1px solid var(--line); padding-top: 8px; font-size: 14px; }
.race-p b { font-variant-numeric: tabular-nums; }
.race { background: var(--surface); border-radius: var(--r-lg); padding: 16px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.race.past { opacity: 0.6; }
.race-head { display: flex; justify-content: space-between; gap: 12px; width: 100%; }
.race.main h3 { font-size: 24px; }

/* plan */
.phasebar { display: flex; flex-direction: column; gap: 6px; }
.segs { display: flex; gap: 3px; height: 14px; }
.seg { flex: 1; border-radius: 3px; background: var(--z-base); }
.seg.ph-base { background: color-mix(in srgb, var(--z-easy) 70%, var(--surface)); }
.seg.ph-dev { background: color-mix(in srgb, var(--z-mod) 75%, var(--surface)); }
.seg.ph-specific { background: color-mix(in srgb, var(--z-hard) 75%, var(--surface)); }
.seg.ph-taper { background: color-mix(in srgb, var(--z-race) 75%, var(--surface)); }
.seg.rec { opacity: 0.45; }
.seg.cur { outline: 2px solid var(--ink); outline-offset: 1px; }
.legend { display: flex; gap: 3px; font-size: 12px; color: var(--ink-3); }
.legend span { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.weeks { display: flex; flex-direction: column; gap: 10px; }
.week { display: flex; flex-direction: column; gap: 6px; }
.week.past { opacity: 0.75; }
.week-head {
  display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 10px; align-items: center;
  border: 0; background: transparent; padding: 4px 2px; text-align: left; width: 100%;
}
.wk-t { display: flex; flex-direction: column; min-width: 0; }
.wk-t b { font-family: var(--f-display); font-size: 18px; }
.wk-t .muted { font-size: 13px; }
.wk-ph { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); }
.wk-ph.ph-base { color: var(--z-easy); }
.wk-ph.ph-dev { color: var(--z-mod); }
.wk-ph.ph-specific { color: var(--z-hard); }
.wk-ph.ph-taper { color: var(--z-race); }
.wk-ph.rec { color: var(--ink-3); }
.wk-k { font-variant-numeric: tabular-nums; font-size: 14px; color: var(--ink-2); }
.week.cur .wk-t b::after { content: "en cours"; margin-left: 8px; font-size: 13px; color: var(--accent); font-weight: 600; font-family: var(--f-body); }

/* tableaux et graphiques */
.tbl { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; background: var(--surface); border-radius: var(--r-md); overflow: hidden; }
.tbl th, .tbl td { padding: 9px 12px; text-align: right; border-bottom: 1px solid var(--line); }
.tbl th { font-size: 13px; color: var(--ink-3); font-weight: 500; }
.tbl td:first-child, .tbl th:first-child { text-align: left; }
.tbl tr:last-child td { border-bottom: 0; }
.chart { width: 100%; height: auto; display: block; background: var(--surface); border-radius: var(--r-md); }
.bar-plan { fill: var(--line); }
.bar-done { fill: color-mix(in srgb, var(--accent) 70%, var(--surface)); }
.bar-done.cur { fill: var(--accent); }
.ax { fill: var(--ink-3); font-size: 10px; font-family: var(--f-body); }
.line { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; }
.chart .dot { fill: var(--accent); }
.legend-inline { font-size: 12px; color: var(--ink-3); display: flex; align-items: center; gap: 6px; }
.legend-inline i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.lg-plan { background: var(--line); }
.lg-done { background: var(--accent); }

/* formulaires */
.form { display: flex; flex-direction: column; gap: 10px; width: 100%; }
.form label, .field { display: flex; flex-direction: column; gap: 4px; font-size: 13.5px; color: var(--ink-2); font-weight: 500; }
.form.inline { flex-direction: row; flex-wrap: wrap; align-items: flex-end; }
.form.inline label { flex: 1 1 120px; }
input, select {
  min-height: 42px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface-2); font-size: 16px; color: var(--ink); width: 100%;
}
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { min-height: 36px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-size: 14px; }
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.switch { display: flex; align-items: center; gap: 10px; font-size: 15px; }
.switch input { width: 22px; height: 22px; min-height: 0; accent-color: var(--accent); flex: none; }
.block > .btn { align-self: flex-start; }

/* barre d'onglets */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
  padding-top: 6px;
  padding-bottom: max(8px, env(safe-area-inset-bottom, 0px));
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.tabs button {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  border: 0; background: transparent; color: var(--ink-3); font-size: 11.5px; padding: 4px 0;
}
.tabs button[aria-current="page"] { color: var(--accent); font-weight: 600; }
.tabs .ic { width: 22px; height: 22px; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(76px + env(safe-area-inset-bottom, 0px)); z-index: 30;
  max-width: min(520px, calc(100% - 32px));
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14.5px;
}
.toast.warn { background: var(--warn); color: #fff; }

.loading { min-height: 60vh; display: flex; flex-direction: column; justify-content: center; align-items: flex-start; gap: 6px; }
.ld-title { font-family: var(--f-display); font-size: 44px; font-weight: 700; }

@media (prefers-reduced-motion: reduce) {
  .icon-btn.spin .ic { animation: none; }
}
@media (min-width: 720px) {
  .tabs { left: 50%; right: auto; transform: translateX(-50%); width: 560px; border: 1px solid var(--line); border-bottom: 0; border-radius: 16px 16px 0 0; }
}
.plan-line { display: flex; flex-direction: column; gap: 2px; margin: 10px 0 4px; }
.note.dup { margin: 0 0 14px; border-left: 3px solid var(--warn); }
.note.dup b { display: block; color: var(--ink); margin-bottom: 4px; }
.note.dup p { margin: 0; color: var(--ink-2); }
.block .note.dup { margin: 10px 0; }
.note.dup .dup-days { margin-top: 6px; color: var(--ink); font-weight: 500; }
