:root {
  --green: #2e7d32;
  --green-light: #4caf50;
  --green-bg: #e8f5e9;
  --red: #d32f2f;
  --orange: #ff9800;
  --gold: #ffc107;
  --gray-100: #f5f5f5;
  --gray-200: #eeeeee;
  --gray-300: #e0e0e0;
  --gray-500: #9e9e9e;
  --gray-700: #616161;
  --gray-900: #212121;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.12);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #fff;
  color: var(--gray-900);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  max-width: 480px;
  margin: 0 auto;
}

/* ─── Top bar ─── */
.topbar {
  position: sticky; top: 0; z-index: 100;
  background: #fff;
  padding: 12px 16px;
  display: flex; align-items: center; gap: 12px;
  border-bottom: 1px solid var(--gray-200);
}
.topbar .back-btn {
  background: none; border: none; font-size: 22px; cursor: pointer;
  color: var(--gray-900); padding: 4px;
}
.topbar h1 { font-size: 17px; font-weight: 600; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .actions { display: flex; gap: 8px; }
.topbar .actions button {
  background: none; border: none; font-size: 22px; cursor: pointer; padding: 4px;
}

/* ─── Search bar ─── */
.search-bar {
  padding: 12px 16px;
  display: flex; gap: 8px; align-items: center;
}
.search-bar input {
  flex: 1; padding: 10px 14px; border-radius: 24px;
  border: 1.5px solid var(--gray-300); font-size: 15px;
  background: var(--gray-100); outline: none;
  transition: border-color 0.2s;
}
.search-bar input:focus { border-color: var(--green); }
.search-bar .filter-btn {
  width: 40px; height: 40px; border-radius: 50%;
  border: 1.5px solid var(--gray-300); background: #fff;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 18px;
}
.search-bar .filter-btn.active { border-color: var(--green); background: var(--green-bg); }

/* ─── Filter panel ─── */
.filter-panel {
  padding: 0 16px 12px;
  display: none;
  flex-direction: column; gap: 12px;
}
.filter-panel.open { display: flex; }
.filter-group label { font-size: 13px; font-weight: 600; color: var(--gray-700); margin-bottom: 6px; display: block; }
.filter-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 6px 14px; border-radius: 20px; font-size: 13px;
  border: 1.5px solid var(--gray-300); background: #fff;
  cursor: pointer; transition: all 0.15s; user-select: none;
}
.chip.selected { background: var(--green); color: #fff; border-color: var(--green); }
.star-filter { display: flex; gap: 4px; }
.star-filter button {
  background: none; border: none; font-size: 24px; cursor: pointer;
  color: var(--gray-300); transition: color 0.15s;
}
.star-filter button.active { color: var(--gold); }
.user-filter select {
  width: 100%; padding: 8px 12px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--gray-300); font-size: 14px;
}

/* ─── Category list (Picnic-style) ─── */
.category-section { padding: 0 16px; }
.category-header {
  font-size: 15px; font-weight: 700; color: var(--gray-900);
  padding: 16px 0 8px;
}
.category-item {
  display: flex; align-items: center; padding: 10px 0;
  border-bottom: 1px solid var(--gray-200); cursor: pointer;
  text-decoration: none; color: inherit;
}
.category-item:last-child { border-bottom: none; }
.category-thumb {
  width: 56px; height: 56px; border-radius: 50%;
  object-fit: cover; margin-right: 14px; flex-shrink: 0;
  background: var(--gray-200);
}
.category-name { flex: 1; font-size: 15px; font-weight: 500; }
.category-arrow { color: var(--gray-500); font-size: 18px; }

/* ─── Recipe cards grid ─── */
.recipe-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px; padding: 12px 16px;
}
.recipe-card {
  border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow); cursor: pointer;
  background: #fff; text-decoration: none; color: inherit;
}
.recipe-card-img {
  width: 100%; aspect-ratio: 4/3; object-fit: cover;
  background: var(--gray-200);
}
.recipe-card-body { padding: 8px 10px; }
.recipe-card-title { font-size: 13px; font-weight: 600; line-height: 1.3; margin-bottom: 4px; }
.recipe-card-meta { font-size: 11px; color: var(--gray-700); display: flex; align-items: center; gap: 6px; }
.recipe-card .fav-badge {
  position: absolute; top: 6px; right: 6px;
  font-size: 20px; cursor: pointer;
}

