:root {
  --bg: #fbfaf6; --surface: #ffffff; --ink: #1f2420; --muted: #636b64; --line: #e4e2da;
  --brand: #2f6f4f; --brand-ink: #ffffff; --brand-soft: #e5f0e9;
  --warn: #8a5a00; --warn-soft: #fdf1d8; --danger: #a83232; --badge: #c8102e;
  --radius: 10px; --shadow: 0 1px 2px rgba(0,0,0,.05), 0 2px 8px rgba(0,0,0,.04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151816; --surface: #1d211e; --ink: #e8ebe8; --muted: #9aa39c; --line: #2d332f;
    --brand: #5fae85; --brand-ink: #0d1a12; --brand-soft: #22352a;
    --warn: #f0c060; --warn-soft: #3a2f16; --danger: #ef7b7b; --badge: #ff6b6b;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 17px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--brand); }
img { max-width: 100%; }
h1, h2, h3 { line-height: 1.2; margin: 1.2em 0 .5em; }
h1 { font-size: 1.8rem; }
h2 { font-size: 1.25rem; }
main { max-width: 980px; margin: 0 auto; padding: 0 16px 48px; }
footer { max-width: 980px; margin: 0 auto; padding: 16px; color: var(--muted); font-size: .85rem; border-top: 1px solid var(--line); }

/* header */
.top {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 8px 16px; padding-top: max(8px, env(safe-area-inset-top));
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; text-decoration: none; color: var(--ink); font-size: 1.1rem; }
.brand img { border-radius: 6px; }
.top nav { display: flex; gap: 4px; margin-left: auto; flex-wrap: wrap; }
.top nav a { padding: 6px 10px; border-radius: 8px; text-decoration: none; color: var(--ink); font-size: .95rem; }
.top nav a[aria-current="page"] { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.count { font-weight: 700; color: var(--brand); }
.offline-badge { background: var(--warn-soft); color: var(--warn); padding: 2px 8px; border-radius: 99px; margin-right: 8px; font-weight: 600; }

/* buttons + forms */
button, .button {
  display: inline-flex; align-items: center; gap: 6px; font: inherit; font-size: .95rem; cursor: pointer;
  padding: 9px 16px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  text-decoration: none; min-height: 42px;
}
button.primary, .button.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); font-weight: 600; }
button.quiet, .button.quiet { background: transparent; }
button.danger { color: var(--danger); border-color: currentColor; background: transparent; }
button.small { min-height: 32px; padding: 4px 10px; font-size: .85rem; }
button:disabled { opacity: .7; cursor: default; }
input, textarea, select {
  font: inherit; width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); color: var(--ink);
}
input[type="checkbox"], input[type="radio"] { width: auto; accent-color: var(--brand); }
label { display: block; margin: 0 0 14px; font-weight: 600; font-size: .95rem; }
label > input, label > textarea { margin-top: 4px; font-weight: 400; }
label.inline, .pantry-box, .verdicts label { display: inline-flex; align-items: center; gap: 6px; font-weight: 400; margin: 0; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin: 0 0 16px; }
legend { font-weight: 700; padding: 0 6px; }
.hint { color: var(--muted); font-size: .9rem; font-weight: 400; }
.error { color: var(--danger); font-weight: 600; }
.flash { background: var(--brand-soft); color: var(--brand); padding: 10px 14px; border-radius: var(--radius); font-weight: 600; margin-top: 16px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 14px 0; }
.box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.box h1, .box h2 { margin-top: 0; }
.two { display: grid; gap: 20px; grid-template-columns: 1fr; margin-top: 24px; }
@media (min-width: 760px) { .two { grid-template-columns: 1fr 1fr; } }
.three { display: grid; gap: 0 12px; grid-template-columns: 1fr 1fr; }
.three label:last-child { grid-column: 1 / -1; }
@media (min-width: 640px) { .three { grid-template-columns: 1fr 1fr 2fr; } .three label:last-child { grid-column: auto; } }
.narrow { max-width: 560px; }
.row-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.row-head h2 { margin: 1em 0 .5em; }
ul.plain { list-style: none; padding: 0; }
ul.plain li { padding: 8px 0; border-bottom: 1px solid var(--line); }
code { background: var(--brand-soft); padding: 1px 5px; border-radius: 4px; font-size: .9em; }
.copy { display: flex; gap: 8px; }
.copy input { font-family: ui-monospace, monospace; font-size: .85rem; }

