/* Famille — styles de l'application. Couleurs issues des maquettes V1 (docs/maquettes/v1).
   Thème : « Automatique » suit le téléphone ; Clair / Sombre forcés par data-theme (D26). */

:root {
  --bg: #F4F5F1; --surface: #FFFFFF; --track: #E6E9E3; --nav: #FFFFFF;
  --ink: #1C2620; --body: #3D4942; --muted: #55625A; --faint: #7C8A81;
  --line: #DDE2DA; --row-line: #EEF1EC; --input-border: #C9D0C6; --input-bg: #FFFFFF;
  --check-border: #7C8A81; --done-text: #6B776F; --drag-bg: #EAF3EE;
  --accent: #2E6A4C; --on-accent: #FFFFFF; --accent-text: #2E6A4C;
  --off-bg: #FCEFD9; --off-border: #E7C48C; --off-fg: #6E420B;
  --err-bg: #FDECEA; --err-fg: #8A2318; --danger: #A3291C;
  --seg-on: #FFFFFF; --seg-shadow: 0 1px 2px rgba(28, 38, 32, 0.12);
  --toast-bg: #1C2620; --toast-fg: #FFFFFF; --overlay: rgba(28, 38, 32, 0.45);
  --p-green-bg: #DDEBE2; --p-green-fg: #1F4D36;
  --p-blue-bg: #DCEBFA;  --p-blue-fg: #1F4E7A;
  --p-orange-bg: #FBE3D3; --p-orange-fg: #8A3B12;
  --p-purple-bg: #EDE3F7; --p-purple-fg: #5B2E86;
  --p-gold-bg: #F3E6C8;  --p-gold-fg: #6B4A0A;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111613; --surface: #1A211D; --track: #232B26; --nav: #151B17;
    --ink: #E6ECE7; --body: #C3CCC5; --muted: #A3AEA6; --faint: #8A968F;
    --line: #2E3832; --row-line: #252E29; --input-border: #3A453E; --input-bg: #151B17;
    --check-border: #7E8C84; --done-text: #85918A; --drag-bg: #22302A;
    --accent: #7FCBA3; --on-accent: #0E1A13; --accent-text: #7FCBA3;
    --off-bg: #3A2C14; --off-border: #6B5126; --off-fg: #F2C987;
    --err-bg: #3A1C18; --err-fg: #F6B8AE; --danger: #F49B8E;
    --seg-on: #36423B; --seg-shadow: none;
    --toast-bg: #E6ECE7; --toast-fg: #111613; --overlay: rgba(0, 0, 0, 0.6);
    --p-green-bg: #25392E; --p-green-fg: #A8E0C0;
    --p-blue-bg: #1E3446;  --p-blue-fg: #A9CDEE;
    --p-orange-bg: #44291A; --p-orange-fg: #F4BE9A;
    --p-purple-bg: #33264A; --p-purple-fg: #D3B8F0;
    --p-gold-bg: #3B3018;  --p-gold-fg: #EBCF8E;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111613; --surface: #1A211D; --track: #232B26; --nav: #151B17;
  --ink: #E6ECE7; --body: #C3CCC5; --muted: #A3AEA6; --faint: #8A968F;
  --line: #2E3832; --row-line: #252E29; --input-border: #3A453E; --input-bg: #151B17;
  --check-border: #7E8C84; --done-text: #85918A; --drag-bg: #22302A;
  --accent: #7FCBA3; --on-accent: #0E1A13; --accent-text: #7FCBA3;
  --off-bg: #3A2C14; --off-border: #6B5126; --off-fg: #F2C987;
  --err-bg: #3A1C18; --err-fg: #F6B8AE; --danger: #F49B8E;
  --seg-on: #36423B; --seg-shadow: none;
  --toast-bg: #E6ECE7; --toast-fg: #111613; --overlay: rgba(0, 0, 0, 0.6);
  --p-green-bg: #25392E; --p-green-fg: #A8E0C0;
  --p-blue-bg: #1E3446;  --p-blue-fg: #A9CDEE;
  --p-orange-bg: #44291A; --p-orange-fg: #F4BE9A;
  --p-purple-bg: #33264A; --p-purple-fg: #D3B8F0;
  --p-gold-bg: #3B3018;  --p-gold-fg: #EBCF8E;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  font-size: 17px; line-height: 1.35;
  -webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent-text); }
