/* Muscu : « Verre de nuit ». Le verre (backdrop-filter) est réservé au chrome qui passe au-dessus du contenu
   (onglets, barre du haut, mini-lecteur, feuilles) : jamais de verre sur du verre, pour tenir 60 fps sur iPhone. */
:root {
  --bg0: #05070d; --bg1: #0c1020; --bg2: #151227;
  --halo1: rgba(86, 104, 164, .42); --halo2: rgba(116, 92, 156, .34); --halo3: rgba(64, 120, 140, .22);
  --fg: #f4f5f8; --fg2: rgba(235, 237, 245, .68); --fg3: rgba(235, 237, 245, .40);
  --glass: rgba(20, 24, 40, .72); --sheet: rgba(20, 24, 38, .82); --card: rgba(255, 255, 255, .055); --card-h: rgba(255, 255, 255, .085);
  --fill: rgba(255, 255, 255, .075); --fill2: rgba(255, 255, 255, .13); --stroke: rgba(255, 255, 255, .10); --hi: rgba(255, 255, 255, .20);
  --acc: #eceff5; --on-acc: #0b0e18; --ok: #6ccf93; --ok-bg: rgba(108, 207, 147, .13); --gold: #e3c277; --bad: #ff6b61; --warn: #e3c277; --drop: #8dbbe3;
  --island: rgba(8, 10, 18, .86); --on-island: #f4f5f8;
  --shadow: 0 12px 40px rgba(0, 0, 0, .42); --shadow-s: 0 4px 16px rgba(0, 0, 0, .28);
  --r-s: 12px; --r-m: 20px; --r-l: 28px;
  --spring: cubic-bezier(.32, .72, 0, 1); --ease: cubic-bezier(.25, .1, .25, 1);
  --tabh: 64px; --sb: env(safe-area-inset-bottom); --st: env(safe-area-inset-top);
  --side: 0px; --rest-space: 0px;
  color-scheme: dark;
}
[data-theme="light"] {
  --bg0: #e6e9f1; --bg1: #f1f2f7; --bg2: #ebe7f3;
  --halo1: rgba(140, 160, 220, .38); --halo2: rgba(186, 160, 222, .34); --halo3: rgba(140, 200, 210, .26);
  --fg: #0e1222; --fg2: rgba(14, 18, 34, .66); --fg3: rgba(14, 18, 34, .42);
  --glass: rgba(255, 255, 255, .74); --sheet: rgba(250, 251, 254, .88); --card: rgba(255, 255, 255, .58); --card-h: rgba(255, 255, 255, .75);
  --fill: rgba(14, 18, 34, .055); --fill2: rgba(14, 18, 34, .10); --stroke: rgba(14, 18, 34, .08); --hi: rgba(255, 255, 255, .95);
  --acc: #151a2c; --on-acc: #f4f5f8; --ok: #1d8049; --ok-bg: rgba(29, 128, 73, .11); --gold: #8f6a10; --bad: #c9251b; --warn: #8f6a10; --drop: #2a6aa0;
  --shadow: 0 12px 40px rgba(40, 50, 90, .14); --shadow-s: 0 4px 16px rgba(40, 50, 90, .10);
  color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { background: var(--bg0); }
html, body { margin: 0; color: var(--fg); font: 17px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
body {
  min-height: 100dvh; -webkit-text-size-adjust: 100%;
  padding: calc(var(--st) + 12px) calc(env(safe-area-inset-right) + 16px) calc(var(--tabh) + var(--sb) + 40px + var(--rest-space)) calc(env(safe-area-inset-left) + 16px);
}
body.resting { --rest-space: 76px; }

/* Fond vivant : dégradé fixe + halos (dégradés radiaux, pas de filter: blur, seul transform est animé) */
body::before, body::after { content: ""; position: fixed; inset: 0; z-index: -2; pointer-events: none; }
body::before { background: linear-gradient(160deg, var(--bg1) 0%, var(--bg0) 45%, var(--bg2) 100%); }
body::after {
  z-index: -1; inset: -25%;
  background:
    radial-gradient(38% 32% at 22% 18%, var(--halo1), transparent 70%),
    radial-gradient(34% 30% at 82% 38%, var(--halo2), transparent 70%),
    radial-gradient(40% 34% at 40% 88%, var(--halo3), transparent 70%);
  animation: drift 48s ease-in-out infinite alternate; will-change: transform;
}
@keyframes drift { 0% { transform: translate3d(0, 0, 0) rotate(0deg); } 50% { transform: translate3d(4%, -3%, 0) rotate(8deg); } 100% { transform: translate3d(-3%, 4%, 0) rotate(-6deg); } }

/* Matériaux */
.glass { background: var(--glass); -webkit-backdrop-filter: blur(24px) saturate(180%); backdrop-filter: blur(24px) saturate(180%); border: 1px solid var(--stroke); box-shadow: inset 0 1px 0 var(--hi), var(--shadow); }

/* Typo */
h1 { font-size: 34px; line-height: 1.12; font-weight: 700; letter-spacing: -.02em; margin: 6px 0 4px; }
h2 { font-size: 22px; line-height: 1.2; font-weight: 700; letter-spacing: -.01em; margin: 28px 0 12px; }
h3 { font-size: 17px; font-weight: 600; margin: 0 0 4px; }
h1, h2, h3, .ex-title { text-wrap: balance; }
.sub { color: var(--fg2); margin: 0 0 18px; }
a { color: var(--fg); }
.muted { color: var(--fg2); } .small { font-size: 14px; } .center { text-align: center; } .pad { padding: 24px 0; }
.num { font-variant-numeric: tabular-nums; }
.row { display: flex; gap: 8px; align-items: center; } .row > .grow, .grow { flex: 1; min-width: 0; }
.wrap { flex-wrap: wrap; } .between { justify-content: space-between; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
svg.i { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }
.ic { display: inline-flex; align-items: center; gap: 6px; }
.ic svg.i { width: 17px; height: 17px; }

/* Cartes : verre « léger » (fond translucide + reflet), sans blur sur mobile */
.card {
  position: relative; background: var(--card); border: 1px solid var(--stroke); border-radius: var(--r-m);
  box-shadow: inset 0 1px 0 var(--hi), var(--shadow-s); padding: 16px; margin: 0 0 12px;
}
.card > h2:first-child, .card > .card-h:first-child { margin-top: 0; }
.card-h { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 600; color: var(--fg2); margin: 0 0 10px; }
.card-h svg.i { width: 18px; height: 18px; }
.list .item { display: flex; align-items: center; gap: 12px; padding: 12px 0; min-height: 48px; border-bottom: 1px solid var(--stroke); }
.list .item:last-child { border-bottom: 0; }
button.item { width: 100%; text-align: left; border-radius: 0; background: none; padding-left: 0; padding-right: 0; font-weight: 400; }
button.item svg.i { color: var(--fg3); }

/* Boutons */
button, .btn {
  font: inherit; font-weight: 600; color: var(--fg); background: var(--fill); border: 0; border-radius: 999px;
  min-height: 48px; padding: 0 18px; cursor: pointer; touch-action: manipulation; user-select: none; -webkit-user-select: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform .18s var(--spring), background-color .2s var(--ease), color .2s var(--ease), box-shadow .2s var(--ease);
}
button:active, .btn:active { transform: scale(.96); }
button:focus-visible, .btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .btn:focus-within { outline: 2px solid var(--fg); outline-offset: 2px; }
.primary { background: var(--acc); color: var(--on-acc); box-shadow: 0 6px 20px rgba(0, 0, 0, .22); }
.big { width: 100%; min-height: 56px; font-size: 17px; margin: 6px 0; }
.danger { color: var(--bad); }
.ghost { background: transparent; }
.sm { min-height: 40px; padding: 0 14px; font-size: 15px; }
.icon { min-width: 44px; width: 44px; padding: 0; }
.sm.icon { min-width: 40px; width: 40px; }
.btns { display: flex; flex-wrap: wrap; gap: 8px; }
@media (hover: hover) and (pointer: fine) {
  button:hover, .btn:hover { background: var(--fill2); }
  .primary:hover { background: var(--acc); filter: brightness(1.06); }
  .ghost:hover { background: var(--fill); }
  button.item:hover { background: none; } button.item:hover b, button.item:hover .t1 { text-decoration: underline; text-underline-offset: 3px; }
}

/* Champs */
input, select, textarea {
  font: inherit; font-size: 17px; color: var(--fg); background: var(--fill); border: 1px solid transparent; border-radius: var(--r-s);
  min-height: 48px; padding: 0 14px; width: 100%; transition: background-color .2s, border-color .2s;
}
input::placeholder, textarea::placeholder { color: var(--fg3); }
input:focus, select:focus, textarea:focus { background: var(--fill2); border-color: var(--stroke); outline: 2px solid var(--fg); outline-offset: 0; }
select { appearance: none; -webkit-appearance: none; padding-right: 40px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--fg2) 50%), linear-gradient(135deg, var(--fg2) 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 15px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
select option { background: var(--bg1); color: var(--fg); }
textarea { padding: 12px 14px; min-height: 72px; resize: vertical; }
label { display: block; font-size: 14px; font-weight: 500; color: var(--fg2); margin: 12px 0 6px; }
input[type="checkbox"] { width: 22px; min-height: 22px; accent-color: var(--fg); }
.seg { display: flex; background: var(--fill); border-radius: 999px; padding: 3px; gap: 2px; }
.seg button { flex: 1; white-space: nowrap; min-height: 40px; background: transparent; font-weight: 500; color: var(--fg2); padding: 0 12px; }
.seg button.on { background: var(--acc); color: var(--on-acc); font-weight: 600; box-shadow: var(--shadow-s); }

/* Barre du haut (titre réduit au scroll, iPhone) */
#top {
  position: fixed; top: 0; left: 0; right: 0; z-index: 8; height: calc(var(--st) + 48px); padding-top: var(--st);
  display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 17px;
  border-width: 0 0 1px; border-radius: 0; box-shadow: none; opacity: 0; pointer-events: none; transform: translateY(-6px);
  transition: opacity .25s var(--ease), transform .25s var(--spring);
}
body.scrolled #top { opacity: 1; transform: none; }

/* Onglets : pilule flottante (mobile) */
#tabs {
  position: fixed; left: calc(env(safe-area-inset-left) + 14px); right: calc(env(safe-area-inset-right) + 14px); bottom: calc(var(--sb) + 10px);
  height: var(--tabh); display: flex; padding: 6px; gap: 2px; border-radius: 999px; z-index: 10; max-width: 520px; margin: 0 auto;
}
#tabs .brand { display: none; }
#tabs button { flex: 1; min-width: 0; height: 100%; min-height: 0; border-radius: 999px; background: none; padding: 0; color: var(--fg2);
  display: flex; flex-direction: column; gap: 1px; font-weight: 500; }
