/* ===================================================
   PANTRY — Earthy Cozy Design
   Typography: Fraunces (headings) + DM Sans (body)
   Palette: Warm cream, sage green, terracotta
   Vibe: Modern, clean, elegant, organic
   =================================================== */

:root {
  --cream: #FAF6F1;
  --cream-dark: #F0EBE3;
  --warm-white: #FFFDFB;
  --card: rgba(255, 253, 251, 0.85);

  --sage: #6B8F71;
  --sage-dark: #5A7A60;
  --sage-light: #E8F0E9;
  --sage-glow: rgba(107, 143, 113, 0.12);

  --terra: #C4704B;
  --terra-light: #F9EDE7;

  --plum: #8B6E99;
  --plum-light: #F0EBF3;

  --text-primary: #2D2A26;
  --text-secondary: #6B6560;
  --text-tertiary: #A8A29E;
  --text-on-dark: #FFFDFB;

  --border: rgba(45, 42, 38, 0.08);
  --border-subtle: rgba(45, 42, 38, 0.04);
  --separator: rgba(45, 42, 38, 0.06);

  --danger: #C44B4B;
  --danger-light: #FAF0F0;
  --success: #6B8F71;
  --amber: #D4943A;

  --shadow-sm: 0 1px 4px rgba(45, 42, 38, 0.04), 0 0 1px rgba(45, 42, 38, 0.06);
  --shadow-md: 0 6px 20px rgba(45, 42, 38, 0.06), 0 1px 4px rgba(45, 42, 38, 0.04);
  --shadow-lg: 0 16px 48px rgba(45, 42, 38, 0.1), 0 4px 12px rgba(45, 42, 38, 0.04);
  --shadow-xl: 0 24px 64px rgba(45, 42, 38, 0.14);

  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px;
  --space-5: 20px; --space-6: 24px; --space-8: 32px; --space-10: 40px; --space-12: 48px;

  --text-xs: 0.6875rem; --text-sm: 0.8125rem; --text-base: 0.9375rem;
  --text-lg: 1.0625rem; --text-xl: 1.3125rem; --text-2xl: 1.625rem; --text-3xl: 2.125rem;

  --radius-sm: 12px; --radius-md: 16px; --radius-lg: 20px; --radius-xl: 24px; --radius-full: 9999px;

  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --duration-fast: 180ms; --duration-normal: 260ms; --duration-slow: 380ms;
}

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

body {
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--cream);
  color: var(--text-primary);
  min-height: 100dvh;
  padding-bottom: 88px;
  -webkit-font-smoothing: antialiased;
  line-height: 1.55;
  font-size: var(--text-base);
}

/* ===== Header ===== */
header {
  background: var(--sage);
  color: var(--text-on-dark);
  padding: var(--space-5) var(--space-5);
  padding-top: calc(var(--space-5) + env(safe-area-inset-top, 0));
  text-align: left;
  position: sticky;
  top: 0;
  z-index: 40;
}

header h1 {
  font-family: 'Fraunces', Georgia, serif;
  font-size: var(--text-2xl);
  font-weight: 600;
  letter-spacing: -0.02em;
  font-optical-sizing: auto;
}

/* ===== Main ===== */
main {
  max-width: 600px;
  margin: 0 auto;
  padding: var(--space-6) var(--space-5);
}

@media (min-width: 768px) {
  main { max-width: 720px; padding: var(--space-8) var(--space-6); }
}

/* ===== Tab bar ===== */
.tab-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  display: flex;
  background: var(--warm-white);
  border-top: 1px solid var(--separator);
  z-index: 50;
  padding: var(--space-2) var(--space-4);
  padding-bottom: calc(var(--space-2) + env(safe-area-inset-bottom, 0));
  gap: var(--space-2);
}

.tab-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: var(--space-2) 0;
  font-family: 'DM Sans', sans-serif;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-tertiary);
  background: none;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  touch-action: manipulation;
  transition: all var(--duration-fast) var(--ease-out);
  min-height: 52px;
}

.tab-btn.active {
  color: var(--sage);
  background: var(--sage-glow);
}

.tab-btn svg { width: 22px; height: 22px; }
.tab-btn:active svg { transform: scale(0.85); }

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ===== Primary button ===== */
.scan-btn {
  display: block;
  width: 100%;
  padding: var(--space-4) var(--space-5);
  font-family: 'DM Sans', sans-serif;
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text-on-dark);
  background: var(--sage);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  touch-action: manipulation;
  min-height: 52px;
  transition: all var(--duration-fast) var(--ease-out);
}

.scan-btn:active { transform: scale(0.97); opacity: 0.9; }

/* ===== Secondary button ===== */
.btn-secondary {
  display: block;
  width: 100%;
  padding: var(--space-3) var(--space-4);
  font-family: 'DM Sans', sans-serif;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--sage);
  background: var(--sage-light);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  margin-top: var(--space-2);
  min-height: 44px;
  transition: all var(--duration-fast) var(--ease-out);
}
.btn-secondary:active { transform: scale(0.97); }

