/* Direction « papier et orange » : les mêmes couleurs que l'appli Android. */
:root {
  --fond: #FBF8F3; --texte: #262320; --discret: #7A746B; --trait: #EBE5DA; --carte: #FFFFFF;
  --accent: #D9560F; --sur-accent: #FFFFFF; --teinte: #FCE4D0; --sur-teinte: #5A2000;
  --avec: #2F7D4F; --avec-fond: #DDF0E3; --sans: #B3261E; --sans-fond: #F9DEDC; --erreur: #B3261E;
  --code: #F2ECE0;
  --r-Legumes: #2E7D32; --r-Viande: #C62828; --r-Poisson: #00838F; --r-Cremerie: #1565C0; --r-Boulangerie: #8D5524;
  --r-Epicerie: #B28704; --r-Epices: #7B1FA2; --r-Surgeles: #3949AB; --r-Boissons: #AD1457; --r-Autre: #6B655B;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fond: #1A1816; --texte: #F1EEE8; --discret: #A39C91; --trait: #33302B; --carte: #24211E;
    --accent: #FFA36B; --sur-accent: #4A1A00; --teinte: #6B2D08; --sur-teinte: #FCE4D0;
    --avec: #7FD39F; --avec-fond: #1E3A2A; --sans: #F2B8B5; --sans-fond: #4A2220; --erreur: #F2B8B5;
    --code: #12100E;
    --r-Legumes: #7FD48A; --r-Viande: #FF8A80; --r-Poisson: #4DD0E1; --r-Cremerie: #82B1FF; --r-Boulangerie: #E0A875;
    --r-Epicerie: #FFD166; --r-Epices: #D7A6F0; --r-Surgeles: #A9B3FF; --r-Boissons: #FF8AB8; --r-Autre: #B5AEA2;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body { background: var(--fond); color: var(--texte); font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
.ic { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; flex: none; position: relative; }
.ic svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ic.plein { background: var(--accent); color: var(--sur-accent); }
.ic.doux { background: var(--teinte); color: var(--sur-teinte); }
.ic:hover { background: color-mix(in srgb, var(--texte) 8%, transparent); }
.ic.plein:hover { background: var(--accent); filter: brightness(1.08); }
.ic[disabled] { opacity: .35; pointer-events: none; }
.pastille { position: absolute; top: 2px; right: 0; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; background: var(--accent); color: var(--sur-accent); font-size: 11px; font-weight: 800; display: grid; place-items: center; }

/* Mise en page : un écran, une barre d'onglets en bas */
#app { height: 100%; display: flex; flex-direction: column; max-width: 760px; margin: 0 auto; position: relative; }
.ecran { flex: 1; overflow-y: auto; min-height: 0; padding-bottom: 96px; }
.entete { display: flex; align-items: center; gap: 2px; padding: 12px 8px 4px 20px; }
.entete h1 { flex: 1; margin: 0; font-size: 28px; line-height: 1.15; font-weight: 800; letter-spacing: -.01em; }
.barre { display: flex; align-items: center; gap: 2px; padding: 8px 8px 4px 8px; }
.barre .espace { flex: 1; }
nav.onglets { display: flex; border-top: 1px solid var(--trait); background: var(--fond); padding-bottom: env(safe-area-inset-bottom, 0); }
nav.onglets button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 7px; font-size: 12px; font-weight: 600; color: var(--discret); }
nav.onglets button svg { width: 24px; height: 24px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
nav.onglets button[aria-current="page"] { color: var(--accent); }

/* Champs et puces */
.champ { display: flex; align-items: center; gap: 8px; background: var(--carte); border: 1px solid var(--trait); border-radius: 50px; padding: 0 14px; min-height: 46px; flex: 1; min-width: 0; }
.champ svg { width: 20px; height: 20px; stroke: var(--discret); fill: none; stroke-width: 2; stroke-linecap: round; flex: none; }
.champ input { flex: 1; min-width: 0; border: 0; background: none; outline: none; padding: 10px 0; }
.rangee { display: flex; align-items: center; gap: 4px; padding: 4px 16px; }
.puces { display: flex; gap: 8px; padding: 6px 16px; overflow-x: auto; scrollbar-width: none; }
.puces.libre { flex-wrap: wrap; overflow: visible; padding: 0; }
.puce { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 50px; background: var(--teinte); color: var(--sur-teinte); font-size: 14px; font-weight: 600; white-space: nowrap; flex: none; }
.puce small { opacity: .7; font-size: 13px; font-weight: 600; }
.puce.choisie { background: var(--accent); color: var(--sur-accent); }
.puce.avec { background: var(--avec-fond); color: var(--avec); }
.puce.sans { background: var(--sans-fond); color: var(--sans); text-decoration: line-through; }
.puce.vue { background: var(--teinte); padding-right: 6px; }
.puce .x { width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; }
.puce .x svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2.4; stroke-linecap: round; }
.puce.carre { padding: 0; width: 38px; height: 38px; justify-content: center; background: var(--carte); border: 1px solid var(--trait); color: var(--texte); }
.puce.carre svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2.2; stroke-linecap: round; }

