:root {
  --bg: #f6f5f2;
  --card: #ffffff;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --line: #e3e1dc;
  --accent: #2e7d5b;
  --accent-soft: #e3f1ea;
  --warn: #b45309;
  --warn-soft: #fdf3e3;
  --danger: #c0392b;
  --radius: 14px;
  --tabs-h: 62px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111312;
    --card: #1c1f1e;
    --text: #f2f2f2;
    --muted: #9a9a9f;
    --line: #2c302e;
    --accent: #4fb58a;
    --accent-soft: #1d3329;
    --warn: #f0a94b;
    --warn-soft: #33281a;
    --danger: #ff6b5b;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding-bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 16px);
}
body.bare .tabs, body.bare .top { display: none; }
a { color: var(--accent); text-decoration: none; }
h1 { font-size: 1.5rem; margin: .4rem 0; }
h2 { font-size: 1.15rem; margin: 1.4rem 0 .5rem; }
h3 { font-size: .95rem; margin: 1.2rem 0 .4rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }

/* ---------- Kopf & Tabs */
.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 8px) 16px 8px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.top h1 { font-size: 1.15rem; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: flex; height: calc(var(--tabs-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--card); border-top: 1px solid var(--line);
}
.tabs a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: .75rem; color: var(--muted); gap: 2px;
}
.tabs a span { font-size: 1.35rem; filter: grayscale(1); opacity: .7; }
.tabs a.on { color: var(--accent); font-weight: 600; }
.tabs a.on span { filter: none; opacity: 1; }

main { max-width: 640px; margin: 0 auto; padding: 12px 16px; }

/* ---------- Allgemein */
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.pad { padding: 2rem 0; }
.error { color: var(--danger); }
.row { display: flex; align-items: center; justify-content: space-between; }
.row.gap { gap: 8px; justify-content: flex-start; margin: 12px 0; }
.row.end { justify-content: flex-end; }

button, .btn, .chip {
  font: inherit; color: inherit; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
button { background: none; border: 0; padding: 0; }
.btn, .primary, .danger {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 0 18px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--card); font-weight: 600;
}
.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.danger { color: var(--danger); }
.block { display: flex; width: 100%; margin: 12px 0; }
.icon { display: inline-flex; align-items: center; justify-content: center; min-width: 40px; min-height: 40px; font-size: 1.2rem; border-radius: 10px; }
.icon.small { min-width: 32px; min-height: 32px; font-size: .9rem; color: var(--muted); }
.link { color: var(--accent); font-weight: 600; padding: 8px 0; }

input, textarea, select {
  font: inherit; color: var(--text); width: 100%;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 11px 12px; min-height: 44px;
}
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
textarea { resize: vertical; }
label { display: block; font-weight: 600; font-size: .9rem; margin: 10px 0; }
label input, label textarea { margin-top: 4px; font-weight: 400; }
label.check { display: flex; align-items: center; gap: 10px; font-weight: 500; }
label.check input { width: 22px; min-height: 22px; height: 22px; margin: 0; accent-color: var(--accent); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 8px -16px; padding: 0 16px; }
.chips.scroll::-webkit-scrollbar { display: none; }
.chips.center { justify-content: center; }
.chip {
  display: inline-flex; align-items: center; white-space: nowrap;
  min-height: 36px; padding: 0 14px; border-radius: 99px;
  border: 1px solid var(--line); background: var(--card); font-size: .9rem;
}
.chip.small { min-height: 32px; padding: 0 11px; font-size: .82rem; }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip.member { --c: var(--accent); }
.chip.member.on { background: var(--c); border-color: var(--c); }
.chip.big { min-height: 52px; padding: 0 24px; font-size: 1.1rem; font-weight: 600; }

