:root {
  --akzent: #e0743c;
  --akzent-dunkel: #c25e2c;
  --hintergrund: #faf6f1;
  --karte: #ffffff;
  --text: #2e2a26;
  --text-leise: #8a7f74;
  --rand: #e8ddd2;
  --gefahr: #c0392b;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--hintergrund);
  color: var(--text);
  line-height: 1.55;
}

main { max-width: 900px; margin: 0 auto; padding: 1rem; }

/* Kopfzeile */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--karte); border-bottom: 1px solid var(--rand);
  padding: 0.7rem 1rem; position: sticky; top: 0; z-index: 10;
}
.logo { font-size: 1.15rem; font-weight: 700; color: var(--text); text-decoration: none; }
.logout-form { margin: 0; }

/* Buttons */
.btn-primary, .btn-ghost, .btn-gefahr {
  display: inline-block; padding: 0.55rem 1.1rem; border-radius: 8px;
  border: none; font-size: 1rem; cursor: pointer; text-decoration: none; text-align: center;
}
.btn-primary { background: var(--akzent); color: #fff; }
.btn-primary:hover { background: var(--akzent-dunkel); }
.btn-ghost { background: transparent; color: var(--akzent-dunkel); border: 1px solid var(--rand); }
.btn-gefahr { background: transparent; color: var(--gefahr); border: 1px solid var(--gefahr); }

/* Login */
.login-body {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; background: var(--hintergrund);
}
.login-box {
  background: var(--karte); padding: 2rem; border-radius: 14px;
  border: 1px solid var(--rand); width: min(90vw, 340px); text-align: center;
}
.login-box h1 { margin-top: 0; font-size: 1.4rem; }
.login-box input {
  width: 100%; padding: 0.7rem; margin-bottom: 0.8rem;
  border: 1px solid var(--rand); border-radius: 8px; font-size: 1rem;
}
.login-box button { width: 100%; }
.fehler { color: var(--gefahr); }

/* Filterleiste */
.filterbar { margin-bottom: 1.2rem; }
.filterbar input[type="search"] {
  width: 100%; padding: 0.7rem; font-size: 1rem;
  border: 1px solid var(--rand); border-radius: 8px; margin-bottom: 0.6rem;
}
.filter-row { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.filter-row select {
  flex: 1 1 130px; padding: 0.55rem; font-size: 0.95rem;
  border: 1px solid var(--rand); border-radius: 8px; background: var(--karte);
}

/* Kacheln */
.kacheln {
  display: grid; gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
}
.kachel {
  background: var(--karte); border: 1px solid var(--rand); border-radius: 12px;
  overflow: hidden; text-decoration: none; color: var(--text);
  display: flex; flex-direction: column;
  transition: transform 0.1s ease;
}
.kachel:hover { transform: translateY(-2px); }
.kachel img, .platzhalter {
  width: 100%; aspect-ratio: 4 / 3; object-fit: cover;
}
.platzhalter {
  display: flex; align-items: center; justify-content: center;
  font-size: 2.5rem; background: #f1e8dd;
}
.kachel-text { padding: 0.6rem 0.8rem; }
.kachel-text h2 { font-size: 1rem; margin: 0 0 0.2rem; }
.kachel-meta { font-size: 0.8rem; color: var(--text-leise); margin: 0; }
.leer { color: var(--text-leise); text-align: center; padding: 2rem 0; }

/* Detailseite */
.detail h1 { font-size: 1.6rem; margin: 0.8rem 0 0.4rem; }
.detail-bild {
  width: 100%; max-height: 340px; object-fit: cover; border-radius: 12px;
}
.meta { margin: 0.3rem 0; }
.badge {
  display: inline-block; background: var(--akzent); color: #fff;
  padding: 0.15rem 0.6rem; border-radius: 999px; font-size: 0.8rem; margin: 0 0.25rem 0.25rem 0;
}
.badge-tag { background: #b59f8c; }
.meta-zeile { color: var(--text-leise); }
.detail h2 { font-size: 1.15rem; margin: 1.4rem 0 0.5rem; border-bottom: 2px solid var(--rand); padding-bottom: 0.25rem; }

/* Zutaten-Kopf mit Portionsregler */
.zutaten-kopf { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 0.5rem; }
.zutaten-kopf h2 { margin-bottom: 0.25rem; flex: 1 1 auto; }
.portionen-statisch { color: var(--text-leise); font-size: 0.95rem; }
.portionen-regler { display: inline-flex; align-items: center; gap: 0.6rem; background: var(--karte); border: 1px solid var(--rand); border-radius: 999px; padding: 0.2rem 0.6rem; }
.portionen-regler button {
  width: 2rem; height: 2rem; border-radius: 50%; border: 1px solid var(--rand);
  background: var(--hintergrund); color: var(--akzent-dunkel); font-size: 1.3rem; line-height: 1; cursor: pointer;
}
.portionen-regler button:active { background: var(--akzent); color: #fff; }
.portionen-regler span { font-size: 0.95rem; white-space: nowrap; }
.zutaten-gruppe { font-size: 1rem; margin: 1rem 0 0.3rem; color: var(--akzent-dunkel); }
.zutaten { list-style: none; padding: 0; margin: 0; }
.zutaten li { padding: 0.35rem 0; border-bottom: 1px dashed var(--rand); }
.menge { font-weight: 600; min-width: 5.5rem; display: inline-block; }
.schritte li { margin-bottom: 0.7rem; }
.notizen { white-space: pre-wrap; background: #fdf3e7; padding: 0.8rem; border-radius: 8px; }
.quelle { color: var(--text-leise); font-size: 0.9rem; margin-top: 1.5rem; }
.quelle a { color: var(--akzent-dunkel); }
.aktionen { display: flex; gap: 0.6rem; margin: 1.5rem 0; align-items: center; }
.aktionen form { margin: 0; }

/* Edit-Formular */
.edit-form label { display: block; margin-bottom: 0.9rem; font-weight: 600; }
.edit-form label small { font-weight: 400; color: var(--text-leise); }
.edit-form input[type="text"], .edit-form input[type="url"],
.edit-form select, .edit-form textarea {
  width: 100%; padding: 0.6rem; font-size: 1rem; margin-top: 0.25rem;
  border: 1px solid var(--rand); border-radius: 8px; background: var(--karte);
  font-family: inherit;
}
.edit-form fieldset {
  border: 1px solid var(--rand); border-radius: 10px; margin-bottom: 0.9rem; padding: 0.8rem;
}
.edit-form legend { font-weight: 600; padding: 0 0.4rem; }
.zutat-zeile { display: flex; gap: 0.4rem; margin-bottom: 0.4rem; align-items: center; }
.zutat-zeile { flex-wrap: wrap; }
.feld-menge { flex: 0 0 4.5rem; }
.feld-einheit { flex: 0 0 5rem; }
.feld-name { flex: 1 1 8rem; }
.feld-gruppe { flex: 1 1 100%; font-size: 0.9rem; }
.zutat-entfernen { flex: 0 0 auto; padding: 0.45rem 0.7rem; }
.feld-hinweis { color: var(--text-leise); margin: 0.3rem 0 0; }
.form-row { display: flex; gap: 0.8rem; }
.form-row label { flex: 1; }
.edit-bild-vorschau { max-width: 200px; border-radius: 8px; margin-bottom: 0.9rem; display: block; }

/* Navigation */
.topnav { display: flex; align-items: center; gap: 0.4rem; }
.topnav .btn-ghost { padding: 0.4rem 0.6rem; }

/* Koch-Leiste auf Detailseite */
.koch-leiste { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 0.8rem; margin: 1rem 0 0.5rem; }
.btn-kochen { font-size: 1.05rem; }
.sterne { display: inline-flex; gap: 0.1rem; }
.stern { background: none; border: none; cursor: pointer; font-size: 1.6rem; line-height: 1; color: var(--akzent); padding: 0 0.05rem; }
.gekocht-form { display: flex; align-items: center; gap: 0.8rem; flex-wrap: wrap; margin-bottom: 0.5rem; }
.gekocht-form { margin-top: 0.2rem; }
.btn-gekocht { background: #3b9c63; color: #fff; border: none; padding: 0.55rem 1.1rem; border-radius: 8px; font-size: 1rem; cursor: pointer; }
.btn-gekocht:hover { background: #318052; }
.koch-info { color: var(--text-leise); font-size: 0.9rem; }

/* Statistik */
.stat-kacheln { display: flex; gap: 1rem; margin: 1rem 0; }
.stat-kachel { background: var(--karte); border: 1px solid var(--rand); border-radius: 12px; padding: 1rem 1.4rem; text-align: center; flex: 1; }
.stat-kachel b { display: block; font-size: 2rem; color: var(--akzent-dunkel); }
.stat-kachel span { color: var(--text-leise); font-size: 0.9rem; }
.stat-liste { padding-left: 1.4rem; }
.stat-liste li { margin: 0.4rem 0; display: flex; justify-content: space-between; gap: 1rem; }
.stat-liste a { color: var(--text); text-decoration: none; }
.stat-liste a:hover { color: var(--akzent-dunkel); }
.stat-zahl { font-weight: 600; color: var(--akzent-dunkel); white-space: nowrap; }
.stat-leise { font-weight: 400; color: var(--text-leise); }

/* Kochmodus (Vollbild) */
body.kochmodus {
  display: flex; flex-direction: column; height: 100vh; height: 100dvh;
  background: var(--text); color: #fff; overflow: hidden;
}
.km-top {
  display: flex; align-items: center; gap: 0.8rem; padding: 0.8rem 1rem;
  padding-top: max(0.8rem, env(safe-area-inset-top));
}
.km-exit { color: #fff; text-decoration: none; font-size: 1.5rem; line-height: 1; }
.km-titel { flex: 1; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.km-fortschritt { height: 5px; background: rgba(255,255,255,0.15); }
.km-balken { height: 100%; width: 0; background: var(--akzent); transition: width 0.2s ease; }
.km-buehne { flex: 1 1 auto; min-height: 0; overflow-y: auto; display: flex; align-items: center; justify-content: center; padding: 1.2rem; }
.km-schritt { text-align: center; max-width: 700px; }
.km-schritt-nr { color: var(--akzent); font-size: 1.1rem; margin-bottom: 1rem; letter-spacing: 0.03em; }
.km-schritt-text { font-size: clamp(1.5rem, 5vw, 2.3rem); line-height: 1.4; margin: 0; }
.km-fertig .km-gekocht-btn { font-size: 1.2rem; margin: 1.5rem 0 1rem; display: block; }
.km-fertig .btn-ghost { color: #fff; border-color: rgba(255,255,255,0.4); }
.km-nav { display: flex; gap: 1rem; padding: 1rem; padding-bottom: max(1rem, env(safe-area-inset-bottom)); }
.km-navbtn {
  flex: 1; padding: 1.3rem; font-size: 1.3rem; border-radius: 12px; cursor: pointer;
  border: 1px solid rgba(255,255,255,0.25); background: rgba(255,255,255,0.1); color: #fff;
}
.km-navbtn:disabled { opacity: 0.3; }
.km-weiter { background: var(--akzent); border-color: var(--akzent); flex: 2; }

/* Zutaten-Panel (immer sichtbar) */
.km-zutaten-panel {
  flex: 0 0 auto; max-height: 38vh; display: flex; flex-direction: column;
  background: rgba(255,255,255,0.06); border-top: 1px solid rgba(255,255,255,0.12);
}
.km-zutaten-kopf {
  display: flex; align-items: baseline; gap: 0.5rem; padding: 0.5rem 1rem 0.3rem;
  font-weight: 600; color: var(--akzent);
}
.km-zutaten-port { font-weight: 400; color: rgba(255,255,255,0.6); font-size: 0.85rem; }
.km-zutaten-scroll { overflow-y: auto; padding: 0 1rem 0.6rem; }
.km-zutaten-scroll .zutaten-gruppe { color: var(--akzent); margin: 0.5rem 0 0.2rem; font-size: 0.9rem; }
.km-zutaten { list-style: none; padding: 0; margin: 0; }

/* Timer-Chip im Schritt-Text */
.timer-chip {
  display: inline-block; background: var(--akzent); color: #fff; border: none;
  border-radius: 999px; padding: 0.15rem 0.7rem; margin: 0 0.15rem; font-size: 0.85em;
  cursor: pointer; white-space: nowrap; vertical-align: baseline;
}
.timer-chip:active { background: var(--akzent-dunkel); }

/* Timer-Leiste */
.km-timerleiste { display: flex; flex-wrap: wrap; gap: 0.5rem; padding: 0 1rem; justify-content: center; }
.km-timerleiste:empty { display: none; }
.km-timer {
  display: inline-flex; align-items: center; gap: 0.5rem;
  background: rgba(255,255,255,0.12); border-radius: 999px; padding: 0.35rem 0.4rem 0.35rem 0.9rem;
  margin-top: 0.6rem; font-variant-numeric: tabular-nums;
}
.km-timer-fertig { background: var(--akzent); animation: km-blink 0.8s steps(2) infinite; }
@keyframes km-blink { 50% { opacity: 0.55; } }
.km-timer-zeit { font-size: 1rem; }
.km-timer-stop { width: 1.7rem; height: 1.7rem; border-radius: 50%; border: none; background: rgba(0,0,0,0.25); color: #fff; cursor: pointer; font-size: 0.9rem; }

/* Zutaten abhaken im Kochmodus */
.km-zutat label { display: flex; align-items: center; gap: 0.6rem; cursor: pointer; padding: 0.3rem 0; border-bottom: 1px solid rgba(255,255,255,0.08); }
.km-zutat-check { width: 1.2rem; height: 1.2rem; flex: 0 0 auto; }
.km-zutat .menge { min-width: 4.5rem; color: #fff; }
.km-zutat-name { flex: 1; }
.km-zutat.erledigt .menge, .km-zutat.erledigt .km-zutat-name { text-decoration: line-through; opacity: 0.45; }

/* Schnellaktionen auf Detailseite */
.schnellaktionen { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; margin-bottom: 0.8rem; }
.plan-popup { display: flex; gap: 0.4rem; align-items: center; }
.plan-popup input[type="date"] { padding: 0.45rem; border: 1px solid var(--rand); border-radius: 8px; font-size: 0.95rem; }
.aktion-info { color: #3b9c63; font-weight: 600; font-size: 0.9rem; }

/* Einkaufsliste */
.ek-kopf { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.ek-rezepte h2 { font-size: 1rem; color: var(--text-leise); border: none; margin-bottom: 0.4rem; }
.ek-rezeptliste { list-style: none; padding: 0; margin: 0 0 1rem; }
.ek-rezept { display: flex; align-items: center; gap: 0.6rem; padding: 0.4rem 0; flex-wrap: wrap; }
.ek-rezept-titel { flex: 1 1 8rem; color: var(--text); text-decoration: none; font-weight: 600; }
.ek-rezept-titel:hover { color: var(--akzent-dunkel); }
.ek-portionen { display: inline-flex; align-items: center; gap: 0.4rem; background: var(--karte); border: 1px solid var(--rand); border-radius: 999px; padding: 0.1rem 0.5rem; font-size: 0.9rem; }
.ek-portionen button, .tag-rezept-port .port-btn { width: 1.6rem; height: 1.6rem; border-radius: 50%; border: 1px solid var(--rand); background: var(--hintergrund); color: var(--akzent-dunkel); font-size: 1.1rem; line-height: 1; cursor: pointer; }
.ek-portionen-fix { color: var(--text-leise); font-size: 0.85rem; }
.ek-rezept-weg { background: none; border: none; color: var(--gefahr); font-size: 1.1rem; cursor: pointer; padding: 0.2rem 0.4rem; }
.ek-info { color: var(--text-leise); margin-top: 0; }
.ek-kategorie h2 { font-size: 1.1rem; color: var(--akzent-dunkel); border-bottom: 2px solid var(--rand); padding-bottom: 0.25rem; margin: 1.4rem 0 0.5rem; }
.ek-liste { list-style: none; padding: 0; margin: 0; }
.ek-item label { display: flex; align-items: center; gap: 0.7rem; padding: 0.5rem 0; border-bottom: 1px dashed var(--rand); cursor: pointer; }
.ek-check { width: 1.2rem; height: 1.2rem; flex: 0 0 auto; }
.ek-name { flex: 1; }
.ek-menge { color: var(--text-leise); white-space: nowrap; }
.ek-item.erledigt .ek-name, .ek-item.erledigt .ek-menge { text-decoration: line-through; opacity: 0.5; }

@media (max-width: 480px) {
  .form-row { flex-direction: column; gap: 0; }
  .menge { min-width: 4.5rem; }
}