/* Listes */
.liste { padding: 4px 16px; }
.ligne { display: flex; align-items: center; gap: 12px; padding: 13px 4px; border-bottom: 1px solid var(--trait); cursor: pointer; }
.ligne .corps { flex: 1; min-width: 0; }
.ligne b { display: block; font-size: 17px; }
.ligne .sous { color: var(--discret); font-size: 14px; }
.points { display: flex; gap: 5px; }
.point { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }
.vide { display: grid; place-items: center; padding: 64px 0; color: var(--trait); }
.vide svg { width: 64px; height: 64px; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.vide.bouton button { width: 96px; height: 96px; border-radius: 50%; background: var(--teinte); color: var(--accent); display: grid; place-items: center; }
.erreur { color: var(--erreur); font-size: 14px; padding: 2px 20px; }
.fab { position: fixed; right: max(16px, calc(50% - 380px + 16px)); bottom: calc(80px + env(safe-area-inset-bottom, 0)); width: 56px; height: 56px; border-radius: 18px; background: var(--accent); color: var(--sur-accent); display: grid; place-items: center; box-shadow: 0 6px 18px rgba(0,0,0,.25); z-index: 5; }
.fab svg { width: 26px; height: 26px; stroke: currentColor; fill: none; stroke-width: 2.4; stroke-linecap: round; }
.etiquette-rayon { font-size: 12px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; padding: 14px 20px 4px; display: flex; align-items: center; gap: 8px; }

/* Feuille de filtres et fenêtres */
.voile { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.voile.centre { align-items: center; }
.feuille { background: var(--fond); width: 100%; max-width: 760px; max-height: 88vh; display: flex; flex-direction: column; border-radius: 24px 24px 0 0; box-shadow: 0 -10px 30px rgba(0,0,0,.2); overflow: hidden; }
.feuille::before { content: ""; width: 38px; height: 4px; border-radius: 4px; background: var(--trait); align-self: center; margin: 10px 0 2px; flex: none; }
.feuille .defile { flex: 1; overflow-y: auto; padding: 0 20px; min-height: 0; }
.feuille .pied { display: flex; gap: 10px; align-items: center; padding: 12px 20px calc(12px + env(safe-area-inset-bottom, 0)); }
.dialogue { background: var(--fond); border-radius: 20px; padding: 20px; width: min(92vw, 420px); display: flex; flex-direction: column; gap: 14px; box-shadow: 0 10px 40px rgba(0,0,0,.3); }
.dialogue h2 { margin: 0; font-size: 20px; }
.dialogue input[type=text], .dialogue input[type=password] { width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--trait); background: var(--carte); outline: none; }
.dialogue label { font-size: 13px; color: var(--discret); font-weight: 700; display: flex; flex-direction: column; gap: 6px; }
.actions { display: flex; gap: 8px; justify-content: flex-end; align-items: center; }
.bouton { background: var(--accent); color: var(--sur-accent); font-weight: 800; padding: 12px 20px; border-radius: 14px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.bouton.doux { background: var(--teinte); color: var(--sur-teinte); }
.bouton.danger { background: var(--sans-fond); color: var(--sans); }
.bouton[disabled] { opacity: .4; pointer-events: none; }
.bouton svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.bouton.large { flex: 1; font-size: 17px; font-variant-numeric: tabular-nums; }
.section { border-bottom: 1px solid var(--trait); }
.section > .tete { display: flex; align-items: center; gap: 12px; padding: 14px 0; cursor: pointer; width: 100%; text-align: left; }
.section > .tete svg { width: 22px; height: 22px; stroke: var(--discret); fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.section.active > .tete > svg:first-child { stroke: var(--accent); }
.section .titre { flex: 1; font-weight: 800; font-size: 15px; }
.section .valeur { color: var(--accent); font-weight: 800; font-size: 14px; }
.section .contenu { padding: 0 0 14px; display: flex; flex-direction: column; gap: 12px; }
.section .chevron { transition: transform .15s; }
.section.ouverte .chevron { transform: rotate(180deg); }
.plage { position: relative; height: 34px; margin: 0 8px; }
.plage::before { content: ""; position: absolute; left: 0; right: 0; top: 15px; height: 4px; border-radius: 4px; background: var(--trait); }
.plage .rempli { position: absolute; top: 15px; height: 4px; border-radius: 4px; background: var(--accent); }
.plage input { position: absolute; left: -8px; width: calc(100% + 16px); top: 0; height: 34px; margin: 0; background: none; pointer-events: none; -webkit-appearance: none; appearance: none; }
.plage input::-webkit-slider-runnable-track { background: none; height: 34px; }
.plage input::-moz-range-track { background: none; }
.plage input::-webkit-slider-thumb { -webkit-appearance: none; pointer-events: auto; width: 22px; height: 22px; margin-top: 6px; border-radius: 50%; background: var(--accent); border: 3px solid var(--fond); box-shadow: 0 1px 4px rgba(0,0,0,.35); cursor: pointer; }
.plage input::-moz-range-thumb { pointer-events: auto; width: 16px; height: 16px; border-radius: 50%; background: var(--accent); border: 3px solid var(--fond); cursor: pointer; }
.plage.simple input { pointer-events: auto; }

/* Fiche */
.fiche { padding: 4px 20px 24px; }
.fiche h1 { margin: 6px 0 8px; font-size: 30px; line-height: 1.15; }
.meta { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; color: var(--discret); margin-bottom: 8px; }
.compteur { display: inline-flex; align-items: center; background: var(--carte); border: 1px solid var(--trait); border-radius: 50px; }
.compteur button { width: 40px; height: 40px; font-size: 22px; }
.compteur span { min-width: 64px; text-align: center; font-weight: 700; }
.fiche h2 { font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--discret); margin: 22px 0 6px; }
.ing { display: flex; align-items: baseline; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--trait); font-size: 17px; }
.ing .q { font-weight: 700; min-width: 70px; font-variant-numeric: tabular-nums; }
.etape { display: flex; gap: 12px; padding: 9px 0; font-size: 16px; line-height: 1.5; }
.etape i { font-style: normal; font-weight: 800; color: var(--accent); width: 20px; flex: none; }
.notes { white-space: pre-wrap; color: var(--discret); }
.notes a { color: var(--accent); }

/* Éditeur sur place (A1) */
.edition { padding: 0 20px 24px; display: flex; flex-direction: column; gap: 4px; }
.edition .titre-champ { font-size: 28px; font-weight: 800; border: 0; background: none; outline: none; width: 100%; padding: 8px 0; letter-spacing: -.01em; }
.edition .rang { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.nb { display: inline-flex; align-items: center; gap: 5px; background: var(--teinte); color: var(--sur-teinte); padding: 6px 14px; border-radius: 50px; font-weight: 700; }
.nb input { width: 44px; border: 0; background: none; outline: none; text-align: right; font-weight: 700; color: inherit; }
.tag-champ { border: 0; background: none; outline: none; width: 110px; padding: 6px; }
.edition h2 { font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--discret); margin: 18px 0 2px; }
.lg-ing { display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--trait); }
.lg-ing input { flex: 1; border: 0; background: none; outline: none; padding: 11px 0; font-size: 17px; min-width: 0; }
.lg-etape { display: flex; gap: 10px; align-items: flex-start; }
.lg-etape i { font-style: normal; font-weight: 800; color: var(--accent); width: 20px; padding-top: 9px; flex: none; }
.lg-etape textarea, .edition .notes-champ { flex: 1; border: 0; background: none; outline: none; resize: none; padding: 9px 0; line-height: 1.5; overflow: hidden; width: 100%; }
.edition .notes-champ { color: var(--discret); min-height: 70px; }
.ajout { align-self: flex-start; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; color: var(--discret); }
.ajout svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 2.2; stroke-linecap: round; }
.touches { display: flex; gap: 6px; overflow-x: auto; padding: 8px 0 4px; scrollbar-width: none; }
.touches button { flex: none; height: 38px; padding: 0 14px; border-radius: 12px; background: var(--carte); border: 1px solid var(--trait); font-family: ui-monospace, Menlo, monospace; font-weight: 600; font-size: 14px; }
.touches button.accent { background: var(--teinte); color: var(--sur-teinte); border-color: transparent; }
.brut { width: calc(100% - 24px); margin: 0 12px; min-height: 60vh; border: 0; border-radius: 16px; background: var(--code); padding: 16px; font: 14px/1.6 ui-monospace, Menlo, monospace; outline: none; resize: vertical; color: var(--texte); }

