:root {
  --bg: #f5f4f0;
  --surface: #ffffff;
  --surface-2: #efeee9;
  --text: #1d1f1e;
  --muted: #6b706d;
  --line: #e2e0da;
  --accent: #2f7d5b;
  --accent-soft: #dcefe5;
  --accent-text: #ffffff;
  --warn: #b5522e;
  --warn-soft: #f8e3da;
  --star: #d69a12;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.05);
  --radius: 14px;
  --nav-h: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141615;
    --surface: #1d201f;
    --surface-2: #262a28;
    --text: #e9ebe9;
    --muted: #9aa19d;
    --line: #2f3432;
    --accent: #5cbf91;
    --accent-soft: #1f3a2e;
    --accent-text: #0d1a14;
    --warn: #e8875f;
    --warn-soft: #3b241b;
    --star: #f0b93a;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
img { max-width: 100%; display: block; }

/* ---------- Layout ---------- */
.shell { min-height: 100dvh; padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 16px); }
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 12px;
  padding: calc(env(safe-area-inset-top) + 12px) 16px 12px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
}
.topbar h1 { font-size: 22px; margin: 0; flex: 1; letter-spacing: -.01em; }
.page { max-width: 760px; margin: 0 auto; padding: 0 16px; }

.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: center;
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav a {
  flex: 1; max-width: 160px; height: var(--nav-h);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--muted); text-decoration: none; font-size: 12px; font-weight: 500;
}
.nav a svg { width: 24px; height: 24px; }
.nav a.active { color: var(--accent); }
.nav .badge {
  position: absolute; transform: translate(14px, -12px);
  background: var(--accent); color: var(--accent-text);
  border-radius: 9px; font-size: 11px; min-width: 18px; height: 18px; line-height: 18px;
  text-align: center; padding: 0 5px; font-weight: 600;
}

@media (min-width: 900px) {
  .shell { padding-bottom: 24px; padding-left: 220px; }
  .nav {
    top: 0; right: auto; width: 220px; flex-direction: column; justify-content: flex-start;
    border-top: 0; border-right: 1px solid var(--line); padding: 24px 12px; gap: 4px;
  }
  .nav a { flex: none; max-width: none; height: 44px; flex-direction: row; justify-content: flex-start;
    gap: 12px; padding: 0 12px; font-size: 15px; border-radius: 10px; }
  .nav a.active { background: var(--accent-soft); }
  .nav .badge { position: static; transform: none; margin-left: auto; }
  .nav .brand { display: block; }
}
.nav .brand { display: none; font-weight: 700; font-size: 18px; padding: 0 12px 16px; }

/* ---------- Bausteine ---------- */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--line); }
.section-title { font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase;
  letter-spacing: .05em; margin: 22px 4px 8px; display: flex; align-items: center; gap: 8px; }
