:root {
  --bg: #F7F3EC;
  --surface: #FFFFFF;
  --ink: #22201C;
  --muted: #6F6A62;
  --line: #E7E0D4;
  --primary: #2F4A3A;
  --primary-soft: #E3ECE4;
  --accent: #E07A4F;
  --accent-soft: #FBE7DC;
  --sage: #7FA36B;
  --danger: #B9442C;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(34, 32, 28, .06), 0 4px 16px rgba(34, 32, 28, .06);
  --safe-b: env(safe-area-inset-bottom, 0px);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-tap-highlight-color: transparent;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); }
body { font-size: 16px; line-height: 1.45; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -0.01em; }
.splash { display: grid; place-items: center; height: 100vh; font-size: 56px; }

/* ---------- Layout ---------- */
.screen { max-width: 640px; margin: 0 auto; padding: 16px 16px calc(96px + var(--safe-b)); }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 0 14px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 22px; color: var(--primary); }
.brand img { width: 32px; height: 32px; border-radius: 9px; }
.section-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 22px 4px 10px; }

/* ---------- Buttons ---------- */
.btn { border: 0; border-radius: 999px; padding: 14px 20px; font-weight: 700; background: var(--primary); color: #fff; display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; transition: transform .08s ease, opacity .2s; }
.btn:active { transform: scale(.98); }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn.block { width: 100%; }
.btn.accent { background: var(--accent); }
.btn.ghost { background: transparent; color: var(--primary); border: 1.5px solid var(--line); }
.btn.soft { background: var(--primary-soft); color: var(--primary); }
.btn.small { min-height: 38px; padding: 8px 14px; font-size: 14px; }
.icon-btn { border: 0; background: var(--surface); width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; font-size: 19px; box-shadow: var(--shadow); }
.link { background: none; border: 0; color: var(--primary); font-weight: 600; padding: 6px; text-decoration: underline; text-underline-offset: 3px; }

/* ---------- Karten ---------- */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.hero { background: var(--primary); color: #fff; border-radius: 24px; padding: 18px 18px 16px; }
.hero .label { opacity: .75; font-size: 13px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }
.hero .total { font-size: 32px; font-weight: 800; margin-top: 4px; }
.hero .total small { font-size: 15px; font-weight: 500; opacity: .8; }
.bar { height: 8px; background: rgba(255, 255, 255, .18); border-radius: 99px; overflow: hidden; margin: 12px 0 4px; }
.bar > i { display: block; height: 100%; background: #CFE3B8; border-radius: 99px; }
.bar.over > i { background: #F2A27E; }
.hero .meta { display: flex; justify-content: space-between; font-size: 13px; opacity: .85; }
.note { background: var(--accent-soft); border-radius: 14px; padding: 12px 14px; font-size: 14px; margin-top: 12px; color: #6A3420; }
.note.info { background: var(--primary-soft); color: var(--primary); }

/* ---------- Tagesleiste ---------- */
.daystrip { display: flex; gap: 6px; overflow-x: auto; padding: 14px 2px 4px; scrollbar-width: none; }
.daystrip::-webkit-scrollbar { display: none; }
.daypill { flex: 0 0 auto; border: 0; background: var(--surface); border-radius: 16px; padding: 8px 0; width: 46px; text-align: center; box-shadow: var(--shadow); }
.daypill b { display: block; font-size: 17px; }
.daypill span { font-size: 11px; color: var(--muted); font-weight: 700; }
.daypill.off { opacity: .35; box-shadow: none; background: transparent; }
.daypill.today { outline: 2px solid var(--accent); }

/* ---------- Rezeptkarten ---------- */
.day-head { display: flex; align-items: baseline; gap: 8px; margin: 22px 4px 8px; }
.day-head h3 { font-size: 18px; }
.day-head span { color: var(--muted); font-size: 14px; }
.recipe { display: flex; gap: 14px; align-items: center; width: 100%; text-align: left; border: 0; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px; }
.recipe .emoji { flex: 0 0 72px; height: 72px; border-radius: 16px; background: var(--accent-soft); display: grid; place-items: center; font-size: 38px; }
.recipe .body { min-width: 0; flex: 1; }
.recipe h4 { margin: 4px 0 2px; font-size: 16px; line-height: 1.25; }
.recipe .desc { font-size: 13px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.recipe .facts { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); margin-top: 4px; }
.recipe .facts b { color: var(--ink); }
.tags { display: flex; gap: 6px; flex-wrap: wrap; }
.tag { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 99px; background: var(--primary-soft); color: var(--primary); }
.tag.offer { background: var(--accent-soft); color: #A2492A; }

/* ---------- Assistent ---------- */
.wizard { max-width: 640px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; padding: 14px 18px calc(18px + var(--safe-b)); }
.wizard-top { display: flex; align-items: center; gap: 12px; }
.progress { display: flex; gap: 6px; flex: 1; }
.progress i { flex: 1; height: 5px; border-radius: 9px; background: var(--line); }
.progress i.on { background: var(--primary); }
.wizard h2 { font-size: 27px; margin: 26px 0 6px; }
.wizard .sub { color: var(--muted); margin: 0 0 20px; font-size: 15px; }
.wizard .content { flex: 1; }
.wizard .actions { padding-top: 16px; position: sticky; bottom: 0; background: linear-gradient(transparent, var(--bg) 30%); }

.grid-markets { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.market { border: 2px solid transparent; background: var(--surface); border-radius: 16px; padding: 18px 10px; font-weight: 800; font-size: 17px; box-shadow: var(--shadow); }
.market.on { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1.5px solid var(--line); background: var(--surface); border-radius: 99px; padding: 9px 14px; font-size: 15px; display: inline-flex; gap: 6px; align-items: center; }
.chip.on { background: var(--primary); border-color: var(--primary); color: #fff; }
.chip.on::before { content: "✓"; font-weight: 800; }

.budget-value { text-align: center; font-size: 64px; font-weight: 800; color: var(--primary); margin: 10px 0 0; }
.budget-value small { font-size: 26px; }
.center-muted { text-align: center; color: var(--muted); margin-bottom: 12px; }
input[type=range] { width: 100%; accent-color: var(--primary); height: 32px; }
.range-legend { display: flex; justify-content: space-between; color: var(--muted); font-size: 13px; }

.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.row .title { font-weight: 700; }
.row .hint { font-size: 13px; color: var(--muted); }
.stepper { display: flex; align-items: center; gap: 12px; }
.stepper button { width: 38px; height: 38px; border-radius: 50%; border: 0; background: var(--primary-soft); color: var(--primary); font-size: 20px; font-weight: 800; }
.stepper b { min-width: 22px; text-align: center; font-size: 18px; }
.switch { position: relative; width: 52px; height: 30px; flex: 0 0 auto; }
.switch input { opacity: 0; width: 0; height: 0; }
.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; background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch input:checked + span { background: var(--primary); }
.switch input:checked + span::after { transform: translateX(22px); }

.days { display: flex; justify-content: space-between; gap: 6px; }
.dayc { flex: 1; aspect-ratio: 1; max-width: 52px; border-radius: 50%; border: 0; background: var(--surface); box-shadow: var(--shadow); font-weight: 800; font-size: 16px; }
.dayc.on { background: var(--primary); color: #fff; }
.segmented { display: flex; background: var(--line); border-radius: 99px; padding: 4px; }
.segmented button { flex: 1; border: 0; background: transparent; border-radius: 99px; padding: 10px; font-weight: 700; color: var(--muted); }
.segmented button.on { background: var(--surface); color: var(--primary); box-shadow: var(--shadow); }

.field { display: block; margin: 12px 0; }
.field span { display: block; font-size: 13px; font-weight: 700; color: var(--muted); margin-bottom: 6px; }
.field input, .field textarea, .field select { width: 100%; border: 1.5px solid var(--line); background: var(--surface); border-radius: 14px; padding: 12px 14px; outline: none; }
.field input:focus, .field textarea:focus { border-color: var(--primary); }

/* ---------- Einkaufsliste ---------- */
.list-group { margin-top: 8px; }
.item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); background: var(--surface); }
.list-card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.list-card .item:last-child { border-bottom: 0; }
.check { width: 26px; height: 26px; border-radius: 8px; border: 2px solid var(--line); background: #fff; flex: 0 0 auto; display: grid; place-items: center; color: #fff; font-weight: 900; font-size: 15px; }
.item.done .check { background: var(--sage); border-color: var(--sage); }
.item .main { flex: 1; min-width: 0; }
.item .name { font-weight: 650; }
.item.done .name { text-decoration: line-through; color: var(--muted); }
.item .sub { font-size: 12.5px; color: var(--muted); }
.item .price { font-weight: 700; white-space: nowrap; text-align: right; }
.item .price s { display: block; font-size: 12px; color: var(--muted); font-weight: 500; }
.item .del { border: 0; background: none; color: var(--muted); font-size: 18px; padding: 4px; }
.mk { font-size: 11px; font-weight: 800; padding: 2px 7px; border-radius: 6px; background: var(--line); color: var(--ink); margin-right: 4px; }
.summary-row { display: flex; gap: 10px; margin-top: 12px; }
.summary-row .card { flex: 1; padding: 12px 14px; }
.summary-row .k { font-size: 12px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.summary-row .v { font-size: 20px; font-weight: 800; }
details.pantry { margin-top: 16px; }
details.pantry summary { cursor: pointer; color: var(--muted); font-weight: 600; padding: 8px 4px; }

/* ---------- Bottom-Navigation ---------- */
.nav { position: fixed; left: 0; right: 0; bottom: 0; background: rgba(255,255,255,.96); backdrop-filter: blur(10px); border-top: 1px solid var(--line); display: flex; justify-content: center; padding-bottom: var(--safe-b); z-index: 20; }
.nav-inner { display: flex; width: 100%; max-width: 640px; }
.nav button { flex: 1; border: 0; background: none; padding: 9px 4px 10px; font-size: 11.5px; font-weight: 700; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 2px; }
.nav button .ico { font-size: 21px; line-height: 1; filter: grayscale(1); opacity: .7; }
.nav button.on { color: var(--primary); }
.nav button.on .ico { filter: none; opacity: 1; }
.nav .badge { position: relative; }
.nav .badge em { position: absolute; top: -4px; right: -12px; font-style: normal; background: var(--accent); color: #fff; font-size: 10px; border-radius: 99px; padding: 1px 5px; }

/* ---------- Sheet (Rezept / Dialoge) ---------- */
.backdrop { position: fixed; inset: 0; background: rgba(20, 20, 18, .45); z-index: 40; display: flex; align-items: flex-end; justify-content: center; animation: fade .2s; }
.sheet { background: var(--bg); width: 100%; max-width: 640px; max-height: 92vh; overflow-y: auto; border-radius: 26px 26px 0 0; padding: 10px 18px calc(24px + var(--safe-b)); animation: up .25s ease; }
.sheet .grab { width: 44px; height: 5px; border-radius: 9px; background: var(--line); margin: 2px auto 12px; }
.sheet-head { display: flex; gap: 14px; align-items: center; }
.sheet-head .emoji { font-size: 46px; width: 76px; height: 76px; border-radius: 20px; background: var(--accent-soft); display: grid; place-items: center; flex: 0 0 auto; }
.sheet h2 { font-size: 22px; }
.facts-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 16px 0 6px; }
.facts-grid div { background: var(--surface); border-radius: 14px; padding: 10px 6px; text-align: center; box-shadow: var(--shadow); }
.facts-grid b { display: block; font-size: 16px; }
.facts-grid span { font-size: 11px; color: var(--muted); font-weight: 700; }
.ingredients { list-style: none; padding: 0; margin: 0; }
.ingredients li { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.ingredients li span:first-child { color: var(--muted); white-space: nowrap; }
.steps { padding-left: 0; list-style: none; counter-reset: s; margin: 0; }
.steps li { counter-increment: s; display: flex; gap: 12px; padding: 10px 0; }
.steps li::before { content: counter(s); flex: 0 0 28px; height: 28px; border-radius: 50%; background: var(--primary); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 14px; }
.sheet-actions { display: flex; gap: 10px; margin-top: 18px; }
.sheet-actions .btn { flex: 1; }

/* ---------- Ladebildschirm ---------- */
.loading { position: fixed; inset: 0; background: var(--bg); z-index: 60; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 30px; text-align: center; }
.pot { font-size: 84px; animation: bob 1.4s ease-in-out infinite; }
.loading h2 { font-size: 24px; margin: 18px 0 8px; }
.loading p { color: var(--muted); min-height: 1.5em; }
.loading .bar { background: var(--line); width: 240px; }
.loading .bar > i { background: var(--primary); width: 40%; animation: slide 1.6s ease-in-out infinite; }

/* ---------- Leere Zustände, Toast ---------- */
.empty { text-align: center; padding: 50px 20px; color: var(--muted); }
.empty .big { font-size: 64px; }
.empty h2 { color: var(--ink); margin: 12px 0 6px; }
#toast { position: fixed; left: 50%; bottom: calc(86px + var(--safe-b)); transform: translateX(-50%) translateY(20px); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 14px; font-size: 14px; opacity: 0; pointer-events: none; transition: .25s; z-index: 80; max-width: calc(100% - 32px); }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.login { max-width: 360px; margin: 18vh auto 0; padding: 20px; text-align: center; }
.login input { text-align: center; font-size: 24px; letter-spacing: .3em; }

@keyframes up { from { transform: translateY(40px); opacity: .4; } }
@keyframes fade { from { opacity: 0; } }
@keyframes bob { 50% { transform: translateY(-10px) rotate(-4deg); } }
@keyframes slide { 0% { transform: translateX(-100%); } 100% { transform: translateX(260%); } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