/* ===== Add button ===== */
.btn-add {
  padding: var(--space-3) var(--space-5);
  font-family: 'DM Sans', sans-serif;
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text-on-dark);
  background: var(--sage);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  flex-shrink: 0;
  min-height: 48px; min-width: 48px;
  transition: all var(--duration-fast);
}
.btn-add:active { transform: scale(0.9); }

/* ===== Danger button ===== */
.btn-danger {
  display: block; width: 100%;
  padding: var(--space-3);
  font-family: 'DM Sans', sans-serif;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--danger);
  background: var(--danger-light);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  min-height: 44px;
  transition: all var(--duration-fast);
}
.btn-danger:active { transform: scale(0.97); }

/* ===== Input row ===== */
.input-row { display: flex; gap: var(--space-2); margin-bottom: var(--space-3); }

.input-row input {
  flex: 1;
  padding: var(--space-3) var(--space-4);
  font-family: 'DM Sans', sans-serif;
  font-size: var(--text-base);
  color: var(--text-primary);
  background: var(--warm-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  min-height: 48px;
  transition: all var(--duration-fast);
}
.input-row input:focus { border-color: var(--sage); box-shadow: 0 0 0 3px var(--sage-glow); }
.input-row input::placeholder { color: var(--text-tertiary); }

/* ===== Scanner ===== */
.scanner {
  position: fixed; inset: 0;
  background: #000;
  z-index: 100;
}
.scanner.hidden { display: none; }
.scanner video {
  width: 100%; height: 100%;
  object-fit: cover;
}

/* Floating UI over camera */
.scan-ui {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  justify-content: space-between;
  z-index: 1;
  pointer-events: none;
}

.scan-top-bar {
  display: flex;
  justify-content: center;
  padding-top: calc(var(--space-6) + env(safe-area-inset-top, 0));
  pointer-events: auto;
}

.scan-bottom-bar {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-bottom: calc(100px + env(safe-area-inset-bottom, 0));
  gap: var(--space-3);
}
.batch-toggle {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  cursor: pointer;
  pointer-events: auto;
}
.batch-toggle input { display: none; }
.batch-slider {
  width: 44px; height: 24px;
  background: rgba(255,255,255,0.2);
  border-radius: 12px;
  position: relative;
  transition: background var(--duration-fast);
}
.batch-slider::after {
  content: '';
  position: absolute;
  width: 20px; height: 20px;
  background: #fff;
  border-radius: 50%;
  top: 2px; left: 2px;
  transition: transform var(--duration-fast);
}
.batch-toggle input:checked + .batch-slider {
  background: var(--sage);
}
.batch-toggle input:checked + .batch-slider::after {
  transform: translateX(20px);
}
.batch-label {
  font-family: 'DM Sans', sans-serif;
  font-size: var(--text-sm);
  font-weight: 600;
  color: rgba(255,255,255,0.85);
}

.scan-hint {
  font-family: 'DM Sans', sans-serif;
  font-size: var(--text-sm);
  color: rgba(255, 255, 255, 0.7);
  text-align: center;
  font-weight: 500;
}

/* Batch scan toast (inside scanner) */
.scan-batch-toast {
  margin-top: var(--space-3);
  padding: var(--space-2) var(--space-4);
  background: rgba(107, 143, 113, 0.9);
  color: #fff;
  border-radius: var(--radius-full);
  font-family: 'DM Sans', sans-serif;
  font-size: var(--text-sm);
  font-weight: 600;
  text-align: center;
  pointer-events: none;
  transition: opacity var(--duration-normal);
}
.scan-batch-toast.hidden { opacity: 0; }

.cancel-btn {
  position: absolute;
  bottom: var(--space-10);
  bottom: calc(var(--space-10) + env(safe-area-inset-bottom, 0));
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  padding: var(--space-3) var(--space-8);
  font-family: 'DM Sans', sans-serif;
  font-size: var(--text-base); font-weight: 600;
  background: rgba(196, 75, 75, 0.85);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  color: #fff;
  border: none; border-radius: var(--radius-full);
  cursor: pointer; min-height: 44px;
  pointer-events: auto;
}
.cancel-btn:active { transform: translateX(-50%) scale(0.92); }

/* ===== Toast ===== */
.toast {
  position: fixed; bottom: 100px; left: 50%;
  transform: translateX(-50%);
  background: var(--text-primary);
  color: var(--cream);
  padding: var(--space-3) var(--space-6);
  border-radius: var(--radius-full);
  font-size: var(--text-sm); font-weight: 500;
  z-index: 200; white-space: nowrap;
  box-shadow: var(--shadow-lg);
  transition: all var(--duration-normal) var(--ease-out);
}
.toast.hidden { opacity: 0; transform: translateX(-50%) translateY(10px); pointer-events: none; }

/* ===== Section headers ===== */
#history { margin-top: var(--space-8); }
#history h2 {
  font-family: 'Fraunces', Georgia, serif;
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  margin-bottom: var(--space-4);
}

