:root {
  --bg: #f4f5f2;
  --surface: #ffffff;
  --surface-2: #eef0ec;
  --text: #17201b;
  --muted: #66716a;
  --line: #e1e5df;
  --accent: #1f8a4c;
  --accent-ink: #ffffff;
  --accent-soft: #e2f2e8;
  --warn: #c2410c;
  --warn-soft: #fdeee4;
  --danger: #c0262d;
  --gold: #b7791f;
  --shadow: 0 1px 2px rgba(20, 30, 25, .06), 0 4px 16px rgba(20, 30, 25, .06);
  --radius: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1412;
    --surface: #171e1b;
    --surface-2: #202925;
    --text: #e8eee9;
    --muted: #93a099;
    --line: #2a3530;
    --accent: #3fbf74;
    --accent-ink: #062012;
    --accent-soft: #19362a;
    --warn: #f59e5b;
    --warn-soft: #3a2616;
    --danger: #f2686e;
    --gold: #e0b45a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 26px; letter-spacing: -.02em; }
h2 { font-size: 19px; letter-spacing: -.01em; }
h3 { font-size: 16px; }
a { color: var(--accent); }
.boot { display: grid; place-items: center; height: 100vh; font-size: 48px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.bold { font-weight: 650; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; align-items: center; gap: 10px; }
.wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.stack > * + * { margin-top: 12px; }
.center { text-align: center; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ───── Structure */
.shell { min-height: 100vh; padding-bottom: calc(76px + var(--safe-b)); }
.top {
  position: sticky; top: 0; z-index: 10;
  padding: calc(14px + var(--safe-t)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
}
.top .sub { color: var(--muted); font-size: 14px; margin-top: 2px; }
.view { padding: 4px 16px 24px; max-width: 720px; margin: 0 auto; }
.top-inner { max-width: 720px; margin: 0 auto; }
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(4, 1fr);
  padding: 6px 6px calc(6px + var(--safe-b));
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 0; border-radius: 12px; color: var(--muted); text-decoration: none; font-size: 11.5px; font-weight: 600;
  position: relative;
}
.tabbar a .ico { font-size: 22px; line-height: 1; filter: grayscale(.6); opacity: .8; }
.tabbar a.on { color: var(--accent); }
.tabbar a.on .ico { filter: none; opacity: 1; }
.tabbar .badge { position: absolute; top: 2px; left: calc(50% + 8px); }
.badge {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; font-size: 11px; font-weight: 700;
  background: var(--accent); color: var(--accent-ink); display: inline-grid; place-items: center;
}
.offline {
  position: fixed; top: calc(8px + var(--safe-t)); right: 12px; z-index: 30;
  background: var(--warn-soft); color: var(--warn); font-size: 12px; font-weight: 650; padding: 4px 10px; border-radius: 99px;
}

/* ───── Cartes, boutons */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; }
.card + .card { margin-top: 12px; }
.card.flat { box-shadow: none; border: 1px solid var(--line); }
.section-title { display: flex; align-items: center; justify-content: space-between; margin: 22px 2px 8px; }
.section-title h2, .section-title h3 { font-size: 15px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); font-weight: 600; text-decoration: none; color: var(--text);
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.soft { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.btn.danger { color: var(--danger); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.block { width: 100%; }
.btn.big { min-height: 54px; font-size: 17px; border-radius: 14px; }
.btn.sm { min-height: 34px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.btn:disabled { opacity: .5; }
.icon-btn {
  width: 40px; height: 40px; display: inline-grid; place-items: center; border-radius: 12px;
  border: 0; background: transparent; font-size: 19px; color: var(--muted); flex: none;
}
.icon-btn:active { background: var(--surface-2); }
.icon-btn.on { color: var(--accent); }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.actions.three { grid-template-columns: 1fr 1fr 1fr; }

/* ───── Chips, segments */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 6px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips.wrap { flex-wrap: wrap; overflow: visible; }
.chip {
  flex: none; padding: 7px 13px; border-radius: 99px; border: 1px solid var(--line); background: var(--surface);
  font-size: 14px; font-weight: 600; color: var(--text); white-space: nowrap;
}
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.tag {
  display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 12px; font-weight: 600;
  background: var(--surface-2); color: var(--muted);
}
.tag.vege { background: #e3f4e1; color: #2c7a2a; }
.tag.poisson { background: #e1eef8; color: #22659a; }
.tag.rouge { background: #f8e3e1; color: #a2382e; }
.tag.porc { background: #f8e6ef; color: #a03a6a; }
.tag.volaille { background: #fbf0dc; color: #96621a; }
.tag.dessert { background: #efe6f8; color: #6b3fa0; }
@media (prefers-color-scheme: dark) {
  .tag.vege { background: #1d3320; color: #8fd88a; }
  .tag.poisson { background: #172a3a; color: #8cc3ee; }
  .tag.rouge { background: #3a1d1b; color: #f1a198; }
  .tag.porc { background: #381c2a; color: #ef9fc5; }
  .tag.volaille { background: #382b15; color: #f0c477; }
  .tag.dessert { background: #2a1f3a; color: #c6a6f2; }
}
.seg { display: flex; background: var(--surface-2); border-radius: 12px; padding: 3px; gap: 3px; }
.seg button {
  flex: 1; border: 0; background: transparent; padding: 8px 4px; border-radius: 9px; font-weight: 650; font-size: 14px; color: var(--muted);
}
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* ───── Formulaires */
.field { display: block; margin-top: 14px; }
.field > span { display: block; font-size: 13px; font-weight: 650; color: var(--muted); margin: 0 0 6px 2px; }
.input, select.input, textarea.input {
  width: 100%; min-height: 46px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); outline: none; font-size: 16px;
}
textarea.input { min-height: 120px; resize: vertical; line-height: 1.5; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search { position: relative; }
.search .input { padding-left: 38px; }
.search::before { content: "🔍"; position: absolute; left: 12px; top: 50%; transform: translateY(-50%); font-size: 15px; opacity: .6; }
.stepper { display: inline-flex; align-items: center; background: var(--surface-2); border-radius: 12px; }
.stepper button { width: 40px; height: 40px; border: 0; background: transparent; font-size: 20px; font-weight: 700; color: var(--accent); }
.stepper b { min-width: 34px; text-align: center; font-size: 17px; }
.switch { position: relative; width: 50px; height: 30px; flex: none; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 99px; background: var(--line); transition: background .15s; }
.switch span::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .15s;
}
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(20px); }
.setting { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.setting:first-child { border-top: 0; padding-top: 2px; }
.setting .lbl { flex: 1; min-width: 0; }
.setting .lbl small { display: block; color: var(--muted); font-size: 13px; }
.grid7 { display: grid; grid-template-columns: 54px repeat(7, 1fr); gap: 4px; align-items: center; text-align: center; font-size: 13px; }
.grid7 .cell { height: 36px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface); font-weight: 700; }
.grid7 .cell.on { background: var(--accent); border-color: transparent; color: var(--accent-ink); }

/* ───── Menu */
.weekbar { display: flex; gap: 6px; overflow-x: auto; margin: 4px 0 10px; scrollbar-width: none; }
.weekbar::-webkit-scrollbar { display: none; }
.stats { display: flex; gap: 6px; flex-wrap: wrap; margin: 2px 0 12px; }
.day { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); margin-top: 10px; overflow: hidden; }
.day.today { outline: 2px solid var(--accent); }
.day.past { opacity: .62; }
.day-h { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px 2px; }
.day-h b { font-size: 15px; }
.slot { display: flex; align-items: center; gap: 10px; padding: 8px 6px 8px 14px; min-height: 58px; }
.slot + .slot { border-top: 1px solid var(--line); }
.slot .meal { width: 38px; flex: none; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.slot .main { flex: 1; min-width: 0; cursor: pointer; }
.slot .name { font-weight: 620; line-height: 1.25; }
.slot .meta { font-size: 12.5px; color: var(--muted); margin-top: 3px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.slot.done .name { text-decoration: line-through; color: var(--muted); }
.slot.off .name { color: var(--muted); font-style: italic; font-weight: 500; }
.slot.left .name::before { content: "♻️ "; }
.dessert-line { display: flex; align-items: center; gap: 10px; padding: 10px 14px; }
.empty { text-align: center; padding: 34px 18px; }
.empty .big { font-size: 54px; }
.empty p { color: var(--muted); margin: 8px 0 18px; }

/* ───── Liste de courses */
.progress { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin-top: 8px; }
.progress i { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .25s; }
.addbar { display: flex; gap: 8px; margin: 6px 0 4px; }
.addbar .input { flex: 1; }
.rayon { margin-top: 16px; }
.rayon-h { display: flex; align-items: center; gap: 8px; margin: 0 4px 6px; font-weight: 750; font-size: 15px; }
.rayon-h .count { margin-left: auto; color: var(--muted); font-size: 13px; font-weight: 600; }
.items { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.item { display: flex; align-items: center; gap: 12px; padding: 11px 8px 11px 14px; min-height: 56px; }
.item + .item { border-top: 1px solid var(--line); }
.check {
  width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--line); flex: none; display: grid; place-items: center;
  background: transparent; padding: 0; color: transparent; font-size: 16px; font-weight: 900;
}
.item.checked .check { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.item .txt { flex: 1; min-width: 0; cursor: pointer; }
.item .nm { font-weight: 600; line-height: 1.25; }
.item .qt { font-weight: 750; color: var(--accent); white-space: nowrap; }
.item .hint { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.item.checked .nm { text-decoration: line-through; color: var(--muted); }
.item.checked .qt { color: var(--muted); }
.item .pbtns { display: flex; gap: 6px; flex: none; }
.store .item { min-height: 66px; }
.store .item .nm { font-size: 18px; }
.store .check { width: 34px; height: 34px; }
.collapse-h { width: 100%; border: 0; background: transparent; padding: 0; text-align: left; }

/* ───── Recettes */
.rcard { display: flex; gap: 12px; align-items: center; padding: 12px 10px 12px 14px; cursor: pointer; }
.rcard + .rcard { border-top: 1px solid var(--line); }
.remoji {
  width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; font-size: 24px; flex: none; background: var(--surface-2);
}
.rcard .nm { font-weight: 640; line-height: 1.25; }
.rcard .meta { font-size: 12.5px; color: var(--muted); margin-top: 3px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.hero { padding: 6px 2px 4px; }
.hero h1 { font-size: 25px; }
.meta-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; }
.meta-grid div { background: var(--surface); border-radius: 14px; padding: 10px; text-align: center; box-shadow: var(--shadow); }
.meta-grid b { display: block; font-size: 17px; }
.meta-grid span { font-size: 12px; color: var(--muted); }
.ing { display: flex; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); }
.ing:first-child { border-top: 0; }
.ing .q { width: 92px; flex: none; font-weight: 700; color: var(--accent); text-align: right; }
.ing.got { opacity: .45; text-decoration: line-through; }
.steps { counter-reset: s; list-style: none; padding: 0; margin: 0; }
.steps li { counter-increment: s; position: relative; padding: 10px 0 10px 40px; border-top: 1px solid var(--line); }
.steps li:first-child { border-top: 0; }
.steps li::before {
  content: counter(s); position: absolute; left: 0; top: 9px; width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent); font-weight: 800; display: grid; place-items: center; font-size: 14px;
}
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--accent); font-weight: 650; text-decoration: none; padding: 4px 0; border: 0; background: none; }

/* ───── Feuilles (modales du bas) */
.overlay {
  position: fixed; inset: 0; z-index: 50; background: rgba(10, 15, 12, .45); display: flex; align-items: flex-end; justify-content: center;
  animation: fade .15s ease-out;
}
.sheet {
  width: 100%; max-width: 640px; max-height: 92vh; overflow-y: auto; background: var(--bg);
  border-radius: 22px 22px 0 0; padding: 8px 16px calc(20px + var(--safe-b));
  animation: up .2s cubic-bezier(.2, .8, .2, 1);
  overscroll-behavior: contain;
}
.sheet .grip { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 4px auto 10px; }
.sheet-h { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.menu-list { background: var(--surface); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.menu-list button {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 14px 16px; border: 0; background: transparent; text-align: left; font-weight: 600; font-size: 16px;
}
.menu-list button + button { border-top: 1px solid var(--line); }
.menu-list button:active { background: var(--surface-2); }
.menu-list .e { width: 26px; text-align: center; font-size: 19px; }
@keyframes up { from { transform: translateY(40px); opacity: .4; } }
@keyframes fade { from { opacity: 0; } }

/* ───── Mode cuisine */
.cook {
  position: fixed; inset: 0; z-index: 60; background: var(--bg); display: flex; flex-direction: column;
  padding: calc(14px + var(--safe-t)) 18px calc(18px + var(--safe-b));
}
.cook .stepnum { color: var(--accent); font-weight: 800; letter-spacing: .05em; text-transform: uppercase; font-size: 14px; }
.cook .steptext { flex: 1; display: flex; align-items: center; font-size: 26px; line-height: 1.4; font-weight: 550; overflow-y: auto; }
.cook .timer { font-size: 44px; font-weight: 800; text-align: center; font-variant-numeric: tabular-nums; color: var(--accent); }
.dots { display: flex; gap: 6px; justify-content: center; margin: 12px 0; }
.dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.dots i.on { background: var(--accent); }

/* ───── Connexion */
.login { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; padding: 24px; max-width: 420px; margin: 0 auto; }
.login .logo { width: 84px; height: 84px; border-radius: 22px; margin: 0 auto 14px; display: block; box-shadow: var(--shadow); }
.login h1 { text-align: center; }
.login p { text-align: center; color: var(--muted); margin: 6px 0 18px; }
.error { color: var(--danger); font-weight: 600; font-size: 14px; margin-top: 10px; min-height: 20px; }
.banner { display: flex; gap: 10px; align-items: flex-start; background: var(--accent-soft); color: var(--text); border-radius: 14px; padding: 12px 14px; font-size: 14px; margin-bottom: 12px; }

#toast {
  position: fixed; left: 50%; bottom: calc(90px + var(--safe-b)); transform: translateX(-50%) translateY(20px);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 600; font-size: 14px;
  opacity: 0; pointer-events: none; transition: all .2s; z-index: 80; max-width: calc(100% - 32px); text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }
#toast button { margin-left: 10px; background: none; border: 0; color: var(--accent); font-weight: 800; }
