/* ============================================================
   Composants — PWA Muscu
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }

/* `display: flex` sur une classe l'emporte sur la feuille de style de
   l'agent utilisateur : sans cette règle, l'attribut `hidden` n'a aucun
   effet sur .chips et le sélecteur de RPE reste toujours visible. */
[hidden] { display: none !important; }

html, body {
  margin: 0; padding: 0;
  height: 100%;
  overscroll-behavior-y: none;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--t-base);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  text-rendering: optimizeLegibility;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; padding: 0; }
a { color: var(--accent); text-decoration: none; }
ul, ol { margin: 0; padding: 0; list-style: none; }
h1, h2, h3, h4, p { margin: 0; }

::selection { background: var(--accent); color: var(--accent-ink); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}

/* ------------------------------------------------------------
   Coquille
   ------------------------------------------------------------ */

/* L'app est pensée pour un téléphone tenu à une main. Sur un écran large
   on garde la même colonne plutôt que d'étirer la mise en page : les
   cibles tactiles et la longueur de ligne restent celles pour lesquelles
   l'interface a été dessinée. */
:root { --shell: 560px; }

#app {
  min-height: 100dvh;
  max-width: var(--shell);
  margin-inline: auto;
  padding-bottom: var(--tabbar-h);
  padding-left: var(--sal);
  padding-right: var(--sar);
}
body.is-session #app { padding-bottom: 0; }

@media (min-width: 620px) {
  body { background: color-mix(in srgb, var(--bg) 92%, #000); }
  #app { background: var(--bg); border-inline: 1px solid var(--line); }
}

.screen { padding: 0 var(--s4) var(--s8); }

.screen__head {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: var(--s3);
  padding: calc(var(--sat) + var(--s5)) var(--s4) var(--s3);
  margin: 0 calc(var(--s4) * -1) var(--s4);
  background: linear-gradient(var(--bg) 72%, transparent);
  backdrop-filter: blur(8px);
}
.screen__title {
  font-size: var(--t-xl);
  font-weight: 680;
  letter-spacing: -0.024em;
  line-height: 1.05;
}
.screen__sub {
  color: var(--text-2);
  font-size: var(--t-sm);
  margin-top: 2px;
}

/* ------------------------------------------------------------
   Primitives typographiques
   ------------------------------------------------------------ */

.label {
  font-size: var(--t-micro);
  font-weight: 620;
  letter-spacing: 0.085em;
  text-transform: uppercase;
  color: var(--text-3);
}
.label--accent { color: var(--accent); }

.num {
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1, "zero" 1;
  letter-spacing: -0.02em;
}

.muted { color: var(--text-2); }
.dim   { color: var(--text-3); }

/* ------------------------------------------------------------
   Panneau — structure à angles nets, filet 1 px, pas d'ombre
   ------------------------------------------------------------ */

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}
.panel + .panel { margin-top: var(--s3); }
.panel__head {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s3);
  padding: var(--s3) var(--s4);
  border-bottom: 1px solid var(--line);
}
.panel__body { padding: var(--s4); }
.panel__body--flush { padding: 0; }