svg.i { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.boot { padding: 40px 20px; text-align: center; color: var(--muted); }
:focus-visible { outline: 3px solid var(--accent-text); outline-offset: 2px; }

/* --- Mise en page --- */
.screen { max-width: 560px; margin: 0 auto; min-height: 100%; display: flex; flex-direction: column; }
.screen-header { padding: 16px 20px 12px; display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.row.start { justify-content: flex-start; }
h1 { margin: 0; font-size: 28px; font-weight: 700; letter-spacing: -0.01em; }
.subtle { font-size: 15px; color: var(--muted); }
.screen-main { flex: 1; padding: 0 20px 110px; display: flex; flex-direction: column; gap: 16px; }

.avatar { width: 44px; height: 44px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; font-size: 17px; font-weight: 700; text-decoration: none; flex: none; border: none; }
.avatar.small { width: 26px; height: 26px; font-size: 13px; }
.p-green { background: var(--p-green-bg); color: var(--p-green-fg); }
.p-blue { background: var(--p-blue-bg); color: var(--p-blue-fg); }
.p-orange { background: var(--p-orange-bg); color: var(--p-orange-fg); }
.p-purple { background: var(--p-purple-bg); color: var(--p-purple-fg); }
.p-gold { background: var(--p-gold-bg); color: var(--p-gold-fg); }

/* --- Puce d'état de synchronisation --- */
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 14px; border-radius: 999px; font-size: 14px; font-weight: 700; white-space: nowrap; border: 1px solid var(--input-border); background: var(--surface); color: var(--accent-text); }
.chip.offline { border-color: var(--off-border); background: var(--off-bg); color: var(--off-fg); }
.chip.busy { color: var(--body); }

/* --- Contrôle segmenté --- */
.segmented { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; padding: 4px; background: var(--track); border-radius: 12px; }
.segmented button { min-height: 40px; border: none; border-radius: 9px; background: transparent; color: var(--muted); font-size: 15px; }
.segmented button[aria-pressed="true"] { background: var(--seg-on); color: var(--ink); font-weight: 700; box-shadow: var(--seg-shadow); }

/* --- Champs --- */
.add-form { display: flex; gap: 8px; }
.input { flex: 1; min-width: 0; height: 48px; padding: 0 14px; border: 1px solid var(--input-border); border-radius: 12px; background: var(--input-bg); color: var(--ink); font-size: 17px; }
.input::placeholder { color: var(--muted); opacity: 0.85; }
.btn { min-height: 48px; padding: 0 16px; border: none; border-radius: 12px; background: var(--accent); color: var(--on-accent); font-size: 16px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn.square { width: 48px; padding: 0; }
.btn.outline { background: var(--surface); color: var(--accent-text); border: 1px solid var(--accent-text); }
.btn.ghost { background: var(--surface); color: var(--ink); border: 1px solid var(--input-border); font-weight: 400; }
.btn.danger-text { background: transparent; color: var(--danger); }
.btn:disabled { opacity: 0.55; cursor: default; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 15px; font-weight: 700; }
.field > .input { flex: none; font-weight: 400; }
.field .add-form .input { font-weight: 400; }

/* --- Liste --- */
.group { display: flex; flex-direction: column; gap: 6px; }
.group-title { margin: 0; padding: 0 4px; font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.card { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.item { display: flex; align-items: center; gap: 10px; min-height: 56px; padding: 0 12px; border-top: 1px solid var(--row-line); background: var(--surface); }
.item:first-child { border-top: none; }
.item.dragging { background: var(--drag-bg); }
.item.pending .label::after { content: ""; display: inline-block; width: 6px; height: 6px; margin-left: 8px; border-radius: 999px; background: var(--off-fg); vertical-align: middle; }
.check { width: 44px; height: 44px; margin-left: -6px; border: none; background: transparent; display: flex; align-items: center; justify-content: center; padding: 0; flex: none; }
.check .box { width: 24px; height: 24px; border: 2px solid var(--check-border); border-radius: 6px; background: var(--surface); display: flex; align-items: center; justify-content: center; }
.check[aria-pressed="true"] .box { border: none; background: var(--accent); color: var(--on-accent); }
.dot { width: 8px; height: 8px; margin: 0 8px 0 4px; border-radius: 999px; background: var(--faint); flex: none; }
.label { flex: 1; min-width: 0; padding: 8px 0; font-size: 17px; overflow-wrap: anywhere; background: none; border: none; text-align: left; color: var(--ink); }
button.label { cursor: pointer; }
.qty { flex: none; font-size: 14px; color: var(--muted); }
.done .label, .done .qty { color: var(--done-text); text-decoration: line-through; }
.photo-btn { width: 40px; height: 44px; border: none; background: transparent; color: var(--muted); display: flex; align-items: center; justify-content: center; padding: 0; flex: none; }
.item-photo { display: block; width: 100%; max-height: 60vh; object-fit: contain; border-radius: 12px; background: var(--surface-2, transparent); margin-bottom: 12px; }
.handle { width: 40px; height: 44px; margin-right: -8px; border: none; background: transparent; color: var(--faint); display: flex; align-items: center; justify-content: center; padding: 0; touch-action: none; cursor: grab; flex: none; }
.empty { padding: 24px; text-align: center; color: var(--muted); font-size: 16px; }
.cart-toggle { display: flex; align-items: center; justify-content: space-between; min-height: 44px; padding: 0 4px; border: none; background: transparent; color: var(--muted); font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; width: 100%; }
.cart-toggle[aria-expanded="true"] svg { transform: rotate(180deg); }

/* --- Bandeaux, toast, feuilles --- */
.banner-zone { padding: 0 20px; display: flex; flex-direction: column; gap: 8px; }
.banner-zone:not(:empty) { margin-bottom: 12px; }
.banner { padding: 12px 14px; border-radius: 12px; background: var(--err-bg); color: var(--err-fg); font-size: 15px; display: flex; flex-direction: column; gap: 8px; }
.banner ul { margin: 0; padding-left: 18px; }
.banner button { align-self: flex-start; min-height: 40px; border: none; background: transparent; color: inherit; text-decoration: underline; padding: 0; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(92px + env(safe-area-inset-bottom)); width: min(520px, calc(100% - 40px)); padding: 14px 16px; border-radius: 12px; background: var(--toast-bg); color: var(--toast-fg); font-size: 15px; z-index: 30; }
dialog.sheet { border: none; padding: 0; margin: auto auto 0; width: 100%; max-width: 560px; background: var(--surface); color: var(--ink); border-radius: 20px 20px 0 0; }
dialog.sheet::backdrop { background: var(--overlay); }
.sheet-body { padding: 20px 20px calc(28px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 14px; }
.sheet-body h2 { margin: 0; font-size: 21px; }
.sheet-body p { margin: 0; color: var(--body); line-height: 1.45; }
.two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.choice-list { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; max-height: 50vh; overflow-y: auto; }
.choice-list button { min-height: 48px; padding: 0 14px; border: none; border-top: 1px solid var(--row-line); background: transparent; text-align: left; font-size: 16px; display: flex; align-items: center; justify-content: space-between; }
.choice-list button:first-child { border-top: none; }
.choice-list button[aria-checked="true"] { font-weight: 700; color: var(--accent-text); }

/* --- Navigation basse --- */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; background: var(--nav); border-top: 1px solid var(--line); padding: 8px 8px calc(12px + env(safe-area-inset-bottom)); z-index: 20; }
.tabbar-inner { max-width: 560px; margin: 0 auto; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); }
.tab { min-height: 56px; color: var(--muted); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: 12px; text-decoration: none; }
.tab[aria-current="page"] { color: var(--accent-text); font-weight: 700; }

/* --- Connexion --- */
.login { max-width: 420px; margin: 0 auto; min-height: 100%; padding: 40px 28px; display: flex; flex-direction: column; justify-content: center; gap: 16px; }
.brand { display: flex; flex-direction: column; align-items: center; gap: 12px; padding-bottom: 20px; }
.brand-mark { width: 72px; height: 72px; border-radius: 22px; background: var(--accent); color: var(--on-accent); display: flex; align-items: center; justify-content: center; }
.brand h1 { font-size: 32px; }
.check-line { display: flex; align-items: center; gap: 12px; min-height: 44px; font-size: 16px; cursor: pointer; }
.check-line input { width: 22px; height: 22px; margin: 0; accent-color: var(--accent); }
.alert { padding: 12px 14px; border-radius: 12px; background: var(--err-bg); color: var(--err-fg); font-size: 15px; }
.link-btn { min-height: 44px; border: none; background: transparent; color: var(--accent-text); text-decoration: underline; font-size: 15px; }

/* --- Profil --- */
.section-title { margin: 0; padding: 0 4px; font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.radio-row { width: 100%; display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 8px 14px; border: none; border-top: 1px solid var(--row-line); background: transparent; text-align: left; }
.radio-row:first-child { border-top: none; }
.radio-dot { width: 22px; height: 22px; border-radius: 999px; border: 2px solid var(--input-border); flex: none; }
.radio-row[aria-checked="true"] .radio-dot { border-color: var(--accent); background: var(--accent); box-shadow: inset 0 0 0 4px var(--surface); }
.hint { display: block; font-size: 13px; color: var(--muted); }

.stack { display: flex; flex-direction: column; gap: 14px; }
.badge { align-self: flex-start; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: var(--ink); color: var(--bg); }
.tag { flex: none; font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 999px; background: var(--track); color: var(--body); }
.member { width: 100%; display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 8px 14px; border: none; border-top: 1px solid var(--row-line); background: transparent; text-align: left; color: var(--ink); }
.member:first-child { border-top: none; }
.member .grow, .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.temp-password { padding: 16px; border-radius: 12px; background: var(--track); font-size: 22px; font-weight: 700; text-align: center; letter-spacing: 0.04em; font-family: ui-monospace, Consolas, monospace; user-select: all; }
.event { display: flex; gap: 12px; padding: 12px 14px; border-top: 1px solid var(--row-line); }
.event:first-child { border-top: none; }
.event-dot { width: 8px; height: 8px; margin-top: 7px; border-radius: 999px; background: var(--faint); flex: none; }
.event-dot.security { background: var(--danger); }
.cap-row { display: flex; align-items: center; gap: 10px; min-height: 64px; padding: 8px 10px 8px 14px; border-top: 1px solid var(--row-line); }
.cap-row:first-child { border-top: none; }
.cap-state { font-size: 12px; font-weight: 700; color: var(--muted); }
.cap-state.exception { color: var(--p-blue-fg); }
.tri { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 2px; padding: 2px; border-radius: 10px; background: var(--track); flex: none; width: 156px; }
.tri button { min-height: 40px; border: none; border-radius: 8px; background: transparent; color: var(--muted); font-size: 13px; }
.tri button[aria-pressed="true"] { background: var(--seg-on); color: var(--ink); font-weight: 700; box-shadow: var(--seg-shadow); }
.savebar { position: fixed; left: 0; right: 0; bottom: calc(80px + env(safe-area-inset-bottom)); z-index: 25; padding: 0 12px; }
.savebar-inner { max-width: 536px; margin: 0 auto; display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); box-shadow: 0 4px 16px rgba(0,0,0,0.12); }
.warn { padding: 12px 14px; border-radius: 12px; background: var(--off-bg); color: var(--off-fg); font-size: 15px; line-height: 1.4; }

/* --- Repas --- */
.period { font-size: 17px; font-weight: 700; text-align: center; flex: 1; }
.proposal-banner { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--p-blue-bg); color: var(--ink); text-align: left; width: 100%; }
.stack-avatars { display: flex; }
.stack-avatars .avatar + .avatar { margin-left: -8px; }
.day-title { margin: 0; padding: 0 4px; font-size: 14px; font-weight: 700; color: var(--muted); }
.day-title.today { color: var(--accent-text); }
.slot { display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 8px 14px; border-top: 1px solid var(--row-line); color: var(--ink); text-decoration: none; }
.slot:first-child { border-top: none; }
.slot-name { width: 70px; flex: none; font-size: 13px; color: var(--muted); }
.state-pill { align-self: flex-start; display: inline-block; font-size: 14px; font-weight: 700; padding: 4px 10px; border-radius: 999px; background: var(--track); color: var(--body); }
.state-pill.todo { background: var(--off-bg); color: var(--off-fg); }
.small { font-size: 13px; }
.month { padding: 12px; }
.month-head, .month-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; text-align: center; }
.month-head { font-size: 12px; color: var(--muted); padding-bottom: 6px; }
.day-cell { min-height: 48px; border: none; border-radius: 10px; background: transparent; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 14px; color: var(--ink); }
.day-cell.today { background: var(--p-green-bg); font-weight: 700; }
.dots { display: flex; gap: 3px; height: 6px; }
.dot-meal { display: inline-block; width: 6px; height: 6px; border-radius: 999px; background: var(--accent-text); }
.dot-meal.special { background: transparent; border: 1px solid var(--muted); }
.legend { display: flex; gap: 14px; padding-top: 10px; font-size: 12px; color: var(--muted); }
.legend > span { display: inline-flex; align-items: center; gap: 5px; }
.proposal { padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.tag.wait { background: var(--off-bg); color: var(--off-fg); }
.allergy { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: 14px; background: var(--err-bg); color: var(--err-fg); font-size: 15px; line-height: 1.4; }
.comp { display: flex; flex-direction: column; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--row-line); }
.comp:first-child { border-top: none; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-tag { font-size: 13px; padding: 3px 9px; border-radius: 999px; background: var(--track); color: var(--body); }
.chip-toggle { min-height: 36px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--input-border); background: var(--surface); color: var(--body); font-size: 13px; }
.chip-toggle[aria-pressed="true"] { border-color: var(--accent-text); background: var(--p-green-bg); color: var(--p-green-fg); font-weight: 700; }
.person { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px 0 8px; border-radius: 999px; border: 1px solid var(--input-border); background: var(--surface); color: var(--ink); font-size: 15px; opacity: 0.75; }
.person[aria-pressed="true"] { border-color: var(--accent-text); background: var(--p-green-bg); font-weight: 700; opacity: 1; }
.step-value { width: 32px; text-align: center; font-size: 17px; font-weight: 700; }

/* --- Produits --- */
.product-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.product-card { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--ink); text-decoration: none; overflow: hidden; }
.product-photo { width: 100%; height: 112px; object-fit: cover; display: block; background: var(--track); }
.empty-photo { display: flex; align-items: center; justify-content: center; color: var(--muted); background: var(--track); }
.product-text { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px 12px; }
.product-hero { width: 100%; height: 220px; object-fit: cover; border-radius: 16px; display: block; background: var(--track); }
.details { margin: 0; }
.variants > summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; color: var(--muted); font-weight: 600; }
.variants > .field { margin-top: 8px; }
.detail { display: flex; flex-direction: column; gap: 3px; padding: 12px 14px; border-top: 1px solid var(--row-line); }
.detail:first-child { border-top: none; }
.detail dd { margin: 0; }
label.btn { cursor: pointer; }

.textarea { height: auto; min-height: 64px; padding: 10px 14px; resize: vertical; font: inherit; }
.avatar[role="radio"] { width: 40px; height: 40px; border: 2px solid transparent; }
.avatar[role="radio"][aria-checked="true"] { border-color: var(--ink); }

.link-btn.left { align-self: flex-start; padding: 0 4px; min-height: 36px; }