.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; vertical-align: 1px; }
.meta { display: block; color: var(--muted); font-size: .85rem; }
.warn { color: var(--warn); font-size: .85rem; font-weight: 600; margin-top: 2px; }
.warn.soft { background: var(--warn-soft); padding: 10px 12px; border-radius: 12px; font-weight: 500; margin: 10px 0; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.badge { font-size: .78rem; padding: 3px 9px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.thumb {
  flex: none; width: 52px; height: 52px; border-radius: 12px; overflow: hidden;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent-soft); font-size: 1.7rem;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb.sm { width: 42px; height: 42px; font-size: 1.35rem; border-radius: 10px; }
.row-main { flex: 1; min-width: 0; display: block; text-align: left; }
.row-title { display: block; font-weight: 600; }

/* ---------- Woche */
.weekbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.weekbar .icon { font-size: 1.6rem; color: var(--accent); }
.weeklabel { font-weight: 600; display: flex; flex-direction: column; align-items: center; }
.weeklabel small { color: var(--accent); font-weight: 500; font-size: .75rem; }
.days { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.day { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.day.today { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.day.past { opacity: .6; }
.dayhead { display: flex; align-items: center; justify-content: space-between; }
.dname { font-weight: 700; }
.day.today .dname { color: var(--accent); }
.shop { font-size: .85rem; min-height: 34px; padding: 0 10px; border-radius: 99px; filter: grayscale(1); opacity: .45; }
.shop.on { filter: none; opacity: 1; background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.entry { display: flex; gap: 10px; width: 100%; padding: 8px 0; align-items: flex-start; border-top: 1px solid var(--line); margin-top: 6px; }
.leftover { font-size: .88rem; color: var(--muted); padding: 6px 0 0; }
.add { color: var(--accent); font-weight: 600; font-size: .9rem; padding: 8px 0 2px; }

/* ---------- Rezepte */
.searchbar input { border-radius: 99px; padding-left: 16px; }
.count { margin: 4px 0 8px; }
.cards { display: grid; gap: 8px; }
.card {
  display: flex; gap: 12px; align-items: flex-start; color: inherit;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px;
}
.fab {
  position: fixed; right: 16px; bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 14px);
  background: var(--accent); color: #fff; font-weight: 600; padding: 13px 18px; border-radius: 99px;
  box-shadow: 0 6px 20px rgba(0,0,0,.18);
}
.back { display: inline-block; padding: 6px 0; font-weight: 600; }
.hero {
  height: 180px; border-radius: var(--radius); overflow: hidden; margin: 6px 0 10px;
  background: var(--accent-soft); display: flex; align-items: center; justify-content: center; font-size: 5rem;
}
.hero img { width: 100%; height: 100%; object-fit: cover; }
.section-head { display: flex; align-items: center; justify-content: space-between; }
.ings { padding-left: 1.1rem; }
.ings li { padding: 3px 0; }
.steps { padding-left: 1.3rem; }
.steps li { padding: 5px 0; }
.stepper { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--line); border-radius: 99px; background: var(--card); }
.stepper button { width: 38px; height: 36px; font-size: 1.2rem; color: var(--accent); }
.stepper span { min-width: 2.5ch; text-align: center; font-weight: 600; font-size: .9rem; }

.form .two, .field.two { display: flex; gap: 8px; }
.narrow-first > :first-child { width: 64px; flex: none; text-align: center; font-size: 1.4rem; padding: 6px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 8px; }
.grid3 label { font-size: .8rem; margin: 6px 0; }

/* ---------- Sheet */
dialog#sheet {
  width: 100%; max-width: 640px; max-height: 92dvh; margin: auto auto 0;
  padding: 0; border: 0; border-radius: 20px 20px 0 0;
  background: var(--bg); color: var(--text);
}
dialog#sheet::backdrop { background: rgba(0,0,0,.4); }
dialog#sheet[open] { animation: up .22s ease-out; }
@keyframes up { from { transform: translateY(40px); opacity: .5; } to { transform: none; opacity: 1; } }
.sheet-body { padding: 14px 16px calc(16px + env(safe-area-inset-bottom)); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; }
.sheet-head h2 { margin: 0; }
.field { margin: 12px 0; }
.field > label { margin: 0 0 4px; }
.field.row > label { margin: 0; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; flex: none; }
.seg button { padding: 0 14px; min-height: 44px; background: var(--card); }
.seg button.on { background: var(--accent); color: #fff; font-weight: 600; }
.picked { display: flex; gap: 10px; align-items: flex-start; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 8px; }
.picker { margin-top: 8px; }
.pick-filters .chips.scroll { margin: 6px -16px; }
.pick-list { max-height: 38dvh; overflow-y: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--card); }
.pick { display: flex; gap: 10px; width: 100%; padding: 8px; border-bottom: 1px solid var(--line); align-items: flex-start; }
.pick:last-child { border-bottom: 0; }
.sheet-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }
.sheet-actions .primary { flex: 1; }

/* ---------- Einkauf */
.meals { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin: 8px 0; }
.meals summary { font-weight: 600; cursor: pointer; }
.meals ul { margin: 8px 0 0; padding-left: 1.1rem; font-size: .9rem; }
.items { list-style: none; margin: 0; padding: 0; background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
.item { display: flex; align-items: center; gap: 6px; padding: 0 8px 0 12px; border-bottom: 1px solid var(--line); min-height: 48px; }
.item:last-child { border-bottom: 0; }
.item label { flex: 1; display: flex; align-items: center; gap: 12px; margin: 0; font-weight: 400; font-size: 1rem; padding: 8px 0; }
.item input[type=checkbox] { width: 22px; height: 22px; min-height: 22px; flex: none; margin: 0; accent-color: var(--accent); }
.item-text { display: flex; flex-direction: column; flex: 1; }
.item-text small { color: var(--muted); font-size: .75rem; }
.item.done .item-text > span { text-decoration: line-through; color: var(--muted); }
.item.pantry { opacity: .75; justify-content: space-between; padding: 8px 8px 8px 12px; }
.addextra { display: flex; gap: 8px; margin: 10px 0; }
.addextra .btn { flex: none; }
.empty { text-align: center; padding: 2rem 0; }

/* ---------- Einstellungen */
.allergy-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; margin: 10px 0; }
.allergy-card h3 { margin: 0 0 4px; color: var(--text); text-transform: none; letter-spacing: 0; font-size: 1rem; }

/* ---------- Login */
.login { max-width: 360px; margin: 12vh auto 0; text-align: center; }
.login .logo { font-size: 3.5rem; }
.login input { margin: 12px 0 0; text-align: center; }

/* ---------- Toast */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 20px);
  transform: translate(-50%, 20px); opacity: 0; transition: .25s;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 99px; font-size: .9rem; z-index: 50;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.login .subtitle { margin: -4px 0 8px; color: var(--muted); font-size: 1.05rem; }
