:root {
  --bg: #F4F1EA;
  --card: #FFFFFF;
  --ink: #1C2320;
  --muted: #6B736E;
  --line: #E6E1D6;
  --accent: #1F6F54;
  --accent-soft: #DCEBE3;
  --easy: #5FA57F;
  --long: #3D6FB6;
  --quality: #D9653B;
  --race: #8A4FB0;
  --warn: #B5462A;
  --r: 18px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Inter, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
main { max-width: 560px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 12px) 16px calc(96px + env(safe-area-inset-bottom)); }
h1 { font-size: 30px; letter-spacing: -0.02em; margin: 2px 0 0; }
h2 { font-size: 21px; margin: 4px 0; letter-spacing: -0.01em; }
h3 { font-size: 17px; margin: 2px 0 6px; }
p { margin: 6px 0; line-height: 1.45; }
a { color: inherit; text-decoration: none; }
.top { padding: 8px 2px 12px; }
.eyebrow { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.right { text-align: right; }
.spread { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.card { background: var(--card); border-radius: var(--r); padding: 16px; margin: 0 0 12px; box-shadow: 0 1px 0 var(--line); }
.card.race { background: var(--ink); color: #fff; }
.card.race .muted, .card.race .eyebrow { color: #B9C2BC; }
.race-line { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.countdown { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.card.ok { background: var(--accent-soft); }
.card.cta { background: var(--accent-soft); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.banner { background: #FFF6DA; border-radius: 12px; padding: 10px 12px; font-size: 13px; margin-bottom: 12px; line-height: 1.4; }
.banner.err { background: #FBE3DC; color: var(--warn); }
.loading { padding: 40vh 0; text-align: center; color: var(--muted); }

.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 99px; color: #fff; }
.pill.k-easy { background: var(--easy); } .pill.k-long { background: var(--long); }
.pill.k-quality { background: var(--quality); } .pill.k-race { background: var(--race); }
.today { display: block; }
.big { font-size: 18px; font-weight: 600; margin: 2px 0 10px; }
.purpose { color: #39423D; }
.done { color: var(--accent); font-weight: 600; }

.bars { display: flex; align-items: flex-end; gap: 2px; height: 44px; margin: 10px 0; }
.bar { border-radius: 3px; min-width: 2px; }
.bar.lv1 { height: 30%; background: #A9CDB8; } .bar.lv2 { height: 42%; background: var(--easy); }
.bar.lv3 { height: 62%; background: #E3A13B; } .bar.lv4 { height: 80%; background: var(--quality); }
.bar.lv5 { height: 100%; background: var(--warn); }

.progress { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; margin: 8px 0 12px; }
.progress span { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.week-dots { display: flex; justify-content: space-between; }
.wd { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); width: 32px; }
.wd.is-today { color: var(--ink); font-weight: 700; }
.wd-dot { width: 14px; height: 14px; border-radius: 50%; background: var(--line); display: block; }
.wd-dot.k-easy { background: var(--easy); } .wd-dot.k-long { background: var(--long); }
.wd-dot.k-quality { background: var(--quality); } .wd-dot.k-race { background: var(--race); }
.wd-dot.st-todo, .wd-dot.st-local { opacity: .35; }
.wd-dot.st-missed { opacity: .25; outline: 2px solid var(--warn); outline-offset: -2px; }

.row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.card .row:first-of-type { border-top: 0; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.dot.k-easy { background: var(--easy); } .dot.k-long { background: var(--long); }
.dot.k-quality { background: var(--quality); } .dot.k-race { background: var(--race); }
.row-main { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.row-date { font-size: 12px; color: var(--muted); }
.row-title { font-weight: 600; }
.row-meta { font-size: 13px; color: var(--muted); }
.row-st { width: 22px; text-align: center; font-weight: 700; }
.row.st-done .row-st { color: var(--accent); }
.row.st-missed { opacity: .55; }
.row.st-local .row-st { color: var(--muted); }
.week.is-past { opacity: .8; }
.week.is-current { outline: 2px solid var(--accent); }

.kpis { display: flex; gap: 8px; margin: 10px 0 4px; }
.kpis div { flex: 1; background: var(--bg); border-radius: 12px; padding: 10px; }
.kpis b { display: block; font-size: 20px; font-variant-numeric: tabular-nums; }
.kpis span { font-size: 12px; color: var(--muted); }
.card.race .kpis div { background: rgba(255,255,255,.08); }
.h-session { font-size: 26px; margin-top: 8px; }

.steps { padding-left: 0; list-style: none; margin: 6px 0 0; }
.steps li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 15px; }
.steps li:first-child { border-top: 0; }
.steps li span:last-child { color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.steps .rep { display: block; }
.steps .rep ol { list-style: none; padding-left: 14px; margin: 4px 0 0; border-left: 3px solid var(--quality); }
.pre { white-space: pre-wrap; font: 13px/1.45 ui-monospace, Menlo, monospace; background: var(--bg); border-radius: 10px; padding: 10px; }
details summary { cursor: pointer; color: var(--accent); font-weight: 600; margin-top: 8px; }

.chips { display: flex; gap: 6px; }
.chip { flex: 1; border: 1px solid var(--line); background: var(--bg); border-radius: 12px; padding: 8px 0; font: inherit; font-weight: 700; display: flex; flex-direction: column; align-items: center; position: relative; color: var(--ink); }
.chip small { font-weight: 400; color: var(--muted); }
.chip.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.chip.on small { color: #DCEBE3; }
.chip:disabled:not(.on) { opacity: .35; }
.chip i { position: absolute; top: 5px; right: 6px; width: 6px; height: 6px; border-radius: 50%; background: var(--quality); }

.btn { display: inline-block; border: 0; background: var(--accent); color: #fff; font: inherit; font-weight: 600; padding: 12px 18px; border-radius: 14px; margin: 8px 8px 0 0; cursor: pointer; }
.btn.ghost { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
.btn.danger, .link.danger { color: var(--warn); border-color: var(--warn); }
.btn:disabled { opacity: .5; }
.link { background: none; border: 0; font: inherit; font-size: 13px; padding: 4px 0; cursor: pointer; }

.form label, .race-edit label { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 0; font-size: 15px; }
input, select { font: inherit; font-size: 16px; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; background: var(--bg); color: var(--ink); min-width: 0; }
.form input:not([type=checkbox]), .form select { width: 46%; }
.form .eyebrow { margin-top: 14px; }
.toggle { justify-content: flex-start !important; }
.race-edit { border-top: 1px solid var(--line); padding: 12px 0 4px; }
.race-edit > input { width: 100%; font-weight: 600; }
.grid4 { display: grid; grid-template-columns: 1.6fr 1fr 1fr 1fr; gap: 6px; }
.grid4 label { flex-direction: column; align-items: stretch; gap: 2px; font-size: 12px; color: var(--muted); padding: 6px 0 0; }
.grid4 input, .grid4 select { width: 100%; padding: 7px 6px; }

.chart { width: 100%; height: 120px; display: block; margin-top: 8px; }
.b-plan { fill: var(--line); } .b-done { fill: var(--easy); } .b-done.cur { fill: var(--accent); }
.l-ctl { fill: none; stroke: var(--long); stroke-width: 2.5; } .l-atl { fill: none; stroke: var(--quality); stroke-width: 1.5; }
.axis { display: flex; font-size: 10px; color: var(--muted); }
.axis span { flex: 1; white-space: nowrap; }
.legend { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-left: 6px; }
.lg-plan { background: var(--line); } .lg-done { background: var(--easy); } .lg-ctl { background: var(--long); } .lg-atl { background: var(--quality); }
.mini-weeks { display: flex; align-items: flex-end; gap: 2px; height: 70px; margin: 12px 0 4px; }
.mw { flex: 1; border-radius: 2px; }
.ph-base { background: var(--easy); } .ph-developpement { background: var(--long); } .ph-specifique { background: var(--quality); }
.ph-affutage { background: #C9C2B3; } .ph-course { background: var(--race); }
.ok-txt { color: var(--accent); }

.tabs { position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-around; background: rgba(255,255,255,.94); backdrop-filter: blur(12px); border-top: 1px solid var(--line); padding: 8px 0 calc(8px + env(safe-area-inset-bottom)); }
.tabs a { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: var(--muted); width: 25%; }
.tabs a.on { color: var(--accent); font-weight: 600; }
.tabs svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.back { color: var(--accent); font-weight: 600; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(84px + env(safe-area-inset-bottom)); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; max-width: 90vw; z-index: 10; }
