:root {
  --color-bg: #f7f5f2;
  --color-surface: #ffffff;
  --color-primary: #d9622b;
  --color-primary-dark: #b64e1f;
  --color-text: #2b2622;
  --color-muted: #756f68;
  --color-border: #e5e0da;
  --color-danger: #c0392b;
  --color-success: #2e7d32;
  --radius: 12px;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  font-size: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

a { color: var(--color-primary-dark); }

.app {
  max-width: 900px;
  margin: 0 auto;
  padding: 1rem;
  padding-bottom: 4rem;
}

/* ---------- Topbar & Navigation ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--color-primary);
  color: #fff;
  padding: 0.75rem 1rem;
  box-shadow: var(--shadow);
}
.topbar__title { font-size: 1.1rem; margin: 0; }
.topbar__spacer { flex: 1; }

.hamburger {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 32px;
  height: 32px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
}
.hamburger span {
  display: block;
  height: 2px;
  background: #fff;
  border-radius: 2px;
}

.drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 240px;
  background: var(--color-surface);
  box-shadow: var(--shadow);
  z-index: 30;
  display: flex;
  flex-direction: column;
  padding: 1rem;
  gap: 0.25rem;
  transform: translateX(-100%);
  transition: transform 0.2s ease;
}
.drawer.open { transform: translateX(0); }
.drawer a, .drawer button {
  display: block;
  padding: 0.75rem 0.5rem;
  border-radius: 8px;
  text-decoration: none;
  color: var(--color-text);
  background: transparent;
  border: none;
  text-align: left;
  cursor: pointer;
  font-size: 1rem;
}
.drawer a:hover, .drawer button:hover { background: var(--color-bg); }
.drawer__logout { margin-top: auto; color: var(--color-danger); }

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 25;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.6rem 1rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  background: var(--color-primary);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  line-height: 1.2;
}
.btn:hover { background: var(--color-primary-dark); }
.btn.secondary {
  background: transparent;
  color: var(--color-text);
  border-color: var(--color-border);
}
.btn.secondary:hover { background: var(--color-bg); }
.btn.small { padding: 0.35rem 0.6rem; font-size: 0.85rem; }
.btn.icon-only { padding: 0.4rem; }
.btn[disabled] { opacity: 0.6; cursor: not-allowed; }

.btn-link {
  background: none;
  border: none;
  color: var(--color-primary-dark);
  cursor: pointer;
  padding: 0;
  font-size: 0.85rem;
  text-decoration: underline;
}

/* ---------- Forms ---------- */
.form-group { margin-bottom: 1rem; }
.form-group label {
  display: block;
  margin-bottom: 0.3rem;
  font-weight: 600;
  font-size: 0.9rem;
}
.form-group input[type=text],
.form-group input[type=password],
.form-group input[type=number],
.form-group input[type=date],
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: #fff;
}
.form-group textarea { min-height: 90px; resize: vertical; }
.form-hint { font-size: 0.8rem; color: var(--color-muted); margin-top: 0.25rem; }

.card {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem;
}

.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.auth-screen .card { width: 100%; max-width: 420px; }
.auth-screen h1 { text-align: center; color: var(--color-primary); }

.error-text { color: var(--color-danger); font-size: 0.9rem; margin: 0.5rem 0; }
.success-text { color: var(--color-success); font-size: 0.9rem; margin: 0.5rem 0; }

/* ---------- Entscheidungshilfe ---------- */
.decision-box {
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
  color: #fff;
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}
.decision-box h2 { margin-top: 0; }
.decision-box .filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin: 0.75rem 0 1rem;
}
.decision-box .filters label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(255,255,255,0.15);
  padding: 0.4rem 0.6rem;
  border-radius: 20px;
  font-size: 0.85rem;
}
.decision-box .filters input,
.decision-box .filters select {
  border: none;
  border-radius: 6px;
  padding: 0.2rem 0.4rem;
  background: #fff;
  color: var(--color-text);
}
.decision-box .btn { background: #fff; color: var(--color-primary-dark); }
.decision-box .btn:hover { background: #f0e9e4; }

.suggestion-card {
  margin-top: 1rem;
  background: rgba(255,255,255,0.12);
  border-radius: var(--radius);
  padding: 0.75rem;
  display: flex;
  gap: 0.75rem;
  align-items: center;
}
.suggestion-card img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 8px;
  flex-shrink: 0;
  background: rgba(255,255,255,0.2);
}
.suggestion-card__info { flex: 1; min-width: 0; }
.suggestion-card__info h3 { margin: 0 0 0.25rem; }
.suggestion-card__actions { display: flex; gap: 0.5rem; margin-top: 0.5rem; flex-wrap: wrap; }

/* ---------- Toolbar (Sortierung/Filter der Liste) ---------- */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 1rem;
}
.toolbar select, .toolbar input[type=text] {
  padding: 0.45rem 0.6rem;
  border-radius: 8px;
  border: 1px solid var(--color-border);
  background: #fff;
}
.toolbar .toggle-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.4rem 0.7rem;
  border-radius: 20px;
  border: 1px solid var(--color-border);
  background: #fff;
  cursor: pointer;
  font-size: 0.85rem;
}
.toolbar .toggle-chip.active {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}

/* ---------- Gerichte-Grid ---------- */
.dish-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}

