:root {
  /* Warme Küchenfarben: Creme, Tomate/Terrakotta, Basilikum */
  --bg: #fbf6ef;
  --bg-2: #f3ebdf;
  --card: #ffffff;
  --text: #2a211c;
  --muted: #7a6c62;
  --line: #eadfd2;
  --accent: #c4572f;
  --accent-ink: #ffffff;
  --accent-soft: #f8e4d9;
  --green: #4f7a43;
  --green-soft: #e3eedb;
  --danger: #b0392b;
  --danger-soft: #f8e3df;
  --warn-soft: #f8ecd2;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(60, 35, 20, .05), 0 3px 12px rgba(60, 35, 20, .07);
  --topbar: rgba(251, 246, 239, .88);
  --tabbar-h: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1714; --bg-2: #241f1b; --card: #26201c; --text: #f1e9e2; --muted: #b0a196; --line: #3a312b;
    --accent: #ef8a5f; --accent-ink: #1f120b; --accent-soft: #432a1f;
    --green: #9cc78c; --green-soft: #243321; --danger: #f0998b; --danger-soft: #3d221d; --warn-soft: #3a2f19;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4); --topbar: rgba(27, 23, 20, .88);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 17px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; overscroll-behavior-y: none; }
a { color: var(--accent); }
h1 { font-size: 1.65rem; line-height: 1.2; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 1.2rem; margin: 0; }
h3 { font-size: 1rem; margin: 0; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.center { text-align: center; }
[hidden] { display: none !important; }

/* ---------- Kopf- und Tab-Leiste ---------- */
.topbar { position: sticky; top: 0; z-index: 20; background: var(--topbar); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line); padding-top: env(safe-area-inset-top); }
.topbar-inner { max-width: 1000px; margin: 0 auto; display: flex; align-items: center; gap: 10px; padding: 9px 16px; min-height: 52px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); font-weight: 750; font-size: 1.05rem; margin-right: auto; }
.logo { width: 32px; height: 32px; border-radius: 9px; }
body.cooking .topbar, body.cooking .tabbar, body.bare .tabbar { display: none; }

.tabbar { position: fixed; z-index: 20; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-around; align-items: stretch;
  background: var(--topbar); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom); }
.tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; height: var(--tabbar-h);
  text-decoration: none; color: var(--muted); font-size: .72rem; font-weight: 650; }
.tabbar .ti { font-size: 1.35rem; line-height: 1.2; filter: grayscale(1); opacity: .75; }
.tabbar a.active { color: var(--accent); }
.tabbar a.active .ti { filter: none; opacity: 1; }
.tabbar .tab-new .ti { filter: none; opacity: 1; background: var(--accent); color: var(--accent-ink); width: 44px; height: 32px; border-radius: 12px;
  display: grid; place-items: center; font-size: 1.4rem; font-weight: 700; }
.tabbar .avatar-mini { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-size: .72rem; font-weight: 800; filter: none; }

main { max-width: 1000px; margin: 0 auto; padding: 14px 16px calc(var(--tabbar-h) + 28px + env(safe-area-inset-bottom)); }
body.bare main { padding-bottom: calc(110px + env(safe-area-inset-bottom)); }

