:root {
  --bg: #f6f5f1; --surface: #ffffff; --surface-2: #efede7; --ink: #1b1f1c; --muted: #66706a;
  --line: #e2dfd7; --accent: #1f6f43; --accent-ink: #ffffff; --accent-soft: #e3f0e7;
  --warn: #a45a00; --warn-soft: #fbefdc; --bad: #b3261e; --bad-soft: #fbe6e4;
  --key: #1f6f43; --radius: 14px; --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.05);
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1210; --surface: #151c18; --surface-2: #1c2520; --ink: #e8ece9; --muted: #9aa69f;
    --line: #26302a; --accent: #5cc58a; --accent-ink: #062012; --accent-soft: #183326;
    --warn: #f0b35a; --warn-soft: #33270f; --bad: #f08a80; --bad-soft: #3a1a17;
    --key: #5cc58a; --shadow: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
       -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.muted { color: var(--muted); }
.error { color: var(--bad); min-height: 1.2em; margin: 8px 0 0; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h2 { font-size: 1.05rem; }
h3 { font-size: .95rem; }

/* ---------- connexion */
.login { min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center;
         padding: 24px; text-align: center; gap: 8px; }
.login-logo { width: 72px; height: 72px; border-radius: 18px; }
.login-form { width: 100%; max-width: 320px; display: grid; gap: 10px; margin-top: 12px; }
input, textarea { font: inherit; color: inherit; background: var(--surface); border: 1px solid var(--line);
                  border-radius: 12px; padding: 12px 14px; width: 100%; }
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ---------- boutons */
.btn { font: inherit; font-weight: 600; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
       border-radius: 12px; padding: 11px 16px; cursor: pointer; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.small { padding: 7px 12px; font-size: .9rem; }
.btn:disabled { opacity: .55; }
.chip { font: inherit; font-size: .92rem; border: 1px solid var(--line); background: var(--surface);
        color: var(--ink); border-radius: 999px; padding: 7px 14px; cursor: pointer; }

/* ---------- squelette */
.app { min-height: 100dvh; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center;
          gap: 12px; padding: calc(10px + var(--safe-t)) 16px 10px; background: var(--bg);
          border-bottom: 1px solid var(--line); }
.race-name { font-weight: 700; }
.race-sub { color: var(--muted); font-size: .85rem; }
.countdown { font-weight: 800; font-size: 1.25rem; color: var(--accent); white-space: nowrap; }
main { flex: 1; width: 100%; max-width: 680px; margin: 0 auto; padding: 14px 16px calc(84px + var(--safe-b)); }
.tabs { position: fixed; bottom: 0; left: 0; right: 0; z-index: 6; display: grid; grid-template-columns: repeat(5, 1fr);
        background: var(--surface); border-top: 1px solid var(--line); padding-bottom: var(--safe-b); }
.tabs a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 9px;
          color: var(--muted); text-decoration: none; font-size: .72rem; font-weight: 600; }
.tabs a .ti { font-size: 1.15rem; line-height: 1; }
.tabs a.on { color: var(--accent); }

/* ---------- cartes */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
        padding: 14px; box-shadow: var(--shadow); margin-bottom: 12px; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.eyebrow { font-size: .75rem; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.session-title { font-size: 1.12rem; font-weight: 700; margin: 2px 0 4px; }
.session-meta { color: var(--muted); font-size: .88rem; margin-bottom: 8px; }
.session-detail { white-space: pre-wrap; font-size: .95rem; }
.badge { display: inline-block; font-size: .72rem; font-weight: 700; border-radius: 999px; padding: 2px 8px;
         background: var(--surface-2); color: var(--muted); }
.badge.key { background: var(--accent-soft); color: var(--key); }
.badge.done { background: var(--accent-soft); color: var(--accent); }
.badge.modified { background: var(--warn-soft); color: var(--warn); }
.badge.skipped { background: var(--bad-soft); color: var(--bad); }
.row-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.note { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; font-size: .93rem; white-space: pre-wrap; }
.empty { text-align: center; color: var(--muted); padding: 24px 8px; }

/* ---------- état */
.metrics { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 12px; }
.metric { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.metric .v { font-size: 1.6rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.metric .k { font-size: .8rem; color: var(--muted); font-weight: 600; }
.metric .h { font-size: .78rem; color: var(--muted); margin-top: 2px; }
.metric.warn .v { color: var(--warn); }
.metric.bad .v { color: var(--bad); }
.act { display: flex; justify-content: space-between; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.act:first-of-type { border-top: 0; }
.act .t { font-weight: 600; }
.act .s { color: var(--muted); font-size: .85rem; }
.act .l { font-variant-numeric: tabular-nums; color: var(--muted); font-size: .85rem; white-space: nowrap; }

/* ---------- semaine */
.week-nav { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.week-nav .title { font-weight: 700; text-align: center; }
.progress { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin: 8px 0 4px; }
.progress > i { display: block; height: 100%; background: var(--accent); width: 0; }
.day { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 8px; }
.day.today { border-color: var(--accent); }
.day-head { display: flex; justify-content: space-between; padding: 10px 14px 0; font-weight: 700; font-size: .9rem; }
.day-body { padding: 4px 14px 10px; }
.day .item { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 0;
             border-top: 1px solid var(--line); cursor: pointer; }
.day .item:first-child { border-top: 0; }
.day .item .it { font-weight: 600; font-size: .95rem; }
.day .item .im { color: var(--muted); font-size: .82rem; }
.day .off { color: var(--muted); font-size: .85rem; padding: 6px 0; }

/* ---------- chat */
.view-chat { display: flex; flex-direction: column; min-height: calc(100dvh - 160px); }
.chat-list { flex: 1; display: flex; flex-direction: column; gap: 8px; padding-bottom: 8px; }
.msg { max-width: 86%; padding: 10px 13px; border-radius: 16px; white-space: pre-wrap; word-wrap: break-word; font-size: .97rem; }
.msg.user { align-self: flex-end; background: var(--accent); color: var(--accent-ink); border-bottom-right-radius: 5px; }
.msg.coach { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 5px; }
.msg.ask { border-color: var(--warn); }
.msg.system { align-self: center; background: var(--surface-2); color: var(--muted); font-size: .85rem; }
.msg .time { display: block; font-size: .7rem; opacity: .7; margin-top: 4px; }
.msg details { margin-top: 6px; font-size: .75rem; color: var(--muted); }
.typing { align-self: flex-start; color: var(--muted); font-size: .9rem; padding: 4px 8px; }
.chat-quick { display: flex; gap: 8px; justify-content: center; padding: 6px 0; }
.chat-form { position: sticky; bottom: calc(64px + var(--safe-b)); display: flex; align-items: flex-end; gap: 8px;
             background: var(--bg); padding: 8px 0; }
.chat-form textarea { resize: none; max-height: 140px; border-radius: 20px; padding: 10px 14px; }
.send, .icon-btn { flex: 0 0 auto; width: 42px; height: 42px; border-radius: 50%; border: 0; display: grid;
                   place-items: center; font-size: 1.1rem; cursor: pointer; }
.send { background: var(--accent); color: var(--accent-ink); }
.icon-btn { background: var(--surface); border: 1px solid var(--line); color: var(--ink); }

/* ---------- feuille de validation */
.sheet { border: 0; padding: 0; margin: auto auto 0; width: 100%; max-width: 560px; background: var(--surface);
         color: var(--ink); border-radius: 20px 20px 0 0; }
.sheet::backdrop { background: rgba(0,0,0,.4); }
.sheet form { padding: 18px 16px calc(16px + var(--safe-b)); display: grid; gap: 14px; }
.field { display: grid; gap: 8px; }
.label { font-weight: 700; font-size: .9rem; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.seg button, .rpe button { font: inherit; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink);
                           border-radius: 10px; padding: 9px 0; cursor: pointer; font-weight: 600; }
.seg button.on, .rpe button.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.rpe { display: grid; grid-template-columns: repeat(10, 1fr); gap: 4px; }
.rpe button { padding: 8px 0; font-size: .9rem; }
.check { display: flex; gap: 10px; align-items: center; font-size: .93rem; }
.check input { width: 20px; height: 20px; }
.sheet-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(80px + var(--safe-b)); z-index: 20;
         background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: .9rem;
         max-width: calc(100% - 32px); }

@media (min-width: 720px) {
  .tabs { max-width: 680px; margin: 0 auto; border: 1px solid var(--line); border-bottom: 0; border-radius: 16px 16px 0 0; }
}
.sheet form > p { margin: -10px 0 0; }
input[type="checkbox"] { accent-color: var(--accent); }

/* ---- premier lancement (v0.10) ---- */
select { font: inherit; color: inherit; background: var(--surface); border: 1px solid var(--line);
         border-radius: 10px; padding: 10px 12px; width: 100%; }
select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.form { display: grid; gap: 14px; }
.form input { width: 100%; box-sizing: border-box; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stepper { list-style: none; display: flex; gap: 6px; padding: 0; margin: 0 0 12px; counter-reset: st; }
.stepper li { flex: 1; font-size: .78rem; font-weight: 600; color: var(--muted); padding-top: 8px;
              border-top: 3px solid var(--line); counter-increment: st; }
.stepper li::before { content: counter(st) ". "; }
.stepper li.on { color: var(--accent); border-color: var(--accent); }
.stepper li.done { color: var(--ink); border-color: var(--accent-soft); }
.ok-line { margin: 8px 0; font-weight: 600; color: var(--accent); }
.msg { white-space: pre-line; }

/* ---- accueil (v0.11) ---- */
.welcome { display: grid; gap: 14px; justify-items: center; text-align: center; padding: 24px 4px; }
.welcome h1 { margin: 0; font-size: 1.5rem; }
.welcome p { margin: 0; max-width: 34ch; }
.welcome .btn.strava { background: #fc4c02; border-color: #fc4c02; color: #fff; padding: 14px 22px; font-size: 1.05rem; }
.welcome .alt { width: 100%; text-align: left; }
.small { font-size: .85rem; }
.alt summary { cursor: pointer; color: var(--muted); font-weight: 600; padding: 8px 0; }
.btn.danger { color: var(--bad); border-color: var(--bad); }
.spinner { width: 36px; height: 36px; border-radius: 50%; border: 4px solid var(--line); border-top-color: var(--accent);
           animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }
.chat-quick { flex-wrap: wrap; }
.progress-line { font-weight: 600; color: var(--accent); min-height: 1.4em; }

/* v0.17 : mémoire de l'athlète */
ul.memory { margin: 6px 0 8px; padding-left: 18px; display: grid; gap: 3px; }
ul.memory li { line-height: 1.4; }
pre.plan-text { white-space: pre-wrap; font: inherit; font-size: 13px; line-height: 1.45; margin: 8px 0 0; max-height: 50vh; overflow: auto; }

/* v0.19 : onglet Progrès */
.seg { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; }
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.chart { margin-top: 8px; position: relative; }
.chart-svg { display: block; width: 100%; height: auto; touch-action: pan-y; }
.chart-svg .grid { stroke: var(--line); stroke-width: 1; }
.chart-svg .axis0 { stroke: var(--muted); stroke-width: 1; }
.chart-svg .tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart-svg .tick.mk { fill: var(--accent); font-weight: 700; }
.chart-svg .ln { stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; }
.chart-svg .ln.dashed { stroke-dasharray: 5 5; opacity: .7; }
.chart-svg .marker { stroke: var(--accent); stroke-dasharray: 2 4; stroke-width: 1.5; }
.chart-svg .cursor { stroke: var(--muted); stroke-width: 1; }
.chart-tip { font-size: .8rem; color: var(--ink); background: var(--surface-2); border-radius: 8px; padding: 4px 8px;
             margin-top: 4px; font-variant-numeric: tabular-nums; }
.chart-note { font-size: .78rem; color: var(--muted); margin-top: 6px; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: .78rem; color: var(--muted); }
.legend i { display: inline-block; width: 12px; height: 3px; border-radius: 2px; margin-right: 5px; vertical-align: middle; }
.goal h2 { margin-top: 2px; }
.goal-est { margin: 8px 0 2px; }
.goal-est .big { font-size: 1.9rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.good { color: var(--accent); font-weight: 600; font-size: .9rem; }
.warnt { color: var(--warn); font-weight: 600; }
.small { font-size: .82rem; }
.chronos { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 8px; }
.chrono { border: 1px solid var(--line); border-radius: 12px; padding: 10px; min-width: 0; }
.chrono .k { font-size: .8rem; color: var(--muted); font-weight: 600; }
.chrono .v { font-size: 1.3rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.chrono .chart { margin-top: 4px; }
.chrono .chart-svg .tick { font-size: 9px; }
.table-wrap { overflow-x: auto; }
table.weeks { width: 100%; border-collapse: collapse; font-size: .85rem; font-variant-numeric: tabular-nums; }
table.weeks th { text-align: right; font-weight: 600; color: var(--muted); padding: 6px 4px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.weeks td { text-align: right; padding: 6px 4px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.weeks th:first-child, table.weeks td:first-child { text-align: left; }
table.weeks tr.partial td { color: var(--muted); }
#acts-list .more { margin-top: 10px; width: 100%; }
.chart-svg .ln.c-accent { stroke: var(--accent); } .chart-svg .ln.c-warn { stroke: var(--warn); }
.chart-svg .ln.c-ink { stroke: var(--ink); } .chart-svg .ln { fill: none; }
.chart-svg .area { stroke: none; opacity: .12; } .chart-svg .area.c-accent { fill: var(--accent); }
.legend i.c-accent { background: var(--accent); } .legend i.c-warn { background: var(--warn); }
.legend i.c-ink { background: var(--ink); } .legend i.dashed { opacity: .45; }

/* v0.20 : radar du profil */
.radar-svg { display: block; width: 100%; max-width: 380px; margin: 6px auto; height: auto; overflow: visible; }
.radar-svg .ring { fill: none; stroke: var(--line); stroke-width: 1; }
.radar-svg .ring.outer { stroke: var(--muted); stroke-opacity: .5; }
.radar-svg .spoke { stroke: var(--line); stroke-width: 1; }
.radar-svg .rp.now { fill: var(--accent); fill-opacity: .18; stroke: var(--accent); stroke-width: 2.2; stroke-linejoin: round; }
.radar-svg .rp.old { fill: none; stroke: var(--muted); stroke-width: 1.5; stroke-dasharray: 4 4; }
.radar-svg .rdot { fill: var(--accent); }
.radar-svg .rlabel { fill: var(--ink); font-size: 11.5px; font-weight: 600; }
.radar-svg .rlabel.off { fill: var(--muted); font-weight: 500; }
.radar-svg .rscore { fill: var(--accent); font-weight: 800; font-size: 12.5px; }
.radar-svg .rlabel.off .rscore { fill: var(--muted); }
.axis { padding: 10px 0; border-top: 1px solid var(--line); display: grid; gap: 2px; }
.axis-head { display: flex; justify-content: space-between; gap: 8px; }
.axis-score { font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.conf { color: var(--muted); font-size: .82rem; }
.tip { color: var(--ink); }
.tip::before { content: "→ "; color: var(--accent); font-weight: 700; }
