:root {
  --bg: #f8f4ec;
  --surface: #ffffff;
  --surface-2: #f1ebdf;
  --ink: #1d2721;
  --muted: #69736c;
  --faint: #a7ada6;
  --line: #e6ded0;
  --accent: #2f6b4f;
  --accent-ink: #ffffff;
  --accent-soft: #e2efe6;
  --warn: #b4532a;
  --warn-soft: #f8e6dc;
  --radius: 14px;
  --tap: 48px;
  --topbar: 56px;
  --tabs: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121613;
    --surface: #1b211d;
    --surface-2: #232a25;
    --ink: #edf1ec;
    --muted: #9ba69e;
    --faint: #5d665f;
    --line: #2d352f;
    --accent: #74c497;
    --accent-ink: #0d1f15;
    --accent-soft: #1f3327;
    --warn: #ef9a72;
    --warn-soft: #3a261d;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

/* ---------- Chrome ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  height: calc(var(--topbar) + env(safe-area-inset-top, 0px));
  padding: env(safe-area-inset-top, 0px) 16px 0;
  display: flex; align-items: center; gap: 10px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 800; font-size: 1.2rem; color: var(--ink); text-decoration: none; letter-spacing: -0.01em; }
.sync { font-size: .8rem; color: var(--muted); margin-left: auto; }
.who {
  margin-left: auto; width: 40px; height: 40px; border-radius: 50%;
  border: 2px solid var(--accent); background: var(--accent-soft); color: var(--accent);
  font-weight: 800; font-size: 1rem; display: grid; place-items: center;
}
.sync:not([hidden]) + .who { margin-left: 0; }

main {
  max-width: 640px; margin: 0 auto;
  padding: 16px 16px calc(var(--tabs) + var(--safe-b) + 24px);
}

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  height: calc(var(--tabs) + var(--safe-b)); padding-bottom: var(--safe-b);
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--surface); border-top: 1px solid var(--line);
}
.tabs a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); text-decoration: none; font-size: .78rem; font-weight: 600;
}
.tabs svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabs a.active { color: var(--accent); }
body.cooking .tabs, body.cooking .topbar { display: none; }

.banner {
  position: sticky; top: var(--topbar); z-index: 15;
  padding: 10px 16px; font-size: .9rem; text-align: center;
  background: var(--warn-soft); color: var(--warn); border-bottom: 1px solid var(--line);
}
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tabs) + var(--safe-b) + 16px); z-index: 40;
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 999px;
  font-size: .9rem; max-width: calc(100% - 32px); box-shadow: 0 6px 20px rgb(0 0 0 / .2);
}

/* ---------- Identity picker ---------- */
.picker { position: fixed; inset: 0; z-index: 50; background: var(--bg); display: grid; place-items: center; padding: 24px 16px; }
.picker-card { width: 100%; max-width: 380px; text-align: center; }
.picker h1 { font-size: 2rem; margin: 0 0 4px; }
.picker p { color: var(--muted); margin: 0 0 28px; }
.picker-options { display: grid; gap: 12px; }
.picker-options button {
  height: 72px; border-radius: var(--radius); border: 2px solid var(--line);
  background: var(--surface); font-size: 1.4rem; font-weight: 700;
  display: flex; align-items: center; gap: 14px; padding: 0 18px;
}
.picker-options button .avatar { width: 44px; height: 44px; font-size: 1.1rem; }
.picker-options button.current { border-color: var(--accent); }
.avatar {
  border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--accent-soft); color: var(--accent); font-weight: 800;
}

