:root {
  --bg: #111418;
  --surface: #1b2027;
  --surface2: #242b34;
  --line: #2f3742;
  --text: #eef1f5;
  --muted: #8f9aa8;
  --accent: #ff7a3d;
  --accent-ink: #1a0d05;
  --blue: #4da3ff;
  --green: #3ecf8e;
  --red: #ff5c5c;
  --yellow: #f5c542;
  --radius: 16px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding: calc(var(--safe-top) + 8px) 16px calc(var(--safe-bottom) + 84px);
  max-width: 560px; margin: 0 auto;
  overscroll-behavior-y: none;
}
body.in-player { padding-bottom: calc(var(--safe-bottom) + 12px); }
body.in-player .tabbar { display: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
h1, h2 { margin: 0; }
small { font-size: 0.82em; }
.muted { color: var(--muted); }
.center { text-align: center; }

/* En-têtes */
.top { display: flex; align-items: center; gap: 8px; padding: 10px 0 14px; }
.top h1 { font-size: 1.6rem; display: flex; flex-direction: column; }
.top h1 small { font-size: 0.9rem; color: var(--muted); font-weight: 500; }
section { margin: 18px 0; }
section > h2 { font-size: 0.95rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 10px; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
section > h2 small { text-transform: none; letter-spacing: 0; font-weight: 500; }

/* Boutons */
.btn { padding: 12px 18px; border-radius: 12px; font-weight: 600; background: var(--surface2); }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.warn { background: var(--yellow); color: #1d1600; }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.btn.danger { color: var(--red); border-color: #5a2a2a; }
.btn.big { padding: 16px 22px; font-size: 1.1rem; min-height: 58px; }
.btn.full { width: 100%; display: block; margin-top: 10px; }
.btn:active, .card:active, .icon:active { transform: scale(.97); }
.icon { width: 48px; height: 48px; border-radius: 50%; font-size: 1.3rem; background: var(--surface2); flex: none; display: grid; place-items: center; }
.row { display: flex; gap: 10px; }
.row .btn { flex: 1; }

/* Cartes séance */
.card { display: block; width: 100%; background: var(--surface); border-radius: var(--radius); padding: 14px; margin-bottom: 10px; text-align: left; }
.scard { display: flex; align-items: center; gap: 14px; }
.sid { width: 46px; height: 46px; border-radius: 12px; background: var(--surface2); display: grid; place-items: center; font-weight: 800; font-size: 1.15rem; flex: none; }
.stxt { flex: 1; display: flex; flex-direction: column; }
.stxt small { color: var(--muted); }
.chev { color: var(--muted); font-size: 1.6rem; }
.scard.hero { background: linear-gradient(135deg, #3a2316, var(--surface)); border: 1px solid #5b3520; }
.scard.hero .sid, .scard.sug .sid { background: var(--accent); color: var(--accent-ink); }
.scard.sug { outline: 1px solid #5b3520; }
.resume { border: 1px solid var(--accent); display: flex; flex-direction: column; gap: 12px; }
.resume small { display: block; color: var(--muted); }

/* Semaine */
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.day { background: var(--surface); border-radius: 12px; padding: 8px 0; text-align: center; display: flex; flex-direction: column; gap: 2px; }
.day span { font-size: .75rem; color: var(--muted); }
.day b { font-size: .8rem; min-height: 1.2em; color: var(--muted); }
.day.done { background: #2c3a2f; }
.day.done b { color: var(--green); }
.day.today { outline: 2px solid var(--accent); }

/* Aperçu séance */
.simple { margin: 0; padding: 0 0 0 18px; color: var(--text); }
.simple li { margin: 4px 0; }
.simple small { color: var(--muted); }
.ex { background: var(--surface); border-radius: 14px; margin-bottom: 8px; overflow: hidden; }
.exhead { width: 100%; display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; padding: 12px 14px; text-align: left; }
.exname { font-weight: 600; }
.exname em { font-style: normal; font-size: .72rem; background: #4a2a18; color: var(--accent); padding: 2px 6px; border-radius: 6px; vertical-align: middle; }
.exlv { font-weight: 800; color: var(--accent); }
.extxt { color: var(--muted); font-size: .9rem; }
.dots { display: inline-flex; gap: 4px; align-items: center; justify-self: end; }
.dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.dots i.on { background: var(--accent); }
.streak { font-size: .72rem; color: var(--green); margin-left: 6px; }
.exbody { padding: 0 14px 14px; }
.exbody p { margin: 4px 0 10px; color: #cfd6df; }
.lvlist { display: flex; flex-direction: column; gap: 6px; margin-bottom: 6px; }
.lvopt { text-align: left; padding: 10px 12px; border-radius: 10px; background: var(--surface2); font-size: .92rem; }
.lvopt.on { background: #4a2a18; outline: 1px solid var(--accent); }
.lvopt b { color: var(--accent); margin-right: 6px; }
.demo { display: block; width: 140px; height: 140px; margin: 6px auto; border-radius: 14px; background: #fff; object-fit: contain; }
.sticky { position: sticky; bottom: calc(var(--safe-bottom) + 76px); padding-top: 10px; background: linear-gradient(transparent, var(--bg) 30%); }

/* Lecteur */
.player { display: flex; flex-direction: column; min-height: calc(100dvh - var(--safe-top) - var(--safe-bottom) - 20px); }
.ptop { display: flex; align-items: center; gap: 10px; padding: 4px 0 8px; }
.ptitle { flex: 1; font-weight: 700; display: flex; flex-direction: column; line-height: 1.2; }
.ptitle small { color: var(--muted); font-weight: 500; }
.pclock { font-variant-numeric: tabular-nums; color: var(--muted); min-width: 48px; text-align: right; }
.pbar { height: 5px; background: var(--surface2); border-radius: 3px; overflow: hidden; }
.pbar i { display: block; height: 100%; background: var(--accent); transition: width .3s; }
.stage { flex: 1; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding-top: 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.chip { background: var(--surface2); border-radius: 999px; padding: 4px 10px; font-size: .82rem; color: #cfd6df; }
.chip.lv { background: #4a2a18; color: var(--accent); font-weight: 700; }
.chip.fin { background: #4a1f2a; color: #ff8fa6; }
.sname { font-size: 1.55rem; font-weight: 800; line-height: 1.2; }
.steptxt { color: #cfd6df; font-size: 1.05rem; }
.gifnote { color: var(--muted); max-width: 300px; }
.stage .demo { width: 120px; height: 120px; }

.ringwrap { position: relative; width: min(62vw, 230px); aspect-ratio: 1; margin: 6px 0; }
.ringwrap svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.rbg { fill: none; stroke: var(--surface2); stroke-width: 12; }
.rfg { fill: none; stroke: var(--accent); stroke-width: 12; stroke-linecap: round; transition: stroke-dashoffset .2s linear; }
.ringwrap.blue .rfg { stroke: var(--blue); }
.ringwrap.prep .rfg { stroke: var(--yellow); }
.rcenter { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
#tnum { font-size: clamp(3rem, 16vw, 4.6rem); font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1; }
.rcenter small { color: var(--muted); margin-top: 4px; }
.reps { display: flex; flex-direction: column; align-items: center; margin: 14px 0; }
.reps span { font-size: 5.5rem; font-weight: 800; line-height: 1; color: var(--accent); }
.reps small { color: var(--muted); font-size: 1rem; }
.cue { min-height: 0; font-weight: 800; font-size: 1.3rem; color: var(--yellow); }
.cue.show { animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .5; } }
.desc { width: 100%; text-align: left; background: var(--surface); border-radius: 12px; padding: 10px 14px; }
.desc summary { color: var(--muted); cursor: pointer; }
.desc p { margin: 8px 0 0; }
.nextup { color: var(--muted); font-size: .92rem; }
.nextup b { color: var(--text); }
.controls { margin-top: auto; width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 0 4px; }
.controls .btn.big { flex: 1; }
.controls .icon { width: 56px; height: 56px; }
.stage.rest .sname { color: var(--blue); }

/* Ressenti */
.fb { padding-top: 16px; display: flex; flex-direction: column; gap: 12px; }
.fb h2 { font-size: 1.4rem; }
.hint { color: var(--muted); margin: 0; font-size: .92rem; }
.fbitem { background: var(--surface); border-radius: 14px; padding: 12px; }
.fbname { font-weight: 700; margin-bottom: 8px; }
.lvchip { color: var(--accent); font-size: .85rem; margin-left: 4px; }
.fbbtns { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.fbb { background: var(--surface2); border-radius: 10px; padding: 8px 2px; font-size: .72rem; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.fbb span { font-size: 1.3rem; }
.fbb.sel.facile { background: #1f4a35; outline: 2px solid var(--green); }
.fbb.sel.moyen { background: #2c3a4f; outline: 2px solid var(--blue); }
.fbb.sel.dur { background: #4a3f1a; outline: 2px solid var(--yellow); }
.fbb.sel.douleur { background: #4a1f1f; outline: 2px solid var(--red); }
.fbb.sel.skip { background: var(--line); outline: 2px solid var(--muted); }

/* Bilan */
.summary { text-align: center; padding-top: 30px; }
.summary h1 { font-size: 1.8rem; }
.summary section { text-align: left; }
.trophy { font-size: 4rem; }
.change { background: var(--surface); padding: 10px 14px; border-radius: 12px; margin-bottom: 6px; }
.change.up { color: var(--green); }
.change.down { color: var(--yellow); }
.change b { color: var(--text); }
.alert { background: #3a1f1f; border: 1px solid #6a2f2f; padding: 12px; border-radius: 12px; text-align: left; }

/* Progrès / historique */
.prow { width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 14px; background: var(--surface); border-radius: 12px; margin-bottom: 6px; text-align: left; }
.hitem { padding: 0; }
.hhead { width: 100%; display: flex; justify-content: space-between; align-items: center; padding: 14px; text-align: left; }
.hhead small { display: block; color: var(--muted); }
.badges i { font-style: normal; font-weight: 700; margin-left: 6px; }
.badges .up { color: var(--green); }
.badges .down { color: var(--yellow); }
.hbody { padding: 0 14px 14px; }
.hres { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: .92rem; }
.hres span:last-child { color: var(--muted); white-space: nowrap; }

/* Réglages */
.set { display: flex; justify-content: space-between; align-items: center; gap: 12px; background: var(--surface); padding: 12px 14px; border-radius: 12px; margin-bottom: 6px; }
.set input[type=number] { width: 70px; padding: 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface2); color: var(--text); font: inherit; text-align: center; }
.set input[type=checkbox] { width: 24px; height: 24px; accent-color: var(--accent); }

/* Barre d'onglets */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; display: flex; background: rgba(17, 20, 24, .96); backdrop-filter: blur(10px); border-top: 1px solid var(--line); padding: 6px 4px calc(var(--safe-bottom) + 6px); z-index: 10; }
.tabbar button { flex: 1; display: flex; flex-direction: column; align-items: center; font-size: .72rem; color: var(--muted); padding: 4px 0; }
.tabbar button span { font-size: 1.25rem; filter: grayscale(1); opacity: .7; }
.tabbar button.on { color: var(--accent); }
.tabbar button.on span { filter: none; opacity: 1; }

#toast { position: fixed; left: 50%; bottom: calc(var(--safe-bottom) + 90px); transform: translateX(-50%) translateY(20px); background: var(--surface2); padding: 10px 16px; border-radius: 12px; opacity: 0; pointer-events: none; transition: .25s; z-index: 20; }
#toast.show { opacity: 1; transform: translateX(-50%); }

@media (max-height: 700px) {
  .stage .demo { width: 90px; height: 90px; }
  .ringwrap { width: min(50vw, 180px); }
  .sname { font-size: 1.3rem; }
}
.restel { color: var(--blue); font-weight: 600; min-height: 1.4em; }
