/* Flans pâtissiers — feuille de styles du site.
   Thème sombre « cuisine » (par défaut si le système est sombre) et thème clair « carnet ». */
:root, [data-theme="sombre"] {
  --fond: #14110E; --surface: #211B16; --surface-2: #2D251E; --trait: #3D3229;
  --texte: #FFF6E6; --texte-2: #D2C4AD; --texte-3: #A0907A;
  --accent: #FFC53D; --accent-texte: #1A1205; --accent-2: #FF9B54; --ok: #6BD49A; --alerte: #FFB4A6;
  --ligne: #FFC53D; --coupe-fond: #2A231C; --ombre: 0 18px 40px -24px #000;
  --mix: white; --mix-p: 42%;
  color-scheme: dark;
}
[data-theme="clair"] {
  --fond: #FBF5E9; --surface: #FFFDF8; --surface-2: #F4EBD8; --trait: #E3D3B4;
  --texte: #2A1C12; --texte-2: #5C4532; --texte-3: #806B55;
  --accent: #A4521A; --accent-texte: #FFFFFF; --accent-2: #9F2D20; --ok: #0F7B4F; --alerte: #9F2D20;
  --ligne: #D9961A; --coupe-fond: #F3E7CF; --ombre: 0 14px 30px -22px #5c3b1c88;
  --mix: black; --mix-p: 12%;
  color-scheme: light;
}
:root { --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { background: var(--fond); }
body { margin: 0; background: var(--fond); color: var(--texte); font: 18px/1.5 var(--sans); }
[data-theme="clair"] body { background-image: radial-gradient(#eadcc2 0.6px, transparent 0.6px); background-size: 14px 14px; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.col { max-width: 1080px; margin: 0 auto; padding: 0 16px; }
.etroit { max-width: 760px; margin: 0 auto; }
.fc { color: color-mix(in srgb, var(--c) calc(100% - var(--mix-p)), var(--mix)); }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- En-tête ---------- */
header.haut { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--fond) 92%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--trait); }
header.haut .col { display: flex; align-items: center; gap: 12px; padding-top: 10px; padding-bottom: 10px; }
.etape-num { font: 800 12px/1 var(--sans); letter-spacing: .14em; text-transform: uppercase; color: var(--accent); }
[data-theme="sombre"] .etape-num { color: var(--accent); }
header.haut h1 { margin: 3px 0 0; font: 700 26px/1.1 var(--serif); letter-spacing: -.01em; }
.icones { margin-left: auto; display: flex; gap: 8px; }
.ico { min-width: 44px; height: 44px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--trait); display: inline-flex; align-items: center; justify-content: center; gap: 6px; cursor: pointer; padding: 0 10px; font-weight: 700; font-size: 15px; }
.ico[aria-pressed="true"] { background: var(--accent); color: var(--accent-texte); border-color: var(--accent); }
.ico svg { width: 22px; height: 22px; flex: none; }
.progres { height: 4px; background: var(--surface-2); }
.progres i { display: block; height: 100%; background: var(--ligne); transition: width .3s; }

/* Réserve en bas = hauteur réelle du bouton collant + de la barre d'étapes (variables mises à jour
   par ResizeObserver dans app.js ; valeurs de repli ci-dessous). La barre inclut la zone sûre iOS. */
