:root{
  --bg:#f5f7f8; --surface:#fff; --fg:#1b2730; --muted:#5d6d78; --line:#dbe2e6; --soft:#eef2f4;
  --accent:#17607a; --accent-fg:#fff; --danger:#c2410c; --ok:#2f7d4f; --ok-soft:#dcefe3; --warn-soft:#fdecd3;
}
@media (prefers-color-scheme:dark){:root:not([data-theme="light"]){
  --bg:#11181d; --surface:#18222a; --fg:#e4ebef; --muted:#9aabb6; --line:#2b3943; --soft:#1f2b33;
  --accent:#5fb6d1; --accent-fg:#0d1a20; --danger:#fb8a4f; --ok:#6fd096; --ok-soft:#183324; --warn-soft:#3a2b14;
  color-scheme:dark}}
:root[data-theme="dark"]{
  --bg:#11181d; --surface:#18222a; --fg:#e4ebef; --muted:#9aabb6; --line:#2b3943; --soft:#1f2b33;
  --accent:#5fb6d1; --accent-fg:#0d1a20; --danger:#fb8a4f; --ok:#6fd096; --ok-soft:#183324; --warn-soft:#3a2b14;
  color-scheme:dark}
*{box-sizing:border-box}
html{-webkit-text-size-adjust:100%}
body{margin:0;background:var(--bg);color:var(--fg);font:16px/1.5 system-ui,-apple-system,"Segoe UI",Roboto,sans-serif}
a{color:var(--accent)}
h1{font-size:1.5rem;margin:0 0 4px;line-height:1.2}
h2{font-size:1.1rem;margin:0;line-height:1.25}
p{margin:0}
.muted{color:var(--muted);font-size:.9rem}
[hidden]{display:none!important}
:focus-visible{outline:2px solid var(--accent);outline-offset:2px}

#barre{position:sticky;top:0;z-index:5;display:flex;align-items:center;justify-content:space-between;gap:12px;
  background:var(--accent);color:var(--accent-fg);
  padding:calc(10px + env(safe-area-inset-top,0px)) max(16px,env(safe-area-inset-right,0px)) 10px max(16px,env(safe-area-inset-left,0px))}
#barre a{color:inherit;text-decoration:none}
.marque{font-weight:700;font-size:1.15rem}
#nav{display:flex;gap:4px;flex-wrap:wrap;justify-content:flex-end}
#nav a,#nav button{font:inherit;font-size:.9rem;color:inherit;background:none;border:1px solid transparent;border-radius:8px;padding:6px 10px;cursor:pointer}
#nav a[aria-current="page"]{border-color:currentColor}

main{max-width:1100px;margin:0 auto;display:flex;flex-direction:column;gap:20px;
  padding:20px max(16px,env(safe-area-inset-right,0px)) calc(40px + env(safe-area-inset-bottom,0px)) max(16px,env(safe-area-inset-left,0px))}
.attente{color:var(--muted);text-align:center;padding:40px 0}
.entete{display:flex;flex-wrap:wrap;gap:12px;align-items:flex-end;justify-content:space-between}

button,input,select{font:inherit;color:inherit}
.btn{border:1px solid var(--line);background:var(--surface);border-radius:8px;padding:9px 14px;font-weight:600;cursor:pointer;min-height:42px}
.btn.primary{background:var(--accent);border-color:var(--accent);color:var(--accent-fg)}
.btn.danger{color:var(--danger)}
.btn.petit{min-height:34px;padding:4px 10px;font-size:.85rem;font-weight:500}
.btn:disabled{opacity:.5;cursor:not-allowed}
input[type=text],input[type=password],select{border:1px solid var(--line);background:var(--surface);border-radius:8px;padding:9px 10px;min-height:42px;width:100%;min-width:0}
.champ{display:flex;flex-direction:column;gap:4px;font-size:.85rem;font-weight:600;color:var(--muted)}
label.coche{display:inline-flex;align-items:center;gap:8px}
input[type=checkbox]{width:22px;height:22px;accent-color:var(--accent);flex:none}