/* ===== Pantry item cards ===== */
#itemList { list-style: none; }
#itemList li {
  background: var(--warm-white);
  padding: var(--space-4);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-3);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-subtle);
  transition: transform var(--duration-fast);
}
#itemList li:active { transform: scale(0.99); }

#itemList li .item-top { display: flex; align-items: center; gap: var(--space-3); }
#itemList li .item-info { flex: 1; min-width: 0; }
#itemList li .item-name { font-weight: 600; font-size: var(--text-base); color: var(--text-primary); }
#itemList li .item-meta { font-size: var(--text-xs); color: var(--text-tertiary); margin-top: 3px; }
#itemList li .item-actions { display: flex; gap: 0; flex-shrink: 0; }

#itemList li .item-rescan,
#itemList li .item-delete {
  background: none; border: none; padding: var(--space-2);
  min-width: 44px; min-height: 44px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm); cursor: pointer;
  color: var(--text-tertiary); transition: all var(--duration-fast);
}
#itemList li .item-rescan:active { color: var(--sage); background: var(--sage-light); }
#itemList li .item-delete:active { color: var(--danger); background: var(--danger-light); }

/* ===== Shopping list ===== */
#shopList { list-style: none; margin-top: var(--space-5); }
#shopList li {
  display: flex; align-items: center; gap: var(--space-3);
  background: var(--warm-white);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-3);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-subtle);
  transition: all var(--duration-normal);
}
#shopList li.checked { opacity: 0.35; }
#shopList li.checked .shop-name { text-decoration: line-through; color: var(--text-tertiary); }

#shopList li .shop-check {
  width: 24px; height: 24px;
  border: 2px solid var(--cream-dark);
  border-radius: 50%; cursor: pointer; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: transparent; font-size: 13px; color: #fff;
  min-width: 44px; min-height: 44px;
  transition: all var(--duration-fast);
}
#shopList li .shop-check:active { transform: scale(0.8); }
#shopList li.checked .shop-check { background: var(--sage); border-color: var(--sage); }
#shopList li .shop-name { flex: 1; font-weight: 500; font-size: var(--text-base); }
#shopList li .shop-brand { font-size: var(--text-sm); color: var(--text-tertiary); }
#shopList li .shop-delete {
  background: none; border: none; font-size: var(--text-xl);
  color: var(--text-tertiary); cursor: pointer; padding: var(--space-2);
  min-width: 44px; min-height: 44px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm); transition: all var(--duration-fast);
}
#shopList li .shop-delete:active { color: var(--danger); }

/* ===== Modal (warm sheet) ===== */
.modal {
  position: fixed; inset: 0;
  background: rgba(45, 42, 38, 0.3);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  z-index: 90;
  display: flex; align-items: flex-end; justify-content: center;
  animation: modalFadeIn var(--duration-normal) var(--ease-out);
}
.modal.hidden { display: none; }
@keyframes modalFadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-content {
  background: var(--cream);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: var(--space-8) var(--space-6) var(--space-6);
  width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-xl);
  animation: modalSlideUp var(--duration-slow) var(--ease-out);
}

@media (min-width: 768px) {
  .modal { align-items: center; padding: var(--space-6); }
  .modal-content { border-radius: var(--radius-xl); max-height: 85vh; }
  .modal-content::before { display: none; }
}
@keyframes modalSlideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

/* Pill handle on modals */
.modal-content::before {
  content: '';
  display: block;
  width: 36px; height: 4px;
  background: var(--cream-dark);
  border-radius: 2px;
  margin: 0 auto var(--space-5);
}

.modal-content h3 {
  font-family: 'Fraunces', Georgia, serif;
  font-size: var(--text-xl); font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-4);
  letter-spacing: -0.01em;
}
.modal-content h4 {
  font-family: 'Fraunces', Georgia, serif;
  font-size: var(--text-sm); font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase; letter-spacing: 0.08em;
  margin: var(--space-6) 0 var(--space-3);
}

