/* ===== Farbpaletten =====
   Palette per data-palette auf <html> (fehlt = Kräuter), Modus per data-theme (fehlt = Automatisch).
   Gesetzt von public/theme.js. Dunkel jeweils Stufe „Dämmerung“, abgeleitet aus der hellen Palette. */
:root {
  --radius: 14px;
  --shadow: 0 1px 2px rgb(40 45 30 / 6%), 0 4px 16px rgb(40 45 30 / 6%);
  --bg: #faf7f0; /* Seitenhintergrund: warmes Cremeweiß */
  --surface: #ffffff; /* Rezeptkarten */
  --text: #22261f;
  --heading: #344a35; /* Überschriften: dunkles Olivgrün */
  --muted: #747c70; /* Sekundärtext: gedämpftes Grauoliv */
  --line: #e6e4da;
  --accent: #547a53; /* aktive Filter, Knöpfe: Kräutergrün */
  --accent-soft: #dce9d5; /* Kartenkopf ohne Foto, Tags: Salbeigrün */
  --on-accent: #ffffff;
  --star: #d88b5c; /* Favoriten: Terrakotta */
  --on-star: #3a2216; /* dunkle Schrift auf Terrakotta (Kontrast) */
  --rating: #d9a21b; /* Bewertungssterne */
  --danger: #b4412f;
  --done: #aab0a5;
  color-scheme: light;
}
:root[data-palette="tomate"] {
  --bg: #fff9f3; /* Cream – Seitenhintergrund */
  --surface: #ffffff; /* Pure White – Rezeptkarten */
  --text: #2e2824;
  --heading: #49423c; /* Dark Cocoa – Überschriften */
  --muted: #8b7770; /* Warm Taupe – Sekundärtext */
  --line: #eed9ce; /* Peach Border – Rahmen */
  --accent: #c85e47; /* Tomato – Buttons, aktive Filter */
  --accent-soft: #f4dcd0; /* Soft Apricot – Kartenkopf */
  --on-accent: #ffffff;
  --star: #c56e54; /* Terracotta – Favoriten */
  --on-star: #2a140c; /* dunkle Schrift auf Terracotta (Kontrast) */
  --rating: #d39a14;
  --danger: #b4412f;
  --done: #c2b2aa;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #353c34;
    --surface: #424a41;
    --text: #e8ece4;
    --heading: #d3e2cc;
    --muted: #b3bcad;
    --line: #535d51;
    --accent: #a6d4a2;
    --accent-soft: #4b5e47;
    --on-accent: #10200f;
    --star: #e7a27c;
    --on-star: #2a140a;
  --rating: #f0c24f;
    --danger: #e8806c;
    --done: #949d90;
    --shadow: none;
    color-scheme: dark;
  }
  :root[data-palette="tomate"]:not([data-theme="light"]) {
    --bg: #3d3632;
    --surface: #4a423d;
    --text: #f4ede8;
    --heading: #f3e4d9;
    --muted: #c9b8ae;
    --line: #5f5550;
    --accent: #f2967f;
    --accent-soft: #614b41;
    --on-accent: #2a120b;
    --star: #eaa68d;
    --on-star: #2a120b;
  --rating: #f2c75a;
    --danger: #f08a74;
    --done: #9d8f88;
    --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #353c34;
  --surface: #424a41;
  --text: #e8ece4;
  --heading: #d3e2cc;
  --muted: #b3bcad;
  --line: #535d51;
  --accent: #a6d4a2;
  --accent-soft: #4b5e47;
  --on-accent: #10200f;
  --star: #e7a27c;
  --on-star: #2a140a;
  --rating: #f0c24f;
  --danger: #e8806c;
  --done: #949d90;
  --shadow: none;
  color-scheme: dark;
}
:root[data-palette="tomate"][data-theme="dark"] {
  --bg: #3d3632;
  --surface: #4a423d;
  --text: #f4ede8;
  --heading: #f3e4d9;
  --muted: #c9b8ae;
  --line: #5f5550;
  --accent: #f2967f;
  --accent-soft: #614b41;
  --on-accent: #2a120b;
  --star: #eaa68d;
  --on-star: #2a120b;
  --rating: #f2c75a;
  --danger: #f08a74;
  --done: #9d8f88;
  --shadow: none;
  color-scheme: dark;
}

