:root {
  --paper: #EEF2EA;
  --card: #FFFFFF;
  --ink: #1B2420;
  --muted: #5B675F;
  --line: #D3DBCF;
  --chicon: #E4EDB8;
  --bottle: #24503F;
  --bottle-2: #2F6650;
  --moutarde: #E5A823;
  --tomate: #C23B26;
  --receipt: #FFFFFF;
  --display: 'Bricolage Grotesque', 'Segoe UI', system-ui, sans-serif;
  --body: 'Atkinson Hyperlegible', 'Segoe UI', system-ui, sans-serif;
  --ticket: 'Courier Prime', 'Courier New', monospace;
  --r-s: 8px;
  --r-m: 14px;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #141A17; --card: #1D2521; --ink: #E8EEE6; --muted: #A3B0A7; --line: #2F3A34;
    --chicon: #3A4426; --bottle: #8CC7A8; --bottle-2: #A6D8BC; --receipt: #F7F7F2;
  }
}
:root[data-theme="dark"] {
  --paper: #141A17; --card: #1D2521; --ink: #E8EEE6; --muted: #A3B0A7; --line: #2F3A34;
  --chicon: #3A4426; --bottle: #8CC7A8; --bottle-2: #A6D8BC; --receipt: #F7F7F2;
}
*, *::before, *::after { box-sizing: inherit; }
html { scroll-padding-top: env(safe-area-inset-top, 0px); }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 17px/1.55 var(--body); -webkit-font-smoothing: antialiased;
  padding-bottom: 84px;
}
h1, h2, h3 { font-family: var(--display); line-height: 1.15; margin: 0 0 .4em; }
h1 { font-size: clamp(1.8rem, 6vw, 2.4rem); font-weight: 800; letter-spacing: -.02em; }
h2 { font-size: 1.35rem; font-weight: 800; letter-spacing: -.01em; }
h3 { font-size: 1.08rem; font-weight: 600; }
p { margin: 0 0 .8em; }
a { color: var(--bottle); }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--moutarde); outline-offset: 2px; }
img { max-width: 100%; }

.top {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5;
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 14px 20px 10px; background: var(--paper);
}
.brand { font: 800 1.5rem var(--display); color: var(--bottle); text-decoration: none; letter-spacing: -.03em; }
.top-store { font-size: .9rem; color: var(--muted); }

main { max-width: 640px; margin: 0 auto; padding: 4px 20px 24px; }
main:focus { outline: none; }
.loading, .empty { color: var(--muted); padding: 40px 0; text-align: center; }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.tabs a {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 9px 4px 10px; font-size: .78rem; color: var(--muted); text-decoration: none;
}
.tabs svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabs a[aria-current="page"] { color: var(--bottle); font-weight: 700; }
.tabs.hidden { display: none; }

