:root {
  --grund: #f6f5f1;
  --flaeche: #ffffff;
  --flaeche-2: #efeee8;
  --text: #1c1d1a;
  --leise: #6b6d66;
  --linie: #e2e0d8;
  --akzent: #1f7a4d;
  --akzent-text: #ffffff;
  --akzent-zart: #e3f1e8;
  --coupon: #fff4d6;
  --coupon-rand: #f0c14b;
  --warn: #b4531a;
  --fehler: #b3261e;
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --grund: #141513;
    --flaeche: #1f201d;
    --flaeche-2: #2a2b27;
    --text: #ecebe6;
    --leise: #a3a59c;
    --linie: #34352f;
    --akzent: #4cc085;
    --akzent-text: #0d1f15;
    --akzent-zart: #1c3328;
    --coupon: #3a3118;
    --coupon-rand: #9b7a1e;
    --warn: #f0a070;
    --fehler: #ff8a80;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --grund: #141513; --flaeche: #1f201d; --flaeche-2: #2a2b27; --text: #ecebe6; --leise: #a3a59c;
  --linie: #34352f; --akzent: #4cc085; --akzent-text: #0d1f15; --akzent-zart: #1c3328;
  --coupon: #3a3118; --coupon-rand: #9b7a1e; --warn: #f0a070; --fehler: #ff8a80; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--grund);
  color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3 { margin: 0; line-height: 1.2; }
button { font: inherit; color: inherit; }
.leise { color: var(--leise); margin: 0; font-size: 14px; }
.fehler { color: var(--fehler); min-height: 1.2em; margin: 0; }
[hidden] { display: none !important; }

/* Login */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.login-karte { width: 100%; max-width: 360px; display: grid; gap: 14px; text-align: center; }
.login-karte h1 { font-size: 28px; }
.login-karte label { display: grid; gap: 6px; text-align: left; font-size: 14px; color: var(--leise); }
input {
  font: inherit; color: var(--text); background: var(--flaeche); border: 1px solid var(--linie);
  border-radius: 12px; padding: 13px 14px; width: 100%;
}
input:focus { outline: 2px solid var(--akzent); outline-offset: 1px; }

/* Kopf */
.kopf {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(env(safe-area-inset-top) + 12px) 16px 12px;
  background: color-mix(in srgb, var(--grund) 88%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--linie);
}
.kopf h1 { font-size: 24px; letter-spacing: -0.01em; }
.rund {
  width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--linie);
  background: var(--flaeche); display: grid; place-items: center; flex: none; cursor: pointer;
}
.rund.dreht svg { animation: drehen 1s linear infinite; }
@keyframes drehen { to { transform: rotate(360deg); } }
.hinweis {
  margin: 12px 16px 0; padding: 10px 12px; border-radius: 12px; font-size: 14px;
  background: var(--flaeche-2); color: var(--text);
}
.hinweis.fehler { color: var(--fehler); }

main { padding: 8px 16px calc(env(safe-area-inset-bottom) + 92px); max-width: 640px; margin: 0 auto; }
.tab > * + * { margin-top: 18px; }

/* Zusammenfassung */
.kennzahlen { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.kennzahl { background: var(--flaeche); border: 1px solid var(--linie); border-radius: var(--radius); padding: 10px 12px; }
.kennzahl b { display: block; font-size: 20px; font-variant-numeric: tabular-nums; }
.kennzahl span { font-size: 12px; color: var(--leise); }

/* Abschnitte */
.abschnitt h2 {
  font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--leise);
  font-weight: 600; margin: 0 4px 8px; display: flex; justify-content: space-between; gap: 8px;
}
.liste { background: var(--flaeche); border: 1px solid var(--linie); border-radius: var(--radius); overflow: hidden; }
.markt-hinweis { font-size: 13px; color: var(--warn); padding: 10px 14px 0; margin: 0; }

