:root {
  --bg: #f6f3ec;
  --card: #fff;
  --text: #24221f;
  --muted: #7a756c;
  --line: #00000014;
  --accent: #2f8f4e;
  --accent-soft: #2f8f4e1a;
  --like: #2f8f4e;
  --nope: #d64545;
  --super: #e0a100;
  --warn: #b86e00;
  --radius: 16px;
  --tabbar: 62px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1b1d; --card: #29292c; --text: #eee; --muted: #9b978f; --line: #ffffff14;
    --accent: #4cb46c; --accent-soft: #4cb46c26; --warn: #e3a040;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  padding-top: env(safe-area-inset-top);
  padding-bottom: calc(var(--tabbar) + env(safe-area-inset-bottom) + 12px);
  -webkit-tap-highlight-color: transparent;
}
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
h1 { font-size: 1.35rem; margin: 4px 0 8px; }
h2 { font-size: 1.1rem; margin: 18px 0 8px; }
h2:first-child { margin-top: 0; }
h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 18px 0 6px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.warn { color: var(--warn); }
.error { color: var(--nope); font-weight: 600; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row.center { justify-content: center; }
.row.between { justify-content: space-between; }
.stack { display: grid; gap: 10px; justify-items: start; }

/* ---------- Kopf & Navigation ---------- */
header.top {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 16px; gap: 8px; max-width: 640px; margin: 0 auto;
}
.brand { font-weight: 800; text-decoration: none; font-size: 1.1rem; }
.pill {
  text-decoration: none; background: var(--card); border: 1px solid var(--line);
  padding: 6px 12px; border-radius: 999px; font-size: .9rem; font-weight: 600;
}
.content { max-width: 640px; margin: 0 auto; padding: 0 12px; }
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; background: var(--card); 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;
  height: var(--tabbar); text-decoration: none; font-size: .72rem; color: var(--muted); position: relative; gap: 2px;
}
.tabbar a span { font-size: 1.3rem; filter: grayscale(1); opacity: .7; }
.tabbar a.active { color: var(--text); font-weight: 600; }
.tabbar a.active span { filter: none; opacity: 1; }
.badge {
  position: absolute; top: 6px; left: calc(50% + 6px); background: var(--nope); color: #fff;
  font-size: .7rem; min-width: 18px; height: 18px; border-radius: 9px; padding: 0 5px;
  display: grid; place-items: center;
}
.flash {
  background: var(--accent-soft); border: 1px solid var(--accent); border-radius: 12px;
  padding: 10px 14px; margin: 0 0 12px;
}

