/* Kochbuch – mobile first, warm, gut lesbar in der Küche */
:root {
  --bg: #faf6ef;
  --flaeche: #ffffff;
  --flaeche-2: #f1ebe0;
  --text: #2a2622;
  --leise: #776d62;
  --linie: #e4dccf;
  --gruen: #2f4a3a;
  --gruen-hell: #e3ebe4;
  --akzent: #c8553d;
  --akzent-hell: #f8e4dd;
  --ok: #2f7a4a;
  --gefahr: #b3261e;
  --radius: 14px;
  --schatten: 0 1px 2px rgba(42, 38, 34, .06), 0 4px 14px rgba(42, 38, 34, .06);
  --nav-hoehe: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171513;
    --flaeche: #221f1c;
    --flaeche-2: #2b2723;
    --text: #efe9e1;
    --leise: #a89e92;
    --linie: #3a352f;
    --gruen: #8fc2a0;
    --gruen-hell: #23332a;
    --akzent: #e7826b;
    --akzent-hell: #3b2620;
    --ok: #7fcf9b;
    --gefahr: #ff8a80;
    --schatten: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(var(--nav-hoehe) + env(safe-area-inset-bottom) + 16px);
}
body.login, body.kochmodus { padding-bottom: 0; }
.inhalt { max-width: 760px; margin: 0 auto; padding: 16px; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: 1.7rem; font-family: Georgia, "Times New Roman", serif; font-weight: 700; }
h2 { font-size: 1.2rem; margin-top: 1.6em; }
h3 { font-size: 1rem; color: var(--leise); margin-top: 1em; }
a { color: var(--gruen); }
img { max-width: 100%; display: block; }
.leise { color: var(--leise); }
.klein { font-size: .9rem; }
.mittig { text-align: center; justify-content: center; }
.breit { width: 100%; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
[hidden] { display: none !important; }

/* ---------------------------------------------------------------- Formularelemente */
input, select, textarea, button { font: inherit; color: inherit; }
input:not([type=checkbox]):not([type=file]), select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--linie);
  border-radius: 10px;
  background: var(--flaeche);
  min-height: 44px;
}
textarea { resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--gruen) 45%, transparent);
  outline-offset: 1px;
}
label { display: block; margin: 0 0 12px; font-weight: 500; }
label > input, label > select, label > textarea { margin-top: 4px; font-weight: 400; }
fieldset { border: 1px solid var(--linie); border-radius: var(--radius); padding: 12px; margin: 0 0 14px; }
legend { font-weight: 600; padding: 0 6px; }