.modal-content input, .modal-content textarea {
  width: 100%; padding: var(--space-3) var(--space-4);
  font-family: 'DM Sans', sans-serif; font-size: var(--text-base);
  color: var(--text-primary);
  background: var(--warm-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none; margin-bottom: var(--space-2); min-height: 48px;
  transition: all var(--duration-fast);
}
.modal-content textarea { min-height: 100px; resize: vertical; line-height: 1.6; }
.modal-content input:focus, .modal-content textarea:focus { border-color: var(--sage); box-shadow: 0 0 0 3px var(--sage-glow); }
.modal-content input::placeholder, .modal-content textarea::placeholder { color: var(--text-tertiary); }

.form-actions { display: flex; flex-direction: column; gap: var(--space-3); margin-top: var(--space-6); }

/* Picker list */
.modal-content ul { list-style: none; max-height: 320px; overflow-y: auto; margin-bottom: var(--space-3); }
.modal-content ul li {
  padding: var(--space-3) var(--space-4); border-radius: var(--radius-sm);
  cursor: pointer; transition: background var(--duration-fast); margin-bottom: 2px;
}
.modal-content ul li:active { background: var(--sage-light); }
.modal-content ul li .picker-name { font-weight: 600; font-size: var(--text-base); }
.modal-content ul li .picker-meta { font-size: var(--text-xs); color: var(--text-tertiary); margin-top: 2px; }

/* ===== Recipe cards ===== */
#recipeList { margin-top: var(--space-6); }
.recipe-card {
  background: var(--warm-white);
  padding: var(--space-5);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-3);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: all var(--duration-fast);
}
.recipe-card:active { transform: scale(0.98); }
.recipe-card .recipe-title {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 600; font-size: var(--text-lg); letter-spacing: -0.01em;
}
.recipe-card .recipe-meta { font-size: var(--text-xs); color: var(--text-tertiary); margin-top: var(--space-1); }

/* ===== Recipe detail ===== */
#detailIngredients { margin: var(--space-3) 0; }
.ing-row {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--separator);
}
.ing-row:last-child { border-bottom: none; }
.ing-dot { width: 8px; height: 8px; border-radius: var(--radius-full); flex-shrink: 0; }
.ing-dot.in-pantry { background: var(--sage); }
.ing-dot.not-in-pantry { background: var(--terra); }
.ing-label { font-size: var(--text-base); color: var(--text-primary); flex: 1; }

.ing-amount-tag {
  font-size: var(--text-xs); font-weight: 600;
  color: var(--sage-dark);
  background: var(--sage-light);
  padding: 3px 10px; border-radius: var(--radius-full); flex-shrink: 0;
}
.ing-prep-tag { font-size: var(--text-xs); color: var(--text-tertiary); flex-shrink: 0; font-style: italic; }

/* Serving adjuster */
.serving-adjuster {
  display: flex; align-items: center; gap: var(--space-3);
  margin-bottom: var(--space-5); padding: var(--space-3) var(--space-4);
  background: var(--cream-dark); border-radius: var(--radius-md);
}
.serving-label { font-size: var(--text-sm); font-weight: 600; color: var(--text-secondary); }
.serving-btns { display: flex; gap: var(--space-2); margin-left: auto; }
.serving-btn {
  width: 40px; height: 40px; border-radius: var(--radius-sm);
  border: none; background: var(--warm-white);
  font-family: 'DM Sans', sans-serif; font-size: var(--text-sm); font-weight: 600;
  color: var(--text-secondary); cursor: pointer;
  transition: all var(--duration-fast);
  min-width: 44px; min-height: 44px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-sm);
}
.serving-btn.active { background: var(--sage); color: #fff; box-shadow: none; }
.serving-btn:active { transform: scale(0.88); }

/* Calorie display */
.detail-calories {
  margin-bottom: var(--space-4);
  padding: var(--space-4);
  background: var(--warm-white);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.macro-row {
  display: flex;
  justify-content: space-around;
  text-align: center;
  gap: var(--space-2);
}
.macro-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.macro-num {
  font-family: 'Fraunces', serif;
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--text-primary);
}
.macro-label {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}

.mf-copy-btn {
  display: block;
  width: 100%;
  margin-top: var(--space-3);
  padding: var(--space-2) var(--space-4);
  font-family: 'DM Sans', sans-serif;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--terra);
  background: var(--terra-light);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  min-height: 36px;
  transition: all var(--duration-fast);
}
.mf-copy-btn:active { transform: scale(0.97); }

.ai-ing-cal {
  font-size: var(--text-xs);
  color: var(--terra);
  font-weight: 500;
  flex-shrink: 0;
}

/* Star rating */
.star-rating { display: flex; gap: 2px; margin-bottom: var(--space-5); }
.star-btn {
  background: none; border: none; padding: 2px; cursor: pointer; font-size: 0;
  min-width: 30px; min-height: 30px; display: flex; align-items: center; justify-content: center;
  transition: transform var(--duration-fast);
}
.star-btn:active { transform: scale(1.3); }
.star-btn svg { width: 20px; height: 20px; }
.star-btn .star-empty { color: var(--cream-dark); }
.star-btn .star-filled { color: var(--amber); }

.recipe-rating { display: flex; gap: 1px; margin-top: var(--space-1); }
.recipe-rating .mini-star { width: 11px; height: 11px; color: var(--amber); }
.recipe-rating .mini-star.empty { color: var(--cream-dark); }