.rows > * + * { border-top: 1px solid var(--line); }
.row {
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s3) var(--s4);
  min-height: var(--tap);
}
.row__main { flex: 1; min-width: 0; }
.row__title {
  font-weight: 560;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.row__meta { font-size: var(--t-sm); color: var(--text-2); }
.row__value { font-size: var(--t-sm); color: var(--text-2); white-space: nowrap; }

button.row, a.row { width: 100%; text-align: left; }
button.row:active { background: var(--panel-2); }

/* ------------------------------------------------------------
   Boutons
   ------------------------------------------------------------ */

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--s2);
  min-height: var(--tap);
  padding: 0 var(--s5);
  border-radius: var(--r-pill);
  background: var(--panel-2);
  border: 1px solid var(--line-strong);
  color: var(--text);
  font-weight: 600;
  font-size: var(--t-base);
  transition: transform var(--fast) var(--ease), background var(--fast);
}
.btn:active { transform: scale(0.97); }
.btn--block { display: flex; width: 100%; }
.btn--lg { min-height: 60px; font-size: var(--t-md); }
.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
}
.btn--primary:active { background: var(--accent-hot); }
.btn--ghost { background: transparent; border-color: var(--line); color: var(--text-2); }
.btn--danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn--ok { background: var(--ok); border-color: var(--ok); color: #04240f; font-weight: 700; }
.btn[disabled] { opacity: 0.42; pointer-events: none; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: var(--tap); height: var(--tap);
  border-radius: var(--r-pill);
  color: var(--text-2);
  flex: none;
}
.icon-btn:active { background: var(--panel-2); }
.icon-btn svg { width: 22px; height: 22px; }

/* ------------------------------------------------------------
   Puces — contrôles tappables, pleinement ronds
   ------------------------------------------------------------ */

.chips {
  display: flex; gap: var(--s2);
  overflow-x: auto; scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x proximity;
  padding-bottom: 2px;
}
.chips::-webkit-scrollbar { display: none; }

.chip {
  flex: none;
  min-width: 46px; min-height: 46px;
  padding: 0 var(--s4);
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text-2);
  font-weight: 620;
  font-variant-numeric: tabular-nums;
  scroll-snap-align: center;
  transition: transform var(--fast) var(--ease);
}
.chip:active { transform: scale(0.92); }
.chip--target {           /* dans la fourchette visée */
  border-color: var(--line-strong);
  color: var(--text);
}
.chip[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.chip--sm { min-width: 40px; min-height: 40px; font-size: var(--t-sm); padding: 0 var(--s3); }

/* ------------------------------------------------------------
   Barre d'onglets
   ------------------------------------------------------------ */

.tabbar {
  position: fixed; inset: auto 0 0 0; z-index: 40;
  max-width: var(--shell); margin-inline: auto;
  display: grid; grid-template-columns: repeat(4, 1fr);
  height: var(--tabbar-h);
  padding-bottom: var(--sab);
  background: color-mix(in srgb, var(--bg-elev) 88%, transparent);
  backdrop-filter: blur(18px) saturate(1.4);
  border-top: 1px solid var(--line);
}
body.is-session .tabbar { display: none; }
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px;
  color: var(--text-3);
  font-size: 10px; font-weight: 600; letter-spacing: 0.02em;
}
.tab svg { width: 23px; height: 23px; }
.tab[aria-current="page"] { color: var(--accent); }

/* ------------------------------------------------------------
   Écran Aujourd'hui
   ------------------------------------------------------------ */

.daypick { display: flex; gap: var(--s2); margin-bottom: var(--s4); }
.daypick__item {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: var(--s3) var(--s1);
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--panel);
  min-height: 62px;
  transition: transform var(--fast) var(--ease);
}
.daypick__item:active { transform: scale(0.96); }
.daypick__day { font-size: var(--t-micro); letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-3); }
.daypick__name { font-weight: 680; font-size: var(--t-sm); }
.daypick__item[aria-pressed="true"] {
  background: var(--accent-ghost);
  border-color: var(--accent-line);
}
.daypick__item[aria-pressed="true"] .daypick__name { color: var(--accent); }
.daypick__item[data-today="1"]::after {
  content: ""; width: 4px; height: 4px; border-radius: 50%;
  background: var(--text-3);
}
.daypick__item[data-today="1"][aria-pressed="true"]::after { background: var(--accent); }

.hero {
  padding: var(--s5) var(--s4);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background:
    radial-gradient(120% 100% at 100% 0%, var(--accent-ghost), transparent 62%),
    var(--panel);
  margin-bottom: var(--s4);
}
.hero__focus { margin-top: 2px; color: var(--text-2); font-size: var(--t-sm); }
.hero__name {
  font-size: var(--t-xl); font-weight: 700; letter-spacing: -0.026em; line-height: 1.08;
}
.hero__stats {
  display: flex; gap: var(--s6);
  margin: var(--s4) 0 var(--s5);
}
.stat__val { font-size: var(--t-lg); font-weight: 680; }
.stat__val sup { font-size: 0.55em; font-weight: 600; color: var(--text-3); margin-left: 1px; }

.banner {
  display: flex; gap: var(--s3);
  padding: var(--s3) var(--s4);
  border-radius: var(--r-md);
  font-size: var(--t-sm);
  margin-bottom: var(--s4);
  border: 1px solid;
}
.banner--warn { background: var(--warn-ghost); border-color: color-mix(in srgb, var(--warn) 40%, transparent); color: var(--text); }
.banner--accent { background: var(--accent-ghost); border-color: var(--accent-line); }
.banner--ok { background: var(--ok-ghost); border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.banner strong { display: block; }

.blockcard { margin-bottom: var(--s3); }
.blockcard__head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: var(--s3); padding: var(--s3) var(--s4);
  border-bottom: 1px solid var(--line);
}
.blockcard__ex {
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s3) var(--s4);
  font-size: var(--t-sm);
}
.blockcard__ex + .blockcard__ex { border-top: 1px solid var(--line); }
.blockcard__ex-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.blockcard__ex-scheme { color: var(--text-2); white-space: nowrap; }

/* ------------------------------------------------------------
   Séance — rail + scène
   ------------------------------------------------------------ */

.session {
  display: grid;
  grid-template-columns: 26px 1fr;
  min-height: 100dvh;
  background: var(--bg);
}