/* ---------- Bausteine ---------- */
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.between { justify-content: space-between; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.btn { font: inherit; font-weight: 700; font-size: 1rem; border: 0; border-radius: 14px; padding: 12px 18px; min-height: 48px; background: var(--accent); color: var(--accent-ink);
  cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn.ghost { background: var(--accent-soft); color: var(--accent); }
.btn.plain { background: var(--bg-2); color: var(--text); }
.btn.danger { background: var(--danger-soft); color: var(--danger); }
.btn.small { min-height: 38px; padding: 7px 13px; font-size: .92rem; border-radius: 11px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; }
.icon-btn { border: 0; background: var(--bg-2); color: var(--text); width: 44px; height: 44px; border-radius: 50%; font-size: 1.2rem; display: inline-grid; place-items: center; cursor: pointer; text-decoration: none; flex: none; }
.chip { display: inline-flex; align-items: center; gap: 4px; font-size: .82rem; font-weight: 650; padding: 4px 11px; border-radius: 999px; background: var(--bg-2); color: var(--text); white-space: nowrap; text-decoration: none; }
.chip.accent { background: var(--accent-soft); color: var(--accent); }
.chip.green { background: var(--green-soft); color: var(--green); }
.error { color: var(--danger); font-weight: 650; margin: 0; }
.notice { background: var(--warn-soft); border-radius: 14px; padding: 12px 14px; }
.empty { text-align: center; padding: 48px 16px; color: var(--muted); }
.empty .big { font-size: 3rem; }

input, select, textarea { font: inherit; font-size: 16px; color: var(--text); background: var(--card); border: 1.5px solid var(--line); border-radius: 12px; padding: 12px 13px; width: 100%; }
textarea { resize: vertical; min-height: 120px; line-height: 1.45; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
.field { display: flex; flex-direction: column; gap: 5px; font-size: .9rem; font-weight: 700; color: var(--muted); }
.field .hint { font-weight: 400; font-size: .82rem; }

/* ---------- Liste ---------- */
.searchbar { position: sticky; top: calc(52px + env(safe-area-inset-top)); z-index: 10; margin: -14px -16px 0; padding: 10px 16px 8px; background: var(--bg); }
.search { position: relative; }
.search input { padding-left: 42px; border-radius: 999px; background: var(--card); box-shadow: var(--shadow); border-color: transparent; }
.search::before { content: "🔍"; position: absolute; left: 15px; top: 50%; transform: translateY(-50%); font-size: .95rem; opacity: .6; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 10px 16px 4px; margin: 0 -16px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips .chip { padding: 7px 14px; font-size: .9rem; border: 1.5px solid var(--line); background: var(--card); cursor: pointer; }
.chips .chip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.listhead { display: flex; justify-content: space-between; align-items: center; margin: 10px 0 10px; gap: 10px; }
.listhead select { width: auto; padding: 6px 10px; border-radius: 999px; font-size: .9rem; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(158px, 1fr)); gap: 12px; }
.rcard { display: flex; flex-direction: column; background: var(--card); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
  text-decoration: none; color: var(--text); border: 1px solid var(--line); position: relative; }
.rcard .pic { aspect-ratio: 4 / 3; background: var(--bg-2) center / cover no-repeat; display: grid; place-items: center; font-size: 2.6rem; }
.rcard .body { padding: 9px 11px 11px; display: flex; flex-direction: column; gap: 3px; flex: 1; }
.rcard .t { font-weight: 720; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.rcard .m { font-size: .8rem; color: var(--muted); margin-top: auto; }
.rcard .fav { position: absolute; top: 8px; right: 8px; background: rgba(255, 255, 255, .9); border-radius: 50%; width: 30px; height: 30px; display: grid; place-items: center; font-size: .9rem; }

/* ---------- Rezept ---------- */
.hero { margin: -14px -16px 0; position: relative; }
.hero .pic { aspect-ratio: 4 / 3; max-height: 62vh; width: 100%; background: var(--bg-2) center / cover no-repeat; display: grid; place-items: center; font-size: 5rem; }
.hero .pic.empty-pic { aspect-ratio: auto; height: 120px; font-size: 3.4rem; }
.hero-actions { position: absolute; top: 12px; left: 12px; right: 12px; display: flex; justify-content: space-between; }
.hero-actions .icon-btn { background: rgba(255, 255, 255, .92); color: #2a211c; box-shadow: 0 2px 8px rgba(0, 0, 0, .15); }
.recipe-head { background: var(--bg); border-radius: 24px 24px 0 0; margin: -24px -16px 0; padding: 20px 16px 4px; position: relative; display: flex; flex-direction: column; gap: 10px; }
.recipe-head .desc { margin: 0; color: var(--muted); }
.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.fact { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 9px 6px; text-align: center; }
.fact b { display: block; font-size: 1.05rem; }
.fact span { font-size: .75rem; color: var(--muted); font-weight: 600; }
.actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.actions .btn { flex-direction: column; gap: 2px; font-size: .78rem; padding: 8px 4px; min-height: 62px; border-radius: 14px; }
.actions .btn .ai { font-size: 1.3rem; line-height: 1.1; }
.section { margin-top: 18px; }
.section > h2 { margin-bottom: 10px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.stepper { display: inline-flex; align-items: center; gap: 4px; background: var(--card); border: 1.5px solid var(--line); border-radius: 999px; padding: 3px; font-size: .95rem; font-weight: 650; }
.stepper button { border: 0; width: 34px; height: 34px; border-radius: 50%; background: var(--bg-2); color: var(--text); font-size: 1.15rem; font-weight: 700; cursor: pointer; }
.stepper span { min-width: 92px; text-align: center; }
.ingredients { list-style: none; margin: 0; padding: 0; }
.ingredients li { display: flex; gap: 12px; align-items: baseline; padding: 11px 2px; border-bottom: 1px solid var(--line); cursor: pointer; user-select: none; }
.ingredients li .amt { flex: 0 0 auto; min-width: 74px; font-weight: 750; text-align: right; font-variant-numeric: tabular-nums; }
.ingredients li.done { opacity: .4; text-decoration: line-through; }
.ingredients li.sub, .steps li.sub { border: 0; cursor: default; font-weight: 800; color: var(--accent); padding: 16px 2px 4px; font-size: .95rem; text-decoration: none; opacity: 1; }
.steps { list-style: none; margin: 0; padding: 0; counter-reset: step; display: flex; flex-direction: column; gap: 10px; }
.steps li.step { counter-increment: step; display: flex; gap: 12px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 13px 14px; cursor: pointer; }
.steps li.step::before { content: counter(step); flex: none; width: 30px; height: 30px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-weight: 800; display: grid; place-items: center; font-size: .9rem; }
.steps li.step.done { opacity: .45; }
.steps li.step.done::before { content: "✓"; background: var(--green-soft); color: var(--green); }
.tip { background: var(--warn-soft); border-radius: 16px; padding: 13px 15px; white-space: pre-line; }
.byline { font-size: .85rem; color: var(--muted); }
.comments { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.comments li { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 10px 13px; }
.comments .who { font-size: .82rem; color: var(--muted); display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.comments .who button { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: .82rem; }
.comments p { margin: 2px 0 0; white-space: pre-line; }
.avatar { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-weight: 800; flex: none; }

/* ---------- Formular ---------- */
.form { display: flex; flex-direction: column; gap: 14px; }
.form .two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.photo-pick { position: relative; border: 2px dashed var(--line); border-radius: var(--radius); aspect-ratio: 4 / 3; max-height: 50vh; width: 100%; overflow: hidden;
  display: grid; place-items: center; background: var(--card) center / cover no-repeat; cursor: pointer; color: var(--muted); font-weight: 650; text-align: center; }
.photo-pick.has { border-style: solid; border-color: transparent; }
.photo-pick.has .ph { display: none; }
.photo-pick input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.photo-pick .ph span { display: block; font-size: 2.6rem; }
.photo-tools { display: flex; gap: 8px; justify-content: flex-end; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--bg-2); border-radius: 12px; padding: 3px; gap: 3px; }
.seg label { text-align: center; padding: 9px 4px; border-radius: 10px; cursor: pointer; font-weight: 650; color: var(--text); font-size: .92rem; }
.seg input { display: none; }
.seg label:has(input:checked) { background: var(--card); box-shadow: var(--shadow); color: var(--accent); }
.tag-suggest { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-suggest .chip { cursor: pointer; border: 0; font: inherit; font-size: .82rem; }
.savebar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; background: var(--topbar); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line); padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); }
.savebar .inner { max-width: 1000px; margin: 0 auto; display: flex; gap: 10px; }
.savebar .btn { flex: 1; }
.start-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.start-card { position: relative; overflow: hidden; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; text-align: center;
  background: var(--accent-soft); color: var(--text); border: 0; border-radius: var(--radius); padding: 16px 10px; min-height: 120px; font: inherit; cursor: pointer; }
.start-card .si { font-size: 2rem; line-height: 1.2; }
.start-card b { color: var(--accent); font-size: 1.05rem; }
.start-card span:last-of-type { font-size: .8rem; color: var(--muted); }
.start-card input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.importbox { background: var(--accent-soft); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.importbox .row input { flex: 1; min-width: 0; }

/* ---------- Kochmodus ---------- */
.cook { position: fixed; inset: 0; z-index: 50; background: var(--bg); display: flex; flex-direction: column;
  padding: calc(10px + env(safe-area-inset-top)) 16px calc(14px + env(safe-area-inset-bottom)); }
.cook-top { display: flex; align-items: center; gap: 10px; }
.cook-top .t { flex: 1; font-weight: 750; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cook-progress { display: flex; gap: 4px; margin: 12px 0 6px; }
.cook-progress i { flex: 1; height: 5px; border-radius: 3px; background: var(--line); }
.cook-progress i.on { background: var(--accent); }
.cook-body { flex: 1; overflow-y: auto; display: flex; flex-direction: column; justify-content: center; gap: 18px; padding: 10px 2px; }
.cook-num { color: var(--accent); font-weight: 800; font-size: 1rem; }
.cook-text { font-size: clamp(1.35rem, 5.4vw, 2rem); line-height: 1.4; font-weight: 550; }
.cook-sub { color: var(--accent); font-weight: 800; }
.cook-nav { display: grid; grid-template-columns: 1fr 2fr; gap: 10px; }
.cook-nav .btn { min-height: 60px; font-size: 1.1rem; }
.wake { font-size: .78rem; color: var(--muted); text-align: center; margin-top: 8px; }
.timer-pill { background: var(--accent); color: var(--accent-ink); font-weight: 800; border-radius: 999px; padding: 6px 13px; font-variant-numeric: tabular-nums; cursor: pointer; }
.timer-pill.ring { animation: ring 1s infinite; }
@keyframes ring { 50% { transform: scale(1.08); background: var(--danger); } }
.cook .timer-pill { font-size: 1.05rem; }

/* ---------- Dialog, Toast ---------- */
dialog { border: 0; border-radius: 22px; padding: 0; width: min(520px, calc(100vw - 24px)); max-height: calc(100dvh - 40px); background: var(--card); color: var(--text); box-shadow: 0 24px 60px rgba(0, 0, 0, .3); }
dialog::backdrop { background: rgba(20, 12, 8, .5); }
dialog .content { padding: 18px; display: flex; flex-direction: column; gap: 12px; }
dialog footer { display: flex; gap: 8px; justify-content: flex-end; padding: 0 18px 18px; flex-wrap: wrap; }
dialog footer .btn { flex: 1; }
dialog.sheet { margin: auto auto 0; width: 100%; max-width: 640px; border-radius: 22px 22px 0 0; padding-bottom: env(safe-area-inset-bottom); }
#toast { position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 18px + env(safe-area-inset-bottom)); transform: translate(-50%, 200px); background: var(--text); color: var(--bg);
  padding: 11px 18px; border-radius: 999px; font-weight: 650; transition: transform .25s; z-index: 100; max-width: calc(100vw - 32px); text-align: center; }
#toast.show { transform: translate(-50%, 0); }
#toast.err { background: var(--danger); color: #fff; }

.menu { list-style: none; margin: 0; padding: 0; }
.menu a, .menu button { display: flex; align-items: center; gap: 12px; width: 100%; padding: 14px 4px; border: 0; border-bottom: 1px solid var(--line); background: none;
  color: var(--text); font: inherit; text-decoration: none; text-align: left; cursor: pointer; }
.menu li:last-child a, .menu li:last-child button { border-bottom: 0; }
.menu .mi { font-size: 1.3rem; width: 30px; text-align: center; }

@media (min-width: 760px) {
  .hero { margin: 0; }
  .hero .pic { border-radius: 24px; }
  .recipe-head { margin: -24px 0 0; padding: 20px 4px 4px; }
  .recipe-layout { display: grid; grid-template-columns: 5fr 7fr; gap: 28px; align-items: start; }
  .recipe-layout .ing { position: sticky; top: 80px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 16px; }
}

@media print {
  .topbar, .tabbar, .hero-actions, .actions, .no-print, #toast { display: none !important; }
  body { background: #fff; color: #000; font-size: 12pt; }
  main { padding: 0; }
  .hero .pic { max-height: 30vh; border-radius: 12px; }
  .recipe-head { margin: 0; padding: 12px 0 0; }
  .card, .steps li.step, .fact { box-shadow: none; border-color: #ccc; break-inside: avoid; }
}