/* ---------- boutons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 20px; border-radius: 999px; border: 0; cursor: pointer;
  background: var(--bottle); color: #fff; font-weight: 700; text-decoration: none;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn { color: #10201A; } }
.btn.ghost { background: transparent; color: var(--bottle); box-shadow: inset 0 0 0 2px var(--bottle); }
.btn.small { min-height: 38px; padding: 0 14px; font-size: .92rem; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .45; cursor: default; }
.link { background: none; border: 0; padding: 4px 0; color: var(--bottle); font-weight: 700; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

/* ---------- ticket de caisse ---------- */
.ticket {
  position: relative; margin: 8px 0 28px; padding: 22px 20px 30px;
  background: var(--receipt); color: #1F1F1F; font: 15px/1.5 var(--ticket);
  box-shadow: 0 1px 0 var(--line);
  -webkit-mask: conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) 50% / 16px 100%;
          mask: conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) 50% / 16px 100%;
}
.ticket-head { text-align: center; margin-bottom: 10px; }
.ticket-head strong { display: block; font-size: 1.15rem; letter-spacing: .08em; }
.ticket-row { display: flex; gap: 10px; }
.ticket-row .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ticket-row .day { flex: 0 0 3.2ch; }
.ticket hr { border: 0; border-top: 2px dashed #9A9A9A; margin: 10px 0; }
.ticket .total { font-weight: 700; font-size: 1.25rem; }
.ticket .over { color: #B3261E; }
.ticket .ok { color: #1F5E44; }
.ticket-note { font-size: .82rem; color: #666; text-align: center; margin-top: 10px; }

/* ---------- jauge budget ---------- */
.gauge { margin: -8px 0 26px; }
.gauge-bar { height: 12px; border-radius: 999px; background: var(--line); overflow: hidden; display: flex; }
.gauge-bar i { display: block; height: 100%; }
.gauge-bar .g-cons { background: var(--bottle); }
.gauge-bar .g-waste { background: var(--moutarde); }
.gauge-bar .g-over { background: var(--tomate); }
.gauge-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 8px; font-size: .88rem; color: var(--muted); }
.gauge-legend b { color: var(--ink); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: 0; }

/* ---------- jours ---------- */
.days { list-style: none; padding: 0; margin: 0 0 28px; }
.day-item { display: grid; grid-template-columns: 3.2rem 1fr auto; gap: 4px 12px; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--line); }
.day-item:first-child { border-top: 1px solid var(--line); }
.day-name { font: 800 1rem var(--display); color: var(--bottle); }
.day-title { background: none; border: 0; padding: 0; text-align: left; font-weight: 700; cursor: pointer; line-height: 1.3; }
.day-meta { grid-column: 2; font-size: .88rem; color: var(--muted); }
.day-actions { grid-row: 1 / span 2; grid-column: 3; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.day-price { font: 700 1rem var(--ticket); }

.section { margin: 0 0 30px; }
.section-intro { color: var(--muted); font-size: .95rem; }

/* ---------- comparaison enseignes ---------- */
.compare { list-style: none; padding: 0; margin: 0; }
.compare li { display: grid; grid-template-columns: 7.5rem 1fr 4.5rem; gap: 10px; align-items: center; padding: 6px 0; font-size: .95rem; }
.compare .bar { height: 14px; border-radius: 4px; background: var(--bottle-2); min-width: 4px; }
.compare li.current { font-weight: 700; }
.compare li.current .bar { background: var(--moutarde); }
.compare .val { font-family: var(--ticket); text-align: right; }
.compare .cov { grid-column: 2 / span 2; font-size: .8rem; color: var(--muted); margin-top: -4px; }

.lesson { background: var(--chicon); border-radius: var(--r-m); padding: 16px 18px; margin: 0 0 30px; }
.lesson h3 { margin-bottom: .3em; }
.lesson p:last-child { margin: 0; }

.banner { border-left: 4px solid var(--moutarde); background: var(--card); padding: 12px 14px; border-radius: 0 var(--r-s) var(--r-s) 0; margin: 0 0 20px; font-size: .95rem; }

/* ---------- courses ---------- */
.aisle { margin: 0 0 22px; }
.aisle h3 { color: var(--bottle); }
.shop { list-style: none; padding: 0; margin: 0; background: var(--card); border-radius: var(--r-m); }
.shop li { display: grid; grid-template-columns: 28px 1fr auto; gap: 2px 12px; align-items: start; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.shop li:last-child { border-bottom: 0; }
.shop input { width: 22px; height: 22px; margin-top: 2px; accent-color: var(--bottle); }
.shop .what { font-weight: 700; }
.shop .how { grid-column: 2 / span 2; font-size: .86rem; color: var(--muted); }
.shop .cost { font-family: var(--ticket); font-weight: 700; }
.shop li.done .what { text-decoration: line-through; color: var(--muted); }
.tag { display: inline-block; font-size: .74rem; font-weight: 700; padding: 1px 7px; border-radius: 999px; background: var(--chicon); color: var(--ink); margin-left: 6px; vertical-align: 1px; }
.tag.warn { background: #F6D9A8; color: #5A3A00; }
.tag.none { background: #F2C9C1; color: #6B1608; }

/* ---------- recettes ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 18px; }
.chip { border: 0; border-radius: 999px; padding: 7px 14px; background: var(--card); box-shadow: inset 0 0 0 1px var(--line); cursor: pointer; font-size: .92rem; }
.chip[aria-pressed="true"] { background: var(--bottle); color: #fff; box-shadow: none; }
.rlist { list-style: none; padding: 0; margin: 0; }
.rlist li { border-bottom: 1px solid var(--line); }
.rlist button { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; width: 100%; background: none; border: 0; padding: 14px 0; text-align: left; cursor: pointer; }
.rlist .t { font-weight: 700; }
.rlist .m { font-size: .86rem; color: var(--muted); }
.rlist .p { grid-row: 1 / span 2; grid-column: 2; align-self: center; font: 700 1rem var(--ticket); }

/* ---------- fiche recette ---------- */
.sheet {
  width: min(640px, 100vw); max-width: 100vw; max-height: 92vh; margin: auto auto 0; padding: 0;
  border: 0; border-radius: 20px 20px 0 0; background: var(--paper); color: var(--ink);
}
.sheet::backdrop { background: rgba(10, 20, 15, .55); }
.sheet-inner { padding: 22px 20px calc(28px + env(safe-area-inset-bottom, 0px)); }
.sheet-close { position: sticky; top: 0; float: right; margin: -6px -6px 0 0; width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--card); font-size: 1.4rem; cursor: pointer; }
.facts { display: flex; flex-wrap: wrap; gap: 6px 18px; color: var(--muted); font-size: .92rem; margin-bottom: 16px; }
.facts b { color: var(--ink); }
.split { display: flex; height: 22px; border-radius: 6px; overflow: hidden; margin: 6px 0 8px; }
.split i { display: block; height: 100%; }
.split-legend { list-style: none; padding: 0; margin: 0 0 20px; font-size: .9rem; }
.split-legend li { display: flex; justify-content: space-between; padding: 3px 0; }
.ing { list-style: none; padding: 0; margin: 0 0 22px; background: var(--card); border-radius: var(--r-m); }
.ing li { display: flex; justify-content: space-between; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.ing li:last-child { border-bottom: 0; }
.ing .q { color: var(--muted); }
.steps { padding-left: 1.4em; margin: 0 0 22px; }
.steps li { margin-bottom: .7em; padding-left: .3em; }
.steps li::marker { font: 800 1rem var(--display); color: var(--bottle); }

/* ---------- formulaires ---------- */
.field { margin: 0 0 22px; }
.field > label, .field > .label { display: block; font-weight: 700; margin-bottom: 6px; }
.hint { font-size: .88rem; color: var(--muted); margin: -2px 0 8px; }
.stepper { display: inline-flex; align-items: center; gap: 4px; background: var(--card); border-radius: 999px; padding: 4px; }
.stepper button { width: 42px; height: 42px; border-radius: 50%; border: 0; background: var(--paper); font-size: 1.3rem; cursor: pointer; }
.stepper output { min-width: 2.4ch; text-align: center; font: 700 1.2rem var(--display); }
.row { display: flex; flex-wrap: wrap; gap: 18px 28px; }
input[type="range"] { width: 100%; accent-color: var(--bottle); height: 32px; }
.budget-out { font: 800 2.4rem var(--display); color: var(--bottle); letter-spacing: -.02em; }
.budget-out small { font: 400 1rem var(--body); color: var(--muted); }
.options { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.opt { position: relative; }
.opt input { position: absolute; opacity: 0; inset: 0; }
.opt span { display: block; padding: 12px 14px; border-radius: var(--r-s); background: var(--card); box-shadow: inset 0 0 0 1px var(--line); cursor: pointer; font-weight: 700; }
.opt small { display: block; font-weight: 400; color: var(--muted); font-size: .82rem; }
.opt input:checked + span { box-shadow: inset 0 0 0 2px var(--bottle); background: var(--chicon); }
.opt input:focus-visible + span { outline: 3px solid var(--moutarde); outline-offset: 2px; }
.text-input { width: 100%; min-height: 46px; padding: 0 14px; border-radius: var(--r-s); border: 1px solid var(--line); background: var(--card); }

.onb-progress { display: flex; gap: 6px; margin: 4px 0 22px; }
.onb-progress i { flex: 1; height: 4px; border-radius: 4px; background: var(--line); }
.onb-progress i.on { background: var(--bottle); }
.onb-nav { display: flex; justify-content: space-between; gap: 12px; margin-top: 10px; }

/* ---------- admin ---------- */
.log { font: 13px/1.5 var(--ticket); background: var(--card); border-radius: var(--r-s); padding: 10px 12px; max-height: 240px; overflow: auto; white-space: pre-wrap; }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: .92rem; }
th, td { text-align: left; padding: 8px 8px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 700; }
td.num, th.num { text-align: right; font-family: var(--ticket); }

@media (min-width: 720px) {
  body { padding-bottom: 0; padding-left: 96px; }
  .tabs { top: 0; right: auto; width: 96px; grid-template-columns: 1fr; grid-auto-rows: min-content; padding-top: 80px; border-top: 0; border-right: 1px solid var(--line); }
  .top { padding-left: 24px; }
}
@media (prefers-reduced-motion: no-preference) {
  .ticket.print { animation: print .7s cubic-bezier(.2,.8,.2,1) both; transform-origin: top; }
  @keyframes print { from { clip-path: inset(0 0 100% 0); } to { clip-path: inset(0 0 0 0); } }
}
