/* Einkauf – Atelier-Stil: Georgia-Überschriften, Salbei-Akzent, ruhige Flächen. Mobile first. */
:root {
  --accent: #9dcbb2;
  --accent-ink: #18241e;
  --accent-strong: #2e7d57;
  --bg: #f6f4ef;
  --card: #ffffff;
  --ink: #1d2320;
  --muted: #66706b;
  --line: #e4e1d8;
  --soft: color-mix(in srgb, var(--accent) 18%, transparent);
  --danger: #c0392b;
  --danger-soft: color-mix(in srgb, var(--danger) 10%, transparent);
  --shadow: 0 1px 2px rgba(20, 30, 25, .05), 0 8px 24px rgba(20, 30, 25, .06);
  --r-card: 24px;
  --r: 14px;
  --serif: Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --tabbar-h: 64px;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151a17;
    --card: #1e2421;
    --ink: #e9ece9;
    --muted: #9aa49f;
    --line: #2f3833;
    --soft: color-mix(in srgb, var(--accent) 14%, transparent);
    --accent-strong: #9dcbb2;
    --danger: #ef6f62;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
body.no-scroll { overflow: hidden; }
h1, h2, h3 { font-family: var(--serif); font-weight: 400; margin: 0; letter-spacing: .1px; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.3rem; }
a { color: inherit; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; padding: 0; }
button:disabled { opacity: .45; cursor: default; }
:focus-visible { outline: 2px solid var(--accent-strong); outline-offset: 2px; }
[hidden] { display: none !important; }
.ic { width: 20px; height: 20px; flex: none; }
.muted { color: var(--muted); }
.pad { padding: 24px; }

/* ---------- Grundgerüst ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  padding: calc(10px + var(--sat)) calc(16px + var(--sar)) 10px calc(16px + var(--sal));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent);
}
.brand { font-family: var(--serif); font-size: 1.35rem; flex: 1; }
.tabs { display: none; gap: 6px; }
.tab {
  display: flex; align-items: center; gap: 8px; text-decoration: none;
  padding: 0 16px; height: 44px; border-radius: 22px; color: var(--muted); font-weight: 500;
}
.tab.active { background: var(--accent); color: var(--accent-ink); }
.bottom-tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(3, 1fr);
  padding: 6px calc(8px + var(--sar)) calc(6px + var(--sab)) calc(8px + var(--sal));
  background: color-mix(in srgb, var(--card) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-top: 1px solid var(--line);
}
.bottom-tabs .tab {
  flex-direction: column; gap: 2px; height: 52px; justify-content: center; padding: 0;
  font-size: .75rem; border-radius: 16px;
}
.bottom-tabs .tab .ic { width: 24px; height: 24px; }
.bottom-tabs .tab.active { background: var(--soft); color: var(--accent-strong); }
body.logged-out .bottom-tabs, body.logged-out .tabs { display: none !important; }

main.view {
  max-width: 1180px; margin: 0 auto;
  padding: 16px calc(12px + var(--sar)) calc(var(--tabbar-h) + 28px + var(--sab)) calc(12px + var(--sal));
  outline: none;
}
.offline {
  margin: 8px 12px 0; padding: 10px 14px; border-radius: var(--r);
  background: #fff4d6; color: #5c4400; font-size: .9rem; text-align: center;
}

@media (min-width: 820px) {
  .tabs { display: flex; }
  .bottom-tabs { display: none; }
  main.view { padding: 24px 24px 48px; }
}

/* ---------- Karten, Knöpfe ---------- */
.card {
  background: var(--card); border-radius: var(--r-card); box-shadow: var(--shadow);
  padding: 18px 16px; margin-bottom: 16px;
}
@media (min-width: 600px) { .card { padding: 22px 22px; } }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h1, .card-head h2 { flex: 1; min-width: 0; }
.count { color: var(--muted); font-size: .9rem; }
.card-head .count { order: 0; flex: none; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 18px; border-radius: var(--r);
  border: 1px solid var(--line); background: transparent; font-weight: 500; white-space: nowrap;
}
.btn:hover:not(:disabled) { border-color: var(--accent); background: var(--soft); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover:not(:disabled) { filter: brightness(.96); background: var(--accent); }
.btn.small { min-height: 40px; padding: 0 14px; font-size: .92rem; }
.btn.big { min-height: 52px; width: 100%; font-size: 1.05rem; }
.btn.grow, .grow { flex: 1; }
.btn small { display: block; font-size: .75rem; color: var(--muted); font-weight: 400; }
.btn.danger-soft, .icon-btn.danger-soft { color: var(--danger); }
.btn.armed, .icon-btn.armed { background: var(--danger); border-color: var(--danger); color: #fff; width: auto; padding: 0 14px; font-size: .9rem; }
.icon-btn {
  width: 48px; height: 48px; flex: none; border-radius: var(--r);
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); color: var(--ink);
}
.icon-btn:hover:not(:disabled), .icon-btn.on { border-color: var(--accent); background: var(--soft); }
.icon-btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.icon-btn.ghost { border-color: transparent; }
.icon-btn.small { width: 40px; height: 40px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.actions { display: flex; gap: 8px; margin-bottom: 12px; }
.info { margin: 0 0 12px; padding: 12px 14px; border-radius: var(--r); background: var(--soft); font-size: .95rem; }
.info.bad { background: var(--danger-soft); }
.hint { color: var(--muted); font-size: .9rem; margin: 4px 0 12px; }
.empty { color: var(--muted); font-family: var(--serif); font-style: italic; padding: 12px 4px; margin: 0; }
.pill { font-size: .75rem; padding: 2px 10px; border-radius: 999px; background: var(--soft); color: var(--accent-strong); font-weight: 600; }

/* ---------- Formulare ---------- */
input, select, textarea {
  font: inherit; font-size: 16px; /* iOS zoomt sonst */
  width: 100%; min-height: 48px; padding: 10px 14px; border-radius: var(--r);
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  -webkit-appearance: none; appearance: none;
}
select {
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 20px) 21px, calc(100% - 15px) 21px; background-size: 5px 5px; background-repeat: no-repeat;
  padding-right: 36px;
}
textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent-strong); box-shadow: 0 0 0 3px var(--soft); }
.form { display: grid; gap: 14px; }
.form.inset { padding: 14px; border-radius: 18px; background: var(--soft); margin-bottom: 8px; }
.form label { display: grid; gap: 6px; font-size: .85rem; color: var(--muted); }
.form label input, .form label select, .form label textarea { color: var(--ink); }
.grid4 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (min-width: 600px) { .grid4 { grid-template-columns: repeat(4, 1fr); } }
.err { color: var(--danger); margin: 0; }

