:root {
  --fond: #f6f4f1;
  --carte: #ffffff;
  --texte: #1d1b19;
  --discret: #6f6a64;
  --bord: #e6e1da;
  --accent: #ff5a36;
  --accent-doux: #ffe3db;
  --accent-texte: #ffffff;
  --peau: #e4ddd4;
  --muscle: #cfc6bb;
  --trait: #2b2825;
  --decor: #d8d1c7;
  --alerte: #b5470b;
  --alerte-fond: #fff1e6;
  --ok: #1f8a5b;
  --rayon: 16px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --fond: #141312; --carte: #1f1d1b; --texte: #f2efeb; --discret: #a39d96; --bord: #34312d;
    --accent: #ff6d4d; --accent-doux: #3d2119; --peau: #3a3631; --muscle: #4a4540; --trait: #f2efeb;
    --decor: #45403a; --alerte: #ffab70; --alerte-fond: #33231a; --ok: #4cc28a;
  }
}
:root[data-theme="dark"] {
  --fond: #141312; --carte: #1f1d1b; --texte: #f2efeb; --discret: #a39d96; --bord: #34312d;
  --accent: #ff6d4d; --accent-doux: #3d2119; --peau: #3a3631; --muscle: #4a4540; --trait: #f2efeb;
  --decor: #45403a; --alerte: #ffab70; --alerte-fond: #33231a; --ok: #4cc28a;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--fond); color: var(--texte);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding: 0 16px calc(24px + env(safe-area-inset-bottom));
  max-width: 640px; margin-inline: auto;
}
h1, h2, h3, p { margin: 0; }
button { font: inherit; color: inherit; }

/* En-tête */
.entete { position: sticky; top: 0; z-index: 2; background: var(--fond); padding: 14px 0 10px; }
.marque { display: flex; align-items: center; gap: 10px; }
.logo { width: 38px; height: 38px; display: block; }
h1 { font-size: 19px; letter-spacing: -0.01em; }
.sous-titre { color: var(--discret); font-size: 14px; }
.puces { display: flex; gap: 8px; margin-top: 12px; overflow-x: auto; scrollbar-width: none; }
.puce {
  border: 1px solid var(--bord); background: var(--carte); border-radius: 999px; padding: 6px 14px;
  white-space: nowrap; cursor: pointer; font-size: 14px;
}
.puce.active { background: var(--texte); color: var(--fond); border-color: var(--texte); }

/* Cartes */
.carte { scroll-margin-top: 112px; background: var(--carte); border: 1px solid var(--bord); border-radius: var(--rayon); padding: 16px; margin-top: 12px; }
.chargement, .erreur, .repos { text-align: center; padding: 32px 16px; }
.grand { font-size: 22px; font-weight: 700; margin-bottom: 6px; }
.discret { color: var(--discret); font-size: 14px; }
.erreur .bouton, .repos .bouton { margin-top: 14px; }

.resume { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; }
.resume h2 { font-size: 22px; line-height: 1.2; margin: 2px 0 4px; }
.etiquette { color: var(--accent); font-weight: 700; font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; }
#corps-seance .cp-legende { display: none; }

/* Consignes épaule */
.consignes summary { cursor: pointer; font-weight: 600; display: flex; align-items: center; gap: 8px; list-style: none; }
.consignes summary::-webkit-details-marker { display: none; }
.consignes summary::after { content: "▾"; margin-left: auto; color: var(--discret); }
.consignes[open] summary::after { content: "▴"; }
.consignes ul { margin: 10px 0 0; padding-left: 20px; }
.consignes li { margin: 6px 0; font-size: 15px; }
.pastille-alerte {
  width: 20px; height: 20px; flex: none; border-radius: 50%; background: var(--alerte); color: var(--carte);
  display: inline-grid; place-items: center; font-size: 13px; font-weight: 800;
}

/* Progression */
.progression { margin: 16px 2px 4px; display: flex; align-items: center; gap: 10px; }
.progression-barre { flex: 1; height: 8px; border-radius: 99px; background: var(--bord); position: relative; overflow: hidden; }
.progression-barre::after {
  content: ""; position: absolute; inset: 0; background: var(--accent); border-radius: 99px;
  transform-origin: left; transform: scaleX(var(--k, 0)); transition: transform .3s ease;
}
.progression-texte { font-size: 13px; color: var(--discret); white-space: nowrap; }

/* Exercice */
.exercice header { display: flex; gap: 12px; align-items: flex-start; }
.numero {
  flex: none; width: 30px; height: 30px; border-radius: 50%; background: var(--accent-doux); color: var(--accent);
  display: grid; place-items: center; font-weight: 800;
}
.exercice h3 { font-size: 18px; line-height: 1.25; }
.badge { display: inline-block; margin-left: 8px; vertical-align: 2px; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: var(--accent-doux); color: var(--accent); }
.prescription { font-weight: 600; margin-top: 2px; }
.tempo { font-weight: 400; color: var(--discret); }
.visuels { display: grid; grid-template-columns: 1.3fr 1fr; gap: 10px; margin: 12px 0 6px; align-items: center; }
.schema { background: var(--fond); border-radius: 12px; aspect-ratio: 1; }
.figure { width: 100%; height: 100%; display: block; }
.etapes { margin: 8px 0 0; padding-left: 22px; }
.etapes li { margin: 5px 0; font-size: 15px; }
.securite {
  display: flex; gap: 8px; align-items: flex-start; margin-top: 10px; padding: 10px 12px; border-radius: 12px;
  background: var(--alerte-fond); color: var(--alerte); font-size: 14px;
}