:root { --nav-h: calc(72px + env(safe-area-inset-bottom)); --cta-h: 82px; }
main.col { padding-top: 18px; padding-bottom: calc(var(--nav-h) + var(--cta-h) + 24px); }
.ecran { display: none; } .ecran.actif { display: block; animation: entree .25s ease; }
@keyframes entree { from { opacity: 0; transform: translateY(8px); } }
.aide { color: var(--texte-2); margin: 0 0 16px; font-size: 17px; }
h2.titre { font: 700 24px/1.2 var(--serif); margin: 26px 0 10px; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
h2.titre small { font: 700 13px var(--sans); letter-spacing: .08em; text-transform: uppercase; color: var(--texte-3); }
.vide { text-align: center; color: var(--texte-2); font: italic 20px var(--serif); padding: 40px 10px; }

/* ---------- Puces, boutons ---------- */
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.chip { min-height: 42px; padding: 7px 15px; border-radius: 999px; border: 1.5px solid var(--trait); background: var(--surface); font-weight: 700; font-size: 15px; cursor: pointer; white-space: nowrap; }
.chip[aria-pressed="true"] { background: var(--texte); color: var(--fond); border-color: var(--texte); }
.recherche { width: 100%; min-height: 48px; border-radius: 14px; border: 1.5px solid var(--trait); background: var(--surface); padding: 10px 14px; margin-bottom: 12px; font-size: 17px; }
.seg { display: inline-flex; border: 1.5px solid var(--texte); border-radius: 999px; overflow: hidden; }
.seg button { border: 0; background: transparent; padding: 7px 14px; cursor: pointer; font-weight: 700; font-size: 15px; min-height: 40px; }
.seg button[aria-pressed="true"] { background: var(--texte); color: var(--fond); }
.lien { background: none; border: 0; color: var(--accent); text-decoration: underline; cursor: pointer; font-weight: 700; font-size: 15px; padding: 8px 6px; }
[data-theme="sombre"] .lien { color: var(--accent); }
.outils { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; margin-bottom: 14px; }

/* ---------- Écran 1 : cartes (façon carnet) ---------- */
.cartes { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.carte { position: relative; display: flex; flex-direction: column; gap: 8px; text-align: left; cursor: pointer; background: var(--surface); border: 2px solid var(--trait); border-radius: 14px; padding: 14px; transition: transform .15s, box-shadow .15s, border-color .15s; }
.carte:hover { transform: translateY(-2px); box-shadow: var(--ombre); }
.carte[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent); }
.carte .coupe { height: 104px; display: grid; place-items: end center; background: linear-gradient(#0000 72%, var(--coupe-fond) 72%); border-radius: 8px; overflow: hidden; }
.carte .coupe img { width: 100%; height: 104px; object-fit: cover; border-radius: 8px; }
.carte h3 { margin: 0; font: 700 20px/1.2 var(--serif); padding-right: 36px; }
.meta { display: flex; flex-wrap: wrap; gap: 6px; font-size: 14px; }
.tag { background: var(--surface-2); border-radius: 5px; padding: 2px 8px; color: var(--texte-2); font-weight: 600; }
.tag.fort { color: var(--accent-2); }
.coche { width: 34px; height: 34px; border-radius: 50%; border: 2.5px solid var(--texte-3); display: grid; place-items: center; flex: none; background: var(--surface); }
.carte .coche { position: absolute; top: 12px; right: 12px; border-radius: 9px; }
[aria-pressed="true"] > .coche, .coche.on { background: var(--accent); border-color: var(--accent); }
[aria-pressed="true"] > .coche::after, .coche.on::after { content: ""; width: 9px; height: 17px; border: solid var(--accent-texte); border-width: 0 3.5px 3.5px 0; transform: rotate(45deg) translate(-1px, -2px); }
.carte .tampon { display: none; position: absolute; left: 12px; top: 12px; font: italic 700 13px var(--serif); color: var(--accent-2); border: 2px solid var(--accent-2); border-radius: 4px; padding: 0 7px; transform: rotate(-6deg); background: var(--surface); }
.carte[aria-pressed="true"] .tampon { display: block; }

/* Ma fournée : réglages par flan */
.fournee { display: grid; gap: 10px; margin-bottom: 8px; }
.reglage { background: var(--surface); border: 1.5px solid var(--trait); border-left: 6px solid var(--c); border-radius: 14px; }
.reglage summary { list-style: none; cursor: pointer; display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; align-items: center; padding: 12px 14px; }
.reglage summary::-webkit-details-marker { display: none; }
.reglage summary b { font: 700 19px/1.2 var(--serif); }
.reglage summary .resume { grid-column: 1; font-size: 15px; color: var(--texte-2); }
.reglage summary .ouvrir { grid-row: 1 / 3; grid-column: 2; font-weight: 700; font-size: 14px; color: var(--accent); border: 1.5px solid var(--trait); border-radius: 10px; padding: 6px 10px; }
.reglage[open] summary .ouvrir { background: var(--surface-2); }
.reg-corps { padding: 0 14px 14px; display: grid; gap: 12px; }
.ligne-reg { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.pas { display: inline-flex; align-items: center; border: 1.5px solid var(--trait); border-radius: 12px; overflow: hidden; }
.pas button { width: 48px; height: 48px; border: 0; background: var(--surface-2); font-size: 24px; font-weight: 700; cursor: pointer; }
.pas output { min-width: 96px; text-align: center; font-weight: 800; font-size: 19px; }
.reg-corps select, .reg-corps input[type=number] { min-height: 46px; border-radius: 10px; border: 1.5px solid var(--trait); background: var(--surface-2); padding: 6px 10px; font-size: 17px; }
.reg-corps input[type=number] { width: 96px; }
.reg-corps label { display: inline-flex; gap: 8px; align-items: center; font-weight: 600; font-size: 15px; color: var(--texte-2); }
.infos { font-size: 15px; color: var(--texte-2); display: grid; gap: 4px; background: var(--surface-2); border-radius: 10px; padding: 10px 12px; }
.infos b { color: var(--texte); }
.surveiller { color: var(--accent-2); font-weight: 600; }
.retirer { background: none; border: 0; color: var(--alerte); font-weight: 700; cursor: pointer; text-decoration: underline; padding: 6px 0; font-size: 15px; justify-self: start; }

/* ---------- Écran 2 : courses ---------- */
.compteur { display: flex; align-items: baseline; gap: 10px; margin-bottom: 8px; }
.compteur b { font-size: 34px; font-weight: 800; }
.barre-p { height: 10px; border-radius: 6px; background: var(--surface-2); overflow: hidden; margin-bottom: 16px; }
.barre-p i { display: block; height: 100%; background: var(--ok); transition: width .3s; }
.encart { background: var(--surface); border: 1px solid var(--trait); border-left: 6px solid var(--ligne); border-radius: 12px; padding: 12px 16px; font-size: 16px; margin-bottom: 16px; color: var(--texte-2); }
.encart strong { color: var(--texte); font: 700 19px var(--serif); }
.courses { columns: 2 360px; column-gap: 32px; }
.rayon { break-inside: avoid; margin-bottom: 18px; }
.rayon h3 { font: italic 700 20px var(--serif); border-bottom: 2px solid var(--texte); padding-bottom: 4px; margin: 0 0 4px; }
.art { display: grid; grid-template-columns: 34px 1fr auto; gap: 4px 12px; align-items: start; padding: 11px 2px; border-bottom: 1px dashed var(--trait); cursor: pointer; }
.art input { width: 28px; height: 28px; margin: 0; accent-color: var(--ok); cursor: pointer; }
.art .nom { font-weight: 650; line-height: 1.3; }
.art .q { font-weight: 800; font-size: 18px; font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; }
.art .q small { display: block; font-size: 13px; font-weight: 600; color: var(--texte-3); }
.art .q.sb { font: italic 500 16px var(--serif); color: var(--texte-2); }
.art .detail { grid-column: 2 / 4; font-size: 14px; color: var(--texte-2); display: flex; flex-wrap: wrap; gap: 2px 12px; }
.art .detail span::before { content: "●"; margin-right: 4px; color: var(--c); }
.art:has(input:checked) { opacity: .55; }
.art:has(input:checked) .nom, .art:has(input:checked) .q { text-decoration: line-through; }
.alerte { font-size: 14px; color: var(--alerte); margin-top: 6px; }

/* Blancs */
.blancs { background: var(--surface); border: 1.5px solid var(--trait); border-radius: 16px; padding: 16px; margin-top: 22px; }
.blancs h2 { margin: 0 0 4px; font: 700 23px/1.2 var(--serif); }
.blancs .sous { color: var(--texte-2); margin: 0 0 12px; font-size: 16px; }
.idees { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.idee { background: var(--surface-2); border-radius: 12px; padding: 10px 12px; font-size: 15px; display: grid; gap: 4px; align-content: start; }
.idee b { font: 700 17px/1.2 var(--serif); }
.idee .nb { font-weight: 800; color: var(--accent-2); font-size: 14px; }
.idee .fois { font-size: 13px; color: var(--texte-3); }
.idee.trop { opacity: .55; }
.conservation { margin: 14px 0 0; padding-left: 20px; font-size: 15px; color: var(--texte-2); display: grid; gap: 3px; }

/* ---------- Écran 3 : planning ---------- */
.jours { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.jour { background: var(--surface); border: 1px solid var(--trait); border-radius: 14px; padding: 16px; border-top: 6px solid var(--ligne); }
.jour:nth-child(2) { border-top-color: var(--accent-2); }
.jour:nth-child(3) { border-top-color: var(--texte-3); }
.jour h3 { margin: 0; font: 700 22px var(--serif); display: flex; gap: 10px; align-items: baseline; }
.jour h3 small { font: 800 13px var(--sans); letter-spacing: .1em; color: var(--accent-2); }
.jour ul { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 10px; }
.jour li { display: grid; grid-template-columns: 14px 1fr; gap: 10px; font-size: 16px; }
.pastille { width: 14px; height: 14px; border-radius: 50%; margin-top: 5px; background: var(--c, var(--texte-3)); }
.pastille.tous { background: repeating-conic-gradient(var(--texte-2) 0 25%, var(--surface) 0 50%); }
.qui { font-weight: 800; }
.jour .note-four { display: block; font-size: 14px; color: var(--accent-2); font-weight: 600; }

/* ---------- Écran 4 : ligne de métro ---------- */
.recap { display: grid; gap: 8px; margin-bottom: 16px; }
.recap div { background: var(--surface); border: 1px solid var(--trait); border-left: 5px solid var(--c); border-radius: 12px; padding: 8px 12px; font-size: 15px; color: var(--texte-2); }
.recap b { color: var(--texte); font-size: 16px; }
.suivre { display: flex; gap: 8px; overflow-x: auto; margin: 0 -16px 16px; padding: 0 16px 6px; scrollbar-width: none; }
.suivre .chip[aria-pressed="true"] { background: var(--c, var(--texte)); border-color: var(--c, var(--texte)); color: #fff; }
.suivre .chip.tous[aria-pressed="true"] { color: var(--fond); }
.phase-t { position: relative; padding: 6px 0 10px 58px; margin-top: 8px; }
.phase-t h3 { margin: 0; font: 800 26px/1.15 var(--serif); }
.phase-t small { color: var(--ligne); font-weight: 800; font-size: 14px; letter-spacing: .08em; }
.phase-t::before { content: ""; position: absolute; left: 12px; top: 6px; width: 30px; height: 30px; border-radius: 8px; background: var(--ligne); }
.station { position: relative; padding: 0 0 18px 58px; }
.station::before { content: ""; position: absolute; left: 24px; top: -14px; bottom: 0; width: 6px; background: var(--ligne); border-radius: 3px; }
.station .noeud { position: absolute; left: 13px; top: 2px; width: 28px; height: 28px; border-radius: 50%; background: var(--fond); border: 5px solid var(--ligne); cursor: pointer; padding: 0; z-index: 1; }
.station.fait .noeud { background: var(--ligne); }
.station.fait .noeud::after { content: ""; position: absolute; left: 6px; top: 1px; width: 6px; height: 12px; border: solid var(--fond); border-width: 0 3px 3px 0; transform: rotate(45deg); }
.station .txt { font-size: 20px; font-weight: 600; line-height: 1.4; padding-top: 1px; }
.station.fait .txt { color: var(--texte-3); text-decoration: line-through; text-decoration-thickness: 2px; }
.branches { margin-top: 10px; display: grid; gap: 8px; }
.br-titre { font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: .1em; color: var(--texte-3); margin: 4px 0 -2px; }
.branche { position: relative; background: var(--surface); border: 1.5px solid color-mix(in srgb, var(--c) 70%, var(--trait)); border-radius: 14px; padding: 10px 12px 10px 14px; font-size: 17px; }
.branche::before { content: ""; position: absolute; left: -34px; top: -14px; width: 32px; height: 34px; border-left: 4px solid var(--c); border-bottom: 4px solid var(--c); border-bottom-left-radius: 18px; }
.branche b { display: block; font-size: 14px; }
.branche.commun { --c: var(--texte-3); border-style: dashed; }
.branche.autres { --c: var(--texte-3); color: var(--texte-2); font-size: 15px; padding: 6px 12px; }
.fin { padding-left: 58px; color: var(--texte-2); font-size: 16px; }

/* ---------- Termes du glossaire ---------- */
.terme { background: none; border: 0; padding: 0; margin: 0; font: inherit; color: inherit; cursor: help; text-decoration: underline dotted; text-decoration-thickness: 2px; text-underline-offset: 3px; text-decoration-color: color-mix(in srgb, var(--accent-2) 80%, transparent); border-radius: 3px; display: inline; text-align: inherit; }
.terme:hover { background: color-mix(in srgb, var(--accent-2) 14%, transparent); }
#infobulle { position: fixed; z-index: 60; max-width: 320px; background: var(--texte); color: var(--fond); border-radius: 10px; padding: 9px 12px; font-size: 14.5px; line-height: 1.4; box-shadow: var(--ombre); pointer-events: none; opacity: 0; transform: translateY(4px); transition: opacity .12s, transform .12s; }
#infobulle.visible { opacity: 1; transform: none; }
#infobulle b { display: block; font-family: var(--serif); font-size: 16px; }
#infobulle small { display: block; margin-top: 4px; opacity: .7; }
#voile { position: fixed; inset: 0; background: #0008; z-index: 70; opacity: 0; pointer-events: none; transition: opacity .2s; }
#voile.visible { opacity: 1; pointer-events: auto; }
#tiroir { position: fixed; z-index: 80; top: 0; right: 0; bottom: 0; width: min(420px, 92vw); background: var(--surface); color: var(--texte); border-left: 1px solid var(--trait); box-shadow: -20px 0 40px -20px #000a; transform: translateX(105%); transition: transform .25s ease; display: flex; flex-direction: column; }
#tiroir.ouvert { transform: none; }
#tiroir .t-tete { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--trait); }
#tiroir .t-tete h2 { margin: 0; font: 700 22px var(--serif); flex: 1; }
#tiroir .fermer { width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--trait); background: var(--surface-2); font-size: 22px; cursor: pointer; }
#tiroir .t-corps { padding: 16px; overflow: auto; flex: 1; }
#tiroir .cat { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .1em; color: var(--accent-2); }
#tiroir .def { font-size: 19px; line-height: 1.5; margin: 6px 0 18px; }
#tiroir dl { margin: 0; }
#tiroir dt { font: 700 17px var(--serif); margin-top: 12px; }
#tiroir dd { margin: 2px 0 0; color: var(--texte-2); font-size: 15.5px; }
#tiroir dt button { all: unset; cursor: pointer; }
#tiroir dt button:focus-visible { outline: 3px solid var(--accent); }

/* ---------- Navigation basse ---------- */
nav.bas { position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; background: var(--surface); border-top: 1px solid var(--trait); padding-bottom: env(safe-area-inset-bottom); }
nav.bas .col { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; padding-top: 6px; padding-bottom: 8px; max-width: 760px; }
nav.bas button { background: none; border: 0; padding: 6px 2px; border-radius: 12px; display: grid; justify-items: center; gap: 2px; cursor: pointer; color: var(--texte-3); font-size: 13px; font-weight: 700; min-height: 56px; }
nav.bas button span { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; border: 2px solid currentColor; font-weight: 800; font-size: 15px; }
nav.bas button[aria-current="step"] { color: var(--texte); }
nav.bas button[aria-current="step"] span { background: var(--accent); border-color: var(--accent); color: var(--accent-texte); }
.cta { position: fixed; left: 0; right: 0; bottom: var(--nav-h); z-index: 24; pointer-events: none; padding: 22px 0 8px;
  background: linear-gradient(to bottom, transparent, color-mix(in srgb, var(--fond) 88%, transparent) 45%, var(--fond)); }
.cta .col { display: flex; max-width: 760px; }
.cta button { pointer-events: auto; flex: 1; min-height: 56px; border: 0; border-radius: 16px; background: var(--accent); color: var(--accent-texte); font-weight: 850; font-size: 19px; cursor: pointer; box-shadow: 0 10px 30px -8px #000c; }
.cta button:disabled { background: var(--surface-2); color: var(--texte-3); box-shadow: none; }
.pied { color: var(--texte-3); font-size: 13px; text-align: center; margin-top: 30px; }

/* ---------- Petits écrans ---------- */
@media (max-width: 700px) {
  body { font-size: 17px; }
  header.haut h1 { font-size: 22px; }
  .ico .txt { display: none; }
  .chips { flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px 12px; padding: 0 16px 6px; scrollbar-width: none; }
  .cartes { grid-template-columns: 1fr 1fr; gap: 10px; }
  .carte { padding: 10px; }
  .carte h3 { font-size: 17px; padding-right: 30px; }
  .carte .coupe { height: 84px; }
  .carte .coupe svg { width: 96px; }
  .carte .coche { width: 30px; height: 30px; top: 8px; right: 8px; }
  .carte .tampon { display: none !important; }
  .meta { font-size: 12.5px; gap: 4px; }
  .jours { grid-template-columns: 1fr; }
  #tiroir { top: auto; left: 0; right: 0; width: auto; max-height: 78vh; border-left: 0; border-top: 1px solid var(--trait); border-radius: 20px 20px 0 0; transform: translateY(105%); }
  #tiroir.ouvert { transform: none; }
  #tiroir .t-tete::before { content: ""; position: absolute; left: 50%; top: 6px; width: 44px; height: 5px; margin-left: -22px; border-radius: 3px; background: var(--trait); }
}
@media (max-width: 360px) { .cartes { grid-template-columns: 1fr; } }
@media (prefers-reduced-motion: reduce) { .ecran.actif { animation: none; } * { transition: none !important; } }
@media print {
  header.haut, nav.bas, .cta, .outils, .chips, .recherche { display: none !important; }
  body { background: #fff; color: #000; }
}

#tiroir[hidden] { display: none; }
