* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

:root {
  --cream: #faf6ef;
  --cream-2: #f3ecdf;
  --sage: #8aa978;
  --sage-dark: #6b8a5a;
  --sage-light: #c5d4b8;
  --terracotta: #c97b5b;
  --terracotta-dark: #a85f42;
  --ink: #3b3a36;
  --muted: #8a857a;
  --border: #e8ddc9;
  --danger: #c0524a;
  --warn: #d49858;
  --success: #6b8a5a;
  --white: #fffdf8;
  --shadow: 0 4px 18px rgba(60, 50, 30, 0.08);
}

html, body {
  background: linear-gradient(180deg, #f4ead8 0%, #ede0c8 100%);
  font-family: 'DM Sans', system-ui, sans-serif;
  color: var(--ink);
  min-height: 100vh;
  font-size: 15px;
}

h1, h2, h3, h4 { font-family: 'Playfair Display', serif; font-weight: 600; letter-spacing: -0.01em; }

#root { min-height: 100vh; display: flex; justify-content: center; }

.app {
  width: 100%;
  max-width: 430px;
  background: var(--cream);
  min-height: 100vh;
  position: relative;
  padding-bottom: 92px;
  box-shadow: 0 0 40px rgba(60, 50, 30, 0.08);
  overflow: hidden;
}

.header {
  padding: 22px 20px 14px;
  background: linear-gradient(135deg, #faf6ef 0%, #f1e6d0 100%);
  border-bottom: 1px solid var(--border);
}
.header-row { display: flex; align-items: center; justify-content: space-between; }
.header h1 { font-size: 28px; color: var(--sage-dark); display: flex; align-items: center; gap: 10px; }
.header .sub { color: var(--muted); font-size: 13px; margin-top: 4px; }
.header-btn { font-size: 20px; padding: 8px 10px; }

.view { padding: 18px 18px 16px; animation: fadeIn 0.35s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.btn {
  background: var(--sage);
  color: white;
  border: none;
  padding: 13px 18px;
  border-radius: 14px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
}
.btn:hover { background: var(--sage-dark); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn.terracotta { background: var(--terracotta); }
.btn.terracotta:hover { background: var(--terracotta-dark); }
.btn.outline { background: transparent; color: var(--sage-dark); border: 1.5px solid var(--sage); }
.btn.outline:hover { background: var(--sage-light); }
.btn.ghost { background: transparent; color: var(--muted); padding: 8px 12px; width: auto; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

.iconbtn {
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--muted);
  padding: 6px 8px;
  border-radius: 8px;
  font-size: 15px;
}
.iconbtn:hover { background: var(--cream-2); color: var(--ink); }
.iconbtn.danger:hover { color: var(--danger); background: #fbeae6; }

.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 12px;
}

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.field .hint { text-transform: none; letter-spacing: 0; color: var(--sage-dark); margin-left: 4px; }

.input, .select, .textarea {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  font-family: inherit;
  font-size: 15px;
  color: var(--ink);
  width: 100%;
  outline: none;
  transition: border 0.2s;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--sage); }
.textarea { resize: vertical; min-height: 60px; }

.row { display: flex; gap: 10px; }
.row > * { flex: 1; }

.checkbox-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; cursor: pointer; }
.checkbox-row input { width: 18px; height: 18px; accent-color: var(--sage); }

.hint-box {
  background: var(--cream-2);
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13px;
  color: var(--ink);
  margin-bottom: 12px;
}

.cat {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 16px;
  margin-bottom: 10px;
  overflow: hidden;
}
.cat-header {
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
}
.cat-header:hover { background: var(--cream-2); }
.cat-title { display: flex; align-items: center; gap: 10px; font-weight: 500; }
.cat-emoji { font-size: 20px; }
.cat-count { color: var(--muted); font-size: 13px; }
.cat-chev { color: var(--muted); transition: transform 0.25s; font-size: 20px; }
.cat-chev.open { transform: rotate(90deg); }
.cat-body { border-top: 1px solid var(--border); padding: 6px 0; }

.item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  gap: 4px;
}
.item + .item { border-top: 1px dashed var(--border); }
.item-main { flex: 1; min-width: 0; }
.item-name { font-weight: 500; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.item-meta { color: var(--muted); font-size: 12px; margin-top: 2px; }

.badge-low {
  background: #f5e3cc;
  color: #8a5a2a;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 500;
}
.badge-exp {
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 500;
}
.badge-exp.ok { background: #dfe9d3; color: var(--sage-dark); }
.badge-exp.warn { background: #f5e3cc; color: #8a5a2a; }
.badge-exp.soon { background: #fae2d8; color: var(--terracotta-dark); }
.badge-exp.expired { background: var(--danger); color: white; }

.tabbar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 430px;
  background: var(--white);
  border-top: 1px solid var(--border);
  display: flex;
  padding: 8px 6px max(8px, env(safe-area-inset-bottom));
  z-index: 50;
  box-shadow: 0 -6px 24px rgba(60, 50, 30, 0.06);
}
.tab {
  flex: 1;
  background: transparent;
  border: none;
  padding: 8px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  font-family: inherit;
  font-size: 11px;
  cursor: pointer;
  border-radius: 12px;
  transition: all 0.2s;
}
.tab.active { color: var(--sage-dark); }
.tab.active .tab-icon { background: var(--sage-light); color: var(--sage-dark); }
.tab-icon {
  width: 44px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  font-size: 18px;
  transition: all 0.2s;
}

.mode-tabs {
  display: flex;
  gap: 6px;
  background: var(--cream-2);
  padding: 4px;
  border-radius: 14px;
  margin-bottom: 14px;
}
.mode-tab {
  flex: 1;
  background: transparent;
  border: none;
  padding: 10px 8px;
  border-radius: 10px;
  font-family: inherit;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.2s;
}
.mode-tab.active { background: var(--white); color: var(--sage-dark); box-shadow: var(--shadow); font-weight: 500; }

.scan-zone {
  border: 2px dashed var(--sage-light);
  border-radius: 18px;
  padding: 24px 20px;
  text-align: center;
  background: var(--white);
}
.scan-zone .icon { font-size: 44px; margin-bottom: 8px; }
.scan-zone h3 { margin-bottom: 4px; }
.scan-zone p { color: var(--muted); font-size: 13px; }

.scan-preview {
  background: var(--white);
  border-radius: 14px;
  padding: 12px;
  border: 1px solid var(--border);
  margin-bottom: 12px;
  text-align: center;
}
.scan-preview img {
  display: block;
  max-width: 100%;
  max-height: 220px;
  width: auto;
  height: auto;
  margin: 0 auto;
  border-radius: 10px;
}

.error-box {
  background: #fbeae6;
  color: var(--terracotta-dark);
  padding: 14px;
  border-radius: 12px;
  margin-bottom: 12px;
  font-size: 14px;
  border: 1px solid #f0c4b5;
}

.recipe-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 12px;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}
.recipe-card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(60, 50, 30, 0.1); }
.recipe-card h3 { font-size: 19px; margin-bottom: 6px; color: var(--ink); }
.recipe-card .desc { color: var(--muted); font-size: 13px; margin-bottom: 10px; line-height: 1.45; }
.recipe-meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.chip {
  background: var(--cream-2);
  color: var(--ink);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  line-height: 1.4;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
/* Emoji glyphs (⏱) inside chips ride higher than text on desktop browsers.
   Wrap the emoji in <span class="chip-icon"> in JSX and we'll nudge it down. */
.chip-icon {
  display: inline-flex;
  align-items: center;
  line-height: 1;
  transform: translateY(1px);
}
.chip.green { background: #dfe9d3; color: var(--sage-dark); }
.chip.red { background: #f5d8d0; color: var(--terracotta-dark); }
.chip.warn { background: #f5e3cc; color: #8a5a2a; }

.modal-bg {
  position: fixed;
  inset: 0;
  background: rgba(50, 40, 25, 0.45);
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}
.modal {
  background: var(--cream);
  width: 100%;
  max-width: 430px;
  max-height: 92vh;
  border-radius: 22px 22px 0 0;
  padding: 20px;
  overflow-y: auto;
  animation: slideUp 0.3s ease;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

.modal-handle { width: 40px; height: 4px; background: var(--border); border-radius: 4px; margin: 0 auto 14px; }
.modal h2 { font-size: 24px; margin-bottom: 8px; color: var(--sage-dark); }
.modal h4 { font-size: 14px; text-transform: uppercase; letter-spacing: 0.1em; margin: 18px 0 10px; color: var(--muted); font-family: 'DM Sans', sans-serif; }

.ingred-list { list-style: none; }
.ingred-list li {
  padding: 8px 12px;
  border-radius: 10px;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}
.ingred-list li.have { background: #e6efd9; color: var(--sage-dark); }
.ingred-list li.miss { background: #fae2d8; color: var(--terracotta-dark); }
.ingred-list li .dot { width: 8px; height: 8px; border-radius: 50%; }
.ingred-list li.have .dot { background: var(--sage); }
.ingred-list li.miss .dot { background: var(--terracotta); }

.steps-list { padding-left: 22px; }
.steps-list li { margin-bottom: 8px; line-height: 1.5; font-size: 14px; }

.empty {
  text-align: center;
  padding: 50px 20px;
  color: var(--muted);
}
.empty .e-icon { font-size: 56px; margin-bottom: 12px; }
.empty h3 { color: var(--ink); margin-bottom: 6px; }
.empty p { font-size: 14px; line-height: 1.5; }

.toast {
  position: fixed;
  bottom: 110px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--cream);
  padding: 12px 18px;
  border-radius: 12px;
  font-size: 14px;
  z-index: 200;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
  animation: toastIn 0.25s ease;
  max-width: 380px;
  text-align: center;
}
.toast.error { background: var(--danger); }
.toast.success { background: var(--sage-dark); }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }

.ing-row { display: flex; gap: 8px; margin-bottom: 8px; align-items: center; }
.ing-row .input { flex: 1; }

.reorder-row { transition: opacity 0.12s ease; }
.reorder-row.dragging { opacity: 0.55; }
.reorder-row.dragging .ing-row { background: var(--cream-2); border-radius: 8px; }
.drag-handle {
  flex: 0 0 auto;
  cursor: grab;
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
  padding: 6px 4px;
  user-select: none;
  touch-action: none;
}
.drag-handle:active { cursor: grabbing; }

.stats-bar { display: flex; gap: 8px; margin-bottom: 14px; }
.stat {
  flex: 1;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 8px;
  text-align: center;
}
.stat .n { font-family: 'Playfair Display', serif; font-size: 22px; color: var(--sage-dark); }
.stat .l { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; margin-top: 2px; }

/* ============ Full-bleed live barcode scanner ============ */

.scanner-fullbleed {
  position: relative;
  margin: 0 -18px;
  background: #000;
  overflow: hidden;
  height: calc(100vh - 230px);
  min-height: 460px;
  border-radius: 18px;
  color: var(--cream);
}

.scanner-region {
  position: absolute;
  inset: 0;
  background: #000;
  transition: opacity 0.3s ease;
}
.scanner-region video {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
}
.scanner-region.dimmed { opacity: 0.35; }

.scanner-msg {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 30px;
  color: var(--cream);
  background: rgba(0, 0, 0, 0.55);
}
.scanner-msg p { color: rgba(255,255,255,0.85); margin-top: 8px; font-size: 14px; line-height: 1.5; }

.scan-frame {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 88%;
  max-width: 340px;
  aspect-ratio: 1.8;
  border-radius: 16px;
  box-shadow: 0 0 0 9999px rgba(0,0,0,0.42);
  pointer-events: none;
  overflow: hidden;
}
.scan-frame .corner {
  position: absolute;
  width: 22px;
  height: 22px;
  border: 3px solid var(--sage);
}
.scan-frame .tl { top: 0; left: 0; border-right: none; border-bottom: none; border-top-left-radius: 12px; }
.scan-frame .tr { top: 0; right: 0; border-left: none; border-bottom: none; border-top-right-radius: 12px; }
.scan-frame .bl { bottom: 0; left: 0; border-right: none; border-top: none; border-bottom-left-radius: 12px; }
.scan-frame .br { bottom: 0; right: 0; border-left: none; border-top: none; border-bottom-right-radius: 12px; }

.scan-line {
  position: absolute;
  left: 6%;
  right: 6%;
  height: 2px;
  background: linear-gradient(90deg, transparent, #ff4444 20%, #ff4444 80%, transparent);
  box-shadow: 0 0 10px #ff4444, 0 0 24px rgba(255,68,68,0.6);
  animation: scanLine 1.8s ease-in-out infinite alternate;
}
@keyframes scanLine {
  0% { top: 6%; }
  100% { top: calc(100% - 6%); }
}

.scan-hint {
  position: absolute;
  bottom: 110px;
  left: 0; right: 0;
  text-align: center;
  font-size: 14px;
  color: rgba(255,255,255,0.92);
  text-shadow: 0 1px 6px rgba(0,0,0,0.7);
  letter-spacing: 0.02em;
  pointer-events: none;
}

.scan-toolbar {
  position: absolute;
  left: 0; right: 0; bottom: 14px;
  display: flex;
  justify-content: space-around;
  padding: 0 24px;
  pointer-events: auto;
}
.tb-btn {
  background: rgba(0, 0, 0, 0.55);
  color: var(--cream);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 14px;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 11px;
  font-family: inherit;
  cursor: pointer;
  min-width: 78px;
}
.tb-btn.on { background: var(--sage); color: white; }
.tb-btn.primary { background: rgba(138, 169, 120, 0.85); }
.tb-spacer { display: inline-block; min-width: 78px; }

/* Product card slides up from the bottom inside the scanner area */
.product-card-wrap {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 12px;
  animation: slideUpCard 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
  pointer-events: auto;
}
@keyframes slideUpCard {
  from { transform: translateY(100%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.product-card {
  background: var(--cream);
  color: var(--ink);
  border-radius: 18px;
  padding: 14px;
  box-shadow: 0 -8px 30px rgba(0,0,0,0.35);
}
.pc-row { display: flex; gap: 12px; align-items: center; }
.pc-img {
  width: 64px;
  height: 64px;
  flex-shrink: 0;
  border-radius: 12px;
  overflow: hidden;
  background: var(--cream-2);
  display: flex;
  align-items: center;
  justify-content: center;
}
.pc-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pc-placeholder {
  font-family: 'Playfair Display', serif;
  font-size: 28px;
  color: var(--sage-dark);
}
.pc-meta { flex: 1; min-width: 0; }
.pc-name { font-family: 'Playfair Display', serif; font-size: 18px; color: var(--ink); line-height: 1.2; }
.pc-brand { color: var(--muted); font-size: 13px; margin-top: 2px; }
.pc-source { color: var(--terracotta-dark); font-size: 12px; font-weight: 500; }
.pc-barcode { color: var(--muted); font-size: 12px; font-family: monospace; margin-top: 2px; }
.pc-tags { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }

/* Recent scans strip */
.recent-strip {
  position: absolute;
  left: 0; right: 0;
  bottom: 80px;
  padding: 0 12px;
}
.recent-label {
  font-size: 10px;
  color: rgba(255,255,255,0.7);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-bottom: 6px;
  padding-left: 4px;
  text-shadow: 0 1px 4px rgba(0,0,0,0.6);
}
.recent-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
}
.recent-row::-webkit-scrollbar { display: none; }
.recent-item {
  flex: 0 0 auto;
  width: 64px;
  background: rgba(0,0,0,0.55);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 10px;
  padding: 4px;
  text-align: center;
}
.recent-item img { width: 56px; height: 40px; object-fit: cover; border-radius: 6px; display: block; }
.recent-fallback {
  width: 56px; height: 40px;
  background: var(--cream-2);
  color: var(--sage-dark);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Playfair Display', serif;
  font-size: 18px;
}
.recent-name {
  font-size: 9px;
  color: var(--cream);
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Numeric keypad in manual-entry modal */
.keypad-display {
  font-family: monospace;
  font-size: 24px;
  padding: 14px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 12px;
  text-align: center;
  margin-bottom: 12px;
  letter-spacing: 0.1em;
  color: var(--ink);
  font-weight: 600;
}
.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.keypad-btn {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 0;
  font-size: 22px;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
}
.keypad-btn:active { background: var(--cream-2); }
.keypad-btn.empty { visibility: hidden; }
.keypad-btn.back { color: var(--terracotta-dark); }

/* ============ Recipe import (LLM) ============ */

.import-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.llm-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--cream-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 11px;
  color: var(--ink);
  font-family: inherit;
  cursor: pointer;
}
.llm-pill .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
}
.llm-pill.on .dot { background: var(--sage); box-shadow: 0 0 6px var(--sage); }
.llm-pill.on { color: var(--sage-dark); border-color: var(--sage-light); }
.llm-pill.off .dot { background: var(--muted); }
.llm-pill.off { color: var(--muted); }
.llm-pill.loading .dot {
  background: var(--sage-light);
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { opacity: 0.5; } 50% { opacity: 1; } }

.confidence-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
}
.confidence-badge.high { background: #dfe9d3; color: var(--sage-dark); }
.confidence-badge.partial { background: #f5e3cc; color: #8a5a2a; }
.confidence-badge.low { background: var(--cream-2); color: var(--muted); }

.import-banner {
  background: linear-gradient(135deg, #f4ecdb 0%, #eee0c2 100%);
  border-color: var(--sage-light);
}
.import-banner-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.import-source {
  color: var(--sage-dark);
  font-size: 12px;
  text-decoration: none;
}
.import-source:hover { text-decoration: underline; }

.recipe-links {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}
.recipe-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--sage-light);
  color: var(--sage-dark);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.15s;
}
.recipe-link:hover { background: var(--sage); color: white; }

/* Suppress html5-qrcode's built-in gray-cornered scan box overlay so only
   our custom green-cornered .scan-frame is visible. Decoding still uses
   qrbox internally — this is purely visual. */
#scanner-region #qr-shaded-region { display: none !important; }
#scanner-region #qr-shaded-region * { display: none !important; }

/* ============ Shopping list ============ */

.shopping-item { padding-left: 8px; }
.shopping-item.bought .item-name { text-decoration: line-through; color: var(--muted); }
.shopping-item.bought .item-meta { color: var(--muted); opacity: 0.7; }
.shopping-check input[type="checkbox"] {
  width: 22px;
  height: 22px;
  accent-color: var(--sage);
  cursor: pointer;
}

/* ============ Selectable ingredient list in recipe modals ============ */

.ingred-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 18px;
}
.ingred-header h4 { margin: 0; }
.btn.small { padding: 6px 12px; font-size: 12px; width: auto; }

/* Auth screen: "or" rule between password form and OAuth buttons. */
.auth-divider {
  display: flex; align-items: center; gap: 10px;
  margin: 14px 0 12px; color: var(--muted); font-size: 12px;
  text-transform: uppercase; letter-spacing: 0.08em;
}
.auth-divider::before, .auth-divider::after {
  content: ""; flex: 1; height: 1px; background: var(--border);
}
.btn.auth-google {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  background: var(--white); border-color: var(--border); color: var(--ink);
}
.btn.auth-google:hover { background: var(--cream-2); }

.ingred-list.selectable li.tappable { cursor: pointer; transition: transform 0.1s, box-shadow 0.1s; }
.ingred-list.selectable li.tappable:active { transform: scale(0.98); }
.ingred-list.selectable li.selected {
  outline: 2px solid var(--sage);
  outline-offset: -2px;
  box-shadow: 0 2px 8px rgba(138, 169, 120, 0.25);
}
.ingred-list li .ing-mark {
  margin-left: auto;
  font-size: 14px;
  min-width: 16px;
}

/* Top-aligned modal variant — used for modals with text inputs so the
   on-screen keyboard doesn't cover the form on mobile. */
.modal-bg.modal-top { align-items: flex-start; }
.modal.modal-top {
  border-radius: 0 0 22px 22px;
  animation: slideDown 0.28s ease;
  margin-top: env(safe-area-inset-top);
}
@keyframes slideDown {
  from { transform: translateY(-100%); }
  to { transform: translateY(0); }
}

/* Interactive stat tiles in stats-bar (Inventory page filters) */
.stats-bar > .stat {
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.stats-bar > .stat:hover { background: var(--cream-2); }
.stats-bar > .stat:active { transform: scale(0.97); }
.stats-bar > .stat.active {
  background: var(--sage-light);
  border-color: var(--sage);
}
.stats-bar > .stat.active .n,
.stats-bar > .stat.active .l { color: var(--sage-dark); }

.filter-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--sage-light);
  color: var(--sage-dark);
  padding: 8px 14px;
  border-radius: 12px;
  font-size: 13px;
  margin-bottom: 12px;
}
.filter-banner .filter-clear {
  background: transparent;
  border: none;
  color: var(--sage-dark);
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  padding: 4px 8px;
  border-radius: 8px;
}
.filter-banner .filter-clear:hover { background: rgba(255,255,255,0.4); }

/* Title row in a recipe modal — keeps title and edit pencil on one line */
.modal-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}
.modal-title-row h2 { margin: 0; flex: 1; min-width: 0; }

.modal-edit {
  background: var(--cream-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: var(--sage-dark);
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, transform 0.1s;
}
.modal-edit:hover { background: var(--sage-light); }
.modal-edit:active { transform: scale(0.95); }

/* iOS Safari gives <input type="date"> its own intrinsic width, ignoring
   the .input width: 100% rule and overflowing narrow containers. Force it
   to behave like other inputs. */
.input[type="date"] {
  -webkit-appearance: none;
  appearance: none;
  min-width: 0;
  max-width: 100%;
}

/* Servings scaler inside recipe modals */
.serving-scaler {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  margin-bottom: 4px;
  padding: 8px 12px;
  background: var(--cream-2);
  border-radius: 12px;
  flex-wrap: wrap;
}
.serving-label { font-size: 12px; color: var(--muted); }
.serving-count {
  font-family: 'Playfair Display', serif;
  font-size: 18px;
  color: var(--sage-dark);
  min-width: 28px;
  text-align: center;
}
.serving-step {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--white);
  border: 1px solid var(--sage-light);
  color: var(--sage-dark);
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  transition: background 0.15s, transform 0.1s;
}
.serving-step:hover { background: var(--sage-light); }
.serving-step:active { transform: scale(0.95); }

/* ---- Cooking mode ---- */

/* "Start cooking" call-to-action inside recipe modals */
.btn.cook-start {
  margin-top: 16px;
  background: var(--terracotta);
  font-size: 16px;
}
.btn.cook-start:hover { background: var(--terracotta-dark); }

/* Floating resume pill (shown above the tab bar when a session is minimized) */
.cooking-resume {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 90;
  max-width: 400px;
  width: calc(100% - 32px);
  background: var(--terracotta);
  color: var(--white);
  border: none;
  border-radius: 999px;
  padding: 13px 18px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(160, 95, 66, 0.35);
  animation: fadeIn 0.3s ease;
}
.cooking-resume:active { transform: translateX(-50%) scale(0.98); }

/* Full-screen overlay */
.cooking {
  position: fixed;
  inset: 0;
  z-index: 150;
  background: rgba(50, 40, 25, 0.5);
  display: flex;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}
.cooking-inner {
  width: 100%;
  max-width: 430px;
  height: 100%;
  background: var(--cream);
  display: flex;
  flex-direction: column;
  animation: slideUp 0.3s ease;
}

.cooking-top {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px 8px;
  border-bottom: 1px solid var(--border);
}
.cooking-close {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: var(--cream-2);
  color: var(--ink);
  font-size: 16px;
  cursor: pointer;
  flex-shrink: 0;
}
.cooking-close:hover { background: var(--border); }
.cooking-top-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  font-weight: 600;
}

/* Recipe switcher tabs (only rendered with 2+ dishes) */
.cooking-switch {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  -webkit-overflow-scrolling: touch;
}
.cooking-tab {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  background: var(--cream-2);
  border: 1.5px solid transparent;
  border-radius: 12px;
  padding: 7px 13px;
  cursor: pointer;
  font-family: inherit;
  color: var(--muted);
  min-width: 96px;
}
.cooking-tab.active {
  background: var(--white);
  border-color: var(--sage);
  color: var(--sage-dark);
  box-shadow: var(--shadow);
}
.cooking-tab-name {
  font-size: 13px;
  font-weight: 600;
  max-width: 130px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cooking-tab-prog { font-size: 11px; opacity: 0.8; }

.cooking-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 18px 24px;
}
.cooking-headline { text-align: center; margin-bottom: 16px; }
.cooking-headline h2 { font-size: 26px; color: var(--sage-dark); margin-bottom: 8px; }

.cooking-progress {
  height: 8px;
  background: var(--cream-2);
  border-radius: 6px;
  overflow: hidden;
  margin-top: 4px;
}
.cooking-progress-fill {
  height: 100%;
  background: var(--sage);
  border-radius: 6px;
  transition: width 0.3s ease;
}
.cooking-progress-label {
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  margin: 6px 0 18px;
}

.cooking-stepnum {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--terracotta);
  font-weight: 700;
  margin-bottom: 10px;
}
.cooking-stepnum span { color: var(--muted); font-weight: 500; }
.cooking-step {
  font-family: 'Playfair Display', serif;
  font-size: 21px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  box-shadow: var(--shadow);
  min-height: 120px;
}
.cooking-step.done { opacity: 0.6; text-decoration: line-through; text-decoration-color: var(--sage-light); }

.cooking-check {
  width: 100%;
  margin-top: 14px;
  padding: 13px;
  border-radius: 12px;
  border: 1.5px solid var(--sage);
  background: transparent;
  color: var(--sage-dark);
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
}
.cooking-check:hover { background: var(--sage-light); }
.cooking-check.checked { background: var(--sage); color: var(--white); border-color: var(--sage); }

.cooking-dots {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin: 20px 0;
}
.cooking-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: none;
  background: var(--border);
  cursor: pointer;
  padding: 0;
  transition: transform 0.1s;
}
.cooking-dot.done { background: var(--sage); }
.cooking-dot.current { transform: scale(1.5); background: var(--terracotta); box-shadow: 0 0 0 3px rgba(201, 123, 91, 0.25); }

.cooking-ing-toggle { width: 100%; margin-top: 4px; }
.cooking-ings { margin-top: 10px; }
.cooking-ings li { background: var(--cream-2); color: var(--ink); }
.cooking-ings li .dot { background: var(--sage); }

.cooking-complete { text-align: center; padding: 24px 10px; }
.cooking-complete-icon { font-size: 52px; margin-bottom: 8px; }
.cooking-complete h3 { color: var(--sage-dark); margin-bottom: 6px; }
.cooking-complete p { color: var(--muted); font-size: 14px; }

.cooking-end {
  display: block;
  margin: 24px auto 0;
  background: none;
  border: none;
  color: var(--danger);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.cooking-nav {
  display: flex;
  gap: 10px;
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  background: var(--cream);
}
.cooking-nav .btn { flex: 1; }
