:root {
  --bg: #f7f1e8;
  --card: #fffdf9;
  --ink: #2b2420;
  --muted: #7a6d63;
  --line: #e8ddd0;
  --accent: #c2553a;
  --accent-soft: #f6e1d9;
  --sage: #5f8a6a;
  --sage-soft: #e3eee4;
  --gold: #c99a2e;
  --warn: #b5462f;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, ui-serif, serif;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(60,40,20,.06), 0 6px 20px rgba(60,40,20,.08);
}
* { 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; }
body { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
button { font: inherit; color: inherit; cursor: pointer; }
input, select { font: inherit; }

.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 18px 10px; background: rgba(247,241,232,.92); backdrop-filter: blur(12px); }
.brand { margin: 0; font-family: var(--serif); font-size: 26px; font-weight: 700; letter-spacing: -.3px; }
.brand span { display: block; font-family: var(--sans); font-size: 12px; font-weight: 500; color: var(--muted); letter-spacing: .2px; }
.icon-btn { border: 0; background: var(--card); width: 40px; height: 40px; border-radius: 50%; font-size: 20px; box-shadow: var(--shadow); }

main { max-width: 1100px; margin: 0 auto; padding: 4px 16px 24px; }

/* Tabbar */
.tabbar { position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; display: flex; justify-content: space-around;
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); background: rgba(255,253,249,.96); backdrop-filter: blur(12px); border-top: 1px solid var(--line); }
.tabbar button { position: relative; flex: 1; border: 0; background: none; padding: 6px 0; font-size: 11px; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 2px; }
.tabbar button span { font-size: 22px; filter: grayscale(.6); opacity: .7; }
.tabbar button.active { color: var(--accent); font-weight: 600; }
.tabbar button.active span { filter: none; opacity: 1; }
.tabbar b { position: absolute; top: 2px; left: 55%; background: var(--accent); color: #fff; font-size: 10px; border-radius: 10px; padding: 1px 6px; }
.tabbar b:empty { display: none; }

/* Suche + Filter */
.search { position: relative; margin: 6px 0 10px; }
.search input { width: 100%; border: 1px solid var(--line); background: var(--card); border-radius: 14px; padding: 12px 14px 12px 40px; font-size: 16px; outline: none; box-shadow: var(--shadow); }
.search input:focus { border-color: var(--accent); }
.search::before { content: "🔍"; position: absolute; left: 13px; top: 50%; transform: translateY(-50%); font-size: 15px; opacity: .6; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 12px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 7px 13px; font-size: 14px; white-space: nowrap; }
.chip.on { background: var(--ink); color: #fff; border-color: var(--ink); }

.section-title { font-family: var(--serif); font-size: 21px; margin: 18px 2px 10px; }
.count { color: var(--muted); font-size: 13px; margin: 0 2px 10px; }

/* Kartenbox */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; }
@media (min-width: 700px) { .grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); } }
.rcard { border: 0; padding: 0; text-align: left; background: var(--card); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column; transition: transform .15s; }
.rcard:active { transform: scale(.97); }
.rcard .hero { height: 96px; display: grid; place-items: center; font-size: 48px; position: relative; }
.rcard .hero .time { position: absolute; top: 8px; left: 8px; background: rgba(255,255,255,.88); border-radius: 999px; font-size: 12px; font-weight: 600; padding: 3px 8px; }
.rcard .hero .bk { position: absolute; top: 8px; right: 8px; background: rgba(43,36,32,.8); color: #fff; border-radius: 999px; font-size: 11px; padding: 3px 8px; }
.rcard .body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.rcard h3 { margin: 0; font-family: var(--serif); font-size: 17px; line-height: 1.2; }
.rcard .meta { font-size: 12px; color: var(--muted); margin-top: auto; }
.planned-dot { display: inline-block; background: var(--sage); color: #fff; border-radius: 999px; font-size: 11px; padding: 1px 7px; margin-left: 4px; }

.hue-Alltag { background: linear-gradient(135deg, #f3d9b8, #e9b98f); }
.hue-Nostalgie { background: linear-gradient(135deg, #e7c9c0, #c99484); }
.hue-Reste { background: linear-gradient(135deg, #d6e4cf, #a9c5a0); }
.hue-veg { background: linear-gradient(135deg, #dfeccc, #b5d39a); }

/* Detail */
.detail { background: var(--card); border-radius: 24px; overflow: hidden; box-shadow: var(--shadow); margin-top: 6px; }
.detail .hero { padding: 22px 20px 20px; position: relative; }
.detail .hero .emoji { font-size: 64px; line-height: 1; }
.detail .hero h2 { font-family: var(--serif); font-size: 30px; line-height: 1.12; margin: 10px 0 12px; letter-spacing: -.3px; }
.detail .back { position: absolute; top: 14px; right: 14px; border: 0; background: rgba(255,255,255,.85); border-radius: 999px; padding: 7px 12px; font-size: 14px; }
.facts { display: flex; flex-wrap: wrap; gap: 8px; }
.fact { background: rgba(255,255,255,.85); border-radius: 12px; padding: 7px 11px; font-size: 14px; }
.fact b { display: block; font-size: 11px; font-weight: 500; color: var(--muted); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.tag { font-size: 12px; background: rgba(43,36,32,.08); border-radius: 999px; padding: 3px 9px; }
.detail .content { padding: 4px 20px 24px; }
.detail h4 { font-family: var(--serif); font-size: 20px; margin: 22px 0 10px; }
.cols { display: grid; gap: 0 28px; }
@media (min-width: 760px) { .cols { grid-template-columns: 1fr 1.3fr; } }
.ingredients { list-style: none; margin: 0; padding: 0; }
.ingredients li { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.ingredients .amt { min-width: 84px; font-weight: 600; font-variant-numeric: tabular-nums; }
.ingredients .vorrat { color: var(--muted); font-size: 12px; margin-left: auto; }
.steps { margin: 0; padding: 0; list-style: none; counter-reset: s; }
.steps li { counter-increment: s; position: relative; padding: 0 0 14px 40px; line-height: 1.5; }
.steps li::before { content: counter(s); position: absolute; left: 0; top: 0; width: 28px; height: 28px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-weight: 700; display: grid; place-items: center; font-size: 14px; }
.plain { margin: 0; padding-left: 20px; line-height: 1.55; }
.utensils { display: flex; flex-wrap: wrap; gap: 6px; }
.utensils span { background: var(--bg); border-radius: 10px; padding: 5px 10px; font-size: 14px; }
.portion-ctrl { display: flex; align-items: center; gap: 12px; background: var(--bg); border-radius: 14px; padding: 8px 12px; margin-bottom: 8px; }
.portion-ctrl button { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line); background: var(--card); font-size: 18px; }
.portion-ctrl .n { font-weight: 700; font-size: 18px; min-width: 24px; text-align: center; }
.portion-ctrl small { color: var(--muted); }
.macros { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.macro { background: var(--bg); border-radius: 14px; padding: 10px; text-align: center; }
.macro b { display: block; font-size: 20px; font-family: var(--serif); }
.macro span { font-size: 12px; color: var(--muted); }
.note { font-size: 13px; color: var(--muted); margin-top: 6px; }
.infobox { border-radius: 14px; padding: 12px 14px; display: flex; gap: 10px; margin-bottom: 8px; line-height: 1.45; font-size: 15px; }
.infobox.plus { background: var(--sage-soft); }
.infobox.minus { background: #f8e0d8; }
.infobox.info { background: #f4ead2; }
.keep { background: #eef3f7; border-radius: 14px; padding: 12px 14px; line-height: 1.5; font-size: 15px; }
.tip { background: var(--accent-soft); border-radius: 14px; padding: 12px 14px; line-height: 1.5; font-size: 15px; margin-top: 10px; }
.opt-group { margin-bottom: 12px; }
.opt-group .gname { font-weight: 600; margin-bottom: 6px; }
.opt-group .gname small { color: var(--muted); font-weight: 400; }
.opt-items { display: flex; flex-wrap: wrap; gap: 7px; }
.opt { border: 1px solid var(--line); background: var(--card); border-radius: 12px; padding: 7px 11px; font-size: 14px; }
.opt.on { background: var(--sage); color: #fff; border-color: var(--sage); }
.nav-arrows { display: flex; justify-content: space-between; gap: 10px; margin-top: 22px; }
.nav-arrows button { flex: 1; border: 1px solid var(--line); background: var(--bg); border-radius: 14px; padding: 12px; font-size: 14px; }

.btn { border: 0; background: var(--accent); color: #fff; border-radius: 14px; padding: 13px 18px; font-weight: 600; font-size: 16px; width: 100%; }
.btn.sec { background: var(--card); color: var(--ink); border: 1px solid var(--line); }
.btn.small { width: auto; padding: 8px 12px; font-size: 14px; border-radius: 11px; }
.btn.sage { background: var(--sage); }
.row { display: flex; gap: 8px; align-items: center; }
.sticky-cta { position: sticky; bottom: calc(80px + env(safe-area-inset-bottom)); margin-top: 18px; }

/* Woche */
.alert { background: #fff3e8; border-left: 4px solid var(--warn); border-radius: 12px; padding: 12px 14px; margin: 8px 0; box-shadow: var(--shadow); }
.alert.ok { background: var(--sage-soft); border-color: var(--sage); }
.alert .row { margin-top: 8px; flex-wrap: wrap; }
.day { background: var(--card); border-radius: 16px; padding: 12px 14px; margin-bottom: 10px; box-shadow: var(--shadow); }
.day.today { outline: 2px solid var(--accent); }
.day .dname { font-weight: 700; display: flex; justify-content: space-between; align-items: center; }
.day .dname small { color: var(--muted); font-weight: 400; }
.entry { display: flex; align-items: center; gap: 10px; padding: 10px 0 2px; }
.entry .e-emoji { font-size: 28px; }
.entry .e-main { flex: 1; }
.entry .e-main b { font-family: var(--serif); font-size: 17px; }
.entry .e-main small { display: block; color: var(--muted); font-size: 13px; }
.eat-on { font-size: 13px; color: var(--sage); padding: 4px 0; }
.week-nav { display: flex; align-items: center; justify-content: space-between; margin: 6px 0 12px; }
.week-nav button { border: 1px solid var(--line); background: var(--card); border-radius: 12px; padding: 8px 12px; }
.freezer { background: #eaf1f8; }

/* Einkauf */
.list-group { background: var(--card); border-radius: 16px; padding: 6px 14px; margin-bottom: 12px; box-shadow: var(--shadow); }
.list-group h5 { margin: 10px 0 4px; font-size: 13px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
.litem { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.litem:last-child { border-bottom: 0; }
.litem .box { width: 24px; height: 24px; border-radius: 7px; border: 2px solid var(--line); flex: none; display: grid; place-items: center; font-size: 14px; color: #fff; }
.litem.done .box { background: var(--sage); border-color: var(--sage); }
.litem.done .lname { text-decoration: line-through; color: var(--muted); }
.litem .lname { flex: 1; }
.litem .lamt { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 14px; }
.litem .from { display: block; font-size: 12px; color: var(--muted); }
.add-row { display: flex; gap: 8px; margin: 8px 0 14px; }
.add-row input { flex: 1; border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px; background: var(--card); }
.day-head { font-family: var(--serif); font-size: 19px; margin: 18px 2px 8px; }
.day-head small { font-family: var(--sans); font-size: 13px; color: var(--muted); }

/* Vorrat */
.pantry-item { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.pantry-item .pname { flex: 1; }
.toggle { border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; font-size: 13px; background: var(--sage-soft); }
.toggle.fehlt { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Sheet */
#sheet-backdrop { position: fixed; inset: 0; background: rgba(30,20,10,.35); z-index: 40; }
#sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; background: var(--card); border-radius: 24px 24px 0 0; max-height: 88vh; overflow-y: auto;
  padding: 18px 18px calc(20px + env(safe-area-inset-bottom)); box-shadow: 0 -10px 40px rgba(0,0,0,.15); max-width: 640px; margin: 0 auto; }
#sheet h3 { font-family: var(--serif); font-size: 23px; margin: 4px 0 14px; }
#sheet label { display: block; font-size: 13px; color: var(--muted); margin: 14px 0 6px; }
#sheet input[type=date], #sheet input[type=password], #sheet input[type=number], #sheet input[type=text] { width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px; background: var(--bg); }
#sheet input[type=range] { width: 100%; }
.sheet-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 20px; }

#toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(90px + env(safe-area-inset-bottom)); background: var(--ink); color: #fff; border-radius: 12px; padding: 10px 16px; z-index: 60; font-size: 14px; max-width: 90vw; }
.empty { text-align: center; color: var(--muted); padding: 40px 10px; line-height: 1.5; }
.empty .big { font-size: 48px; }
.login { max-width: 360px; margin: 60px auto; text-align: center; }
.login input { width: 100%; text-align: center; font-size: 24px; letter-spacing: 8px; border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin: 16px 0; background: var(--card); }
.offline { background: #f4ead2; border-radius: 10px; padding: 6px 10px; font-size: 13px; margin: 4px 0 8px; text-align: center; }