.carte{background:var(--surface);border:1px solid var(--line);border-radius:12px;padding:16px;display:flex;flex-direction:column;gap:12px;min-width:0}
.etroit{max-width:420px;width:100%;margin:6vh auto 0}
.erreur{color:var(--danger);font-size:.9rem}
.info{background:var(--ok-soft);color:var(--ok);border-radius:8px;padding:8px 12px;font-size:.9rem}
.avis{background:var(--warn-soft);border-radius:8px;padding:8px 12px;font-size:.9rem}
.ligne{display:flex;flex-wrap:wrap;gap:8px;align-items:center}
.pousse{margin-left:auto}

/* Accueil */
.tuiles{display:grid;grid-template-columns:repeat(auto-fill,minmax(160px,1fr));gap:12px}
.tuile{background:var(--surface);border:1px solid var(--line);border-radius:14px;padding:18px 16px;min-height:120px;
  display:flex;flex-direction:column;justify-content:space-between;gap:10px;text-decoration:none;color:inherit}
a.tuile:hover{border-color:var(--accent)}
.tuile strong{font-size:1.05rem}
.tuile .pastille{align-self:flex-start;font-size:.75rem;font-weight:600;border-radius:999px;padding:2px 10px;background:var(--soft);color:var(--muted)}
.tuile.bientot{opacity:.65}
.tuile svg{width:30px;height:30px;color:var(--accent)}

/* Courses */
.listes{display:grid;grid-template-columns:repeat(auto-fill,minmax(290px,1fr));gap:14px;align-items:start}
.liste h2 small{display:block;font-size:.8rem;font-weight:500;color:var(--muted)}
.compte{font-size:.8rem;color:var(--muted);white-space:nowrap}
.articles{list-style:none;margin:0;padding:0;display:flex;flex-direction:column}
.articles li{display:flex;align-items:center;gap:10px;padding:7px 0;border-top:1px solid var(--line);min-height:46px}
.articles li .txt{flex:1;min-width:0;overflow-wrap:anywhere}
.articles li .txt small{display:block;color:var(--muted);font-size:.78rem}
.articles li.fait .txt{text-decoration:line-through;color:var(--muted)}
.articles .qte{font-size:.85rem;color:var(--muted);white-space:nowrap}
.x{border:0;background:none;color:var(--muted);font-size:1.2rem;line-height:1;cursor:pointer;width:36px;height:36px;border-radius:8px;flex:none}
.x:hover{background:var(--soft);color:var(--danger)}
form.ajout{display:grid;grid-template-columns:1fr 84px auto;gap:6px}
.vide{color:var(--muted);font-size:.9rem;padding:6px 0}

/* Administration */
.tableau{overflow-x:auto}
.tableau table{border-collapse:collapse;width:100%;font-size:.92rem}
.tableau th,.tableau td{text-align:left;padding:8px 10px 8px 0;border-top:1px solid var(--line);vertical-align:middle;white-space:nowrap}
.tableau thead th{border-top:0;font-size:.78rem;color:var(--muted);font-weight:600}
.tableau td select{min-height:36px;padding:4px 6px;width:auto}
.grille{display:grid;grid-template-columns:repeat(auto-fill,minmax(180px,1fr));gap:10px;align-items:end}
.lien{font-family:ui-monospace,Menlo,Consolas,monospace;font-size:.82rem;overflow-wrap:anywhere;background:var(--soft);border-radius:8px;padding:8px 10px}

@media (max-width:480px){form.ajout{grid-template-columns:1fr 70px auto}.btn{padding:9px 12px}}
@media (prefers-reduced-motion:reduce){*{transition:none!important;animation:none!important}}

/* Repas et tâches */
.semaine{display:grid;grid-template-columns:repeat(auto-fill,minmax(250px,1fr));gap:12px}
.jour h2{display:flex;justify-content:space-between;align-items:baseline;gap:8px;text-transform:capitalize}
.jour h2 small{font-size:.8rem;font-weight:500;color:var(--muted);text-transform:none}
.jour.auj{border-color:var(--accent);box-shadow:inset 0 0 0 1px var(--accent)}
.repas{display:grid;grid-template-columns:44px 1fr;gap:8px;align-items:center}
.repas>span:first-child{font-size:.8rem;font-weight:600;color:var(--muted)}
.repas .plat{min-height:42px;display:flex;align-items:center;overflow-wrap:anywhere}
.tc-retard{--evc:var(--danger)}.tc-jour{--evc:var(--accent)}.tc-plus{--evc:var(--line)}
.puces{display:flex;flex-wrap:wrap;gap:6px}
.puces button{border:1px solid var(--line);background:var(--surface);border-radius:999px;padding:6px 14px;cursor:pointer;font-weight:500;min-height:38px}
.puces button[aria-pressed="true"]{background:var(--accent);border-color:var(--accent);color:var(--accent-fg)}
a.item{text-decoration:none;color:inherit}