#detailSteps {
  margin: var(--space-4) 0; white-space: pre-wrap;
  font-size: var(--text-sm); color: var(--text-secondary); line-height: 1.75;
  padding: var(--space-5); background: var(--warm-white);
  border-radius: var(--radius-md); border: 1px solid var(--border-subtle);
}

/* ===== Ingredient chips ===== */
.ing-chip {
  display: inline-flex; align-items: center; gap: var(--space-2);
  background: var(--sage-light); color: var(--sage-dark);
  padding: var(--space-1) var(--space-3); border-radius: var(--radius-full);
  margin: 0 var(--space-1) var(--space-2) 0; font-size: var(--text-sm); font-weight: 500;
}
.ing-chip .ing-remove {
  background: none; border: none; font-size: var(--text-lg);
  color: var(--text-tertiary); cursor: pointer; padding: 0; line-height: 1;
  min-width: 24px; min-height: 24px; display: flex; align-items: center; justify-content: center;
}
.ing-chip .ing-remove:active { color: var(--danger); }

/* ===== Empty state ===== */
.empty-state { text-align: center; padding: var(--space-12) var(--space-5); color: var(--text-tertiary); }
.empty-state p { font-size: var(--text-sm); line-height: 1.7; }

/* ===== Button row ===== */
.btn-row { display: flex; gap: var(--space-3); }

/* ===== AI Button ===== */
.ai-btn {
  background: var(--plum);
}
.ai-btn:active { opacity: 0.9; }

/* ===== AI Questionnaire ===== */
.quiz-subtitle { font-size: var(--text-sm); color: var(--text-tertiary); margin-bottom: var(--space-4); line-height: 1.5; }
.quiz-options { display: flex; flex-direction: column; gap: var(--space-3); margin-bottom: var(--space-4); }
.quiz-opt {
  display: block; width: 100%; padding: var(--space-4) var(--space-5);
  font-family: 'DM Sans', sans-serif; font-size: var(--text-base); font-weight: 500;
  color: var(--text-primary);
  background: var(--warm-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-md); cursor: pointer; text-align: left; min-height: 52px;
  transition: all var(--duration-fast);
}
.quiz-opt:active { transform: scale(0.97); background: var(--sage-light); border-color: var(--sage); }

.quiz-text {
  width: 100%; padding: var(--space-4);
  font-family: 'DM Sans', sans-serif; font-size: var(--text-base);
  color: var(--text-primary); background: var(--warm-white);
  border: 1px solid var(--border); border-radius: var(--radius-md);
  outline: none; resize: vertical; line-height: 1.6;
  min-height: 80px;
  transition: all var(--duration-fast);
}
.quiz-text:focus { border-color: var(--sage); box-shadow: 0 0 0 3px var(--sage-glow); }
.quiz-text::placeholder { color: var(--text-tertiary); }

/* ===== AI Loading ===== */
.ai-loading { display: flex; flex-direction: column; align-items: center; gap: var(--space-5); padding: var(--space-12) 0; }
.ai-loading p { font-size: var(--text-sm); color: var(--text-secondary); text-align: center; font-style: italic; }
.ai-spinner {
  width: 32px; height: 32px; border: 2.5px solid var(--cream-dark);
  border-top-color: var(--plum); border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== AI Suggestion ===== */
.ai-desc { font-size: var(--text-base); color: var(--text-secondary); line-height: 1.65; margin-bottom: var(--space-4); font-style: italic; }
.ai-meta-row { display: flex; gap: var(--space-2); margin-bottom: var(--space-5); flex-wrap: wrap; }
.ai-meta-tag {
  display: inline-block; padding: var(--space-1) var(--space-3);
  background: var(--cream-dark); border-radius: var(--radius-full);
  font-size: var(--text-xs); font-weight: 600; color: var(--text-secondary);
}

.ai-ing-row { display: flex; gap: var(--space-3); padding: var(--space-3) 0; border-bottom: 1px solid var(--separator); }
.ai-ing-row:last-child { border-bottom: none; }
.ai-ing-amount { font-weight: 600; font-size: var(--text-sm); color: var(--sage-dark); min-width: 70px; flex-shrink: 0; }
.ai-ing-name { font-size: var(--text-base); color: var(--text-primary); }
.ai-ing-prep { font-size: var(--text-xs); color: var(--text-tertiary); margin-left: auto; flex-shrink: 0; font-style: italic; }

.ai-steps { padding-left: var(--space-5); margin-bottom: var(--space-2); }
.ai-steps li { font-size: var(--text-base); line-height: 1.75; color: var(--text-secondary); padding: var(--space-2) 0; }

/* ===== Nosrat Cards ===== */
.nosrat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); margin: var(--space-5) 0; }
.nosrat-card { padding: var(--space-4); border-radius: var(--radius-md); border: 1px solid; }
.nosrat-card .nosrat-icon {
  width: 28px; height: 28px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Fraunces', serif; font-weight: 700; font-size: var(--text-xs);
  margin-bottom: var(--space-2);
}
.nosrat-card .nosrat-label { font-family: 'Fraunces', serif; font-weight: 700; font-size: var(--text-sm); margin-bottom: var(--space-1); }
.nosrat-card p { font-size: 11px; line-height: 1.5; }