.rail {
  position: relative;
  padding: calc(var(--sat) + var(--s4)) 0 calc(var(--sab) + var(--s4));
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column; align-items: center;
  gap: 3px;
  overflow: hidden;
}
.rail__tick {
  width: 8px; flex: 1 1 0; min-height: 3px; max-height: 22px;
  border-radius: 2px;
  background: var(--line-strong);
  transition: background var(--mid) var(--ease), width var(--mid) var(--ease);
}
.rail__tick[data-state="done"] { background: var(--ok); }
.rail__tick[data-state="now"] {
  background: var(--accent);
  width: 14px;
  box-shadow: 0 0 12px var(--accent-line);
}
.rail__tick[data-boundary="1"] { margin-top: 9px; }
.rail__tick[data-boundary="1"]::before {
  content: ""; position: absolute; left: 4px; right: 4px;
  height: 1px; background: var(--line-strong); margin-top: -5px;
}

.stage {
  display: flex; flex-direction: column;
  min-height: 100dvh;
  padding-bottom: var(--sab);
  position: relative;
  overflow: hidden;
}

.sess-head {
  display: flex; align-items: center; gap: var(--s2);
  padding: calc(var(--sat) + var(--s3)) var(--s4) var(--s3);
  border-bottom: 1px solid var(--line);
}
.sess-head__main { flex: 1; min-width: 0; }
.sess-head__title { font-weight: 660; font-size: var(--t-base); }
.sess-head__prog { font-size: var(--t-micro); letter-spacing: 0.07em; text-transform: uppercase; color: var(--text-3); }

/* ------------------------------------------------------------
   Carte de série
   ------------------------------------------------------------ */

.setcard {
  flex: 1;
  display: flex; flex-direction: column;
  padding: var(--s4);
  gap: var(--s3);
  animation: cardIn var(--mid) var(--ease);
}
@keyframes cardIn {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .setcard { animation: none; }
  * { transition-duration: 1ms !important; }
}

.setcard__ctx {
  display: flex; align-items: center; gap: var(--s2);
}
.setcard__badge {
  padding: 4px var(--s3);
  border-radius: var(--r-pill);
  background: var(--accent-ghost);
  border: 1px solid var(--accent-line);
  color: var(--accent);
  font-size: var(--t-micro); font-weight: 700;
  letter-spacing: 0.07em; text-transform: uppercase;
  white-space: nowrap;
}
.setcard__badge--split { background: var(--warn-ghost); border-color: color-mix(in srgb, var(--warn) 45%, transparent); color: var(--warn); }
.setcard__badge--sub  { background: var(--target-ghost); border-color: color-mix(in srgb, var(--target) 45%, transparent); color: var(--target); }

.setcard__name {
  font-size: var(--t-lg); font-weight: 700;
  letter-spacing: -0.02em; line-height: 1.15;
  text-wrap: balance;
}
.setcard__scheme { color: var(--text-2); font-size: var(--t-sm); }

.ghostperf {
  display: flex; align-items: center; gap: var(--s2);
  padding: var(--s3);
  border-radius: var(--r-sm);
  background: var(--panel);
  border: 1px solid var(--line);
  font-size: var(--t-sm);
  color: var(--text-2);
}
.ghostperf__sets { font-family: var(--font-num); color: var(--text); }
.hint {
  display: flex; gap: var(--s2); align-items: flex-start;
  font-size: var(--t-sm);
  padding: var(--s2) var(--s3);
  border-radius: var(--r-sm);
}
.hint--up    { background: var(--ok-ghost); color: var(--ok); }
.hint--hold  { background: var(--panel-2); color: var(--text-2); }
.hint--reset { background: var(--warn-ghost); color: var(--warn); }
.hint--planb { background: var(--danger-ghost); color: var(--danger); }
.hint--first { background: var(--target-ghost); color: var(--target); }

/* Sélecteur de charge */
.loadpick {
  display: grid;
  grid-template-columns: 64px 1fr 64px;
  align-items: center;
  gap: var(--s2);
  margin-top: auto;
}
.loadpick__btn {
  height: 64px;
  border-radius: var(--r-md);
  background: var(--panel-2);
  border: 1px solid var(--line-strong);
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; font-weight: 400; color: var(--text);
  transition: transform var(--fast) var(--ease), background var(--fast);
}
.loadpick__btn:active { transform: scale(0.93); background: var(--panel-hi); }
.loadpick__val {
  text-align: center;
  padding: var(--s1) 0;
  border-radius: var(--r-md);
}
.loadpick__val:active { background: var(--panel); }
.loadpick__n {
  display: block;
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
  font-size: var(--t-read);
  font-weight: 620;
  line-height: 1;
  letter-spacing: -0.035em;
}
.loadpick__u { display: block; margin-top: 2px; font-size: var(--t-micro); letter-spacing: 0.1em; color: var(--text-3); text-transform: uppercase; }
.loadpick__step { text-align: center; font-size: var(--t-micro); color: var(--text-3); margin-top: var(--s1); }

