:root {
  --accent: #2f7d6d;
  --accent-ink: #ffffff;
  --bg: #f4f1ea;
  --surface: #ffffff;
  --surface-2: #ebe6db;
  --ink: #1f2522;
  --ink-2: #5d6661;
  --line: #ddd6c8;
  --danger: #c0392b;
  --shadow: 0 1px 2px rgb(0 0 0 / 6%), 0 4px 14px rgb(0 0 0 / 6%);
  --radius: 14px;
  --tab-h: 64px;
  color-scheme: light;
  font-family: "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
:root[data-theme="dark"] {
  --bg: #141816;
  --surface: #1f2522;
  --surface-2: #2a312d;
  --ink: #eef2ef;
  --ink-2: #a4aea8;
  --line: #343c37;
  --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 4px 14px rgb(0 0 0 / 25%);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141816;
    --surface: #1f2522;
    --surface-2: #2a312d;
    --ink: #eef2ef;
    --ink-2: #a4aea8;
    --line: #343c37;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 4px 14px rgb(0 0 0 / 25%);
    color-scheme: dark;
  }
}
[data-accent="teal"] { --accent: #2f7d6d; }
[data-accent="tomato"] { --accent: #d2493f; }
[data-accent="amber"] { --accent: #c97a12; }
[data-accent="plum"] { --accent: #7b4b94; }
[data-accent="ocean"] { --accent: #2b6cb0; }
[data-accent="forest"] { --accent: #3f7d3a; }
[data-accent="rose"] { --accent: #c2477a; }
[data-accent="graphite"] { --accent: #4a5560; }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
.hidden { display: none !important; }

/* ---------- Auth ---------- */
.auth {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  background: radial-gradient(circle at 20% 0%, color-mix(in srgb, var(--accent) 30%, transparent), transparent 60%), var(--bg);
}
.auth-card {
  width: min(420px, 100%);
  background: var(--surface);
  border-radius: 22px;
  padding: 28px 24px;
  box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.brand img { width: 52px; height: 52px; border-radius: 14px; }
.brand h1 { margin: 0; font-size: 1.7rem; letter-spacing: -0.02em; }
.brand p { margin: 2px 0 0; color: var(--ink-2); font-size: 0.92rem; }
.seg { display: flex; background: var(--surface-2); border-radius: 12px; padding: 4px; margin-bottom: 16px; }
.seg button { flex: 1; border: 0; background: none; padding: 9px; border-radius: 9px; font-weight: 700; color: var(--ink-2); }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

.field { display: block; margin-bottom: 12px; }
.field span { display: block; font-size: 0.82rem; font-weight: 700; color: var(--ink-2); margin-bottom: 5px; }
.input, .field input, .field select, .field textarea {
  width: 100%;
  border: 1.5px solid var(--line);
  background: var(--bg);
  border-radius: 12px;
  padding: 11px 13px;
  outline: none;
}
.field textarea { min-height: 120px; resize: vertical; }
.input:focus, .field input:focus, .field textarea:focus, .field select:focus { border-color: var(--accent); }
.btn {
  border: 0;
  border-radius: 12px;
  padding: 12px 16px;
  font-weight: 800;
  background: var(--accent);
  color: var(--accent-ink);
  width: 100%;
}
.btn.secondary { background: var(--surface-2); color: var(--ink); }
.btn.danger { background: color-mix(in srgb, var(--danger) 14%, var(--surface)); color: var(--danger); }
.btn.small { width: auto; padding: 8px 12px; font-size: 0.9rem; }
.btn:disabled { opacity: 0.55; }
.error { color: var(--danger); font-size: 0.9rem; min-height: 1.2em; margin: 4px 0 10px; }
.muted { color: var(--ink-2); }
.row { display: flex; gap: 10px; align-items: center; }
.row > * { flex: 1; }

/* ---------- Shell ---------- */
.app { min-height: 100%; padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom)); }
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--accent);
  color: var(--accent-ink);
  padding: calc(10px + env(safe-area-inset-top)) 16px 12px;
}
.topbar-row { display: flex; align-items: center; gap: 8px; max-width: 760px; margin: 0 auto; }
.list-switch {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  border: 0;
  background: none;
  color: inherit;
  font-size: 1.35rem;
  font-weight: 800;
  padding: 4px 0;
  text-align: left;
}
.list-switch span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn {
  border: 0;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: rgb(255 255 255 / 16%);
  color: inherit;
  font-size: 1.15rem;
  flex: none;
}
.avatars { display: flex; flex: none; }
.avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 0.8rem;
  font-weight: 800;
  background: rgb(255 255 255 / 92%);
  color: var(--accent);
  border: 2px solid var(--accent);
  margin-left: -8px;
}
.avatar:first-child { margin-left: 0; }
.searchbar { max-width: 760px; margin: 10px auto 0; position: relative; display: flex; gap: 8px; }
.searchbar input {
  flex: 1;
  border: 0;
  border-radius: 14px;
  padding: 12px 14px 12px 40px;
  background: var(--surface);
  color: var(--ink);
  outline: none;
  min-width: 0;
}
.searchbar .lens { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); opacity: 0.55; pointer-events: none; }
.mic {
  flex: none;
  width: 46px;
  border: 0;
  border-radius: 14px;
  background: var(--surface);
  color: var(--accent);
  font-size: 1.2rem;
}

main { max-width: 760px; margin: 0 auto; padding: 14px 16px 24px; }
.section { margin-bottom: 18px; }
.section-head {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  border: 0;
  background: none;
  padding: 6px 2px 10px;
  font-weight: 800;
  font-size: 1rem;
  color: var(--ink);
  text-align: left;
}
.section-head .count { color: var(--ink-2); font-weight: 700; font-size: 0.85rem; }
.section-head .chev { margin-left: auto; color: var(--ink-2); transition: transform 0.15s; }
.section.collapsed .chev { transform: rotate(-90deg); }
.section.collapsed .grid { display: none; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.tile {
  position: relative;
  aspect-ratio: 1;
  border: 0;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 6px;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  transition: transform 0.08s ease;
  overflow: hidden;
}
.tile:active { transform: scale(0.95); }
.tile .ic { font-size: 2.1rem; line-height: 1; }
.tile .letter {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 1.2rem;
  background: var(--surface-2);
  color: var(--ink-2);
}
.tile .nm { font-size: 0.8rem; font-weight: 700; line-height: 1.15; text-align: center; overflow-wrap: anywhere; max-height: 2.3em; overflow: hidden; }
.tile .sp { font-size: 0.72rem; line-height: 1.1; opacity: 0.85; text-align: center; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile.buy { background: var(--accent); color: var(--accent-ink); }
.tile.buy .letter { background: rgb(255 255 255 / 22%); color: inherit; }
.tile.recent { background: var(--surface); opacity: 0.92; }
.tile.on-list::after {
  content: "✓";
  position: absolute;
  top: 6px;
  right: 7px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 0.7rem;
  display: grid;
  place-items: center;
  font-weight: 900;
}
.tile.add-new { border: 2px dashed color-mix(in srgb, var(--accent) 55%, transparent); background: transparent; box-shadow: none; color: var(--accent); }
.tile.pop { animation: pop 0.25s ease; }
@keyframes pop { 50% { transform: scale(1.08); } }

.empty {
  text-align: center;
  padding: 26px 16px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: var(--ink-2);
}
.empty .big { font-size: 2.6rem; }
.empty b { display: block; color: var(--ink); font-size: 1.05rem; margin: 6px 0 2px; }

/* ---------- Tabbar ---------- */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 25;
  height: calc(var(--tab-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface);
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: center;
}
.tabbar button {
  flex: 1;
  max-width: 190px;
  border: 0;
  background: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--ink-2);
}
.tabbar button .ti { font-size: 1.35rem; filter: grayscale(1); opacity: 0.7; }
.tabbar button.on { color: var(--accent); }
.tabbar button.on .ti { filter: none; opacity: 1; }

/* ---------- Sheets ---------- */
.backdrop {
  position: fixed;
  inset: 0;
  background: rgb(0 0 0 / 40%);
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fade 0.15s ease;
}
.sheet {
  width: min(560px, 100%);
  max-height: 88vh;
  overflow: auto;
  background: var(--surface);
  border-radius: 22px 22px 0 0;
  padding: 10px 18px calc(22px + env(safe-area-inset-bottom));
  animation: up 0.2s ease;
}
.sheet .grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 12px; }
.sheet h2 { margin: 0 0 14px; font-size: 1.25rem; display: flex; align-items: center; gap: 10px; }
.sheet h3 { margin: 18px 0 8px; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-2); }
@media (min-width: 700px) {
  .backdrop { align-items: center; }
  .sheet { border-radius: 22px; }
}
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(30px); opacity: 0.5; } }