/* Historique (avant / après) */
.deux { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 8px 16px; }
.deux h3 { margin: 0 0 4px; font-size: 12px; color: var(--discret); text-transform: uppercase; letter-spacing: .08em; }
.df { font-size: 13.5px; line-height: 1.4; padding: 3px 8px; border-radius: 6px; margin: 2px 0; overflow-wrap: anywhere; }
.df.ajout-l { background: var(--avec-fond); color: var(--avec); }
.df.retrait-l { background: var(--sans-fond); color: var(--sans); text-decoration: line-through; text-decoration-thickness: 1px; }
.df.commun-l { color: var(--discret); }

/* Plan */
.jour { display: flex; align-items: stretch; gap: 8px; padding: 4px 16px; }
.jour .date { width: 46px; text-align: center; display: flex; flex-direction: column; justify-content: center; color: var(--discret); font-size: 13px; font-weight: 600; }
.jour .date b { font-size: 22px; color: var(--texte); }
.jour.auj .date b { color: var(--accent); }
.creneau { flex: 1; min-width: 0; min-height: 58px; border-radius: 14px; background: var(--carte); border: 1px solid var(--trait); display: flex; align-items: center; padding: 8px 12px; gap: 6px; text-align: left; font-weight: 700; }
.creneau.vide-c { border-style: dashed; background: none; justify-content: center; color: var(--discret); }
.creneau span { overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.entetes-c { display: flex; padding: 0 16px 0 70px; gap: 8px; color: var(--discret); font-size: 13px; font-weight: 600; }
.entetes-c span { flex: 1; padding-left: 4px; }

/* Courses */
.article { display: flex; align-items: center; gap: 12px; padding: 11px 20px; cursor: pointer; }
.case { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--discret); display: grid; place-items: center; flex: none; }
.case.cochee { background: var(--accent); border-color: var(--accent); }
.case svg { width: 16px; height: 16px; stroke: var(--sur-accent); fill: none; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.article.fait .texte { text-decoration: line-through; color: var(--discret); }
.article .texte { flex: 1; font-size: 17px; }

/* Statistiques */
.gros { font-size: 44px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.macros { display: flex; height: 10px; border-radius: 10px; overflow: hidden; margin: 8px 0; }
.stat-ligne { padding: 8px 20px; }
.stat-ligne .tete { display: flex; align-items: center; gap: 10px; }
.stat-ligne .barre-fond { height: 4px; border-radius: 4px; background: var(--trait); margin-top: 5px; overflow: hidden; }
.stat-ligne .barre-fond i { display: block; height: 100%; }

#toasts { position: fixed; left: 0; right: 0; bottom: calc(84px + env(safe-area-inset-bottom, 0)); display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 40; pointer-events: none; }
.toast { background: var(--texte); color: var(--fond); padding: 10px 16px; border-radius: 12px; font-size: 14px; max-width: 90vw; }
.tourne { animation: tourne 1s linear infinite; }
@keyframes tourne { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .tourne { animation: none; } .section .chevron { transition: none; } }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Icônes posées directement dans une ligne ou une barre (sans bouton) */
.barre > svg, .ligne > svg, .creneau.vide-c svg { width: 24px; height: 24px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.barre > svg { stroke: var(--accent); margin: 0 8px; }
.ligne > svg { stroke: var(--accent); }