.field { margin-top: var(--s3); }
.field__lab { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--s2); }

.rpe-toggle {
  display: flex; align-items: center; gap: var(--s2);
  font-size: var(--t-sm); color: var(--text-3);
  padding: var(--s2) 0;
}

.setcard__cta { margin-top: var(--s4); }

/* ------------------------------------------------------------
   Minuteur de repos — l'écran entier devient l'instrument
   ------------------------------------------------------------ */

.rest {
  position: absolute; inset: 0; z-index: 30;
  display: flex; flex-direction: column; align-items: center;
  padding: calc(var(--sat) + var(--s6)) var(--s4) calc(var(--sab) + var(--s5));
  background: var(--bg);
  animation: restIn var(--mid) var(--ease);
}
@keyframes restIn { from { opacity: 0; } to { opacity: 1; } }

.rest__ring { position: relative; width: min(74vw, 300px); aspect-ratio: 1; margin: auto 0 0; }
.rest__ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.rest__track { fill: none; stroke: var(--line); stroke-width: 6; }
.rest__bar   { fill: none; stroke: var(--accent); stroke-width: 6; stroke-linecap: round; transition: stroke var(--mid); }
.rest.is-over .rest__bar { stroke: var(--ok); }
.rest__center {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.rest__clock {
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
  font-size: var(--t-clock);
  font-weight: 600;
  line-height: 0.95;
  letter-spacing: -0.05em;
}
.rest__next {
  margin: var(--s6) 0 auto;
  text-align: center;
  max-width: 26ch;
}
.rest__next-name { font-size: var(--t-md); font-weight: 660; margin-top: var(--s1); text-wrap: balance; }
.rest__next-scheme { color: var(--text-2); font-size: var(--t-sm); margin-top: 2px; }
.rest__ctrl { display: flex; gap: var(--s3); width: 100%; }
.rest__ctrl .btn { flex: 1; }

/* ------------------------------------------------------------
   Échauffement
   ------------------------------------------------------------ */

.warmup { flex: 1; display: flex; flex-direction: column; padding: var(--s4); gap: var(--s3); }
.warmup__list { flex: 1; }
.warmup__step {
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s3) 0;
  border-bottom: 1px solid var(--line);
}
.warmup__step[data-state="now"] .warmup__name { color: var(--accent); font-weight: 660; }
.warmup__step[data-state="done"] { opacity: 0.42; }
.warmup__t {
  font-family: var(--font-num); font-variant-numeric: tabular-nums;
  color: var(--text-3); font-size: var(--t-sm); width: 46px; flex: none;
}
.warmup__main { flex: 1; min-width: 0; }
.warmup__detail { color: var(--text-2); font-size: var(--t-sm); }

/* ------------------------------------------------------------
   Feuille modale
   ------------------------------------------------------------ */

.sheet-backdrop {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(3px);
  animation: fadeIn var(--fast) var(--ease);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.sheet {
  position: fixed; inset: auto 0 0 0; z-index: 61;
  max-width: var(--shell); margin-inline: auto;
  max-height: 88dvh;
  display: flex; flex-direction: column;
  background: var(--bg-elev);
  border-top: 1px solid var(--line-strong);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  padding-bottom: var(--sab);
  animation: sheetIn var(--mid) var(--ease);
}
@keyframes sheetIn { from { transform: translateY(100%); } to { transform: none; } }
.sheet__grip { width: 38px; height: 4px; border-radius: 2px; background: var(--line-strong); margin: var(--s2) auto var(--s1); }
.sheet__head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); padding: var(--s3) var(--s4); }
.sheet__title { font-size: var(--t-md); font-weight: 680; }
.sheet__body { overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 0 var(--s4) var(--s5); }

/* Pavé numérique */
.numpad__display {
  font-family: var(--font-num); font-variant-numeric: tabular-nums;
  font-size: clamp(2rem, 9dvh, 3.4rem); font-weight: 620; text-align: center;
  padding: var(--s2) 0 var(--s3);
  letter-spacing: -0.035em;
  border-bottom: 1px solid var(--line);
  margin-bottom: var(--s4);
}
.numpad__grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s2); }
.numpad__key {
  height: min(62px, 8.2dvh);
  min-height: 50px;
  border-radius: var(--r-md);
  background: var(--panel-2);
  border: 1px solid var(--line);
  font-family: var(--font-num); font-size: var(--t-lg); font-weight: 560;
  display: flex; align-items: center; justify-content: center;
  transition: transform var(--fast) var(--ease);
}
.numpad__key:active { transform: scale(0.94); background: var(--panel-hi); }
.numpad__key--fn { color: var(--text-2); font-size: var(--t-md); }