/* Schéma animé */
.fg-corps line { stroke: var(--trait); stroke-width: 6; stroke-linecap: round; }
.fg-corps line.fg-loin { opacity: .45; }
.fg-corps line.fg-echarpe-bras { stroke-width: 5; opacity: .8; }
.fg-tete { fill: var(--trait); }
.fg-echarpe { fill: var(--accent); opacity: .85; stroke: none; }
.fg-sol { stroke: var(--decor); stroke-width: 3; stroke-linecap: round; }
.fg-decor { fill: var(--decor); }
.fg-decor-trait { stroke: var(--decor); stroke-width: 4; }
.fg-tapis { fill: var(--accent-doux); }

/* Silhouettes */
.cp-corps { display: flex; gap: 6px; justify-content: center; }
.cp-vue { margin: 0; text-align: center; }
.cp-vue svg { height: 150px; width: auto; display: block; }
.cp-corps.compact .cp-vue svg { height: 112px; }
.cp-vue figcaption { font-size: 11px; color: var(--discret); text-transform: uppercase; letter-spacing: .05em; }
.cp-peau > * { fill: var(--peau); }
.cp-muscle { fill: var(--muscle); }
.cp-muscle.actif { fill: var(--accent); }
.cp-legende { list-style: none; padding: 0; margin: 6px 0 0; display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; }
.cp-legende li { font-size: 11px; background: var(--accent-doux); color: var(--accent); padding: 2px 8px; border-radius: 99px; }
.mini-corps .cp-legende li { font-size: 10.5px; }

/* Chronomètre */
.chrono { margin-top: 12px; padding: 12px; border-radius: 12px; background: var(--fond); position: relative; overflow: hidden; }
.chrono::before {
  content: ""; position: absolute; left: 0; bottom: 0; height: 4px; width: 100%; background: var(--accent);
  transform-origin: left; transform: scaleX(var(--k, 0));
}
.chrono-haut { display: flex; align-items: center; gap: 14px; margin-bottom: 10px; }
.chrono-cadran { font-size: 30px; font-weight: 800; min-width: 84px; font-variant-numeric: tabular-nums; }
.chrono.en-cours .chrono-cadran { font-size: 44px; color: var(--accent); }
.chrono.preparation .chrono-cadran { color: var(--texte); }
.chrono-etat { font-weight: 600; }
.chrono-compteur { color: var(--discret); font-size: 13px; }
.chrono-boutons { display: flex; gap: 8px; }
.chrono-boutons .bouton.plein { flex: 1; }

/* Saisie fait / demandé */
.saisie { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--bord); }
.saisie.notee { border-top-color: var(--ok); }
.saisie-titre { font-weight: 700; margin-bottom: 8px; }
.saisie-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.saisie-ligne { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.fois { font-weight: 700; color: var(--discret); }
.unite { color: var(--discret); font-size: 14px; }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--bord); border-radius: 12px; overflow: hidden; }
.stepper button { width: 38px; height: 40px; border: 0; background: var(--fond); font-size: 20px; cursor: pointer; }
.stepper input {
  width: 52px; height: 40px; border: 0; text-align: center; font: inherit; font-weight: 700;
  background: var(--carte); color: var(--texte); -moz-appearance: textfield;
}
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* Boutons */
.bouton {
  border: 1px solid var(--bord); background: var(--carte); border-radius: 12px; padding: 10px 14px;
  font-weight: 600; cursor: pointer; min-height: 44px;
}
.bouton.plein { background: var(--accent); border-color: var(--accent); color: var(--accent-texte); }
.bouton.large { width: 100%; margin-top: 16px; font-size: 17px; }
.bouton:disabled { opacity: .6; cursor: default; }
.lien { border: 0; background: none; color: var(--discret); text-decoration: underline; cursor: pointer; padding: 6px 0; font-size: 13px; }

/* Compte rendu */
.compte-rendu h2 { font-size: 20px; margin-bottom: 4px; }
.champ { margin-top: 16px; }
.champ-titre { display: block; font-weight: 700; margin-bottom: 8px; }
.segment { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--bord); border-radius: 12px; overflow: hidden; }
.segment button { border: 0; background: var(--carte); padding: 10px 4px; cursor: pointer; min-height: 44px; }
.segment button + button { border-left: 1px solid var(--bord); }
.segment button.actif { background: var(--texte); color: var(--fond); font-weight: 700; }
.ressentis { display: flex; justify-content: space-between; gap: 6px; }
.ressentis button {
  flex: 1; font-size: 26px; padding: 6px 0; border-radius: 12px; border: 1px solid var(--bord);
  background: var(--carte); cursor: pointer; filter: grayscale(.8); opacity: .7;
}
.ressentis button.actif { filter: none; opacity: 1; border-color: var(--accent); background: var(--accent-doux); }
input[type="range"] { width: 100%; accent-color: var(--accent); }
.douleur-valeur { color: var(--accent); }
.echelle { display: flex; justify-content: space-between; font-size: 12px; color: var(--discret); }
textarea {
  width: 100%; border: 1px solid var(--bord); border-radius: 12px; padding: 10px; font: inherit;
  background: var(--carte); color: var(--texte); resize: vertical;
}
.message { margin-top: 10px; font-size: 14px; }
.message.alerte { color: var(--alerte); }

.pied { display: flex; justify-content: center; align-items: center; gap: 12px; margin-top: 28px; color: var(--discret); font-size: 12px; }

@media (max-width: 340px) {
  .visuels, .resume { grid-template-columns: 1fr; }
}