/* ---------- Login ---------- */
.view-login { display: grid; place-items: center; min-height: 80vh; }
.login { width: min(420px, 100%); display: grid; gap: 14px; padding: 32px 24px; text-align: center; }
.login label { text-align: left; display: grid; gap: 6px; font-size: .85rem; color: var(--muted); }
.login-logo { width: 72px; height: 72px; margin: 0 auto; border-radius: 22px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; }
.login-logo .ic { width: 36px; height: 36px; }
.login h1 { font-size: 2rem; }
.login p { margin: 0; }

/* ---------- Einkaufen ---------- */
.cols { display: grid; gap: 16px; align-items: start; }
.cols .card { margin: 0; }
@media (min-width: 900px) { .cols { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); } .fav-card { position: sticky; top: 88px; } }
.add-row { display: flex; gap: 8px; margin-bottom: 8px; }
.group { margin-top: 8px; }
.group-h {
  display: flex; align-items: center; gap: 8px; font-family: var(--sans); font-size: .78rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 14px 4px 6px;
}
.items { list-style: none; margin: 0; padding: 0; }
.item { position: relative; overflow: hidden; border-top: 1px solid var(--line); }
.items .item:first-child { border-top: 0; }
.swipe-bg {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: flex-end; padding-right: 20px;
  background: var(--danger); color: #fff; opacity: 0;
}
.item.swiping .swipe-bg { opacity: 1; }
.item-inner {
  position: relative; display: flex; align-items: center; gap: 10px; min-height: 56px; padding: 4px 0 4px 2px;
  background: var(--card); transition: transform .18s ease; touch-action: pan-y;
}
.item.swiping .item-inner { transition: none; }
.check {
  width: 28px; height: 28px; flex: none; border-radius: 9px; border: 2px solid var(--accent-strong);
  display: grid; place-items: center; color: var(--accent-ink);
}
.check .ic { width: 18px; height: 18px; stroke-width: 3; }
.is-done .check { background: var(--accent); border-color: var(--accent); }
.name { flex: 1; min-width: 0; text-align: left; overflow-wrap: anywhere; padding: 8px 0; font-size: 1.02rem; }
.is-done .name { text-decoration: line-through; color: var(--muted); }
.qty-text { color: var(--muted); font-size: .9rem; }
.stepper { display: flex; align-items: center; gap: 2px; }
.qty { min-width: 58px; text-align: center; font-variant-numeric: tabular-nums; font-size: .93rem; color: var(--muted); }
.pm { width: 36px; height: 36px; border-radius: 11px; border: 1px solid var(--line); display: grid; place-items: center; }
.pm .ic { width: 16px; height: 16px; }
.del { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; color: var(--muted); }
.del:hover { color: var(--danger); background: var(--danger-soft); }
@media (max-width: 400px) {
  .qty { min-width: 46px; font-size: .85rem; }
  .pm { width: 32px; height: 32px; }
  .item-inner { gap: 6px; }
  .del { width: 34px; }
}
.done-toggle { margin: 12px 4px 4px; color: var(--muted); font-size: .9rem; text-decoration: underline; text-underline-offset: 3px; min-height: 40px; }
.items.done .item-inner { opacity: .7; }

