/* Sport & nutrition : design « cockpit » sombre, pensé pour une main sur iPhone.
   Une couleur par grandeur (calories, protéines, lipides, glucides), le reste en retrait. */
:root {
  --fond: #0b0e13;
  --surface: #141922;
  --surface-2: #1c222d;
  --surface-3: #262d3a;
  --trait: rgba(255, 255, 255, 0.07);
  --texte: #eceff4;
  --discret: #8b93a3;
  --faible: #5c6575;
  --accent: #8ea2ff;
  --accent-texte: #0b0e13;
  --kcal: #ffb547;
  --prot: #4fd1c5;
  --lip: #ff7b8a;
  --glu: #b392f0;
  --ok: #4ade80;
  --alerte: #ff9f43;
  --danger: #ff6b6b;
  --verre: rgba(20, 25, 34, 0.72);
  --ombre: 0 10px 30px rgba(0, 0, 0, 0.45);
  --r-carte: 22px;
  --r-ctrl: 14px;
  --ressort: cubic-bezier(0.32, 0.72, 0, 1);
  --texte-ui: -apple-system, "SF Pro Text", system-ui, "Segoe UI", sans-serif;
  --chiffres: ui-rounded, "SF Pro Rounded", -apple-system, system-ui, sans-serif;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --fond: #f2f3f7;
    --surface: #ffffff;
    --surface-2: #f4f5f9;
    --surface-3: #e8eaf0;
    --trait: rgba(15, 20, 30, 0.08);
    --texte: #0e1219;
    --discret: #6b7280;
    --faible: #9ca3af;
    --accent: #4f63e8;
    --accent-texte: #ffffff;
    --kcal: #e08a00;
    --prot: #0f9f94;
    --lip: #e2475c;
    --glu: #7c55d6;
    --ok: #16a34a;
    --alerte: #e67e22;
    --danger: #dc2626;
    --verre: rgba(255, 255, 255, 0.78);
    --ombre: 0 10px 30px rgba(20, 25, 40, 0.12);
    color-scheme: light;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--fond); color: var(--texte); }
body {
  font: 16px/1.4 var(--texte-ui);
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
h1, h2, h3 { margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 2rem; font-weight: 700; letter-spacing: -0.025em; }
h2 { font-size: 1.02rem; font-weight: 600; }
h3 { font-size: 1rem; font-weight: 600; }
small, .discret { color: var(--discret); }
.discret { font-size: 0.86rem; margin: 6px 0; line-height: 1.45; }
.centre { text-align: center; }
code { font-size: 0.85em; color: var(--discret); }
.chiffre { font-family: var(--chiffres); font-variant-numeric: tabular-nums; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Mise en page ---------- */
.contenu {
  max-width: 560px; margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 12px) 16px calc(env(safe-area-inset-bottom) + 110px);
}
/* « backwards » et non « both » : une fois l'entrée finie, plus aucun transform ne reste sur l'écran,
   sinon les feuilles en position fixe se placeraient par rapport à lui au lieu de la fenêtre. */
.ecran { animation: entree 0.32s var(--ressort) backwards; }
.ecran.depuis-droite { animation-name: entree-droite; }
.ecran.depuis-gauche { animation-name: entree-gauche; }
@keyframes entree { from { opacity: 0; transform: translateY(8px); } }
@keyframes entree-droite { from { opacity: 0; transform: translateX(24px); } }
@keyframes entree-gauche { from { opacity: 0; transform: translateX(-24px); } }
.centre-ecran { max-width: 420px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 64px) 20px 40px; }

.bandeau {
  font-size: 0.78rem; text-align: center; padding: calc(env(safe-area-inset-top) + 4px) 8px 6px;
  background: var(--surface-2); color: var(--discret);
}
.bandeau.alerte { color: var(--alerte); }

/* En-tête d'écran : grand titre + jour, flèches discrètes */
.entete { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 6px 2px 16px; }
.entete-texte { min-width: 0; }
.entete-jour { font-size: 0.86rem; color: var(--discret); margin: 0 0 2px; }
.entete-jour::first-letter { text-transform: uppercase; }
.entete-nav { display: flex; gap: 6px; flex: none; }

