/* styles.css — Bowl Builder component styles */

/* ============ Layout shell ============ */
body {
  font-family: var(--font-body);
  overflow-x: hidden;
}
h1, h2, h3 { font-family: var(--font-display); }

.bb-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: color-mix(in oklab, var(--color-bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--color-divider);
}
.bb-header__inner {
  max-width: var(--content-wide);
  margin: 0 auto;
  padding: var(--space-3) var(--space-6);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.bb-logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  text-decoration: none;
  color: var(--color-text);
}
.bb-logo__mark {
  height: 32px;
  width: auto;
  display: block;
  flex-shrink: 0;
}
.bb-logo__divider {
  width: 1px;
  height: 22px;
  background: var(--color-border);
  flex-shrink: 0;
}
.bb-logo__text {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--text-lg);
  color: var(--color-primary);
  white-space: nowrap;
}
[data-theme="dark"] .bb-logo__text { color: var(--color-text); }
.bb-theme-toggle {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  color: var(--color-text-muted);
}
.bb-theme-toggle:hover { background: var(--color-surface-offset); color: var(--color-text); }
.bb-theme-toggle svg { width: 20px; height: 20px; }

.bb-footer {
  max-width: var(--content-wide);
  margin: 0 auto;
  padding: var(--space-10) var(--space-6) var(--space-16);
  color: var(--color-text-faint);
  font-size: var(--text-xs);
  text-align: center;
}
.bb-footer a { color: var(--color-text-muted); }

/* ============ Progress bar ============ */
.bb-progress {
  max-width: var(--content-wide);
  margin: 0 auto;
  padding: var(--space-6) var(--space-6) 0;
}
.bb-progress__list {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-2);
  counter-reset: step;
  position: relative;
}
.bb-progress__list::before {
  content: "";
  position: absolute;
  top: 15px;
  left: 5%;
  right: 5%;
  height: 2px;
  background: var(--color-divider);
  z-index: 0;
}
.bb-progress__list li {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  flex: 1;
  position: relative;
  z-index: 1;
}
.bb-progress__num {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  transition: all var(--transition-interactive);
}
.bb-progress__label {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  text-align: center;
  font-weight: 600;
}
.bb-progress__list li.is-active .bb-progress__num {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: var(--color-text-inverse);
}
.bb-progress__list li.is-active .bb-progress__label { color: var(--color-primary); }
.bb-progress__list li.is-complete .bb-progress__num {
  background: var(--color-success);
  border-color: var(--color-success);
  color: #fff;
}
.bb-progress__list li.is-complete .bb-progress__label { color: var(--color-success); }

@media (max-width: 640px) {
  .bb-progress__label { display: none; }
}

/* ============ Steps ============ */
.bb-step {
  display: none;
  padding: var(--space-10) var(--space-6) var(--space-24);
}
.bb-step.is-active {
  display: block;
  animation: bbFadeIn 320ms cubic-bezier(0.16,1,0.3,1);
}
@keyframes bbFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.bb-step__inner {
  max-width: var(--content-default);
  margin: 0 auto;
}
.bb-step__inner--narrow { max-width: var(--content-narrow); }
.bb-step__inner--wide { max-width: var(--content-wide); }

.bb-eyebrow {
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-gold-hover);
  margin-bottom: var(--space-2);
}
.bb-step__title {
  font-size: var(--text-xl);
  font-weight: 800;
  color: var(--color-text);
  margin-bottom: var(--space-3);
}
.bb-step__subtitle {
  color: var(--color-text-muted);
  font-size: var(--text-base);
  max-width: 60ch;
  margin-bottom: var(--space-8);
}
.bb-step__nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: var(--space-10);
  gap: var(--space-4);
  flex-wrap: wrap;
}

