/* Layout: app shell — sticky header, one view at a time, bottom tab bar on phones,
   7-column week board on wide screens, bottom sheets for choosing and reading recipes. */
:root {
  --bg: #eef1ea;
  --surface: #fbfcf9;
  --surface-2: #e3e8dd;
  --ink: #17221b;
  --muted: #586459;
  --line: #d3dacd;
  --accent: #1d5c40;
  --accent-strong: #15452f;
  --accent-soft: #d7e6d9;
  --on-accent: #ffffff;
  --time: #95550a;
  --warn: #a63d22;
  --warn-soft: #f7e1d8;
  --tag-bg: #f5d95e;
  --tag-ink: #2a2410;
  --heart: #c8392f;
  --shadow: 0 1px 2px rgb(23 34 27 / 6%), 0 8px 24px -12px rgb(23 34 27 / 18%);
  --display: "Bricolage Grotesque", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --body: "DM Sans", "Segoe UI", system-ui, sans-serif;
  --r-sm: 8px;
  --r-md: 14px;
  --r-lg: 22px;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --tabbar-h: 64px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101612; --surface: #18201a; --surface-2: #222c25; --ink: #e6ece6; --muted: #9eab9f;
    --line: #2e3a31; --accent: #78c79b; --accent-strong: #9ad8b4; --accent-soft: #1f3828; --on-accent: #0d1a12;
    --time: #f1b25b; --warn: #f29a7e; --warn-soft: #3b2119; --tag-bg: #5b4b10; --tag-ink: #fbe9a6; --heart: #ff7a70;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 10px 28px -14px rgb(0 0 0 / 60%);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #101612; --surface: #18201a; --surface-2: #222c25; --ink: #e6ece6; --muted: #9eab9f;
  --line: #2e3a31; --accent: #78c79b; --accent-strong: #9ad8b4; --accent-soft: #1f3828; --on-accent: #0d1a12;
  --time: #f1b25b; --warn: #f29a7e; --warn-soft: #3b2119; --tag-bg: #5b4b10; --tag-ink: #fbe9a6; --heart: #ff7a70;
  --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 10px 28px -14px rgb(0 0 0 / 60%);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 var(--body);
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 0 calc(var(--tabbar-h) + 24px + env(safe-area-inset-bottom, 0px));
}
body::before {
  content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 30; background: var(--bg);
}
h1, h2, h3, h4, p, ul, ol, figure, dl, dd { margin: 0; }
ul, ol { padding: 0; }
h1, h2, h3 { font-family: var(--display); font-weight: 650; letter-spacing: -0.02em; line-height: 1.1; text-wrap: balance; }
h2 { font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2.3rem); }
h3 { font-size: 1.15rem; }
a { color: var(--accent); text-underline-offset: 0.18em; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { opacity: 0.45; cursor: default; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
img { max-width: 100%; display: block; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.icon { width: 1.1em; height: 1.1em; flex: none; vertical-align: -0.18em; }

/* ---------- Shell ---------- */
.shell { max-width: 1180px; margin: 0 auto; }
.topbar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20;
  display: flex; align-items: center; gap: 16px; padding-block: 12px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: baseline; gap: 8px; margin-right: auto; min-width: 0; }
.brand b { font: 700 1.25rem/1 var(--display); letter-spacing: -0.03em; white-space: nowrap; }
.brand span { color: var(--muted); font-size: 0.85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.savestate { display: inline-flex; align-items: center; gap: 6px; font-size: 0.8rem; color: var(--muted); white-space: nowrap; }
.savestate i { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.savestate.off i { background: var(--warn); }
.savestate.off { color: var(--warn); }

.tabs { display: flex; gap: 4px; }
.tabs a {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px;
  color: var(--muted); text-decoration: none; font-weight: 600; transition: background 0.15s, color 0.15s;
}
.tabs a:hover { background: var(--surface-2); color: var(--ink); }
.tabs a[aria-current="page"] { background: var(--ink); color: var(--bg); }
.badge {
  min-width: 1.6em; padding: 1px 6px; border-radius: 999px; font-size: 0.72rem; font-weight: 700; text-align: center;
  background: var(--accent-soft); color: var(--accent-strong); font-variant-numeric: tabular-nums;
}
.tabs a[aria-current="page"] .badge { background: var(--bg); color: var(--ink); }

@media (max-width: 760px) {
  .topbar .tabs { display: none; }
  .brand span { display: none; }
  .tabbar {
    position: fixed; z-index: 25; left: 0; right: 0; bottom: 0;
    display: grid; grid-template-columns: repeat(4, 1fr);
    padding: 6px max(8px, env(safe-area-inset-right, 0px)) calc(6px + env(safe-area-inset-bottom, 0px)) max(8px, env(safe-area-inset-left, 0px));
    background: var(--surface); border-top: 1px solid var(--line);
  }
  .tabbar a {
    position: relative; display: grid; justify-items: center; gap: 2px; padding: 6px 4px; border-radius: 12px;
    color: var(--muted); text-decoration: none; font-size: 0.72rem; font-weight: 600;
  }
  .tabbar a .icon { width: 22px; height: 22px; }
  .tabbar a[aria-current="page"] { color: var(--accent); background: var(--accent-soft); }
  .tabbar .badge { position: absolute; top: 2px; left: calc(50% + 6px); font-size: 0.62rem; padding: 0 5px; background: var(--accent); color: var(--on-accent); }
}
@media (min-width: 761px) {
  .tabbar { display: none; }
  body { padding-bottom: 48px; }
}

main { padding-block: 24px 0; }
.view { display: grid; gap: 28px; }
.view.enter { animation: viewin 0.25s var(--ease); }
@keyframes viewin { from { opacity: 0.4; transform: translateY(6px); } }
.viewhead { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px 24px; }
.viewhead > div { min-width: 0; display: grid; gap: 6px; }
.viewhead p { color: var(--muted); max-width: 60ch; }
.eyebrow { font-size: 0.75rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }

/* ---------- Buttons & controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 8px 16px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-weight: 600; font-size: 0.9rem;
  text-decoration: none; color: var(--ink); transition: transform 0.12s var(--ease), background 0.15s, border-color 0.15s;
}
.btn:hover:not(:disabled) { border-color: var(--muted); }
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover:not(:disabled) { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover:not(:disabled) { background: var(--surface-2); }
.btn.danger { color: var(--warn); }
.btn[data-armed] { background: var(--warn); border-color: var(--warn); color: var(--surface); }
.btn:has(input:focus-visible) { outline: 3px solid var(--accent); outline-offset: 2px; }
.btn.small { min-height: 34px; padding: 5px 12px; font-size: 0.84rem; }
.btn.icon-only { width: 40px; padding: 0; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }

.field { display: grid; gap: 6px; font-size: 0.85rem; font-weight: 600; color: var(--muted); }
.input, select.input, textarea.input {
  width: 100%; min-height: 42px; padding: 8px 12px; border-radius: var(--r-sm); border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font-weight: 500; font-size: 16px;
}
textarea.input { min-height: 120px; font: 0.8rem/1.4 ui-monospace, "SF Mono", Menlo, monospace; resize: vertical; }
.input:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
.inline-field { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-size: 0.9rem; }
.inline-field .input { width: auto; min-height: 38px; }

.segmented { display: inline-flex; padding: 4px; gap: 4px; border-radius: 999px; background: var(--surface-2); max-width: 100%; overflow-x: auto; }
.segmented button {
  border: 0; background: transparent; padding: 7px 14px; border-radius: 999px; font-weight: 600; font-size: 0.9rem; white-space: nowrap; color: var(--muted);
}
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.segmented small { font-weight: 500; opacity: 0.75; margin-left: 4px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); font-size: 0.84rem; font-weight: 600; color: var(--muted);
}
.chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-strong); }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: clamp(16px, 3vw, 24px); display: grid; gap: 16px; min-width: 0; }
.panel > h3 { font-size: 1.2rem; }
.note { font-size: 0.85rem; color: var(--muted); max-width: 70ch; }
.alert { background: var(--warn-soft); color: var(--warn); border-radius: var(--r-md); padding: 12px 14px; font-size: 0.9rem; font-weight: 500; }
.empty {
  display: grid; justify-items: start; gap: 12px; padding: 28px; border: 1.5px dashed var(--line); border-radius: var(--r-lg); color: var(--muted);
}
.empty b { color: var(--ink); font: 650 1.2rem/1.2 var(--display); }

details > summary { cursor: pointer; font-weight: 600; list-style: none; display: flex; align-items: center; gap: 8px; }
details > summary::-webkit-details-marker { display: none; }
details > summary::before { content: ""; width: 7px; height: 7px; border: solid currentColor; border-width: 0 2px 2px 0; transform: rotate(-45deg); transition: transform 0.15s; flex: none; }
details[open] > summary::before { transform: rotate(45deg); }

/* ---------- Week board ---------- */
.weekstats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 12px 14px; display: grid; gap: 2px; text-decoration: none; color: inherit; }
.stat small { color: var(--muted); font-size: 0.78rem; font-weight: 600; }
.stat b { font: 650 1.45rem/1.15 var(--display); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.stat span { font-size: 0.8rem; color: var(--muted); }
a.stat:hover { border-color: var(--accent); }
.meter { height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin-top: 6px; }
.meter i { display: block; height: 100%; background: var(--accent); border-radius: inherit; transition: width 0.3s var(--ease); }

.board { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 10px; }
.day { display: grid; gap: 8px; align-content: start; min-width: 0; scroll-margin-top: 80px; }
.dayhead { display: grid; gap: 1px; padding: 4px 4px 6px; border-bottom: 2px solid var(--line); }
.dayhead b { font: 650 1.05rem/1.2 var(--display); }
.dayhead small { color: var(--muted); font-size: 0.78rem; font-variant-numeric: tabular-nums; }
.day.today .dayhead { border-color: var(--accent); }
.day.today .dayhead b::after { content: "Aujourd’hui"; margin-left: 6px; font: 700 0.62rem/1 var(--body); letter-spacing: 0.06em; text-transform: uppercase; padding: 3px 6px; border-radius: 999px; background: var(--accent); color: var(--on-accent); vertical-align: 0.2em; }

.slot {
  position: relative; display: grid; grid-template-rows: auto 1fr; text-align: left; width: 100%; padding: 0; overflow: hidden;
  border-radius: var(--r-md); border: 1px solid var(--line); background: var(--surface); color: inherit;
  transition: transform 0.15s var(--ease), box-shadow 0.15s, border-color 0.15s;
}
.slot:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.slot img { width: 100%; aspect-ratio: 16 / 11; object-fit: cover; background: var(--surface-2); }
.slot .slotbody { display: grid; gap: 3px; padding: 8px 10px 10px; min-width: 0; }
.slot .meal { font-size: 0.68rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.slot .name { font-weight: 600; font-size: 0.88rem; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.slot .meta { font-size: 0.75rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.slot .meta b { color: var(--time); font-weight: 700; }
.slot.empty-slot { border-style: dashed; border-width: 1.5px; background: transparent; }
.slot.empty-slot .ph { aspect-ratio: 16 / 11; display: grid; place-items: center; color: var(--accent); }
.slot.empty-slot .ph span { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: 0.85rem; }
.slot.nothing .ph { color: var(--muted); }
.slot.nothing { background: var(--surface-2); border-style: solid; }
.slot.just-set { animation: pop 0.45s var(--ease); }
@keyframes pop { 40% { transform: scale(1.03); box-shadow: 0 0 0 3px var(--accent); } }

.dayjump { display: none; }

@media (max-width: 1020px) and (min-width: 761px) {
  .board { grid-template-columns: repeat(4, minmax(0, 1fr)); row-gap: 22px; }
}
@media (max-width: 760px) {
  .dayjump { display: flex; gap: 6px; overflow-x: auto; margin-inline: -4px; padding: 2px 4px 6px; scrollbar-width: none; }
  .dayjump a { flex: none; display: grid; justify-items: center; min-width: 46px; padding: 6px 8px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); text-decoration: none; color: var(--ink); font-weight: 700; font-size: 0.85rem; }
  .dayjump a small { font-size: 0.66rem; color: var(--muted); font-weight: 600; font-variant-numeric: tabular-nums; }
  .dayjump a.full { border-color: var(--accent); }
  .dayjump a.today { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
  .dayjump a.today small { color: var(--on-accent); }
  .board { grid-template-columns: 1fr; gap: 22px; }
  .slot { grid-template-columns: 84px 1fr; grid-template-rows: none; align-items: center; }
  .slot img, .slot.empty-slot .ph { aspect-ratio: 1; height: 100%; min-height: 76px; }
  .slot.empty-slot .ph span .lbl { display: none; }
  .slot:hover { transform: none; }
}

/* ---------- Dish cards (catalogue + picker) ---------- */
.toolbar { display: grid; gap: 12px; }
.toolrow { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.search { position: relative; flex: 1 1 240px; min-width: 0; }
.search .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search .input { padding-left: 38px; border-radius: 999px; }
.resultcount { font-size: 0.85rem; color: var(--muted); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); gap: 16px; }
.card {
  position: relative; display: grid; grid-template-rows: auto 1fr; border-radius: var(--r-md); overflow: hidden;
  background: var(--surface); border: 1px solid var(--line); transition: transform 0.15s var(--ease), box-shadow 0.15s;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.card .open { all: unset; cursor: pointer; display: grid; grid-template-rows: auto 1fr; }
.card .open:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; }
.card img { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; background: var(--surface-2); }
.card .body { display: grid; gap: 6px; padding: 12px 14px 14px; align-content: start; }
.card .title { font: 650 1.02rem/1.25 var(--display); letter-spacing: -0.01em; }
.facts { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 0.8rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.facts .time { color: var(--time); font-weight: 700; }
.score { display: inline-flex; align-items: center; gap: 5px; }
.score i { display: inline-block; width: 34px; height: 5px; border-radius: 999px; background: linear-gradient(90deg, var(--accent) var(--p), var(--surface-2) var(--p)); }
.code { font-size: 0.7rem; font-weight: 700; letter-spacing: 0.04em; padding: 1px 6px; border-radius: 5px; border: 1px solid var(--line); color: var(--muted); }
.planned { position: absolute; left: 10px; top: 10px; padding: 3px 9px; border-radius: 999px; font-size: 0.72rem; font-weight: 700; background: var(--accent); color: var(--on-accent); box-shadow: var(--shadow); }
.favbtn {
  position: absolute; right: 10px; top: 10px; z-index: 1; width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%;
  border: 0; background: color-mix(in srgb, var(--surface) 92%, transparent); color: var(--muted); box-shadow: var(--shadow); transition: transform 0.15s var(--ease);
}
.favbtn:active { transform: scale(0.88); }
.favbtn[aria-pressed="true"], .favtoggle[aria-pressed="true"] { color: var(--heart); }
.favbtn .icon { width: 20px; height: 20px; }

/* Picker list rows */
.options { display: grid; gap: 10px; }
.option {
  display: grid; grid-template-columns: 88px minmax(0, 1fr) auto; align-items: stretch; border-radius: var(--r-md);
  border: 1px solid var(--line); background: var(--surface); overflow: hidden; transition: border-color 0.15s, box-shadow 0.15s;
}
.option.current { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.option img { width: 88px; height: 100%; min-height: 88px; object-fit: cover; background: var(--surface-2); }
.option .pick { all: unset; cursor: pointer; display: grid; gap: 4px; align-content: center; padding: 10px 12px; min-width: 0; }
.option .pick:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; }
.option .pick b { font-weight: 650; line-height: 1.25; }
.option .side { display: grid; align-content: space-between; justify-items: end; gap: 6px; padding: 10px 10px 10px 0; }
.option:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); }
.why { font-size: 0.78rem; color: var(--accent-strong); font-weight: 500; }
.why.home { color: var(--muted); }
.pricetag {
  font: 700 0.8rem/1 var(--body); font-variant-numeric: tabular-nums; padding: 5px 8px 5px 10px; white-space: nowrap;
  background: var(--tag-bg); color: var(--tag-ink); border-radius: 4px 999px 999px 4px; position: relative;
}
.pricetag.zero { background: var(--accent-soft); color: var(--accent-strong); }

/* ---------- Sheets ---------- */
dialog.sheet {
  padding: 0; border: 0; color: var(--ink); background: var(--surface); width: min(720px, 100%); max-width: 100%;
  max-height: min(92vh, 900px); border-radius: var(--r-lg); box-shadow: 0 30px 80px -20px rgb(0 0 0 / 45%);
  overflow: hidden;
}
dialog.sheet[open] { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; animation: sheetin 0.28s var(--ease); }
dialog.sheet::backdrop { background: rgb(10 16 12 / 45%); backdrop-filter: blur(2px); }
@keyframes sheetin { from { transform: translateY(24px); opacity: 0; } }
.sheethead { display: flex; align-items: flex-start; gap: 12px; padding: 18px 20px 12px; border-bottom: 1px solid var(--line); }
.sheethead > div { flex: 1; min-width: 0; display: grid; gap: 4px; }
.sheethead h2 { font-size: 1.45rem; }
.sheetbody { overflow-y: auto; overscroll-behavior: contain; padding: 16px 20px 20px; display: grid; gap: 16px; align-content: start; }
.sheetfoot[hidden] { display: none; }
.sheetfoot { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; padding: 12px 20px calc(12px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--line); background: var(--surface); }
@media (max-width: 760px) {
  dialog.sheet { margin: auto 0 0; width: 100%; max-height: 94vh; max-height: 94dvh; border-radius: var(--r-lg) var(--r-lg) 0 0; }
  @keyframes sheetin { from { transform: translateY(60px); opacity: 0.2; } }
}

/* Recipe detail */
.recipehero { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 18px; align-items: start; }
.recipehero img { width: 200px; aspect-ratio: 1; object-fit: cover; border-radius: var(--r-md); background: var(--surface-2); }
.recipehero .intro { display: grid; gap: 10px; min-width: 0; }
.bigfacts { display: grid; grid-template-columns: repeat(auto-fit, minmax(92px, 1fr)); gap: 8px; }
.bigfacts div { padding: 8px 10px; border-radius: var(--r-sm); background: var(--surface-2); display: grid; }
.bigfacts small { font-size: 0.72rem; color: var(--muted); font-weight: 600; }
.bigfacts b { font: 650 1.05rem/1.2 var(--display); font-variant-numeric: tabular-nums; }
.bigfacts .t b { color: var(--time); }
@media (max-width: 560px) {
  .recipehero { grid-template-columns: 1fr; }
  .recipehero img { width: 100%; aspect-ratio: 16 / 10; }
}
.ingredients { list-style: none; display: grid; gap: 0; }
.ingredients li { display: grid; grid-template-columns: 96px minmax(0, 1fr) auto; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 0.92rem; }
.ingredients li b { font-variant-numeric: tabular-nums; }
.ingredients li span:last-child { color: var(--muted); font-size: 0.8rem; font-variant-numeric: tabular-nums; }
.steps { list-style: none; display: grid; gap: 8px; counter-reset: step; }
.steps label { display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 10px; padding: 10px 12px; border-radius: var(--r-md); background: var(--surface-2); cursor: pointer; counter-increment: step; }
.steps label::before { content: counter(step); display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--surface); font-weight: 700; font-size: 0.85rem; }
.steps input { position: absolute; opacity: 0; pointer-events: none; }
.steps label:has(input:checked) { opacity: 0.55; text-decoration: line-through; text-decoration-color: var(--muted); }
.steps label:has(input:checked)::before { content: "✓"; background: var(--accent); color: var(--on-accent); }
.steps label:has(input:focus-visible) { outline: 3px solid var(--accent); }
.scoreparts { list-style: none; display: grid; gap: 10px; }
.scoreparts li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; font-size: 0.88rem; }
.scoreparts .bar { grid-column: 1 / -1; height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.scoreparts .bar i { display: block; height: 100%; background: var(--accent); }
.scoreparts small { grid-column: 1 / -1; color: var(--muted); font-size: 0.78rem; }
.section-title { font: 650 1.05rem/1.2 var(--display); display: flex; align-items: baseline; gap: 8px; }
.section-title small { font: 500 0.8rem var(--body); color: var(--muted); }
.planbox { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 12px; border-radius: var(--r-md); background: var(--accent-soft); }
.planbox .input { width: auto; flex: 1 1 160px; }

/* ---------- Shopping ---------- */
.shopgrid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 24px; align-items: start; }
.shopgrid aside { position: sticky; top: calc(env(safe-area-inset-top, 0px) + 80px); display: grid; gap: 16px; max-height: calc(100vh - env(safe-area-inset-top, 0px) - 100px); overflow-y: auto; overscroll-behavior: contain; }
@media (max-width: 960px) { .shopgrid { grid-template-columns: 1fr; } .shopgrid aside { position: static; order: -1; } }
.totals { display: grid; gap: 6px; }
.totals div { display: flex; justify-content: space-between; gap: 12px; font-variant-numeric: tabular-nums; }
.totals .grand { padding-top: 8px; margin-top: 4px; border-top: 1px solid var(--line); font: 650 1.6rem/1.1 var(--display); letter-spacing: -0.02em; }
.tiers { position: relative; height: 44px; margin-top: 4px; }
.tiers .track { position: absolute; left: 0; right: 0; top: 8px; height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.tiers .fill { display: block; height: 100%; background: var(--accent); transition: width 0.3s var(--ease); }
.tiers .fill.over { background: var(--warn); }
.tiers .tick { position: absolute; top: 2px; width: 2px; height: 22px; background: var(--ink); opacity: 0.55; transform: translateX(-1px); }
.tiers .tick span { position: absolute; top: 24px; left: 50%; transform: translateX(-50%); font-size: 0.66rem; white-space: nowrap; color: var(--muted); font-weight: 600; font-variant-numeric: tabular-nums; }
.tiers .tick.budget { background: var(--warn); opacity: 0.9; }
.tiers .tick.budget span { color: var(--warn); }
.shopprogress { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.group { display: grid; gap: 4px; }
.group h3 { font-size: 0.78rem; font-family: var(--body); font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); padding: 4px 2px; }
.line { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 4px 10px; align-items: start; padding: 10px 12px 10px 6px; border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--line); }
.line .check { display: grid; place-items: center; width: 44px; height: 44px; cursor: pointer; }
.line .check input { width: 22px; height: 22px; accent-color: var(--accent); cursor: pointer; }
.line .what { display: grid; gap: 2px; padding-top: 4px; min-width: 0; }
.line .what b { font-weight: 650; }
.line .what small { color: var(--muted); font-size: 0.8rem; font-variant-numeric: tabular-nums; }
.line .price { padding-top: 4px; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; display: grid; gap: 4px; justify-items: end; }
.line .more { grid-column: 2 / -1; display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; font-size: 0.82rem; }
.line .more details { flex-basis: 100%; }
.line .more details p { margin-top: 6px; color: var(--muted); }
.line .more a { font-weight: 600; }
.line.bought { background: transparent; border-style: dashed; }
.line.bought .what b { text-decoration: line-through; text-decoration-color: var(--muted); color: var(--muted); }
.line .flag { color: var(--warn); font-weight: 600; }
.linkbtn { border: 0; background: none; padding: 0; color: var(--accent); font-weight: 600; text-decoration: underline; text-underline-offset: 0.18em; font-size: inherit; }
.homeline { opacity: 0.8; }
.homeline .price { color: var(--muted); font-weight: 600; }

/* ---------- More ---------- */
.moregrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); gap: 16px; align-items: start; }
.weeklist { list-style: none; display: grid; gap: 8px; }
.weeklist li { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 12px; border-radius: var(--r-md); background: var(--surface-2); }
.weeklist li div { flex: 1 1 160px; min-width: 0; display: grid; }
.weeklist small { color: var(--muted); font-size: 0.78rem; }
.method { display: grid; gap: 10px; font-size: 0.9rem; max-width: 75ch; }
.method ul { padding-left: 1.2em; display: grid; gap: 4px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; z-index: 40; left: 0; right: 0; margin-inline: auto; width: max-content; bottom: calc(var(--tabbar-h) + 20px + env(safe-area-inset-bottom, 0px));
  display: flex; align-items: center; gap: 14px; max-width: calc(100% - 32px);
  padding: 10px 10px 10px 16px; border-radius: 999px; background: var(--ink); color: var(--bg); box-shadow: var(--shadow);
  font-size: 0.9rem; font-weight: 500; animation: toastin 0.25s var(--ease);
}
.toast button { border: 0; border-radius: 999px; padding: 6px 12px; background: var(--bg); color: var(--ink); font-weight: 700; font-size: 0.85rem; }
@media (min-width: 761px) { .toast { bottom: 28px; } }
@keyframes toastin { from { transform: translateY(16px); opacity: 0; } }

.loading { display: grid; place-items: center; min-height: 50vh; color: var(--muted); gap: 12px; text-align: center; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