/* ---------- Cartes ---------- */
.carte {
  background: var(--surface); border-radius: var(--r-carte); padding: 16px; margin: 0 0 12px;
  border: 1px solid var(--trait);
}
.carte-titre { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 12px; min-height: 28px; }
.carte-titre h2 { font-size: 0.95rem; color: var(--discret); font-weight: 600; }
.grille-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.grille-2 > .carte { margin: 0; }

/* ---------- Boutons ---------- */
.bouton {
  min-height: 44px; padding: 10px 16px; border-radius: var(--r-ctrl); border: none;
  background: var(--surface-2); color: var(--texte); font: inherit; font-weight: 500; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform 0.15s var(--ressort), background-color 0.2s, opacity 0.2s;
  touch-action: manipulation; user-select: none; -webkit-user-select: none;
}
.bouton:active:not(:disabled), .puce:active, .chip:active, .ligne-nom:active, .choix:active, .onglets button:active { transform: scale(0.96); }
.bouton:disabled { opacity: 0.4; cursor: default; }
.bouton.principal { background: var(--accent); color: var(--accent-texte); font-weight: 600; }
.bouton.large { width: 100%; margin-top: 10px; min-height: 50px; font-size: 1.02rem; }
.bouton.petit { min-height: 36px; padding: 6px 12px; font-size: 0.9rem; border-radius: 12px; }
.bouton.rond { width: 40px; min-height: 40px; padding: 0; border-radius: 50%; }
.bouton.rond.petit { width: 32px; min-height: 32px; }
.bouton.lien { background: none; color: var(--accent); padding: 6px 4px; min-height: 36px; }
.bouton.danger, .bouton.lien.danger { color: var(--danger); }
.bouton.fichier { position: relative; }
.bouton svg { width: 18px; height: 18px; flex: none; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; align-items: center; }
.raccourcis { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }

.pastille {
  font-size: 0.78rem; font-weight: 600; padding: 3px 9px; border-radius: 999px;
  background: var(--surface-2); color: var(--discret); border: none; white-space: nowrap; font-family: inherit;
}
.pastille.ok { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.pastille.alerte { background: color-mix(in srgb, var(--alerte) 16%, transparent); color: var(--alerte); cursor: pointer; min-height: 30px; }

/* Défilement horizontal (puces, modèles) sans barre visible */
.defile {
  display: flex; gap: 8px; overflow-x: auto; margin: 0 -16px 12px; padding: 2px 16px 4px;
  scrollbar-width: none; scroll-snap-type: x proximity; scroll-padding-inline: 16px;
}
.defile::-webkit-scrollbar { display: none; }
.defile > * { scroll-snap-align: start; }

.puce, .chip {
  flex: none; min-height: 40px; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--trait);
  background: var(--surface); color: var(--texte); font: inherit; font-size: 0.92rem; font-weight: 500;
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  transition: transform 0.15s var(--ressort), background-color 0.25s, border-color 0.25s, color 0.25s;
}
.puce.active { background: var(--texte); color: var(--fond); border-color: transparent; }

