:root {
  --bg: #F7F4EE;
  --card: #FFFFFF;
  --ink: #1D1B18;
  --muted: #736D64;
  --faint: #A9A297;
  --line: #E9E3D9;
  --chip: #EFEAE1;
  --accent: #C4572E;
  --accent-ink: #FFFFFF;
  --accent-soft: #F7E7DD;
  --in: #3F7D5A;
  --in-soft: #E3EFE7;
  --out-soft: #F1EDE6;
  --shadow: 0 1px 2px rgba(40, 30, 20, .05), 0 6px 20px rgba(40, 30, 20, .06);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --r: 18px;
  --tabs-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171513; --card: #221F1C; --ink: #F3EFE9; --muted: #A69F94; --faint: #6F6960;
    --line: #34302B; --chip: #2C2824; --accent: #E07B50; --accent-soft: #3A2A22;
    --in: #7BC497; --in-soft: #1F3328; --out-soft: #2A2622;
    --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(--ink); font-family: var(--sans); font-size: 16px; line-height: 1.45; }
body { min-height: 100dvh; overscroll-behavior-y: none; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
a { color: inherit; }
[hidden] { display: none !important; }

#app { max-width: 560px; margin: 0 auto; padding: calc(var(--safe-t) + 12px) 16px calc(var(--tabs-h) + var(--safe-b) + 28px); }

/* ---------- Type ---------- */
h1, h2, h3 { font-family: var(--serif); font-weight: 600; letter-spacing: -.01em; margin: 0; }
h1 { font-size: 30px; line-height: 1.1; }
h2 { font-size: 22px; line-height: 1.2; }
h3 { font-size: 18px; }
.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; margin: 26px 2px 10px; }
.section-title h2 { font-size: 20px; }

/* ---------- Top bar ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 4px 0 16px; min-height: 44px; }
.topbar .back { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--card); box-shadow: var(--shadow); }
.me-chip { display: flex; align-items: center; gap: 8px; padding: 5px 12px 5px 5px; border-radius: 99px; background: var(--card); box-shadow: var(--shadow); font-size: 14px; font-weight: 500; }

/* ---------- Avatars ---------- */
.av { width: 30px; height: 30px; letter-spacing: -.02em; border-radius: 50%; display: inline-grid; place-items: center; font-size: 13px; font-weight: 600; background: var(--in-soft); color: var(--in); flex: none; position: relative; }
.av.out { background: transparent; color: var(--faint); box-shadow: inset 0 0 0 1.5px var(--line); }
.av .plus { position: absolute; right: -4px; bottom: -3px; width: 15px; height: 15px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 11px; line-height: 15px; text-align: center; border: 2px solid var(--card); box-sizing: content-box; }
.av-row { display: flex; gap: 6px; flex-wrap: wrap; }
.av.sm { width: 24px; height: 24px; font-size: 11px; }
.av.sm .plus { width: 11px; height: 11px; font-size: 9px; line-height: 11px; }

/* ---------- Cards ---------- */
.card { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); }
.pad { padding: 16px; }