/* ============ Buttons ============ */
.bb-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-full);
  font-weight: 700;
  font-size: var(--text-sm);
  white-space: nowrap;
}
.bb-btn svg, .bb-btn i { width: 16px; height: 16px; }
.bb-btn--lg { padding: var(--space-4) var(--space-6); font-size: var(--text-base); }
.bb-btn--primary { background: var(--color-primary); color: var(--color-text-inverse); }
.bb-btn--primary:hover:not(:disabled) { background: var(--color-primary-hover); }
.bb-btn--gold { background: var(--color-gold); color: var(--color-primary-active); }
.bb-btn--gold:hover:not(:disabled) { background: var(--color-gold-hover); }
.bb-btn--ghost { background: transparent; color: var(--color-text-muted); border: 1.5px solid var(--color-border); }
.bb-btn--ghost:hover:not(:disabled) { color: var(--color-text); border-color: var(--color-text-muted); }
.bb-btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* ============ Forms ============ */
.bb-form { display: flex; flex-direction: column; gap: var(--space-5); }
.bb-field { display: flex; flex-direction: column; gap: var(--space-2); }
.bb-field-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); }
@media (max-width: 560px) { .bb-field-row { grid-template-columns: 1fr; } }
.bb-field label { font-weight: 700; font-size: var(--text-sm); color: var(--color-text); }
.bb-optional { font-weight: 500; color: var(--color-text-faint); text-transform: none; letter-spacing: 0; }
.bb-field input, .bb-field select {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  border: 1.5px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: var(--text-base);
}
.bb-field input:focus, .bb-field select:focus { border-color: var(--color-primary); }
.bb-field__hint { font-size: var(--text-xs); color: var(--color-text-faint); }
.bb-field--checkbox { flex-direction: row; }
.bb-checkbox {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  font-weight: 500 !important;
  font-size: var(--text-sm);
  color: var(--color-text);
  cursor: pointer;
}
.bb-checkbox input[type="checkbox"] {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  margin-top: 2px;
  accent-color: var(--color-primary);
  cursor: pointer;
}
.bb-inline-form { display: flex; gap: var(--space-3); flex-wrap: wrap; }
.bb-inline-form input { flex: 1; min-width: 220px; padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); border: 1.5px solid var(--color-border); background: var(--color-surface); font-size: var(--text-base); }

/* ============ Product grid ============ */
.bb-product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}
.bb-product-card {
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  text-align: center;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
}
.bb-product-card:hover { border-color: var(--color-gold); box-shadow: var(--shadow-sm); }
.bb-product-card.is-selected { border-color: var(--color-primary); background: var(--color-primary-highlight); box-shadow: var(--shadow-md); }
.bb-product-card img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: var(--radius-md);
  background: var(--color-surface-offset);
}
.bb-product-card__title { font-weight: 700; font-size: var(--text-sm); }
.bb-product-card__meta { font-size: var(--text-xs); color: var(--color-text-muted); }
.bb-product-card__badge {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--color-primary);
  background: var(--color-primary-highlight);
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
}

/* ============ Builder layout ============ */
.bb-builder {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: var(--space-6);
  align-items: start;
}
.bb-builder__library, .bb-builder__bowl { min-width: 0; } /* grid tracks default to a content-based min-width, which lets a wide table blow out the whole grid; min-width:0 lets the column shrink to fit and rely on the table's own overflow handling instead */
@media (max-width: 900px) {
  .bb-builder { grid-template-columns: 1fr; }
}

.bb-tabs {
  display: flex;
  gap: var(--space-2);
  overflow-x: auto;
  padding-bottom: var(--space-2);
  margin-bottom: var(--space-3);
}
.bb-tab {
  flex-shrink: 0;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-full);
  border: 1.5px solid var(--color-border);
  background: var(--color-surface);
  font-weight: 700;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}
.bb-tab.is-active { background: var(--color-primary); border-color: var(--color-primary); color: var(--color-text-inverse); }