/* Compléments : une puce par prise, cochée d'un geste */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip .coche {
  width: 20px; height: 20px; border-radius: 50%; border: 1.5px solid var(--faible); display: grid; place-items: center;
  transition: background-color 0.25s, border-color 0.25s;
}
.chip .coche svg { width: 12px; height: 12px; opacity: 0; transform: scale(0.4); transition: all 0.25s var(--ressort); }
.chip.pris { background: color-mix(in srgb, var(--ok) 14%, var(--surface)); border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.chip.pris .coche { background: var(--ok); border-color: var(--ok); color: var(--fond); }
.chip.pris .coche svg { opacity: 1; transform: scale(1); }
.chip small { color: var(--discret); font-size: 0.78rem; }
.chip > svg { width: 16px; height: 16px; color: var(--accent); }
.exo-num svg { width: 16px; height: 16px; }

/* ---------- Champs ---------- */
.champ { display: flex; flex-direction: column; gap: 6px; font-size: 0.84rem; color: var(--discret); margin: 10px 0; }
.champ.ligne { flex-direction: row; align-items: center; gap: 10px; color: var(--texte); font-size: 1rem; }
.champ.mini { flex-direction: row; align-items: center; gap: 6px; margin: 0; }
.champ.mini .nombre { width: 70px; }
.nombre, .texte, .recherche, select {
  font: inherit; font-size: 16px; /* évite le zoom automatique sur iPhone */
  min-height: 46px; padding: 10px 12px; border-radius: var(--r-ctrl); border: 1px solid transparent;
  background: var(--surface-2); color: var(--texte); width: 100%; transition: border-color 0.2s, background-color 0.2s;
}
.nombre { font-family: var(--chiffres); font-variant-numeric: tabular-nums; }
.nombre:focus, .texte:focus, .recherche:focus, select:focus { outline: none; border-color: var(--accent); background: var(--surface); }
.nombre::-webkit-inner-spin-button, .nombre::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.texte.court { width: 120px; }
.champ.ligne .nombre { width: 120px; }
.recherche { margin-bottom: 10px; }
.ligne-saisie { display: flex; gap: 8px; }
.ligne-saisie .nombre { flex: 1; }
.grille-macros { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 0 10px; }
.case { display: flex; align-items: center; gap: 10px; min-height: 44px; color: var(--texte); font-size: 1rem; }
.case input { width: 22px; height: 22px; accent-color: var(--accent); }
.cases { list-style: none; padding: 0; margin: 0; }
.complement { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 8px 0; border-bottom: 1px solid var(--trait); }
.complement .case { flex: 1 1 160px; }

/* Pas à pas « − 10 + » : on ajuste sans clavier, à la salle */
.pas {
  display: grid; grid-template-columns: 38px minmax(0, 1fr) 38px; align-items: center;
  background: var(--surface-2); border-radius: var(--r-ctrl); min-height: 46px; overflow: hidden;
}
.pas button {
  height: 46px; border: none; background: none; color: var(--texte); font-size: 1.25rem; cursor: pointer; font-family: var(--chiffres);
  transition: background-color 0.15s;
}
.pas button:active { background: var(--surface-3); }
.pas button { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; touch-action: manipulation; }
.pas input {
  width: 100%; min-width: 0; border: none; background: none; color: var(--texte); text-align: center; padding: 0;
  font: 600 1.08rem/1 var(--chiffres); font-variant-numeric: tabular-nums; height: 46px;
}
.pas input:focus { outline: none; }
.pas input::-webkit-inner-spin-button { -webkit-appearance: none; }
.pas.grand { grid-template-columns: 52px 1fr 52px; }
.pas.grand input { font-size: 1.5rem; }
.pas.mini { display: flex; width: 128px; flex: none; min-height: 40px; border-radius: 12px; }
.pas.mini button { width: 36px; height: 40px; flex: none; font-size: 1.15rem; color: var(--discret); }
.pas.mini input { flex: 1; height: 40px; font-size: 16px; text-align: right; }
.pas-unite { font-size: 0.78rem; color: var(--discret); padding: 0 1px 0 2px; }

/* ---------- Mesures : anneau, barres, courbe ---------- */
.jour-hero { display: grid; grid-template-columns: auto 1fr; gap: 18px; align-items: center; }
.anneau { position: relative; display: grid; place-items: center; }
.anneau svg { display: block; transform: rotate(-90deg); }
.anneau .piste { stroke: var(--surface-3); }
.anneau .arc { transition: stroke-dashoffset 0.9s var(--ressort), stroke 0.3s; }
.anneau-centre { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.anneau-valeur { font: 700 1.9rem/1 var(--chiffres); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.anneau-legende { font-size: 0.74rem; color: var(--discret); margin-top: 4px; }

.macros { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.macro-ligne { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 0.84rem; }
.macro-ligne span:first-child { color: var(--discret); }
.macro-ligne .chiffre { font-weight: 600; font-size: 0.95rem; }
.macro-ligne .sur { color: var(--faible); font-weight: 500; }
.macro-piste { height: 6px; background: var(--surface-3); border-radius: 999px; overflow: hidden; margin-top: 6px; }
.macro-plein { height: 100%; border-radius: 999px; transform-origin: left; transition: width 0.9s var(--ressort); }
.depasse .chiffre, .alerte { color: var(--alerte); }
.alerte-texte { color: var(--alerte); font-size: 0.9rem; }
.ok-texte { color: var(--ok); font-size: 0.9rem; margin: 8px 0 0; }

.reste { margin: 14px 0 0; padding-top: 12px; border-top: 1px solid var(--trait); font-size: 0.92rem; color: var(--discret); }
.reste strong { color: var(--texte); font-family: var(--chiffres); }

.stat-valeur { font: 700 2rem/1.05 var(--chiffres); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.stat-valeur small { font: 600 0.95rem var(--texte-ui); color: var(--discret); margin-left: 3px; }
.stat-sous { font-size: 0.8rem; color: var(--discret); margin-top: 4px; }
.tendance { font-weight: 600; font-size: 0.8rem; }
.tendance.baisse { color: var(--ok); }
.tendance.hausse { color: var(--alerte); }
.courbe-cadre { position: relative; margin-top: 10px; }
.courbe { display: block; width: 100%; height: 44px; overflow: visible; }
.courbe-point {
  position: absolute; width: 8px; height: 8px; border-radius: 50%; transform: translate(-50%, -50%);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--surface) 70%, transparent);
}
.courbe .ligne { fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.courbe .aire { opacity: 0.14; }

/* ---------- Séance ---------- */
.seance-hero { display: flex; align-items: center; gap: 14px; }
.seance-pastille {
  width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; font-size: 1.6rem;
  background: var(--surface-2); flex: none;
}
.seance-titre { font-size: 1.15rem; font-weight: 700; margin: 0; }
.progression-seance { height: 4px; background: var(--surface-3); border-radius: 999px; margin: 14px 0 0; overflow: hidden; }
.progression-seance div { height: 100%; background: var(--ok); border-radius: 999px; transition: width 0.6s var(--ressort); }

.exo { transition: border-color 0.3s; }
.exo.fait { border-color: color-mix(in srgb, var(--ok) 45%, transparent); }
.exo-tete { display: flex; gap: 12px; align-items: flex-start; }
.exo-num {
  flex: none; width: 30px; height: 30px; border-radius: 10px; background: var(--surface-2); color: var(--discret);
  display: grid; place-items: center; font: 700 0.9rem var(--chiffres);
}
.exo.fait .exo-num { background: var(--ok); color: var(--fond); }
.exo-titre { line-height: 1.25; font-size: 1.05rem; }
.fourchette { font-weight: 500; color: var(--discret); font-size: 0.84rem; display: block; margin-top: 2px; }
.cible-bloc {
  margin: 14px 0 10px; padding: 12px 14px; border-radius: var(--r-ctrl);
  background: color-mix(in srgb, var(--accent) 10%, var(--surface-2));
}
.cible-valeur { font: 700 1.3rem/1.15 var(--chiffres); font-variant-numeric: tabular-nums; }
.cible-raison { font-size: 0.8rem; color: var(--discret); margin-top: 3px; }
.cues { font-size: 0.84rem; color: var(--discret); margin: 6px 0 10px; line-height: 1.5; }
details { margin: 4px 0 8px; }
details summary {
  cursor: pointer; color: var(--discret); min-height: 36px; font-size: 0.88rem; list-style: none;
  display: flex; align-items: center; gap: 8px;
}
details summary::-webkit-details-marker { display: none; }
details summary svg { width: 14px; height: 14px; transition: transform 0.25s var(--ressort); }
details[open] summary svg { transform: rotate(90deg); }
.historique { list-style: none; padding: 0; margin: 2px 0 8px; font-size: 0.84rem; font-variant-numeric: tabular-nums; }
.historique li { padding: 6px 0; border-bottom: 1px solid var(--trait); }
.historique li:last-child { border-bottom: none; }
.saisie-seance { border-top: 1px solid var(--trait); padding-top: 14px; margin-top: 6px; }
.charge-ligne { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; margin-bottom: 12px; }
.charge-ligne .etiquette { font-size: 0.84rem; color: var(--discret); }
.series { display: grid; grid-template-columns: 24px minmax(0, 1fr) 50px 50px 44px; gap: 8px 6px; align-items: center; }
.series .tete { font-size: 0.74rem; color: var(--faible); text-align: center; font-weight: 600; }
.series .num { font: 700 0.85rem var(--chiffres); color: var(--discret); text-align: center; }
.series .nombre { text-align: center; padding: 10px 2px; }
.note { margin-top: 12px; }
.recap { list-style: none; padding: 0; margin: 0; }
.recap li { padding: 10px 0; border-bottom: 1px solid var(--trait); }
.recap li:last-child { border-bottom: none; }
.recap small { display: block; margin-top: 2px; }
.series-actions { display: flex; align-items: center; gap: 4px 10px; flex-wrap: wrap; margin-top: 6px; }
.series-actions .discret { font-size: 0.8rem; flex-basis: 100%; }
.exo, .terminer { scroll-margin-top: calc(env(safe-area-inset-top) + 12px); }
.lancer-repos { margin-left: auto; font-variant-numeric: tabular-nums; }
.lancer-repos svg { width: 17px; height: 17px; color: var(--accent); }

/* ---------- Minuteur de repos (au-dessus des onglets) ---------- */
.repos {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 84px); transform: translateX(-50%); z-index: 30;
  width: min(calc(100% - 24px), 480px); display: flex; align-items: center; gap: 8px;
  background: var(--surface-3); border: 1px solid var(--trait); border-radius: 20px; padding: 8px 8px 8px 16px; box-shadow: var(--ombre);
}
.repos-temps { flex: 1; display: flex; flex-direction: column; line-height: 1.1; }
.repos-temps small { font-size: 0.72rem; color: var(--discret); font-weight: 600; }
.repos-temps span { font: 700 1.5rem/1.1 var(--chiffres); font-variant-numeric: tabular-nums; }
.repos.fini { background: var(--ok); border-color: transparent; color: var(--fond); animation: pouls 1s ease-in-out 3; }
.repos.fini small { color: inherit; opacity: 0.8; }
.repos.fini .bouton { background: color-mix(in srgb, var(--fond) 18%, transparent); color: var(--fond); }
@keyframes pouls { 50% { transform: translateX(-50%) scale(1.03); } }
/* ---------- 7 derniers jours ---------- */
.semaine { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.semaine-jour {
  display: flex; flex-direction: column; align-items: center; gap: 6px; background: none; border: none; padding: 0;
  color: var(--discret); font: inherit; cursor: pointer;
}
/* La cible est à 80 % de la hauteur : la barre peut la dépasser jusqu'à 125 %. */
.semaine-piste { position: relative; width: 100%; max-width: 30px; height: 84px; background: var(--surface-2); border-radius: 8px; overflow: hidden; }
.semaine-barre { position: absolute; left: 0; right: 0; bottom: 0; background: var(--kcal); border-radius: 8px 8px 0 0; transition: height 0.5s var(--ressort); }
.semaine-cible { position: absolute; left: 0; right: 0; bottom: 80%; border-top: 2px dashed color-mix(in srgb, var(--texte) 45%, transparent); }
.semaine-jour.au-dessus .semaine-barre { background: var(--alerte); }
.semaine-lettre { font-size: 0.75rem; font-weight: 600; width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; }
.semaine-jour.actif .semaine-lettre { background: var(--texte); color: var(--fond); }
.semaine-jour.vide .semaine-lettre { opacity: 0.5; }

body.avec-repos .contenu { padding-bottom: calc(env(safe-area-inset-bottom) + 180px); }
body.avec-repos .toast { bottom: calc(env(safe-area-inset-bottom) + 156px); }
.bouton.lien.gris { color: var(--discret); }
.terminer { margin: 4px 0 18px; min-height: 54px; font-size: 1.05rem; }
.pastille.recul { background: color-mix(in srgb, var(--alerte) 14%, transparent); color: var(--alerte); }
.bilan { border: 1px solid color-mix(in srgb, var(--ok) 35%, transparent); }
.bilan .fin-bilan { margin-bottom: 14px; }
.analyse { margin: 0 0 6px; padding-left: 18px; font-size: 0.92rem; line-height: 1.5; }
.analyse li + li { margin-top: 4px; }
.sous-titre { font-size: 0.95rem; margin: 16px 0 4px; }
.recap-tete { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.prochaine {
  margin-top: 8px; padding: 8px 12px; border-radius: 12px;
  background: color-mix(in srgb, var(--accent) 10%, var(--surface-2));
}
.prochaine .chiffre { font-weight: 700; font-size: 1.05rem; }
.prochaine small { display: block; color: var(--discret); }

/* ---------- Repas ---------- */
.moment { padding: 4px 0 12px; }
.moment + .moment { border-top: 1px solid var(--trait); padding-top: 12px; }
.moment header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 4px; }
.moment header small { font-family: var(--chiffres); }
/* Macros du repas en un coup d'œil, aux couleurs des barres du résumé. */
.macros-moment { font-family: var(--chiffres); font-size: 0.85rem; font-variant-numeric: tabular-nums; color: var(--discret); white-space: nowrap; }
.macros-moment b { color: var(--texte); font-weight: 600; }
.macros-moment span { margin-left: 8px; font-weight: 600; }
.macros-moment .m-p { color: var(--prot); }
.macros-moment .m-g { color: var(--glu); }
.macros-moment .m-l { color: var(--lip); }
.moment ul { list-style: none; padding: 0; margin: 2px 0; }
.ligne-repas { display: flex; align-items: center; gap: 6px; border-radius: 12px; transition: background-color 0.25s; }
.ligne-repas.prevu { background: color-mix(in srgb, var(--alerte) 9%, transparent); }
.ligne-nom {
  flex: 1; min-width: 0; text-align: left; background: none; border: none; color: var(--texte); font: inherit;
  display: flex; flex-direction: column; padding: 8px 6px; min-height: 48px; cursor: pointer; transition: transform 0.15s var(--ressort);
}
.ligne-nom span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ligne-nom small { font-size: 0.8rem; font-variant-numeric: tabular-nums; }
.ligne-nom small.en-cours { color: var(--kcal); }
/* Aliments « à calculer » : bordure pointillée tant que l'IA n'est pas passée. */
.a-calculer .ligne-repas { border: 1.5px dashed var(--trait); margin: 4px 0; padding-left: 6px; }
.a-calculer .ligne-nom { cursor: default; }
.nom-etiquette { font: inherit; color: var(--texte); background: none; border: none; border-bottom: 1px dashed var(--trait); padding: 2px 0; width: 100%; min-width: 0; }
.nom-etiquette:focus { outline: none; border-bottom-color: var(--accent); }
.a-calculer .ligne-nom small:not(.alerte-texte) { color: var(--discret); }
.vignette {
  width: 40px; height: 40px; flex: none; border-radius: 8px; object-fit: cover;
  display: grid; place-items: center; background: var(--surface-2, var(--surface-3)); color: var(--discret);
}
.vignette svg { width: 18px; height: 18px; }
.a-calculer + .bouton { margin-top: 6px; }
.ligne-repas .bouton.rond { background: none; color: var(--faible); }
.ligne-repas .bouton.rond svg { width: 16px; height: 16px; }
.ajouter { color: var(--accent); background: none; }
.composer { list-style: none; padding: 0; margin: 8px 0; }
.composer li { display: flex; align-items: center; gap: 8px; padding: 6px 0; }
.composer li span { flex: 1; min-width: 0; }
.composer .nombre { width: 84px; }
.composer strong { font-family: var(--chiffres); color: var(--accent); min-width: 54px; text-align: right; }
.composer-macros { display: block; color: var(--discret); font-size: 0.78rem; font-variant-numeric: tabular-nums; }
/* Bouton photo réduit à son icône : la ligne d'actions d'un repas tient sans passer à la ligne. */
.bouton.icone-seule { padding-left: 12px; padding-right: 12px; }
.bouton.icone-seule svg { margin: 0; }
/* Modifications en attente de réseau (salle de sport sans signal). */
.attente-reseau { text-align: center; font-size: 0.78rem; color: var(--discret); padding: 4px 12px; }
.fin-bilan { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.fin-bilan li { background: var(--surface-2); border-radius: var(--r-ctrl); padding: 12px; }
.fin-bilan .stat-valeur { font-size: 1.35rem; }
.fin-bilan .stat-sous { margin-top: 2px; }

/* ---------- Listes de choix ---------- */
.liste-choix { list-style: none; padding: 0; margin: 0; }
.choix {
  width: 100%; text-align: left; background: none; border: none; border-bottom: 1px solid var(--trait);
  color: var(--texte); font: inherit; padding: 12px 4px; display: flex; flex-direction: column; min-height: 52px; cursor: pointer;
  transition: transform 0.15s var(--ressort);
}
.choix small { font-variant-numeric: tabular-nums; }
.vide { color: var(--discret); padding: 16px 4px; }

/* ---------- Feuille modale : monte du bas, se ferme en la tirant ---------- */
.voile {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0); display: flex; align-items: flex-end; justify-content: center;
  z-index: 30; transition: background-color 0.32s var(--ressort);
}
.voile.ouvert { background: rgba(0, 0, 0, 0.5); }
.feuille {
  background: var(--surface); width: 100%; max-width: 560px; max-height: 92%; border-radius: 26px 26px 0 0;
  display: flex; flex-direction: column; padding-bottom: env(safe-area-inset-bottom); box-shadow: var(--ombre);
  transform: translateY(100%); transition: transform 0.38s var(--ressort); will-change: transform;
}
.voile.ouvert .feuille { transform: translateY(0); }
.feuille.tiree { transition: none; }
.feuille.haute { height: 92%; }
.bouton.inconnu { margin-bottom: 10px; }
.recherche-net { display: flex; gap: 8px; margin-bottom: 10px; }
body:not([data-feuilles="0"])[data-feuilles] .ajout-rapide { display: none; }
.modele-ligne { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.modele-ligne .bouton.rond { background: none; color: var(--faible); }
.recherche-net .texte { flex: 1; min-width: 0; }
.feuille-poignee { padding: 8px 0 2px; display: grid; place-items: center; touch-action: none; cursor: grab; }
.feuille-poignee span { width: 38px; height: 5px; border-radius: 999px; background: var(--surface-3); }
.feuille-titre { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 4px 16px 10px; touch-action: none; }
.feuille-titre h2 { font-size: 1.1rem; }
.feuille-corps { overflow-y: auto; padding: 4px 16px 24px; overscroll-behavior: contain; }

/* ---------- Barre d'onglets flottante ---------- */
.onglets {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 10px); transform: translateX(-50%);
  width: min(calc(100% - 24px), 480px); display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--verre); -webkit-backdrop-filter: saturate(180%) blur(22px); backdrop-filter: saturate(180%) blur(22px);
  border: 1px solid var(--trait); border-radius: 26px; padding: 6px; z-index: 20; box-shadow: var(--ombre);
}
.onglets-indicateur {
  position: absolute; top: 6px; bottom: 6px; left: 6px; width: calc((100% - 12px) / 5);
  background: color-mix(in srgb, var(--accent) 16%, transparent); border-radius: 20px;
  transition: transform 0.42s var(--ressort);
}
.onglets button {
  position: relative; background: none; border: none; color: var(--discret); font: inherit; font-size: 0.66rem; font-weight: 600;
  display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 7px 0 5px; min-height: 52px; cursor: pointer;
  transition: color 0.25s, transform 0.15s var(--ressort);
}
.onglets button svg { width: 23px; height: 23px; }
.onglets button.actif { color: var(--accent); }

/* ---------- Message éphémère ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 88px); z-index: 40;
  transform: translate(-50%, 16px); opacity: 0; pointer-events: none;
  background: var(--texte); color: var(--fond); padding: 10px 16px; border-radius: 999px; font-size: 0.9rem; font-weight: 600;
  display: flex; align-items: center; gap: 8px; box-shadow: var(--ombre);
  white-space: nowrap; max-width: calc(100% - 32px);
  transition: opacity 0.25s, transform 0.35s var(--ressort);
}
.toast.visible { opacity: 1; transform: translate(-50%, 0); }
.toast svg { width: 16px; height: 16px; flex: none; color: var(--ok); }
.toast span { overflow: hidden; text-overflow: ellipsis; }
.toast.avec-action.visible { pointer-events: auto; padding-right: 6px; }
.toast-annuler {
  border: 0; background: color-mix(in srgb, var(--fond) 14%, transparent); color: var(--accent);
  font: inherit; font-weight: 700; padding: 6px 12px; border-radius: 999px; margin-left: 4px; cursor: pointer;
}

/* ---------- Connexion / bienvenue ---------- */
.marque { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; }
.marque img { width: 52px; height: 52px; border-radius: 14px; }
.marque p { margin: 2px 0 0; color: var(--discret); font-size: 0.9rem; }
.chargement { display: grid; place-items: center; min-height: 70vh; }
.chargement span {
  width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--surface-3); border-top-color: var(--accent);
  animation: tourne 0.8s linear infinite;
}
@keyframes tourne { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ---------- Ergonomie séance : coche par série, exercice replié ---------- */
.serie { display: contents; }
.coche-serie {
  width: 44px; height: 44px; border-radius: 12px; border: 1.5px solid var(--trait); background: var(--surface-2);
  color: var(--faible); display: grid; place-items: center; cursor: pointer; touch-action: manipulation;
  transition: background-color 0.2s, color 0.2s, transform 0.15s var(--ressort);
}
.coche-serie svg { width: 20px; height: 20px; }
.coche-serie:active:not(:disabled) { transform: scale(0.92); }
.coche-serie:disabled { opacity: 0.4; }
.serie.faite .coche-serie { background: var(--ok); border-color: transparent; color: var(--fond); }
.serie.faite .num { color: var(--ok); }
.serie.faite .pas, .serie.faite .nombre { background: color-mix(in srgb, var(--ok) 10%, var(--surface-2)); }
.exo.replie { padding-top: 12px; padding-bottom: 12px; }
.exo-resume {
  display: flex; align-items: center; gap: 12px; width: 100%; background: none; border: none; padding: 0;
  color: var(--texte); font: inherit; text-align: left; cursor: pointer; min-height: 44px;
}
.exo-resume-texte { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.exo-resume-texte small { color: var(--discret); font-size: 0.86rem; }
.exo-resume-modifier { color: var(--accent); font-size: 0.88rem; font-weight: 600; }

/* ---------- Ajout rapide d'un aliment (bouton flottant) ---------- */
.ajout-rapide {
  position: fixed; right: max(16px, calc(50% - 240px + 4px)); bottom: calc(env(safe-area-inset-bottom) + 86px); z-index: 25;
  width: 58px; height: 58px; border-radius: 20px; border: none; background: var(--accent); color: #fff;
  display: grid; place-items: center; box-shadow: var(--ombre); cursor: pointer; touch-action: manipulation;
  transition: transform 0.15s var(--ressort), bottom 0.3s var(--ressort);
}
.ajout-rapide svg { width: 26px; height: 26px; }
.ajout-rapide:active { transform: scale(0.92); }
body.avec-repos .ajout-rapide { display: none; }
body.avec-ajout .contenu { padding-bottom: calc(env(safe-area-inset-bottom) + 170px); }
body.avec-ajout .toast { bottom: calc(env(safe-area-inset-bottom) + 156px); }
.moments-choix { margin-top: 0; }

/* Cibles tactiles : la croix des lignes de repas reste petite à l'œil mais large au doigt. */
.ligne-repas .bouton.rond.petit { position: relative; }
.ligne-repas .bouton.rond.petit::after { content: ''; position: absolute; inset: -6px; }

/* Repas dicté */
.bouton.dicter { margin: 4px 0 10px; }
textarea.texte.dicte { width: 100%; min-height: 84px; resize: vertical; font: inherit; font-size: 16px; line-height: 1.4; margin-top: 10px; }
.lignes-dicte { list-style: none; padding: 0; margin: 12px 0 0; }
.lignes-dicte li { padding: 10px 0; border-top: 1px solid var(--trait, rgba(127,127,127,.2)); }
.lignes-dicte li .discret { margin: 2px 0 6px 32px; }
.lignes-dicte li .alerte-texte { margin: 2px 0 6px 32px; }
.lignes-dicte li .pas { margin-left: 32px; }
.lignes-dicte li.ecartee { opacity: .55; }

/* Rappel de la dernière séance (début de séance) */
.rappel { border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent); }
.rappel .sous-titre:first-of-type { margin-top: 8px; }
.rappel-resume { margin: 0; font-weight: 600; }
details.rappel { padding: 6px 16px; }
details.rappel[open] { padding-bottom: 16px; }
.recap small.manque { color: var(--alerte); }