.menu-list { display: flex; flex-direction: column; gap: 2px; }
.menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 0;
  background: none;
  text-align: left;
  padding: 12px 10px;
  border-radius: 12px;
  width: 100%;
}
.menu-item:hover { background: var(--surface-2); }
.menu-item .mi { width: 28px; text-align: center; font-size: 1.2rem; }
.menu-item .sub { display: block; font-size: 0.8rem; color: var(--ink-2); }
.menu-item.active { background: color-mix(in srgb, var(--accent) 12%, transparent); font-weight: 800; }
.dot { width: 14px; height: 14px; border-radius: 50%; background: var(--accent); flex: none; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1.5px solid var(--line);
  background: var(--bg);
  border-radius: 999px;
  padding: 7px 12px;
  font-weight: 700;
  font-size: 0.9rem;
}
.chip.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }
.swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.swatch { width: 36px; height: 36px; border-radius: 50%; border: 3px solid transparent; background: var(--accent); }
.swatch.on { border-color: var(--ink); }
.emoji-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(42px, 1fr)); gap: 4px; }
.emoji-grid button { border: 0; background: var(--bg); border-radius: 10px; font-size: 1.4rem; padding: 6px 0; }
.emoji-grid button.on { outline: 2px solid var(--accent); }
.sec-row { display: flex; align-items: center; gap: 8px; padding: 8px 4px; border-bottom: 1px solid var(--line); }
.sec-row .nm { flex: 1; font-weight: 700; }
.sec-row button { border: 0; background: var(--surface-2); border-radius: 8px; width: 34px; height: 30px; }
.sec-row.off .nm { opacity: 0.45; text-decoration: line-through; }
.code-box {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  background: var(--bg);
  border: 1px dashed var(--line);
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 0.82rem;
  overflow-wrap: anywhere;
  user-select: all;
}
pre.code-box { white-space: pre-wrap; margin: 6px 0; }
.activity { list-style: none; padding: 0; margin: 0; }
.activity li { display: flex; gap: 10px; padding: 9px 2px; border-bottom: 1px solid var(--line); font-size: 0.92rem; }
.activity time { margin-left: auto; color: var(--ink-2); font-size: 0.8rem; flex: none; }

