/* Rezepte-App – Gestaltung „Emaille & Gusseisen“
 *
 * Hell: weißes Emaille-Geschirr mit Kobaltrand. Dunkel: Gusseisen mit kobaltblauem Glanz.
 * Schrift: Überschriften in New York (iOS-Serif, ui-serif), Bedienung in SF Pro Rounded
 * (ui-rounded). Beide sind auf dem iPhone eingebaut – keine Webfonts nötig (CSP 'self').
 * Mobil zuerst, Dark Mode nach Systemeinstellung, Safe-Area, Touch-Ziele ≥ 44 px (NFR5).
 */

:root {
  --hg: #f3f5f9;          /* Emaille-Weiß, leicht kühl */
  --flaeche: #ffffff;
  --flaeche-2: #eaeef6;   /* vertiefte Flächen (Eingaben, Stepper) */
  --text: #141b2d;
  --leise: #5b6680;
  --linie: #dce2ec;
  --akzent: #2340a0;      /* Kobaltrand */
  --akzent-text: #ffffff;
  --akzent-hell: #e6ecfa;
  --gefahr: #c2362b;      /* Tomate */
  --warnung: #a65a00;
  --stern: #e09b00;       /* Safran */
  --schatten: 0 1px 2px rgba(20, 27, 45, 0.06), 0 6px 20px -8px rgba(20, 27, 45, 0.18);

  --schrift-titel: ui-serif, "New York", "Iowan Old Style", "Charter", Georgia, serif;
  --schrift: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --radius-gross: 20px;   /* Kacheln, Dialoge */
  --radius: 14px;         /* Eingaben, Listenflächen */
  --tipp: 44px;           /* Mindestgröße Touch-Ziel */
  --navi-hoehe: 60px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --hg: #121418;        /* Gusseisen */
    --flaeche: #1b1e24;
    --flaeche-2: #242833;
    --text: #eceef3;
    --leise: #9aa3b5;
    --linie: #2e3340;
    --akzent: #8ea6ff;
    --akzent-text: #0e1530;
    --akzent-hell: #1e2640;
    --gefahr: #ff7a6b;
    --warnung: #f2b14c;
    --stern: #f5b82e;
    --schatten: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 8px 24px -10px rgba(0, 0, 0, 0.6);
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--hg);
  color: var(--text);
  font: 17px/1.5 var(--schrift);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

.inhalt {
  max-width: 760px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 12px) calc(env(safe-area-inset-right) + 18px)
           calc(var(--navi-hoehe) + env(safe-area-inset-bottom) + 32px) calc(env(safe-area-inset-left) + 18px);
}

/* Überschriften tragen die Persönlichkeit: Serif wie in einem Kochbuch */
h1, h2, .dialog-titel, .kachel-name, .wochen-titel {
  font-family: var(--schrift-titel);
  font-weight: 600;
  letter-spacing: -0.01em;
}
h1 { font-size: 2rem; margin: 0.25em 0 0.2em; line-height: 1.1; letter-spacing: -0.02em; }
h2 { font-size: 1.3rem; margin: 1.8em 0 0.6em; line-height: 1.2; }
h3 { font-size: 1rem; margin: 1em 0 0.3em; }
a { color: var(--akzent); }
.leise { color: var(--leise); }
.klein { font-size: 0.85rem; }
.versteckt { display: none; }
.laedt, .leer { color: var(--leise); text-align: center; padding: 3rem 1rem; }
.warnung { color: var(--warnung); }
.fehler-text { color: var(--gefahr); min-height: 1.4em; }

:focus-visible { outline: 2px solid var(--akzent); outline-offset: 2px; }

/* ---------------------------------------------------------------- Formularelemente */

