:root {
  color-scheme: light;
  --bg: #faf7f2;
  --surface: #ffffff;
  --text: #2b2521;
  --text-muted: #71675f;
  --border: #e6ddd1;
  --accent: #b5551f;
  --accent-contrast: #ffffff;
  --badge-bg: #f1e6d6;
  --badge-text: #6b4a1f;
  --radius: 10px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

header.site-header {
  padding: 1rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.site-nav {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.site-logo {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
}

.site-logo:hover {
  color: var(--accent);
  text-decoration: none;
}

.site-nav-links {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  font-size: 0.9rem;
}

.logged-in-indicator {
  color: #2f7d3a;
  font-size: 0.85rem;
  font-weight: 600;
}

main {
  max-width: 960px;
  margin: 0 auto;
  padding: 1rem 1.5rem 3rem;
}

/* Filter bar */

form.filter-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
}

.filter-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  align-items: end;
}

form.filter-bar .field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.85rem;
}

form.filter-bar label {
  color: var(--text-muted);
}

form.filter-bar select {
  padding: 0.4rem 0.5rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: white;
  font-size: 0.95rem;
}

form.filter-bar .checkbox-field {
  flex-direction: row;
  align-items: center;
  gap: 0.4rem;
}

.filter-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.filter-actions button {
  padding: 0.5rem 1.1rem;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: var(--accent-contrast);
  font-size: 0.95rem;
  cursor: pointer;
}

.filter-actions button:hover {
  opacity: 0.9;
}

.filter-actions a.reset-link {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.filter-actions a.reset-link:hover {
  color: var(--accent);
}

/* Recipe grid */

.recipe-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
}

.recipe-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.recipe-card:hover {
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
  transform: translateY(-1px);
  text-decoration: none;
}

.recipe-card h2 {
  margin: 0 0 0.4rem;
  font-size: 1.15rem;
  color: var(--text);
}

.recipe-meta {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

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

/* Badges */

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.badge {
  display: inline-block;
  background: var(--badge-bg);
  color: var(--badge-text);
  font-size: 0.75rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  white-space: nowrap;
}

/* Detail page */

.back-link {
  display: inline-block;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.recipe-detail h1 {
  margin-bottom: 0.25rem;
}

.servings-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin: 1rem 0 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.servings-box label {
  font-weight: 600;
}

.servings-box select {
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  font-size: 0.95rem;
}

.servings-hint {
  color: var(--text-muted);
  font-size: 0.85rem;
  width: 100%;
}

.ingredient-list {
  list-style: none;
  padding: 0;
  margin: 0 0 2rem;
}

.ingredient-list li {
  display: flex;
  gap: 0.6rem;
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--border);
}

.ingredient-list .amount {
  min-width: 3.5rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.ingredient-list .unit {
  min-width: 2.5rem;
  color: var(--text-muted);
}

.instructions {
  white-space: pre-line;
}

.recipe-image {
  max-width: 100%;
  max-height: 360px;
  border-radius: var(--radius);
  display: block;
  margin: 1rem 0;
}

/* Edit form */

.edit-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-width: 640px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.edit-form .field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.edit-form label {
  font-weight: 600;
  font-size: 0.9rem;
}

.edit-form input[type="text"],
.edit-form input[type="number"],
.edit-form input[type="file"],
.edit-form select,
.edit-form textarea {
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.95rem;
  font-family: inherit;
}

.edit-form textarea {
  resize: vertical;
}

.field-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.field-row .field {
  flex: 1 1 160px;
}

.field-hint {
  margin: 0.3rem 0 0;
  font-size: 0.8rem;
  font-weight: normal;
  color: var(--text-muted);
}

.ingredients-section {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.ingredients-section .field input {
  max-width: 160px;
}

.ingredients-section h2 {
  margin: 0;
}

.current-image {
  max-width: 100%;
  max-height: 240px;
  border-radius: var(--radius);
  display: block;
  margin-bottom: 0.4rem;
}

#ingredient-rows {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

.ingredient-row {
  display: flex;
  gap: 0.5rem;
}

.ingredient-row input {
  flex: 1;
  min-width: 0;
}

.ingredient-row .remove-ingredient {
  flex: 0 0 auto;
  background: #b3403a;
}

/* Auf schmalen Bildschirmen werden Name/Menge/Einheit/Entfernen nebeneinander
   zu schmal, Platzhalter und eingetragene Werte werden abgeschnitten - ab
   hier stattdessen alle vier Felder untereinander in voller Breite
   (flex-direction: column, .ingredient-row-Kinder strecken sich dank des
   Flexbox-Standards align-items: stretch automatisch auf 100% Breite). */
@media (max-width: 600px) {
  .ingredient-row {
    flex-direction: column;
  }
}

#add-ingredient {
  align-self: flex-start;
  background: none;
  border: 1px dashed var(--border);
  border-radius: 6px;
  padding: 0.4rem 0.8rem;
  cursor: pointer;
  color: var(--accent);
  font-size: 0.9rem;
}

.form-actions button,
.remove-ingredient {
  padding: 0.5rem 1.1rem;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: var(--accent-contrast);
  cursor: pointer;
  font-size: 0.9rem;
}

.save-banner {
  background: #e4f3e1;
  color: #2f5c2a;
  border-radius: 6px;
  padding: 0.6rem 0.9rem;
  display: inline-block;
}

.error-banner {
  background: #f7dcd8;
  color: #8c2c22;
  border-radius: 6px;
  padding: 0.6rem 0.9rem;
  display: inline-block;
}

.draft-preview-banner {
  background: #fbeecb;
  color: #7a5a12;
  border-radius: 6px;
  padding: 0.6rem 0.9rem;
  margin-bottom: 1rem;
  display: inline-block;
}

.login-form {
  max-width: 320px;
}

/* Admin dashboard */

.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1rem;
}

.admin-header-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.button-link {
  display: inline-block;
  background: var(--accent);
  color: var(--accent-contrast);
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-size: 0.9rem;
}

.button-link:hover {
  opacity: 0.9;
  text-decoration: none;
}

.admin-recipe-list {
  list-style: none;
  padding: 0;
  margin: 0 0 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.admin-recipe-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
}

.admin-recipe-title {
  font-weight: 600;
}

.admin-recipe-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.9rem;
}

