/* Juste Portion — feuille de style unique (app + pages légales).
   Palette tirée du marché : aubergine (encre), framboise (action), menthe (fait), safran (attention),
   myrtille (eau). Titres en Bricolage Grotesque, texte en Figtree, embarquées (pas de CDN : Capacitor). */
@font-face { font-family:"Bricolage"; src:url("/static/polices/bricolage-grotesque-latin-wght-normal.woff2") format("woff2");
             font-weight:200 800; font-display:swap; }
@font-face { font-family:"Figtree"; src:url("/static/polices/figtree-latin-wght-normal.woff2") format("woff2");
             font-weight:300 900; font-display:swap; }

:root {
  --fond:#F7F5FA; --surface:#FFFFFF; --creux:#EFEBF5; --encre:#2B1B3D; --encre-2:#6A5F7C; --ligne:#E4DEEC;
  --framboise:#D7265E; --framboise-encre:#B31748; --menthe:#12876B; --safran:#C98A00; --myrtille:#4B4FCF;
  --t-framboise:#FCE7EE; --t-menthe:#DDF3EC; --t-safran:#FDF0CF; --t-myrtille:#E6E7FB;
  --titre:"Bricolage", "Figtree", system-ui, sans-serif; --texte:"Figtree", system-ui, sans-serif;
  --r-s:10px; --r-m:16px; --r-l:26px; --onglets:64px;
  color-scheme:light;
}
@media (prefers-color-scheme: dark) {
  :root { --fond:#150F1D; --surface:#21182D; --creux:#2B2038; --encre:#F4EFF9; --encre-2:#AFA3C2; --ligne:#382C47;
          --framboise:#FF5C8D; --framboise-encre:#FF7AA2; --menthe:#3FCFA8; --safran:#F4B32C; --myrtille:#8F93FF;
          --t-framboise:#40152A; --t-menthe:#143A31; --t-safran:#3D300D; --t-myrtille:#22244F; color-scheme:dark; }
}

* { box-sizing:border-box; }
[hidden] { display:none !important; }
html { -webkit-text-size-adjust:100%; }
body { margin:0; font:400 16px/1.45 var(--texte); background:var(--fond); color:var(--encre);
       -webkit-font-smoothing:antialiased; }
h1, h2, h3, p { margin:0; }
h1 { font:700 1.75rem/1.1 var(--titre); letter-spacing:-.02em; }
h2 { font:650 1.2rem/1.2 var(--titre); letter-spacing:-.01em; }
h3 { font:600 1rem/1.25 var(--texte); }
a { color:var(--framboise-encre); }
.discret { color:var(--encre-2); } .petit { font-size:.875rem; } .mini { font-size:.78rem; }
.chiffre { font-family:var(--titre); font-variant-numeric:tabular-nums; font-weight:700; letter-spacing:-.02em; }
:focus-visible { outline:3px solid var(--myrtille); outline-offset:2px; border-radius:6px; }

/* --- Structure : colonne mobile, onglets en bas ------------------------------------------------------ */
.app { max-width:560px; margin:0 auto; min-height:100dvh; display:flex; flex-direction:column; }
#vue { flex:1; padding:calc(18px + env(safe-area-inset-top)) 18px calc(var(--onglets) + 34px + env(safe-area-inset-bottom));
       outline:none; }
.entete { display:flex; align-items:flex-end; justify-content:space-between; gap:12px; margin-bottom:18px; }
.entete p { margin-top:2px; }
.bloc { margin-top:26px; } .bloc > h2 { margin-bottom:10px; }
.bloc-titre { display:flex; align-items:baseline; justify-content:space-between; gap:10px; margin-bottom:10px; }
.pile { display:grid; gap:10px; }
.ligne { display:flex; align-items:center; gap:10px; } .ligne.haut { align-items:flex-start; }
.pousse { flex:1; min-width:0; }
.carte { background:var(--surface); border-radius:var(--r-m); padding:14px; }

.onglets { position:fixed; left:0; right:0; bottom:0; z-index:5; background:var(--surface); border-top:1px solid var(--ligne);
           padding-bottom:env(safe-area-inset-bottom); }
.onglets ul { list-style:none; margin:0 auto; padding:0; max-width:560px; display:grid; grid-template-columns:repeat(5, 1fr); }
.onglets a { display:grid; justify-items:center; gap:2px; padding:9px 2px 8px; height:var(--onglets); text-decoration:none;
             color:var(--encre-2); font-size:.72rem; font-weight:600; }