.bb-ingredient-table-wrap {
  max-height: 560px;
  overflow-y: auto;
  overflow-x: auto; /* safety net: never let a wide table blow out the page layout */
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
}
.bb-ingredient-table { font-size: var(--text-sm); width: 100%; }
@media (max-width: 640px) {
  .bb-ingredient-table { table-layout: fixed; }
  .bb-ingredient-table thead th:nth-child(2),
  .bb-ingredient-table td:nth-child(2) { display: none; } /* hide "Per 100g" kcal column to reclaim width */
  .bb-ingredient-table thead th:first-child,
  .bb-ingredient-row td:first-child { width: auto; }
  .bb-ingredient-table thead th:last-child,
  .bb-ingredient-row td:last-child { width: 84px; }
  .bb-ingredient-row td { padding: var(--space-2); }
  .bb-ingredient-row__notes { max-width: none; }
  .bb-add-btn { width: 100%; padding: var(--space-2) var(--space-1); }
}
.bb-ingredient-table thead th {
  position: sticky;
  top: 0;
  background: var(--color-surface-offset);
  text-align: left;
  padding: var(--space-3) var(--space-3);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
  z-index: 1;
}
.bb-ingredient-row {
  border-top: 1px solid var(--color-divider);
}
.bb-ingredient-row.is-dragging { opacity: 0.4; }
.bb-ingredient-row.is-selected { background: var(--color-primary-highlight); }
.bb-ingredient-row td { padding: var(--space-2) var(--space-3); vertical-align: middle; }
.bb-ingredient-row__name { font-weight: 700; }
.bb-ingredient-row__notes { display: block; font-size: var(--text-xs); color: var(--color-text-faint); font-weight: 500; max-width: 26ch; }
.bb-ingredient-row__kcal { color: var(--color-text-muted); white-space: nowrap; }
.bb-add-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-full);
  background: var(--color-primary-highlight);
  color: var(--color-primary);
  font-weight: 700;
  font-size: var(--text-xs);
  white-space: nowrap;
}
.bb-add-btn:hover { background: var(--color-primary); color: var(--color-text-inverse); }
.bb-add-btn svg, .bb-add-btn i { width: 14px; height: 14px; }
.bb-add-btn.is-added { background: var(--color-success-highlight); color: var(--color-success); }
.bb-add-btn.is-added:hover { background: var(--color-error-highlight); color: var(--color-error); }
.bb-drag-handle { color: var(--color-text-faint); margin-right: var(--space-1); cursor: grab; touch-action: none; padding: var(--space-1); }
.bb-drag-handle:active { cursor: grabbing; }
.bb-allergy-flag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: var(--space-2);
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  background: var(--color-error-highlight);
  color: var(--color-error);
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: capitalize;
  vertical-align: middle;
}
.bb-allergy-flag svg, .bb-allergy-flag i { width: 12px; height: 12px; }

/* Ghost element that follows the pointer while dragging */
.bb-drag-ghost {
  position: fixed;
  z-index: 999;
  pointer-events: none;
  background: var(--color-primary);
  color: var(--color-text-inverse);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-full);
  font-weight: 700;
  font-size: var(--text-sm);
  box-shadow: var(--shadow-lg);
  transform: translate(-50%, -50%);
}

/* ============ Bowl card ============ */
.bb-bowl-card {
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-xl);
  padding: var(--space-5);
  position: sticky;
  top: 90px;
  max-height: calc(100vh - 110px);
  overflow-y: auto;
  transition: border-color var(--transition-interactive), background var(--transition-interactive);
}
.bb-bowl-card.is-drag-over { border-color: var(--color-gold); background: var(--color-gold-highlight); }

/* ============ Bowl picker (Step 2) ============ */
.bb-bowl-picker { margin-bottom: var(--space-5); padding-bottom: var(--space-5); border-bottom: 1px solid var(--color-divider); }
.bb-bowl-picker__title { font-weight: 800; font-size: var(--text-base); margin-bottom: var(--space-2); }
.bb-bowl-picker__note {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-bottom: var(--space-3);
}
.bb-bowl-picker__note svg, .bb-bowl-picker__note i { width: 14px; height: 14px; flex-shrink: 0; margin-top: 1px; }
.bb-bowl-picker__sizing { padding: var(--space-3) var(--space-4); font-size: var(--text-xs); margin-bottom: var(--space-3); }
.bb-product-grid.bb-product-grid--compact {
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: var(--space-2);
  max-height: 260px;
  overflow-y: auto;
  padding-right: 2px;
}
.bb-product-grid.bb-product-grid--compact .bb-product-card { padding: var(--space-2); gap: var(--space-1); }
.bb-product-grid.bb-product-grid--compact .bb-product-card__title { font-size: var(--text-xs); line-height: 1.2; }

