:root {
  --gruen: #2f5d3a;
  --gruen-hell: #e7efe6;
  --grund: #f6f4ef;
  --karte: #ffffff;
  --text: #1f2421;
  --text-leise: #67706a;
  --linie: #e4e1d8;
  --warn: #9a5b00;
  --warn-grund: #fff4e0;
  --radius: 18px;
}

html, body { overflow-x: hidden; }
body {
  background: var(--grund);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

/* Kopfzeile */
.app-kopf {
  position: sticky; top: 0; z-index: 10;
  background: rgba(246, 244, 239, .92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--linie);
  padding: calc(env(safe-area-inset-top, 0px) + .4rem) 0 .4rem;
}
.app-marke { font-weight: 800; font-size: 1.25rem; color: var(--gruen); text-decoration: none; letter-spacing: -.01em; }
.zurueck {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2.5rem; height: 2.5rem; border-radius: 50%;
  background: var(--karte); border: 1px solid var(--linie);
  color: var(--text); text-decoration: none; font-size: 1.8rem; line-height: 1; padding-bottom: .2rem;
}
.app-inhalt { padding-top: .75rem; padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 2.5rem); }

/* Suche + Kategorien */
.marke-titel { font-size: inherit; font-weight: inherit; margin: 0; display: inline; }
.suche { display: flex; gap: .4rem; }
.suche .form-control { border-radius: 12px; border-color: var(--linie); font-size: 1rem; min-width: 0; padding: .4rem .75rem; }
.btn-gruen { background: var(--gruen); color: #fff; border-radius: 12px; font-size: .95rem; padding: .4rem .85rem; }
.btn-gruen:hover, .btn-gruen:focus { background: #244a2e; color: #fff; }

.chips { display: flex; flex-wrap: wrap; gap: .35rem; margin: .55rem 0 .3rem; }
.chip {
  padding: .25rem .7rem; border-radius: 999px;
  background: var(--karte); border: 1px solid var(--linie);
  color: var(--text); text-decoration: none; font-weight: 600; font-size: .85rem;
}
.chip.aktiv { background: var(--gruen); border-color: var(--gruen); color: #fff; }
.treffer { color: var(--text-leise); font-size: .8rem; margin: .3rem 0 .5rem; }

/* Rezeptkarten: 2 Spalten (iPhone), 3 ab 768px, 4 ab 1100px */
.karten-raster { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; }
@media (min-width: 768px) { .karten-raster { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .9rem; } }
@media (min-width: 1100px) { .karten-raster { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.karte-zelle { min-width: 0; }
.rezept-karte {
  display: block; height: 100%;
  background: var(--karte); border-radius: 14px; overflow: hidden;
  color: inherit; text-decoration: none;
  box-shadow: 0 1px 2px rgba(0,0,0,.05), 0 3px 10px rgba(0,0,0,.05);
  transition: transform .15s ease;
}
.rezept-karte:active { transform: scale(.98); }
.karte-bild { aspect-ratio: 1 / 1; background: var(--gruen-hell); }
.karte-bild img { width: 100%; height: 100%; object-fit: cover; display: block; }
.karte-text { padding: .45rem .55rem .55rem; }
.karte-text h2 {
  font-size: .86rem; font-weight: 700; margin: 0; line-height: 1.2;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  overflow-wrap: anywhere; min-height: 2.4em;
}
.karte-meta { display: flex; flex-wrap: wrap; gap: .1rem .6rem; margin-top: .3rem; font-size: .75rem; color: var(--text-leise); }
.karte-meta span { display: inline-flex; align-items: center; gap: .2rem; white-space: nowrap; }
.ico { width: 1.05em; height: 1.05em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.leer { text-align: center; padding: 2.5rem 1rem; color: var(--text-leise); }

/* Detail */
.rezept { max-width: 920px; margin: 0 auto; }
.detail-bild {
  width: 100%; max-width: 560px; margin: 0 auto;
  border-radius: var(--radius); overflow: hidden; background: var(--gruen-hell);
}
.detail-bild img { width: 100%; height: auto; display: block; }
.detail-kopf { margin: 1rem 0 .9rem; }
.detail-kopf h1 { font-size: clamp(1.6rem, 6vw, 2.3rem); font-weight: 800; line-height: 1.15; margin: .4rem 0 0; letter-spacing: -.015em; overflow-wrap: anywhere; }
.detail-untertitel { color: var(--text-leise); font-size: 1.05rem; margin: .2rem 0 0; }
.kategorie-badge {
  display: inline-block; background: var(--gruen-hell); color: var(--gruen);
  font-weight: 700; font-size: .82rem; padding: .25rem .7rem; border-radius: 999px; text-decoration: none;
}

.kacheln { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .5rem; }
.kachel {
  background: var(--karte); border: 1px solid var(--linie); border-radius: 14px;
  padding: .6rem .4rem; text-align: center; display: flex; flex-direction: column; gap: .15rem; min-width: 0;
}
.kachel-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-leise); font-weight: 600; overflow-wrap: anywhere; }
.kachel-wert { font-weight: 750; font-size: 1rem; overflow-wrap: anywhere; }
.kacheln-naehr .kachel-wert { font-size: 1.1rem; }
.kachel-kcal { background: var(--gruen); border-color: var(--gruen); color: #fff; }
.kachel-kcal .kachel-label { color: rgba(255,255,255,.8); }
@media (max-width: 420px) {
  .kacheln-naehr { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kacheln-zeit .kachel-label { font-size: .68rem; text-transform: none; letter-spacing: 0; overflow-wrap: normal; }
  .kacheln-zeit .kachel-wert { font-size: .92rem; }
}
.wert-offen {
  display: inline-block; font-size: .72rem; font-weight: 700; color: var(--warn);
  background: var(--warn-grund); border-radius: 6px; padding: .1rem .35rem;
}
.kachel-kcal .wert-offen { background: #fff; }

.block { margin-top: 1.4rem; }
.block h2 { font-size: 1.25rem; font-weight: 800; margin-bottom: .7rem; }
.block h2 small { font-size: .85rem; font-weight: 500; color: var(--text-leise); }

.hinweis-box {
  margin-top: 1rem; background: var(--warn-grund); color: #5a3a00;
  border-radius: 14px; padding: .75rem 1rem; font-size: .9rem; margin-bottom: .4rem;
}
.hinweis-box em { font-style: normal; font-weight: 700; }

.zutaten { list-style: none; margin: 0; padding: 0; background: var(--karte); border-radius: var(--radius); border: 1px solid var(--linie); }
.zutaten li { display: flex; gap: .75rem; padding: .7rem 1rem; border-bottom: 1px solid var(--linie); font-size: 1.02rem; }
.zutaten li:last-child { border-bottom: 0; }
.zutat-menge { flex: 0 0 6.4rem; font-weight: 750; color: var(--gruen); text-align: right; }
.zutat-name { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.zutat-zusatz { color: var(--text-leise); }

.schritte { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .7rem; }
.schritte li { display: flex; gap: .85rem; background: var(--karte); border: 1px solid var(--linie); border-radius: var(--radius); padding: .85rem 1rem; }
.schritt-nr {
  flex: 0 0 2rem; height: 2rem; border-radius: 50%;
  background: var(--gruen); color: #fff; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
}
.schritte p { margin: .2rem 0 0; font-size: 1.02rem; line-height: 1.5; min-width: 0; overflow-wrap: anywhere; }

.quelle { margin-top: 1.5rem; text-align: center; font-size: .9rem; }
.quelle a { color: var(--text-leise); }

/* Portionsauswahl (Detailseite) */
.portionen-wahl { display: flex; align-items: center; gap: .5rem; margin: 0 0 .7rem; }
.portionen-wahl[hidden] { display: none; }
.portionen-label { color: var(--text-leise); font-size: .9rem; margin-right: auto; }
.portionen-btn {
  width: 2.75rem; height: 2.75rem; border-radius: 50%;
  background: var(--karte); border: 1px solid var(--linie); color: var(--gruen);
  font-size: 1.5rem; font-weight: 700; line-height: 1; padding: 0 0 .1rem;
  display: inline-flex; align-items: center; justify-content: center;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.portionen-btn:active:not(:disabled) { background: var(--gruen-hell); }
.portionen-btn:disabled { opacity: .35; }
.portionen-wert { min-width: 2.2rem; text-align: center; font-weight: 800; font-size: 1.25rem; }

/* Anmeldung, Bearbeiten, Löschen */
.kopf-link { background: none; border: 0; padding: .3rem .1rem; color: var(--text-leise); font-size: .85rem; text-decoration: underline; }
.meldung { padding: .6rem .9rem; border-radius: 12px; margin-bottom: .7rem; font-size: .95rem; background: var(--gruen-hell); color: var(--gruen); }
.meldung-error { background: #fde8e8; color: #8a1c1c; }
.formular { max-width: 640px; margin: 0 auto; }
.formular-schmal { max-width: 420px; }
.formular label { font-size: .85rem; color: var(--text-leise); display: block; margin: .5rem 0 .2rem; }
.formular input[type=text], .formular input[type=number], .formular input[type=password], .formular select, .formular textarea, .formular input[type=file] {
  width: 100%; border: 1px solid var(--linie); border-radius: 12px; padding: .55rem .7rem; font-size: 1rem; background: var(--karte); min-width: 0;
}
.form-titel { font-size: 1.3rem; font-weight: 800; margin-bottom: .5rem; }
.form-block { background: var(--karte); border: 1px solid var(--linie); border-radius: var(--radius); padding: .8rem .9rem 1rem; margin-bottom: 1rem; }
.form-block h2 { font-size: 1.05rem; font-weight: 800; margin: 0 0 .3rem; }
.form-hinweis { font-size: .82rem; color: var(--text-leise); }
.form-fehler { color: #8a1c1c; font-size: .85rem; margin: .2rem 0; }
.feld-reihe { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 .6rem; }
.feld { min-width: 0; }
.zeile { border-top: 1px solid var(--linie); padding: .5rem 0 .6rem; }
.zeile-oben { display: grid; grid-template-columns: 3.6rem minmax(0, 1fr) minmax(0, 1fr); gap: 0 .5rem; }
.f-nr { max-width: 4.5rem; }
.loeschen-check { display: flex !important; align-items: center; gap: .4rem; margin-top: .4rem !important; color: #8a1c1c !important; }
.loeschen-check input { width: 1.2rem; height: 1.2rem; }
.form-bild { width: 100%; max-width: 240px; border-radius: 12px; display: block; margin-bottom: .4rem; }
.btn-gefahr { background: #b3261e; color: #fff; border-radius: 12px; padding: .7rem; }
.btn-gefahr:hover { background: #8f1e18; color: #fff; }
.btn-gefahr-text { color: #b3261e; border: 1px solid #e3b4b0; border-radius: 12px; background: var(--karte); }
.loesch-name { font-size: 1.15rem; font-weight: 700; }

.dubletten-warnung { background: var(--warn-grund); border-color: #e8c98f; }
.dubletten-warnung ul { padding-left: 1.1rem; }
.bestaetigung { display: flex !important; align-items: center; gap: .5rem; color: var(--text) !important; font-size: .95rem !important; }
.bestaetigung input { width: 1.3rem; height: 1.3rem; }

/* Einkauf: Auswahl in der Übersicht */
.karte-zelle { position: relative; }
.auswahl-knopf {
  /* Tippfläche 44×44 px, sichtbarer Kreis (::before) 32 px, Position oben rechts */
  position: absolute; top: 0; right: 0; width: 2.75rem; height: 2.75rem; padding: 0;
  background: transparent; border: 0; color: transparent;
  display: inline-flex; align-items: center; justify-content: center; touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.auswahl-knopf::before {
  content: ""; position: absolute; top: 6px; right: 6px; width: 32px; height: 32px; border-radius: 50%; box-sizing: border-box;
  background: rgba(255,255,255,.92); border: 2px solid var(--linie); box-shadow: 0 1px 4px rgba(0,0,0,.2);
}
.auswahl-knopf[hidden] { display: none; }
.auswahl-knopf .ico { position: relative; width: 1.15rem; height: 1.15rem; stroke-width: 3; }
.auswahl-knopf.an { color: #fff; }
.auswahl-knopf.an::before { background: var(--gruen); border-color: var(--gruen); }
.auswahl-hinweis { color: var(--text-leise); font-size: .8rem; margin: 0 0 .5rem; }
.auswahl-detail.an { background: var(--gruen); color: #fff; border-color: var(--gruen); }
.auswahl-detail[hidden] { display: none; }
body.mit-leiste .app-inhalt { padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 6rem); }
.auswahl-leiste {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; align-items: center; gap: .5rem; flex-wrap: wrap;
  padding: .6rem 1rem calc(env(safe-area-inset-bottom, 0px) + .6rem);
  background: rgba(255,255,255,.97); border-top: 1px solid var(--linie); box-shadow: 0 -2px 10px rgba(0,0,0,.08);
}
.auswahl-leiste[hidden] { display: none; }
.auswahl-zaehler { font-weight: 700; flex: 1 1 auto; min-width: 0; }
.auswahl-leeren { background: none; border: 0; color: var(--text-leise); text-decoration: underline; padding: .6rem .3rem; font-size: .9rem; }
.auswahl-weiter { min-height: 2.75rem; display: inline-flex; align-items: center; }
@media (max-width: 420px) { .auswahl-weiter { flex: 1 1 100%; justify-content: center; } }

/* Einkauf planen */
.auswahl-zeilen { list-style: none; margin: 0 0 1rem; padding: 0; display: flex; flex-direction: column; gap: .5rem; }
.auswahl-zeile { background: var(--karte); border: 1px solid var(--linie); border-radius: 14px; padding: .65rem .8rem; display: flex; flex-direction: column; gap: .4rem; }
.auswahl-titel { min-width: 0; }
.auswahl-titel a { font-weight: 700; color: var(--text); text-decoration: none; overflow-wrap: anywhere; }
.auswahl-titel small { display: block; color: var(--text-leise); }
.auswahl-zeile .portionen-wahl { margin: 0; justify-content: flex-end; }
.auswahl-entfernen { width: 2.75rem; height: 2.75rem; border: 0; background: none; color: #b3261e; font-size: 1.6rem; line-height: 1; }
.auswahl-absenden { min-height: 3rem; }

/* Einkaufsliste */
.einkauf-liste { list-style: none; margin: 0; padding: 0; background: var(--karte); border: 1px solid var(--linie); border-radius: var(--radius); overflow: hidden; }
.einkauf-item { border-bottom: 1px solid var(--linie); }
.einkauf-item:last-child { border-bottom: 0; }
.einkauf-form { margin: 0; }
.einkauf-knopf {
  width: 100%; min-height: 3.4rem; display: flex; align-items: center; gap: .85rem; text-align: left;
  background: none; border: 0; padding: .6rem 1rem; color: var(--text); font-size: 1.05rem;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.einkauf-knopf:active { background: var(--gruen-hell); }
.einkauf-box {
  flex: 0 0 1.9rem; height: 1.9rem; border: 2px solid #9aa59d; border-radius: 8px; background: #fff;
  display: inline-flex; align-items: center; justify-content: center; color: transparent;
}
.einkauf-box .ico { width: 1.3rem; height: 1.3rem; stroke-width: 3; }
.einkauf-text { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 .45rem; min-width: 0; overflow-wrap: anywhere; }
.einkauf-menge { font-weight: 750; color: var(--gruen); }
.einkauf-bedarf { color: var(--text-leise); font-size: .85rem; }
.einkauf-item.erledigt .einkauf-text { text-decoration: line-through; color: var(--text-leise); }
.einkauf-item.erledigt .einkauf-menge { color: var(--text-leise); }
.einkauf-item.erledigt .einkauf-box { background: var(--gruen); border-color: var(--gruen); color: #fff; }
.einkauf-rezepte { padding-left: 1.1rem; }
.kopf-einkauf { white-space: nowrap; }
.loeschen-unten { margin-top: 2.5rem; text-align: center; }

/* Seitennavigation */
.seiten { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: .5rem; margin: 1.2rem 0 .3rem; }
.seiten-nummern { list-style: none; display: flex; gap: .3rem; margin: 0; padding: 0; order: 1; flex: 1 0 100%; justify-content: center; }
.seiten .seite-pfeil { order: 2; flex: 1 1 40%; }
.seiten .seite-pfeil[rel=next], .seiten > .seite-pfeil:last-child { order: 3; }
.seite-link {
  display: inline-flex; align-items: center; justify-content: center; min-width: 2.75rem; min-height: 2.75rem;
  padding: 0 .6rem; border-radius: 12px; background: var(--karte); border: 1px solid var(--linie);
  color: var(--text); text-decoration: none; font-weight: 700; touch-action: manipulation;
}
.seite-link.aktiv { background: var(--gruen); border-color: var(--gruen); color: #fff; }
.seite-link.aus { opacity: .35; }
.seite-luecke { align-self: center; color: var(--text-leise); padding: 0 .1rem; }