.tonight { padding: 20px; position: relative; overflow: hidden; }
.tonight .meal { font-family: var(--serif); font-size: 26px; line-height: 1.15; margin: 6px 0 4px; font-weight: 600; }
.tonight .meal.empty { color: var(--faint); font-style: italic; font-weight: 400; }
.tonight .meta { display: flex; flex-wrap: wrap; gap: 6px 14px; color: var(--muted); font-size: 14px; margin-bottom: 16px; }
.tonight .meta b { color: var(--ink); font-weight: 600; }
.tonight .divider { height: 1px; background: var(--line); margin: 16px -20px; }
.me-toggle { display: grid; grid-template-columns: 1fr 1fr; background: var(--chip); border-radius: 14px; padding: 4px; gap: 4px; }
.me-toggle button { padding: 12px 8px; border-radius: 11px; font-weight: 600; color: var(--muted); }
.me-toggle button.on.in { background: var(--card); color: var(--in); box-shadow: var(--shadow); }
.me-toggle button.on.out { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.check { display: flex; align-items: center; gap: 10px; padding: 12px 2px 0; font-size: 15px; }
.check input { width: 22px; height: 22px; accent-color: var(--accent); margin: 0; }

.days { display: flex; flex-direction: column; gap: 10px; }
.day { display: grid; grid-template-columns: 52px 1fr; gap: 12px; align-items: center; padding: 14px 16px 14px 12px; text-align: left; width: 100%; }
.day .date { text-align: center; }
.day .date .dow { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.day .date .num { font-family: var(--serif); font-size: 24px; line-height: 1.1; font-weight: 600; }
.day.today .date .num, .day.today .date .dow { color: var(--accent); }
.day.past { opacity: .55; }
.day .name { font-weight: 600; font-size: 16px; line-height: 1.25; }
.day .name.empty { color: var(--faint); font-weight: 400; font-style: italic; }
.day .sub { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 6px; font-size: 13px; color: var(--muted); }

.weeknav { display: flex; align-items: center; justify-content: space-between; margin: 26px 2px 10px; }
.weeknav .arrows { display: flex; gap: 6px; }
.icon-btn { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--card); box-shadow: var(--shadow); color: var(--ink); }
.icon-btn:disabled { opacity: .4; }

/* ---------- Buttons / chips ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 14px 18px; border-radius: 14px; font-weight: 600; background: var(--chip); }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.block { width: 100%; }
.btn.ghost { background: transparent; color: var(--accent); padding: 10px 6px; }
.btn.danger { color: #B3261E; background: transparent; }
.btn:disabled { opacity: .5; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px; padding: 2px 16px 6px; scrollbar-width: none; }
.chips.scroll::-webkit-scrollbar { display: none; }
.chip { padding: 9px 14px; border-radius: 99px; background: var(--chip); font-size: 14px; font-weight: 500; white-space: nowrap; }
.chip.on { background: var(--ink); color: var(--bg); }
.pill { display: inline-block; padding: 2px 8px; border-radius: 99px; background: var(--chip); font-size: 12px; color: var(--muted); font-weight: 500; }
.pill.new { background: var(--accent-soft); color: var(--accent); }
.seg { display: flex; background: var(--chip); border-radius: 12px; padding: 3px; gap: 3px; }
.seg button { flex: 1; padding: 9px 10px; border-radius: 9px; font-size: 14px; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.seg.compact { display: inline-flex; }
.seg.compact button { flex: none; padding: 7px 12px; }
.seg button.on.in { color: var(--in); }

/* ---------- Inputs ---------- */
.field { width: 100%; padding: 13px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); outline: none; }
.field:focus { border-color: var(--accent); }
textarea.field { min-height: 110px; resize: vertical; line-height: 1.5; }
label.lbl { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin: 16px 2px 6px; }
.search { position: relative; }
.search .field { padding-left: 40px; }
.search svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--faint); }

/* ---------- Recipe list ---------- */
.rlist { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.ritem { display: flex; gap: 14px; align-items: center; padding: 14px 16px; text-align: left; width: 100%; }
.swatch { width: 44px; height: 44px; border-radius: 12px; flex: none; display: grid; place-items: center; font-family: var(--serif); font-weight: 600; font-size: 17px; }
.ritem .t { font-weight: 600; line-height: 1.25; }
.ritem .m { font-size: 13px; color: var(--muted); margin-top: 3px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

/* ---------- Recipe page ---------- */
.rhead { margin: 2px 2px 18px; }
.rhead h1 { margin: 6px 0 8px; }
.rhead p { margin: 0; color: var(--muted); }
.rmeta { display: flex; gap: 16px; margin-top: 12px; font-size: 14px; color: var(--muted); flex-wrap: wrap; }
.rmeta b { color: var(--ink); }
.src { font-size: 14px; color: var(--accent); text-decoration: none; display: inline-flex; gap: 4px; align-items: center; margin-top: 10px; }
.servings { display: flex; align-items: center; justify-content: space-between; padding: 12px 12px 12px 18px; }
.stepper { display: flex; align-items: center; gap: 4px; background: var(--chip); border-radius: 99px; padding: 4px; }
.stepper button { width: 34px; height: 34px; border-radius: 50%; background: var(--card); box-shadow: var(--shadow); font-size: 20px; line-height: 1; display: grid; place-items: center; }
.stepper span { min-width: 34px; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }
.ings { list-style: none; margin: 0; padding: 6px 0; }
.ings li { display: flex; gap: 12px; align-items: flex-start; padding: 11px 16px; border-bottom: 1px solid var(--line); }
.ings li:last-child { border-bottom: 0; }
.ings .tick { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line); flex: none; margin-top: 1px; display: grid; place-items: center; }
.ings li.done .tick { background: var(--in); border-color: var(--in); color: #fff; }
.ings li.done .txt { color: var(--faint); text-decoration: line-through; }
.ings .amt { font-weight: 700; }
.ings .note { color: var(--muted); font-size: 14px; }
.ings .group { padding: 14px 16px 4px; font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); border: 0; }
.steps { list-style: none; margin: 0; padding: 0; counter-reset: s; }
.steps li { display: grid; grid-template-columns: 30px 1fr; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.steps li:last-child { border-bottom: 0; }
.steps .n { width: 28px; height: 28px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 700; font-size: 14px; }
.steps .st { font-weight: 600; margin-bottom: 2px; }
.steps b, .cook-text b { font-weight: 700; color: var(--accent); }
.timer-chip { display: inline-flex; align-items: center; gap: 6px; margin-top: 8px; padding: 6px 12px; border-radius: 99px; background: var(--chip); font-size: 13px; font-weight: 600; }
.timer-chip.running { background: var(--accent); color: #fff; }
.sticky-cta { position: sticky; bottom: calc(var(--tabs-h) + var(--safe-b) + 12px); margin-top: 18px; z-index: 5; }
.sticky-cta .btn { box-shadow: 0 8px 24px rgba(196, 87, 46, .35); }
.side-card { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; }

/* ---------- Notes ---------- */
.note-item { padding: 14px 16px; border-bottom: 1px solid var(--line); }
.note-item:last-child { border-bottom: 0; }
.note-item .txt { font-size: 16px; white-space: pre-wrap; word-break: break-word; }
.note-item .by { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; font-size: 13px; color: var(--muted); }
.agree { display: inline-flex; align-items: center; gap: 6px; padding: 6px 11px; border-radius: 99px; background: var(--chip); font-size: 13px; font-weight: 600; color: var(--muted); }
.agree.on { background: var(--accent-soft); color: var(--accent); }
.note-form { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); }
.note-form .field { flex: 1; padding: 11px 12px; }
.empty-note { padding: 18px 16px; color: var(--muted); font-size: 15px; }

/* ---------- Tabs ---------- */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: grid; grid-template-columns: repeat(4, 1fr); height: calc(var(--tabs-h) + var(--safe-b)); padding-bottom: var(--safe-b); background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-top: 1px solid var(--line); }
.tabs a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11px; font-weight: 600; color: var(--faint); text-decoration: none; }
.tabs a.on { color: var(--accent); }