/* ---------- Shared bits ---------- */
h1.page { font-size: 1.6rem; margin: 4px 0 2px; letter-spacing: -0.01em; }
.sub { color: var(--muted); margin: 0 0 16px; font-size: .95rem; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.btn {
  min-height: var(--tap); padding: 0 18px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); font-weight: 650; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  text-decoration: none; color: var(--ink);
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { color: var(--warn); }
.btn.block { width: 100%; }
.btn.small { min-height: 36px; padding: 0 12px; font-size: .9rem; }
.row { display: flex; gap: 10px; align-items: center; }
.chip {
  display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .75rem; font-weight: 650;
  background: var(--surface-2); color: var(--muted);
}
.chip.good { background: var(--accent-soft); color: var(--accent); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.empty { text-align: center; color: var(--muted); padding: 40px 12px; }
.empty .btn { margin-top: 14px; }
.segmented { display: inline-grid; grid-auto-flow: column; background: var(--surface-2); border-radius: 12px; padding: 3px; }
.segmented button { border: 0; background: none; padding: 7px 16px; border-radius: 9px; font-weight: 650; color: var(--muted); }
.segmented button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgb(0 0 0 / .12); }
input[type=text], input[type=number], input[type=url], select, textarea {
  width: 100%; min-height: var(--tap); padding: 10px 12px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface);
}
textarea { min-height: 140px; resize: vertical; line-height: 1.4; }
label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-weight: 650; font-size: .9rem; margin-bottom: 6px; }
label.field small { color: var(--muted); font-weight: 400; }

