:root {
  --bg: #ffffff;
  --soft: #f4f8f5;
  --surface: #ffffff;
  --text: #14201a;
  --muted: #637068;
  --line: #e7ece8;
  --accent: #34d27c;
  --accent-ink: #05311a;
  --accent-strong: #0f8f4a;
  --accent-soft: #e7faef;
  --sun: #ffcf4a;
  --warn: #b25e00;
  --warn-soft: #fff4e2;
  --danger: #d93b2b;
  --shadow: 0 1px 2px rgba(20, 32, 26, .04), 0 8px 24px rgba(20, 32, 26, .06);
  --radius: 20px;
  color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { background: var(--bg); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
body.has-sheet { overflow: hidden; }
h1 { font-size: 1.75rem; line-height: 1.2; letter-spacing: -.02em; margin: 0 0 .4rem; font-weight: 800; }
h2 { font-size: 1.1rem; margin: 0 0 .6rem; font-weight: 700; letter-spacing: -.01em; }
h3 { font-size: 1rem; margin: 0; font-weight: 700; }
p { margin: .4rem 0; }
small, .small { font-size: .85rem; }
.muted { color: var(--muted); }
.center { text-align: center; justify-content: center; }
.lead { color: var(--muted); font-size: 1.05rem; margin-bottom: 1.2rem; }
.error { color: var(--danger); }
.warn { background: var(--warn-soft); color: var(--warn); border-radius: 12px; padding: .6rem .8rem; font-size: .9rem; }
.eat { color: var(--accent-strong); }
.row { display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
.gap { gap: .5rem; }
.stack { display: flex; flex-direction: column; gap: .8rem; }

main {
  max-width: 640px;
  position: relative;
  margin: 0 auto;
  padding: calc(1.25rem + env(safe-area-inset-top)) 1rem calc(6.5rem + env(safe-area-inset-bottom));
  min-height: 100vh;
}
.loading { display: grid; place-items: center; min-height: 70vh; color: var(--muted); }

/* Boutons */
button { font: inherit; color: inherit; cursor: pointer; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  border-radius: 999px; padding: .75rem 1.25rem; font-weight: 600;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 700; box-shadow: 0 6px 18px rgba(52, 210, 124, .35); }
.btn.lg { padding: .95rem 1.6rem; font-size: 1.05rem; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.small { padding: .45rem .9rem; font-size: .9rem; }
.btn.block { width: 100%; margin-top: 1rem; }
.btn:disabled { opacity: .45; cursor: default; }
.link { background: none; border: 0; color: var(--accent-strong); font-weight: 600; padding: 0; }
.icon-btn {
  display: inline-grid; place-items: center; flex: none;
  width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
}
.icon-btn.small { width: 34px; height: 34px; }
.icon { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon.inline { width: 15px; height: 15px; vertical-align: -3px; }
.actions { display: flex; flex-wrap: wrap; gap: .6rem; margin: 1.2rem 0; }

/* Champs */
input, select {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--line); border-radius: 14px; padding: .75rem .9rem; width: 100%;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.field { display: flex; flex-direction: column; gap: .3rem; font-size: .85rem; color: var(--muted); font-weight: 500; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; margin-bottom: .8rem; }
.big-input { font-size: 1.5rem; font-weight: 700; padding: 1rem 1.1rem; border-radius: 18px; }
.money { display: flex; align-items: center; gap: .6rem; font-size: 1.5rem; font-weight: 700; }
.money input { max-width: 180px; }
.search { border-radius: 999px; margin-bottom: .8rem; }

/* Puces & choix */
.chips { display: flex; flex-wrap: wrap; gap: .45rem; margin: .6rem 0; }
.chip {
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px;
  padding: .45rem .85rem; font-size: .9rem; font-weight: 500;
}
.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-strong); }
.chip.on.no { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); text-decoration: line-through; }
.choices { display: flex; flex-direction: column; gap: .6rem; margin: .6rem 0; }
.choices.grid { display: grid; grid-template-columns: 1fr 1fr; }
.choice {
  display: flex; align-items: center; gap: .8rem; text-align: left;
  border: 1.5px solid var(--line); background: var(--surface); border-radius: 18px; padding: .95rem 1rem;
}
.choice span { display: flex; flex-direction: column; flex: 1; }
.choice small { color: var(--muted); font-size: .85rem; }
.choice.on { border-color: var(--accent); background: var(--accent-soft); }
.choice-emoji { font-size: 1.6rem; flex: none !important; }
.choice .price { flex: none; font-weight: 700; }

/* Connexion */
.auth { display: flex; flex-direction: column; align-items: center; text-align: center; padding-top: 12vh; gap: .4rem; }
.auth img { border-radius: 20px; box-shadow: var(--shadow); }
.auth h1 { font-size: 2.4rem; }
.auth form { width: 100%; max-width: 360px; text-align: left; margin: 1rem 0; }

/* Démarrage guidé */
.onboarding { display: flex; flex-direction: column; min-height: calc(100vh - 3rem); }
.progress { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; margin-bottom: 1rem; }
.progress span { display: block; height: 100%; background: var(--accent); border-radius: 3px; transition: width .3s; }
.ob-body { flex: 1; padding-top: 1rem; }
.ob-footer { position: sticky; bottom: 0; padding: 1rem 0 calc(1rem + env(safe-area-inset-bottom)); background: linear-gradient(transparent, var(--bg) 30%); }
.ob-footer .btn { width: 100%; padding: 1rem; font-size: 1.05rem; }
.stepper { display: flex; align-items: center; gap: 1rem; padding: .9rem 0; border-bottom: 1px solid var(--line); font-weight: 600; }
.stepper span { flex: 1; }
.stepper b { min-width: 1.5rem; text-align: center; font-size: 1.2rem; }
.round { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); font-size: 1.3rem; }
.round:disabled { opacity: .35; }

/* Cartes */
.page-head { margin-bottom: 1rem; }
.page-head p { margin: 0; }
.page-head .date::first-letter { text-transform: uppercase; }
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--line); padding: 1.1rem; margin-bottom: 1rem; }
.card.empty { text-align: center; padding: 2rem 1rem; }
.pill { background: var(--accent-soft); color: var(--accent-strong); border-radius: 999px; padding: .2rem .65rem; font-size: .8rem; font-weight: 600; }
.budget .amount { font-size: 2.2rem; font-weight: 800; letter-spacing: -.03em; margin: .2rem 0 .5rem; }
.budget .amount small { font-size: 1rem; color: var(--muted); font-weight: 500; }
.bar { height: 10px; background: var(--line); border-radius: 5px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--accent); border-radius: 5px; }
.budget.over .bar span { background: var(--warn); }
.budget p { margin-top: .7rem; }
.health { display: grid; grid-template-columns: repeat(3, 1fr); text-align: center; cursor: pointer; }
.health b { display: block; font-size: 1.15rem; }
.health small { color: var(--muted); }
.health p { grid-column: 1 / -1; margin: .6rem 0 0; }