/* Schriften (lokal ausgeliefert, siehe public/fonts/LICENSE.md) */
@font-face {
  font-family: "Fraunces"; font-style: normal; font-weight: 600; font-display: swap;
  src: url("/fonts/fraunces-600-latin.woff2") format("woff2");
}
@font-face {
  font-family: "Inter"; font-style: normal; font-weight: 400 600; font-display: swap;
  src: url("/fonts/inter-var-latin.woff2") format("woff2");
}
:root {
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-head: "Fraunces", Georgia, "Times New Roman", serif;
}
h1, h2, .head-font { font-family: var(--font-head); font-weight: 600; letter-spacing: -0.01em; color: var(--heading); }

* { box-sizing: border-box; }
/* „hidden“ muss immer gewinnen – sonst überstimmen display-Regeln (z. B. .btn, .fab-menu) das Attribut */
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--font-body);
}
a { color: var(--accent); }
button, input, textarea { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }

#app {
  max-width: 1100px;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 16px calc(96px + env(safe-area-inset-bottom));
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 16px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); cursor: pointer; text-decoration: none; color: var(--text);
  white-space: nowrap;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
.btn.danger { color: var(--danger); }
.btn.icon { width: 44px; padding: 0; font-size: 20px; }
.btn.ghost { border-color: transparent; background: transparent; }

.fab {
  position: fixed; right: max(20px, env(safe-area-inset-right)); bottom: calc(20px + env(safe-area-inset-bottom));
  width: 60px; height: 60px; border-radius: 50%; border: 0;
  background: var(--accent); color: var(--on-accent); font-size: 32px; line-height: 1;
  box-shadow: 0 6px 20px rgb(0 0 0 / 20%); cursor: pointer;
  display: grid; place-items: center; text-decoration: none;
}

.fab { transition: transform .15s; }
.fab.open { transform: rotate(45deg); }
.fab-menu {
  position: fixed; right: max(20px, env(safe-area-inset-right)); bottom: calc(92px + env(safe-area-inset-bottom));
  display: grid; gap: 8px; justify-items: end; z-index: 5;
}
.fab-menu .btn { box-shadow: 0 4px 16px rgb(0 0 0 / 15%); }