/* ---------- Bausteine ---------- */
.panel { background: var(--card); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.button, button.primary, button.secondary, button.danger {
  display: inline-block; text-decoration: none; border-radius: 12px; padding: 10px 16px;
  border: 1px solid transparent; font-weight: 600; line-height: 1.2;
}
.primary { background: var(--accent); color: #fff !important; }
.secondary { background: transparent; border: 1px solid var(--line) !important; box-shadow: inset 0 0 0 1px var(--line); }
.danger { background: transparent; color: var(--nope) !important; border: 1px solid var(--nope) !important; }
button:disabled { opacity: .45; cursor: default; }
.mini {
  width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg);
  padding: 0; font-weight: 700;
}
.mini.ghost { background: transparent; border-color: transparent; color: var(--muted); }
label { display: block; margin: 10px 0; font-size: .9rem; }
label.inline { display: inline-flex; align-items: center; gap: 8px; margin: 4px 0; }
label.check { display: flex; align-items: center; gap: 8px; }
input:not([type=checkbox]), select {
  display: block; width: 100%; margin-top: 4px; padding: 10px 12px; font-size: 1rem;
  border-radius: 10px; border: 1px solid var(--line); background: var(--bg);
  box-shadow: inset 0 0 0 1px var(--line);
}
input.num { width: 72px; display: inline-block; margin: 0; text-align: center; }
input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--accent); margin: 0; flex: none; }
.empty { text-align: center; padding: 40px 16px; }
.empty .big { font-size: 3rem; margin: 0; }
.badge-diet {
  font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
  padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent);
}
.badge-diet.vegetarisch { background: #e0a1001f; color: #a37400; }
.badge-diet.warn { background: #d645451c; color: var(--nope); }

/* ---------- Login ---------- */
.login { margin-top: 10vh; }
.login button { width: 100%; margin-top: 8px; }

/* ---------- Swipen ---------- */
body.app { height: 100dvh; overflow: hidden; display: flex; flex-direction: column; padding-bottom: 0; }
body.app .content {
  flex: 1; min-height: 0; width: 100%; display: flex; flex-direction: column;
  padding-bottom: calc(var(--tabbar) + env(safe-area-inset-bottom));
}
.filters { background: var(--card); border-radius: 12px; padding: 8px 12px; }
.filters summary { cursor: pointer; font-size: .9rem; }
#stage { flex: 1; position: relative; margin-top: 10px; min-height: 0; }
.card {
  position: absolute; inset: 0; background: var(--card); border-radius: var(--radius);
  box-shadow: 0 6px 24px #0000001f; overflow: hidden; display: flex; flex-direction: column;
  touch-action: none; user-select: none; -webkit-user-select: none; transition: transform .25s ease;
}
.card.dragging { transition: none; }
.card.behind { transform: scale(.96) translateY(10px); pointer-events: none; }
.pic {
  position: relative; flex: 1 1 50%; min-height: 120px; background: linear-gradient(135deg, #e7efe2, #f6e9d6);
}
.pic img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.pic .added {
  position: absolute; left: 10px; bottom: 10px; background: #000a; color: #fff;
  font-size: .8rem; padding: 4px 10px; border-radius: 999px;
}
.stamp {
  position: absolute; top: 22px; padding: 4px 12px; border: 4px solid; border-radius: 8px;
  font-weight: 800; font-size: 1.5rem; opacity: 0; background: #fffd; pointer-events: none;
}
.stamp.like { left: 18px; color: var(--like); transform: rotate(-12deg); }
.stamp.nope { right: 18px; color: var(--nope); transform: rotate(12deg); }
.stamp.super { left: 50%; top: auto; bottom: 22px; color: var(--super); transform: translateX(-50%); }
.info { padding: 12px 14px 14px; flex: 0 1 auto; display: flex; flex-direction: column; min-height: 0; }
.meta { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; font-size: .82rem; color: var(--muted); }
.meta .source { margin-left: auto; }
.info h2 { font-size: 1.15rem; margin: 6px 0 4px; line-height: 1.25; }
.info .warn { margin: 0 0 4px; }
.chips {
  list-style: none; padding: 0; margin: 6px 0 8px; display: flex; flex-wrap: wrap; gap: 5px;
  max-height: 92px; overflow-y: auto; touch-action: pan-y;
}
.chips li { font-size: .78rem; background: var(--bg); padding: 3px 9px; border-radius: 999px; }
.info .link { font-size: .9rem; font-weight: 600; color: var(--accent); text-decoration: none; }
.actions { display: flex; justify-content: center; align-items: center; gap: 18px; padding: 12px 0 10px; }
.round {
  width: 62px; height: 62px; border-radius: 50%; border: 0; background: var(--card);
  box-shadow: 0 3px 12px #00000024; font-size: 1.7rem;
}
.round.small { width: 46px; height: 46px; font-size: 1.25rem; }
.round.like { color: var(--like); }
.round.nope { color: var(--nope); }
.round.super { color: var(--super); }
.round:active { transform: scale(.94); }
.overlay {
  position: fixed; inset: 0; background: #000b; z-index: 50; display: grid; place-items: center; padding: 20px;
}
.overlay[hidden] { display: none; }
.match-box { background: var(--card); border-radius: 20px; padding: 20px; text-align: center; width: min(360px, 100%); }
.match-title { font-size: 1.6rem; font-weight: 800; color: var(--accent); margin: 0 0 12px; }
.match-box img { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 12px; }
#matchName { font-weight: 600; }

/* ---------- Detailseite ---------- */
.detail .hero { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: var(--radius); display: block; margin-bottom: 12px; }
.ingredients { padding-left: 20px; line-height: 1.6; margin: 0; }
.matchbox { background: var(--accent-soft); border-radius: 12px; padding: 10px 12px; margin: 12px 0; }
.matchbox form { margin-top: 8px; }
.more { margin-top: 20px; }
.more summary { cursor: pointer; color: var(--muted); }
.more form { margin: 10px 0; }
.more select { width: auto; display: inline-block; margin: 0; }

/* ---------- Listen (Matches, Pool) ---------- */
.tabs { display: flex; gap: 6px; margin-bottom: 12px; background: var(--card); padding: 4px; border-radius: 12px; }
.tabs a {
  flex: 1; text-align: center; padding: 8px 4px; text-decoration: none; border-radius: 9px; font-size: .9rem;
}
.tabs a.active { background: var(--accent); color: #fff; font-weight: 600; }
.tabs .count { opacity: .7; font-size: .8rem; }
.matchlist { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 8px; }
.matchrow {
  display: flex; align-items: center; gap: 10px; background: var(--card); border-radius: 14px; padding: 8px;
}
.matchrow .pick { margin: 0; padding: 8px 2px 8px 6px; }
.matchrow .thumb {
  width: 64px; height: 64px; flex: none; border-radius: 10px; overflow: hidden;
  background: linear-gradient(135deg, #e7efe2, #f6e9d6);
}
.matchrow .thumb img { width: 100%; height: 100%; object-fit: cover; }
.matchrow .text { flex: 1; min-width: 0; text-decoration: none; display: flex; flex-direction: column; gap: 2px; }
.matchrow .text strong { font-size: .95rem; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.matchrow .new {
  align-self: flex-start; font-size: .7rem; font-weight: 700; color: #fff; background: var(--nope);
  padding: 1px 7px; border-radius: 999px;
}
.matchrow .new.super { background: var(--super); }
.matchrow .vote { padding: 0 8px; font-size: 1.1rem; color: var(--muted); }
.sticky-bar {
  position: sticky; bottom: calc(var(--tabbar) + env(safe-area-inset-bottom) + 8px);
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  background: var(--card); border-radius: 14px; padding: 10px 10px 10px 14px; box-shadow: 0 4px 18px #00000024;
}
.sticky-bar .done { color: var(--accent); font-weight: 700; }
.search input { margin: 0 0 8px; }

/* ---------- Einkauf ---------- */
.planlist { list-style: none; padding: 0; margin: 0 0 10px; }
.planlist li { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.planlist li > a { flex: 1; min-width: 0; text-decoration: none; font-weight: 500; }
.stepper { display: flex; align-items: center; gap: 6px; flex: none; font-size: .9rem; }
.additem { display: flex; gap: 8px; margin: 8px 0; }
.additem input { margin: 0; }
.items { list-style: none; padding: 0; margin: 0; }
.items li { display: flex; align-items: center; border-bottom: 1px solid var(--line); }
.item {
  flex: 1; display: grid; grid-template-columns: auto 1fr auto; column-gap: 12px; align-items: center;
  margin: 0; padding: 10px 2px; cursor: pointer; font-size: 1rem;
}
.item .amount { color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; }
.item .usedin { grid-column: 2 / 4; font-size: .75rem; color: var(--muted); }
.item.checked .name, .item.checked .amount { text-decoration: line-through; opacity: .5; }
.items .del { margin: 0; }
.pantry { margin-top: 18px; }
.pantry summary { cursor: pointer; font-weight: 600; }
.close-list { margin-top: 20px; text-align: center; }

/* ---------- Einstellungen ---------- */
.prose { line-height: 1.5; }
.prose h3 { margin-top: 16px; }
.prose ol { padding-left: 20px; }
.prose li { margin: 6px 0; }
.copy { display: flex; gap: 6px; margin: 6px 0; }
.copy input { margin: 0; font: 13px ui-monospace, monospace; }
code { background: var(--bg); padding: 1px 5px; border-radius: 5px; }
