:root {
  --primary: #d32f2f;
  --text: #212121;
  --bg: #f9f9f9;
  --card: #ffffff;
  --input: #fafafa;
  --err: #d32f2f;
  --shadow: 0 4px 12px rgba(0,0,0,0.12);
}
[data-theme="dark"] {
  --primary: #ff7961;
  --text: #e0e0e0;
  --bg: #121212;
  --card: #1e1e1e;
  --input: #2a2a2a;
  --err: #ff6b6b;
  --shadow: 0 4px 12px rgba(0,0,0,0.5);
}
* { box-sizing: border-box; margin:0; padding:0; }
body {
  font-family: system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
header {
  background: var(--primary);
  color: white;
  padding: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.btn-round {
  background: rgba(255,255,255,0.25);
  border: none;
  width: 44px; height: 44px;
  border-radius: 50%;
  color: white;
  font-size: 1.3rem;
  cursor: pointer;
  display: grid;
  place-items: center;
}
#category-filters {
  padding: 12px;
  display: flex;
  gap: 10px;
  overflow-x: auto;
  background: var(--card);
}
.category-btn {
  padding: 8px 16px;
  border: none;
  border-radius: 999px;
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
}
.category-btn.active { background: var(--primary); color: white; }
#search-bar { padding: 12px; background: var(--card); }
#search-input {
  width: 100%;
  padding: 12px;
  border: 1px solid #0002;
  border-radius: 12px;
  background: var(--input);
}
#recipes-container { flex: 1; overflow-y: auto; padding: 12px; }
#recipes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.recipe-card {
  background: var(--card);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.2s;
}
.recipe-card:hover { transform: translateY(-4px); }
.recipe-card img { width: 100%; height: 160px; object-fit: cover; }
.recipe-info { padding: 12px; }
.recipe-title { font-size: 1.1rem; margin-bottom: 4px; font-weight: 600; }
.recipe-meta { font-size: 0.85rem; color: #666; }
[data-theme="dark"] .recipe-meta { color: #aaa; }

.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-content {
  background: var(--card);
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  border-radius: 16px;
  padding: 20px;
  overflow-y: auto;
}
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 6px; font-weight: 600; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  padding: 10px;
  border: 1px solid #0002;
  border-radius: 8px;
  background: var(--input);
}
.btn-group { display: flex; gap: 12px; margin-top: 20px; }
.btn { flex: 1; padding: 12px; border: none; border-radius: 8px; font-weight: 600; cursor: pointer; }
.btn-primary { background: var(--primary); color: white; }
.btn-secondary { background: #ddd; color: #333; }

.detail-view {
  display: none;
  flex-direction: column;
  height: 100vh;
  background: var(--bg);
}
.detail-view.active { display: flex; }
.detail-header {
  background: var(--primary);
  color: white;
  padding: 16px;
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.back-btn {
  background: rgba(255,255,255,0.3);
  border: none;
  width: 48px; height: 48px;
  border-radius: 50%;
  color: white;
  font-size: 1.4rem;
  cursor: pointer;
}
.detail-title { flex: 1; font-size: 1.5rem; margin: 0; }
.action-btn {
  background: rgba(0,0,0,0.3);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
}
.detail-content { padding: 20px; overflow-y: auto; }
.section-title { margin: 24px 0 12px; font-size: 1.25rem; }
#detail-images { margin: 16px 0; border-radius: 12px; overflow: hidden; }
.glide__slide img { width: 100%; height: 240px; object-fit: cover; }
.ingredients-list, .steps-list { list-style: none; padding: 0; }
.ingredients-list li, .steps-list li { padding: 10px 0; border-bottom: 1px solid #0001; }
[data-theme="dark"] .ingredients-list li, [data-theme="dark"] .steps-list li { border-color: #fff2; }
#toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--err);
  color: white;
  padding: 12px 24px;
  border-radius: 8px;
  z-index: 2000;
  opacity: 0;
  transition: 0.4s;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.success { background: #4caf50; }
.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 1500;
  display: flex;
  align-items: center;
  justify-content: center;
}
.confirm-modal {
  background: var(--card);
  padding: 24px;
  border-radius: 16px;
  max-width: 340px;
  text-align: center;
}
.confirm-buttons { display: flex; gap: 12px; margin-top: 20px; }
.confirm-buttons button { flex: 1; padding: 12px; border: none; border-radius: 8px; font-weight: 600; cursor: pointer; }
.btn-cancel { background: #ddd; }
.btn-confirm { background: var(--err); color: white; }