/* ─── Recipe detail ─── */
.recipe-hero {
  width: 100%; aspect-ratio: 16/10; object-fit: cover;
  background: var(--gray-200);
}
.recipe-header { padding: 16px; }
.recipe-header h2 { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.recipe-header .subtitle { font-size: 14px; color: var(--gray-700); margin-bottom: 12px; }
.recipe-meta-row {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
}
.meta-item {
  display: flex; flex-direction: column; align-items: center;
}
.meta-item .meta-icon { font-size: 20px; }
.meta-item .meta-value { font-size: 15px; font-weight: 700; }
.meta-item .meta-label { font-size: 11px; color: var(--gray-700); }

/* Star rating */
.star-rating { display: flex; gap: 2px; }
.star-rating button {
  background: none; border: none; font-size: 24px; cursor: pointer;
  color: var(--gray-300); padding: 0;
}
.star-rating button.filled { color: var(--gold); }

/* Favorite heart */
.heart-btn {
  background: none; border: none; font-size: 26px; cursor: pointer;
  color: var(--gray-300); padding: 4px;
}
.heart-btn.favorited { color: var(--red); }

/* ─── Tabs ─── */
.tab-bar {
  display: flex; border-bottom: 2px solid var(--gray-200);
  padding: 0 16px; gap: 0;
}
.tab-btn {
  flex: 1; padding: 12px 0; font-size: 15px; font-weight: 600;
  background: none; border: none; border-bottom: 3px solid transparent;
  cursor: pointer; color: var(--gray-500); text-align: center;
  transition: all 0.2s;
}
.tab-btn.active { color: var(--green); border-bottom-color: var(--green); }

/* ─── Ingredients tab ─── */
.ingredients-tab { padding: 16px; }
.servings-control {
  display: flex; align-items: center; gap: 12px; margin-bottom: 16px;
}
.servings-control span { font-size: 14px; color: var(--gray-700); }
.servings-control .qty-btn {
  width: 36px; height: 36px; border-radius: 50%;
  border: 2px solid var(--green); background: #fff;
  font-size: 18px; font-weight: 700; color: var(--green);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.servings-control .qty-value {
  font-size: 16px; font-weight: 700; min-width: 24px; text-align: center;
}
.ingredient-list { list-style: none; }
.ingredient-item {
  padding: 10px 0; border-bottom: 1px solid var(--gray-200);
  display: flex; justify-content: space-between;
  font-size: 15px;
}
.ingredient-item:last-child { border-bottom: none; }
.ingredient-name { font-weight: 600; }
.ingredient-amount { color: var(--gray-700); }

/* ─── Nutrition ─── */
.nutrition-bar {
  display: flex; justify-content: space-around;
  padding: 12px 16px; background: var(--gray-100);
  border-radius: var(--radius-sm); margin: 12px 16px;
}
.nutrition-item { text-align: center; }
.nutrition-value { font-size: 16px; font-weight: 700; }
.nutrition-label { font-size: 11px; color: var(--gray-700); }

/* ─── Steps tab (stap-voor-stap) ─── */
.steps-tab { padding: 16px; }
.step-card {
  display: none;
  flex-direction: column;
}
.step-card.active { display: flex; }
.step-number {
  font-size: 13px; font-weight: 700; color: var(--green);
  text-transform: uppercase; margin-bottom: 8px;
}
.step-text { font-size: 16px; line-height: 1.6; }
.step-text .ingredient-highlight { font-weight: 700; }
.step-nav {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px; gap: 12px;
}
.step-nav button {
  padding: 12px 24px; border-radius: 24px; font-size: 15px;
  font-weight: 600; cursor: pointer; border: none;
  transition: all 0.2s;
}
.step-nav .prev-btn { background: var(--gray-200); color: var(--gray-900); }
.step-nav .next-btn { background: var(--green); color: #fff; }
.step-nav .step-counter { font-size: 14px; color: var(--gray-500); }
.timer-btn {
  display: inline-flex; align-items: center; gap: 6px;
  margin-top: 12px; padding: 8px 16px;
  background: var(--orange); color: #fff; border: none;
  border-radius: 20px; font-size: 14px; font-weight: 600;
  cursor: pointer;
}
.timer-btn.running { background: var(--red); }
.timer-display {
  font-size: 32px; font-weight: 700; text-align: center;
  padding: 12px; color: var(--green);
}

/* ─── Add recipe modal ─── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  z-index: 200; display: none; align-items: flex-end; justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: #fff; border-radius: 16px 16px 0 0;
  width: 100%; max-width: 480px; max-height: 90vh;
  overflow-y: auto; padding: 20px;
}
.modal h3 { font-size: 18px; font-weight: 700; margin-bottom: 16px; }
.modal .close-btn {
  position: absolute; top: 16px; right: 16px;
  background: none; border: none; font-size: 24px; cursor: pointer;
}

/* ─── Form elements ─── */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--gray-700); }
.form-group input, .form-group textarea, .form-group select {
  width: 100%; padding: 10px 14px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--gray-300); font-size: 15px;
  font-family: inherit; outline: none;
}
.form-group input:focus, .form-group textarea:focus { border-color: var(--green); }
.form-group textarea { min-height: 100px; resize: vertical; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 12px 24px; border-radius: 24px; font-size: 15px;
  font-weight: 600; cursor: pointer; border: none;
  transition: all 0.2s;
}
.btn-primary { background: var(--green); color: #fff; }
.btn-primary:disabled { background: var(--gray-300); cursor: not-allowed; }
.btn-secondary { background: var(--gray-200); color: var(--gray-900); }
.btn-danger { background: var(--red); color: #fff; }
.btn-full { width: 100%; }

/* ─── Photo upload ─── */
.upload-zone {
  border: 2px dashed var(--gray-300); border-radius: var(--radius);
  padding: 24px; text-align: center; cursor: pointer;
  transition: border-color 0.2s; background: var(--gray-100);
}
.upload-zone.dragover { border-color: var(--green); background: var(--green-bg); }
.upload-zone .upload-icon { font-size: 36px; margin-bottom: 8px; }
.upload-zone p { font-size: 14px; color: var(--gray-700); }
.upload-previews {
  display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px;
}
.upload-preview {
  width: 72px; height: 72px; border-radius: var(--radius-sm);
  object-fit: cover; position: relative;
}
.upload-preview .remove-btn {
  position: absolute; top: -6px; right: -6px;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--red); color: #fff; border: none;
  font-size: 14px; cursor: pointer; display: flex;
  align-items: center; justify-content: center;
}

/* ─── Bottom nav ─── */
.bottom-nav {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px;
  background: #fff; border-top: 1px solid var(--gray-200);
  display: flex; z-index: 100;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.nav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  padding: 8px 0; cursor: pointer; border: none; background: none;
  color: var(--gray-500); font-size: 10px; gap: 2px;
  text-decoration: none;
}
.nav-item.active { color: var(--green); }
.nav-item .nav-icon { font-size: 22px; }

/* ─── Loading & empty ─── */
.loading { text-align: center; padding: 40px; color: var(--gray-500); }
.empty-state { text-align: center; padding: 40px; }
.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state p { color: var(--gray-700); font-size: 15px; }

/* ─── Toast / snackbar ─── */
.toast {
  position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%);
  background: var(--gray-900); color: #fff; padding: 12px 24px;
  border-radius: 24px; font-size: 14px; z-index: 300;
  opacity: 0; transition: opacity 0.3s; pointer-events: none;
}
.toast.show { opacity: 1; }