/* Arrière-plan : une famille sur un chemin */
.fond{position:fixed;left:0;right:0;bottom:0;width:100%;height:min(48vh,440px);z-index:-1;pointer-events:none;color:var(--accent);opacity:.11}
:root[data-theme="dark"] .fond{opacity:.16}
@media (prefers-color-scheme:dark){:root:not([data-theme="light"]) .fond{opacity:.16}}
.marque small{font-weight:500;opacity:.85}
/* Apparence */
.pastilles{display:flex;flex-wrap:wrap;gap:10px;align-items:center}
.pastilles button{width:40px;height:40px;border-radius:50%;border:3px solid var(--surface);box-shadow:0 0 0 1px var(--line);cursor:pointer;padding:0}
.pastilles button[aria-pressed="true"]{box-shadow:0 0 0 3px var(--fg)}
.pastilles input[type=color]{width:44px;height:44px;padding:2px;border:1px solid var(--line);border-radius:8px;background:var(--surface);cursor:pointer}
.carte.suite{margin-top:0}
.marque{white-space:nowrap}
@media (max-width:520px){#barre{flex-direction:column;align-items:flex-start;gap:2px}#nav{justify-content:flex-start;margin-left:-10px}}

/* Repas : tableau jours x (midi, soir) */
table.menus{width:100%;border-collapse:collapse;table-layout:fixed}
.menus th,.menus td{padding:6px 6px 6px 0;border-top:1px solid var(--line);text-align:left;vertical-align:middle;overflow-wrap:anywhere}
.menus thead th{border-top:0;font-size:.8rem;color:var(--muted);font-weight:600;padding-bottom:8px}
.menus thead th:first-child,.menus tbody th{width:92px}
.menus tbody th{font-weight:600;text-transform:capitalize}
.menus tbody th small{display:block;font-size:.76rem;font-weight:500;color:var(--muted);text-transform:none}
.menus td:last-child{padding-right:0}
.menus tr.auj th{color:var(--accent)}
.menus tr.auj td input{border-color:var(--accent)}
@media (max-width:420px){.menus thead th:first-child,.menus tbody th{width:74px}.menus input[type=text]{padding:9px 6px}}
.plat-b{display:block;width:100%;min-height:42px;text-align:left;font:inherit;color:inherit;background:var(--surface);border:1px solid var(--line);border-radius:8px;padding:8px 10px;cursor:text;overflow-wrap:anywhere}
.plat-b.vide{color:var(--muted)}
.plat-b:hover{border-color:var(--accent)}
.menus tr.auj .plat-b{border-color:var(--accent)}
.menus .court{display:none}
@media (max-width:480px){.menus .long{display:none}.menus .court{display:inline}.menus thead th:first-child,.menus tbody th{width:70px}.menus tbody th small{white-space:nowrap}.plat-b{padding:8px}}

/* Recettes */
textarea{font:inherit;color:inherit;border:1px solid var(--line);background:var(--surface);border-radius:8px;padding:9px 10px;width:100%;min-width:0;resize:vertical;line-height:1.45}
.tuiles.recettes{grid-template-columns:repeat(auto-fill,minmax(220px,1fr))}
.tuile.recette{min-height:92px;justify-content:flex-start}
.fiche{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1.6fr);gap:14px;align-items:start}
@media (max-width:760px){.fiche{grid-template-columns:1fr}}
.ingredients{margin:0;padding-left:20px;display:flex;flex-direction:column;gap:6px}
.ingredients.grand{list-style:none;padding:0;gap:4px;font-size:1.1rem}
.ingredients.grand .coche{padding:8px 0;width:100%}
.etapes{margin:0;padding-left:24px;display:flex;flex-direction:column;gap:12px}
.etapes li::marker{font-weight:700;color:var(--accent)}
.pile-s{display:flex;flex-direction:column;gap:14px}
.cases{display:flex;flex-direction:column;gap:2px;max-height:42vh;overflow-y:auto}
.cases .coche{padding:6px 0}
.lien-rec{display:inline-block;font-size:.8rem;margin-top:3px}
/* Pas à pas : plein écran, gros caractères */
.pas{position:fixed;inset:0;z-index:30;background:var(--bg);display:flex;flex-direction:column;
  padding:calc(12px + env(safe-area-inset-top,0px)) max(16px,env(safe-area-inset-right,0px)) calc(12px + env(safe-area-inset-bottom,0px)) max(16px,env(safe-area-inset-left,0px))}
