:root {
  --bg: #f6f2ea; --card: #ffffff; --ink: #1d2a26; --muted: #6c7a74; --line: #e6e0d4;
  --brand: #1f5f4a; --brand-2: #e8f1ec; --accent: #e07a3f; --accent-2: #fcefe5;
  --bonus: #d9480f; --ok: #2b8a3e; --warn: #c92a2a; --radius: 16px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 14px rgba(31,95,74,.06);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121816; --card: #1b2420; --ink: #e8efe9; --muted: #93a39b; --line: #2b3632;
    --brand: #6cc3a0; --brand-2: #1f3029; --accent: #f0a06a; --accent-2: #3a2a1f; --bonus: #ff8a50;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: 'Rubik', system-ui, sans-serif; font-size: 16px; -webkit-text-size-adjust: 100%; }
body.noscroll { overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
main { max-width: 680px; margin: 0 auto; padding: 12px 16px 110px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.splash { display: grid; place-items: center; height: 100vh; color: var(--muted); }

/* header */
header.top { position: sticky; top: 0; z-index: 5; background: var(--brand); color: #fff; padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; }
@media (prefers-color-scheme: dark) { header.top { background: #17332a; } }
.brand { font-weight: 700; font-size: 18px; display: flex; gap: 6px; align-items: center; }
.weeknav { display: flex; align-items: center; gap: 4px; }
.weeklabel { font-weight: 500; min-width: 92px; text-align: center; font-variant-numeric: tabular-nums; }
.icon { background: rgba(255,255,255,.15); border: 0; color: #fff; width: 34px; height: 34px; border-radius: 10px; font-size: 20px; cursor: pointer; }

/* bottom nav */
nav.bottom { position: fixed; bottom: 0; inset-inline: 0; z-index: 5; background: var(--card); border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(4, 1fr); padding-bottom: env(safe-area-inset-bottom); }
nav.bottom button { background: none; border: 0; padding: 8px 0 10px; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 12px; color: var(--muted); cursor: pointer; }
nav.bottom button span { font-size: 20px; filter: grayscale(1); opacity: .7; }
nav.bottom button.on { color: var(--brand); font-weight: 700; }
nav.bottom button.on span { filter: none; opacity: 1; }

/* cards */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--line); padding: 14px; margin-bottom: 12px; }
.summary .sum-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.big { font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; }
.big.over { color: var(--warn); }
.sum-side { text-align: left; font-size: 14px; display: grid; gap: 2px; }
.save { color: var(--ok); font-weight: 500; }
.bar { height: 8px; border-radius: 99px; background: var(--brand-2); overflow: hidden; margin: 10px 0 6px; }
.bar i { display: block; height: 100%; background: var(--brand); border-radius: 99px; transition: width .3s; }
.bar i.over { background: var(--warn); }
.warn { color: var(--warn); font-size: 14px; }
.actions { display: grid; grid-template-columns: 1fr; gap: 8px; margin-bottom: 12px; }
@media (min-width: 520px) { .actions { grid-template-columns: 1fr 1fr; } }

.primary { background: var(--accent); color: #fff; border: 0; border-radius: 12px; padding: 12px 16px; font-weight: 700; cursor: pointer; font-size: 16px; }
.secondary { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; cursor: pointer; }
.ghost { background: var(--brand-2); color: var(--brand); border: 0; border-radius: 10px; padding: 8px 12px; cursor: pointer; font-weight: 500; }
.ghost.tiny { padding: 4px 8px; font-size: 12px; }
.ghost.danger { color: var(--warn); background: #fdecec; }
@media (prefers-color-scheme: dark) { .ghost.danger { background: #3a1f1f; } }
.row-btns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

/* day cards */
.day.off { opacity: .65; }
.day.today { border-color: var(--brand); }
.day-h { display: flex; justify-content: space-between; align-items: center; }
.day-h b { font-size: 17px; }
.day-ctl { display: flex; gap: 8px; align-items: center; margin: 10px 0; flex-wrap: wrap; }
.day-ctl select { border: 1px solid var(--line); background: var(--card); border-radius: 10px; padding: 6px 8px; }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.stepper button { background: var(--brand-2); border: 0; width: 34px; height: 34px; font-size: 18px; cursor: pointer; color: var(--brand); }
.stepper span { min-width: 54px; text-align: center; font-variant-numeric: tabular-nums; }
.stepper.center { display: flex; width: max-content; margin: 8px auto; }
.chip { border: 1px solid var(--line); background: var(--card); border-radius: 99px; padding: 6px 12px; cursor: pointer; font-size: 14px; }
.chip.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0; }

.meal, .rcard { display: flex; gap: 12px; align-items: center; cursor: pointer; }
.meal { background: var(--bg); border-radius: 12px; padding: 10px; }
.emoji { font-size: 30px; width: 46px; height: 46px; display: grid; place-items: center; background: var(--accent-2); border-radius: 12px; flex: none; }
.emoji.big { font-size: 40px; width: 64px; height: 64px; }
.meal-n { font-weight: 700; }
.meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.pill { background: var(--brand-2); color: var(--brand); border-radius: 99px; padding: 2px 8px; font-size: 12px; white-space: nowrap; }
.pill.bonus { background: var(--accent-2); color: var(--bonus); }
.day-act { display: flex; gap: 8px; margin-top: 10px; }
.day-act .ghost { flex: 1; }

/* switch */
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.switch input { display: none; }
.switch span { width: 42px; height: 24px; background: var(--line); border-radius: 99px; position: relative; transition: .2s; flex: none; }
.switch span::after { content: ''; position: absolute; top: 3px; inset-inline-start: 3px; width: 18px; height: 18px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + span { background: var(--brand); }
.switch input:checked + span::after { inset-inline-start: 21px; }
.switch em { font-style: normal; font-size: 13px; color: var(--muted); }

/* shopping list */
.aisle h3 { font-size: 14px; color: var(--muted); margin: 18px 4px 6px; font-weight: 500; letter-spacing: .02em; }
.aisle.have h3 { cursor: pointer; }
.item { display: flex; gap: 10px; align-items: flex-start; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 10px; margin-bottom: 6px; }
.item.done { opacity: .5; }
.item.done .item-n b { text-decoration: line-through; }
.cb { width: 22px; height: 22px; margin-top: 2px; accent-color: var(--brand); flex: none; }
.item-b { flex: 1; min-width: 0; cursor: pointer; }
.prod { display: flex; gap: 8px; align-items: center; margin-top: 6px; }
.prod img, .prow img, .noimg { width: 40px; height: 40px; object-fit: contain; border-radius: 8px; background: #fff; flex: none; }
.nl { font-size: 13px; text-align: left; overflow-wrap: anywhere; }
.bonus-l { display: inline-block; margin-top: 3px; font-size: 11px; font-weight: 700; color: #fff; background: var(--bonus); border-radius: 6px; padding: 1px 6px; direction: ltr; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.item-p { text-align: left; display: grid; gap: 4px; justify-items: end; flex: none; }
.price { font-weight: 700; font-variant-numeric: tabular-nums; }
s.muted { font-size: 12px; }
.small-item { align-items: center; }
.empty { text-align: center; display: grid; gap: 12px; padding: 30px; }

/* recipes */
.search { width: 100%; border: 1px solid var(--line); background: var(--card); border-radius: 12px; padding: 10px 12px; }
.rlist .rcard { margin-bottom: 8px; padding: 10px; }
.rcard.off { opacity: .5; }
.rcard.sel { border-color: var(--brand); }

/* modal */
#modal { position: fixed; inset: 0; background: rgba(10,20,15,.45); z-index: 20; display: none; align-items: flex-end; justify-content: center; }
#modal.open { display: flex; }
.sheet { background: var(--card); width: 100%; max-width: 680px; max-height: 92vh; overflow-y: auto; border-radius: 20px 20px 0 0; padding: 20px 16px calc(24px + env(safe-area-inset-bottom)); position: relative; }
@media (min-width: 720px) { #modal { align-items: center; } .sheet { border-radius: 20px; } }
.sheet h2 { margin: 0 0 6px; font-size: 20px; padding-inline-end: 36px; }
.sheet h3 { margin: 16px 0 6px; font-size: 16px; }
.close { position: absolute; top: 12px; inset-inline-end: 12px; border: 0; background: var(--brand-2); color: var(--brand); width: 32px; height: 32px; border-radius: 50%; cursor: pointer; }
.rhead { display: flex; gap: 12px; align-items: center; }
.ings { list-style: none; padding: 0; margin: 0; }
.ings li { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px dashed var(--line); }
.steps { padding-inline-start: 20px; line-height: 1.6; }
.steps li { margin-bottom: 6px; }
.searchrow { display: flex; gap: 8px; margin: 10px 0; }
.searchrow .primary { padding: 8px 14px; }
.plist { display: grid; gap: 6px; margin-top: 10px; }
.prow { display: flex; gap: 10px; align-items: center; border: 1px solid var(--line); border-radius: 12px; padding: 8px; cursor: pointer; }
.prow.sel { border-color: var(--brand); background: var(--brand-2); }
.prow-b { flex: 1; min-width: 0; }
.ahlink { display: inline-block; margin-top: 12px; color: var(--brand); }

/* forms */
.form h3 { margin: 0 0 10px; font-size: 16px; }
.field { display: grid; gap: 4px; margin-bottom: 10px; font-size: 14px; }
.field.row { grid-template-columns: 1fr auto; align-items: center; }
.field input, .field select, .field textarea { border: 1px solid var(--line); background: var(--card); border-radius: 10px; padding: 9px 10px; width: 100%; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.ingrow { display: grid; grid-template-columns: 1fr 76px 40px auto; gap: 6px; align-items: center; margin-bottom: 6px; }
.ingrow input { border: 1px solid var(--line); background: var(--card); border-radius: 10px; padding: 8px; width: 100%; }
.unit { font-size: 12px; }
.login { max-width: 380px; margin: 12vh auto; }
.big-brand { justify-content: center; font-size: 22px; margin-bottom: 16px; color: var(--brand); }
.login form { display: grid; gap: 8px; }

#toast { position: fixed; bottom: 86px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px; opacity: 0; pointer-events: none; transition: .25s; z-index: 30; max-width: 90vw; text-align: center; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
