:root {
  --bg: #f6f4ef;
  --card: #ffffff;
  --text: #1f2522;
  --muted: #6b726e;
  --line: #e3e0d8;
  --primary: #2f6f4e;
  --primary-soft: #e3efe8;
  --danger: #b3261e;
  --star: #e0a400;
  --radius: 12px;
  --nav-h: 62px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151816;
    --card: #1f2421;
    --text: #e8ebe9;
    --muted: #9aa39e;
    --line: #333a36;
    --primary: #6cc196;
    --primary-soft: #23352b;
    --danger: #f2827a;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 16px);
}
a { color: var(--primary); }
h1 { font-size: 1.45rem; line-height: 1.25; margin: .4rem 0 .3rem; }
h2 { font-size: 1.15rem; margin: 1.6rem 0 .6rem; }
h3 { font-size: .95rem; margin: 1.2rem 0 .4rem; }
p { margin: .4rem 0; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.hint { color: var(--muted); font-size: .88rem; }

.topbar {
  position: sticky; top: 0; z-index: 5;
  background: var(--primary); color: #fff;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  font-weight: 700; font-size: 1.1rem;
}
.topbar a { color: inherit; text-decoration: none; }
@media (prefers-color-scheme: dark) { .topbar { color: #0f1a14; } }

main { max-width: 720px; margin: 0 auto; padding: 12px 14px; }

/* Navigation unten */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: var(--nav-h); color: var(--muted); text-decoration: none; font-size: .78rem;
}
.nav a span { font-size: 1.3rem; line-height: 1.2; }
.nav a.active { color: var(--primary); font-weight: 600; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .3rem;
  min-height: 44px; padding: 0 16px; border-radius: 22px;
  border: 1px solid var(--line); background: var(--card); color: var(--text);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
}
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
@media (prefers-color-scheme: dark) { .btn.primary { color: #0f1a14; } }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: .5; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.icon {
  min-width: 40px; height: 40px; border-radius: 20px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); font-size: 1rem; cursor: pointer;
}
.icon.on { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }
.icon:disabled { opacity: .35; }

input, select, textarea {
  font: inherit; color: var(--text); background: var(--card);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
}
textarea { width: 100%; resize: vertical; }
input[type="search"] { width: 100%; }

/* Rezeptliste */
.toolbar { display: flex; flex-direction: column; gap: 10px; margin-bottom: 8px; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chip {
  flex: none; border: 1px solid var(--line); background: var(--card); color: var(--text);
  border-radius: 18px; padding: 6px 12px; font: inherit; font-size: .9rem; cursor: pointer;
}
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.sort { font-size: .9rem; color: var(--muted); }
.sort select { padding: 6px 8px; margin-left: 4px; }
.count { color: var(--muted); font-size: .85rem; margin: 4px 0 8px; }

.card, .plan-link {
  display: flex; gap: 12px; background: var(--card); border-radius: var(--radius);
  text-decoration: none; color: inherit; overflow: hidden; margin-bottom: 10px;
  box-shadow: 0 1px 2px rgba(0,0,0,.06);
}
.card img, .plan-link img, .img-placeholder {
  width: 104px; min-height: 88px; object-fit: cover; flex: none; background: var(--primary-soft);
}
.card-body { padding: 10px 10px 10px 0; min-width: 0; }
.card-title { font-weight: 650; line-height: 1.25; }
.card-sub { color: var(--muted); font-size: .85rem; margin-top: 2px; }
.card-meta { color: var(--muted); font-size: .82rem; margin-top: 6px; }
.stars { color: var(--star); letter-spacing: 1px; }
.stars.muted { color: var(--muted); letter-spacing: 0; }

.fab {
  position: fixed; right: 18px; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 18px); z-index: 11;
  width: 58px; height: 58px; border-radius: 29px; background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 2rem; text-decoration: none;
  box-shadow: 0 4px 12px rgba(0,0,0,.25);
}
.empty { text-align: center; color: var(--muted); padding: 32px 12px; }

/* Rezeptansicht */
.recipe .hero { width: calc(100% + 28px); margin: -12px -14px 10px; aspect-ratio: 16 / 10; object-fit: cover; display: block; }
.recipe .sub { color: var(--muted); margin-top: 0; }
.rating { display: flex; align-items: center; gap: 2px; margin: 6px 0; }
.star { background: none; border: none; font-size: 2rem; line-height: 1; color: var(--line); cursor: pointer; padding: 2px; }
.star.on { color: var(--star); }
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.badge { background: var(--primary-soft); color: var(--primary); border-radius: 12px; padding: 3px 10px; font-size: .82rem; font-weight: 600; }
.badge.light { background: transparent; border: 1px solid var(--line); color: var(--muted); font-weight: 500; }
.nutrition { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 12px; }
.nutrition div { background: var(--card); border-radius: 10px; padding: 8px 4px; text-align: center; }
.nutrition strong { display: block; }
.nutrition span { font-size: .75rem; color: var(--muted); }
.nutrition + .hint { text-align: right; margin: 2px 0 0; font-size: .75rem; }

.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: 22px; overflow: hidden; background: var(--card); }
.segmented button { border: none; background: none; color: var(--text); font: inherit; padding: 8px 14px; min-height: 40px; cursor: pointer; }
.segmented button.active { background: var(--primary); color: #fff; font-weight: 600; }

.ingredients { list-style: none; padding: 0; margin: 10px 0; background: var(--card); border-radius: var(--radius); }
.ingredients li { display: flex; gap: 12px; padding: 9px 12px; border-bottom: 1px solid var(--line); }
.ingredients li:last-child { border-bottom: none; }
.ingredients .amt { flex: 0 0 92px; color: var(--muted); text-align: right; }
.ingredients li.pantry { color: var(--muted); }
.ingredients em { font-style: normal; font-size: .8rem; }

.steps { padding-left: 1.3rem; }
.steps li { margin-bottom: 18px; }
.steps li::marker { font-weight: 700; color: var(--primary); }
.steps img { width: 100%; border-radius: 10px; margin: 4px 0; }
.footer-actions { margin-top: 24px; }

/* Import */
.import-log { list-style: none; padding: 0; }
.import-log li { padding: 8px 0; border-bottom: 1px solid var(--line); word-break: break-word; }
.import-log li.ok { color: var(--primary); }
.import-log li.error { color: var(--danger); }
.import-log li.pending { color: var(--muted); }

/* Wochenplan */
.plan-controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 8px 0; }
.summary { font-weight: 600; color: var(--primary); }
.plan-card { background: var(--card); border-radius: var(--radius); margin-bottom: 12px; overflow: hidden; box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.plan-card .plan-link { margin: 0; box-shadow: none; border-radius: 0; }
.plan-card.done { opacity: .55; }
.plan-tools { display: flex; gap: 6px; padding: 8px 10px; border-top: 1px solid var(--line); align-items: center; }
.plan-tools select { padding: 6px 8px; margin-right: auto; }

/* Einkaufsliste */
.switch { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: .9rem; margin: 8px 0; }
.section-title { color: var(--primary); text-transform: uppercase; letter-spacing: .04em; font-size: .8rem; }
.shop-list { list-style: none; padding: 0; margin: 0; background: var(--card); border-radius: var(--radius); }
.shop-list li { border-bottom: 1px solid var(--line); padding: 0 12px; }
.shop-list li:last-child { border-bottom: none; }
.shop-list label { display: flex; align-items: center; gap: 10px; min-height: 48px; cursor: pointer; }
.shop-list input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--primary); flex: none; }
.shop-list .name { flex: 1; }
.shop-list .amt { color: var(--muted); font-size: .9rem; text-align: right; }
.shop-list li.off .name, .shop-list li.off .amt { color: var(--muted); text-decoration: line-through; }
.shop-list select { width: 100%; margin-bottom: 8px; padding: 6px 8px; font-size: .9rem; }
.sticky-actions {
  position: sticky; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 8px);
  display: flex; gap: 8px; align-items: center; margin-top: 16px;
  background: var(--card); border-radius: 30px; padding: 6px 6px 6px 16px; box-shadow: 0 3px 10px rgba(0,0,0,.15);
}
.sticky-actions span { margin-right: auto; color: var(--muted); font-size: .9rem; }

/* Einstellungen */
.section-order, .overrides { list-style: none; padding: 0; margin: 0; background: var(--card); border-radius: var(--radius); }
.section-order li, .overrides li { display: flex; align-items: center; gap: 6px; padding: 6px 8px 6px 12px; border-bottom: 1px solid var(--line); }
.section-order li:last-child, .overrides li:last-child { border-bottom: none; }
.section-order span, .overrides span { flex: 1; }
.section-order .icon, .overrides .icon { min-width: 36px; height: 36px; }
.inline-form { display: flex; gap: 8px; margin-top: 8px; }
.inline-form input { flex: 1; min-width: 0; }
.field { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; }
.field input[type="number"] { width: 72px; }

/* Hinweis-Meldung */
#toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 90px);
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none; transition: .2s;
  background: #222; color: #fff; padding: 10px 16px; border-radius: 20px; font-size: .92rem;
  max-width: 90vw; text-align: center; z-index: 20;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Erinnerung an die Datensicherung (Rezeptliste) */
.backup-reminder {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--primary-soft); border: 1px solid var(--primary); border-radius: var(--radius);
  padding: 8px 12px; margin: 8px 0; font-size: .9rem;
}