.pas-haut{display:flex;justify-content:space-between;align-items:center;gap:12px;padding-bottom:10px;border-bottom:1px solid var(--line)}
.pas-haut strong{font-size:1.15rem}
.pas-corps{flex:1;overflow-y:auto;padding:18px 0;max-width:760px;width:100%;margin:0 auto}
.pas-texte{font-size:clamp(1.3rem,4.6vw,1.9rem);line-height:1.45}
.pas-bas{display:grid;grid-template-columns:1fr 1.4fr;gap:10px;max-width:760px;width:100%;margin:0 auto}
.pas-bas .btn{min-height:58px;font-size:1.1rem}

/* Tâches : case à cocher, annulable */
.item.tache{grid-template-columns:6px auto 1fr auto;padding-right:8px}
.item.tache.faite .t{text-decoration:line-through;color:var(--muted)}
@media (max-width:560px){.item.tache{grid-template-columns:6px auto 1fr}.item.tache>.stripe{grid-row:1/3}.item.tache>.ligne{grid-column:3}}

/* Garde-manger */
.item.stockee{grid-template-columns:6px 1fr auto;padding-right:8px}
.item.stockee.zero .t{color:var(--muted)}
.qte-b{display:inline-flex;align-items:center;gap:4px}
.qte-b button{width:44px;height:44px;border-radius:10px;border:1px solid var(--line);background:var(--surface);font-size:1.4rem;line-height:1;cursor:pointer;font-weight:600}
.qte-b button:disabled{opacity:.4;cursor:not-allowed}
.qte-b b{min-width:40px;text-align:center;font-size:1.15rem;font-variant-numeric:tabular-nums}
@media (max-width:560px){.item.stockee>.actions-s{grid-column:2/4}}
.actions-s{display:flex;gap:6px;align-items:center;flex-wrap:wrap}
.scan{position:fixed;inset:0;z-index:40;background:#000;color:#fff;display:flex;flex-direction:column}
.scan video{flex:1;min-height:0;width:100%;object-fit:cover}
.scan-bas{padding:14px 16px calc(14px + env(safe-area-inset-bottom,0px));display:flex;gap:12px;align-items:center;justify-content:space-between;background:#111}
.scan-cadre{position:absolute;left:10%;right:10%;top:38%;height:22%;border:3px solid #fff;border-radius:14px;box-shadow:0 0 0 100vmax rgba(0,0,0,.35);pointer-events:none}
.lien-b{background:none;border:0;padding:0;font:inherit;color:inherit;cursor:pointer;text-align:left;text-decoration:underline;text-decoration-color:var(--line);text-underline-offset:3px}
.item .t.lien-b{display:block;font-weight:600}

/* Cave à vin */
.v-rouge{--evc:#8b1e3f}.v-blanc{--evc:#d9c46a}.v-rose{--evc:#e8909c}.v-effervescent{--evc:#8fbccf}.v-liquoreux{--evc:#c98a2b}.v-autre{--evc:var(--line)}
.etoiles{color:#c98a0c;letter-spacing:1px;white-space:nowrap}
.etoiles .vide{color:var(--line)}
.note-b{display:flex;gap:4px}
.note-b button{font-size:1.9rem;line-height:1;background:none;border:0;cursor:pointer;color:var(--line);padding:2px 4px;min-width:44px;min-height:44px}
.note-b button[aria-pressed="true"]{color:#c98a0c}
.avis-v{border-top:1px solid var(--line);padding:10px 0;display:flex;flex-direction:column;gap:2px}
.avis-v .ligne{justify-content:space-between}
.grille3{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px}
@media (max-width:480px){.grille3{grid-template-columns:1fr 1fr}}
