/* Web app de saisie — papier et encre, comme l'écran. */
:root {
  --paper: #f6f5f1;
  --card: #ffffff;
  --ink: #161615;
  --muted: #5d5c57;
  --line: #dddbd3;
  --soft: #eeede7;
  --hot: #161615;
  --danger: #a3271b;
  --on-ink: #ffffff;
  --radius: 14px;
  --serif: 'EB Garamond', Georgia, serif;
  --sans: system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #161615;
    --card: #20201e;
    --ink: #f2f0e9;
    --muted: #a9a79f;
    --line: #36352f;
    --soft: #2a2a27;
    --hot: #f2f0e9;
    --danger: #ff8a7a;
    --on-ink: #161615;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 17px/1.4 var(--sans);
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
a { color: inherit; }
h1, h2, p { margin: 0; }
.shell { max-width: 640px; margin: 0 auto; padding: calc(12px + env(safe-area-inset-top)) 16px 24px; }

/* En-tête */
.top { padding: 12px 2px 14px; }
.top h1 { font: italic 600 34px/1.05 var(--serif); letter-spacing: -0.01em; }
.sub { color: var(--muted); font-size: 15px; margin-top: 4px; }
.sub a { text-decoration: none; }

/* Blocs */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.card h2 { font: 600 19px/1.2 var(--serif); }
.stack { display: flex; flex-direction: column; gap: 12px; }
main > * + * { margin-top: 12px; }
.row { display: flex; gap: 10px; align-items: flex-end; }
.row > .field { flex: 1 1 0; min-width: 0; }
.grow { flex: 1 1 auto; }
.center { text-align: center; }
.muted { color: var(--muted); font-size: 15px; }
.empty { color: var(--muted); text-align: center; padding: 24px 0; font-style: italic; font-family: var(--serif); font-size: 19px; }
.tag { font: 600 12px/1 var(--sans); letter-spacing: 0.06em; text-transform: uppercase; background: var(--ink); color: var(--on-ink); padding: 3px 7px; border-radius: 999px; vertical-align: 3px; margin-left: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
code { font-size: 15px; background: var(--soft); padding: 4px 8px; border-radius: 6px; word-break: break-all; }

/* Champs */
.field { display: flex; flex-direction: column; gap: 5px; }
label, .label, legend { font-size: 14px; font-weight: 600; color: var(--muted); }
input, select {
  font: inherit; font-size: 17px; color: var(--ink);
  background: var(--paper); border: 1px solid var(--line); border-radius: 10px;
  min-height: 46px; padding: 10px 12px; width: 100%;
}
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
input::placeholder { color: var(--muted); opacity: 0.7; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
legend { padding: 0; margin-bottom: 6px; }
.narrow { max-width: 96px; }

/* Boutons */
.btn {
  font: inherit; font-weight: 600; font-size: 16px; min-height: 46px; padding: 0 18px;
  border-radius: 10px; border: 1px solid var(--ink); background: transparent; color: var(--ink); cursor: pointer;
}
.btn.primary { background: var(--ink); color: var(--on-ink); }
.btn.small { min-height: 44px; padding: 0 14px; font-size: 15px; }
.btn:disabled { opacity: 0.4; cursor: default; }
.icon-btn {
  display: inline-grid; place-items: center; width: 44px; height: 44px; flex: none;
  border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--ink); cursor: pointer;
}
.icon-btn svg, .tabs svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.link-btn { font: inherit; font-weight: 600; background: none; border: 0; padding: 10px; color: inherit; text-decoration: underline; cursor: pointer; min-height: 44px; }
.danger { color: var(--danger); }
.danger-zone { margin-top: 28px; }

/* Puces de choix (radio) */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips legend { width: 100%; }
.chips label { position: relative; color: var(--ink); font-weight: 500; font-size: 15px; }
.chips input { position: absolute; opacity: 0; width: 1px; height: 1px; min-height: 0; }
.chips span { display: inline-flex; align-items: center; min-height: 44px; padding: 0 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--paper); cursor: pointer; }
.chips input:checked + span { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }
.chips input:focus-visible + span { outline: 2px solid var(--ink); outline-offset: 2px; }
.checks { display: flex; flex-direction: column; gap: 4px; }
.checks label { display: flex; align-items: center; gap: 10px; min-height: 44px; color: var(--ink); font-weight: 500; font-size: 16px; }
.checks input { width: 22px; height: 22px; min-height: 0; accent-color: var(--ink); }

/* Quantité − 1 + */
.stepper { display: flex; gap: 6px; }
.stepper input { text-align: center; min-width: 0; }

details > summary { cursor: pointer; color: var(--muted); font-size: 14px; font-weight: 600; min-height: 32px; display: flex; align-items: center; }
details[open] > summary { margin-bottom: 6px; }

/* Repas */
.weeknav { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.weeknav-label { display: flex; flex-direction: column; align-items: center; text-align: center; }
.weeknav-label strong { font: 600 13px/1.2 var(--sans); letter-spacing: 0.1em; text-transform: uppercase; }
.weeknav-label span { font: italic 500 21px/1.2 var(--serif); }
.day { display: flex; flex-direction: column; gap: 8px; }
.day.is-today { border: 2px solid var(--ink); }
.day.is-past { opacity: 0.62; }
.meal { display: grid; grid-template-columns: 52px minmax(0, 1fr); column-gap: 10px; align-items: center; }
.meal > label { color: var(--muted); }
.meal .note { grid-column: 2; margin-top: -2px; }
.meal .note summary { font-weight: 500; font-size: 13px; min-height: 26px; }
.meal .note input { min-height: 40px; font-size: 16px; }
.savebar { display: flex; align-items: center; justify-content: flex-end; gap: 12px; padding: 8px 0; }
.savebar.sticky { position: sticky; bottom: calc(60px + env(safe-area-inset-bottom)); background: var(--paper); margin: 0 -16px; padding: 8px 16px; }
form.autosaving .savebar.sticky { position: static; background: none; }
.save-state { color: var(--muted); font-size: 15px; }
form.autosaving [data-save-button] { display: none; }

/* Listes restes / congélo */
.items { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.item { display: flex; align-items: center; gap: 10px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 8px 8px 14px; }
.item.is-hot { border: 2px solid var(--hot); }
.item.is-hot .item-name { font-weight: 700; }
.item-main { flex: 1 1 auto; min-width: 0; text-decoration: none; display: flex; flex-direction: column; padding: 4px 0; }
.item-name { font-size: 17px; font-weight: 600; overflow-wrap: anywhere; }
.qty { font-weight: 500; color: var(--muted); }
.item-meta { font-size: 14px; color: var(--muted); }
.item-actions { display: flex; gap: 6px; flex: none; }
.item-actions form { margin: 0; }

/* Écrans */
.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 16px; margin: 10px 0 0; }
.facts div { min-width: 0; }
.facts dt { font-size: 13px; color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.manual { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.screen { display: flex; flex-direction: column; gap: 12px; }
.preview { margin: 0; display: flex; justify-content: center; }
.preview img { width: 100%; max-width: 480px; height: auto; aspect-ratio: 480 / 800; border: 1px solid var(--line); border-radius: 6px; background: var(--soft); box-shadow: 0 1px 0 var(--line); }
.show-form select { width: auto; flex: none; }
.links { font-size: 14px; color: var(--muted); }

/* Bandeau de confirmation */
.flash { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--ink); color: var(--on-ink); border-radius: var(--radius); padding: 6px 8px 6px 16px; margin-bottom: 12px; min-height: 52px; }
.flash form { margin: 0; }
.error { color: var(--danger); font-weight: 600; }
.login { margin-top: 24px; }

/* Barre d'onglets */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; justify-content: center;
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs a {
  flex: 1 1 0; max-width: 128px; min-height: 60px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  text-decoration: none; color: var(--muted); font-size: 12px; font-weight: 600;
}
.tabs a[aria-current="page"] { color: var(--ink); }
.tabs a[aria-current="page"] svg { stroke-width: 2.3; }