.dish-card {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
  text-decoration: none;
  color: inherit;
}
.dish-card__photo {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: var(--color-border);
  display: block;
}
.dish-card__body { padding: 0.75rem; flex: 1; display: flex; flex-direction: column; gap: 0.35rem; }
.dish-card__title { margin: 0; font-size: 1.05rem; }
.dish-card__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--color-muted);
}
.dish-card__favorite {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: rgba(255,255,255,0.85);
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
}
.dish-card__cook-quick {
  position: absolute;
  bottom: 0.5rem;
  right: 0.5rem;
  background: rgba(0,0,0,0.55);
  color: #fff;
  border: none;
  border-radius: 14px;
  padding: 0.2rem 0.55rem;
  font-size: 0.7rem;
  cursor: pointer;
  opacity: 0.85;
  transition: background-color 0.15s ease, opacity 0.15s ease;
}
.dish-card__cook-quick:hover,
.dish-card__cook-quick:focus-visible {
  opacity: 1;
  background: var(--color-success);
}

.stars { color: #e0a300; letter-spacing: 1px; }
.stars .off { color: var(--color-border); }

.empty-state {
  text-align: center;
  color: var(--color-muted);
  padding: 3rem 1rem;
}

/* ---------- Detail ---------- */
.dish-detail__photo {
  width: 100%;
  max-height: 320px;
  object-fit: cover;
  border-radius: var(--radius);
  background: var(--color-border);
}
.dish-detail__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin: 1rem 0 0.5rem;
}
.tag-list { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.5rem 0; }
.tag {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 20px;
  padding: 0.25rem 0.65rem;
  font-size: 0.85rem;
}
.tag--optional {
  background: transparent;
  border-style: dashed;
  color: var(--color-muted);
}
.tag--optional em { font-style: normal; }
.secondary-action {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px dashed var(--color-border);
  font-size: 0.85rem;
  color: var(--color-muted);
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}
.history-list { list-style: none; padding: 0; margin: 0.5rem 0 0; font-size: 0.9rem; }
.history-list li { padding: 0.25rem 0; border-bottom: 1px solid var(--color-border); }

/* ---------- Ingredient / Photo Picker ---------- */
.chip-input {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0.5rem;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: #fff;
  color: var(--color-text);
}
.chip-input input {
  border: none;
  flex: 1;
  min-width: 120px;
  padding: 0.3rem;
  background: transparent;
  color: var(--color-text);
}
.chip {
  background: var(--color-bg);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: 20px;
  padding: 0.25rem 0.5rem 0.25rem 0.75rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
}
.chip--optional {
  background: transparent;
  border-style: dashed;
}
.chip__remove {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-muted);
  font-size: 0.9rem;
  padding: 0;
}
.chip__optional-toggle {
  background: var(--color-border);
  border: none;
  border-radius: 10px;
  padding: 0.1rem 0.5rem;
  font-size: 0.7rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--color-muted);
  white-space: nowrap;
}
.chip--optional .chip__optional-toggle {
  background: var(--color-primary);
  color: #fff;
}
.autocomplete-list {
  list-style: none;
  margin: 0.25rem 0 0;
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  max-height: 160px;
  overflow-y: auto;
  background: #fff;
  color: var(--color-text);
}
.autocomplete-list li {
  padding: 0.5rem 0.7rem;
  cursor: pointer;
}
.autocomplete-list li:hover,
.autocomplete-list li.active {
  background: var(--color-primary);
  color: #fff;
}

.photo-picker-tabs { display: flex; gap: 0.5rem; margin-bottom: 0.5rem; }
.photo-picker-results {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 0.5rem;
  margin-top: 0.5rem;
}
.photo-picker-results img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 8px;
  cursor: pointer;
  border: 2px solid transparent;
}
.photo-picker-results img.selected { border-color: var(--color-primary); }
.photo-preview {
  width: 100%;
  max-height: 220px;
  object-fit: cover;
  border-radius: var(--radius);
  margin-bottom: 0.5rem;
  background: var(--color-border);
}

/* ---------- Setup Wizard ---------- */
.setup-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.setup-screen .card { max-width: 480px; width: 100%; }
.setup-screen h1 { color: var(--color-primary); margin-top: 0; }
.setup-screen fieldset {
  border: 1px solid var(--color-border);
  border-radius: 8px;
  margin: 0 0 1rem;
  padding: 0.75rem 1rem 0.25rem;
}
.setup-screen legend { font-weight: 600; padding: 0 0.4rem; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--color-text);
  color: #fff;
  padding: 0.6rem 1rem;
  border-radius: 8px;
  font-size: 0.9rem;
  z-index: 50;
  max-width: 90vw;
}
.toast.error { background: var(--color-danger); }
.toast.success { background: var(--color-success); }

/* ---------- Utility ---------- */
.flex-row { display: flex; align-items: center; gap: 0.5rem; }
.mt-1 { margin-top: 1rem; }
.text-muted { color: var(--color-muted); }
.spinner {
  border: 3px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  width: 28px;
  height: 28px;
  animation: spin 0.7s linear infinite;
  margin: 2rem auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (min-width: 640px) {
  .app { padding: 1.5rem; }
  .decision-box .filters label { font-size: 0.9rem; }
}