/* ------------------------------------------------------------
   Exercices
   ------------------------------------------------------------ */

.search {
  display: flex; align-items: center; gap: var(--s2);
  height: var(--tap);
  padding: 0 var(--s4);
  border-radius: var(--r-pill);
  background: var(--panel);
  border: 1px solid var(--line);
  margin-bottom: var(--s3);
}
.search input {
  flex: 1; min-width: 0;
  background: none; border: 0; outline: none;
  font-size: var(--t-base);
}
.search input[type="password"] { letter-spacing: 0.14em; }
.search svg { width: 18px; height: 18px; color: var(--text-3); flex: none; }

.exlist__group { margin-top: var(--s5); }
.exlist__group:first-child { margin-top: 0; }
.exrow {
  display: flex; align-items: center; gap: var(--s3);
  width: 100%; text-align: left;
  padding: var(--s2) var(--s3);
  border-radius: var(--r-md);
  min-height: 60px;
}
.exrow:active { background: var(--panel); }
/* Format paysage plutôt que carré : les photos sont en 3:2, un carré
   rognerait le sujet et le matériel qui l'entoure. */
.exrow__fig {
  width: 68px; height: 46px; flex: none;
  border-radius: var(--r-sm);
  background: var(--panel);
  border: 1px solid var(--line);
  overflow: hidden;
}
.exrow__main { flex: 1; min-width: 0; }
.exrow__name { display: block; font-weight: 560; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.exrow__meta { display: block; font-size: var(--t-sm); color: var(--text-3); }

.figure-wrap {
  background:
    linear-gradient(var(--panel), var(--bg-elev));
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
  position: relative;
}
.figure-wrap svg { display: block; width: 100%; height: auto; }
.figure-wrap__cap {
  position: absolute; left: var(--s3); bottom: var(--s3);
  display: flex; gap: var(--s2); align-items: center;
}
.tempo-pill {
  padding: 3px var(--s3);
  border-radius: var(--r-pill);
  background: color-mix(in srgb, var(--bg) 74%, transparent);
  border: 1px solid var(--line);
  font-size: var(--t-micro); letter-spacing: 0.06em;
  color: var(--text-2);
  font-family: var(--font-num);
}

.cues { }
.cues li {
  display: flex; gap: var(--s3);
  padding: var(--s3) 0;
  border-bottom: 1px solid var(--line);
  font-size: var(--t-base);
}
.cues li:last-child { border-bottom: 0; }
.cues__mark { flex: none; color: var(--ok); font-weight: 700; }
.cues--bad .cues__mark { color: var(--danger); }

.muscle-tags { display: flex; flex-wrap: wrap; gap: var(--s2); }
.mtag {
  padding: 5px var(--s3);
  border-radius: var(--r-pill);
  font-size: var(--t-sm);
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text-2);
}
.mtag--primary { background: var(--accent-ghost); border-color: var(--accent-line); color: var(--accent); }

.photo-slot {
  position: relative;
  aspect-ratio: 4 / 3;
  border-radius: var(--r-lg);
  border: 1px dashed var(--line-strong);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--s2);
  color: var(--text-3);
  background: var(--panel);
  overflow: hidden;
  width: 100%;
}
.photo-slot img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.photo-slot__hint { font-size: var(--t-sm); text-align: center; padding: 0 var(--s4); text-wrap: balance; }

/* ------------------------------------------------------------
   Progrès
   ------------------------------------------------------------ */

.seg {
  display: flex; gap: 2px; padding: 3px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r-pill);
  margin-bottom: var(--s4);
}
.seg button {
  flex: 1; min-height: 40px;
  border-radius: var(--r-pill);
  font-size: var(--t-sm); font-weight: 600;
  color: var(--text-2);
}
.seg button[aria-pressed="true"] { background: var(--panel-hi); color: var(--text); }

.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--s3); margin-bottom: var(--s4); }
.kpi {
  padding: var(--s4);
  border-radius: var(--r-md);
  background: var(--panel);
  border: 1px solid var(--line);
}
.kpi__v { font-family: var(--font-num); font-variant-numeric: tabular-nums; font-size: var(--t-lg); font-weight: 640; letter-spacing: -0.03em; }
.kpi__v sup { font-family: var(--font); font-size: 0.5em; color: var(--text-3); margin-left: 2px; }

