:root {
  --fond: #f3f1ec; --carte: #ffffff; --texte: #18201c; --discret: #66706b; --bord: #e2ded6;
  --accent: #1f6f50; --accent-txt: #ffffff; --prot: #b5651d; --alerte: #a33a2a; --doux: #eef3f0;
  --rayon: 14px; --ombre: 0 1px 2px rgb(0 0 0 / .06);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --fond: #0f1412; --carte: #18201c; --texte: #ecefe9; --discret: #97a29c; --bord: #27312c;
    --accent: #4fb489; --accent-txt: #0f1412; --prot: #e09a55; --alerte: #ef8a78; --doux: #1f2a25; --ombre: none; }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--fond); color: var(--texte);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
.entete { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px; background: color-mix(in srgb, var(--fond) 92%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
h1 { font-size: 26px; margin: 0; letter-spacing: -.02em; }
h2 { font-size: 17px; margin: 0 0 10px; }
main { max-width: 640px; margin: 0 auto; padding: 0 16px; }
.carte { background: var(--carte); border: 1px solid var(--bord); border-radius: var(--rayon); padding: 16px; margin: 0 0 12px; box-shadow: var(--ombre); }
.bandeau { background: var(--doux); border-color: transparent; }
.bandeau.alerte { color: var(--alerte); font-weight: 600; }
.ligne-titre { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.discret { color: var(--discret); font-size: 14px; margin: 6px 0 0; }
.lien { color: var(--accent); background: none; border: 0; font: inherit; font-size: 15px; padding: 6px 0; text-decoration: none; cursor: pointer; }
input, textarea, select { font: inherit; font-size: 17px; color: var(--texte); background: var(--fond); border: 1px solid var(--bord);
  border-radius: 10px; padding: 11px 12px; width: 100%; min-width: 0; }
textarea { resize: none; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 0; }
label { display: block; font-size: 14px; color: var(--discret); margin: 0 0 12px; }
label input, label select { margin-top: 4px; }
label small { display: block; margin-top: 4px; }
button, .bouton { font: inherit; font-size: 16px; border-radius: 10px; padding: 11px 16px; border: 0; cursor: pointer; text-align: center;
  display: inline-block; text-decoration: none; -webkit-tap-highlight-color: transparent; }
button:disabled { opacity: .5; }
.principal { background: var(--accent); color: var(--accent-txt); font-weight: 600; }
.secondaire { background: var(--doux); color: var(--texte); }
.large { width: 100%; margin-top: 8px; }
.rang { display: flex; gap: 8px; align-items: center; margin: 8px 0; }
.rang > * { flex: 1; margin: 0; }
.rang.wrap { flex-wrap: wrap; }
.rang.wrap input { flex: 1 1 30%; }
.case { display: flex; align-items: center; gap: 8px; color: var(--texte); font-size: 15px; }
.case input { width: auto; margin: 0; }

.saisie-poids { display: grid; grid-template-columns: 44px 1fr 44px auto; gap: 8px; align-items: center; }
.saisie-poids input { font-size: 28px; font-weight: 700; text-align: center; padding: 8px; font-variant-numeric: tabular-nums; }
.pas { background: var(--doux); color: var(--texte); font-size: 22px; padding: 8px 0; }
.chiffres { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; }
.chiffres > div { display: flex; flex-direction: column; }
.valeur { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.etiquette { font-size: 12px; color: var(--discret); }

.jauges p { margin: 6px 0 12px; }
.jauge { height: 10px; background: var(--doux); border-radius: 6px; overflow: hidden; }
.jauge i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 6px; transition: width .4s; }
.jauge.prot i { background: var(--prot); }
.jauge i.depasse { background: var(--alerte); }

.liste { list-style: none; margin: 0; padding: 0; }
.liste li { display: flex; justify-content: space-between; gap: 8px; padding: 9px 0; border-top: 1px solid var(--bord); align-items: center; }
.liste li:first-child { border-top: 0; }
.liste.petite li { font-size: 14px; padding: 6px 0; }
.liste .suppr { background: none; color: var(--discret); padding: 4px 8px; font-size: 18px; }
.puces { display: flex; flex-wrap: wrap; gap: 8px; }
.puces button { background: var(--doux); color: var(--texte); font-size: 14px; padding: 9px 12px; border-radius: 20px; }
.puces button.choisi { background: var(--accent); color: var(--accent-txt); }

.photo-btn { display: block; text-align: center; padding: 22px; border: 2px dashed var(--bord); border-radius: 12px;
  color: var(--accent); font-weight: 600; font-size: 16px; margin-bottom: 8px; cursor: pointer; }
.photo-btn.choisie { border-style: solid; border-color: var(--accent); }
#estimation { margin-top: 12px; border-top: 1px solid var(--bord); padding-top: 12px; }
#es-titre { font-weight: 600; margin-bottom: 6px; }
.manuel summary { color: var(--accent); margin-top: 10px; cursor: pointer; }

.bascule { display: flex; background: var(--doux); border-radius: 10px; padding: 3px; }
.bascule button { background: none; color: var(--texte); padding: 6px 14px; font-weight: 600; }
.bascule button.choisi { background: var(--carte); box-shadow: var(--ombre); }
.exo h3 { margin: 0; font-size: 17px; }
.exo .consigne { font-size: 13px; color: var(--discret); margin: 4px 0 10px; }
.exo .note { font-size: 13px; color: var(--accent); margin: 0 0 8px; }
.exo .stagne { color: var(--prot); font-size: 13px; margin: 0 0 8px; }
.serie { display: grid; grid-template-columns: 54px 1fr 1fr; gap: 8px; align-items: center; margin-bottom: 6px; }
.serie span { font-size: 14px; color: var(--discret); }
.serie select, .serie input { padding: 9px; text-align: center; font-variant-numeric: tabular-nums; }
.exo .tout-ok { margin-top: 4px; width: 100%; }
.exo.fait { border-color: var(--accent); }

.fil { display: flex; flex-direction: column; gap: 10px; padding-bottom: 8px; }
.bulle { max-width: 88%; padding: 10px 13px; border-radius: 16px; white-space: pre-wrap; font-size: 15.5px; }
.bulle.moi { align-self: flex-end; background: var(--accent); color: var(--accent-txt); border-bottom-right-radius: 4px; }
.bulle.coach { align-self: flex-start; background: var(--carte); border: 1px solid var(--bord); border-bottom-left-radius: 4px; }
.bulle.alerte { border-color: var(--alerte); }
.bulle.attente { color: var(--discret); }
.suggestions { margin: 8px 0; }
.saisie-coach { position: sticky; bottom: calc(68px + env(safe-area-inset-bottom)); display: flex; gap: 8px; padding: 8px 0;
  background: var(--fond); }
.saisie-coach textarea { flex: 1; max-height: 140px; }

.graphe svg { width: 100%; height: auto; display: block; }
.graphe .axe { stroke: var(--bord); stroke-width: 1; }
.graphe text { fill: var(--discret); font-size: 10px; }
.legende { font-size: 12px; color: var(--discret); display: flex; gap: 6px; align-items: center; }
.legende span { display: inline-block; width: 14px; height: 3px; margin-left: 8px; }
.legende .pt { width: 6px; height: 6px; border-radius: 50%; background: var(--discret); }
.legende .tr { background: var(--accent); }
.legende .obj { background: var(--prot); }
.galerie { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 10px; }
.galerie figure { margin: 0; }
.galerie img { width: 100%; aspect-ratio: 3/4; object-fit: cover; border-radius: 8px; }
.galerie figcaption { font-size: 11px; color: var(--discret); text-align: center; }
.bilan { border-top: 1px solid var(--bord); padding: 10px 0; }
.bilan:first-child { border-top: 0; }
.bilan .texte { white-space: pre-wrap; font-size: 15px; }
.jours { border: 0; padding: 0; margin: 0 0 12px; display: flex; flex-wrap: wrap; gap: 6px; }
.jours legend { font-size: 14px; color: var(--discret); margin-bottom: 6px; padding: 0; }
.jours label { margin: 0; display: flex; gap: 4px; align-items: center; background: var(--doux); padding: 6px 10px; border-radius: 16px; color: var(--texte); }
.jours input { width: auto; margin: 0; }

.onglets { position: fixed; bottom: 0; left: 0; right: 0; z-index: 10; display: grid; grid-template-columns: repeat(5, 1fr);
  background: color-mix(in srgb, var(--carte) 94%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--bord); padding-bottom: env(safe-area-inset-bottom); }
.onglets a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 6px; font-size: 10.5px;
  color: var(--discret); text-decoration: none; -webkit-tap-highlight-color: transparent; }
.onglets svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.onglets a.actif { color: var(--accent); }
#toast { position: fixed; left: 50%; bottom: calc(86px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px);
  background: var(--texte); color: var(--fond); padding: 10px 16px; border-radius: 20px; font-size: 14px; opacity: 0;
  transition: .25s; pointer-events: none; max-width: calc(100% - 32px); z-index: 20; }
#toast.vu { opacity: 1; transform: translateX(-50%); }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