input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea {
  font-size: 17px; /* ≥ 16 px verhindert Auto-Zoom auf iOS */
  min-height: var(--tipp);
  width: 100%;
  padding: 10px 14px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--flaeche-2);
  transition: border-color 0.15s, background 0.15s;
}
input::placeholder, textarea::placeholder { color: var(--leise); opacity: 0.8; }
select {
  appearance: none; -webkit-appearance: none;
  padding-right: 34px;
  /* Pfeil als Hintergrund, Farbe neutral für hell und dunkel */
  background-image: linear-gradient(45deg, transparent 50%, var(--leise) 50%), linear-gradient(135deg, var(--leise) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
textarea { resize: vertical; min-height: 96px; line-height: 1.45; }
input[type="checkbox"] { width: 24px; height: 24px; min-height: 0; accent-color: var(--akzent); flex: none; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--akzent); background: var(--flaeche); }

.knopf {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: var(--tipp);
  min-width: var(--tipp);
  padding: 8px 18px;
  border: 1px solid var(--linie);
  border-radius: 999px;
  background: var(--flaeche);
  color: var(--text);
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.1s, filter 0.15s;
}
.knopf:active { transform: scale(0.97); filter: brightness(0.94); }
.knopf:disabled { opacity: 0.4; cursor: default; transform: none; }
.knopf-primaer { background: var(--akzent); border-color: var(--akzent); color: var(--akzent-text); font-weight: 600; }
.knopf-gefahr { color: var(--gefahr); }
.knopf-primaer.knopf-gefahr, .dialog .knopf-gefahr { border-color: var(--gefahr); }
.knopf-primaer.knopf-gefahr { background: var(--gefahr); color: #fff; }
.knopf-breit { width: 100%; margin: 6px 0; }
.knopf-klein { min-height: 36px; padding: 4px 12px; font-size: 0.9rem; }
.knopf-icon { padding: 0; width: var(--tipp); height: var(--tipp); font-size: 1.1rem; border-color: transparent; background: var(--flaeche-2); }
.knopf-rund { border-radius: 50%; width: var(--tipp); padding: 0; font-size: 1.4rem; }
.knopf-zurueck { border: none; background: none; color: var(--akzent); padding-left: 0; font-weight: 600; }

.feld { display: block; margin: 10px 0; }
.feld-label { display: block; font-size: 0.85rem; color: var(--leise); margin: 0 0 4px 4px; }
.feld-reihe { display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: 10px; }
.formular label { display: block; margin: 10px 0; }
.formular input, .formular select { margin-top: 4px; }

/* ---------------------------------------------------------------- Kopfzeile, Aktionen, Chips */

.kopfzeile { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: var(--tipp); }
.kopfzeile h1 { flex: 1; }
.kopf-knoepfe { display: flex; gap: 6px; }
.import-hinweis {
  margin: 8px 0 4px; padding: 10px 14px; border-radius: var(--radius);
  background: var(--akzent-hell); color: var(--text); font-size: 0.92rem;
}
.import-hinweis p { margin: 0; font-weight: 600; color: var(--akzent); }
.import-hinweis ul { margin: 6px 0 0; padding-left: 1.2em; }
.aktionen { display: flex; flex-wrap: wrap; gap: 8px; margin: 20px 0; }

.tag-leiste { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  min-height: 34px; padding: 4px 14px;
  border: 1px solid var(--linie); border-radius: 999px;
  background: transparent; font-size: 0.9rem; color: var(--text);
}
button.chip { min-height: var(--tipp); cursor: pointer; }
.chip-aktiv { background: var(--akzent); border-color: var(--akzent); color: var(--akzent-text); font-weight: 600; }
.chip-x { border: none; background: none; min-width: var(--tipp); min-height: var(--tipp); margin: -6px -12px -6px 0; color: var(--leise); cursor: pointer; }

/* ---------------------------------------------------------------- Rezeptliste */

.such-leiste { display: flex; gap: 8px; margin-top: 4px; }
.such-leiste .suche { padding-left: 16px; }
.such-leiste .sortierung { width: auto; flex: none; max-width: 45%; }
.anzahl { margin: 6px 4px 12px; font-size: 0.85rem; }
.raster { display: grid; grid-template-columns: repeat(auto-fill, minmax(155px, 1fr)); gap: 14px; }
.kachel {
  display: flex; flex-direction: column;
  background: var(--flaeche); border-radius: var(--radius-gross);
  box-shadow: var(--schatten);
  overflow: hidden; color: var(--text); text-decoration: none;
  transition: transform 0.12s;
}
.kachel:active { transform: scale(0.98); }
.kachel-bild { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; }
.kachel-text { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 3px; }
.kachel-name { font-size: 1.05rem; line-height: 1.2; overflow-wrap: anywhere; }
.kachel-info { font-size: 0.82rem; display: flex; gap: 8px; align-items: center; }
.sterne { color: var(--stern); letter-spacing: 1px; }

/* Platzhalter ohne Foto: kobaltblaues Emaille mit hellen Sprenkeln */
.foto-platzhalter {
  display: flex; align-items: center; justify-content: center;
  aspect-ratio: 4 / 3; width: 100%;
  font-size: 2.2rem;
  background-color: var(--akzent);
  background-image:
    radial-gradient(circle at 18% 27%, rgba(255, 255, 255, 0.55) 0 1.4px, transparent 2px),
    radial-gradient(circle at 63% 71%, rgba(255, 255, 255, 0.45) 0 1.1px, transparent 1.7px),
    radial-gradient(circle at 81% 19%, rgba(255, 255, 255, 0.35) 0 1.6px, transparent 2.2px),
    radial-gradient(circle at 37% 86%, rgba(255, 255, 255, 0.4) 0 1px, transparent 1.6px);
  background-size: 61px 53px, 47px 71px, 89px 79px, 43px 59px;
}
@media (prefers-color-scheme: dark) {
  .foto-platzhalter { background-color: #263a85; }
}

/* ---------------------------------------------------------------- Rezeptansicht */

.rezept-foto { margin: -12px -18px 0; }
.rezept-foto .foto-gross, .rezept-foto .foto-platzhalter {
  border-radius: 0 0 28px 28px;
}
.foto-gross { width: 100%; max-height: 50vh; object-fit: cover; display: block; }
.rezept-foto .foto-platzhalter { display: flex; aspect-ratio: 16 / 9; font-size: 3rem; }
.rezept-name { overflow-wrap: anywhere; margin-top: 0.5em; }
.eckdaten { display: flex; flex-wrap: wrap; gap: 6px 16px; color: var(--leise); font-size: 0.95rem; }
.sterne-eingabe { display: flex; gap: 0; margin: 4px 0 0 -8px; }
.stern { border: none; background: none; min-width: var(--tipp); min-height: var(--tipp); font-size: 1.6rem; color: var(--leise); opacity: 0.55; cursor: pointer; padding: 0; transition: transform 0.12s; }
.stern:active { transform: scale(1.2); }
.stern-an { color: var(--stern); opacity: 1; }

/* Portionen: das markante Element – ein Emaillerand mit großer Serifenziffer */
.portionen {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px;
  margin: 22px 0 6px; padding: 8px 8px 8px 18px;
  border: 2px solid var(--akzent); border-radius: 999px;
  background: var(--flaeche);
}
/* Mit Umrechnungshinweis wird aus der Pille eine abgerundete Fläche */
.portionen:has(.umgerechnet) { border-radius: 28px; padding-bottom: 10px; }
.portionen-label { font-weight: 600; }
.stepper { display: inline-flex; align-items: center; gap: 4px; }
.stepper .knopf { border: none; background: var(--akzent-hell); color: var(--akzent); font-weight: 700; }
.stepper-feld {
  width: 64px; text-align: center; background: transparent; border: none;
  font-family: var(--schrift-titel); font-size: 1.6rem; font-weight: 600; padding: 0;
  font-variant-numeric: tabular-nums;
}
.stepper-feld:focus { background: var(--akzent-hell); }
.umgerechnet {
  flex-basis: 100%; margin: 4px 0 0 -10px; padding: 6px 6px 6px 14px; border-radius: 999px;
  background: var(--akzent-hell); color: var(--akzent);
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  font-size: 0.9rem; font-weight: 500;
}

.zutaten { list-style: none; padding: 0; margin: 0; }
.zutat { display: flex; align-items: baseline; gap: 14px; padding: 10px 0; border-bottom: 1px solid var(--linie); }
.zutat:last-child { border-bottom: none; }
.zutat-menge {
  flex: 0 0 6.5em; text-align: right; font-weight: 600; color: var(--akzent);
  font-variant-numeric: tabular-nums;
}
.zutat-name { flex: 1; overflow-wrap: anywhere; }

.naehrwerte { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.naehrwerte th, .naehrwerte td { padding: 8px 4px; border-bottom: 1px solid var(--linie); text-align: right; }
.naehrwerte tr:last-child th, .naehrwerte tr:last-child td { border-bottom: none; }
.naehrwerte th[scope="row"], .naehrwerte thead th:first-child { text-align: left; font-weight: normal; }
.naehrwerte thead th { font-size: 0.85rem; color: var(--leise); font-weight: normal; }

/* Zubereitung ist eine echte Abfolge: große Kobalt-Ziffern */
.schritte { list-style: none; padding: 0; counter-reset: schritt; }
.schritte li {
  counter-increment: schritt; position: relative;
  margin: 0 0 16px; padding-left: 2.6em; overflow-wrap: anywhere;
}
.schritte li::before {
  content: counter(schritt);
  position: absolute; left: 0; top: -0.15em;
  font-family: var(--schrift-titel); font-size: 1.5rem; font-weight: 600; color: var(--akzent);
  line-height: 1.2; width: 1.4em; text-align: right;
}
.notizen {
  white-space: pre-wrap; overflow-wrap: anywhere;
  padding: 12px 16px; border-left: 3px solid var(--stern); background: var(--flaeche);
  border-radius: 0 var(--radius) var(--radius) 0;
}

/* ---------------------------------------------------------------- Editor */

.editor-zeile {
  display: flex; gap: 8px; align-items: flex-start;
  padding: 12px 0; border-bottom: 1px solid var(--linie);
}
.editor-felder { flex: 1; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.editor-knoepfe { display: flex; flex-direction: column; gap: 4px; }
.menge-einheit { display: flex; gap: 6px; }
.menge-einheit .menge { flex: 1; }
.menge-einheit select { flex: 1; }
.schritt-nr { padding-top: 6px; font-family: var(--schrift-titel); font-size: 1.3rem; font-weight: 600; color: var(--akzent); min-width: 1.4em; }
.zeile-eingabe { display: flex; gap: 8px; }
.zeile-eingabe .knopf { flex: none; }
.foto-editor { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.foto-vorschau { width: 160px; aspect-ratio: 4 / 3; object-fit: cover; border-radius: var(--radius); }
.fehler-box:not(:empty) {
  border: 1px solid var(--gefahr); color: var(--gefahr); border-radius: var(--radius); padding: 6px 14px; margin: 12px 0;
}

/* ---------------------------------------------------------------- Kochmodus (FR13) */

.kochmodus { font-size: 22px; line-height: 1.5; }
.kochmodus h1 { font-size: 1.5em; }
.kochmodus h2 { font-size: 1.15em; }
.koch-portionen { color: var(--leise); }
.koch-zutaten { padding-left: 1.2em; }
.koch-zutaten li { margin: 6px 0; }
.koch-schritte { list-style: none; padding: 0; }
.koch-schritt {
  display: block; width: 100%; text-align: left; font-size: 22px; line-height: 1.45;
  padding: 18px 20px; margin: 10px 0; min-height: var(--tipp);
  border: 2px solid var(--linie); border-radius: var(--radius-gross);
  background: var(--flaeche); color: var(--text); cursor: pointer;
  transition: opacity 0.2s, border-color 0.2s;
}
.koch-schritt:not(.erledigt):first-of-type { border-color: var(--akzent); }
.koch-schritt.erledigt { opacity: 0.45; text-decoration: line-through; border-color: transparent; }
.wakelock-status { font-size: 0.7em; }

/* ---------------------------------------------------------------- Einkaufsliste */

.einkauf-neu {
  display: flex; gap: 6px; margin: 10px 0 18px; padding: 6px;
  background: var(--flaeche); border-radius: var(--radius-gross); box-shadow: var(--schatten);
}
.einkauf-neu input, .einkauf-neu select { background: transparent; }
.einkauf-neu input:first-child { flex: 2; }
.einkauf-neu .menge { flex: 1; min-width: 0; }
.einkauf-neu select { flex: 1; width: auto; min-width: 0; }
.einkauf-neu .knopf { flex: none; width: var(--tipp); padding: 0; font-size: 1.4rem; }
.einkauf-gruppe {
  list-style: none; padding: 2px 14px; margin: 0 0 14px;
  background: var(--flaeche); border-radius: var(--radius-gross);
}
.einkauf-gruppe:empty { display: none; }
.einkauf-eintrag { display: flex; align-items: center; gap: 6px; padding: 4px 0; border-bottom: 1px solid var(--linie); }
.einkauf-eintrag:last-child { border-bottom: none; }
.einkauf-text { flex: 1; display: flex; flex-direction: column; min-width: 0; overflow-wrap: anywhere; }
.einkauf-name { font-weight: 500; }
.einkauf-eintrag.erledigt .einkauf-name { text-decoration: line-through; color: var(--leise); font-weight: 400; }
.haken { border: none; background: none; min-width: var(--tipp); min-height: var(--tipp); font-size: 1.5rem; color: var(--akzent); cursor: pointer; padding: 0; }
.ausstehend-zaehler { color: var(--warnung); font-size: 0.9rem; }

/* ---------------------------------------------------------------- Wochenplan */

.wochen-navi { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.wochen-titel { font-size: 1.1rem; text-align: center; }
.tag { padding: 6px 0 10px; border-bottom: 1px solid var(--linie); }
.tag:last-child { border-bottom: none; }
.tag-kopf { display: flex; align-items: center; justify-content: space-between; }
.tag-kopf h2 { margin: 0.5em 0; font-size: 1.1rem; }
.plan-eintraege { list-style: none; padding: 0; margin: 0 0 6px; display: flex; flex-direction: column; gap: 6px; }
.plan-eintrag { display: flex; align-items: center; gap: 4px; }
.plan-link {
  flex: 1; min-height: var(--tipp); display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px;
  padding: 8px 14px; background: var(--flaeche); border-left: 4px solid var(--akzent); border-radius: 6px var(--radius) var(--radius) 6px;
  color: var(--text); text-decoration: none; overflow-wrap: anywhere; box-shadow: var(--schatten);
}

/* ---------------------------------------------------------------- Login / Einstellungen */

.login-formular { max-width: 360px; margin: 14vh auto 0; text-align: center; display: flex; flex-direction: column; gap: 14px; }
.login-formular h1 { font-size: 2.4rem; margin-bottom: 0.3em; }
.login-logo {
  width: 96px; height: 96px; margin: 0 auto; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: 3rem;
  border: 4px solid var(--akzent); background: var(--flaeche); box-shadow: var(--schatten);
}
.version { margin-top: 2rem; text-align: center; }

/* ---------------------------------------------------------------- Navigation, Banner, Meldung, Dialog */

.navi {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; justify-content: space-around; gap: 4px;
  background: color-mix(in srgb, var(--flaeche) 82%, transparent);
  -webkit-backdrop-filter: saturate(1.6) blur(18px); backdrop-filter: saturate(1.6) blur(18px);
  border-top: 1px solid var(--linie);
  padding: 4px calc(env(safe-area-inset-right) + 8px) env(safe-area-inset-bottom) calc(env(safe-area-inset-left) + 8px);
}
.reiter {
  flex: 1; min-height: var(--navi-hoehe);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 0.72rem; color: var(--leise); text-decoration: none;
}
.reiter-symbol {
  font-size: 1.25rem; line-height: 1; padding: 4px 16px; border-radius: 999px;
  transition: background 0.2s;
}
.reiter-aktiv { color: var(--akzent); font-weight: 600; }
.reiter-aktiv .reiter-symbol { background: var(--akzent-hell); }
body.vollbild .navi { display: none; }
body.vollbild .inhalt { padding-bottom: calc(env(safe-area-inset-bottom) + 24px); }

.banner-bereich {
  position: sticky; top: 0; z-index: 20;
  padding-top: env(safe-area-inset-top);
}
.banner-bereich:empty { padding: 0; }
.banner {
  display: flex; align-items: center; gap: 8px;
  padding: 8px calc(env(safe-area-inset-right) + 14px) 8px calc(env(safe-area-inset-left) + 14px);
  background: var(--warnung); color: #fff; font-weight: 500;
}
.banner span { flex: 1; }
.banner .knopf { background: transparent; color: #fff; border-color: rgba(255, 255, 255, 0.6); }

.meldung {
  position: fixed; left: 50%; z-index: 30;
  bottom: calc(var(--navi-hoehe) + env(safe-area-inset-bottom) + 16px);
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  max-width: calc(100% - 32px);
  padding: 12px 20px; border-radius: 999px;
  background: var(--text); color: var(--hg); font-weight: 500;
  box-shadow: var(--schatten);
  transition: opacity 0.2s, transform 0.25s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
.meldung.sichtbar { opacity: 1; transform: translate(-50%, 0); }
.meldung-fehler { background: var(--gefahr); color: #fff; }

.dialog {
  width: min(520px, calc(100vw - 24px)); max-height: calc(100vh - 48px);
  border: none; border-radius: 24px; padding: 20px;
  background: var(--flaeche); color: var(--text);
  box-shadow: 0 24px 60px -20px rgba(0, 0, 0, 0.5);
}
.dialog::backdrop { background: rgba(10, 14, 30, 0.45); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.dialog-titel { margin-top: 0; font-size: 1.35rem; }
.dialog-knoepfe { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.abwahl { max-height: 55vh; overflow-y: auto; }
.abwahl-gruppe { font-size: 0.95rem; color: var(--leise); }
.abwahl-zeile { display: flex; align-items: center; gap: 10px; min-height: var(--tipp); border-bottom: 1px solid var(--linie); }
.abwahl-name { flex: 1; overflow-wrap: anywhere; }

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