/* recipe cards */
.intro p { color: var(--muted); max-width: 60ch; }
.intro { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 0 16px; }
.intro p { flex-basis: 100%; }
.cards { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.card { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; text-decoration: none; color: inherit; box-shadow: var(--shadow); }
.card img, .card .ph { aspect-ratio: 4 / 3; width: 100%; object-fit: cover; }
.card .ph { background: linear-gradient(135deg, var(--brand-soft), var(--bg)); }
.card-body { padding: 10px 14px 14px; }
.card h3 { margin: 0 0 4px; font-size: 1.1rem; }
.card p { margin: 0 0 6px; color: var(--muted); font-size: .92rem; }
.meta { color: var(--muted); font-size: .92rem; }
.tags a { display: inline-block; margin: 0 6px 6px 0; padding: 2px 10px; border-radius: 99px; background: var(--brand-soft); text-decoration: none; font-size: .9rem; }
.tags a[aria-current] { background: var(--brand); color: var(--brand-ink); }
.empty { color: var(--muted); padding: 24px 0; }

/* recipe page */
.banner { margin-top: 16px; padding: 10px 14px; border-radius: var(--radius); background: var(--warn-soft); color: var(--warn); }
.banner.draft { background: var(--brand-soft); color: var(--brand); }
.hero { width: 100%; max-height: 420px; object-fit: cover; border-radius: var(--radius); margin-top: 16px; }
.lead { font-size: 1.1rem; }
.cost { font-size: 1.05rem; }
.recipe-body { display: grid; gap: 0 32px; }
@media (min-width: 820px) { .recipe-body { grid-template-columns: 2fr 3fr; } }
.ingredients { list-style: none; padding: 0; margin: 0; }
.ingredients li { padding: 8px 0; border-bottom: 1px solid var(--line); }
.ingredients li.pantry .itext { color: var(--muted); }
.prod { display: block; font-size: .87rem; color: var(--muted); }
.badge { display: inline-block; background: var(--badge); color: #fff; font-size: .75rem; font-weight: 700; padding: 1px 7px; border-radius: 99px; vertical-align: middle; }
.badge.gone { background: var(--muted); }
.steps { padding-left: 1.4em; }
.steps li { margin-bottom: 12px; padding-left: 4px; }
.notes p { margin: 0 0 8px; }
.reports { margin-top: 24px; }
.report { padding: 10px 0; border-bottom: 1px solid var(--line); }
.report p { margin: 4px 0 0; }
.report-form { margin-top: 12px; }
.report-form textarea { margin: 10px 0; }
.verdicts { display: flex; gap: 18px; }
.manage { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 28px; padding-top: 16px; border-top: 1px solid var(--line); }
.pill { font-size: .8rem; padding: 1px 8px; border-radius: 99px; background: var(--line); color: var(--muted); }
.pill.submitted { background: var(--warn-soft); color: var(--warn); }
.pill.tested { background: var(--brand-soft); color: var(--brand); }

dialog { border: 1px solid var(--line); border-radius: 14px; padding: 18px; width: min(560px, calc(100vw - 24px)); max-height: 85vh; background: var(--surface); color: var(--ink); }
dialog::backdrop { background: rgba(0,0,0,.4); }
dialog h2 { margin-top: 0; }
.add-lines { list-style: none; padding: 0; margin: 0; max-height: 55vh; overflow: auto; }
.add-lines label { display: flex; gap: 10px; align-items: baseline; font-weight: 400; padding: 8px 0; margin: 0; border-bottom: 1px solid var(--line); }

/* editor */
.ing-rows { padding: 0; list-style: none; margin: 0 0 8px; }
.ing-row { display: grid; grid-template-columns: 1fr; gap: 6px; padding: 10px 0; border-bottom: 1px solid var(--line); }
@media (min-width: 700px) { .ing-row { grid-template-columns: 2fr 2fr auto; align-items: center; } }
.ing-row .pick { justify-content: flex-start; text-align: left; font-size: .88rem; min-height: 40px; overflow: hidden; }
.thumb { max-width: 160px; border-radius: 8px; vertical-align: middle; }
.picker-results { list-style: none; padding: 0; margin: 10px 0; max-height: 50vh; overflow: auto; }
.picker-results button { display: block; width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: transparent; }
.picker-results .name { display: block; font-weight: 600; }

/* cook view: big text, ingredients beside the steps */
body.cook { font-size: 21px; }
body.cook .top, body.cook footer { display: none; }
.cook-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; padding-top: 12px; }
.cook-head h1 { margin: 0; flex: 1; }
.cook-head .hint { flex-basis: 100%; }
.cook-body { display: grid; gap: 0 40px; }
@media (min-width: 820px) { .cook-body { grid-template-columns: 1fr 2fr; } main { max-width: 1200px; } }
#cook-steps li { cursor: pointer; padding: 6px 8px; border-radius: 8px; }
#cook-steps li.done { color: var(--muted); text-decoration: line-through; }

/* shopping list */
.list-app { max-width: 640px; }
.list-head { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 0 12px; }
.total { font-weight: 700; color: var(--brand); margin: 0; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; margin: 4px 0 12px; }
.seg button { border: 0; border-radius: 0; min-height: 36px; padding: 6px 12px; }
.seg button[aria-pressed="true"] { background: var(--brand); color: var(--brand-ink); }
.add-free { display: flex; gap: 8px; margin-bottom: 8px; }
.list section h2 { font-size: .85rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 18px 0 4px; }
.list .row-head h2 { margin: 18px 0 4px; }
ul.items { list-style: none; padding: 0; margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.item { display: flex; align-items: stretch; border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: 0; }
.item .tick { flex: 1; display: flex; align-items: flex-start; gap: 12px; border: 0; border-radius: 0; background: transparent; text-align: left; padding: 12px; min-height: 52px; }
.item .box { flex: none; width: 24px; height: 24px; border: 2px solid var(--brand); border-radius: 6px; margin-top: 1px; }
.item.checked .box { background: var(--brand); box-shadow: inset 0 0 0 3px var(--surface); }
.item .what { display: flex; flex-direction: column; }
.item .name { font-weight: 600; }
.item .qty { color: var(--brand); }
.item .for { color: var(--muted); font-size: .85rem; }
.item.checked .name { text-decoration: line-through; color: var(--muted); font-weight: 400; }
.item .del { border: 0; border-radius: 0; background: transparent; color: var(--muted); padding: 0 14px; }
.done ul.items { opacity: .8; }
details.box { margin: 20px 0; }
details.box summary { cursor: pointer; font-weight: 600; }
details.box form { margin-top: 12px; max-width: 360px; }
#connector { margin-top: 20px; }