/* ---------- Shopping ---------- */
.shop-head { display: flex; align-items: end; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.total { font-size: .95rem; color: var(--muted); }
.total strong { color: var(--ink); font-size: 1.15rem; }
.add-form { display: flex; gap: 8px; margin-bottom: 18px; }
.add-form input { flex: 1; }
.section-head {
  display: flex; align-items: center; gap: 8px; margin: 22px 0 8px;
  font-size: .8rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--muted);
}
.section-head .dot { width: 10px; height: 10px; border-radius: 50%; }
.section-head .count { margin-left: auto; font-weight: 650; letter-spacing: 0; text-transform: none; }
.items { list-style: none; margin: 0; padding: 0; }
.item {
  display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 8px 6px 8px 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 6px;
}
.item .check {
  flex: none; width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--faint);
  display: grid; place-items: center; background: none; padding: 0;
}
.item .check svg { width: 18px; height: 18px; stroke: var(--accent-ink); stroke-width: 3; fill: none; opacity: 0; }
.item.done .check { background: var(--accent); border-color: var(--accent); }
.item.done .check svg { opacity: 1; }
.item .body { flex: 1; min-width: 0; background: none; border: 0; text-align: left; padding: 4px 0; }
.item .name { font-weight: 650; display: block; }
.item .meta { font-size: .82rem; color: var(--muted); display: block; }
.recipe-tag { font-weight: 650; }
.rc0 { color: #b4532a; } .rc1 { color: #2f7d6a; } .rc2 { color: #8a4fa3; }
.rc3 { color: #b07d12; } .rc4 { color: #3f6fb0; } .rc5 { color: #b0425e; }
@media (prefers-color-scheme: dark) {
  .rc0 { color: #f0a07a; } .rc1 { color: #6fcfb3; } .rc2 { color: #c99be0; }
  .rc3 { color: #e8c063; } .rc4 { color: #8fb6ec; } .rc5 { color: #ee8fa7; }
}
.item.done .recipe-tag { color: inherit; font-weight: inherit; }

/* Prices stay quiet: small, faint green, never competing with the ingredient. */
.cost, .pick .p {
  font-variant-numeric: tabular-nums; font-weight: 500; font-size: .75rem; color: var(--accent); opacity: .6;
}
.item .more { border: 0; background: none; width: 36px; height: 44px; color: var(--faint); font-size: 1.3rem; }
.item.done { background: transparent; }
.item.done .name { text-decoration: line-through; color: var(--faint); }
.cart-head { margin-top: 30px; }

/* Map */
.map-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; }
.map { width: 100%; height: auto; display: block; touch-action: manipulation; }
.map .wall { fill: var(--surface-2); stroke: var(--line); stroke-width: 2; }
.map .zone { stroke: var(--surface); stroke-width: 2; cursor: pointer; }
.map .zone-label { font-size: 11px; font-weight: 700; fill: var(--ink); pointer-events: none; }
.map .zone-label.dim { fill: var(--faint); }
.map .badge { pointer-events: none; }
.map .badge circle { fill: var(--ink); stroke: var(--surface); stroke-width: 2; }
.map .badge text { fill: var(--bg); font-size: 11px; font-weight: 800; }
.map .badge.next circle { fill: var(--warn); }
.map .badge.next text { fill: #fff; }
.map .fixture { fill: var(--surface-2); stroke: var(--line); }
.map .fixture-label { font-size: 10px; fill: var(--muted); font-weight: 650; }
.map .selected { stroke: var(--ink); stroke-width: 3; }
.map-note { font-size: .8rem; color: var(--muted); margin: 8px 4px 0; }
.next-stop { margin: 14px 0 6px; font-weight: 700; }

/* ---------- Recipes ---------- */
.recipe-card { display: block; padding: 16px; margin-bottom: 12px; text-decoration: none; color: inherit; }
.recipe-card h2 { margin: 0 0 4px; font-size: 1.2rem; }
.recipe-card p { margin: 0 0 10px; color: var(--muted); font-size: .92rem; }
.recipe-card .facts { display: flex; flex-wrap: wrap; gap: 6px; }
.recipe h1 { font-size: 1.7rem; line-height: 1.15; margin: 4px 0 6px; }
.recipe .tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 14px; }
.diet-note { padding: 12px 14px; border-radius: 12px; background: var(--accent-soft); color: var(--ink); font-size: .92rem; margin-bottom: 16px; }
.diet-note strong { color: var(--accent); }
.prep { padding: 16px; margin-bottom: 18px; }
.prep h2 { margin: 0 0 10px; font-size: 1rem; }
.stepper { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.stepper button { width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); font-size: 1.3rem; font-weight: 700; }
.stepper .val { font-size: 1.1rem; font-weight: 750; min-width: 7ch; text-align: center; }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat { background: var(--surface-2); border-radius: 12px; padding: 10px 12px; }
.stat b { display: block; font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.stat span { font-size: .8rem; color: var(--muted); }
.portion-note { font-size: .9rem; color: var(--muted); margin: 12px 0 0; }
.recipe h2.h { font-size: 1.1rem; margin: 22px 0 8px; }
.ing-group { font-size: .78rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 14px 0 4px; }
.ings { list-style: none; padding: 0; margin: 0; }
.ings li { display: flex; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); align-items: baseline; }
.ings li .amt { flex: 1; }
.ings li .amt em { color: var(--muted); font-style: normal; font-size: .88rem; }
.steps-preview { padding-left: 22px; margin: 0; }
.steps-preview li { margin-bottom: 10px; }
.recipe-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 20px 0; }
.recipe-actions .wide { grid-column: 1 / -1; }
.source { font-size: .88rem; color: var(--muted); }
.fine { font-size: .8rem; color: var(--muted); }

/* Restrictions */
.restrictions { list-style: none; padding: 0; margin: 0; }
.restriction { margin-bottom: 8px; }
.restriction-body {
  width: 100%; text-align: left; background: none; border: 0; padding: 14px 16px;
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px;
}
.restriction-name { font-weight: 750; font-size: 1.1rem; }
.restriction .watch { flex-basis: 100%; font-size: .85rem; color: var(--muted); }
.clash { color: var(--warn); }
.clash-note {
  padding: 12px 14px; border-radius: 12px; background: var(--warn-soft); color: var(--ink);
  font-size: .92rem; margin-bottom: 16px; border: 1px solid color-mix(in srgb, var(--warn) 35%, transparent);
}
.clash-note strong { color: var(--warn); }

/* Bottom sheet */
dialog#sheet {
  width: 100%; max-width: 640px; max-height: 88vh; margin: auto auto 0; padding: 0;
  border: 0; border-radius: 20px 20px 0 0; background: var(--surface); color: var(--ink);
}
dialog#sheet::backdrop { background: rgb(0 0 0 / .45); }
.sheet-body { padding: 18px 16px calc(16px + var(--safe-b)); }
.sheet-body h2 { margin: 0 0 4px; font-size: 1.25rem; }
.pick { list-style: none; padding: 0; margin: 12px 0; }
.pick label { display: flex; gap: 12px; align-items: center; padding: 10px 2px; border-bottom: 1px solid var(--line); }
.pick input { width: 22px; height: 22px; accent-color: var(--accent); flex: none; }
.pick .what { flex: 1; }
.pick .what small { display: block; color: var(--muted); }
.sheet-foot { display: flex; gap: 10px; position: sticky; bottom: 0; background: var(--surface); padding-top: 10px; }
.sheet-foot .btn { flex: 1; }

/* ---------- Cook ---------- */
.cook {
  min-height: 100dvh; display: flex; flex-direction: column;
  max-width: 720px; margin: 0 auto;
}
body.cooking main { padding: 0; max-width: none; }
.cook-head { position: sticky; top: 0; z-index: 5; background: var(--bg); }
.cook-top {
  display: flex; align-items: center; gap: 10px;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 14px 10px; border-bottom: 1px solid var(--line);
}
.timer-strip { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.timer-strip .timer { margin: 0; min-height: 44px; padding: 0 14px; font-size: 1rem; }
.cook-top .x { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); font-size: 1.2rem; }
.cook-top .t { flex: 1; min-width: 0; }
.cook-top .t b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cook-top .t span { font-size: .85rem; color: var(--muted); }
.progress { height: 4px; background: var(--line); }
.progress div { height: 100%; background: var(--accent); transition: width .25s; }
.cook-steps { list-style: none; margin: 0; padding: 24px 20px 40vh; flex: 1; }
.cook-steps li {
  padding: 14px 0; color: var(--ink); opacity: .28; font-size: 1.05rem; line-height: 1.4;
  transition: opacity .2s, font-size .2s; cursor: pointer;
}
.cook-steps li .n { font-size: .8rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; display: block; margin-bottom: 2px; }
.cook-steps li.done { opacity: .2; }
.cook-steps li.current {
  opacity: 1; font-size: clamp(1.65rem, 7vw, 2.5rem); font-weight: 800; line-height: 1.22;
  letter-spacing: -0.01em; padding: 22px 0; cursor: default;
}
.cook-steps li.current .n { color: var(--accent); font-size: .9rem; margin-bottom: 8px; }
.timer {
  display: inline-flex; align-items: center; gap: 10px; margin-top: 16px; min-height: 56px; padding: 0 20px;
  border-radius: 14px; border: 2px solid var(--accent); background: var(--accent-soft); color: var(--accent);
  font-size: 1.15rem; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: 0;
}
.timer.running { background: var(--accent); color: var(--accent-ink); }
.timer.ring { background: var(--warn); border-color: var(--warn); color: #fff; animation: pulse 1s infinite; }
@keyframes pulse { 50% { transform: scale(1.04); } }
.cook-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  display: grid; grid-template-columns: 88px 1fr; gap: 10px;
  padding: 12px 14px calc(12px + var(--safe-b)); background: var(--bg); border-top: 1px solid var(--line);
  max-width: 720px; margin: 0 auto;
}
.cook-bar button { height: 76px; border-radius: 18px; font-weight: 800; }
.cook-bar .back { border: 1px solid var(--line); background: var(--surface); font-size: 1rem; color: var(--muted); }
.cook-bar .next { border: 0; background: var(--accent); color: var(--accent-ink); font-size: 1.6rem; }
.cook-done { text-align: center; padding: 48px 20px 40vh; }
.cook-done h2 { font-size: 2.2rem; margin: 0 0 10px; }
.cook-done p { font-size: 1.15rem; color: var(--muted); max-width: 32ch; margin: 0 auto 10px; }
.ing-drawer { padding: 6px 20px 14px; background: var(--surface); border-bottom: 1px solid var(--line); }
.ing-drawer ul { list-style: none; padding: 0; margin: 0; columns: 2; column-gap: 20px; font-size: .95rem; }
.ing-drawer li { padding: 5px 0; break-inside: avoid; }
@media (max-width: 420px) { .ing-drawer ul { columns: 1; } }
.cook-pick a { display: block; padding: 18px 16px; margin-bottom: 10px; font-size: 1.15rem; font-weight: 700; text-decoration: none; color: inherit; }
.cook-pick a span { display: block; font-size: .88rem; color: var(--muted); font-weight: 400; }
