:root {
  --bg: #0f1115;
  --card: #181b22;
  --card-2: #20242d;
  --line: #2a2f3a;
  --text: #f3f4f6;
  --muted: #9ca3af;
  --accent: #4ade80;
  --accent-ink: #052e16;
  --warn: #fbbf24;
  --danger: #f87171;
  --radius: 16px;
  --tabbar-h: 68px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 17px;
  line-height: 1.4;
  padding-bottom: calc(var(--tabbar-h) + var(--safe-b) + 16px);
  overscroll-behavior-y: contain;
}
body.has-timer { padding-bottom: calc(var(--tabbar-h) + var(--safe-b) + 170px); }
body[data-route="onboarding"] .tabbar { display: none; }
body[data-route="onboarding"] { padding-bottom: 24px; }

button, input, a.btn { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
button:disabled { opacity: .4; cursor: not-allowed; }

/* ── Barre du haut ─────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 8px;
  padding: 14px 16px; padding-top: calc(14px + env(safe-area-inset-top, 0px));
  background: rgba(15, 17, 21, .92); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar h1 { margin: 0; font-size: 20px; font-weight: 800; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.back { font-size: 32px; line-height: 1; width: 40px; height: 40px; margin: -6px 0 -6px -8px; }

main { padding: 16px; max-width: 640px; margin: 0 auto; }

/* ── Textes ─────────────────────────────────────── */
h2 { font-size: 24px; margin: 8px 0; }
h3 { font-size: 18px; margin: 0; }
.section-title { margin: 24px 0 10px; font-size: 15px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.center { text-align: center; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; }

/* ── Cartes ─────────────────────────────────────── */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.card p { margin: 10px 0 0; }
.badge { background: var(--card-2); border-radius: 999px; padding: 4px 12px; font-size: 14px; font-weight: 600; white-space: nowrap; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.chip { padding: 6px 12px; border-radius: 999px; background: var(--card-2); color: var(--muted); font-size: 14px; font-weight: 600; }
.chip.on { background: var(--accent); color: var(--accent-ink); }

/* ── Boutons ────────────────────────────────────── */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: 56px; padding: 12px 18px; margin: 8px 0;
  border-radius: 14px; font-weight: 700; font-size: 17px; text-decoration: none; text-align: center;
  background: var(--card-2); border: 1px solid var(--line);
  transition: transform .08s;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn-xl { min-height: 64px; font-size: 19px; }
.btn-ghost { background: transparent; }
.btn-danger { background: transparent; color: var(--danger); border-color: rgba(248, 113, 113, .35); }
.btn small { display: block; font-weight: 500; font-size: 14px; opacity: .8; }
.btn-col { flex-direction: column; gap: 2px; }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { margin: 0; flex: 1; min-width: 0; padding: 12px 8px; font-size: 16px; white-space: nowrap; }

/* Choix (onboarding / réglages) */
.choices { display: grid; gap: 10px; }
.choice {
  text-align: left; padding: 16px; border-radius: 14px;
  background: var(--card); border: 2px solid var(--line); min-height: 64px;
}
.choice strong { display: block; font-size: 18px; }
.choice span { color: var(--muted); font-size: 15px; }
.choice.selected { border-color: var(--accent); background: rgba(74, 222, 128, .08); }

.hero { text-align: center; padding: 16px 0 4px; }
.hero .logo { font-size: 56px; }

/* Grille des types de séance */
.type-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.type-btn {
  display: flex; flex-direction: column; align-items: flex-start; justify-content: space-between; gap: 8px;
  min-height: 96px; padding: 14px; border-radius: var(--radius);
  background: var(--card); border: 1px solid var(--line); font-weight: 700; font-size: 17px; text-align: left;
}
.type-btn .ico { font-size: 28px; }
.type-btn:active { background: var(--card-2); }

/* Aperçu de séance */
.preview-item { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.preview-item:last-child { border-bottom: 0; }
.preview-txt { flex: 1; min-width: 0; }
.num { flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--card-2); font-weight: 800; }
.num.ok { background: var(--accent); color: var(--accent-ink); }
.preview-item small, .ex-title small { display: block; color: var(--muted); font-size: 14px; }
.demo-link {
  flex: none; display: flex; flex-direction: column; align-items: center; justify-content: center;
  width: 60px; height: 52px; border-radius: 12px; background: var(--card-2); border: 1px solid var(--line);
  color: #ff4e45; font-size: 18px; text-decoration: none;
}
.demo-link span { font-size: 12px; font-weight: 700; color: var(--text); }
.demo-link:active { background: var(--line); }
.demo-link.swap { color: var(--accent); }
.preview-card { padding: 4px 12px; }
.preview-card .preview-item { gap: 8px; }
.preview-card .demo-link { width: 50px; }
.preview-card .num { width: 28px; height: 28px; font-size: 14px; }

/* ── Séance en cours ────────────────────────────── */
.progress { height: 8px; background: var(--card-2); border-radius: 99px; overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); transition: width .3s; }

.ex { padding: 0; overflow: hidden; }
.ex.active { border-color: var(--accent); }
.ex.complete .ex-title strong { color: var(--muted); }
.ex-head { display: flex; align-items: center; gap: 12px; width: 100%; padding: 14px 16px; text-align: left; min-height: 64px; }
.ex-title { flex: 1; min-width: 0; }
.ex-title strong { display: block; font-size: 18px; }
.ex-count { font-weight: 800; color: var(--muted); }
.ex-body { padding: 0 16px 16px; }
.ex-meta { color: var(--muted); font-size: 14px; }
.last { margin: 10px 0; padding: 10px 12px; border-radius: 12px; background: var(--card-2); font-size: 15px; }
.last strong { color: var(--warn); }

.sets { margin-top: 8px; }
.set { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.set-n { flex: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-size: 14px; font-weight: 800; background: var(--card-2); }
.set.done .set-n { background: var(--accent); color: var(--accent-ink); }
.set.done .set-val { flex: 1; font-size: 18px; font-weight: 700; }
.icon-btn { width: 44px; height: 44px; border-radius: 12px; color: var(--muted); font-size: 18px; }

.set.next { flex-wrap: wrap; }
.inputs { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; }
.stepper { display: flex; align-items: stretch; background: var(--card-2); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.stepper button { width: 46px; font-size: 24px; font-weight: 700; color: var(--accent); }
.stepper button:active { background: var(--line); }
.stepper label { flex: 1; display: flex; flex-direction: column; align-items: center; padding: 6px 0; min-width: 0; }
.stepper input {
  width: 100%; border: 0; background: transparent; text-align: center;
  font-size: 26px; font-weight: 800; padding: 0; outline: none; -moz-appearance: textfield;
}
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.stepper span { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }

/* ── Chrono ─────────────────────────────────────── */
.timer {
  position: fixed; left: 8px; right: 8px; z-index: 20;
  bottom: calc(var(--tabbar-h) + var(--safe-b) + 8px);
  max-width: 624px; margin: 0 auto;
  background: #11261a; border: 2px solid var(--accent); border-radius: 20px;
  padding: 0 12px 10px; overflow: hidden; box-shadow: 0 10px 30px rgba(0, 0, 0, .5);
}
.timer.ending { animation: pulse .5s infinite alternate; }
.timer.done { background: var(--accent); color: var(--accent-ink); }
@keyframes pulse { to { background: #1d4d2e; } }
.timer-bar { height: 6px; margin: 0 -12px; background: rgba(255, 255, 255, .08); }
.timer-bar > div { height: 100%; background: var(--accent); transition: width .25s linear; }
.timer-row { display: flex; align-items: center; justify-content: space-between; padding-top: 6px; }
.timer-center { text-align: center; }
.timer-label { font-size: 14px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; opacity: .8; }
.timer-time { font-size: 52px; font-weight: 900; font-variant-numeric: tabular-nums; line-height: 1.05; }
.timer-btn { width: 72px; height: 56px; border-radius: 14px; background: rgba(255, 255, 255, .08); font-weight: 800; font-size: 18px; }
.timer-skip { width: 100%; min-height: 44px; margin-top: 6px; border-radius: 12px; font-weight: 700; background: rgba(255, 255, 255, .06); }
.timer.done .timer-btn, .timer.done .timer-skip { background: rgba(0, 0, 0, .12); }

/* ── Barre d'onglets ────────────────────────────── */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 15;
  display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--tabbar-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: rgba(15, 17, 21, .96); backdrop-filter: blur(10px); border-top: 1px solid var(--line);
}
.tabbar button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 12px; font-weight: 600; color: var(--muted); }
.tabbar .ico { font-size: 22px; filter: grayscale(1); opacity: .7; }
.tabbar button.active { color: var(--text); }
.tabbar button.active .ico { filter: none; opacity: 1; }

/* ── Historique ─────────────────────────────────── */
.hist-head { display: block; width: 100%; text-align: left; }
.hist-stats { display: flex; gap: 14px; margin-top: 6px; color: var(--muted); font-size: 14px; flex-wrap: wrap; }
.hist-ex { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.hist-ex strong { display: block; }
.hist-ex span { color: var(--muted); font-size: 15px; }

/* ── Suivi ──────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.stat b { display: block; font-size: 28px; font-weight: 900; }
.stat span { color: var(--muted); font-size: 14px; }
.chart { width: 100%; height: 200px; display: block; margin-top: 12px; }
.inline-form { display: flex; gap: 10px; margin-top: 12px; }
.inline-form input {
  flex: 1; min-width: 0; min-height: 56px; padding: 0 14px; border-radius: 14px;
  background: var(--card-2); border: 1px solid var(--line); font-size: 20px; font-weight: 700;
}
.inline-form .btn { width: auto; margin: 0; }
.bw-list { margin-top: 8px; }
.bw-item { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; border-top: 1px solid var(--line); }

/* ── Feuille modale (Ajouter un exercice) ───────── */
.sheet-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .6); display: flex; align-items: flex-end; }
.sheet {
  width: 100%; max-width: 640px; margin: 0 auto; max-height: 80vh; overflow-y: auto;
  background: var(--card); border-radius: 22px 22px 0 0; padding: 18px 16px calc(18px + var(--safe-b));
  animation: up .2s ease-out;
}
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.sheet h3 { margin-bottom: 4px; }
.alt { display: block; width: 100%; text-align: left; padding: 14px; margin-top: 8px; border-radius: 14px; background: var(--card-2); border: 1px solid var(--line); min-height: 60px; }
.alt strong { display: block; }
.alt small { color: var(--muted); }
.tag { display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 99px; font-size: 12px; font-weight: 700; background: rgba(251, 191, 36, .15); color: var(--warn); }

/* ── Toast ──────────────────────────────────────── */
.toast {
  position: fixed; left: 50%; top: calc(70px + env(safe-area-inset-top, 0px)); transform: translateX(-50%); z-index: 60;
  background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: 999px; font-weight: 700;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .4); max-width: 90vw; text-align: center;
}

.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.empty .big { font-size: 48px; }

/* Séance perso : choix des muscles */
.chips.pick { margin: 0 0 4px; }
.pick-chip { min-height: 44px; padding: 8px 14px; font-size: 15px; border: 1px solid var(--line); }
.pick-chip.on { border-color: transparent; }

.howto ol { margin: 8px 0 0; padding-left: 20px; }
.howto li { margin: 4px 0; }
.howto p { margin-top: 8px; }

/* Profil Homme / Femme */
.choices.two { grid-template-columns: 1fr 1fr; }
.choices.two .choice span { font-size: 13px; }
.card.highlight { border-color: var(--accent); background: linear-gradient(135deg, rgba(74, 222, 128, .12), var(--card)); }

/* Cardio */
.stat.wide { grid-column: span 2; }
.last.note { background: rgba(74, 222, 128, .08); border: 1px solid rgba(74, 222, 128, .25); }
.btn-cardio { border-color: var(--accent); color: var(--accent); }
.timer.fast { border-color: var(--danger); background: #2b1212; }
.timer.fast .timer-bar > div { background: var(--danger); }
.timer.slow { border-color: #60a5fa; background: #10203a; }
.timer.slow .timer-bar > div { background: #60a5fa; }

/* Records, conseil de charge */
.rec-line { margin-top: 6px; color: var(--text); }
.rec-line b { color: var(--accent); }
.last.tip { background: rgba(96, 165, 250, .1); border: 1px solid rgba(96, 165, 250, .35); }
.last.tip b { color: #93c5fd; }
.set.done.pr .set-n { background: var(--warn); color: #3b2500; }
.set.done.pr .set-val { color: var(--warn); }
.rec-item { display: flex; justify-content: space-between; align-items: center; gap: 10px; width: 100%; padding: 12px 0; border-top: 1px solid var(--line); text-align: left; min-height: 56px; }
.rec-item strong { display: block; }
.rec-item small { color: var(--muted); font-size: 13px; }
.rec-item b { color: var(--warn); white-space: nowrap; }
.rec-item.open b { color: var(--accent); }
.rec-detail { padding-bottom: 8px; }

/* ⭐ Exercice favori : petite étoile après le nom */
.star { display: inline-block; padding: 2px 6px; margin: -4px 0 -4px -2px; font-size: 20px; line-height: 1; color: var(--muted); cursor: pointer; vertical-align: -1px; }
.star.on { color: var(--warn); }
.star:active { transform: scale(1.3); }
.fav-ex .chips { margin-top: 8px; }
.fav-chip { display: inline-flex; align-items: center; gap: 6px; background: rgba(251, 191, 36, .15); color: var(--warn); }
.chip-x { padding: 0 2px 0 4px; cursor: pointer; opacity: .8; }

/* Exercices perso : formulaire et liste dans les réglages */
.form-label { display: block; margin: 16px 0 6px; font-weight: 700; font-size: 15px; }
.form-input { width: 100%; min-height: 52px; padding: 0 14px; border-radius: 14px; background: var(--card-2); border: 1px solid var(--line); font-size: 17px; color: var(--text); }
.form-input:focus { outline: 2px solid var(--accent); border-color: transparent; }
.sheet .chips { margin-top: 0; }
.sheet .pick-chip { min-height: 42px; }
.cx-item { display: flex; align-items: center; gap: 4px; padding: 10px 0; border-top: 1px solid var(--line); }
.cx-txt { flex: 1; min-width: 0; }
.cx-txt strong { display: block; }
.cx-txt small { color: var(--muted); font-size: 13px; }
.tag.perso { background: rgba(74, 222, 128, .15); color: var(--accent); }

/* Ajouter (en haut) / Retirer un exercice */
.btn-add { border: 1px dashed var(--accent); color: var(--accent); background: rgba(74, 222, 128, .06); margin: 4px 0 12px; }
.preview-card .demo-link { width: 46px; }
.demo-link.del { color: var(--muted); font-size: 16px; }
.btn-link { display: block; width: 100%; margin-top: 10px; padding: 10px; background: none; font-size: 15px; font-weight: 600; color: var(--muted); text-align: center; }
.btn-link.danger { color: var(--danger); opacity: .85; }
.add-row { margin: 4px 0 12px; }
.add-row .btn-add { margin: 0; font-size: 15px; padding: 12px 6px; }

/* Fenêtre de confirmation de l'app */
.btn-danger-solid { background: var(--danger); color: #3b0a0a; border-color: transparent; }
.sheet h3 + p.muted { margin: 8px 0 0; }

/* 🔥 Échauffement */
.warm-tip { background: #2a2f39; border-color: #3a404c; border-left: 4px solid var(--accent); }
.warm-tip p { margin-top: 6px; }
.warmup { margin: 12px 0 4px; padding: 12px; border-radius: 14px; background: #2e3440; border: 1px solid #3d4452; }
.warmup .row-between strong { white-space: nowrap; }
.warmup .row-between .muted { text-align: right; font-size: 13px; }
.warmup.done { color: var(--accent); font-weight: 700; font-size: 15px; background: rgba(74, 222, 128, .08); border-color: rgba(74, 222, 128, .3); }
.wu-row { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 48px; padding: 6px 2px; text-align: left; border-top: 1px solid #3d4452; }
.wu-check { font-size: 20px; width: 26px; text-align: center; }
.wu-txt { flex: 1; font-weight: 700; font-size: 17px; }
.wu-row small { color: var(--muted); }
.wu-row.ok .wu-txt { color: var(--muted); text-decoration: line-through; }
.warmup .btn-link { margin-top: 4px; padding: 6px; }

/* Rappel de sauvegarde + liens */
.export-reminder { border-color: rgba(96, 165, 250, .45); background: linear-gradient(135deg, rgba(96, 165, 250, .1), var(--card)); }
.export-reminder p { margin-top: 6px; }
.export-reminder .btn-row .btn { min-height: 48px; }
a.link { color: var(--accent); }