/* ============ Chosen bowl summary (Step 4) ============ */
.bb-visualize__chosen-bowl {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  background: var(--color-surface-offset);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-4);
}
.bb-visualize__chosen-bowl img { width: 56px; height: 56px; object-fit: cover; border-radius: var(--radius-md); background: var(--color-surface); flex-shrink: 0; }
.bb-visualize__chosen-bowl__info { flex: 1; min-width: 0; }
.bb-visualize__chosen-bowl__label { font-size: var(--text-xs); color: var(--color-text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.bb-visualize__chosen-bowl__title { font-weight: 700; font-size: var(--text-sm); }
.bb-bowl-visual {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--radius-full);
  background: var(--color-surface-offset);
  border: 3px dashed var(--color-border);
  display: grid;
  place-items: center;
  overflow: hidden;
  margin-bottom: var(--space-4);
  transition: all var(--transition-interactive);
}
.bb-bowl-visual.is-drag-over { border-color: var(--color-gold); background: var(--color-gold-highlight); transform: scale(1.02); }
.bb-bowl-visual img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.bb-bowl-visual__empty {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  color: var(--color-text-faint);
  font-weight: 600;
  font-size: var(--text-sm);
  text-align: center;
  padding: var(--space-4);
}
.bb-bowl-visual__empty svg, .bb-bowl-visual__empty i { width: 28px; height: 28px; }
.bb-checklist { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-bottom: var(--space-4); }
.bb-checklist__item {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-full);
  background: var(--color-surface-offset);
  color: var(--color-text-faint);
  font-size: var(--text-xs);
  font-weight: 700;
}
.bb-checklist__item svg, .bb-checklist__item i { width: 13px; height: 13px; }
.bb-checklist__item.is-complete { background: var(--color-success-highlight); color: var(--color-success); }
.bb-bowl-contents { display: flex; flex-direction: column; gap: var(--space-2); margin-bottom: var(--space-4); max-height: 220px; overflow-y: auto; }
.bb-bowl-contents:empty::before { content: "No ingredients yet."; color: var(--color-text-faint); font-size: var(--text-sm); }
.bb-bowl-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--color-surface-offset);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
}
.bb-bowl-item__name { flex: 1; font-weight: 700; }
.bb-bowl-item__remove { color: var(--color-text-faint); width: 24px; height: 24px; display: grid; place-items: center; border-radius: var(--radius-full); }
.bb-bowl-item__remove:hover { color: var(--color-error); background: var(--color-error-highlight); }
.bb-bowl-item__remove svg, .bb-bowl-item__remove i { width: 14px; height: 14px; }
.bb-bowl-summary {
  display: flex;
  justify-content: space-between;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-4);
  font-weight: 600;
}
.bb-bowl-summary strong { color: var(--color-text); font-size: var(--text-base); }
#gradeBtn { width: 100%; }

/* ============ Grade card ============ */
.bb-grade-card {
  display: flex;
  align-items: center;
  gap: var(--space-6);
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  margin-bottom: var(--space-6);
  flex-wrap: wrap;
}
.bb-grade-badge {
  width: 88px;
  height: 88px;
  border-radius: var(--radius-full);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  background: var(--color-surface-offset);
  border: 4px solid var(--color-border);
}
.bb-grade-badge__letter { font-family: var(--font-display); font-size: 2rem; font-weight: 800; letter-spacing: -0.02em; white-space: nowrap; }
.bb-grade-badge.grade-A, .bb-grade-badge.grade-B { border-color: var(--color-success); background: var(--color-success-highlight); }
.bb-grade-badge.grade-A .bb-grade-badge__letter, .bb-grade-badge.grade-B .bb-grade-badge__letter { color: var(--color-success); }
.bb-grade-badge.grade-C { border-color: var(--color-warning); background: var(--color-warning-highlight); }
.bb-grade-badge.grade-C .bb-grade-badge__letter { color: var(--color-warning); }
.bb-grade-badge.grade-D { border-color: var(--color-error); background: var(--color-error-highlight); }
.bb-grade-badge.grade-D .bb-grade-badge__letter { color: var(--color-error); }
.bb-grade-summary__status { font-size: var(--text-lg); font-weight: 800; margin-bottom: var(--space-1); }
.bb-grade-summary__score { color: var(--color-text-muted); font-size: var(--text-sm); }