/* ─── Edit mode ─── */
.editable { position: relative; }
.editable:hover { background: var(--green-bg); border-radius: var(--radius-sm); }
.edit-actions {
  display: flex; gap: 8px; padding: 16px;
  position: sticky; bottom: 60px;
  background: #fff; border-top: 1px solid var(--gray-200);
}

/* ─── Grouping review (bulk upload) ─── */
.grouping-review { padding: 16px; }
.group-card {
  border: 2px solid var(--gray-200); border-radius: var(--radius);
  padding: 12px; margin-bottom: 12px;
}
.group-card h4 { font-size: 15px; font-weight: 600; margin-bottom: 8px; }
.group-thumbs { display: flex; gap: 6px; flex-wrap: wrap; }
.group-thumb {
  width: 60px; height: 60px; border-radius: var(--radius-sm);
  object-fit: cover; border: 2px solid transparent; cursor: pointer;
}
.group-thumb.selected { border-color: var(--green); }

/* ─── Misc ─── */
.hidden { display: none !important; }
.page { padding-bottom: 70px; min-height: 100vh; }

/* ─── Progress bar for extraction ─── */
.progress-bar {
  height: 4px; background: var(--gray-200); border-radius: 2px;
  overflow: hidden; margin: 12px 0;
}
.progress-bar .fill {
  height: 100%; background: var(--green); border-radius: 2px;
  transition: width 0.3s;
}
