:root {
  --bg: #fbfaf8;
  --surface: #ffffff;
  --text: #22211f;
  --muted: #6f6b66;
  --line: #e7e3dd;
  --accent: #a9502e;
  --accent-soft: #f4e6df;
  --ok: #3f7a4a;
  --radius: 12px;
  --serif: Georgia, 'Iowan Old Style', 'Times New Roman', serif;
  --sans: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1917;
    --surface: #23221f;
    --text: #ece9e4;
    --muted: #a39e97;
    --line: #36332f;
    --accent: #e08a66;
    --accent-soft: #3a2a23;
    --ok: #7fbf8a;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.55 var(--sans);
}
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.2; }
h1 { font-size: 1.8rem; margin: .2em 0 .4em; }
h2 { font-size: 1.25rem; margin: 1.6em 0 .6em; }
a { color: var(--accent); }
img { max-width: 100%; display: block; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }

/* Kopfzeile */
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .7rem 1rem; padding-top: max(.7rem, env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { font-family: var(--serif); font-size: 1.15rem; font-weight: 600; color: var(--text); text-decoration: none; }
#nav { display: flex; gap: .9rem; white-space: nowrap; overflow-x: auto; }
@media (max-width: 560px) {
  .top { flex-direction: column; align-items: flex-start; gap: .25rem; padding-bottom: .5rem; }
}
#nav a { color: var(--muted); text-decoration: none; font-size: .95rem; }
#nav a.active { color: var(--text); font-weight: 600; }

main { max-width: 760px; margin: 0 auto; padding: 1rem 1rem 4rem; }

/* Formularelemente */
input, select, textarea, button { font: inherit; color: inherit; }
input[type=text], input[type=search], input[type=email], input[type=url], input[type=number], select, textarea {
  width: 100%;
  padding: .6rem .75rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
textarea { min-height: 7rem; resize: vertical; }
label { display: block; font-size: .9rem; color: var(--muted); margin: 1rem 0 .3rem; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .6rem 1rem;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); cursor: pointer; text-decoration: none; color: var(--text);
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: #b3261e; }
.btn.small { padding: .35rem .7rem; font-size: .9rem; }
.btn:disabled { opacity: .5; cursor: default; }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.row > .grow { flex: 1; min-width: 0; }
.actions { display: flex; gap: .6rem; flex-wrap: wrap; margin: 1.2rem 0; }

/* Chips */
.chips { display: flex; gap: .4rem; flex-wrap: wrap; margin: .7rem 0; }
.chip {
  padding: .3rem .75rem; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface);
  font-size: .9rem; cursor: pointer; color: var(--text); text-decoration: none;
}
.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.chip .x { margin-left: .3rem; opacity: .6; }

/* Rezeptliste */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: .9rem; margin-top: 1rem; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; text-decoration: none; color: var(--text);
}
.card .ph { aspect-ratio: 4/3; background: var(--accent-soft); display: grid; place-items: center; font-size: 2rem; }
.card .ph img { width: 100%; height: 100%; object-fit: cover; }
.card .body { padding: .6rem .75rem .75rem; }
.card .title { font-weight: 600; line-height: 1.3; }
.card .meta { font-size: .82rem; color: var(--muted); margin-top: .2rem; }

/* Rezeptansicht */
.hero { border-radius: var(--radius); overflow: hidden; margin: 0 -1rem 1rem; }
@media (min-width: 640px) { .hero { margin: 0 0 1rem; } }
.hero img { width: 100%; max-height: 420px; object-fit: cover; }
.servings { display: inline-flex; align-items: center; gap: .6rem; }
.servings button { width: 2.2rem; height: 2.2rem; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); cursor: pointer; }
ul.ings { list-style: none; padding: 0; margin: 0; }
ul.ings li { padding: .45rem 0; border-bottom: 1px solid var(--line); display: flex; gap: .6rem; }
ul.ings .amt { min-width: 5.5rem; color: var(--muted); font-variant-numeric: tabular-nums; }
ol.steps { padding-left: 1.3rem; }
ol.steps li { margin: .7rem 0; padding-left: .3rem; }

/* Kochmodus */
body.cook .top { display: none; }
body.cook main { font-size: 1.25rem; max-width: 900px; }
body.cook .no-cook { display: none !important; }
.cook-only { display: none; }
body.cook .cook-only { display: flex; }
body.cook ul.ings li, body.cook ol.steps li { cursor: pointer; }
.done { text-decoration: line-through; opacity: .45; }
.cookbar { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: .6rem 0; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--line); }

/* Kühlschrank */
.result { display: flex; gap: .8rem; align-items: center; padding: .7rem 0; border-bottom: 1px solid var(--line); text-decoration: none; color: var(--text); }
.result img, .result .ph { width: 56px; height: 56px; border-radius: 8px; object-fit: cover; background: var(--accent-soft); flex: none; display: grid; place-items: center; }
.badge { font-size: .85rem; }
.badge.ok { color: var(--ok); font-weight: 600; }

/* Formular Zutatenzeilen */
.ing-row { display: grid; grid-template-columns: 4.2rem 5rem 1fr 2.2rem; gap: .4rem; margin-bottom: .4rem; }
.ing-row .note { grid-column: 1 / 4; padding: .35rem .75rem; font-size: .9rem; }
.ing-row { padding-bottom: .5rem; border-bottom: 1px dashed var(--line); }
.ing-row button { border: none; background: none; color: var(--muted); cursor: pointer; font-size: 1.1rem; }
.box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem; margin: 1rem 0; }
.preview { max-height: 180px; border-radius: 8px; margin-top: .5rem; }
.checks { display: flex; flex-wrap: wrap; gap: .4rem 1rem; }
.checks label { display: flex; gap: .35rem; align-items: center; margin: 0; color: var(--text); font-size: .95rem; }

#toast {
  position: fixed; left: 50%; bottom: 1.5rem; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: .6rem 1rem; border-radius: 10px;
  opacity: 0; pointer-events: none; transition: opacity .2s; max-width: 90vw;
}
#toast.show { opacity: 1; }