.knopf {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 8px 16px;
  border: 1px solid var(--linie); border-radius: 999px;
  background: var(--flaeche); color: var(--text);
  text-decoration: none; font-weight: 600; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.knopf:active { transform: scale(.98); }
.knopf.haupt { background: var(--gruen); border-color: var(--gruen); color: #fff; }
@media (prefers-color-scheme: dark) { .knopf.haupt { color: #10140f; } }
.knopf.gross { min-height: 54px; font-size: 1.1rem; padding: 10px 22px; }
.knopf.klein { min-height: 36px; padding: 4px 12px; font-size: .9rem; }
.knopf.gefahr { color: var(--gefahr); border-color: currentColor; background: transparent; }
.knopf.leise-knopf { background: transparent; }
.knopf:disabled { opacity: .5; cursor: default; }
.link { background: none; border: 0; padding: 0; color: var(--gruen); text-decoration: underline; cursor: pointer; font: inherit; }
.link.gefahr { color: var(--gefahr); }
.rund {
  width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--linie); background: var(--flaeche);
  font-size: 1.3rem; line-height: 1; cursor: pointer; flex: none;
}
.rund.klein { width: 34px; height: 34px; font-size: 1.1rem; }
.knoepfe { display: flex; flex-wrap: wrap; gap: 10px; margin: 12px 0; }
form.inline { display: inline; }

/* ---------------------------------------------------------------- Meldungen */
.meldung { padding: 10px 14px; border-radius: 10px; background: var(--flaeche-2); margin: 0 0 14px; }
.meldung.ok { background: var(--gruen-hell); color: var(--ok); }
.meldung.fehler { background: var(--akzent-hell); color: var(--gefahr); }
.sync-hinweis {
  position: sticky; top: 0; z-index: 20;
  background: var(--gruen); color: #fff; padding: 8px 16px; font-size: .95rem; text-align: center;
}
.sync-hinweis .link { color: #fff; margin-left: 6px; }
.hinweis-box {
  background: var(--akzent-hell); border-radius: var(--radius); padding: 14px 16px; margin: 16px 0;
}
.hinweis-box h2 { margin-top: 0; }
.hinweis-box.entwurf { background: var(--gruen-hell); }
.leer { text-align: center; color: var(--leise); padding: 32px 8px; }
.badge {
  display: inline-block; margin-left: 6px; font-size: .75rem; font-weight: 600;
  background: var(--akzent); color: #fff; border-radius: 999px; padding: 1px 8px; vertical-align: middle;
}
.karte-text .badge { align-self: flex-start; margin: 2px 0; }

/* ---------------------------------------------------------------- Kopf, Suche, Filter */
.kopf { margin: 8px 0 14px; }
.kopf p { margin: 0; }
.suche, .filter { margin-bottom: 16px; }
.suche input, .filter input { border-radius: 999px; padding-left: 18px; }
.filter-zeile { display: flex; gap: 8px; margin-top: 8px; overflow-x: auto; }
.filter-zeile select { width: auto; flex: 1 0 auto; border-radius: 999px; }

/* ---------------------------------------------------------------- Karten */
.karten { display: grid; gap: 10px; }
.karte {
  display: flex; gap: 12px; align-items: center;
  background: var(--flaeche); border-radius: var(--radius); padding: 8px;
  text-decoration: none; color: var(--text); box-shadow: var(--schatten);
  border: 1px solid var(--linie);
}
.karte-bild { width: 76px; height: 76px; flex: none; border-radius: 10px; overflow: hidden; background: var(--flaeche-2); display: grid; place-items: center; }
.karte-bild img { width: 100%; height: 100%; object-fit: cover; }
.platzhalter { font: 700 2rem Georgia, serif; color: var(--leise); }
.karte-text { display: flex; flex-direction: column; min-width: 0; }
.karte-text strong { font-size: 1.05rem; line-height: 1.25; }
.karte-text small { font-size: .85rem; }
.karte-text .fehlt { color: var(--akzent); font-weight: 500; }
.karten.quer {
  grid-auto-flow: column; grid-auto-columns: 72%;
  overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 6px;
}
.karten.quer .karte { flex-direction: column; align-items: stretch; scroll-snap-align: start; }
.karten.quer .karte-bild { width: 100%; height: 140px; }
@media (min-width: 640px) {
  .karten { grid-template-columns: 1fr 1fr; }
  .karten.quer { grid-template-columns: none; grid-auto-columns: 32%; }
}

/* ---------------------------------------------------------------- Rezept */
.galerie {
  display: flex; gap: 8px; overflow-x: auto; scroll-snap-type: x mandatory;
  margin: -16px -16px 16px; padding: 0;
}
.galerie-bild { flex: 0 0 100%; scroll-snap-align: center; }
.galerie-bild img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.galerie:has(.galerie-bild:nth-child(2)) .galerie-bild { flex-basis: 88%; }
@media (min-width: 760px) { .galerie { margin: 0 0 16px; border-radius: var(--radius); } }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 0; }
.tag {
  font-size: .85rem; padding: 2px 10px; border-radius: 999px;
  background: var(--flaeche-2); color: var(--text); text-decoration: none;
}
.tag.haupt { background: var(--gruen-hell); color: var(--gruen); font-weight: 600; }
.beschreibung { font-size: 1.05rem; }
.eckdaten { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.eckdaten div { background: var(--flaeche); border: 1px solid var(--linie); border-radius: 12px; padding: 6px 12px; }
.eckdaten dt { font-size: .75rem; color: var(--leise); text-transform: uppercase; letter-spacing: .04em; }
.eckdaten dd { margin: 0; font-weight: 600; }
.aktionen { margin: 16px 0; }
.aktionen .knopf { width: 100%; }
.abschnitt-kopf { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 1.6em; }
.abschnitt-kopf h2 { margin: 0; }
.portionen { display: flex; align-items: center; gap: 8px; }
.zutatenliste { list-style: none; padding: 0; margin: 0; }
.zutatenliste li {
  display: grid; grid-template-columns: 3.2em 3.6em 1fr auto; gap: 6px;
  padding: 8px 0; border-bottom: 1px solid var(--linie); align-items: baseline;
}
.zutatenliste .menge { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.zutatenliste .einheit { color: var(--leise); }
.zutatenliste .zusatz { color: var(--leise); }
.zutatenliste .optional .name { color: var(--leise); }
.vorrat-punkt { color: var(--ok); font-weight: 700; }
.schritte { padding-left: 0; list-style: none; counter-reset: s; }
.schritte li {
  counter-increment: s; position: relative; padding: 4px 0 14px 44px;
}
.schritte li::before {
  content: counter(s); position: absolute; left: 0; top: 2px;
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--gruen); color: var(--bg); display: grid; place-items: center; font-weight: 700; font-size: .9rem;
}
.notizen p, .transkript { white-space: normal; }
.gekocht-box { background: var(--flaeche); border: 1px solid var(--linie); border-radius: var(--radius); padding: 14px 16px; margin-top: 20px; }
.gekocht-box h2 { margin-top: 0; }
.gekocht-form { display: flex; gap: 8px; flex-wrap: wrap; }
.gekocht-form input[type=date] { width: auto; flex: 1; }
.verlauf li { padding: 4px 0; }
details { margin: 14px 0; }
summary { cursor: pointer; color: var(--gruen); font-weight: 600; min-height: 32px; }
.original audio { width: 100%; margin: 8px 0; }
.transkript { font-size: .95rem; color: var(--leise); background: var(--flaeche-2); padding: 10px 12px; border-radius: 10px; }
.foto-ergaenzen { display: flex; gap: 10px; flex-wrap: wrap; margin: 20px 0; }
ul.schlicht { list-style: none; padding: 0; margin: 0; }
.fusszeile { text-align: center; margin: 28px 0 0; font-size: .95rem; }

/* ---------------------------------------------------------------- Bearbeiten */
.raster-2, .raster-3 { display: grid; gap: 0 10px; grid-template-columns: 1fr 1fr; }
.raster-3 { grid-template-columns: 1fr 1fr 1fr; }
.raster-3 label { font-size: .85rem; }
.zutat-zeile {
  display: grid; gap: 6px; grid-template-columns: 4.5em 5.5em 1fr auto;
  grid-template-areas: "name name name weg" "menge einheit zusatz zusatz" "optional optional gruppe gruppe";
  padding: 8px 0 12px; border-bottom: 1px dashed var(--linie); margin-bottom: 4px; align-items: center;
}
.zutat-zeile .feld-name { grid-area: name; font-weight: 600; }
.zutat-zeile .feld-menge { grid-area: menge; }
.zutat-zeile .feld-einheit { grid-area: einheit; }
.zutat-zeile .feld-zusatz { grid-area: zusatz; }
.zutat-zeile .feld-gruppe { grid-area: gruppe; }
.zutat-zeile .feld-optional { grid-area: optional; margin: 0; font-weight: 400; display: flex; align-items: center; gap: 6px; }
.zutat-zeile [data-zeile-weg] { grid-area: weg; }
@media (min-width: 640px) {
  .zutat-zeile { grid-template-columns: 4.5em 5.5em 1.4fr 1.2fr 1fr auto auto; grid-template-areas: "menge einheit name zusatz gruppe optional weg"; }
}
.formular-knoepfe { display: flex; gap: 10px; flex-wrap: wrap; margin: 16px 0; }
.bild-verwaltung { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; margin-bottom: 12px; }
.bild-kachel { background: var(--flaeche); border: 1px solid var(--linie); border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; gap: 4px; padding-bottom: 8px; text-align: center; font-size: .9rem; }
.bild-kachel.titel { border-color: var(--gruen); border-width: 2px; }
.bild-kachel img { aspect-ratio: 1; object-fit: cover; width: 100%; }
.loeschen-form { margin-top: 32px; text-align: center; }

/* ---------------------------------------------------------------- Aufnahme */
.aufnahme-zentrale { text-align: center; margin: 16px 0; }
.aufnahme-knopf {
  width: 168px; height: 168px; border-radius: 50%;
  border: 0; background: var(--akzent); color: #fff;
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  font-weight: 700; font-size: 1rem; cursor: pointer;
  box-shadow: 0 6px 24px color-mix(in srgb, var(--akzent) 40%, transparent);
}
.aufnahme-knopf svg { width: 56px; height: 56px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.aufnahme-knopf.laeuft { background: var(--gefahr); animation: puls 1.4s ease-in-out infinite; }
@keyframes puls { 50% { box-shadow: 0 0 0 18px color-mix(in srgb, var(--gefahr) 15%, transparent); } }
@media (prefers-reduced-motion: reduce) { .aufnahme-knopf.laeuft { animation: none; } }
.aufnahme-zeit { font: 600 1.6rem/1 ui-monospace, monospace; margin: 14px 0 6px; }
.teile-liste { list-style: none; padding: 0; display: grid; gap: 8px; }
.teil { display: flex; align-items: center; gap: 10px; background: var(--flaeche); border: 1px solid var(--linie); border-radius: 12px; padding: 8px; }
.teil img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; }
.teil audio { flex: 1; min-width: 0; height: 40px; }
.teil-info { font-size: .9rem; white-space: nowrap; }
.teil img + .rund { margin-left: auto; }

/* ---------------------------------------------------------------- Vorrat */
.ergebnis { margin-bottom: 20px; }
.ergebnis h2:first-child { margin-top: 0; }
.vorrat-werkzeug { display: flex; gap: 8px; margin: 16px 0 4px; position: sticky; top: 0; background: var(--bg); padding: 8px 0; z-index: 5; }
.vorrat-werkzeug input { border-radius: 999px; }
.vorrat-werkzeug .knopf { white-space: nowrap; flex: none; }
.vorrat-zutaten { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: 1fr; }
@media (min-width: 560px) { .vorrat-zutaten { grid-template-columns: 1fr 1fr; gap: 0 16px; } }
.vorrat-zutaten li { display: flex; align-items: center; border-bottom: 1px solid var(--linie); }
.haken { flex: 1; display: flex; align-items: center; gap: 10px; margin: 0; padding: 10px 0; font-weight: 400; cursor: pointer; min-height: 48px; }
.haken input, .koch-zutaten input { width: 22px; height: 22px; accent-color: var(--gruen); flex: none; }
.haken small { margin-left: auto; }
.haken input:disabled + span { color: var(--leise); }
.stern { margin: 0; padding: 10px 4px 10px 12px; cursor: pointer; color: var(--linie); font-size: 1.3rem; position: relative; }
.stern input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.stern input:checked + span { color: #d9a33a; }
.stern input:focus-visible + span { outline: 2px solid var(--gruen); border-radius: 4px; }
.zutat-verwaltung { list-style: none; padding: 0; }
.zutat-form { display: grid; gap: 6px; grid-template-columns: 1fr 1fr; padding: 12px 0; border-bottom: 1px solid var(--linie); align-items: center; }
.zutat-form input[name=name], .zutat-form select[name=zusammen] { grid-column: 1 / -1; }
.zutat-form .knopf { justify-self: end; }

/* ---------------------------------------------------------------- Kochmodus */
body.kochmodus .inhalt { min-height: 100dvh; display: flex; flex-direction: column; padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
.koch-kopf { display: flex; justify-content: space-between; align-items: center; min-height: 40px; }
.koch-fortschritt-balken { height: 4px; background: var(--flaeche-2); border-radius: 2px; margin: 6px 0 16px; overflow: hidden; }
.koch-fortschritt-balken div { height: 100%; width: 0; background: var(--gruen); transition: width .25s; }
.koch-inhalt { flex: 1; display: flex; flex-direction: column; justify-content: center; }
.koch-nr { font: 700 3.2rem/1 Georgia, serif; color: var(--akzent); margin-bottom: 12px; }
.koch-text { font-size: clamp(1.4rem, 5.5vw, 2rem); line-height: 1.4; margin: 0; }
.koch-zutaten { list-style: none; padding: 0; font-size: 1.2rem; }
.koch-zutaten li { padding: 8px 0; border-bottom: 1px solid var(--linie); }
.koch-zutaten label { display: flex; gap: 12px; align-items: center; margin: 0; font-weight: 400; }
.koch-zutaten input:checked + * , .koch-zutaten label:has(input:checked) { color: var(--leise); text-decoration: line-through; }
.koch-timer { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 12px 0; padding: 10px; border-radius: var(--radius); background: var(--flaeche-2); }
.koch-timer.alarm { background: var(--akzent); color: #fff; }
.timer-anzeige { font: 700 1.8rem/1 ui-monospace, monospace; }
.koch-steuerung { display: grid; grid-template-columns: 1fr 1fr 2fr; gap: 10px; margin-top: 12px; }
.koch-steuerung .knopf { border-radius: 16px; min-height: 64px; font-size: 1.4rem; }
.koch-steuerung #koch-weiter { font-size: 1.2rem; }
#koch-vorlesen.aktiv { background: var(--gruen-hell); border-color: var(--gruen); }
.koch-optionen { display: flex; flex-wrap: wrap; gap: 4px 16px; justify-content: center; margin-top: 12px; font-size: .9rem; color: var(--leise); }
.koch-optionen label { font-weight: 400; margin: 0; display: flex; align-items: center; gap: 6px; }

/* ---------------------------------------------------------------- Login */
body.login .inhalt { min-height: 100dvh; display: grid; place-items: center; }
.login-karte { width: 100%; max-width: 360px; background: var(--flaeche); padding: 24px; border-radius: var(--radius); box-shadow: var(--schatten); border: 1px solid var(--linie); }
.login-logo { margin: 0 auto 8px; }
.login-karte h1 { text-align: center; }
.login-karte .knopf { width: 100%; }

/* ---------------------------------------------------------------- Navigation unten */
nav.unten {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--nav-hoehe) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--flaeche) 94%, transparent);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--linie);
}
.nav-punkt {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--leise); text-decoration: none; font-size: .75rem; font-weight: 600;
}
.nav-punkt svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav-punkt.aktiv { color: var(--gruen); }
.nav-punkt.neu svg { width: 40px; height: 40px; padding: 8px; border-radius: 50%; background: var(--akzent); color: #fff; margin-top: -14px; box-shadow: var(--schatten); }