/* ---------- Toast ---------- */
.toasts {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tab-h) + 14px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(480px, calc(100% - 32px));
}
.toast {
  background: var(--ink);
  color: var(--bg);
  border-radius: 14px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: up 0.2s ease;
  font-weight: 600;
}
.toast button { margin-left: auto; border: 0; background: none; color: inherit; font-weight: 800; text-decoration: underline; }
.offline-pill {
  position: fixed;
  top: calc(8px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 70;
  background: #3d3d3d;
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  border-radius: 999px;
  padding: 5px 12px;
}

/* ---------- Voice ---------- */
.voice {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: color-mix(in srgb, var(--accent) 94%, black);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  padding: 24px;
  text-align: center;
}
.voice .pulse {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: rgb(255 255 255 / 18%);
  display: grid;
  place-items: center;
  font-size: 3rem;
  animation: pulse 1.4s infinite;
}
.voice .transcript { font-size: 1.5rem; font-weight: 700; min-height: 2em; max-width: 600px; }
.voice .hint { opacity: 0.8; max-width: 420px; }
.voice .btn { width: auto; background: #fff; color: var(--accent); padding: 12px 28px; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgb(255 255 255 / 40%); } 100% { box-shadow: 0 0 0 36px rgb(255 255 255 / 0%); } }

/* ---------- Rezepte ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 4px 0 14px; }
.page-head h2 { margin: 0; font-size: 1.4rem; }
.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.recipe-card {
  border: 0;
  padding: 0;
  text-align: left;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}
.recipe-card .img {
  aspect-ratio: 4 / 3;
  background: var(--surface-2) center / cover no-repeat;
  display: grid;
  place-items: center;
  font-size: 2.6rem;
}
.recipe-card .body { padding: 10px 12px 12px; }
.recipe-card b { display: block; line-height: 1.2; }
.recipe-card small { color: var(--ink-2); }
.ing { display: flex; align-items: center; gap: 10px; padding: 9px 4px; border-bottom: 1px solid var(--line); }
.ing input { width: 20px; height: 20px; accent-color: var(--accent); }
.ing .ic { font-size: 1.3rem; width: 28px; text-align: center; }
.ing .raw { display: block; font-size: 0.78rem; color: var(--ink-2); }

/* ---------- Karten ---------- */
.loyalty {
  border: 0;
  border-radius: 16px;
  aspect-ratio: 1.586;
  color: #fff;
  padding: 14px;
  text-align: left;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: var(--shadow);
  background-image: linear-gradient(135deg, rgb(255 255 255 / 18%), transparent 60%);
}
.loyalty b { font-size: 1.15rem; }
.loyalty small { opacity: 0.85; font-family: ui-monospace, Consolas, monospace; }
.barcode-wrap { background: #fff; border-radius: 14px; padding: 18px 12px; text-align: center; color: #000; }
.barcode-wrap svg { width: 100%; height: 120px; }
.barcode-wrap .num { font-family: ui-monospace, Consolas, monospace; font-size: 1.1rem; letter-spacing: 0.08em; margin-top: 8px; }

/* ---------- Profil ---------- */
.panel { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; margin-bottom: 14px; }
.panel h3 { margin: 0 0 10px; font-size: 1rem; display: flex; align-items: center; gap: 8px; }
.panel p { margin: 6px 0; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; }
.key-row { display: flex; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.key-row .meta { flex: 1; min-width: 0; }
.key-row .meta small { color: var(--ink-2); display: block; }
ol.steps { padding-left: 20px; margin: 6px 0; }
ol.steps li { margin: 4px 0; }