.section-title .count { font-weight: 500; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; align-items: center; gap: 8px; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.spacer { height: 12px; }
.empty { text-align: center; color: var(--muted); padding: 40px 16px; }
.empty .big { font-size: 40px; margin-bottom: 8px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 42px; padding: 0 16px; border-radius: 11px; border: 1px solid var(--line);
  background: var(--surface); cursor: pointer; font-weight: 500; white-space: nowrap; text-decoration: none; color: var(--text);
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.danger { color: var(--warn); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.small { height: 34px; padding: 0 12px; font-size: 14px; border-radius: 9px; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 10px; border: 0; background: transparent;
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer; color: var(--muted); flex: none;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn.on { color: var(--star); }

input[type=text], input[type=password], input[type=number], input[type=date], input[type=search], input[type=url], select, textarea {
  width: 100%; height: 44px; padding: 0 12px; border-radius: 11px;
  border: 1px solid var(--line); background: var(--surface); outline: none;
}
textarea { height: auto; min-height: 96px; padding: 10px 12px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 6px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; height: 34px; padding: 0 14px; border-radius: 17px; border: 1px solid var(--line);
  background: var(--surface); cursor: pointer; font-size: 14px; display: inline-flex; align-items: center; gap: 6px;
}
.chip.on { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.tag { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 8px; background: var(--surface-2); color: var(--muted); }
.tag.accent { background: var(--accent-soft); color: var(--accent); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }

/* Schnell-Eingabe */
.quick-add { display: flex; gap: 8px; margin: 4px 0 8px; }
.quick-add input { height: 48px; font-size: 16px; }
.quick-add .btn { height: 48px; width: 48px; padding: 0; }

/* Listen */
.list { overflow: hidden; }
.item { display: flex; align-items: center; gap: 10px; padding: 10px 8px 10px 12px; border-bottom: 1px solid var(--line); min-height: 56px; }
.item:last-child { border-bottom: 0; }
.item .body { flex: 1; min-width: 0; cursor: pointer; }
.item .title { overflow-wrap: anywhere; }
.item .meta { font-size: 13px; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; margin-top: 2px; }
.item.done .title { text-decoration: line-through; color: var(--muted); }
.check {
  width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--line); flex: none;
  background: transparent; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; padding: 0;
}
.check svg { width: 16px; height: 16px; opacity: 0; color: var(--accent-text); }
.check.on { background: var(--accent); border-color: var(--accent); }
.check.on svg { opacity: 1; }
.check.square { border-radius: 8px; }
.prio { color: var(--warn); font-weight: 700; }

/* Rezepte */
.recipe-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.recipe-card { overflow: hidden; cursor: pointer; display: flex; flex-direction: column; position: relative; }
.recipe-card .img { aspect-ratio: 4/3; background: var(--surface-2); display: flex; align-items: center; justify-content: center; font-size: 40px; }
.recipe-card .img img { width: 100%; height: 100%; object-fit: cover; }
.recipe-card .info { padding: 10px 12px 12px; }
.recipe-card .name { font-weight: 600; line-height: 1.25; overflow-wrap: anywhere; }
.recipe-card .meta { font-size: 12px; color: var(--muted); margin-top: 4px; display: flex; gap: 6px; flex-wrap: wrap; }
.recipe-card .fav { position: absolute; top: 8px; right: 8px; background: rgba(0,0,0,.45); color: #fff; border-radius: 50%;
  width: 30px; height: 30px; display: flex; align-items: center; justify-content: center; font-size: 15px; }
.recipe-card .saved { position: absolute; top: 8px; left: 8px; }

.hero { border-radius: var(--radius); overflow: hidden; aspect-ratio: 16/9; background: var(--surface-2); margin-bottom: 14px; }
.hero img { width: 100%; height: 100%; object-fit: cover; }
.recipe-head h2 { margin: 0 0 6px; font-size: 24px; line-height: 1.2; }
.ingredients .item { min-height: 48px; }
.steps { white-space: pre-wrap; padding: 14px 16px; line-height: 1.6; }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 11px; overflow: hidden; }
.stepper button { width: 38px; height: 38px; border: 0; background: var(--surface); cursor: pointer; font-size: 18px; }
.stepper span { min-width: 92px; text-align: center; font-size: 14px; }
.tabs { display: flex; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 12px; margin-bottom: 12px; }
.tabs button { flex: 1; height: 36px; border: 0; border-radius: 9px; background: transparent; cursor: pointer; font-weight: 500; color: var(--muted); }
.tabs button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.filter-box { padding: 14px; margin-bottom: 14px; }
.toggle { display: flex; align-items: center; gap: 10px; cursor: pointer; padding: 6px 0; }
.toggle input { width: 20px; height: 20px; accent-color: var(--accent); }

/* Sheet / Dialog */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 50; display: flex; align-items: flex-end; justify-content: center; animation: fade .15s; }
.sheet {
  background: var(--bg); width: 100%; max-width: 640px; max-height: 92dvh; overflow-y: auto;
  border-radius: 20px 20px 0 0; padding: 8px 16px calc(16px + env(safe-area-inset-bottom)); animation: up .2s ease-out;
}
.sheet .grabber { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 4px auto 12px; }
.sheet h3 { margin: 0 0 14px; font-size: 19px; }
.sheet .actions { display: flex; gap: 8px; margin-top: 16px; position: sticky; bottom: 0; background: var(--bg); padding-top: 8px; }
.sheet .actions .btn { flex: 1; }
@media (min-width: 700px) {
  .overlay { align-items: center; }
  .sheet { border-radius: 20px; max-height: 86dvh; }
}
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 16px); transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; z-index: 60;
  font-size: 14px; display: flex; gap: 12px; align-items: center; max-width: calc(100% - 32px); animation: up .2s;
}
.toast button { background: none; border: 0; color: var(--accent); font-weight: 700; cursor: pointer; }
@media (prefers-color-scheme: dark) { .toast button { color: #1f6d4b; } }

.suggest-list { position: absolute; left: 0; right: 56px; top: 52px; z-index: 5; overflow: hidden; }
.suggest-list button { display: flex; width: 100%; padding: 10px 14px; border: 0; background: var(--surface); text-align: left; cursor: pointer; gap: 8px; }
.suggest-list button:hover, .suggest-list button:focus { background: var(--surface-2); }

/* Login */
.login { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login .card { width: 100%; max-width: 360px; padding: 28px 22px; }
.login h1 { margin: 0 0 4px; font-size: 26px; }
.error { color: var(--warn); font-size: 14px; min-height: 20px; margin: 6px 0; }
.spinner { width: 22px; height: 22px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; margin: 30px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