.vbar { padding: var(--s3) var(--s4); border-bottom: 1px solid var(--line); }
.vbar:last-child { border-bottom: 0; }
.vbar__top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; font-size: var(--t-sm); }
.vbar__n { font-family: var(--font-num); font-variant-numeric: tabular-nums; color: var(--text-2); }
.vbar__track {
  position: relative; height: 10px; border-radius: var(--r-pill);
  background: var(--panel-2); overflow: hidden;
}
.vbar__zone {
  position: absolute; top: 0; bottom: 0;
  background: var(--target-ghost);
  border-left: 1px solid color-mix(in srgb, var(--target) 55%, transparent);
  border-right: 1px solid color-mix(in srgb, var(--target) 55%, transparent);
}
.vbar__fill { position: absolute; top: 0; bottom: 0; left: 0; border-radius: var(--r-pill); background: var(--text-2); }
.vbar[data-in="1"] .vbar__fill { background: var(--ok); }
.vbar[data-in="over"] .vbar__fill { background: var(--warn); }

.chart { width: 100%; display: block; }
.chart__line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart__area { fill: url(#chartGrad); }
.chart__dot  { fill: var(--accent); }
.chart__grid { stroke: var(--line); stroke-width: 1; }
.chart__lab  { fill: var(--text-3); font-size: 10px; font-family: var(--font-num); }

.empty {
  text-align: center; padding: var(--s8) var(--s5);
  color: var(--text-3);
}
.empty__t { color: var(--text-2); font-weight: 600; margin-bottom: var(--s2); }

/* ------------------------------------------------------------
   Réglages
   ------------------------------------------------------------ */

.switch {
  position: relative; width: 50px; height: 30px; flex: none;
  border-radius: var(--r-pill);
  background: var(--panel-hi);
  border: 1px solid var(--line-strong);
  transition: background var(--fast);
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--text-2);
  transition: transform var(--fast) var(--ease), background var(--fast);
}
.switch[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); }
.switch[aria-pressed="true"]::after { transform: translateX(20px); background: var(--accent-ink); }

.stepper-sm { display: flex; align-items: center; gap: var(--s2); }
.stepper-sm button {
  width: 36px; height: 36px; border-radius: var(--r-pill);
  background: var(--panel-2); border: 1px solid var(--line-strong);
  display: flex; align-items: center; justify-content: center; font-size: 19px;
}
.stepper-sm output { min-width: 46px; text-align: center; font-family: var(--font-num); font-variant-numeric: tabular-nums; font-weight: 620; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + var(--s4)); z-index: 90;
  transform: translateX(-50%);
  padding: var(--s3) var(--s5);
  border-radius: var(--r-pill);
  background: var(--panel-hi);
  border: 1px solid var(--line-strong);
  font-size: var(--t-sm); font-weight: 560;
  animation: toastIn var(--mid) var(--ease);
  max-width: calc(100vw - var(--s6));
  text-align: center;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* Résumé de fin de séance */
.summary { padding: var(--s4); flex: 1; display: flex; flex-direction: column; }
.summary__big {
  font-family: var(--font-num); font-variant-numeric: tabular-nums;
  font-size: var(--t-read); font-weight: 640; letter-spacing: -0.04em; line-height: 1;
}
.delta { font-size: var(--t-sm); font-weight: 620; }
.delta--up { color: var(--ok); }
.delta--down { color: var(--warn); }

/* ------------------------------------------------------------
   Compte et synchronisation
   ------------------------------------------------------------ */

.sync-dot {
  width: 9px; height: 9px; border-radius: 50%; flex: none;
  background: var(--text-3);
}
.sync-dot--synced   { background: var(--ok); }
.sync-dot--pending  { background: var(--warn); }
.sync-dot--offline  { background: var(--text-3); }
.sync-dot--signedout{ background: var(--line-strong); }
.sync-dot--disabled { background: var(--line-strong); }

.sync-chip {
  display: inline-flex; align-items: center; gap: var(--s2);
  padding: 5px var(--s3);
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  background: var(--panel);
  font-size: var(--t-micro);
  font-weight: 620;
  letter-spacing: 0.04em;
  color: var(--text-2);
  white-space: nowrap;
}
.sync-chip:active { background: var(--panel-2); }

/* ------------------------------------------------------------
   Démonstrations photo
   ------------------------------------------------------------ */

.demo {
  position: relative;
  aspect-ratio: 3 / 2;
  border-radius: var(--r-lg);
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  cursor: pointer;
}
.demo__frame {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  /* Les photos d'origine sont éclairées pour un studio clair ; en thème
     sombre elles éclatent. Un léger abaissement les fait tenir dans la page
     sans altérer la lisibilité du mouvement. */
  filter: brightness(0.94) saturate(0.92);
}
.demo__progress {
  position: absolute; left: 0; right: 0; bottom: 0;
  height: 3px;
  background: color-mix(in srgb, var(--bg) 55%, transparent);
}
.demo__progress-fill {
  display: block; height: 100%;
  background: var(--accent);
  transform-origin: left center;
  transform: scaleX(0);
}
.demo.is-paused::after {
  content: "en pause";
  position: absolute; right: var(--s3); top: var(--s3);
  padding: 4px var(--s3);
  border-radius: var(--r-pill);
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  border: 1px solid var(--line-strong);
  font-size: var(--t-micro);
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-2);
}