.bb-nutrient-list { display: flex; flex-direction: column; gap: var(--space-3); margin-bottom: var(--space-6); }
.bb-nutrient-row {
  display: grid;
  grid-template-columns: 172px 1fr auto;
  align-items: center;
  gap: var(--space-3);
  font-size: var(--text-sm);
}
@media (max-width: 560px) { .bb-nutrient-row { grid-template-columns: 112px 1fr auto; font-size: var(--text-xs); } }
.bb-nutrient-row__label { font-weight: 700; line-height: 1.2; }
.bb-nutrient-bar { height: 8px; border-radius: var(--radius-full); background: var(--color-surface-offset); overflow: hidden; min-width: 60px; }
.bb-nutrient-bar__fill { height: 100%; border-radius: var(--radius-full); transition: width 400ms cubic-bezier(0.16,1,0.3,1); }
.bb-nutrient-bar__fill.status-ok, .bb-nutrient-bar__fill.status-low-ok { background: var(--color-success); }
.bb-nutrient-bar__fill.status-low { background: var(--color-warning); }
.bb-nutrient-bar__fill.status-high { background: var(--color-error); }
.bb-nutrient-row__pct { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; min-width: 3.5ch; }
.bb-nutrient-row__pct.status-ok, .bb-nutrient-row__pct.status-low-ok { color: var(--color-success); }
.bb-nutrient-row__pct.status-low { color: var(--color-warning-hover); }
.bb-nutrient-row__pct.status-high { color: var(--color-error); }

.bb-recommend-card[hidden], .bb-callout[hidden], .bb-portions-summary[hidden] { display: none !important; }
.bb-recommend-card {
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
  background: var(--color-gold-highlight);
  border: 1px solid var(--color-gold);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  margin-bottom: var(--space-6);
  flex-wrap: wrap;
}
.bb-recommend-card__icon { color: var(--color-gold-hover); flex-shrink: 0; }
.bb-recommend-card__icon svg, .bb-recommend-card__icon i { width: 24px; height: 24px; }
.bb-recommend-card__body { flex: 1; min-width: 220px; }
.bb-recommend-card__title { font-weight: 800; margin-bottom: var(--space-3); }
.bb-recommend-list { display: flex; flex-direction: column; gap: var(--space-2); }
.bb-recommend-list__item {
  display: grid;
  grid-template-columns: 1.2fr auto;
  gap: var(--space-1) var(--space-3);
  padding: var(--space-2) var(--space-3);
  background: var(--color-surface);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
}
.bb-recommend-list__name { font-weight: 700; }
.bb-recommend-list__amount { font-weight: 700; text-align: right; color: var(--color-text-muted); }
.bb-recommend-list__reason { grid-column: 1 / -1; font-size: var(--text-xs); color: var(--color-text-faint); }
.bb-recommend-card__actions { display: flex; gap: var(--space-2); align-items: center; width: 100%; justify-content: flex-end; }

/* ============ Portions summary (top of grading step) ============ */
.bb-portions-summary {
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  margin-bottom: var(--space-6);
}
.bb-portions-summary__title { font-size: var(--text-lg); font-weight: 800; margin-bottom: var(--space-1); }
.bb-portions-summary__subtitle { font-size: var(--text-sm); color: var(--color-text-muted); margin-bottom: var(--space-4); }
.bb-portions-list { display: flex; flex-direction: column; gap: var(--space-2); }
.bb-portions-list__item {
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  background: var(--color-surface-offset);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
}
.bb-portions-list__name { font-weight: 700; }
.bb-portions-list__amount { font-weight: 700; color: var(--color-primary); white-space: nowrap; }

.bb-callout {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-6);
  font-size: var(--text-sm);
}
.bb-callout svg, .bb-callout i { width: 20px; height: 20px; flex-shrink: 0; margin-top: 2px; }
.bb-callout--success { background: var(--color-success-highlight); color: var(--color-success-active); }
.bb-callout--warning { background: var(--color-warning-highlight); color: var(--color-warning-active); }
.bb-callout--info { background: var(--color-primary-highlight); color: var(--color-primary-active); margin-bottom: var(--space-4); }
.bb-callout--info p { margin: 0; }

/* ============ Recipe card ============ */
.bb-recipe-card {
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-xl);
  overflow: hidden;
  margin-bottom: var(--space-8);
}
.bb-recipe-card__body { padding: var(--space-6); }
.bb-recipe-card__name { font-size: var(--text-xl); font-weight: 800; margin: var(--space-1) 0 var(--space-2); }
.bb-recipe-card__meta { color: var(--color-text-muted); font-size: var(--text-sm); margin-bottom: var(--space-6); }
.bb-recipe-card__subhead { font-size: var(--text-base); font-weight: 800; margin: var(--space-6) 0 var(--space-3); }
.bb-recipe-ingredients { display: flex; flex-direction: column; gap: var(--space-2); }
.bb-recipe-ingredients li { display: flex; justify-content: space-between; padding: var(--space-2) 0; border-bottom: 1px dashed var(--color-divider); font-size: var(--text-sm); }
.bb-recipe-ingredients li span:last-child { font-weight: 700; color: var(--color-text); }
.bb-recipe-instructions { display: flex; flex-direction: column; gap: var(--space-3); padding-left: var(--space-5); font-size: var(--text-sm); }
.bb-recipe-instructions li { padding-left: var(--space-2); }