#tabs button span { font-size: 11px; letter-spacing: .01em; }
#tabs button.on { color: var(--fg); background: var(--fill2); }
#tabs button.on span { font-weight: 600; }

main#app { max-width: 1320px; margin: 0 auto; animation: view-in .32s var(--spring); }
main#app.no-anim { animation: none; }
@keyframes view-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* Indicateur de synchro */
.sync { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--fg2); min-height: 20px; }
.sync::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.sync:empty { display: none; }
.sync.pending::before { background: var(--warn); animation: blink 1.4s ease-in-out infinite; }
@keyframes blink { 50% { opacity: .3; } }

/* En-tête de vue */
.vh { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.vh > .primary { flex: none; }
@media (max-width: 767px) { .vh > .primary { width: 44px; min-width: 44px; padding: 0; } .vh > .primary > span { display: none; } }
.vh .grow > .sub { margin: 2px 0 0; }
.back { margin: 0 0 6px -10px; padding: 0 12px 0 6px; background: none; color: var(--fg2); }

/* ---------- Séance ---------- */
.wk-head { position: sticky; top: calc(var(--st) + 6px); z-index: 7; display: flex; align-items: center; gap: 12px; padding: 10px 10px 10px 18px; border-radius: 999px; margin: 0 0 16px; }
.wk-head .t-name { font-size: 13px; color: var(--fg2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.timer { font-variant-numeric: tabular-nums; font-size: 24px; font-weight: 600; letter-spacing: -.01em; line-height: 1.1; }
body.scrolled.on-seance #top { opacity: 0; }
.ex-title { font-size: 19px; font-weight: 700; letter-spacing: -.01em; }
.ex-tools { display: flex; gap: 2px; }
.ex-tools button { background: none; color: var(--fg2); }
.ex-meta { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 4px; }
.chip { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; color: var(--fg2); background: var(--fill); border-radius: 999px; padding: 4px 10px; }
.chip svg.i { width: 14px; height: 14px; }
.last { font-size: 14px; color: var(--fg2); margin: 6px 0 2px; font-variant-numeric: tabular-nums; }
.sugg { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; color: var(--fg); background: var(--fill); border-radius: var(--r-s); padding: 10px 12px; margin: 8px 0 2px; }
.sugg svg.i { width: 18px; height: 18px; color: var(--gold); margin-top: 1px; }
.sets { margin: 12px -6px 6px; }
.set { display: grid; grid-template-columns: 44px 1fr 1fr 58px 52px; gap: 6px; align-items: center; padding: 4px 6px; border-radius: 16px; transition: background-color .25s var(--ease); }
.set.hdr { font-size: 12px; font-weight: 500; color: var(--fg2); text-align: center; padding-bottom: 0; }
.set input { text-align: center; padding: 0 4px; min-height: 52px; font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }
.set input::placeholder { font-weight: 500; color: var(--fg3); }
.set input[data-f="rpe"] { font-size: 16px; font-weight: 500; }
.set.done { background: var(--ok-bg); }
.set.done input { background: transparent; color: var(--fg); }
.kind { min-height: 52px; min-width: 0; padding: 0; font-size: 15px; font-weight: 700; background: none; color: var(--fg2); font-variant-numeric: tabular-nums; border-radius: 14px; }
.kind.W { color: var(--warn); } .kind.D { color: var(--drop); } .kind.F { color: var(--bad); }
.check { min-height: 52px; min-width: 0; padding: 0; border-radius: 16px; background: var(--fill); color: var(--fg3); }
.check svg.i { width: 24px; height: 24px; stroke-width: 2.4; }
.set.done .check { background: var(--ok); color: #fff; box-shadow: 0 4px 14px rgba(60, 170, 110, .35); }
[data-theme="light"] .set.done .check { color: #fff; }
.set.is-pr .check { background: var(--gold); color: #1b1404; box-shadow: 0 0 0 4px rgba(227, 194, 119, .22), 0 4px 18px rgba(227, 194, 119, .45); }
.set.pop .check svg path { stroke-dasharray: 24; animation: draw .38s var(--spring) both; }
.set.pop .check { animation: pop .42s var(--spring); }
@keyframes draw { from { stroke-dashoffset: 24; } to { stroke-dashoffset: 0; } }
@keyframes pop { 0% { transform: scale(.82); } 60% { transform: scale(1.08); } 100% { transform: scale(1); } }
.pr { display: inline-flex; align-items: center; gap: 4px; background: rgba(227, 194, 119, .16); color: var(--gold); font-weight: 600; font-size: 12px; border-radius: 999px; padding: 2px 9px 2px 7px; margin-left: 8px; vertical-align: 3px; }
.pr svg.i { width: 13px; height: 13px; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.add-ex { border: 1.5px dashed var(--stroke); background: transparent; color: var(--fg2); }
.wk-foot { margin-top: 20px; }

/* Récap */
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.stats > .stat:last-child:nth-child(odd) { grid-column: 1 / -1; }
.stat { background: var(--card); border: 1px solid var(--stroke); box-shadow: inset 0 1px 0 var(--hi); border-radius: 18px; padding: 14px 12px; }
.card .stat { background: var(--fill); box-shadow: none; border: 0; }
.stat b { display: block; font-size: clamp(20px, 6vw, 26px); font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.15; }
.stat span { font-size: 13px; color: var(--fg2); }
.done-hero { text-align: center; padding: 18px 0 8px; }
.done-hero .badge { width: 72px; height: 72px; border-radius: 50%; margin: 0 auto 14px; display: grid; place-items: center; background: var(--ok); color: #fff; box-shadow: 0 10px 30px rgba(60, 170, 110, .35); }
.done-hero .badge svg.i { width: 36px; height: 36px; stroke-width: 2.4; }

/* ---------- Tableau de bord ---------- */
.dash { display: grid; gap: 12px; grid-template-columns: 1fr; }
.dash > .card { margin: 0; }
.start-card .big { margin: 0 0 10px; }
.k-big { font-size: 34px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.kpis .stat b { font-size: 22px; }
.day { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--stroke); }
.day:last-child { border-bottom: 0; }
.prog-name { font-size: 13px; font-weight: 600; color: var(--fg2); margin: 12px 0 0; }
.prog-name:first-of-type { margin-top: 0; }
.heat { display: grid; grid-template-rows: repeat(7, 1fr); grid-auto-flow: column; grid-auto-columns: 1fr; gap: 3px; }
.heat i { aspect-ratio: 1; border-radius: 3px; background: var(--fill); }
.heat i.l1 { background: color-mix(in srgb, var(--fg) 26%, transparent); }
.heat i.l2 { background: color-mix(in srgb, var(--fg) 50%, transparent); }
.heat i.l3 { background: color-mix(in srgb, var(--fg) 82%, transparent); }
.heat i.fut { visibility: hidden; }
.heat-leg { display: flex; align-items: center; justify-content: flex-end; gap: 4px; font-size: 12px; color: var(--fg2); margin-top: 8px; }
.heat-leg i { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }
.rec { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--stroke); }
.rec:last-child { border-bottom: 0; }
.rec .dot { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: rgba(227, 194, 119, .16); color: var(--gold); flex: none; }
.rec .dot svg.i { width: 16px; height: 16px; }

/* ---------- Timer de repos : mini-lecteur façon Dynamic Island ---------- */
#rest {
  position: fixed; z-index: 9; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--sb) + var(--tabh) + 20px); width: min(calc(100vw - 28px), 400px);
  display: flex; align-items: center; gap: 6px; padding: 8px 8px 8px 10px; border-radius: 999px;
  background: var(--island); color: var(--on-island); -webkit-backdrop-filter: blur(20px) saturate(160%); backdrop-filter: blur(20px) saturate(160%);
  border: 1px solid rgba(255, 255, 255, .10); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .12), 0 16px 40px rgba(0, 0, 0, .45);
  animation: island-in .45s var(--spring);
}
@keyframes island-in { from { opacity: 0; transform: translateX(-50%) translateY(14px) scale(.9); } to { opacity: 1; transform: translateX(-50%); } }
#rest .ring { width: 44px; height: 44px; flex: none; transform: rotate(-90deg); }
#rest .ring circle { fill: none; stroke-width: 4; }
#rest .ring .bgc { stroke: rgba(255, 255, 255, .14); }
#rest .ring .fgc { stroke: #fff; stroke-linecap: round; stroke-dasharray: 113.1; transition: stroke-dashoffset .25s linear; }
#rest .t { font-size: 28px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -.01em; padding: 0 6px; flex: 1; }
#rest .t small { display: block; font-size: 11px; font-weight: 500; color: rgba(244, 245, 248, .64); letter-spacing: 0; line-height: 1; margin-bottom: 2px; }
#rest button { color: var(--on-island); background: rgba(255, 255, 255, .12); min-height: 44px; font-size: 14px; padding: 0 12px; font-variant-numeric: tabular-nums; }
#rest button.icon { padding: 0; }
#rest.over .fgc { stroke: var(--ok); }
#rest.over .t { color: #8de0ad; }
#rest.over { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: inset 0 1px 0 rgba(255, 255, 255, .12), 0 0 0 6px rgba(108, 207, 147, .18), 0 16px 40px rgba(0, 0, 0, .45); } }

/* ---------- Feuilles modales ---------- */
#modal { position: fixed; inset: 0; background: rgba(0, 0, 0, .42); z-index: 20; display: flex; align-items: flex-end; justify-content: center; animation: fade .25s var(--ease); }
#modal[hidden] { display: none; }
@keyframes fade { from { opacity: 0; } }
#modal .sheet {
  width: 100%; max-width: 640px; max-height: 90dvh; overflow: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  background: var(--sheet); -webkit-backdrop-filter: blur(30px) saturate(180%); backdrop-filter: blur(30px) saturate(180%);
  border: 1px solid var(--stroke); border-bottom: 0; border-radius: var(--r-l) var(--r-l) 0 0; box-shadow: inset 0 1px 0 var(--hi), 0 -10px 50px rgba(0, 0, 0, .35);
  padding: 8px calc(env(safe-area-inset-right) + 18px) calc(var(--sb) + 18px) calc(env(safe-area-inset-left) + 18px);
  animation: sheet-in .42s var(--spring);
}
#modal .sheet::before { content: ""; display: block; width: 38px; height: 5px; border-radius: 3px; background: var(--fg3); margin: 0 auto 12px; }
#modal .sheet-h { position: sticky; top: -8px; z-index: 1; display: flex; align-items: center; gap: 8px; margin: -8px -18px 6px; padding: 8px 18px; background: var(--sheet); }
#modal .sheet-h h2 { margin: 0; flex: 1; }
@keyframes sheet-in { from { transform: translateY(100%); } }

/* Calendrier */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; text-align: center; }
.cal .d { min-height: 46px; min-width: 0; border-radius: 14px; background: var(--fill); display: flex; align-items: center; justify-content: center; font-size: 15px; font-weight: 500; padding: 0; font-variant-numeric: tabular-nums; }
.cal .d.has { background: var(--acc); color: var(--on-acc); font-weight: 700; }
.cal .d.today { box-shadow: inset 0 0 0 2px var(--fg); }
.cal .d.sel { outline: 2px solid var(--fg); outline-offset: 2px; }
.cal .h { font-size: 12px; color: var(--fg2); padding-bottom: 2px; }

/* Graphiques */
.chart-wrap { position: relative; }
svg.chart { width: 100%; height: auto; display: block; overflow: visible; touch-action: pan-y; }
svg.chart text { fill: var(--fg2); font-size: 11px; font-variant-numeric: tabular-nums; }
svg.chart .grid { stroke: var(--stroke); }
svg.chart .ln { fill: none; stroke: var(--fg); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
svg.chart .area { fill: var(--fg); opacity: .07; }
svg.chart .pt { fill: var(--bg1); stroke: var(--fg); stroke-width: 1.5; }
svg.chart .mk { stroke: var(--ok); opacity: .45; }
svg.chart .tip { pointer-events: none; opacity: 0; transition: opacity .12s; }
svg.chart .tip.on { opacity: 1; }
svg.chart .tip line { stroke: var(--fg3); stroke-dasharray: 3 3; }
svg.chart .tip circle { fill: var(--fg); stroke: var(--bg1); stroke-width: 2; }
svg.chart .tip rect { fill: var(--acc); }
svg.chart .tip text { fill: var(--on-acc); font-weight: 600; font-size: 11px; }
.period { margin: 0 0 12px; max-width: 360px; }

code { background: var(--fill); padding: 3px 8px; border-radius: 8px; word-break: break-all; font: 13px/1.5 ui-monospace, "SF Mono", Menlo, monospace; display: inline-block; }
[hidden] { display: none !important; }
.toast {
  position: fixed; left: 50%; top: calc(var(--st) + 14px); transform: translateX(-50%); z-index: 30; max-width: 90vw; text-align: center;
  display: inline-flex; align-items: center; gap: 8px; padding: 12px 18px; border-radius: 999px; font-weight: 600; font-size: 15px;
  background: var(--island); color: var(--on-island); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); box-shadow: 0 12px 40px rgba(0, 0, 0, .4);
  animation: toast-in .4s var(--spring);
}
@keyframes toast-in { from { opacity: 0; transform: translateX(-50%) translateY(-12px) scale(.95); } }
#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 40; }
#haptic { position: fixed; left: -100px; top: 0; opacity: 0; pointer-events: none; }

/* Login */
.login { min-height: 70dvh; display: grid; place-items: center; }
.login .card { width: min(100%, 400px); padding: 28px 22px; }
.mark { width: 64px; height: 64px; border-radius: 20px; display: grid; place-items: center; margin: 0 auto 14px; background: var(--acc); color: var(--on-acc); box-shadow: var(--shadow); }
.mark svg.i { width: 34px; height: 34px; stroke-width: 2; }

/* Réglages : rangées style iOS */
.opt { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; }
.opt + .opt { border-top: 1px solid var(--stroke); margin-top: 12px; padding-top: 12px; }
.opt label { margin: 0; color: var(--fg); font-size: 16px; flex: 1 1 auto; }
.opt input { width: 110px; text-align: right; }
.opt .seg { flex: 1 1 240px; max-width: 320px; }

/* Grilles de contenu */
.cols { display: grid; gap: 12px; grid-template-columns: 1fr; }
.cols > .card { margin: 0; }
.wk-side { display: none; }

/* ---------- Tablette ---------- */
@media (min-width: 768px) {
  :root { --side: 92px; }
  body { padding: 28px 28px 48px calc(var(--side) + 28px); }
  body.resting { --rest-space: 90px; }
  #top { display: none; }
  #tabs { left: 14px; top: 14px; bottom: 14px; right: auto; width: 68px; height: auto; flex-direction: column; justify-content: flex-start; border-radius: var(--r-l); padding: 10px 8px; gap: 6px; margin: 0; }
  #tabs .brand { display: grid; place-items: center; height: 52px; margin-bottom: 8px; }
  #tabs .brand .mark { width: 40px; height: 40px; border-radius: 13px; margin: 0; box-shadow: none; }
  #tabs .brand .mark svg.i { width: 22px; height: 22px; }
  #tabs .brand b { display: none; }
  #tabs button { flex: none; height: 52px; border-radius: 16px; }
  #tabs button span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  #rest { bottom: 24px; left: calc(50% + var(--side) / 2); }
  #modal { align-items: center; padding: 24px; }
  #modal .sheet { border-radius: var(--r-l); border-bottom: 1px solid var(--stroke); max-height: 86dvh; padding-bottom: 22px; animation: dialog-in .32s var(--spring); }
  #modal .sheet::before { display: none; }
  @keyframes dialog-in { from { opacity: 0; transform: translateY(16px) scale(.97); } }
  h1 { font-size: 38px; }
  .dash, .cols { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
  .span2, .span-all { grid-column: 1 / -1; }
  .stats { grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); }
  .stats > .stat:last-child:nth-child(odd) { grid-column: auto; }
  .cols.c3 > .card:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .wk-head { top: 14px; }
  .card { padding: 20px; }
  .narrow { max-width: 760px; margin-left: auto; margin-right: auto; }
}

/* ---------- Laptop ---------- */
@media (min-width: 1100px) {
  :root { --side: 248px; }
  body { padding: 36px 40px 56px calc(var(--side) + 40px); }
  #tabs { width: 224px; left: 16px; top: 16px; bottom: 16px; padding: 14px 12px; gap: 4px; }
  #tabs .brand { display: flex; align-items: center; justify-content: flex-start; gap: 12px; height: 56px; padding: 0 8px; margin-bottom: 14px; }
  #tabs .brand b { display: block; font-size: 19px; letter-spacing: -.01em; }
  #tabs button { flex-direction: row; justify-content: flex-start; gap: 12px; height: 46px; padding: 0 14px; border-radius: 14px; font-size: 15px; }
  #tabs button span { position: static; width: auto; height: auto; clip: auto; overflow: visible; font-size: 15px; }
  #tabs .sync { margin-top: auto; padding: 8px 14px; }
  .card { -webkit-backdrop-filter: blur(16px) saturate(150%); backdrop-filter: blur(16px) saturate(150%); }
  .dash { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .dash .span2 { grid-column: span 2; }
  .dash .span-all { grid-column: 1 / -1; }
  .wk-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 24px; align-items: start; }
  .wk-side { display: block; position: sticky; top: 16px; max-height: calc(100dvh - 32px); overflow: auto; }
  .wk-side .card { margin-bottom: 14px; }
  .cols.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .cols.c3 > .card:last-child:nth-child(odd) { grid-column: auto; }
  .set { grid-template-columns: 52px 1fr 1fr 80px 64px; gap: 8px; }
  h1 { font-size: 40px; }
}
@media (min-width: 1600px) { :root { --side: 264px; } body { padding-left: calc(var(--side) + 56px); padding-right: 56px; } #tabs { width: 240px; } }

/* Accessibilité */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media (prefers-reduced-transparency: reduce) {
  :root { --glass: #141828; --sheet: #141828; --card: #12162a; --island: #0a0c14; }
  [data-theme="light"] { --glass: #fff; --sheet: #fff; --card: #fff; }
  .glass, .card, #modal .sheet, #rest, .toast { -webkit-backdrop-filter: none !important; backdrop-filter: none !important; }
  body::after { display: none; }
}
