:root {
  --bg: #f6f4ee; --card: #ffffff; --ink: #1d2420; --muted: #6d756f; --line: #e5e2d9;
  --brand: #1f5c45; --brand-soft: #dcebe3; --warn: #c2541f; --warn-soft: #f8e3d6; --ok: #2f8a5b; --ok-soft: #dff1e6;
  --amber: #e8a23a; --radius: 16px; --tabh: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #121614; --card: #1b201d; --ink: #e9ede9; --muted: #95a099; --line: #2a312d;
    --brand: #5fbf91; --brand-soft: #1f3a2e; --warn: #f08a5d; --warn-soft: #3a2519; --ok: #5fbf91; --ok-soft: #1c3428; }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { padding-bottom: calc(var(--tabh) + var(--safe-b) + 16px); font-size: 16px; line-height: 1.35; }
button, input, select, textarea { font: inherit; color: inherit; }
svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
a { color: var(--brand); }

/* Kopf */
.head { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 14px 16px 10px; }
.head h1 { margin: 0 0 10px; font-size: 28px; letter-spacing: -0.02em; display: flex; align-items: baseline; gap: 8px; }
.head h1 small { font-size: 15px; font-weight: 500; color: var(--muted); }
.search { width: 100%; border: 1px solid var(--line); background: var(--card); border-radius: 12px; padding: 12px 14px; font-size: 16px; outline: none; }
.search:focus { border-color: var(--brand); }
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 10px 0 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 6px 12px; font-size: 14px; }
.chip.on { background: var(--brand); border-color: var(--brand); color: var(--bg); }

.wrap { padding: 0 16px; }
.section { margin: 18px 0 8px; font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); display: flex; justify-content: space-between; align-items: center; }
.empty { text-align: center; color: var(--muted); padding: 40px 20px; }