.bb-recipe-actions { display: flex; flex-direction: column; gap: var(--space-5); margin-bottom: var(--space-4); }
.bb-share-cta {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  background: var(--color-primary);
  color: var(--color-text-inverse);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  flex-wrap: wrap;
}
.bb-share-cta svg, .bb-share-cta i { width: 28px; height: 28px; flex-shrink: 0; color: var(--color-gold); }
.bb-share-cta__title { font-weight: 800; font-size: var(--text-base); }
.bb-share-cta__body { font-size: var(--text-sm); opacity: 0.9; }
.bb-share-cta > div { flex: 1; min-width: 200px; }

/* ============ Toast ============ */
.bb-toast {
  position: fixed;
  bottom: var(--space-6);
  left: 50%;
  transform: translate(-50%, 150%);
  background: var(--color-primary);
  color: var(--color-text-inverse);
  padding: var(--space-3) var(--space-6);
  border-radius: var(--radius-full);
  font-weight: 700;
  font-size: var(--text-sm);
  box-shadow: var(--shadow-lg);
  z-index: 100;
  transition: transform 320ms cubic-bezier(0.16,1,0.3,1);
}
.bb-toast.is-visible { transform: translate(-50%, 0); }

/* ============ Header gallery link ============ */
.bb-header__gallery-link {
  margin-left: auto;
  margin-right: var(--space-4);
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--color-text-muted);
  text-decoration: none;
  white-space: nowrap;
}
.bb-header__gallery-link:hover { color: var(--color-primary); text-decoration: underline; }
[data-theme="dark"] .bb-header__gallery-link:hover { color: var(--color-text); }

/* ============ Visualize section (Step 4) ============ */
.bb-visualize {
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  margin-bottom: var(--space-6);
}
.bb-visualize__header {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  margin-bottom: var(--space-5);
}
.bb-visualize__header i, .bb-visualize__header svg { width: 26px; height: 26px; color: var(--color-gold); flex-shrink: 0; margin-top: 2px; }
.bb-visualize__title { font-weight: 800; font-size: var(--text-base); margin-bottom: var(--space-1); }
.bb-visualize__body { font-size: var(--text-sm); color: var(--color-text-muted); }

.bb-visualize__tabs {
  display: inline-flex;
  background: var(--color-surface-offset);
  border-radius: var(--radius-full);
  padding: 4px;
  margin-bottom: var(--space-4);
  gap: 4px;
}
.bb-visualize__tab {
  border: none;
  background: transparent;
  padding: var(--space-2) var(--space-5);
  border-radius: var(--radius-full);
  font-weight: 700;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  cursor: pointer;
  transition: var(--transition-interactive);
}
.bb-visualize__tab.is-active { background: var(--color-primary); color: var(--color-text-inverse); }

.bb-product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: var(--space-3);
  margin-bottom: var(--space-5);
  max-height: 360px;
  overflow-y: auto;
  padding: 2px;
}
.bb-product-card {
  border: 2px solid var(--color-divider);
  border-radius: var(--radius-lg);
  background: var(--color-surface-2);
  cursor: pointer;
  padding: var(--space-2);
  text-align: center;
  transition: var(--transition-interactive);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}
.bb-product-card:hover { border-color: var(--color-gold); transform: translateY(-2px); }
.bb-product-card.is-selected { border-color: var(--color-gold); background: var(--color-gold-highlight); box-shadow: var(--shadow-sm); }
.bb-product-card img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  border-radius: var(--radius-sm);
  background: #fff;
}
.bb-product-card__title {
  font-size: var(--text-xs);
  font-weight: 700;
  line-height: 1.2;
  color: var(--color-text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.bb-visualize__actions { display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-2); margin-bottom: var(--space-2); }

.bb-visualize__loading {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-5);
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}
.bb-spinner {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 3px solid var(--color-divider);
  border-top-color: var(--color-gold);
  animation: bbSpin 0.8s linear infinite;
  flex-shrink: 0;
}
@keyframes bbSpin { to { transform: rotate(360deg); } }

