:root {
  --bg: #FBF6EE;
  --card: #FFFFFF;
  --ink: #2B2118;
  --muted: #8A7B6C;
  --line: #EADFCF;
  --accent: #D2551F;
  --accent-ink: #FFFFFF;
  --accent-soft: #FBE6D8;
  --done: #5E8A63;
  --done-soft: #E3EEE2;
  --warn: #B7791F;
  --shadow: 0 1px 2px rgba(43, 33, 24, .06), 0 4px 14px rgba(43, 33, 24, .06);
  --radius: 16px;
  --serif: "Fraunces", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1A1512; --card: #241D19; --ink: #F3EADF; --muted: #A8998A; --line: #3A2F28;
    --accent: #F0763F; --accent-soft: #3D2619; --done: #8DBA92; --done-soft: #233024;
    --shadow: 0 1px 2px rgba(0,0,0,.3); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1A1512; --card: #241D19; --ink: #F3EADF; --muted: #A8998A; --line: #3A2F28;
  --accent: #F0763F; --accent-soft: #3D2619; --done: #8DBA92; --done-soft: #233024;
  --shadow: 0 1px 2px rgba(0,0,0,.3); color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
  font: 17px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}
main { max-width: 640px; margin: 0 auto; padding: 12px 16px 96px; }
h1, h2, h3 { font-family: var(--serif); font-weight: 650; letter-spacing: -.01em; margin: 0; }
h1 { font-size: 30px; line-height: 1.1; }
h2 { font-size: 21px; margin: 28px 0 10px; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.hidden { display: none !important; }

/* Kopf */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0 14px; }
.top h1 span { color: var(--accent); }
.icon-btn {
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center;
  background: var(--card); box-shadow: var(--shadow); flex: none;
}
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn.primary { background: var(--accent); color: var(--accent-ink); }