/* Listen */
.list { background: var(--card); border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; min-height: 56px; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.row .main { flex: 1; min-width: 0; }
.row .title { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.row.tap { cursor: pointer; }
.row.done .title { text-decoration: line-through; color: var(--muted); }

.check { flex: none; width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; background: none; padding: 0; }
.check.on { background: var(--ok); border-color: var(--ok); color: #fff; }
.check svg { width: 16px; height: 16px; stroke-width: 3; }

.qty { flex: none; font-variant-numeric: tabular-nums; background: var(--brand-soft); color: var(--brand); border: 0; border-radius: 10px; padding: 6px 10px; font-weight: 600; font-size: 14px; }

.stepper { flex: none; display: flex; align-items: center; background: var(--bg); border-radius: 12px; }
.stepper button { width: 40px; height: 40px; border: 0; background: none; font-size: 22px; color: var(--brand); }
.stepper .val { min-width: 52px; text-align: center; font-variant-numeric: tabular-nums; font-weight: 600; border: 0; background: none; padding: 0; }
.stepper .val small { display: block; font-size: 11px; font-weight: 400; color: var(--muted); }
.zero .stepper .val { color: var(--muted); }

.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.dot.ok { background: var(--ok); } .dot.no { background: var(--warn); } .dot.part { background: var(--amber); }
.pill { font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 999px; flex: none; }
.pill.ok { background: var(--ok-soft); color: var(--ok); } .pill.no { background: var(--warn-soft); color: var(--warn); }
.pill.plan { background: var(--brand); color: var(--bg); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 14px; padding: 14px 18px; font-weight: 600; background: var(--brand); color: var(--bg); width: 100%; font-size: 16px; }
.btn.ghost { background: var(--brand-soft); color: var(--brand); }
.btn.danger { background: var(--warn-soft); color: var(--warn); }
.btn.small { padding: 8px 12px; font-size: 14px; width: auto; border-radius: 10px; }
.btn:disabled { opacity: 0.45; }
.btns { display: grid; gap: 10px; margin: 16px 0; }
.btns.two { grid-template-columns: 1fr 1fr; }
.link { background: none; border: 0; color: var(--brand); font-weight: 600; font-size: 14px; padding: 4px; }

.fab { position: fixed; right: 18px; bottom: calc(var(--tabh) + var(--safe-b) + 18px); width: 58px; height: 58px; border-radius: 18px; border: 0; background: var(--brand); color: var(--bg); box-shadow: 0 6px 20px rgba(0,0,0,.18); display: grid; place-items: center; z-index: 6; }
.fab svg { width: 28px; height: 28px; stroke-width: 2.2; }

/* Autocomplete */
.suggest { margin-top: 6px; }
.suggest .row { min-height: 48px; padding: 10px 14px; }
.suggest .new { color: var(--brand); font-weight: 600; }

/* Tab-Leiste */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: grid; grid-template-columns: repeat(4, 1fr); height: calc(var(--tabh) + var(--safe-b)); padding-bottom: var(--safe-b); background: var(--card); border-top: 1px solid var(--line); }
.tabs a { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; text-decoration: none; color: var(--muted); font-size: 12px; font-weight: 500; }
.tabs a.on { color: var(--brand); }
.tabs a.on svg { stroke-width: 2.2; }
.badge { position: absolute; top: 8px; left: calc(50% + 6px); background: var(--warn); color: #fff; font-size: 11px; font-weight: 700; border-radius: 999px; padding: 1px 6px; min-width: 18px; text-align: center; }
.badge:empty { display: none; }

/* Bottom-Sheet */
.sheetWrap { position: fixed; inset: 0; z-index: 20; }
.sheetBackdrop { position: absolute; inset: 0; background: rgba(0,0,0,.4); animation: fade .2s; }
.sheet { position: absolute; left: 0; right: 0; bottom: 0; max-height: 92vh; overflow-y: auto; background: var(--card); border-radius: 22px 22px 0 0; padding: 8px 18px calc(20px + var(--safe-b)); animation: up .22s ease-out; }
.grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 4px auto 12px; }
.sheet h2 { margin: 4px 0 4px; font-size: 22px; letter-spacing: -0.01em; }
.sheet .lead { color: var(--muted); margin: 0 0 12px; font-size: 14px; }
@keyframes up { from { transform: translateY(100%); } }
@keyframes fade { from { opacity: 0; } }

/* Formulare */
.field { display: block; margin: 12px 0; }
.field > span { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.field input, .field select, .field textarea { width: 100%; border: 1px solid var(--line); background: var(--bg); border-radius: 12px; padding: 12px; font-size: 16px; outline: none; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--brand); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid2 .field { margin: 6px 0; }
.ing { display: grid; grid-template-columns: 1fr 76px 36px; gap: 6px; align-items: center; margin-bottom: 8px; }
.ing input { width: 100%; border: 1px solid var(--line); background: var(--bg); border-radius: 10px; padding: 10px; font-size: 15px; }
.ing .u { grid-column: 1 / -1; font-size: 12px; color: var(--muted); margin-top: -4px; padding-left: 4px; }
.ing .u select { border: 0; background: none; color: var(--brand); font-size: 12px; padding: 0; }
.iconbtn { border: 0; background: none; color: var(--muted); width: 36px; height: 36px; display: grid; place-items: center; padding: 0; }
.codes { display: flex; flex-wrap: wrap; gap: 6px; }
.codes span { background: var(--bg); border-radius: 8px; padding: 4px 8px; font-size: 13px; font-family: ui-monospace, monospace; display: inline-flex; gap: 6px; align-items: center; }
.codes button { border: 0; background: none; color: var(--warn); padding: 0; font-size: 16px; }

/* Gericht-Detail */
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--brand); text-decoration: none; font-weight: 600; margin-bottom: 6px; }
.back svg { width: 20px; height: 20px; }
.meta { color: var(--muted); font-size: 14px; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.need { font-variant-numeric: tabular-nums; font-size: 14px; text-align: right; flex: none; }
.need small { display: block; font-size: 12px; color: var(--muted); }
.planCard { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.planCard a { flex: none; width: 160px; text-decoration: none; color: var(--ink); background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.planCard a b { display: block; font-size: 15px; margin-bottom: 6px; line-height: 1.25; }
.planCard a span { font-size: 13px; color: var(--muted); }

/* Scanner */
.scanBox { position: relative; border-radius: 20px; overflow: hidden; background: #000; aspect-ratio: 4 / 3; }
#reader { width: 100%; height: 100%; }
#reader video { width: 100% !important; height: 100% !important; object-fit: cover; }
.scanHint { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; text-align: center; padding: 20px; font-size: 15px; }
.scanFrame { position: absolute; left: 12%; right: 12%; top: 30%; bottom: 30%; border: 3px solid rgba(255,255,255,.85); border-radius: 14px; pointer-events: none; box-shadow: 0 0 0 999px rgba(0,0,0,.25); }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 3px; margin: 12px 0; }
.seg button { border: 0; background: none; border-radius: 9px; padding: 9px 4px; font-size: 14px; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--brand); color: var(--bg); }
.manual { display: flex; gap: 8px; }
.manual input { flex: 1; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabh) + var(--safe-b) + 90px); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px; z-index: 30; max-width: 90vw; box-shadow: 0 6px 20px rgba(0,0,0,.2); }
.offline { background: var(--warn-soft); color: var(--warn); text-align: center; font-size: 13px; padding: 6px; }

/* Bilder zu Gerichten */
.thumb { position: relative; flex: none; width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center;
  background: hsl(var(--h, 140) 70% 91%); background-size: cover; background-position: center; }
@media (prefers-color-scheme: dark) { .thumb { background-color: hsl(var(--h, 140) 25% 22%); } }
.thumb.photo { background-color: var(--line); }
.thumb .emo { font-size: 30px; line-height: 1; }
.thumb .dot { position: absolute; right: -3px; bottom: -3px; width: 14px; height: 14px; border: 2.5px solid var(--card); }
.thumb.card { width: 100%; height: 84px; border-radius: 12px; margin-bottom: 8px; }
.thumb.card .emo { font-size: 44px; }
.thumb.hero { width: 100%; height: 180px; border-radius: 20px; margin: 6px 0 12px; }
.thumb.hero .emo { font-size: 92px; }
.thumb.edit { width: 88px; height: 88px; border-radius: 18px; }
.thumb.edit .emo { font-size: 50px; }
.planCard a { width: 150px; }
.imgEdit { display: flex; gap: 14px; align-items: center; }
.imgBtns { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.imgBtns .btn { cursor: pointer; }
.emojiGrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 6px; margin-top: 12px; max-height: 150px; overflow-y: auto; }
.emojiGrid button { height: 44px; border: 1px solid var(--line); background: var(--bg); border-radius: 12px; font-size: 24px; padding: 0; }
.emojiGrid button[data-e=""] { font-size: 13px; font-weight: 600; color: var(--brand); }
.emojiGrid button.on { border: 2px solid var(--brand); background: var(--brand-soft); }