.demo-thumb {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}

.demo-credit {
  font-size: var(--t-micro);
  color: var(--text-3);
  letter-spacing: 0.03em;
  margin-top: var(--s2);
}

.demo-wrap { position: relative; }
.demo-wrap .figure-wrap__cap { pointer-events: none; }

/* Le nom de l'exercice, en séance, ouvre sa fiche. */
.setcard__name {
  display: flex; align-items: center; gap: var(--s2);
  width: 100%; text-align: left;
  color: var(--text);
}
.setcard__name svg { flex: none; color: var(--text-3); }
.setcard__name:active { opacity: 0.6; }

/* Les exercices d'un bloc mènent à leur fiche. */
button.blockcard__ex { width: 100%; text-align: left; }
button.blockcard__ex:active { background: var(--panel-2); }
button.blockcard__ex svg { flex: none; color: var(--text-3); }

/* Les étapes d'échauffement mènent à leur démonstration. */
button.warmup__step { width: 100%; text-align: left; background: none; }
button.warmup__step:active { opacity: 0.6; }
button.warmup__step svg { flex: none; color: var(--text-3); }
.hint--equivalent { background: var(--target-ghost); color: var(--target); }

/* Décomposition en disques, sous le sélecteur de charge. */
.plates {
  text-align: center;
  margin-top: var(--s2);
  font-size: var(--t-sm);
  color: var(--accent);
  letter-spacing: 0.01em;
}

/* Interrupteur précédé de son bouton « Tester ». */
.row__controls { display: flex; align-items: center; gap: var(--s3); flex-shrink: 0; }
.row__controls .chip--sm { min-width: 4.5rem; justify-content: center; }
.switch:disabled { opacity: .38; cursor: not-allowed; }