/* Eingabe */
.add { display: flex; gap: 8px; margin-bottom: 14px; }
.add input, .search input, textarea, .key input {
  flex: 1; min-width: 0; border: 1px solid var(--line); background: var(--card);
  border-radius: 12px; padding: 12px 14px; outline: none;
}
.add input:focus, .search input:focus, textarea:focus, .key input:focus { border-color: var(--accent); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 18px; border-radius: 12px; font-weight: 600;
  background: var(--card); box-shadow: var(--shadow);
}
.btn, .item { text-decoration: none; color: inherit; }
.btn.primary { background: var(--accent); color: var(--accent-ink); box-shadow: none; }
.btn.done { background: var(--done); color: #fff; box-shadow: none; }
.btn svg { width: 20px; height: 20px; }

/* Tabs */
.tabs { display: flex; gap: 6px; background: var(--line); padding: 4px; border-radius: 12px; margin-bottom: 12px; }
.tabs button { flex: 1; padding: 9px 0; border-radius: 9px; font-weight: 600; color: var(--muted); font-size: 15px; }
.tabs button[aria-selected="true"] { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.search { display: flex; margin-bottom: 14px; }

/* Liste */
.list { display: grid; gap: 10px; }
.item {
  display: flex; gap: 12px; align-items: center; text-align: left; width: 100%;
  background: var(--card); border-radius: var(--radius); padding: 10px; box-shadow: var(--shadow);
}
.thumb { width: 64px; height: 80px; border-radius: 10px; object-fit: cover; background: var(--accent-soft); flex: none; }
.thumb.ph { display: grid; place-items: center; font-size: 28px; }
.item .t { font-family: var(--serif); font-weight: 650; font-size: 18px; line-height: 1.2; }
.item .m { font-size: 14px; color: var(--muted); margin-top: 3px; }
.badge { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 99px; margin-top: 5px; }
.badge.wartet { background: var(--accent-soft); color: var(--warn); }
.badge.fehler { background: var(--accent-soft); color: var(--accent); }
.empty { text-align: center; padding: 48px 16px; color: var(--muted); }
.empty .big { font-size: 44px; }

/* Rezept */
.hero { display: flex; gap: 14px; align-items: flex-end; margin: 4px 0 14px; }
.hero .thumb { width: 92px; height: 116px; }
.hero h1 { font-size: 27px; }
.meta { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 14px; color: var(--muted); margin-top: 6px; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 6px 0 4px; }
.actions .wide { grid-column: span 2; }

.servings { display: flex; align-items: center; justify-content: space-between; background: var(--card); border-radius: 12px; padding: 6px 6px 6px 14px; box-shadow: var(--shadow); margin-bottom: 8px; }
.stepper { display: flex; align-items: center; gap: 4px; }
.stepper button { width: 38px; height: 38px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); font-size: 22px; font-weight: 700; line-height: 1; }
.stepper output { min-width: 34px; text-align: center; font-weight: 700; font-size: 18px; }

.group { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 16px 0 4px; }
.ing { list-style: none; margin: 0; padding: 0; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.ing li + li { border-top: 1px solid var(--line); }
.ing label { display: flex; align-items: center; gap: 12px; padding: 11px 14px; cursor: pointer; }
.ing input { appearance: none; width: 24px; height: 24px; border: 2px solid var(--line); border-radius: 7px; flex: none; margin: 0; display: grid; place-items: center; }
.ing input:checked { background: var(--done); border-color: var(--done); }
.ing input:checked::after { content: ""; width: 6px; height: 11px; border: solid #fff; border-width: 0 2.5px 2.5px 0; transform: translateY(-1px) rotate(45deg); }
.ing .amt { font-weight: 700; min-width: 64px; flex: none; white-space: nowrap; font-variant-numeric: tabular-nums; }
.ing .amt.soft { font-weight: 500; color: var(--muted); font-size: 14px; }
.ing .nm { flex: 1; min-width: 0; }
.ing li.checked .amt, .ing li.checked .nm { opacity: .4; text-decoration: line-through; }

.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; counter-reset: s; }
.steps li { counter-increment: s; }
.steps button { display: flex; gap: 12px; text-align: left; width: 100%; background: var(--card); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.steps button::before {
  content: counter(s); flex: none; width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent); font-weight: 700; display: grid; place-items: center; font-size: 15px;
}
.steps li.done button { opacity: .45; }
.steps li.done button::before { content: "✓"; background: var(--done); color: #fff; }
.tips { padding-left: 20px; margin: 0; }
.tips li + li { margin-top: 6px; }

.rate { display: flex; gap: 8px; justify-content: center; margin-top: 10px; }
.rate button { width: 52px; height: 44px; border-radius: 12px; background: var(--card); box-shadow: var(--shadow); font-size: 20px; }
.rate button[aria-pressed="true"] { background: var(--done-soft); outline: 2px solid var(--done); }

/* Kochmodus */
body.cook { font-size: 21px; }
body.cook .hide-cook { display: none !important; }
body.cook .steps button { padding: 18px; font-size: 22px; line-height: 1.4; }
body.cook .ing label { padding: 14px; }
.cookbar { position: fixed; left: 0; right: 0; bottom: 0; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: var(--bg); border-top: 1px solid var(--line); display: none; }
body.cook .cookbar { display: block; }
.cookbar .btn { width: 100%; }

/* Fortschritt */
.progress { padding: 56px 8px; text-align: center; }
.progress .pot { font-size: 56px; animation: bob 1.4s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-6px) rotate(-4deg); } }
.stages { list-style: none; padding: 0; margin: 24px auto 0; max-width: 280px; text-align: left; display: grid; gap: 10px; }
.stages li { color: var(--muted); display: flex; gap: 10px; align-items: center; }
.stages li::before { content: ""; width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--line); flex: none; }
.stages li.on { color: var(--ink); font-weight: 600; }
.stages li.on::before { border-color: var(--accent); background: var(--accent); }
.stages li.ok::before { border-color: var(--done); background: var(--done); }

.box { background: var(--card); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin: 12px 0; }
.box textarea { width: 100%; min-height: 160px; margin: 10px 0; resize: vertical; }
.key { max-width: 360px; margin: 18vh auto 0; text-align: center; }
.key input { width: 100%; margin: 18px 0 10px; text-align: center; }

#toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 15px;
  opacity: 0; pointer-events: none; transition: .2s; max-width: calc(100% - 32px);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Einkaufszettel */
.top-actions { display: flex; gap: 8px; }
.icon-btn.cart { position: relative; color: var(--ink); }
.icon-btn .count { position: absolute; top: -4px; right: -4px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px; background: var(--accent); color: var(--accent-ink); font-size: 12px; font-weight: 700; display: grid; place-items: center; }
.ing.shop li { display: flex; align-items: center; }
.sh-item { flex: 1; min-width: 0; display: grid; grid-template-columns: 1fr auto; column-gap: 10px; text-align: left; padding: 12px 4px 12px 14px; }
.sh-name { font-weight: 600; }
.sh-amt { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.sh-from { grid-column: 1 / -1; font-size: 12px; color: var(--muted); }
.sh-del { width: 44px; height: 44px; display: grid; place-items: center; color: var(--muted); flex: none; }
.sh-del svg { width: 16px; height: 16px; }
.ing.shop li.checked .sh-name, .ing.shop li.checked .sh-amt { text-decoration: line-through; opacity: .45; }
.link { color: var(--accent); font-weight: 600; text-transform: none; letter-spacing: 0; font-size: 14px; }
.pick .ing { box-shadow: none; border: 1px solid var(--line); }
