/* PetitChef : feuille de style unique, mobile d'abord.
   Chaque couleur est définie une seule fois pour les deux thèmes avec
   light-dark() ; color-scheme choisit la valeur : selon l'appareil par défaut,
   forcée par l'attribut data-theme posé côté serveur (aucun flash). */

:root {
  color-scheme: light dark;
  --bg: light-dark(#f6f5f1, #121412);
  --surface: light-dark(#ffffff, #1b1e1b);
  --hover: light-dark(#ecebe5, #272b27);
  --text: light-dark(#1c1f1b, #e8ebe6);
  --muted: light-dark(#575d55, #a9b0a6);
  --border: light-dark(#dedcd3, #30352f);
  --input-bg: light-dark(#ffffff, #141714);
  --input-border: light-dark(#7d8279, #767d74);
  --primary: light-dark(#1f6b45, #7fd3a3);
  --primary-hover: light-dark(#175536, #9fe2bb);
  --on-primary: light-dark(#ffffff, #0b2416);
  --link: light-dark(#1d6542, #86d9aa);
  --focus: light-dark(#1f6b45, #7fd3a3);
  --danger-bg: light-dark(#fdeceb, #3b1816);
  --danger-border: light-dark(#f2b8b3, #7a2a24);
  --danger-text: light-dark(#8c1d13, #ffb4ab);
  --danger: light-dark(#b3261e, #ffb4ab);
  --on-danger: light-dark(#ffffff, #3b0d09);
  --ok-bg: light-dark(#e8f5ec, #12301d);
  --ok-border: light-dark(#a6dcb5, #2c6b41);
  --ok-text: light-dark(#14532d, #a7f0ba);
  --positive: light-dark(#17703f, #6fdc8c);
  --warning-bg: light-dark(#fff4d6, #3a2c05);
  --warning-text: light-dark(#7a4f00, #ffd27a);
  --warning: light-dark(#b07400, #e6b545);

  --tap: 44px;
  --topbar-h: 56px;
  --tabbar-h: 60px;
  --radius: 12px;
  --content-max: 72rem;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 1rem/1.5 var(--font);
  overflow-wrap: anywhere;
}

h1 { margin: 0 0 1rem; font-size: 1.5rem; line-height: 1.25; }
h2 { margin: 0 0 .5rem; font-size: 1.125rem; line-height: 1.3; }
p { margin: 0 0 .75rem; }
p:last-child { margin-bottom: 0; }
a { color: var(--link); }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  top: -100px;
  left: .5rem;
  z-index: 20;
  padding: .75rem 1rem;
  background: var(--primary);
  color: var(--on-primary);
  border-radius: 8px;
}
.skip-link:focus { top: .5rem; }

.muted { color: var(--muted); }

/* En-tête */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  min-height: var(--topbar-h);
  padding: env(safe-area-inset-top) .75rem 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  min-height: var(--tap);
  color: var(--text);
  font-size: 1.125rem;
  font-weight: 700;
  text-decoration: none;
}

.brand-logo { flex: none; width: 32px; height: 32px; }
/* Sur un petit écran connecté, le nom laisse la place aux actions de
   l'en-tête ; il reste lu par les lecteurs d'écran. */
@media (max-width: 399px) {
  .topbar:has(.topbar-actions) .brand span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
}
.brand-logo rect { fill: var(--primary); }
.brand-logo path {
  fill: none;
  stroke: var(--on-primary);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.topbar-actions { display: flex; align-items: center; gap: .25rem; }

.theme-switch fieldset {
  display: flex;
  margin: 0;
  padding: 1px;
  border: 1px solid var(--border);
  border-radius: 999px;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: var(--tap);
  height: var(--tap);
  padding: 0;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
}
.icon-btn:hover { color: var(--text); background: var(--hover); }
.icon-btn[aria-pressed="true"] { color: var(--on-primary); background: var(--primary); }

.icon-btn svg, .tabbar svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon-btn svg .fill { fill: currentColor; stroke: none; }

/* Cloche des alertes : le nombre à lire en pastille. */
.bell { position: relative; }
.bell[aria-current="page"] { color: var(--primary); }
.bell-count {
  position: absolute;
  top: 4px;
  right: 2px;
  min-width: 1.125rem;
  padding: 0 .25rem;
  color: var(--on-danger);
  font-size: .6875rem;
  font-weight: 700;
  line-height: 1.125rem;
  text-align: center;
  background: var(--danger);
  border-radius: 999px;
}

/* Navigation : barre d'onglets en bas sur mobile, sous l'en-tête au-delà. */

.tabbar {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 10;
  display: flex;
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.tabbar a {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: var(--tabbar-h);
  color: var(--muted);
  font-size: .75rem;
  white-space: nowrap;
  text-decoration: none;
}
.tabbar a:hover { color: var(--text); }
.tabbar .nav-secondary { display: none; }
.nav-more svg { stroke-width: 3.5; }
.tabbar a[aria-current="page"], .tabbar a.is-current-narrow { color: var(--primary); font-weight: 600; }

/* Contenu : l'espace bas laisse la place à la barre d'onglets et au bouton
   flottant sur mobile. */

.page {
  display: grid;
  align-content: start;
  gap: 1rem;
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 1rem 1rem calc(var(--tabbar-h) + 56px + 2rem + env(safe-area-inset-bottom));
}
.page > h1, .page-head h1, .section-head h2 { margin: 0; }
/* Un élément de grille ne doit pas s'élargir à la taille d'un contenu
   défilant (tableau d'aperçu) : il le contient. */
.page > * { min-width: 0; }

.page-centered {
  justify-items: center;
  padding-block: 2rem;
}

.page-head, .section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
}
.section-head { margin-bottom: .75rem; }

.total { margin: 0; color: var(--muted); }
.total strong { color: var(--text); }

.card {
  padding: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.card.empty { display: grid; justify-items: start; gap: .75rem; margin: 0; }

.auth-card { width: 100%; max-width: 26rem; }
.form-card, .danger-zone { width: 100%; max-width: 40rem; }
.danger-zone h2 { font-size: 1rem; }

/* Tuiles des soldes */

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 15rem), 1fr));
  gap: .75rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tile {
  display: grid;
  gap: .25rem;
  padding: 1rem 1.25rem;
  color: var(--text);
  text-decoration: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.tile:hover { border-color: var(--input-border); }
.tile-label { font-weight: 600; }
.tile-meta { color: var(--muted); font-size: .875rem; }
.tile-value { font-size: 1.375rem; }

/* Listes (comptes, catégories) */

.rows {
  margin: 0;
  padding: 0;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.row {
  display: flex;
  align-items: center;
  gap: .75rem;
  min-height: 3.5rem;
  padding: .25rem 1rem;
}
.row + .row { border-top: 1px solid var(--border); }
.row-child { padding-left: 2.5rem; }

.row-link, .row-body {
  display: grid;
  flex: 1;
  align-content: center;
  gap: .125rem;
  min-width: 0;
  min-height: var(--tap);
  color: var(--text);
  text-decoration: none;
}
.row-link:hover .row-title { text-decoration: underline; }
.row-title { display: flex; align-items: center; gap: .5rem; font-weight: 600; }
.row-child .row-title { font-weight: 400; }
.row-meta { color: var(--muted); font-size: .875rem; }

.dot { flex: none; width: .75rem; height: .75rem; }

/* Montants : le signe est toujours écrit, la couleur ne fait que souligner. */

.amount { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.amount.positive { color: var(--positive); }
.amount.negative { color: var(--danger-text); }

/* Formulaires : champs de 16 px minimum (pas de zoom automatique sur iOS)
   et cibles tactiles de 44 px. */

.form { display: grid; gap: 1rem; margin-top: 1rem; }
.field { display: grid; align-content: start; gap: .375rem; }
.field-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 12rem), 1fr));
  gap: 1rem;
}

label, legend { font-weight: 600; }
.optional { color: var(--muted); font-weight: 400; }

fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
legend { margin-bottom: .375rem; padding: 0; }

input, select, textarea {
  width: 100%;
  min-height: var(--tap);
  padding: .5rem .75rem;
  color: var(--text);
  font: inherit;
  font-size: 1rem;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: 8px;
}
textarea { min-height: 5rem; resize: vertical; }
input[type="color"] { width: 5rem; padding: .25rem; }
input[type="checkbox"], input[type="radio"] {
  flex: none;
  width: 1.25rem;
  height: 1.25rem;
  min-height: 0;
  margin: 0;
  accent-color: var(--primary);
}

.hint { margin: 0; color: var(--muted); font-size: .875rem; }

.check {
  display: flex;
  align-items: center;
  gap: .625rem;
  min-height: var(--tap);
  font-weight: 400;
  cursor: pointer;
}

.actions { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; }

/* Sélecteur segmenté (type d'opération, de catégorie) */

.segmented {
  display: flex;
  gap: 3px;
  padding: 3px;
  background: var(--hover);
  border-radius: 10px;
}
.segmented label { position: relative; flex: 1; }
.segmented input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}
.segmented span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  padding: .25rem;
  color: var(--muted);
  line-height: 1.2;
  text-align: center;
  border-radius: 8px;
}
.segmented input:checked + span {
  color: var(--text);
  background: var(--surface);
  box-shadow: 0 1px 3px rgb(0 0 0 / .2);
}
.segmented input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }


/* Panneaux repliables */

details > summary {
  display: flex;
  align-items: center;
  min-height: var(--tap);
  color: var(--link);
  font-weight: 600;
  cursor: pointer;
}
details.more[open] { display: grid; grid-template-columns: minmax(0, 1fr); gap: .5rem; }

.panel {
  padding: 0 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.panel[open] { padding-bottom: 1rem; }
.panel .form { margin-top: 0; }

.filters { display: grid; gap: .75rem; }
.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 11rem), 1fr));
  gap: .75rem 1rem;
  margin-bottom: 1rem;
}

/* Boutons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  padding: .5rem 1.25rem;
  color: var(--text);
  font: inherit;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  background: var(--hover);
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}
.btn:hover { background: var(--border); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { color: var(--on-primary); background: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { color: var(--on-danger); background: var(--danger); }
.btn-danger:hover { background: var(--danger-text); }
.btn-icon { flex: none; width: var(--tap); padding: 0; font-size: 1.375rem; }

/* Messages */

.alert, .flash {
  margin: 0;
  padding: .75rem 1rem;
  border-radius: 8px;
}
.alert { color: var(--danger-text); background: var(--danger-bg); border: 1px solid var(--danger-border); }
.flash { color: var(--ok-text); background: var(--ok-bg); border: 1px solid var(--ok-border); }

.badge {
  display: inline-block;
  padding: 0 .375rem;
  color: var(--text);
  font-size: .75rem;
  font-weight: 600;
  background: var(--hover);
  border-radius: 4px;
}

/* Bouton flottant « + Opération », toujours accessible */

.fab {
  position: fixed;
  right: 1rem;
  bottom: calc(var(--tabbar-h) + 1rem + env(safe-area-inset-bottom));
  z-index: 11;
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  min-height: 56px;
  padding: 0 1.25rem 0 1rem;
  color: var(--on-primary);
  font-weight: 700;
  text-decoration: none;
  background: var(--primary);
  border-radius: 16px;
  box-shadow: 0 4px 12px rgb(0 0 0 / .25);
}
.fab:hover { background: var(--primary-hover); }
.fab svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; }

.chart { display: grid; gap: .5rem; margin: 0; }
.chart figcaption { font-weight: 600; }
.chart-svg { display: block; width: 100%; height: 14rem; overflow: visible; }
.chart-area { fill: color-mix(in srgb, var(--primary) 12%, transparent); }
.chart-line { fill: none; stroke: var(--primary); stroke-width: 2; stroke-linejoin: round; }
.chart-reference { fill: none; stroke: var(--muted); stroke-width: 1.5; stroke-dasharray: 4 4; }
.chart-grid { stroke: var(--border); stroke-width: 1; }
.chart-threshold { stroke: var(--danger); stroke-width: 1.5; stroke-dasharray: 6 4; }
.chart-below { fill: var(--danger-bg); }
.chart-low { fill: var(--surface); stroke: var(--danger); stroke-width: 3; }
.chart-label {
  fill: var(--muted);
  font-size: .75rem;
  font-variant-numeric: tabular-nums;
  paint-order: stroke;
  stroke: var(--surface);
  stroke-width: 3px;
  stroke-linejoin: round;
}
.chart-x { text-anchor: middle; }

.breakdown { display: grid; margin: 0 0 .75rem; }
.breakdown div { display: flex; justify-content: space-between; gap: 1rem; padding: .375rem 0; }
.breakdown div + div { border-top: 1px solid var(--border); }
.breakdown dt { color: var(--muted); }
.breakdown dd { margin: 0; text-align: right; white-space: nowrap; }
.breakdown .breakdown-total dt, .breakdown .breakdown-total dd { color: var(--text); font-weight: 700; }
.breakdown .breakdown-total { border-top-width: 2px; }
.rows-split .row { justify-content: space-between; }

/* Indice d'équilibre : lettre et couleur (jamais la couleur seule). */
.grade {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 1.75rem;
  height: 1.75rem;
  font-weight: 800;
  border-radius: 6px;
}
.grade-A { color: #fff; background: light-dark(#1b6e3a, #2f8a52); }
.grade-B { color: #10240f; background: light-dark(#8fcf6e, #8fcf6e); }
.grade-C { color: #2b2100; background: light-dark(#f2cf45, #e9c63c); }
.grade-D { color: #fff; background: light-dark(#b85a10, #c96a1c); }
.grade-E { color: #fff; background: light-dark(#a8261d, #c23a2f); }
.grade-lg { width: 2.75rem; height: 2.75rem; font-size: 1.5rem; }

/* Pastilles : raisons d'un choix, étiquettes, filtres. */
.badges { display: flex; flex-wrap: wrap; gap: .25rem; margin: 0; padding: 0; list-style: none; }
.badges li, .tag {
  display: inline-block;
  padding: .0625rem .5rem;
  color: var(--muted);
  font-size: .8125rem;
  background: var(--hover);
  border-radius: 999px;
}
.badge-ok { color: var(--ok-text); background: var(--ok-bg); }
.badge-warn, .badges .warn { color: var(--warning-text); background: var(--warning-bg); }
.badge-danger, .badges .danger { color: var(--danger-text); background: var(--danger-bg); }

.chips { display: flex; flex-wrap: wrap; gap: .5rem; margin: 0; padding: 0; list-style: none; }
.chips a, .chips button {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  padding: 0 1rem;
  color: var(--text);
  font: inherit;
  text-decoration: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
}
.chips a:hover, .chips button:hover { border-color: var(--input-border); }
.chips a[aria-current] { color: var(--on-primary); background: var(--primary); border-color: var(--primary); }

.tabs { display: flex; gap: .25rem; overflow-x: auto; border-bottom: 1px solid var(--border); }
.tabs a {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  padding: 0 .75rem;
  color: var(--muted);
  white-space: nowrap;
  text-decoration: none;
  border-bottom: 2px solid transparent;
}
.tabs a[aria-current="page"] { color: var(--primary); font-weight: 600; border-bottom-color: var(--primary); }

/* Cartes (stock, recettes) : une colonne sur mobile, grille au-delà. */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 17rem), 1fr));
  gap: .75rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.item {
  display: grid;
  gap: .5rem;
  padding: .75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.item-head { display: flex; align-items: flex-start; justify-content: space-between; gap: .5rem; }
.item-title { font-weight: 600; color: var(--text); text-decoration: none; }
a.item-title:hover { text-decoration: underline; }
.item-meta { margin: 0; color: var(--muted); font-size: .875rem; }
.item-photo { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 8px; }

.qty { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.expiry-soon { color: var(--warning-text); font-weight: 600; }
.expiry-past { color: var(--danger-text); font-weight: 600; }

/* Gestes rapides d'une ligne de stock : formulaires d'un bouton. */
.quick { display: flex; flex-wrap: wrap; gap: .375rem; }
.quick form { display: contents; }
.quick .btn { min-width: var(--tap); padding: .25rem .75rem; font-size: .9375rem; }
.btn-small { min-height: var(--tap); padding: .25rem .75rem; font-size: .875rem; }
.btn-ghost { background: transparent; border: 1px solid var(--border); }
.inline-form { display: flex; flex-wrap: wrap; align-items: end; gap: .5rem; }
.inline-form .field { flex: 1 1 8rem; }

/* Sélecteur de produit : recherche instantanée (HTMX) dans une liste. */
.picker { position: relative; display: grid; gap: .375rem; }
.picker-results { display: grid; gap: 0; margin: 0; padding: 0; list-style: none; }
.picker-results:empty { display: none; }
.picker-results li + li { border-top: 1px solid var(--border); }
.picker-results button, .picker-results a {
  display: flex;
  justify-content: space-between;
  gap: .5rem;
  width: 100%;
  min-height: var(--tap);
  padding: .5rem .75rem;
  color: var(--text);
  font: inherit;
  text-align: left;
  text-decoration: none;
  background: var(--surface);
  border: 0;
  cursor: pointer;
}
.picker-results button:hover, .picker-results a:hover { background: var(--hover); }
.picker-box { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }

/* Tableaux de données : défilement horizontal confiné au tableau. */
.table-scroll { max-width: 100%; overflow-x: auto; }
.data { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.data th, .data td { padding: .5rem .625rem; text-align: left; vertical-align: top; border-bottom: 1px solid var(--border); }
.data thead th { color: var(--muted); font-size: .875rem; font-weight: 600; }
.data td.num, .data th.num { text-align: right; white-space: nowrap; }

.figures { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 9rem), 1fr)); gap: .75rem; margin: 0; }
.figures div { display: grid; gap: .125rem; }
.figures dt { color: var(--muted); font-size: .875rem; }
.figures dd { margin: 0; font-size: 1.25rem; font-weight: 700; }

.notice { margin: 0; padding: .75rem 1rem; color: var(--warning-text); background: var(--warning-bg); border-radius: 8px; }
.empty-state { color: var(--muted); }

/* Menu : liste par jour sur mobile, tableau semaine × créneaux au-delà. */
.week { display: grid; gap: .75rem; margin: 0; padding: 0; list-style: none; }
.day { display: grid; gap: .5rem; padding: .75rem 1rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.day.is-today { border-color: var(--primary); box-shadow: inset 4px 0 0 var(--primary); }
.day h2 { font-size: 1rem; }
.meal { display: grid; gap: .375rem; padding: .5rem 0; border-top: 1px solid var(--border); }
.meal-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .25rem .75rem; }
.meal-slot { font-weight: 700; }
.meal-off { color: var(--muted); font-style: italic; }
.dish { display: grid; gap: .25rem; padding: .5rem .625rem; background: var(--bg); border-radius: 8px; }
.dish[draggable="true"] { cursor: grab; }
.dish.is-drop { outline: 2px dashed var(--primary); }
.dish-head { display: flex; align-items: center; gap: .5rem; }
.dish-role { color: var(--muted); font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
.dish-title { flex: 1; min-width: 0; font-weight: 600; color: var(--text); text-decoration: none; }
a.dish-title:hover { text-decoration: underline; }
.dish.is-locked { box-shadow: inset 3px 0 0 var(--warning); }
.dish.is-cooked .dish-title { color: var(--muted); }
.dish-actions { display: flex; flex-wrap: wrap; gap: .25rem; }
.dish-actions form { display: contents; }
.dish-actions .btn { min-height: var(--tap); padding: .125rem .625rem; font-size: .8125rem; }
.dish-actions details { flex-basis: 100%; }
.alternatives { display: grid; gap: .25rem; margin: .25rem 0 0; padding: 0; list-style: none; }

/* Liste de courses, mode magasin : gros caractères, un geste par ligne ;
   une ligne cochée descend en bas de son rayon, barrée. */
.aisle { display: grid; gap: .25rem; }
.aisle h2 { display: flex; justify-content: space-between; gap: .5rem; margin: .5rem 0 .25rem; font-size: 1rem; }
.shop { display: flex; flex-direction: column; margin: 0; padding: 0; list-style: none; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.shop-line { display: flex; align-items: center; gap: .5rem; min-height: 3.5rem; padding: .25rem .5rem .25rem .25rem; border-top: 1px solid var(--border); }
.shop-line:first-child { border-top: 0; }
.shop-line.is-checked { order: 1; }
.shop-line.is-checked .shop-name { color: var(--muted); text-decoration: line-through; }
.shop-toggle { display: contents; }
.shop-check {
  display: flex;
  flex: 1;
  align-items: center;
  gap: .75rem;
  min-width: 0;
  min-height: 3.25rem;
  padding: .25rem .5rem;
  color: var(--text);
  font: inherit;
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}
.shop-check:hover { background: var(--hover); }
.shop-box {
  display: grid;
  flex: none;
  place-items: center;
  width: 1.75rem;
  height: 1.75rem;
  border: 2px solid var(--input-border);
  border-radius: 6px;
}
.is-checked .shop-box { color: var(--on-primary); background: var(--primary); border-color: var(--primary); }
.shop-box svg { width: 1.125rem; height: 1.125rem; fill: none; stroke: currentColor; stroke-width: 3; visibility: hidden; }
.is-checked .shop-box svg { visibility: visible; }
.shop-text { display: grid; min-width: 0; }
.shop-name { font-size: 1.0625rem; font-weight: 600; }
.shop-detail { color: var(--muted); font-size: .8125rem; }
.shop-qty { margin-left: auto; font-weight: 700; white-space: nowrap; }
.store-mode .shop-name { font-size: 1.25rem; }
.store-mode .shop-line { min-height: 4rem; }
.offline-banner { display: none; }
.is-offline .offline-banner { display: block; }

/* Mode cuisine : plein écran, gros caractères. */
.cook { display: grid; gap: 1rem; font-size: 1.25rem; }
.cook h1 { font-size: 1.75rem; }
.cook-step { padding: 1.25rem; font-size: 1.5rem; line-height: 1.45; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.cook-nav { display: flex; gap: .75rem; }
.cook-nav .btn { flex: 1; min-height: 3.5rem; font-size: 1.125rem; }
.timers { display: flex; flex-wrap: wrap; gap: .5rem; }
.timer { font-variant-numeric: tabular-nums; }
.timer.is-done { color: var(--on-danger); background: var(--danger); }
.ingredients { display: grid; gap: .25rem; margin: 0; padding: 0; list-style: none; }
.ingredients .check { font-size: inherit; }
.ingredient-group { margin: .75rem 0 .25rem; color: var(--muted); font-size: .875rem; font-weight: 700; text-transform: uppercase; }
.steps-list { display: grid; gap: .75rem; margin: 0; padding-left: 1.5rem; }

.reasons { display: grid; gap: .25rem; margin: 0; padding: 0; list-style: none; }
.reasons li { display: flex; justify-content: space-between; gap: 1rem; padding: .25rem 0; border-bottom: 1px solid var(--border); }

.sortable { display: grid; gap: 0; margin: 0; padding: 0; list-style: none; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.sortable li { display: flex; align-items: center; gap: .5rem; min-height: 3rem; padding: .25rem .5rem .25rem 1rem; border-top: 1px solid var(--border); }
.sortable li:first-child { border-top: 0; }
.sortable li[draggable="true"] { cursor: grab; }
.sortable .grow { flex: 1; }
.sortable li.is-drop { outline: 2px dashed var(--primary); outline-offset: -2px; }

.scan-video { width: 100%; max-height: 50vh; background: #000; border-radius: var(--radius); }

@media (min-width: 768px) {
  .topbar, .tabbar { padding-inline: max(1.5rem, (100% - var(--content-max)) / 2 + 1.5rem); }
  .tabbar {
    position: static;
    gap: .25rem;
    padding-block: 0;
    border-top: 0;
    border-bottom: 1px solid var(--border);
  }
  .tabbar a {
    flex: none;
    flex-direction: row;
    gap: .5rem;
    min-height: var(--tap);
    padding: 0 .75rem;
    font-size: .9375rem;
    border-bottom: 2px solid transparent;
  }
  .tabbar a[aria-current="page"], .tabbar a.is-current-narrow { border-bottom-color: var(--primary); }
  .page { padding: 1.5rem 1.5rem calc(56px + 3rem); }
  .page-centered { padding-top: 4rem; }
  .fab { right: max(1.5rem, (100% - var(--content-max)) / 2 + 1.5rem); bottom: 1.5rem; }
  .chart-svg { height: 18rem; }
}

@media (min-width: 1024px) {
  .tabbar .nav-secondary { display: flex; }
  .tabbar .nav-more.is-current-narrow:not([aria-current]) { color: var(--muted); font-weight: 400; border-bottom-color: transparent; }
  .nav-secondary-entry { display: none; }
  /* Grille du menu : les jours en colonnes. */
  .week { grid-template-columns: repeat(7, minmax(0, 1fr)); gap: .5rem; }
  .day { padding: .5rem; align-content: start; }
  .dish { padding: .375rem .5rem; font-size: .9375rem; }
}

/* Impression : toujours en clair, sans navigation (menu pour le
   réfrigérateur, liste de courses, recette). */
@media print {
  :root, :root[data-theme="dark"] { color-scheme: light; }
  body { background: #fff; font-size: 11pt; }
  .topbar, .tabbar, .fab, .skip-link, .no-print, .dish-actions, .quick, .flash { display: none !important; }
  .page { max-width: none; padding: 0; }
  .card, .day, .item, .shop, .rows { border-color: #999; box-shadow: none; }
  .week { grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4pt; }
  .day { padding: 4pt; break-inside: avoid; }
  a { color: inherit; text-decoration: none; }
  @page { size: A4 landscape; margin: 10mm; }
}

/* Mode cuisine : gros caractères, sans navigation. */
.cooking-mode .tabbar, .cooking-mode .fab { display: none; }
.cooking-mode .page { padding-bottom: 2rem; }
.cooking-mode .ingredients { font-size: 1.125rem; }
.store-mode .fab { display: none; }
.dish-actions details > summary, .shop-line details > summary { min-height: var(--tap); padding: 0 .75rem; }
.shop-line details { flex: none; }
.grow { flex: 1; min-width: 0; }
.chart-bar { fill: var(--primary); }
.shop-line { flex-wrap: wrap; }
.shop-line details > summary { min-width: var(--tap); justify-content: center; }
.shop-line details[open] { flex-basis: 100%; padding: 0 0 .5rem 2.75rem; }

/* Plat : rôle et indice sur une ligne, titre en pleine largeur dessous. */
.dish-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: .125rem .5rem; }
.dish-head .dish-role { grid-column: 1; grid-row: 1; }
.dish-head .grade { grid-column: 2; grid-row: 1; width: 1.5rem; height: 1.5rem; font-size: .875rem; }
.dish-head .dish-title { grid-column: 1 / -1; overflow-wrap: break-word; hyphens: auto; }
.dish-actions .btn { flex: 1 1 auto; }
@media (min-width: 1280px) {
  :root { --content-max: 84rem; }
}
.week-nav { display: grid; grid-template-columns: var(--tap) minmax(0, 1fr) var(--tap); align-items: center; gap: .5rem; }
.week-nav h2 { margin: 0; font-size: 1rem; text-align: center; }
.week-nav .btn { padding: 0; }
.figures { grid-template-columns: repeat(auto-fit, minmax(min(100%, 7rem), 1fr)); }