.posten {
  display: flex; gap: 12px; align-items: flex-start; width: 100%; text-align: left;
  padding: 13px 14px; border: 0; background: none; cursor: pointer; min-height: 56px;
}
.posten + .posten { border-top: 1px solid var(--linie); }
.kreis {
  flex: none; width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--linie);
  display: grid; place-items: center; margin-top: 1px; transition: background .15s, border-color .15s;
}
.kreis svg { opacity: 0; width: 15px; height: 15px; }
.posten[aria-pressed="true"] .kreis { background: var(--akzent); border-color: var(--akzent); color: var(--akzent-text); }
.posten[aria-pressed="true"] .kreis svg { opacity: 1; }
.posten[aria-pressed="true"] .haupt { text-decoration: line-through; color: var(--leise); }
.posten .text { flex: 1; min-width: 0; }
.posten .haupt { font-weight: 550; }
.posten .neben { font-size: 13px; color: var(--leise); margin-top: 2px; }
.posten .preis { flex: none; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.posten .preis small { display: block; font-weight: 400; font-size: 12px; color: var(--akzent); }
.marke { color: var(--leise); font-weight: 400; }
.wer { font-size: 12px; color: var(--akzent); }
.unsicher { font-size: 12px; color: var(--warn); }

.coupons .liste { background: var(--coupon); border-color: var(--coupon-rand); }
.coupons .posten + .posten { border-top-color: var(--coupon-rand); }

/* Rezepte */
.rezept { background: var(--flaeche); border: 1px solid var(--linie); border-radius: 18px; overflow: hidden; }
.rezept img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; display: block; background: var(--flaeche-2); }
.rezept .inhalt { padding: 14px; display: grid; gap: 10px; }
.rezept h3 { font-size: 18px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 12px; padding: 4px 9px; border-radius: 999px; background: var(--flaeche-2); color: var(--text); }
.chip.spar { background: var(--akzent-zart); color: var(--akzent); font-weight: 600; }
.teller { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; }
.teller div { border: 1px solid var(--linie); border-radius: 12px; padding: 8px 10px; }
.teller b { display: block; font-size: 14px; }
.teller span { font-size: 13px; color: var(--leise); font-variant-numeric: tabular-nums; }
.teller .nein { color: var(--warn); }
.teller .ich { border-color: var(--akzent); background: var(--akzent-zart); }
.knopfreihe { display: flex; gap: 8px; flex-wrap: wrap; }
.knopf {
  border: 0; border-radius: 12px; padding: 12px 16px; background: var(--akzent); color: var(--akzent-text);
  font-weight: 600; cursor: pointer; min-height: 46px; text-decoration: none; display: inline-flex;
  align-items: center; justify-content: center;
}
.knopf.leer { background: var(--flaeche-2); color: var(--text); }
.knopf.voll { width: 100%; }
.knopf:disabled { opacity: .5; }
.knopf.klein { padding: 8px 12px; min-height: 38px; font-size: 14px; }
.geplant { font-size: 14px; color: var(--akzent); font-weight: 600; }

/* Prüfen */
.pruef { padding: 14px; display: grid; gap: 10px; }
.pruef + .pruef { border-top: 1px solid var(--linie); }
.pruef .pfeil { color: var(--leise); }

.leer-zustand { text-align: center; color: var(--leise); padding: 40px 12px; }

/* Reiter */
.reiter {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  display: grid; grid-template-columns: repeat(3, 1fr);
  padding: 6px 8px calc(env(safe-area-inset-bottom) + 6px);
  background: color-mix(in srgb, var(--flaeche) 92%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--linie);
}
.reiter button {
  position: relative; border: 0; background: none; display: grid; justify-items: center; gap: 2px;
  padding: 6px 0; font-size: 11px; color: var(--leise); cursor: pointer; min-height: 48px;
}
.reiter svg { width: 26px; height: 26px; }
.reiter [aria-selected="true"] { color: var(--akzent); }
.zahl {
  position: absolute; top: 2px; left: calc(50% + 8px); min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: var(--warn); color: #fff; font-size: 11px; line-height: 18px;
}

/* Dialog */
dialog {
  border: 0; border-radius: 20px; padding: 20px; width: min(420px, calc(100% - 32px));
  background: var(--flaeche); color: var(--text);
}
dialog::backdrop { background: rgb(0 0 0 / .4); }
dialog form { display: grid; gap: 14px; }
.tage { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.tage label {
  border: 1px solid var(--linie); border-radius: 12px; padding: 8px 4px; text-align: center;
  font-size: 13px; cursor: pointer; display: grid;
}
.tage label b { font-size: 16px; }
.tage input { position: absolute; opacity: 0; pointer-events: none; width: 1px; }
.tage label:has(input:checked) { border-color: var(--akzent); background: var(--akzent-zart); color: var(--akzent); }

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