.bb-visualize__result { margin-top: var(--space-4); }
.bb-visualize__result img {
  width: 100%;
  max-width: 480px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-divider);
  display: block;
  margin-bottom: var(--space-4);
}
.bb-visualize__result-actions { display: flex; flex-wrap: wrap; gap: var(--space-3); margin-bottom: var(--space-2); }

.bb-visualize__gallery-link { margin-top: var(--space-5); font-size: var(--text-sm); }
.bb-visualize__gallery-link a { color: var(--color-primary); font-weight: 700; text-decoration: none; display: inline-flex; align-items: center; gap: var(--space-1); }
[data-theme="dark"] .bb-visualize__gallery-link a { color: var(--color-gold); }
.bb-visualize__gallery-link a:hover { text-decoration: underline; }
.bb-visualize__gallery-link a i, .bb-visualize__gallery-link a svg { width: 16px; height: 16px; }

/* ============ Page layout: builder + persistent gallery rail ============ */
.bb-page-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: var(--space-8);
  align-items: start;
  max-width: calc(var(--content-wide) + 300px + var(--space-8) * 2);
  margin: 0 auto;
  padding: 0 var(--space-6);
}
.bb-page-layout__main { min-width: 0; }
.bb-page-layout .bb-progress,
.bb-page-layout .bb-step__inner,
.bb-page-layout .bb-footer { padding-left: 0; padding-right: 0; }

.bb-gallery-rail {
  position: sticky;
  top: calc(var(--space-6) + 64px);
  max-height: calc(100vh - var(--space-6) - 64px - var(--space-6));
  display: flex;
  flex-direction: column;
  background: var(--color-surface);
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-top: var(--space-6);
  overflow: hidden;
}
.bb-gallery-rail__header {
  padding: var(--space-4) var(--space-4) var(--space-3);
  border-bottom: 1px solid var(--color-divider);
  flex-shrink: 0;
}
.bb-gallery-rail__title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: 800;
  font-size: var(--text-sm);
  color: var(--color-text);
}
.bb-gallery-rail__title i, .bb-gallery-rail__title svg { width: 16px; height: 16px; color: var(--color-gold); }
.bb-gallery-rail__subtitle {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-top: var(--space-1);
}
.bb-gallery-rail__scroll {
  overflow-y: auto;
  padding: var(--space-4);
  flex: 1;
}
.bb-gallery-rail__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: var(--space-3);
}
.bb-gallery-rail__card {
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--color-divider);
  background: var(--color-surface-offset);
  text-decoration: none;
  color: inherit;
  display: block;
}
.bb-gallery-rail__card img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  display: block;
}
.bb-gallery-rail__card-body { padding: var(--space-2); }
.bb-gallery-rail__card-name {
  font-size: var(--text-xs);
  font-weight: 700;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.bb-gallery-rail__card-meta {
  font-size: 0.7rem;
  color: var(--color-text-faint);
  margin-top: 2px;
}
.bb-gallery-rail__empty {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  text-align: center;
  padding: var(--space-6) var(--space-2);
}
.bb-gallery-rail__viewall {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  padding: var(--space-3);
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--color-primary);
  text-decoration: none;
  border-top: 1px solid var(--color-divider);
  flex-shrink: 0;
}
[data-theme="dark"] .bb-gallery-rail__viewall { color: var(--color-gold); }
.bb-gallery-rail__viewall:hover { background: var(--color-surface-offset); }
.bb-gallery-rail__viewall i, .bb-gallery-rail__viewall svg { width: 14px; height: 14px; }

/* Rail widens on very large screens: grid naturally flows 2 images wide there */
@media (min-width: 1700px) {
  .bb-page-layout { grid-template-columns: minmax(0, 1fr) 380px; }
}

/* Not enough room for a 3rd column below this width — gallery moves under the builder */
@media (max-width: 1180px) {
  .bb-page-layout {
    grid-template-columns: 1fr;
    max-width: var(--content-wide);
  }
  .bb-gallery-rail {
    position: static;
    max-height: none;
    margin-top: var(--space-10);
  }
  .bb-gallery-rail__scroll { max-height: 420px; }
}
@media (max-width: 640px) {
  .bb-gallery-rail__grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }
}