.fav-group { margin-top: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px;
  border-radius: var(--r); border: 1px solid var(--line); transition: background .15s, border-color .15s;
}
.chip .ic { width: 16px; height: 16px; color: var(--muted); }
.chip small { color: var(--muted); font-variant-numeric: tabular-nums; }
.chip:hover { border-color: var(--accent); }
.chip.on { background: var(--soft); border-color: var(--accent); }
.chip.on .ic { color: var(--accent-strong); }
.chip.flash { background: var(--accent); color: var(--accent-ink); }
.chip.edit { border-style: dashed; }
.chip.edit .ic { color: var(--danger); }

/* ---------- Planen ---------- */
.week-nav { display: flex; gap: 6px; align-items: center; }
.banner { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; padding: 12px 14px; border-radius: var(--r); background: var(--soft); }
.days { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
@media (min-width: 900px) { .days { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); } }
.day { border: 1px solid var(--line); border-radius: 18px; padding: 12px; }
.day.today { border-color: var(--accent); box-shadow: 0 0 0 2px var(--soft); }
.day.past { opacity: .6; }
.day-h { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.day-body { display: grid; gap: 8px; }
.meal { display: flex; align-items: center; gap: 10px; }
.meal img, .meal-ph { width: 56px; height: 56px; border-radius: 12px; object-fit: cover; flex: none; background: var(--soft); display: grid; place-items: center; color: var(--muted); }
.meal-name { flex: 1; min-width: 0; text-decoration: none; font-family: var(--serif); font-size: 1.08rem; overflow-wrap: anywhere; }
a.meal-name:hover { text-decoration: underline; }
.add-meal {
  display: flex; align-items: center; gap: 8px; justify-content: center; min-height: 48px; border-radius: var(--r);
  border: 1px dashed var(--line); color: var(--muted);
}
.add-meal:hover { border-color: var(--accent); color: var(--ink); background: var(--soft); }
.day-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.day-pick .btn { flex-direction: column; gap: 0; min-height: 60px; }

/* ---------- Rezepte ---------- */
.search-row { position: relative; margin-bottom: 14px; }
.search-row input { padding-left: 44px; }
.search-ic { position: absolute; left: 14px; top: 14px; color: var(--muted); pointer-events: none; }
.recipe-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
@media (max-width: 420px) { .recipe-grid { grid-template-columns: 1fr 1fr; gap: 10px; } }
.tile { text-decoration: none; display: grid; gap: 6px; }
.tile-img { aspect-ratio: 4 / 3; border-radius: 16px; overflow: hidden; background: var(--soft); display: grid; place-items: center; color: var(--muted); }
.tile-img img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .25s; }
.tile:hover .tile-img img { transform: scale(1.03); }
.tile-name { font-family: var(--serif); font-size: 1.02rem; line-height: 1.25; overflow-wrap: anywhere; }
.tile-meta { display: flex; align-items: center; gap: 4px; color: var(--muted); font-size: .8rem; }
.tile-meta .ic { width: 14px; height: 14px; }
.recipe-top { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.spacer { flex: 1; }
.hero { width: 100%; height: 220px; object-fit: cover; border-radius: 18px; display: block; margin-bottom: 16px; }
@media (max-width: 600px) { .hero { height: 180px; } }
.recipe-title { font-size: 1.8rem; line-height: 1.2; margin-bottom: 8px; }
.meta { display: flex; flex-wrap: wrap; gap: 8px 16px; color: var(--muted); font-size: .9rem; margin-bottom: 8px; }
.meta span { display: inline-flex; gap: 6px; align-items: center; }
.meta .ic { width: 16px; height: 16px; }
.source { display: inline-flex; gap: 6px; align-items: center; color: var(--accent-strong); font-size: .9rem; margin-bottom: 8px; }
.source .ic { width: 16px; height: 16px; }
.recipe-cols { display: grid; gap: 24px; margin-top: 12px; }
@media (min-width: 820px) { .recipe-cols { grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); } }
.recipe-cols h2 { margin: 8px 0 10px; }
.ingredients { list-style: none; padding: 0; margin: 0 0 12px; }
.ingredients li { padding: 10px 2px; border-top: 1px solid var(--line); }
.ingredients li:first-child { border-top: 0; }
.steps { margin: 0; padding-left: 0; list-style: none; counter-reset: s; display: grid; gap: 14px; }
.steps li { counter-increment: s; display: grid; grid-template-columns: 32px 1fr; gap: 10px; line-height: 1.55; }
.steps li::before { content: counter(s); width: 28px; height: 28px; border-radius: 50%; background: var(--soft); color: var(--accent-strong); font-weight: 600; font-size: .85rem; display: grid; place-items: center; }
.notes { white-space: pre-line; }