/* Visuels recettes */
.visual svg { width: 72%; height: 72%; }
.visual {
  display: grid; place-items: center; flex: none; object-fit: cover;
  width: 76px; height: 76px; border-radius: 16px; font-size: 2.3rem;
  background: var(--tint, var(--accent-soft));
}
.visual.small { width: 52px; height: 52px; font-size: 1.6rem; border-radius: 12px; }
.visual.tall { width: 100%; height: auto; aspect-ratio: 4 / 3; font-size: 3.5rem; border-radius: 18px; }
.visual.hero { width: 100%; height: 180px; font-size: 5rem; border-radius: 20px; margin-bottom: 1rem; }

/* Semaine */
.day h2 { text-transform: capitalize; margin: 1.4rem 0 .6rem; }
.meal-card {
  display: flex; align-items: center; gap: .9rem; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: .7rem; margin-bottom: .6rem;
}
.meal-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .1rem; }
.meal-type { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--accent-strong); }
.meta { font-size: .85rem; color: var(--muted); }

/* Courses */
.store-pick { display: grid; grid-template-columns: 1fr auto; text-align: left; width: 100%; gap: 0 .5rem; }
.store-pick .muted { grid-column: 1; }
.store-pick b { grid-column: 1; }
.store-pick .link { grid-column: 2; grid-row: 1 / 3; align-self: center; }
.aisle h2 { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 1.4rem 0 .4rem; }
.list { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.list li { display: flex; align-items: center; gap: .6rem; padding: .7rem .8rem; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.check-row { display: flex; align-items: center; gap: .75rem; flex: 1; min-width: 0; cursor: pointer; }
.check-row input { width: 22px; height: 22px; flex: none; accent-color: var(--accent); }
.item { display: flex; flex-direction: column; min-width: 0; }
.item small { color: var(--muted); }
.list li.done .item b, .list li.done .price { text-decoration: line-through; color: var(--muted); }
.price { font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* Recettes */
.recipe-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem .8rem; margin-top: .6rem; }
.recipe-card { cursor: pointer; display: flex; flex-direction: column; gap: .35rem; }
.recipe-card h3 { font-size: .95rem; line-height: 1.3; }
@media (min-width: 560px) { .recipe-grid { grid-template-columns: repeat(3, 1fr); } }

/* Profil */
.me { display: flex; align-items: center; gap: 1rem; }
.me div:last-child { display: flex; flex-direction: column; }
.avatar { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); font-weight: 800; font-size: 1.3rem; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; margin: .6rem 0; }
.stats div { background: var(--accent-soft); border-radius: 14px; padding: .6rem .3rem; text-align: center; }
.stats b { display: block; }
.stats small { color: var(--muted); font-size: .75rem; }
.settings { padding: .3rem 1.1rem; }
.settings h2 { margin: .8rem 0 .2rem; }
.setting { display: flex; justify-content: space-between; align-items: center; gap: 1rem; width: 100%; text-align: left; background: none; border: 0; border-bottom: 1px solid var(--line); padding: .9rem 0; }
.setting:last-child { border-bottom: 0; }
.setting b { font-weight: 500; color: var(--muted); text-align: right; }
.setting.danger { color: var(--danger); }
#weigh-form input { flex: 1; }
.chart { width: 100%; height: auto; margin: .5rem 0; }
.chart .proj { fill: none; stroke: var(--accent); stroke-width: 2.2; stroke-dasharray: 5 5; }
.chart .dot { fill: var(--text); }
.chart .axis { fill: var(--muted); font-size: 10px; }

/* Bottom sheet */
.backdrop { position: fixed; inset: 0; background: rgba(10, 14, 12, .45); z-index: 20; animation: fade .2s; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 21;
  max-width: 640px; margin: 0 auto; max-height: 88vh; overflow-y: auto;
  background: var(--bg); border-radius: 26px 26px 0 0;
  padding: 1.3rem 1.2rem calc(1.5rem + env(safe-area-inset-bottom));
  animation: up .25s ease-out;
}
.sheet.wide { max-width: 900px; }
.sheet-close { position: sticky; top: 0; float: right; z-index: 1; }
.ingredients { list-style: none; padding: 0; margin: .5rem 0 1rem; }
.ingredients li { display: flex; justify-content: space-between; padding: .5rem 0; border-bottom: 1px solid var(--line); }
.steps { padding-left: 1.2rem; }
.steps li { margin-bottom: .5rem; }
.sheet h3 { margin-top: 1rem; }
.swap-list { display: flex; flex-direction: column; gap: .5rem; }
.swap-item { display: flex; align-items: center; gap: .8rem; text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: .5rem; }
.swap-item span { display: flex; flex-direction: column; }
.swap-item small { color: var(--muted); }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }

