:root {
  --bg: #faf6f0; --surface: #ffffff; --surface-2: #f3ece2; --line: #e8dfd2;
  --text: #2b211c; --muted: #8a7b6f; --accent: #c4512f; --accent-2: #a8401f; --accent-soft: #f9e3da;
  --ok: #3f8a5a; --danger: #c0392b; --shadow: 0 1px 2px rgba(60, 40, 20, .06), 0 6px 18px rgba(60, 40, 20, .07);
  --radius: 16px; --topbar-h: 56px; --tabbar-h: 56px; --tabbar-safe: max(env(safe-area-inset-bottom) - 14px, 0px);
  --font: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --display: 'Fraunces', Georgia, serif;
}
:root[data-theme="dark"] {
  --bg: #171311; --surface: #221c19; --surface-2: #2b2420; --line: #3a312c;
  --text: #f1e9e1; --muted: #a39386; --accent: #e8714d; --accent-2: #f08560; --accent-soft: #3d2519;
  --ok: #5bb67b; --danger: #ee6a5a; --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 18px rgba(0, 0, 0, .25);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { background: var(--bg); }
body { margin: 0; font: 16px/1.5 var(--font); color: var(--text); background: var(--bg); min-height: 100vh; min-height: 100dvh; overflow-x: clip; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { font-family: var(--display); line-height: 1.2; margin: 0; }
h1 { font-size: 1.7rem; } h2 { font-size: 1.25rem; } h3 { font-size: 1.05rem; }
.muted { color: var(--muted); } .small { font-size: .85rem; }
[hidden] { display: none !important; }

/* Kopfzeile & Navigation */
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 18px; min-height: var(--topbar-h);
  padding: env(safe-area-inset-top) max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); }
@media (display-mode: standalone) { .topbar { padding-top: calc(env(safe-area-inset-top) + 18px); } }
.brand { display: flex; align-items: center; gap: 8px; font-family: var(--display); font-size: 1.2rem; }
.brand i { color: var(--accent); font-size: 1.5rem; }
.topnav { display: none; gap: 4px; margin-left: 12px; flex: 1; }
.topnav a { padding: 8px 14px; border-radius: 999px; color: var(--muted); font-weight: 500; position: relative; }
.topnav a.active { background: var(--accent-soft); color: var(--accent); }
.badge { display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 6px; border-radius: 999px; background: var(--accent); color: #fff; font-size: .72rem; font-style: normal; font-weight: 700; text-align: center; line-height: 20px; }
.icon-btn { margin-left: auto; width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; border: 0; background: transparent; color: var(--muted); font-size: 1.3rem; cursor: pointer; }
.icon-btn:hover, .icon-btn.active { background: var(--surface-2); color: var(--text); }
.topbar .icon-btn { display: none; }
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; height: calc(var(--tabbar-h) + var(--tabbar-safe)); padding-bottom: var(--tabbar-safe);
  background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--line); }
.tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; color: var(--muted); font-size: .7rem; font-weight: 500; position: relative; }
.tabbar a i { font-size: 1.45rem; } .tabbar a.active { color: var(--accent); }
.tabbar .badge { position: absolute; top: 5px; left: calc(50% + 6px); margin: 0; min-width: 18px; line-height: 18px; font-size: .68rem; }
body.logged-out .topbar nav, body.logged-out .topbar .icon-btn, body.logged-out .tabbar { display: none; }
@media (min-width: 800px) {
  .topnav { display: flex; } .tabbar { display: none; } .topbar .icon-btn { display: grid; }
  body.logged-out .topbar .topnav { display: none; }
}

/* Seite */
.container { max-width: 1000px; margin: 0 auto; padding: 18px max(16px, env(safe-area-inset-left)) calc(var(--tabbar-h) + var(--tabbar-safe) + 90px) max(16px, env(safe-area-inset-right)); }
@media (min-width: 800px) { .container { padding-bottom: 60px; } }
.page { position: relative; animation: fade .18s ease; }
.page.pending { position: absolute; left: 0; right: 0; visibility: hidden; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
#view.is-loading::after { content: ''; position: fixed; top: 50%; left: 50%; width: 30px; height: 30px; margin: -15px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; }
#view.is-loading > .page { opacity: .4; }
@keyframes spin { to { transform: rotate(360deg); } }
.page-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.page-head h1 { flex: 1; }
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); margin-bottom: 8px; font-weight: 500; }

