:root {
  --accent: #c64a2e;
  --accent-2: #e87a3a;
  --bg: #fff7ef;
  --card: #ffffff;
  --text: #2b2320;
  --muted: #8a7d74;
  --line: #ece0d5;
  --danger: #c0392b;
  --ok: #2e7d55;
  --radius: 16px;
  --shadow: 0 2px 10px rgba(120, 70, 40, 0.08);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1815;
    --card: #262019;
    --text: #f2e9e1;
    --muted: #a99c90;
    --line: #3a312a;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--danger); }

/* Buttons */
.btn {
  appearance: none; border: 1px solid var(--line); background: var(--card);
  color: var(--text); padding: 11px 16px; border-radius: 12px; font-size: 16px;
  cursor: pointer; font-weight: 600;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 12px; font-size: 14px; border-radius: 10px; }
.icon-btn {
  appearance: none; background: transparent; border: none; color: #fff;
  font-size: 26px; line-height: 1; width: 40px; height: 40px; cursor: pointer;
}

/* Login */
.login-view {
  min-height: 100dvh; display: grid; place-items: center; padding: 24px;
  background: linear-gradient(160deg, var(--accent-2), var(--accent));
}
.login-card {
  width: 100%; max-width: 360px; background: var(--card); color: var(--text);
  border-radius: 20px; padding: 28px 24px; box-shadow: 0 12px 40px rgba(0,0,0,.2);
}
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.brand img { border-radius: 14px; }
.brand h1 { font-size: 22px; margin: 0; }
#login-form { display: grid; gap: 12px; margin-top: 12px; }
input, textarea, select {
  width: 100%; padding: 11px 13px; border: 1px solid var(--line);
  border-radius: 12px; background: var(--bg); color: var(--text); font-size: 16px;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent-2); border-color: transparent; }

/* Layout */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 8px;
  background: var(--accent); color: #fff;
  padding: calc(10px + var(--safe-top)) 10px 10px;
}
.topbar h1 { font-size: 18px; margin: 0; flex: 1; text-align: center; font-weight: 700; }
.main { padding: 16px; padding-bottom: 96px; max-width: 720px; margin: 0 auto; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: var(--safe-bottom);
}
.tab {
  flex: 1; appearance: none; border: none; background: transparent; cursor: pointer;
  color: var(--muted); font-size: 22px; padding: 8px 4px 6px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.tab span { font-size: 11px; font-weight: 600; }
.tab.active { color: var(--accent); }

/* Suchleiste + Chips */
.searchbar { display: flex; gap: 8px; margin-bottom: 12px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.chip {
  appearance: none; border: 1px solid var(--line); background: var(--card);
  color: var(--text); padding: 6px 12px; border-radius: 999px; font-size: 14px; cursor: pointer;
}
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* Gericht-Karten */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow); cursor: pointer; display: flex; flex-direction: column;
}
.card .thumb {
  width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: var(--line);
  display: grid; place-items: center; color: var(--muted); font-size: 34px;
}
.card .body { padding: 10px 12px; }
.card .title { font-weight: 700; font-size: 15px; }
.card .tags { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 4px; }
.tag-pill { font-size: 11px; background: var(--bg); border: 1px solid var(--line); color: var(--muted); padding: 2px 8px; border-radius: 999px; }

.empty { text-align: center; color: var(--muted); padding: 48px 16px; }
.empty .big { font-size: 44px; }

/* Detail */
.detail-photos { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 12px; }
.detail-photos img { height: 180px; border-radius: 12px; object-fit: cover; }
.detail h2 { margin: 0 0 4px; }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 20px 0 8px; }
.person-row { display: flex; align-items: center; gap: 12px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.stepper { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.stepper button { width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); font-size: 20px; cursor: pointer; color: var(--text); }
.stepper .count { min-width: 22px; text-align: center; font-weight: 700; font-size: 18px; }
.ing-list { list-style: none; margin: 0; padding: 0; }
.ing-list li { display: flex; justify-content: space-between; gap: 12px; padding: 10px 2px; border-bottom: 1px solid var(--line); }
.ing-list .amount { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.detail-actions { display: flex; gap: 10px; margin-top: 24px; }

/* Formular */
.form { display: grid; gap: 14px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; font-weight: 600; }
.ing-editor { display: grid; gap: 8px; }
.ing-edit-row { display: grid; grid-template-columns: 1fr 72px 78px 40px; gap: 6px; align-items: center; }
.ing-edit-row input { padding: 9px 10px; }
.ing-edit-row .del { border: none; background: transparent; color: var(--danger); font-size: 22px; cursor: pointer; }
.photo-strip { display: flex; gap: 8px; flex-wrap: wrap; }
.photo-strip .ph { position: relative; }
.photo-strip img { height: 84px; width: 84px; object-fit: cover; border-radius: 10px; }
.photo-strip .rm { position: absolute; top: -6px; right: -6px; background: var(--danger); color: #fff; border: none; border-radius: 999px; width: 22px; height: 22px; cursor: pointer; font-size: 14px; line-height: 1; }
.hint { font-size: 12px; color: var(--muted); }

/* Auslosen */
.random-controls { display: grid; gap: 12px; margin-bottom: 18px; }
.random-result { display: grid; gap: 12px; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: calc(84px + var(--safe-bottom)); transform: translateX(-50%);
  background: #333; color: #fff; padding: 10px 16px; border-radius: 12px; z-index: 50;
  max-width: 90%; box-shadow: 0 6px 20px rgba(0,0,0,.3); font-size: 14px;
}
.toast.ok { background: var(--ok); }
.toast.err { background: var(--danger); }

.spinner { text-align: center; color: var(--muted); padding: 40px; }