.admin-recipe-actions form {
  margin: 0;
}

.admin-recipe-actions button {
  padding: 0.35rem 0.8rem;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: var(--accent-contrast);
  cursor: pointer;
  font-size: 0.85rem;
  font-family: inherit;
}

.admin-recipe-actions button.delete-button {
  background: #b3403a;
}

/* New-recipe source selection */

.source-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
  margin-top: 1.5rem;
}

.source-tile {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.4rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  color: var(--text);
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}

a.source-tile:hover {
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
  transform: translateY(-1px);
  text-decoration: none;
}

.source-tile-title {
  font-weight: 700;
  font-size: 1.05rem;
}

.source-tile-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.source-tile-badge {
  background: var(--badge-bg);
  color: var(--badge-text);
  font-size: 0.7rem;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
}

.source-tile-disabled {
  opacity: 0.6;
}

/* Toasts */

.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: min(360px, calc(100vw - 2rem));
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 0.9rem;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
  font-size: 0.9rem;
  animation: toast-in 0.15s ease;
}

.toast-error {
  background: #fbeceb;
  border-color: #b3403a;
  color: #7a2c26;
}

.toast-success {
  background: #eaf5ec;
  border-color: #2f7d3a;
  color: #1f5326;
}

.toast-message {
  flex: 1;
}

.toast-close {
  flex: 0 0 auto;
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  font-size: 1.1rem;
  line-height: 1;
  color: inherit;
  opacity: 0.6;
  cursor: pointer;
}

.toast-close:hover {
  opacity: 1;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Voice recorder */

.voice-help {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1.1rem;
  margin: 1.25rem auto 0;
  max-width: 480px;
}

.voice-help-title {
  margin: 0 0 0.4rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

.voice-help-list {
  margin: 0;
  padding-left: 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.voice-recorder {
  display: flex;
  justify-content: center;
  margin-top: 2.5rem;
}

.voice-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.1rem;
  text-align: center;
}

/* .voice-state{display:flex} hat dieselbe Spezifität wie die
   UA-Stylesheet-Regel [hidden]{display:none} - ohne diese Regel würde
   unser eigenes display:flex das hidden-Attribut überstimmen (Author-
   vor User-Agent-Styles gewinnt bei Regeln gleicher Spezifität). */
.voice-state[hidden] {
  display: none;
}

.mic-button {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: var(--accent-contrast);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.mic-button:hover {
  transform: scale(1.03);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.mic-button:active {
  transform: scale(0.97);
}

.mic-icon {
  width: 56px;
  height: 56px;
}

.voice-hint {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.mic-recording-visual {
  position: relative;
  width: 140px;
  height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mic-recording-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #c0392b;
  position: relative;
  z-index: 1;
}

.mic-pulse-ring {
  position: absolute;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: rgba(192, 57, 43, 0.35);
  animation: mic-pulse 1.8s ease-out infinite;
}

.mic-pulse-ring-delay {
  animation-delay: 0.9s;
}

@keyframes mic-pulse {
  0% {
    transform: scale(0.4);
    opacity: 0.7;
  }
  100% {
    transform: scale(1.15);
    opacity: 0;
  }
}

.voice-timer {
  font-size: 1.6rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.voice-preview-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: center;
}

#preview-audio {
  width: min(360px, 90vw);
}

.voice-state button {
  padding: 0.65rem 1.4rem;
  border-radius: 6px;
  font-size: 0.95rem;
  cursor: pointer;
  font-family: inherit;
}

.voice-state #submit-button {
  border: none;
  background: var(--accent);
  color: var(--accent-contrast);
}

.voice-state button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.button-secondary {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

@media (max-width: 600px) {
  .mic-button,
  .mic-recording-visual,
  .mic-pulse-ring {
    width: 110px;
    height: 110px;
  }

  .mic-icon {
    width: 44px;
    height: 44px;
  }
}