.nosrat-salt { background: #FDF8EC; border-color: #EDD9A3; }
.nosrat-salt .nosrat-icon { background: #D4A636; color: #fff; }
.nosrat-salt .nosrat-label { color: #8B6D1F; }
.nosrat-salt p { color: #8B6D1F; }

.nosrat-fat { background: #FDF3EC; border-color: #E8C4A8; }
.nosrat-fat .nosrat-icon { background: var(--terra); color: #fff; }
.nosrat-fat .nosrat-label { color: #8B4D30; }
.nosrat-fat p { color: #8B4D30; }

.nosrat-acid { background: var(--sage-light); border-color: #B8D4BB; }
.nosrat-acid .nosrat-icon { background: var(--sage); color: #fff; }
.nosrat-acid .nosrat-label { color: var(--sage-dark); }
.nosrat-acid p { color: var(--sage-dark); }

.nosrat-heat { background: #FAF0F0; border-color: #E0B5B5; }
.nosrat-heat .nosrat-icon { background: var(--danger); color: #fff; }
.nosrat-heat .nosrat-label { color: #8B3535; }
.nosrat-heat p { color: #8B3535; }

/* ===== Cooking Mode ===== */
.cooking-mode { position: fixed; inset: 0; z-index: 110; background: var(--cream); display: flex; flex-direction: column; }
.cooking-mode.hidden { display: none; }

.cook-phase { display: flex; flex-direction: column; height: 100%; }
.cook-phase.hidden { display: none; }

.cook-header {
  background: var(--sage);
  color: var(--text-on-dark);
  padding: var(--space-5) var(--space-6);
  padding-top: calc(var(--space-5) + env(safe-area-inset-top, 0));
  position: relative; text-align: left;
}
.cook-header h2 { font-family: 'Fraunces', serif; font-size: var(--text-xl); font-weight: 600; letter-spacing: -0.01em; }
.cook-phase-label { font-size: var(--text-sm); opacity: 0.7; margin-top: var(--space-1); }

.cook-exit {
  position: absolute; top: var(--space-4); right: var(--space-4);
  top: calc(var(--space-4) + env(safe-area-inset-top, 0));
  background: rgba(255,255,255,0.15);
  border: none; color: #fff; width: 36px; height: 36px;
  border-radius: var(--radius-full); font-size: var(--text-xl); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  min-width: 44px; min-height: 44px;
}

.cook-body { flex: 1; overflow-y: auto; padding: var(--space-6) var(--space-5); max-width: 600px; margin: 0 auto; width: 100%; }
.cook-instruction { font-size: var(--text-sm); color: var(--text-tertiary); text-align: center; margin-bottom: var(--space-6); font-style: italic; }

/* Prep list */
.cook-prep-list { list-style: none; }
.cook-prep-list li {
  display: flex; align-items: flex-start; gap: var(--space-3);
  padding: var(--space-4);
  background: var(--warm-white);
  border-radius: var(--radius-md); margin-bottom: var(--space-3);
  border: 1px solid var(--border-subtle);
  cursor: pointer; transition: opacity var(--duration-normal);
}
.cook-prep-list li.prepped { opacity: 0.3; }
.cook-prep-list li .prep-check {
  width: 24px; height: 24px; border: 2px solid var(--cream-dark);
  border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; color: #fff;
  min-width: 44px; min-height: 44px;
  transition: all var(--duration-fast);
}
.cook-prep-list li.prepped .prep-check { background: var(--sage); border-color: var(--sage); }
.cook-prep-list li .prep-info { flex: 1; }
.cook-prep-list li .prep-name { font-weight: 600; font-size: var(--text-base); }
.cook-prep-list li .prep-detail { font-size: var(--text-xs); color: var(--text-tertiary); margin-top: 3px; font-style: italic; }

/* Cooking step */
.cook-step-body { display: flex; align-items: center; justify-content: center; padding: var(--space-10) var(--space-6); touch-action: pan-y; }
.cook-step-text {
  font-family: 'DM Sans', sans-serif; font-size: var(--text-lg); font-weight: 400;
  line-height: 1.75; color: var(--text-primary); text-align: left; max-width: 400px;
  transition: all var(--duration-normal);
}

.cook-footer {
  padding: var(--space-5);
  padding-bottom: calc(var(--space-5) + env(safe-area-inset-bottom, 0));
  max-width: 600px; margin: 0 auto; width: 100%;
}

.cook-nav { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); }
.cook-nav-btn {
  background: var(--warm-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  width: 56px; height: 56px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--text-secondary); flex-shrink: 0;
  box-shadow: var(--shadow-sm);
  transition: all var(--duration-fast);
}
.cook-nav-btn:active { transform: scale(0.88); }
.cook-nav-btn:disabled { opacity: 0.2; }

.cook-dots { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.cook-dot {
  width: 6px; height: 6px; border-radius: var(--radius-full);
  background: var(--cream-dark); transition: all var(--duration-fast);
}
.cook-dot.active { background: var(--sage); width: 22px; }

/* ===== Pantry item detail modal ===== */
.id-stats {
  display: flex;
  gap: var(--space-3);
  margin-bottom: var(--space-5);
}
.id-stat-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-4);
  background: var(--cream-dark);
  border-radius: var(--radius-md);
}
.id-stat-num {
  font-family: 'Fraunces', serif;
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--text-primary);
}
.id-stat-label {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}

.id-qty-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.id-qty-btn {
  width: 36px; height: 36px;
  border-radius: var(--radius-full);
  border: 1.5px solid var(--border);
  background: var(--warm-white);
  font-family: 'DM Sans', sans-serif;
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  transition: all var(--duration-fast);
}
.id-qty-btn:active { transform: scale(0.88); background: var(--sage-light); }

.id-stock-row {
  display: flex;
  gap: var(--space-2);
  margin-bottom: var(--space-5);
}
.id-stock-btn {
  flex: 1;
  padding: var(--space-3);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--warm-white);
  font-family: 'DM Sans', sans-serif;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  min-height: 44px;
  transition: all var(--duration-fast);
}
.id-stock-btn:active { transform: scale(0.95); }
.id-stock-lots.active { background: var(--sage-light); border-color: var(--sage); color: var(--sage-dark); }
.id-stock-med.active { background: #FFF8E1; border-color: #F9A825; color: #F57F17; }
.id-stock-low.active { background: #FFF3E0; border-color: #E65100; color: #E65100; }

.id-meta {
  margin-bottom: var(--space-4);
}
.id-meta-row {
  display: flex;
  justify-content: space-between;
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--separator);
}
.id-meta-row:last-child { border-bottom: none; }
.id-meta-label {
  font-size: var(--text-sm);
  color: var(--text-tertiary);
}
.id-meta-value {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-primary);
}

/* ===== Quantity & stock badges ===== */
.qty-badge {
  display: inline-block;
  background: var(--sage-light);
  color: var(--sage-dark);
  font-size: var(--text-xs);
  font-weight: 700;
  padding: 1px 7px;
  border-radius: var(--radius-full);
  margin-left: var(--space-2);
  vertical-align: middle;
}
.stock-badge-low {
  display: inline-block;
  background: #FFF3E0;
  color: #E65100;
  font-size: var(--text-xs);
  font-weight: 700;
  padding: 1px 7px;
  border-radius: var(--radius-full);
  margin-left: var(--space-2);
  vertical-align: middle;
}
.stock-badge-med {
  display: inline-block;
  background: #FFF8E1;
  color: #F9A825;
  font-size: var(--text-xs);
  font-weight: 700;
  padding: 1px 7px;
  border-radius: var(--radius-full);
  margin-left: var(--space-2);
  vertical-align: middle;
}

#itemList li.stock-low {
  border-left: 3px solid #E65100;
}

/* ===== Stock level buttons (depleted checklist) ===== */
.stock-check-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4) !important;
  background: var(--warm-white) !important;
  border-radius: var(--radius-md) !important;
  margin-bottom: var(--space-3) !important;
  border: 1px solid var(--border-subtle) !important;
  flex-wrap: wrap;
}
.stock-check-item .prep-info { flex: 1; min-width: 120px; }

.stock-btns {
  display: flex;
  gap: var(--space-1);
}
.stock-opt {
  padding: var(--space-2) var(--space-3);
  font-family: 'DM Sans', sans-serif;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-tertiary);
  background: var(--cream-dark);
  border: none;
  border-radius: var(--radius-full);
  cursor: pointer;
  min-height: 36px;
  min-width: 44px;
  transition: all var(--duration-fast);
}
.stock-opt:active { transform: scale(0.92); }
.stock-opt.active { background: var(--sage); color: #fff; }
.stock-opt-low.active { background: #E65100; color: #fff; }
.stock-opt-remove.active { background: var(--danger); color: #fff; }

/* ===== Pantry section headers ===== */
.pantry-section-header {
  font-family: 'Fraunces', Georgia, serif !important;
  font-size: var(--text-sm) !important;
  font-weight: 600 !important;
  color: var(--sage) !important;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: var(--space-5) 0 var(--space-2) 0 !important;
  margin: 0 !important;
  background: none !important;
  border: none !important;
  box-shadow: none !important;
}
.pantry-section-header:first-child { padding-top: 0 !important; }

/* ===== Recipe photo ===== */
.recipe-photo-wrap {
  margin: -24px -24px 16px -24px;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  overflow: hidden;
  max-height: 240px;
}
.recipe-photo-wrap.hidden { display: none; }
.recipe-photo {
  width: 100%;
  height: 240px;
  object-fit: cover;
  display: block;
}
.photo-actions {
  display: flex;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}
.photo-btn {
  flex: 1;
  margin-top: 0 !important;
  font-size: var(--text-xs) !important;
  padding: var(--space-2) var(--space-3) !important;
  min-height: 36px !important;
}

/* Recipe card thumbnail */
.recipe-card-photo {
  width: 100%;
  height: 140px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-3);
}

/* ===== Beta badge ===== */
.beta-badge {
  display: inline-block;
  background: var(--amber);
  color: #fff;
  font-size: 0.6rem;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.05em;
  vertical-align: middle;
  margin-left: 4px;
}

/* ===== Shopping Mode ===== */
.shopping-mode {
  position: fixed; inset: 0; z-index: 110;
  background: var(--cream);
  display: flex; flex-direction: column;
}
.shopping-mode.hidden { display: none; }

.shop-mode-header {
  background: var(--sage);
  color: var(--text-on-dark);
  padding: var(--space-5) var(--space-6);
  padding-top: calc(var(--space-5) + env(safe-area-inset-top, 0));
  position: relative; text-align: left;
}
.shop-mode-header h2 { font-family: 'Fraunces', serif; font-size: var(--text-xl); font-weight: 600; }

.shop-mode-body {
  flex: 1; overflow-y: auto;
  padding: var(--space-4) var(--space-5);
  max-width: 600px; margin: 0 auto; width: 100%;
}

.shop-section-header {
  font-family: 'Fraunces', Georgia, serif;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--sage);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: var(--space-5) 0 var(--space-2) 0;
}
.shop-mode-section:first-child .shop-section-header { padding-top: var(--space-2); }

.shop-mode-item {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-4);
  background: var(--warm-white);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-2);
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: all var(--duration-normal) var(--ease-out);
}
.shop-mode-item.checked {
  opacity: 0.25;
  transform: scale(0.98);
}
.shop-mode-item.checked .shop-mode-name {
  text-decoration: line-through;
  color: var(--text-tertiary);
}

.shop-mode-check {
  width: 24px; height: 24px;
  border: 2px solid var(--cream-dark);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; color: #fff;
  flex-shrink: 0;
  min-width: 44px; min-height: 44px;
  transition: all var(--duration-fast);
}
.shop-mode-item.checked .shop-mode-check {
  background: var(--sage); border-color: var(--sage);
}

.shop-mode-name { font-weight: 500; font-size: var(--text-base); }

.shop-mode-footer {
  padding: var(--space-5);
  padding-bottom: calc(var(--space-5) + env(safe-area-inset-bottom, 0));
  max-width: 600px; margin: 0 auto; width: 100%;
}

/* ===== Receipt scanner items ===== */
.receipt-list { list-style: none; max-height: 400px; overflow-y: auto; }
.receipt-list li {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--separator);
}
.receipt-list li:last-child { border-bottom: none; }

.receipt-check {
  width: 22px; height: 22px;
  border: 2px solid var(--cream-dark);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; color: #fff;
  flex-shrink: 0;
  min-width: 40px; min-height: 40px;
  cursor: pointer;
  transition: all var(--duration-fast);
}
.receipt-check.selected {
  background: var(--sage); border-color: var(--sage);
}

.receipt-item-info { display: flex; flex-direction: column; gap: 2px; }
.receipt-item-name { font-weight: 500; font-size: var(--text-base); }
.receipt-item-meta { font-size: var(--text-xs); color: var(--text-tertiary); font-style: italic; }

/* ===== Install banner ===== */
.install-banner {
  position: fixed;
  bottom: 92px;
  left: var(--space-4); right: var(--space-4);
  background: var(--warm-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  box-shadow: var(--shadow-lg);
  z-index: 60;
  animation: modalFadeIn var(--duration-normal) var(--ease-out);
}
.install-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.install-text strong {
  font-family: 'Fraunces', serif;
  font-size: var(--text-base);
}
.install-text span {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
}
.install-btn {
  padding: var(--space-2) var(--space-4);
  background: var(--sage);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  min-height: 40px;
  transition: all var(--duration-fast);
}
.install-btn:active { transform: scale(0.95); }
.install-dismiss {
  background: none;
  border: none;
  font-size: var(--text-xl);
  color: var(--text-tertiary);
  cursor: pointer;
  padding: var(--space-1);
  min-width: 36px;
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ===== Reduced motion ===== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