.seg { display: flex; gap: 4px; padding: 4px; border: 1px solid var(--line); border-radius: 26px; margin-bottom: 16px; }
.seg button { flex: 1; min-height: 44px; border-radius: 22px; display: flex; align-items: center; justify-content: center; gap: 6px; font-weight: 500; color: var(--muted); }
.seg button.on { background: var(--accent); color: var(--accent-ink); }
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; }
.thumbs img { width: 72px; height: 72px; object-fit: cover; border-radius: 10px; }
.photo { display: flex; gap: 14px; align-items: center; }
.photo-box { width: 120px; height: 90px; border-radius: 14px; overflow: hidden; background: var(--soft); display: grid; place-items: center; color: var(--muted); flex: none; }
.photo-box img { width: 100%; height: 100%; object-fit: cover; }
.photo-btns { display: grid; gap: 8px; }
.pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.pick { display: grid; gap: 6px; text-align: left; padding: 6px; border-radius: 14px; border: 1px solid transparent; }
.pick:hover { border-color: var(--accent); background: var(--soft); }
.pick img, .pick .meal-ph { width: 100%; height: auto; aspect-ratio: 4 / 3; border-radius: 10px; object-fit: cover; }
.pick span { font-family: var(--serif); line-height: 1.25; }
.pick-free { margin-bottom: 12px; }
.pick-free .btn { width: 100%; justify-content: flex-start; white-space: normal; text-align: left; }

/* ---------- Bottom-Sheet ---------- */
.sheet-wrap { position: fixed; inset: 0; z-index: 50; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(10, 15, 12, .45); opacity: 0; transition: opacity .2s; }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: calc(100% - 24px - var(--sat));
  display: flex; flex-direction: column;
  background: var(--card); border-radius: 24px 24px 0 0; box-shadow: 0 -8px 40px rgba(0, 0, 0, .2);
  transform: translateY(100%); transition: transform .22s cubic-bezier(.2, .8, .2, 1);
  padding-bottom: var(--sab);
}
.sheet-wrap.open .sheet-backdrop { opacity: 1; }
.sheet-wrap.open .sheet { transform: none; }
.sheet-grip { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 8px auto 0; }
.sheet-head { display: flex; align-items: center; gap: 8px; padding: 6px 12px 6px calc(20px + var(--sal)); }
.sheet-head h2 { flex: 1; font-size: 1.25rem; }
.sheet-body { overflow: auto; padding: 4px calc(20px + var(--sar)) 20px calc(20px + var(--sal)); -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.sticky-actions { position: sticky; bottom: -20px; background: var(--card); padding: 12px 0; margin-bottom: -8px; }
@media (min-width: 700px) {
  .sheet-wrap { display: grid; place-items: center; }
  .sheet { position: relative; width: min(560px, calc(100% - 48px)); max-height: 86vh; border-radius: 24px; transform: translateY(20px); opacity: 0; transition: transform .2s, opacity .2s; padding-bottom: 0; }
  .sheet.wide { width: min(820px, calc(100% - 48px)); }
  .sheet-wrap.open .sheet { opacity: 1; }
  .sheet-grip { display: none; }
  .sheet-head { padding-top: 14px; }
}

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 20px + var(--sab)); z-index: 60;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  max-width: calc(100% - 32px); padding: 12px 18px; border-radius: 14px;
  background: var(--ink); color: var(--bg); font-size: .95rem; box-shadow: var(--shadow);
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--danger); color: #fff; }
@media (min-width: 820px) { .toast { bottom: 28px; } }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