/* ---------- Sheet ---------- */
.sheet-wrap { position: fixed; inset: 0; z-index: 40; background: rgba(20, 15, 10, .35); display: flex; align-items: flex-end; justify-content: center; animation: fade .18s ease; }
.sheet { width: 100%; max-width: 560px; max-height: 92dvh; overflow-y: auto; background: var(--bg); border-radius: 24px 24px 0 0; padding: 10px 16px calc(var(--safe-b) + 24px); animation: up .22s cubic-bezier(.2, .8, .2, 1); overscroll-behavior: contain; }
.sheet .grab { width: 40px; height: 5px; border-radius: 99px; background: var(--line); margin: 0 auto 12px; }
.sheet-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 4px; }
.person-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.person-row:last-child { border-bottom: 0; }
.person-row .nm { flex: 1; font-weight: 600; }
.person-row .nm small { display: block; font-weight: 400; color: var(--muted); font-size: 13px; }
.person-row .plusline { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); margin-top: 4px; font-weight: 400; }
.person-row .plusline input { width: 18px; height: 18px; accent-color: var(--accent); margin: 0; }
.pick-list { max-height: 46dvh; overflow-y: auto; margin-top: 10px; }
.pick { display: flex; justify-content: space-between; align-items: center; width: 100%; padding: 13px 14px; text-align: left; border-bottom: 1px solid var(--line); font-weight: 500; }
.pick:last-child { border-bottom: 0; }
.pick.on { color: var(--accent); font-weight: 700; }
.pick-group { padding: 12px 14px 4px; font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }

@keyframes up { from { transform: translateY(40px); opacity: .4; } }
@keyframes fade { from { opacity: 0; } }