/* Prix */
.scroll-x { overflow-x: auto; }
.prices { border-collapse: collapse; font-size: .85rem; min-width: 700px; width: 100%; }
.prices th, .prices td { padding: .25rem; border-bottom: 1px solid var(--line); text-align: left; }
.prices th small { display: block; color: var(--muted); font-weight: 400; }
.prices tr.cat th { background: var(--accent-soft); padding: .4rem; }
.prices input { width: 5.2rem; padding: .3rem .4rem; border-radius: 8px; text-align: right; }
.prices input.custom { border-color: var(--accent); background: var(--accent-soft); }

/* Navigation du bas */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; justify-content: space-around;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
  padding: .4rem .5rem calc(.4rem + env(safe-area-inset-bottom));
}
.bottom-nav[hidden] { display: none; }
.bottom-nav button {
  flex: 1; max-width: 120px; display: flex; flex-direction: column; align-items: center; gap: .15rem;
  background: none; border: 0; color: var(--muted); font-size: .72rem; font-weight: 600; padding: .35rem 0;
}
.bottom-nav button .icon { width: 24px; height: 24px; }
.bottom-nav button[aria-current="page"] { color: var(--accent-strong); }

/* Page de présentation */
main:has(.landing) { max-width: 1080px; padding-bottom: 2rem; }
.landing-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; }
.brand { display: inline-flex; align-items: center; gap: .55rem; font-weight: 800; font-size: 1.25rem; letter-spacing: -.02em; }
.brand img { border-radius: 9px; }
.hero { display: grid; gap: 2rem; align-items: center; padding: 1rem 0 2.5rem; }
.eyebrow { display: inline-block; background: var(--accent-soft); color: var(--accent-strong); font-weight: 700; font-size: .8rem; letter-spacing: .04em; border-radius: 999px; padding: .3rem .8rem; }
.hero h1 { font-size: clamp(2.1rem, 6vw, 3.4rem); line-height: 1.08; letter-spacing: -.035em; margin: .8rem 0; }
.hero .lead { font-size: 1.1rem; max-width: 34rem; }
.preview {
  background: linear-gradient(160deg, var(--accent-soft), #fff8dc);
  border-radius: 28px; padding: 1.2rem; display: flex; flex-direction: column; gap: .6rem;
  box-shadow: var(--shadow);
}
.preview-budget { background: var(--surface); border-radius: 18px; padding: 1rem; display: flex; flex-direction: column; gap: .3rem; }
.preview-budget span { color: var(--muted); font-size: .85rem; }
.preview-budget b { font-size: 1.8rem; letter-spacing: -.03em; }
.preview-budget small { font-size: .95rem; color: var(--muted); font-weight: 500; }
.preview-meal { display: flex; align-items: center; gap: .8rem; background: var(--surface); border-radius: 16px; padding: .5rem; }
.preview-meal span { display: flex; flex-direction: column; }
.preview-meal small { color: var(--accent-strong); font-weight: 700; font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; }
.how, .features, .cta { padding: 2rem 0; border-top: 1px solid var(--line); }
.how h2, .cta h2 { font-size: 1.5rem; letter-spacing: -.02em; }
.steps-list { list-style: none; padding: 0; margin: 1rem 0 0; display: grid; gap: 1rem; counter-reset: step; }
.steps-list li { counter-increment: step; display: grid; grid-template-columns: 2.6rem 1fr; gap: .1rem .9rem; }
.steps-list li::before { content: counter(step); grid-row: 1 / 3; width: 2.6rem; height: 2.6rem; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-weight: 800; display: grid; place-items: center; }
.steps-list span { color: var(--muted); }
.features { display: grid; gap: 1rem; }
.feature { background: var(--soft); border-radius: var(--radius); padding: 1.2rem; display: flex; flex-direction: column; gap: .3rem; }
.feature span { color: var(--muted); font-size: .95rem; }
.ficon { width: 36px; height: 36px; padding: 7px; border-radius: 12px; background: var(--accent); fill: none; stroke: var(--accent-ink); stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; margin-bottom: .4rem; }
.cta { text-align: center; }
.landing-foot { border-top: 1px solid var(--line); padding: 1.5rem 0 calc(1rem + env(safe-area-inset-bottom)); text-align: center; }
.auth-back { position: absolute; top: calc(1rem + env(safe-area-inset-top)); left: 1rem; }
@media (min-width: 760px) {
  .hero { grid-template-columns: 1.1fr .9fr; padding-top: 2.5rem; }
  .features { grid-template-columns: repeat(4, 1fr); }
  .steps-list { grid-template-columns: repeat(3, 1fr); }
}