.onglets a svg { width:24px; height:24px; }
.onglets a[aria-current=page] { color:var(--framboise-encre); }
.onglets a[aria-current=page] svg { stroke-width:2.3; }

/* --- Boutons et champs -------------------------------------------------------------------------------- */
button { font:600 1rem/1.2 var(--texte); color:inherit; cursor:pointer; border:0; background:none; padding:0; }
.btn { display:inline-flex; align-items:center; justify-content:center; gap:8px; min-height:48px; padding:12px 20px;
       border-radius:999px; background:var(--framboise); color:#fff; text-decoration:none; }
@media (prefers-color-scheme: dark) { .btn { color:#1B0A12; } }
.btn.large { width:100%; }
.btn.second { background:var(--creux); color:var(--encre); }
.btn.contour { background:transparent; color:var(--framboise-encre); box-shadow:inset 0 0 0 1.5px currentColor; }
.btn.petit { min-height:38px; padding:8px 14px; font-size:.9rem; }
.btn.danger { background:transparent; color:var(--framboise-encre); box-shadow:inset 0 0 0 1.5px currentColor; }
.btn svg { width:20px; height:20px; flex:none; }
button:disabled, .btn[aria-disabled=true] { opacity:.5; cursor:default; }
.btn.charge { position:relative; color:transparent !important; }
.btn.charge::after { content:""; position:absolute; width:18px; height:18px; border-radius:50%; border:2.5px solid #fff;
                     border-right-color:transparent; animation:tourne .7s linear infinite; }
.btn.second.charge::after, .btn.contour.charge::after { border-color:var(--encre); border-right-color:transparent; }
@keyframes tourne { to { transform:rotate(1turn); } }
.lien { color:var(--framboise-encre); font-weight:600; font-size:.92rem; text-decoration:none; }
.rond { width:42px; height:42px; border-radius:50%; background:var(--surface); display:grid; place-items:center; flex:none; }
.rond svg { width:22px; height:22px; }

label.champ { display:grid; gap:6px; font-weight:600; font-size:.92rem; }
input, select { font:400 1rem var(--texte); color:var(--encre); background:var(--surface); border:1.5px solid var(--ligne);
                border-radius:var(--r-s); padding:12px; min-height:48px; min-width:0; width:100%; }
input:focus, select:focus { outline:none; border-color:var(--myrtille); }
.unite { position:relative; } .unite input { padding-right:46px; }
.unite span { position:absolute; right:14px; top:50%; translate:0 -50%; color:var(--encre-2); pointer-events:none; }
.grille-2 { display:grid; grid-template-columns:1fr 1fr; gap:12px; }
.erreur { color:var(--framboise-encre); font-weight:600; font-size:.92rem; }

/* choix (radio / cases) présentés en cartes ou en pastilles */
.choix { display:grid; gap:8px; }
.choix label { display:block; position:relative; cursor:pointer; }
.choix label > input { position:absolute; opacity:0; width:100%; height:100%; margin:0; cursor:pointer; min-height:0; }
.choix label > span { display:block; padding:13px 14px; border-radius:var(--r-m); background:var(--surface);
                      box-shadow:inset 0 0 0 1.5px var(--ligne); }
.choix label > span > b { display:block; } .choix label > span > small { color:var(--encre-2); font-size:.85rem; }
.choix label > input:checked + span { box-shadow:inset 0 0 0 2px var(--framboise); background:var(--t-framboise); }
.choix label > input:focus-visible + span { outline:3px solid var(--myrtille); outline-offset:2px; }
.choix.pastilles { display:flex; flex-wrap:wrap; }
.choix.pastilles label > span { padding:9px 14px; border-radius:999px; font-weight:600; font-size:.92rem; }
.choix.cote { grid-template-columns:1fr 1fr; }

.puce { display:inline-flex; align-items:center; gap:5px; padding:3px 9px; border-radius:999px; font-size:.78rem; font-weight:600;
        background:var(--creux); color:var(--encre-2); white-space:nowrap; }
.puce.menthe { background:var(--t-menthe); color:var(--menthe); } .puce.safran { background:var(--t-safran); color:var(--safran); }
.puce.framboise { background:var(--t-framboise); color:var(--framboise-encre); }
.puces { display:flex; flex-wrap:wrap; gap:6px; }
.note { padding:12px 14px; border-radius:var(--r-m); background:var(--t-safran); font-size:.92rem; }
.note.menthe { background:var(--t-menthe); } .note.myrtille { background:var(--t-myrtille); }

/* --- Le fil de la journée : un segment par repas, largeur = calories, plein = mangé --------------------- */
.fil { background:var(--surface); border-radius:var(--r-l); padding:18px 18px 16px; }
.fil-reste { display:flex; align-items:baseline; gap:8px; flex-wrap:wrap; }
.fil-reste .chiffre { font-size:2.6rem; line-height:1; }
.fil-barre { display:flex; gap:4px; height:30px; margin:16px 0 6px; }
.fil-seg { position:relative; border-radius:9px; background:var(--creux); overflow:hidden; min-width:14px; }
.fil-seg i { position:absolute; inset:0; transform-origin:left; transform:scaleX(0); transition:transform .5s cubic-bezier(.2,.8,.2,1); }
.fil-seg.plein i { transform:scaleX(1); }
.fil-seg.petit_dejeuner i { background:var(--safran); } .fil-seg.dejeuner i { background:var(--menthe); }
.fil-seg.collation i { background:var(--myrtille); } .fil-seg.diner i { background:var(--framboise); }
.fil-seg.extra i { background:var(--encre-2); transform:scaleX(1); }
.fil-legende { display:flex; gap:4px; font-size:.7rem; color:var(--encre-2); font-weight:600; }
.fil-legende span { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; text-align:center; }
.macros { display:grid; grid-template-columns:repeat(4, 1fr); gap:12px; margin-top:16px; }
.macro p { white-space:nowrap; font-size:.74rem; color:var(--encre-2); }
.macro p b { font:700 1rem var(--titre); font-variant-numeric:tabular-nums; color:var(--encre); }
.macro small { color:var(--encre-2); font-size:.74rem; }
.jauge { height:5px; border-radius:3px; background:var(--creux); margin:5px 0 4px; overflow:hidden; }
.jauge i { display:block; height:100%; border-radius:3px; background:var(--encre); transition:width .5s; }
.jauge.menthe i { background:var(--menthe); } .jauge.framboise i { background:var(--framboise); }

/* --- Repas ---------------------------------------------------------------------------------------------- */
.repas { display:flex; align-items:center; gap:12px; background:var(--surface); border-radius:var(--r-m); padding:10px 12px 10px 10px; }
.repas > button.corps { display:flex; align-items:center; gap:12px; flex:1; min-width:0; text-align:left; }
.tuile { width:54px; height:54px; border-radius:14px; display:grid; place-items:center; font-size:1.7rem; flex:none; background:var(--creux); }
.tuile.petit_dejeuner { background:var(--t-safran); } .tuile.dejeuner { background:var(--t-menthe); }
.tuile.collation { background:var(--t-myrtille); } .tuile.diner { background:var(--t-framboise); }
.tuile.grande { width:72px; height:72px; font-size:2.3rem; border-radius:20px; }
.repas .titre { font-weight:600; line-height:1.25; display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden; }
.repas .sous { color:var(--encre-2); font-size:.82rem; margin-top:2px; }
.repas.mange .titre { color:var(--encre-2); }
.coche { width:36px; height:36px; border-radius:50%; flex:none; display:grid; place-items:center;
         box-shadow:inset 0 0 0 2px var(--ligne); color:transparent; transition:background .2s, box-shadow .2s; }
.coche svg { width:20px; height:20px; stroke-width:3; }
.coche[aria-pressed=true] { background:var(--menthe); box-shadow:none; color:#fff; }
.coche[aria-pressed=true] svg { animation:pop .3s cubic-bezier(.3,1.6,.5,1); }
@keyframes pop { from { transform:scale(.3); } }

.jours { display:grid; grid-template-columns:repeat(7, 1fr); gap:6px; }
.jours button { display:grid; justify-items:center; gap:2px; padding:8px 0; border-radius:14px; background:var(--surface);
                font-size:.72rem; color:var(--encre-2); font-weight:600; }
.jours button b { font:700 1.05rem var(--titre); color:var(--encre); }
.jours button[aria-pressed=true] { background:var(--encre); color:var(--fond); }
.jours button[aria-pressed=true] b { color:var(--fond); }
.jours button.auj:not([aria-pressed=true]) { box-shadow:inset 0 0 0 2px var(--framboise); }

.verres { display:flex; gap:6px; flex-wrap:wrap; }
.verres button { width:34px; height:42px; border-radius:6px 6px 12px 12px; background:var(--creux); position:relative; overflow:hidden; }
.verres button::after { content:""; position:absolute; inset:auto 0 0; height:0; background:var(--myrtille); transition:height .25s; }
.verres button[aria-pressed=true]::after { height:78%; }

.liste { list-style:none; margin:0; padding:0; background:var(--surface); border-radius:var(--r-m); overflow:hidden; }
.liste > li { display:flex; align-items:center; gap:12px; padding:12px 14px; }
.liste > li + li { border-top:1px solid var(--ligne); }
.liste .emoji { font-size:1.3rem; width:28px; text-align:center; flex:none; }
.liste button.pleine { display:flex; align-items:center; gap:12px; width:100%; text-align:left; }
.case { width:26px; height:26px; border-radius:8px; flex:none; display:grid; place-items:center; color:transparent;
        box-shadow:inset 0 0 0 2px var(--ligne); }
.case svg { width:16px; height:16px; stroke-width:3.2; }
[aria-pressed=true] > .case, .case[aria-pressed=true] { background:var(--menthe); box-shadow:none; color:#fff; }
li.fait .pousse { color:var(--encre-2); text-decoration:line-through; }
.rayon { font:650 .95rem var(--titre); margin:18px 0 8px; }

/* --- Feuille (panneau qui monte du bas) ---------------------------------------------------------------------- */
.feuille { position:fixed; inset:0; z-index:20; display:flex; align-items:flex-end; justify-content:center;
           background:rgb(20 10 30 / .5); animation:voile .2s; }
.feuille-corps { width:100%; max-width:560px; max-height:92dvh; overflow:auto; background:var(--fond); border-radius:var(--r-l) var(--r-l) 0 0;
                 padding:10px 18px calc(22px + env(safe-area-inset-bottom)); animation:monte .28s cubic-bezier(.2,.9,.3,1); }
.feuille-barre { position:sticky; top:-10px; z-index:1; display:flex; justify-content:flex-end; margin:0 -8px; padding:6px 0; background:var(--fond); }
@keyframes voile { from { opacity:0; } } @keyframes monte { from { transform:translateY(40px); opacity:0; } }
.valeurs { display:grid; grid-template-columns:repeat(4, 1fr); gap:8px; text-align:center; }
.valeurs div { background:var(--surface); border-radius:var(--r-s); padding:10px 4px; }
.valeurs b { display:block; font:700 1.15rem var(--titre); } .valeurs small { color:var(--encre-2); font-size:.74rem; }
.ingredients { list-style:none; margin:0; padding:0; }
.ingredients li { display:flex; justify-content:space-between; gap:12px; padding:9px 0; border-bottom:1px solid var(--ligne); }
.ingredients li span:last-child { color:var(--encre-2); text-align:right; white-space:nowrap; }
.etapes { margin:0; padding:0; list-style:none; counter-reset:etape; display:grid; gap:12px; }
.etapes li { counter-increment:etape; display:grid; grid-template-columns:30px 1fr; gap:10px; }
.etapes li::before { content:counter(etape); width:30px; height:30px; border-radius:50%; background:var(--encre); color:var(--fond);
                     display:grid; place-items:center; font:700 .9rem var(--titre); }

#toast { position:fixed; left:50%; bottom:calc(var(--onglets) + 18px + env(safe-area-inset-bottom)); translate:-50% 0; z-index:30;
         background:var(--encre); color:var(--fond); padding:11px 18px; border-radius:999px; font-weight:600; font-size:.92rem;
         max-width:calc(100vw - 32px); text-align:center; opacity:0; pointer-events:none; transition:opacity .2s, transform .2s; transform:translateY(8px); }
#toast.vu { opacity:1; transform:none; }

/* --- Accueil / parcours de départ --------------------------------------------------------------------------- */
.parcours { min-height:calc(100dvh - 60px); display:flex; flex-direction:column; gap:20px; }
.parcours .avance { display:flex; gap:5px; }
.parcours .avance i { flex:1; height:4px; border-radius:2px; background:var(--ligne); }
.parcours .avance i.fait { background:var(--framboise); }
.parcours .pied { margin-top:auto; display:flex; gap:10px; padding-top:8px; }
.parcours .pied .btn { flex:1; }
.accueil { display:flex; flex-direction:column; justify-content:flex-end; gap:22px; min-height:calc(100dvh - 60px); }
.accueil h1 { font-size:clamp(2.6rem, 13vw, 3.8rem); line-height:.95; }
.assiette { width:min(72vw, 300px); aspect-ratio:1; margin:0 auto; display:block; }
.promesses { list-style:none; padding:0; margin:0; display:grid; gap:14px; }
.promesses li { display:grid; grid-template-columns:34px 1fr; gap:12px; align-items:start; }
.promesses li > span { font-size:1.5rem; line-height:1.2; }
.resultat { background:var(--encre); color:var(--fond); border-radius:var(--r-l); padding:22px 20px; }
.resultat .chiffre { font-size:3.4rem; line-height:1; }
.resultat .discret { color:color-mix(in srgb, var(--fond) 70%, transparent); }
.resultat .trio { display:grid; grid-template-columns:repeat(3, 1fr); gap:10px; margin-top:18px; }
.resultat .trio b { display:block; font:700 1.2rem var(--titre); }

/* --- Progrès ---------------------------------------------------------------------------------------------------- */
.courbe { width:100%; height:auto; display:block; }
.stats { display:grid; grid-template-columns:repeat(3, 1fr); gap:8px; }
.stats div { background:var(--surface); border-radius:var(--r-m); padding:12px; }
.stats b { display:block; font:700 1.35rem var(--titre); font-variant-numeric:tabular-nums; }
.stats small { color:var(--encre-2); font-size:.78rem; }
.barres { display:grid; grid-template-columns:repeat(7, 1fr); gap:8px; align-items:end; height:110px; position:relative; }
.barres .col { display:flex; flex-direction:column; justify-content:flex-end; height:100%; }
.barres .col i { display:block; border-radius:6px 6px 2px 2px; background:var(--menthe); min-height:3px; }
.barres .col.vide i { background:var(--creux); } .barres .col.trop i { background:var(--safran); }
.barres-jours { display:grid; grid-template-columns:repeat(7, 1fr); gap:8px; text-align:center; font-size:.72rem; color:var(--encre-2); margin-top:6px; }
.phases { display:flex; gap:4px; }
.phases div { height:8px; border-radius:4px; background:var(--creux); }
.phases div.passee { background:var(--encre-2); } .phases div.courante { background:var(--framboise); }

/* --- Pages légales et connexion ----------------------------------------------------------------------------------- */
main.legal { max-width:720px; margin:0 auto; padding:24px 18px 64px; }
main.legal nav { margin-bottom:20px; } main.legal h1 { margin-bottom:6px; } main.legal h2 { margin:26px 0 8px; }
main.legal p, main.legal li { line-height:1.6; } main.legal p { margin:0 0 12px; }
main.legal section { margin-bottom:18px; }
.muted { color:var(--encre-2); } .sub { color:var(--encre-2); margin-bottom:24px; }
.a-completer { background:var(--t-safran); padding:0 4px; border-radius:4px; }
footer { margin-top:32px; font-size:.85rem; display:flex; flex-wrap:wrap; gap:6px 16px; }
#connexion { position:fixed; inset:0; background:var(--fond); display:grid; place-items:center; padding:18px; z-index:40; }
.carte-connexion { width:100%; max-width:380px; background:var(--surface); border-radius:var(--r-l); padding:24px; display:grid; gap:12px; }
.carte-connexion h2 { font-size:1.8rem; } .carte-connexion h2 span { color:var(--framboise-encre); }
.carte-connexion button { min-height:48px; border-radius:999px; background:var(--framboise); color:#fff; padding:12px 20px; }
.carte-connexion button.ghost { background:none; color:var(--encre-2); min-height:0; padding:4px; font-weight:500; font-size:.9rem; }
.err { color:var(--framboise-encre); font-weight:600; font-size:.92rem; }

@media (min-width:700px) { body { background:var(--creux); } .app { background:var(--fond); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation:none !important; transition:none !important; } }

/* Goûts, sport, rappels */
.btn[aria-pressed="true"] { background:var(--t-framboise); color:var(--framboise-encre); box-shadow:inset 0 0 0 2px var(--framboise); }
.tuile svg { width:26px; height:26px; }
a.carte.ligne > svg { width:20px; height:20px; flex:none; color:var(--encre-2); }
.seance .chrono { font-family:var(--titre, inherit); font-size:3.4rem; font-weight:700; line-height:1.1; font-variant-numeric:tabular-nums; }
.seance .chrono.repos { color:var(--menthe); }
#formRappels input[type=checkbox] { width:22px; height:22px; min-height:0; accent-color:var(--framboise); flex:none; }
