:root {
  --bg: #faf6f0;
  --flaeche: #fffdfa;
  --rand: #e6dccd;
  --text: #2f2a24;
  --gedaempft: #7a7065;
  --terracotta: #c65d3b;
  --oliv: #5b7a4a;
  --gold: #d99a2b;
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1815;
    --flaeche: #262119;
    --rand: #3a332a;
    --text: #f0e9df;
    --gedaempft: #a89c8d;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}

.topbar {
  display: flex;
  align-items: baseline;
  gap: 1.5rem;
  padding: 0.75rem 1rem;
  padding-top: calc(0.75rem + env(safe-area-inset-top));
  background: var(--flaeche);
  border-bottom: 1px solid var(--rand);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar .marke { font-weight: 700; color: var(--terracotta); text-decoration: none; }
.topbar nav { display: flex; gap: 1rem; }
.topbar nav a { color: var(--gedaempft); text-decoration: none; }
.topbar nav a:hover { color: var(--text); }

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

.anmeldung {
  max-width: 20rem;
  margin: 4rem auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.anmeldung h1 { color: var(--terracotta); margin: 0 0 1rem; }

input, button, textarea, select {
  font: inherit;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--rand);
  border-radius: var(--radius);
  background: var(--flaeche);
  color: var(--text);
}

button {
  background: var(--terracotta);
  color: #fff;
  border-color: transparent;
  cursor: pointer;
}

.fehler { color: var(--terracotta); margin: 0; }

.rezepte { display: grid; grid-template-columns: 14rem 1fr; gap: 1.5rem; align-items: start; }
.tags { display: flex; flex-direction: column; gap: 0.15rem; }
.tags details > summary { list-style: none; cursor: pointer; }
.tags details > summary::-webkit-details-marker { display: none; }

.tag-knopf {
  background: none;
  border: none;
  color: var(--text);
  text-align: left;
  width: 100%;
  padding: 0.35rem 0.5rem;
  border-radius: var(--radius);
  cursor: pointer;
}
.tag-knopf:hover { background: var(--flaeche); }
.tag-knopf.aktiv { background: var(--terracotta); color: #fff; }
.tag-knopf.kind { padding-left: 1.5rem; font-size: 0.92em; }
.anzahl { color: var(--gedaempft); font-size: 0.85em; float: right; }
.tag-knopf.aktiv .anzahl { color: #ffffffcc; }

.liste { display: flex; flex-direction: column; gap: 1rem; }
.liste input[type="search"] { width: 100%; }

.raster {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
  gap: 1rem;
}

.kachel a {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  text-decoration: none;
  color: inherit;
}
.kachel img, .kachel-leer {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: var(--radius);
  background: var(--flaeche);
  border: 1px solid var(--rand);
}
.kachel-titel { font-weight: 600; line-height: 1.3; }
.kachel-zeit { color: var(--gedaempft); font-size: 0.85em; }
.leer, .hinweis { color: var(--gedaempft); }

@media (max-width: 720px) {
  .rezepte { grid-template-columns: 1fr; }
  .tags { flex-direction: row; flex-wrap: wrap; }
  .tags details { width: 100%; }
}

.rezept h1 { margin: 0 0 0.3rem; }
.rezept .meta { display: flex; gap: 1rem; color: var(--gedaempft); margin: 0 0 0.5rem; }
.rezept .tag-zeile { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0 0 0.5rem; }
.rezept .tag-zeile a {
  font-size: 0.85em;
  padding: 0.15rem 0.5rem;
  border: 1px solid var(--rand);
  border-radius: 999px;
  color: var(--gedaempft);
  text-decoration: none;
}
.rezept .herkunft { color: var(--gedaempft); font-style: italic; margin: 0 0 0.5rem; }
.link-liste { list-style: none; padding: 0; margin: 0 0 0.6rem; display: flex;
              flex-wrap: wrap; gap: 0.75rem; }
.link-liste a { color: var(--terracotta); text-decoration: none; }
.link-liste a:hover { text-decoration: underline; }
.link-liste li.video a { color: var(--oliv); }
.rezept .werkzeuge { display: flex; gap: 1rem; }
.rezept .werkzeuge a { color: var(--terracotta); }

.bilder { display: flex; gap: 0.75rem; overflow-x: auto; margin: 1rem 0; }
.bilder img {
  height: 15rem;
  border-radius: var(--radius);
  border: 1px solid var(--rand);
}

.spalten { display: grid; grid-template-columns: 18rem 1fr; gap: 2rem; align-items: start; }
/* A grid item is min-width:auto by default, so one long unbreakable word - a
   URL in an ingredient line - widens the column past its 18rem and pushes the
   text out of it. Both halves are needed: the floor lets the column hold its
   track size, the wrap breaks the word inside it. */
.spalten > * { min-width: 0; }
.zutaten ul { list-style: none; margin: 0; padding: 0; }
.zutaten li { padding: 0.25rem 0; border-bottom: 1px solid var(--rand);
              overflow-wrap: anywhere; }
.zutaten .menge { font-variant-numeric: tabular-nums; color: var(--oliv); font-weight: 600; }
.zutaten li.abschnitt { padding: 0; border-bottom: none; }
.zutaten-abschnitt { margin: 1rem 0 0.3rem; font-size: 0.95em; color: var(--gedaempft); }
.zutaten a, .anleitung a { color: var(--terracotta); overflow-wrap: anywhere; }

.anleitung p { margin: 0 0 0.8rem; }
/* The step number is drawn by the counter, not by the list marker: it sits in
   its own column so a wrapped step lines up under its own first line. */
.anleitung ol.schritte { list-style: none; margin: 0 0 1.2rem; padding: 0;
                         counter-reset: schritt; }
.anleitung ol.schritte > li {
  counter-increment: schritt;
  display: grid;
  grid-template-columns: 1.5rem 1fr;
  gap: 0.6rem;
  margin: 0 0 0.9rem;
}
.anleitung ol.schritte > li::before {
  content: counter(schritt);
  color: var(--gedaempft);
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.anleitung .schritt-abschnitt { margin: 1.4rem 0 0.6rem; font-size: 1em; color: var(--oliv); }
.anleitung .schritt-abschnitt:first-child { margin-top: 0; }

@media (max-width: 720px) {
  .spalten { grid-template-columns: 1fr; }
}

.editor { display: flex; flex-direction: column; gap: 0.9rem; }
.editor label { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.9em;
                color: var(--gedaempft); }
.editor input, .editor textarea { color: var(--text); font-size: 1rem; }
.editor textarea { font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
                   line-height: 1.45; resize: vertical; }
.editor .zwei { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.editor .vier { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.75rem; }
.editor fieldset { border: 1px solid var(--rand); border-radius: var(--radius);
                   padding: 0.75rem; }
.editor legend { color: var(--gedaempft); font-size: 0.85em; padding: 0 0.4rem; }
.herkunft-felder { display: grid; grid-template-columns: 1fr; gap: 0.75rem; }
.link-felder { display: flex; flex-direction: column; gap: 0.4rem; }
.link-zeile { display: grid; grid-template-columns: 2fr 1.4fr 8rem 2.2rem; gap: 0.4rem; }
.link-zeile button { background: none; color: var(--gedaempft); border: 1px solid var(--rand); }
.link-zeile button:disabled { opacity: 0.4; cursor: default; }
.zeile-mehr { align-self: start; background: none; color: var(--terracotta);
              border: 1px solid var(--rand); }
.tag-wahl { display: flex; flex-wrap: wrap; gap: 1.25rem; }
.tag-gruppe { display: flex; flex-direction: column; gap: 0.15rem; }
.tag-kasten { flex-direction: row !important; align-items: center; gap: 0.4rem;
              color: var(--text); }
.tag-kasten.kind { padding-left: 1rem; font-size: 0.92em; }
.aktionen { display: flex; align-items: center; gap: 1rem; }
.aktionen a { color: var(--gedaempft); }

.bild-verwaltung { margin-top: 2rem; }
.bild-liste, .bild-aktionen { list-style: none; display: flex; gap: 0.75rem;
                              padding: 0; flex-wrap: wrap; }
.bild-liste img { height: 7rem; border-radius: var(--radius); border: 1px solid var(--rand); }
.bild-liste li { position: relative; }
.titelbild { position: absolute; left: 0.3rem; bottom: 0.5rem; background: var(--terracotta);
             color: #fff; font-size: 0.7em; padding: 0.1rem 0.4rem; border-radius: 999px; }
.hinweis { color: var(--gedaempft); font-size: 0.85em; }
.bild-aktionen button, .loeschen button { background: none; color: var(--gedaempft);
                                          border: 1px solid var(--rand); }
.loeschen { margin-top: 2rem; }
.loeschen button:hover { color: var(--terracotta); border-color: var(--terracotta); }

@media (max-width: 720px) {
  .editor .zwei, .editor .vier { grid-template-columns: 1fr; }
  .link-zeile { grid-template-columns: 1fr; }
}

.icon { width: 1em; height: 1em; vertical-align: -0.125em; stroke: currentColor; fill: none; }
.tag-neu { display: flex; gap: 0.5rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.tag-verwaltung, .tag-verwaltung ul { list-style: none; padding: 0; margin: 0; }
.tag-verwaltung > li { padding: 0.5rem 0; border-bottom: 1px solid var(--rand); }
.tag-verwaltung .kind { padding-left: 1.5rem; }
.tag-aktionen { display: flex; gap: 0.5rem; flex-wrap: wrap; margin: 0.35rem 0 0.6rem; }
.tag-aktionen form { display: flex; gap: 0.25rem; }
.tag-aktionen input, .tag-aktionen select, .tag-aktionen button {
  font-size: 0.85em;
  padding: 0.25rem 0.45rem;
}
.tag-aktionen button { background: none; color: var(--gedaempft); border: 1px solid var(--rand); }

.fehlerseite { text-align: center; padding: 3rem 1rem; }
.fehlerseite .fehler-code { color: var(--gedaempft); font-size: 3rem; margin: 0; line-height: 1; }
.fehlerseite h1 { font-size: 1.25rem; margin: 0.75rem 0 1.5rem; }
.fehlerseite a { color: var(--terracotta); }