/* Bausteine */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.card + .card, .stack > * + * { margin-top: 14px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 10px 18px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-weight: 600; cursor: pointer; transition: transform .08s, background .15s; }
.btn:active { transform: scale(.97); } .btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; } .btn.primary:hover { background: var(--accent-2); }
.btn.danger { color: var(--danger); } .btn.block { width: 100%; } .btn.small { padding: 6px 12px; font-size: .88rem; }
.btn[disabled] { opacity: .55; pointer-events: none; }
.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: .82rem; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
input[type=text], input[type=url], input[type=email], input[type=password], input[type=number], input[type=search], select, textarea {
  width: 100%; padding: 11px 13px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { resize: vertical; min-height: 90px; line-height: 1.5; }
.row { display: flex; gap: 10px; align-items: center; } .row > .grow { flex: 1; min-width: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 8px; scrollbar-width: none; margin: 0 -16px; padding-inline: 16px; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; padding: 6px 13px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-size: .88rem; font-weight: 500; cursor: pointer; white-space: nowrap; }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.tag { display: inline-block; padding: 2px 10px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: .78rem; font-weight: 500; }
.empty { text-align: center; color: var(--muted); padding: 40px 16px; } .empty i { font-size: 2.6rem; display: block; margin-bottom: 8px; color: var(--accent); opacity: .7; }
.fab { position: fixed; right: max(18px, env(safe-area-inset-right)); bottom: calc(var(--tabbar-h) + var(--tabbar-safe) + 18px); z-index: 25; width: 58px; height: 58px; border-radius: 50%; border: 0; background: var(--accent); color: #fff; font-size: 1.8rem; display: grid; place-items: center; box-shadow: 0 8px 22px rgba(196, 81, 47, .45); cursor: pointer; }
@media (min-width: 800px) { .fab { bottom: 28px; } }
.banner { padding: 12px 14px; border-radius: 12px; background: var(--accent-soft); color: var(--accent-2); font-size: .92rem; display: flex; gap: 10px; align-items: flex-start; }
.banner i { font-size: 1.2rem; margin-top: 1px; }

/* Rezeptliste */
.search { position: relative; margin-bottom: 10px; } .search i { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search input { padding-left: 40px; border-radius: 999px; }
.recipes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (min-width: 640px) { .recipes { grid-template-columns: repeat(3, 1fr); gap: 16px; } }
@media (min-width: 900px) { .recipes { grid-template-columns: repeat(4, 1fr); } }
.rcard { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); position: relative; }
.rcard .pic { aspect-ratio: 4 / 3; background: var(--surface-2) center / cover no-repeat; display: grid; place-items: center; color: var(--muted); font-size: 2.2rem; }
.rcard .info { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 4px; }
.rcard h3 { font-size: .98rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.rcard .meta { color: var(--muted); font-size: .8rem; display: flex; gap: 10px; }
.rcard .fav { position: absolute; top: 8px; right: 8px; width: 32px; height: 32px; border-radius: 50%; background: rgba(0, 0, 0, .45); color: #fff; display: grid; place-items: center; }
.rcard .fav.on { color: #ffcf5a; }
.rcard .ribbon { position: absolute; top: 8px; left: 8px; padding: 2px 9px; border-radius: 999px; background: var(--accent); color: #fff; font-size: .72rem; font-weight: 700; }

/* Rezeptansicht */
.hero { margin: -18px calc(-1 * max(16px, env(safe-area-inset-left))) 16px; aspect-ratio: 16 / 10; max-height: 420px; width: calc(100% + 32px); background: var(--surface-2) center / cover no-repeat; }
@media (min-width: 800px) { .hero { margin: 0 0 18px; width: 100%; border-radius: var(--radius); } }
.detail-meta { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; color: var(--muted); margin: 8px 0 12px; }
.detail-meta i { color: var(--accent); margin-right: 4px; }
.detail-grid { display: grid; gap: 16px; margin-top: 16px; } @media (min-width: 800px) { .detail-grid { grid-template-columns: 340px 1fr; align-items: start; } }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); }
.stepper button { width: 34px; height: 34px; border: 0; background: transparent; font-size: 1.2rem; cursor: pointer; color: var(--accent); }
.stepper b { min-width: 44px; text-align: center; font-size: .95rem; }
.ing { list-style: none; padding: 0; margin: 8px 0 12px; }
.ing li { display: flex; gap: 10px; align-items: baseline; padding: 8px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.ing li:last-child { border-bottom: 0; }
.ing .amt { min-width: 74px; font-weight: 600; text-align: right; flex: none; }
.ing li.group { cursor: default; font-family: var(--display); font-weight: 600; padding-top: 14px; border: 0; color: var(--accent-2); }
.ing li.off { opacity: .4; text-decoration: line-through; }
.ing input { accent-color: var(--accent); width: 18px; height: 18px; flex: none; align-self: center; }
.steps { list-style: none; counter-reset: s; padding: 0; margin: 8px 0 0; }
.steps li { counter-increment: s; position: relative; padding: 0 0 16px 44px; }
.steps li::before { content: counter(s); position: absolute; left: 0; top: -2px; width: 30px; height: 30px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-weight: 700; display: grid; place-items: center; }
.desc { white-space: pre-line; color: var(--text); opacity: .92; }
.raw { white-space: pre-wrap; font-size: .9rem; background: var(--surface-2); border-radius: 12px; padding: 12px; max-height: 260px; overflow: auto; }

/* Einkauf */
.add-row { display: flex; gap: 8px; margin-bottom: 14px; } .add-row input { flex: 1; border-radius: 999px; }
.aisle { margin: 18px 0 6px; font-size: .78rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.shop { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.shop .item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.shop .item:last-child { border-bottom: 0; }
.shop .check { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--line); background: transparent; flex: none; cursor: pointer; display: grid; place-items: center; color: #fff; padding: 0; }
.shop .item.done .check { background: var(--ok); border-color: var(--ok); }
.shop .item.done .nm { text-decoration: line-through; color: var(--muted); }
.shop .nm { flex: 1; min-width: 0; cursor: pointer; } .shop .nm small { display: block; color: var(--muted); font-size: .76rem; }
.shop .qty { color: var(--muted); font-weight: 600; font-size: .9rem; white-space: nowrap; }
.shop .x { border: 0; background: transparent; color: var(--muted); font-size: 1.1rem; cursor: pointer; padding: 4px; opacity: .6; }

/* Notizen */
.notes { display: grid; gap: 12px; grid-template-columns: 1fr; } @media (min-width: 640px) { .notes { grid-template-columns: 1fr 1fr; } }
.note { display: block; text-align: left; width: 100%; cursor: pointer; }
.note h3 { margin-bottom: 4px; } .note p { margin: 0; color: var(--muted); white-space: pre-line; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; font-size: .92rem; }
.note-edit textarea { min-height: 50vh; border: 0; box-shadow: none; padding: 4px 0; background: transparent; font-size: 1.02rem; }
.note-edit input.title { border: 0; box-shadow: none; padding: 4px 0; font: 700 1.5rem var(--display); background: transparent; }
.saved { font-size: .8rem; color: var(--muted); }

/* Anmeldung */
.auth { max-width: 380px; margin: 8vh auto 0; text-align: center; }
.auth .logo { font-size: 3.4rem; color: var(--accent); }
.auth h1 { margin: 4px 0 18px; } .auth form { text-align: left; }
.error { color: var(--danger); font-size: .9rem; margin: 4px 0 10px; min-height: 1.2em; }

/* Dialog & Toast */
.overlay { position: fixed; inset: 0; z-index: 60; background: rgba(20, 12, 8, .5); display: flex; align-items: flex-end; justify-content: center; animation: fade .15s; }
.sheet { width: 100%; max-width: 520px; max-height: 88vh; overflow: auto; background: var(--surface); border-radius: 22px 22px 0 0; padding: 20px 18px calc(18px + env(safe-area-inset-bottom)); }
@media (min-width: 800px) { .overlay { align-items: center; } .sheet { border-radius: 22px; } }
.sheet h2 { margin-bottom: 12px; } .sheet .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 14px; }
#toast { position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + var(--tabbar-safe) + 20px); transform: translate(-50%, 20px); z-index: 80; display: flex; gap: 14px; align-items: center; padding: 11px 18px; border-radius: 999px; background: #2b211c; color: #fff; font-size: .92rem; opacity: 0; pointer-events: none; transition: .22s; max-width: 92vw; }
#toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; } #toast button { background: none; border: 0; color: #ffb59d; font-weight: 700; cursor: pointer; }
@media (min-width: 800px) { #toast { bottom: 28px; } }
.copybox { word-break: break-all; font: .85rem/1.4 ui-monospace, Menlo, Consolas, monospace; background: var(--surface-2); padding: 10px 12px; border-radius: 10px; margin: 8px 0; user-select: all; }
.import-grid { display: grid; gap: 14px; } .dropthumbs { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.dropthumbs img { width: 64px; height: 64px; object-fit: cover; border-radius: 10px; }
.pic-edit { display: flex; gap: 12px; align-items: center; margin-bottom: 12px; }
.pic-edit .thumb { width: 84px; height: 64px; border-radius: 10px; background: var(--surface-2) center / cover no-repeat; flex: none; }
hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