/* ---------- Cook mode ---------- */
.cook { position: fixed; inset: 0; z-index: 60; background: var(--bg); display: flex; flex-direction: column; padding: calc(var(--safe-t) + 12px) 20px calc(var(--safe-b) + 18px); }
.cook-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.cook-prog { height: 4px; background: var(--line); border-radius: 99px; overflow: hidden; margin: 14px 0 0; }
.cook-prog div { height: 100%; background: var(--accent); transition: width .25s ease; }
.cook-body { flex: 1; overflow-y: auto; padding: 28px 2px 16px; }
.cook-num { font-size: 14px; font-weight: 600; color: var(--accent); letter-spacing: .04em; }
.cook-title { font-family: var(--serif); font-size: 30px; line-height: 1.15; margin: 8px 0 16px; font-weight: 600; }
.cook-text { font-size: 22px; line-height: 1.5; }
.cook-ings { margin-top: 24px; padding: 4px 0; }
.cook-ings div { padding: 10px 16px; border-bottom: 1px solid var(--line); font-size: 16px; }
.cook-ings div:last-child { border-bottom: 0; }
.cook-timer { margin-top: 22px; width: 100%; padding: 18px; border-radius: 16px; background: var(--chip); font-size: 18px; font-weight: 700; display: flex; justify-content: center; gap: 10px; align-items: center; font-variant-numeric: tabular-nums; }
.cook-timer.running { background: var(--accent); color: #fff; }
.cook-timer.done { background: var(--in); color: #fff; }
.cook-nav { display: grid; grid-template-columns: 1fr 2fr; gap: 10px; }
.cook-nav .btn { padding: 18px; font-size: 17px; }

/* Floating timers */
.timer-pills { position: fixed; z-index: 70; bottom: calc(var(--tabs-h) + var(--safe-b) + 80px); left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; }
.timer-pill { pointer-events: auto; display: flex; align-items: center; gap: 8px; padding: 8px 10px 8px 14px; border-radius: 99px; background: var(--ink); color: var(--bg); font-size: 14px; font-weight: 600; box-shadow: 0 6px 20px rgba(0, 0, 0, .25); font-variant-numeric: tabular-nums; }
.timer-pill.done { background: var(--in); color: #fff; animation: pulse 1s infinite; }
.timer-pill button { width: 22px; height: 22px; border-radius: 50%; background: rgba(255, 255, 255, .18); color: inherit; font-size: 13px; line-height: 22px; }
@keyframes pulse { 50% { transform: scale(1.05); } }
.cook-open .timer-pills { bottom: calc(var(--safe-b) + 96px); }

/* ---------- Planner / groceries ---------- */
.plan-row { display: grid; grid-template-columns: 44px 1fr auto; gap: 12px; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.plan-row:last-child { border-bottom: 0; }
.plan-row .d { font-size: 12px; font-weight: 700; text-transform: uppercase; color: var(--muted); text-align: center; line-height: 1.2; }
.plan-row .d b { display: block; font-family: var(--serif); font-size: 20px; color: var(--ink); }
.plan-row .nm { font-weight: 600; line-height: 1.25; }
.plan-row .nm small { display: block; font-weight: 400; font-size: 13px; color: var(--muted); }
.plan-row input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--accent); }
.shared { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.toggle-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 16px; }
.switch { position: relative; width: 50px; height: 30px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; background: var(--line); border-radius: 99px; transition: .2s; }
.switch span::after { content: ""; position: absolute; left: 3px; top: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(20px); }

.gl { list-style: none; margin: 0; padding: 4px 0; }
.gl li { display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.gl li:last-child { border-bottom: 0; }
.gl .tick { width: 24px; height: 24px; border-radius: 7px; border: 2px solid var(--line); flex: none; display: grid; place-items: center; margin-top: 1px; }
.gl li.done .tick { background: var(--in); border-color: var(--in); color: #fff; }
.gl li.done .gt { color: var(--faint); text-decoration: line-through; }
.gl .gt { flex: 1; }
.gl .gq { font-weight: 700; }
.gl .gm { font-size: 13px; color: var(--muted); margin-top: 2px; }
.gl .x { color: var(--faint); padding: 2px 6px; }
details.pantry summary { list-style: none; cursor: pointer; padding: 14px 16px; display: flex; justify-content: space-between; font-weight: 600; }
details.pantry summary::-webkit-details-marker { display: none; }
details.pantry[open] summary { border-bottom: 1px solid var(--line); }

/* ---------- Misc ---------- */
.toast { position: fixed; left: 50%; bottom: calc(var(--tabs-h) + var(--safe-b) + 16px); transform: translateX(-50%); z-index: 90; background: var(--ink); color: var(--bg); padding: 11px 18px; border-radius: 12px; font-size: 14px; font-weight: 500; box-shadow: 0 8px 24px rgba(0,0,0,.2); max-width: calc(100% - 32px); }
.center-screen { min-height: 80dvh; display: flex; flex-direction: column; justify-content: center; gap: 14px; max-width: 380px; margin: 0 auto; }
.who-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.who-grid button { padding: 22px 10px; font-size: 17px; font-weight: 600; }
.row { display: flex; gap: 10px; align-items: center; }
.spacer { height: 12px; }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--in); display: inline-block; margin-right: 6px; box-shadow: 0 0 0 3px var(--in-soft); }
.hint { font-size: 13px; color: var(--muted); margin: 6px 2px 0; }