.busy {
  position: fixed; inset: 0; z-index: 20; display: grid; place-items: center;
  background: rgb(0 0 0 / 35%); padding: 16px;
}
.busy-card {
  background: var(--surface); color: var(--text); border-radius: var(--radius); padding: 24px 28px;
  display: grid; gap: 6px; justify-items: center; text-align: center; max-width: 320px;
}
.busy-card span { color: var(--muted); font-size: 14px; }
.spinner {
  width: 36px; height: 36px; border-radius: 50%; margin-bottom: 8px;
  border: 3px solid var(--accent-soft); border-top-color: var(--accent); animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Hilfe ---- */
.help { display: grid; gap: 10px; max-width: 720px; }
.help details, .example {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
.help summary, .example summary {
  cursor: pointer; padding: 14px 16px; font-weight: 600; list-style: none;
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
}
.help summary::-webkit-details-marker, .example summary::-webkit-details-marker { display: none; }
.help summary::after, .example summary::after { content: "+"; color: var(--accent); font-size: 20px; font-weight: 400; }
.help details[open] summary::after, .example[open] summary::after { content: "−"; }
.help-body { padding: 0 16px 14px; }
.help-body p, .help-body ul, .help-body ol { margin: 0 0 10px; }
.help-body li { margin-bottom: 4px; }
.help pre, .example pre {
  background: var(--accent-soft); border-radius: 10px; padding: 10px 12px; margin: 0 0 10px;
  font-size: 14px; white-space: pre-wrap;
}
.example { font-size: 14px; }
.example summary { padding: 8px 14px; font-weight: 500; color: var(--accent); }
.example pre, .example p { margin-left: 14px; margin-right: 14px; }
.example p { color: var(--muted); margin-bottom: 12px; }
.cook-hint { color: var(--muted); font-size: 15px; margin: -8px 0 16px; }

/* ---- List ---- */
.top { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.top h1 { margin: 0; font-size: clamp(25px, 7vw, 30px); flex: 1; min-width: 0; line-height: 1.05; white-space: nowrap; }
.top h1 .tagline { display: block; font-family: var(--font-body); font-size: 13px; font-weight: 400; letter-spacing: .02em; color: var(--muted); margin-top: 3px; }
.count { color: var(--muted); font-size: 14px; }

.search {
  width: 100%; height: 48px; padding: 0 16px 0 44px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' fill='none' stroke='%23999' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='9' cy='9' r='6'/%3E%3Cpath d='m14 14 4 4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: 16px center;
  outline: none;
}
.search:focus { border-color: var(--accent); }

.listbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 10px; }
.sort {
  display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-size: 14px;
  border: 1px solid var(--line); border-radius: 999px; padding: 0 4px 0 12px; background: var(--surface);
}
.sort select {
  border: 0; background: transparent; font-size: 14px; padding: 7px 8px 7px 2px; outline: none;
  color: var(--text); cursor: pointer;
}
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 12px 0 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; padding: 6px 14px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); cursor: pointer; font-size: 14px; color: var(--text);
}
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; margin-top: 14px; }
.card {
  background: var(--surface); border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow); text-decoration: none; color: inherit;
  display: flex; flex-direction: column;
}
.card { position: relative; }
/* zuletzt geöffnetes Rezept nach „Zurück“: Rahmen, der langsam verblasst */
.card.last { animation: last-seen 3s ease-out forwards; }
@keyframes last-seen {
  0%, 40% { box-shadow: 0 0 0 3px var(--accent), var(--shadow); }
  100% { box-shadow: 0 0 0 3px transparent, var(--shadow); }
}
.card .star {
  position: absolute; z-index: 1; top: 8px; right: 8px; width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center; font-size: 16px; line-height: 1;
  background: var(--surface); color: var(--star); box-shadow: 0 1px 4px rgb(0 0 0 / 15%);
}
.chip.fav.on { background: var(--star); border-color: var(--star); color: var(--on-star); }
.fav-btn { font-size: 22px; color: var(--muted); }
.fav-btn.on { color: var(--star); border-color: var(--star); }
.card .thumb { aspect-ratio: 3 / 2; object-fit: cover; width: 100%; background: var(--accent-soft); }
.card .ph {
  aspect-ratio: 3 / 2; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent);
}
.card .ph svg { opacity: .85; }
.card .body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 6px; }
/* feste Zeilen: Titel (2 Zeilen), Zeit (1), Tags (1) – damit alle Karten gleich aufgebaut sind */
.card h3 {
  margin: 0; font-size: 15px; line-height: 1.3; font-weight: 600; min-height: 2.6em;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card .c-time { color: var(--muted); font-size: 13px; line-height: 1.4; min-height: 1.4em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .c-tags { display: flex; flex-wrap: wrap; gap: 4px; height: 21px; overflow: hidden; }
.card .c-tags span {
  font-size: 11.5px; line-height: 19px; padding: 0 8px; border-radius: 999px; white-space: nowrap;
  background: var(--accent-soft); color: var(--heading);
}
.card .meta { color: var(--muted); font-size: 13px; margin-top: 4px; }
.empty { text-align: center; color: var(--muted); padding: 60px 0; }

/* ---- Recipe ---- */
.bar { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.bar .spacer { flex: 1; }
.bar strong { font-family: var(--font-head); font-weight: 600; font-size: 21px; color: var(--heading); }
.hero { border-radius: var(--radius); overflow: hidden; margin-bottom: 16px; max-height: 360px; }
.hero img { width: 100%; height: 100%; max-height: 360px; object-fit: cover; }
.recipe h1 { font-size: 32px; line-height: 1.12; margin: 0 0 10px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.tag { font-size: 13px; padding: 2px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--heading); text-decoration: none; }
.facts { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 20px; color: var(--muted); font-size: 15px; }
.facts a { word-break: break-all; }

.scaler {
  display: inline-flex; align-items: center; gap: 2px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 3px;
  color: var(--text);
}
.scaler button { width: 36px; height: 36px; border-radius: 50%; border: 0; background: transparent; font-size: 20px; cursor: pointer; color: var(--accent); }
.scaler button:hover { background: var(--accent-soft); }
.scaler span { min-width: 92px; text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; }

.cols { display: grid; gap: 28px; }
@media (min-width: 760px) { .cols { grid-template-columns: minmax(260px, 1fr) 2fr; } }
.cols h2 { font-size: 21px; margin: 0 0 8px; }
.cols h4 { margin: 16px 0 6px; font-size: 14px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }

.ing { list-style: none; margin: 0; padding: 0; }
.ing li { display: flex; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.ing .amt { min-width: 76px; font-weight: 600; font-variant-numeric: tabular-nums; }

.steps { margin: 0; padding-left: 24px; }
.steps li { margin-bottom: 12px; padding-left: 4px; }
.notes { margin-top: 28px; padding: 14px 16px; background: var(--surface); border-radius: var(--radius); white-space: pre-wrap; color: var(--muted); }
.notes strong { color: var(--text); display: block; margin-bottom: 4px; }

/* ---- Cook mode ---- */
.cook { font-size: 20px; }
.cook h1 { font-size: 28px; margin: 0; flex: 1; line-height: 1.15; }
.cook .cols { gap: 36px; }
.cook .ing li { cursor: pointer; padding: 12px 4px; align-items: center; user-select: none; }
.cook .ing li::before {
  content: ""; flex: none; width: 24px; height: 24px; border-radius: 7px; border: 2px solid var(--line);
}
.cook .ing li.done { color: var(--done); text-decoration: line-through; }
.cook .ing li.done::before { background: var(--accent); border-color: var(--accent); }
.cook .steps { list-style: none; padding: 0; counter-reset: s; }
.cook .steps li {
  counter-increment: s; position: relative; cursor: pointer; user-select: none;
  padding: 14px 16px 14px 56px; margin-bottom: 10px; border-radius: var(--radius);
  background: var(--surface); border: 2px solid transparent;
}
.cook .steps li::before {
  content: counter(s); position: absolute; left: 14px; top: 14px;
  width: 30px; height: 30px; border-radius: 50%; background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center; font-size: 16px; font-weight: 700;
}
.cook .steps li.current { border-color: var(--accent); }
.cook .steps li.done { color: var(--done); }
.cook .steps li.done::before { content: "✓"; background: var(--line); color: var(--muted); }
.wake { font-size: 13px; color: var(--muted); }

/* ---- Editor ---- */
.form { display: grid; gap: 16px; }
.form label { display: grid; gap: 6px; font-weight: 600; font-size: 14px; }
.form .hint { font-weight: 400; color: var(--muted); font-size: 13px; }
.form input[type=text], .form input[type=number], .form input[type=url], .form textarea {
  width: 100%; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); font-weight: 400; outline: none;
}
.form input:focus, .form textarea:focus { border-color: var(--accent); }
.form textarea { resize: vertical; line-height: 1.6; }
.row { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
.row3 { display: grid; gap: 12px; grid-template-columns: 1fr 1fr 1.4fr; }
@media (max-width: 520px) { .row3 { grid-template-columns: 1fr 1fr; } .row3 > :last-child { grid-column: span 2; } }
.photo-edit { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.photo-edit img { width: 120px; height: 90px; object-fit: cover; border-radius: 10px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; padding-top: 6px; }
.actions .spacer { flex: 1; }

#toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 999px;
  opacity: 0; pointer-events: none; transition: .2s; font-size: 15px;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

@media print {
  .bar, .fab, .scaler button { display: none !important; }
  :root { --bg: #fff; --surface: #fff; --text: #000; --muted: #444; --line: #ccc; }
}

.theme-btn { font-size: 18px; color: var(--muted); }
.top { position: relative; }
.look-menu {
  position: absolute; right: 0; top: 52px; z-index: 10; width: min(300px, calc(100vw - 32px));
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 8px 28px rgb(0 0 0 / 18%); padding: 12px 14px 14px;
}
.look-label { font-size: 13px; color: var(--muted); margin: 4px 0 6px; }
.look-label + .seg + .look-label { margin-top: 12px; }
.seg { display: flex; gap: 6px; }
.seg button {
  flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 0 8px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg); color: var(--text); font-size: 14px; cursor: pointer;
}
.seg button[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--heading); font-weight: 600; }
.seg .dot { width: 14px; height: 14px; border-radius: 50%; flex: none; }

/* Gäste / Anmeldung / Privat */
.login-btn { font-size: 14px; color: var(--muted); padding: 0 12px; }
/* schmale Handys: nur das Schloss, damit der Name in eine Zeile passt */
@media (max-width: 440px) { .login-btn .lbl { display: none; } .login-btn { padding: 0 8px; } .top { gap: 6px; } }
.look-logout { margin-top: 12px; width: 100%; min-height: 40px; border-radius: 10px; border: 1px solid var(--line); background: transparent; color: var(--muted); cursor: pointer; font-size: 14px; }
.private-note { display: inline-block; font-size: 13px; color: var(--muted); background: var(--accent-soft); border-radius: 999px; padding: 2px 10px; margin-bottom: 10px; }
.card .lock { font-size: 12px; }
.form .check { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.form .check input { width: 20px; height: 20px; accent-color: var(--accent); }

.keep-orig { margin-top: 6px; font-weight: 500 !important; }

/* Vorheriges / Nächstes Rezept */
.recipe-nav { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: stretch; margin-top: 28px; }
.recipe-nav .rn {
  display: flex; flex-direction: column; gap: 2px; padding: 10px 14px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line); color: var(--text); text-decoration: none; min-width: 0;
}
.recipe-nav .rn.next { text-align: right; }
.recipe-nav .rn.empty { background: transparent; border-color: transparent; }
.recipe-nav .rn small { color: var(--accent); font-weight: 600; font-size: 13px; }
.recipe-nav .rn span { font-weight: 600; font-size: 14px; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.recipe-nav .rn:hover { border-color: var(--accent); }
.rn-pos { align-self: center; color: var(--muted); font-size: 13px; white-space: nowrap; }
@media print { .recipe-nav { display: none; } }

/* Bewertung (Sterne) – getrennt vom Favoriten-Herz */
.stars { display: inline-flex; gap: 1px; line-height: 1; }
.stars .st { color: var(--line); font-size: 20px; }
.stars .st.full { color: var(--rating); }
.stars .st.half { background: linear-gradient(90deg, var(--rating) 50%, var(--line) 50%); -webkit-background-clip: text; background-clip: text; color: transparent; }
.stars.rate .st { background: none; border: 0; padding: 2px; cursor: pointer; font-size: 26px; }
.stars.rate .st:hover, .stars.rate .st:focus-visible { transform: scale(1.12); }
.rating-row { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; flex-wrap: wrap; }
.rating-text { color: var(--muted); font-size: 14px; }
.card .c-time { display: flex; justify-content: space-between; gap: 6px; }
.card .c-time .t { overflow: hidden; text-overflow: ellipsis; }
.card .c-rating { color: var(--muted); font-weight: 600; flex: none; }
.card .c-rating b { color: var(--rating); }
.fav-btn { font-size: 22px; }