/* Barre d'avancement de l'objectif de poids. */
.goalbar {
  height: 10px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
}
.goalbar__fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--ok));
  transition: width 320ms var(--ease);
}
.goal-preview { border-top: 1px solid var(--line); }
.panel > .goal-preview:first-child { border-top: none; }
/* Un rythme intenable n'est pas une remarque de plus : il doit se voir. */
.goal-warn {
  color: var(--warn, #e8a33d);
  border-left: 2px solid currentColor;
  padding-left: var(--s3);
}
/* Repère de cible et droite de tendance sur les courbes de poids. */
.chart__ref    { stroke: var(--ok); stroke-width: 1.5; stroke-dasharray: 4 3; opacity: .8; }
.chart__reflab { fill: var(--ok); font-size: 9px; font-family: var(--font-num); }
.chart__trend  { stroke: var(--text-3); stroke-width: 1.5; stroke-dasharray: 3 3; opacity: .9; }

/* ------------------------------------------------------------
   Bandeau de connexion — au-dessus de la barre d'onglets, jamais
   par-dessus le contenu, et masqué pendant une séance comme la
   barre d'onglets : rien ne doit couvrir le bouton de validation.
   ------------------------------------------------------------ */
.netbar {
  position: fixed; z-index: 45;
  left: 0; right: 0; bottom: calc(var(--tabbar-h) + var(--sab));
  max-width: var(--shell); margin-inline: auto;
  display: flex; align-items: center; gap: var(--s2);
  padding: var(--s2) var(--s4);
  font-size: var(--t-sm); font-weight: 600;
  color: #fff; background: var(--danger);
  border-top: 1px solid rgba(0, 0, 0, .18);
}
/* Rouge dans les deux cas : hors ligne ou envoi bloqué, la donnée n'est
   pas encore en sécurité ailleurs que sur ce téléphone. C'est le texte qui
   distingue les deux situations, pas la couleur. */
.netbar[data-state="offline"] { background: var(--danger); }
.netbar__t { flex: 1 1 auto; }
.netbar__btn {
  flex: 0 0 auto;
  min-height: 32px; padding: 0 var(--s3);
  border-radius: 999px; border: 1px solid currentColor;
  background: transparent; color: inherit;
  font: inherit; font-weight: 700;
}
body.is-session .netbar { display: none; }

/* ------------------------------------------------------------
   Sections repliables — écran Progrès.
   ------------------------------------------------------------ */
.folds { display: grid; gap: var(--s2); }

.fold {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
}
.fold__head {
  display: flex; align-items: center; gap: var(--s3);
  min-height: 56px; padding: var(--s3) var(--s4);
  cursor: pointer; user-select: none;
  list-style: none;                 /* masque le triangle par défaut */
  color: var(--text-2);
}
.fold__head::-webkit-details-marker { display: none; }
.fold__head:active { background: color-mix(in srgb, var(--text) 5%, transparent); }
.fold__label { flex: 1 1 auto; display: flex; flex-direction: column; gap: 2px; }
.fold__title { font-weight: 650; color: var(--text); }
.fold__meta  { font-size: var(--t-sm); color: var(--text-3); }
.fold__head svg { transition: transform 200ms var(--ease); flex: 0 0 auto; }
.fold[open] > .fold__head svg { transform: rotate(180deg); }
.fold[open] > .fold__head { border-bottom: 1px solid var(--line); }
.fold__body { padding: var(--s4); }

/* Bandeau « l'essentiel » : quatre chiffres, rien d'autre. */
.gist {
  display: grid; grid-template-columns: repeat(2, 1fr);
  gap: 1px; background: var(--line);
  border: 1px solid var(--line); border-radius: var(--r-md);
  overflow: hidden; margin-bottom: var(--s4);
}
.gist__cell { background: var(--bg-elev); padding: var(--s3) var(--s4); }
.gist__k { font-size: var(--t-sm); color: var(--text-3); }
.gist__v { font-family: var(--font-num); font-size: var(--t-lg); font-weight: 650; margin-top: 2px; }
.gist__d { font-size: var(--t-sm); color: var(--text-3); }
.gist__d--up { color: var(--ok); }

/* ------------------------------------------------------------
   Carte musculaire — planches anatomiques superposées.

   Les calques musculaires sont posés en position absolue par-dessus la
   planche, dans le même repère 200 × 369 : ils tombent au pixel près
   sans le moindre calcul.
   ------------------------------------------------------------ */
.bodymap { display: flex; gap: var(--s2); }
.bodymap__plate {
  position: relative;
  height: 100%;
  aspect-ratio: 200 / 369;
  border-radius: var(--r-sm);
  background: var(--bm-sheet);
}
.bodymap__plate svg { position: absolute; inset: 0; width: 100%; height: 100%; }

/* La planche garde ses sept gris d'origine — c'est eux qui donnent le
   relief. On ajuste seulement le contraste selon le thème. */
.bm-plate { filter: var(--bm-plate-filter); }

/* Les calques, eux, sont recolorés : c'est la raison pour laquelle les
   SVG sont injectés en ligne plutôt que posés dans une balise `img`. */
.bm-layer path { stroke: none; }
.bm-layer--primary path   { fill: var(--bm-red) !important; }
.bm-layer--secondary path { fill: var(--bm-red-soft) !important; }

.focus { display: flex; align-items: center; gap: var(--s4); }
.focus .bodymap { flex: 0 0 auto; }
.focus__legend { display: grid; gap: var(--s2); min-width: 0; }
.focus__row { display: flex; align-items: center; gap: var(--s2); }
.focus__dot { width: 10px; height: 10px; border-radius: 999px; flex: 0 0 auto; }
.focus__dot--primary   { background: var(--bm-red); }
.focus__dot--secondary { background: var(--bm-red-soft); }
.focus__dot--absent    { background: var(--line); }
.focus__name { font-size: var(--t-sm); color: var(--text-2); text-wrap: pretty; }
.focus__name--absent { color: var(--text-3); font-style: italic; }
.focus__credit { margin: var(--s2) 0 0; font-size: 11px; color: var(--text-3); }
.focus__credit a { color: inherit; }

/* ------------------------------------------------------------
   Nutrition — barres de macros et cases de placard.
   ------------------------------------------------------------ */
.macro { margin-top: var(--s3); }
.macro__head {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: var(--t-sm); color: var(--text-2); margin-bottom: 4px;
}
.macro__track {
  display: flex; height: 8px; border-radius: 999px;
  background: var(--line); overflow: hidden;
}
/* Deux nuances sur la même barre : ce qui est consommé, ce qui reste
   planifié. Voir les deux dit à la fois où on en est et si la journée
   tient debout. */
.macro__done { background: var(--accent); }
.macro__plan { background: color-mix(in srgb, var(--accent) 32%, transparent); }

.stock {
  flex: 0 0 auto; width: 26px; height: 26px; border-radius: 8px;
  border: 1.5px solid var(--line); background: transparent;
  color: transparent; display: grid; place-items: center;
}
.stock[aria-pressed="true"] {
  background: var(--ok); border-color: var(--ok); color: #04240f;
}
.panel[data-consomme="true"] { opacity: .62; }
.row[data-pris="true"] .row__title { text-decoration: line-through; color: var(--text-3); }
.row[data-pris="true"] { opacity: .62; }
/* Curseur d'objectif — cible tactile large, pas de style natif. */
.slider { width: 100%; height: 44px; accent-color: var(--accent); background: transparent; }
