/* ============================================================
   NutriGap — Apothecary palette + Punchy motion
   Cream / gold / ink · Georgia serif headings · system sans body
   ============================================================ */

:root {
  /* Palette */
  --cream:        #faf8f4;
  --cream-warm:   #f4ecd6;
  --surface:      #ffffff;
  --ink:          #1a1a1a;
  --ink-soft:     #4a4a4a;
  --ink-mute:     #8a8a8a;
  --gold:         #b8860b;
  --gold-deep:    #8a6309;
  --gold-soft:    #f4ecd6;
  --rule:         #e6e2d8;

  /* Score colours */
  --score-red:    #c25e3d;
  --score-amber:  #d9a521;
  --score-green:  #4a9e5c;

  /* Type stack */
  --serif: 'Georgia', 'Times New Roman', serif;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', system-ui, sans-serif;

  /* Spacing rhythm */
  --r1: 4px;
  --r2: 8px;
  --r3: 16px;
  --r4: 24px;
  --r5: 32px;
  --r6: 48px;
  --r7: 64px;
  --r8: 96px;
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--sans);
  background: var(--cream);
  color: var(--ink);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'kern';
  overflow-x: hidden;
}
button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, h4 { font-family: var(--serif); font-weight: 400; }
[hidden] { display: none !important; }

/* ============================================================
   SCREEN SYSTEM — show/hide via data-active
   ============================================================ */

#app {
  position: relative;
  min-height: 100vh;
}

.screen {
  position: fixed;
  inset: 0;
  background: var(--cream);
  display: none;
  flex-direction: column;
  opacity: 0;
  transition: opacity 0.35s ease;
}
.screen[data-active="true"] {
  display: flex;
  opacity: 1;
}
.screen[data-leaving="true"] { opacity: 0; pointer-events: none; }

/* ============================================================
   LOADER
   ============================================================ */

#screen-loader {
  align-items: center;
  justify-content: center;
}
.loader-stage {
  text-align: center;
  padding: 0 var(--r4);
}
.loader-wordmark {
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(42px, 9vw, 64px);
  font-weight: 400;
  letter-spacing: -1px;
  color: var(--ink);
  opacity: 0; /* animated in by JS */
}
.loader-rule {
  width: 200px;
  height: 1.5px;
  background: var(--gold);
  margin: var(--r3) auto var(--r2);
  transform-origin: left center;
  transform: scaleX(0); /* animated in by JS */
}
.loader-tagline {
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--gold);
  opacity: 0; /* animated in by JS */
}

/* ============================================================
   BRAND BAR — sticky top wordmark on Hook + later screens
   ============================================================ */

.brand-bar {
  position: relative;
  z-index: 2;
  padding: var(--r4) var(--r4) 0;
  display: flex;
  justify-content: center;
}
.brand {
  text-align: center;
}
.brand-wordmark {
  font-family: var(--serif);
  font-style: italic;
  font-size: 22px;
  color: var(--ink);
  letter-spacing: -0.4px;
}
.brand-rule {
  width: 70px;
  height: 1px;
  background: var(--gold);
  margin: 6px auto 4px;
}
.brand-tagline {
  font-size: 9px;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: var(--gold);
}

/* ============================================================
   HOOK SCREEN
   ============================================================ */

#screen-hook {
  align-items: center;
  justify-content: center;
}
.hook-stage {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0 var(--r4);
  text-align: center;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
}
.hook-grain {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.55;
  background-image:
    radial-gradient(rgba(184,134,11,0.04) 1px, transparent 1px),
    radial-gradient(rgba(26,26,26,0.025) 1px, transparent 1px);
  background-size: 7px 7px, 11px 11px;
  background-position: 0 0, 3px 3px;
}
.hook-question {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(32px, 8vw, 56px);
  letter-spacing: -1.2px;
  line-height: 1.1;
  color: var(--ink);
  margin-bottom: var(--r5);
  position: relative;
}
.hook-line {
  display: block;
}
.hook-promise {
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(15px, 3.6vw, 19px);
  color: var(--ink-soft);
  margin-bottom: var(--r6);
  position: relative;
  max-width: 460px;
}
.cta {
  display: inline-block;
  border-radius: 8px;
  padding: 16px 40px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.5px;
  transition: transform 0.18s ease, background 0.2s ease;
  position: relative;
  will-change: transform;
}
.cta-primary {
  background: var(--gold);
  color: var(--surface);
}
.cta-primary:hover {
  background: var(--gold-deep);
}
.cta-primary:active {
  transform: scale(0.97);
}
.cta-ghost {
  background: transparent;
  color: var(--gold);
  font-weight: 500;
  padding: 12px 16px;
  font-size: 14px;
}
.cta-ghost:hover {
  color: var(--gold-deep);
}
.hook-disclaimer {
  font-size: 11px;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: var(--ink-mute);
  margin-top: var(--r4);
  position: relative;
}
#hook-resume {
  margin-top: var(--r3);
  position: relative;
}

/* ============================================================
   GRID SCREEN — food selection
   ============================================================ */

#screen-grid {
  display: none;
  background: var(--cream);
  overflow-y: auto;
  overflow-x: hidden;
}
#screen-grid[data-active="true"] {
  display: block;
}

/* Sticky header */
.grid-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(250, 248, 244, 0.96);
  backdrop-filter: saturate(180%) blur(8px);
  -webkit-backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--rule);
}

.grid-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--r3);
  padding: var(--r3) var(--r4);
  flex-wrap: wrap;
}

.brand-compact .brand-wordmark {
  font-size: 18px;
}

/* Diet toggle */
.diet-toggle {
  display: flex;
  gap: 6px;
  background: var(--cream-warm);
  border-radius: 999px;
  padding: 4px;
}
.diet-pill {
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
  border-radius: 999px;
  letter-spacing: 0.2px;
  transition: background 0.18s ease, color 0.18s ease;
  white-space: nowrap;
}
.diet-pill[aria-pressed="true"] {
  background: var(--ink);
  color: var(--surface);
}
.diet-pill:hover:not([aria-pressed="true"]) {
  color: var(--ink);
}

/* Progress + Continue */
.grid-progress {
  display: flex;
  align-items: center;
  gap: var(--r3);
}
.selected-count {
  font-size: 12px;
  letter-spacing: 0.6px;
  color: var(--ink-mute);
  text-transform: uppercase;
  font-variant-numeric: tabular-nums;
}
.selected-count strong {
  color: var(--ink);
  font-weight: 700;
  font-size: 14px;
}
.cta-continue {
  padding: 10px 20px;
  font-size: 13px;
  font-weight: 600;
  background: var(--gold);
  color: var(--surface);
  border-radius: 999px;
  transition: opacity 0.2s ease, background 0.2s ease, transform 0.18s ease;
}
.cta-continue:hover:not(:disabled) {
  background: var(--gold-deep);
}
.cta-continue:active:not(:disabled) {
  transform: scale(0.97);
}
.cta-continue:disabled {
  background: var(--rule);
  color: var(--ink-mute);
  cursor: not-allowed;
}

/* Category tabs */
.category-tabs {
  display: flex;
  gap: 6px;
  padding: 0 var(--r4) var(--r3);
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.category-tabs::-webkit-scrollbar { display: none; }

.cat-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
  background: transparent;
  color: var(--ink-soft);
  border: 1px solid var(--rule);
  border-radius: 999px;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}
.cat-tab:hover {
  color: var(--ink);
  border-color: var(--ink-soft);
}
.cat-tab[aria-pressed="true"] {
  background: var(--gold);
  color: var(--surface);
  border-color: var(--gold);
}
.cat-tab-badge {
  font-size: 10px;
  font-weight: 700;
  background: var(--ink);
  color: var(--surface);
  border-radius: 999px;
  padding: 1px 6px;
  min-width: 16px;
  text-align: center;
}
.cat-tab[aria-pressed="true"] .cat-tab-badge {
  background: var(--surface);
  color: var(--gold-deep);
}

/* Grid stage */
.grid-stage {
  padding: var(--r4) var(--r4) var(--r8);
  max-width: 1280px;
  margin: 0 auto;
}
.grid-prompt {
  font-family: var(--serif);
  font-style: italic;
  font-size: 16px;
  color: var(--ink-soft);
  margin-bottom: var(--r4);
  text-align: center;
}
.grid-empty {
  text-align: center;
  padding: var(--r6) var(--r3);
  color: var(--ink-mute);
}

/* Food grid */
.food-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px 12px;
}
@media (min-width: 600px) {
  .food-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 24px 16px;
  }
}
@media (min-width: 900px) {
  .food-grid {
    grid-template-columns: repeat(5, 1fr);
  }
}
@media (min-width: 1200px) {
  .food-grid {
    grid-template-columns: repeat(6, 1fr);
  }
}

/* Food card */
.food-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 8px 4px;
  background: transparent;
  border-radius: 12px;
  transition: transform 0.15s ease;
  position: relative;
}
.food-card:active {
  transform: scale(0.96);
}

/* Wrapper around the photo — does NOT clip, so the check badge can overflow */
.food-photo-wrap {
  position: relative;
  width: 80px;
  height: 80px;
  flex-shrink: 0;
  /* No overflow:hidden — the check badge needs to escape this box */
}

.food-photo {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  overflow: hidden;
  background-color: var(--rule);
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}
.food-photo::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  box-shadow: inset 0 0 0 0 transparent;
  pointer-events: none;
  transition: box-shadow 0.2s ease;
}
.food-card[data-selected="true"] .food-photo::after {
  box-shadow: inset 0 0 0 3px var(--gold);
}
.food-card[data-selected="true"] {
  transform: scale(1.03);
}

.food-photo img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 1;
}
.food-letter {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--serif);
  font-style: italic;
  font-size: 34px;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.92);
  z-index: 0;
  text-shadow: 0 1px 2px rgba(0,0,0,0.15);
}

/* Check badge — sits on the photo edge, outside the clip.
   Positioned at the upper-right of the wrapper, slightly outside it. */
.food-check {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 28px;
  height: 28px;
  background: var(--gold);
  border: 2.5px solid var(--cream);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3;
  opacity: 0;
  transform: scale(0.4);
  transform-origin: center;
  transition: opacity 0.18s ease, transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 2px 8px rgba(184, 134, 11, 0.45);
  pointer-events: none;
}
.food-card[data-selected="true"] .food-check {
  opacity: 1;
  transform: scale(1);
}
.food-check svg {
  width: 12px;
  height: 12px;
  stroke: var(--surface);
  stroke-width: 3.5;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.food-name {
  font-family: var(--serif);
  font-style: italic;
  font-size: 13px;
  color: var(--ink);
  text-align: center;
  line-height: 1.3;
  /* Lock to 2 lines max — prevents long names breaking grid */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  transition: color 0.18s ease, font-weight 0.18s ease;
}
.food-card[data-selected="true"] .food-name {
  color: var(--gold-deep);
  font-weight: 600;
  font-style: normal;
}

@media (max-width: 360px) {
  .food-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .food-photo-wrap { width: 96px; height: 96px; }
  .food-photo { width: 96px; height: 96px; }
  .food-letter { font-size: 40px; }
}

@media (max-width: 600px) {
  .grid-header-row {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .grid-header-row .brand-compact {
    text-align: center;
  }
  .diet-toggle {
    align-self: center;
  }
  .grid-progress {
    justify-content: space-between;
  }
}

/* ============================================================
   FREQUENCY SCREEN (Phase 5)
   ============================================================ */

#screen-frequency {
  display: none;
  background: var(--cream);
  overflow-y: auto;
}
#screen-frequency[data-active="true"] {
  display: block;
}
.freq-stage {
  max-width: 760px;
  margin: 0 auto;
  padding: var(--r5) var(--r4) var(--r8);
}
.freq-intro {
  text-align: center;
  margin-bottom: var(--r6);
}
.freq-title {
  font-family: var(--serif);
  font-size: clamp(26px, 6vw, 36px);
  font-weight: 400;
  letter-spacing: -0.5px;
  margin-bottom: var(--r3);
}
.freq-sub {
  color: var(--ink-soft);
  font-size: 15px;
  max-width: 480px;
  margin: 0 auto var(--r4);
}
.cta-quick {
  background: var(--cream-warm);
  color: var(--gold-deep);
  padding: 12px 24px;
  font-size: 14px;
  border-radius: 999px;
  font-weight: 600;
}
.cta-quick:hover {
  background: var(--gold-soft);
}
.cta-block {
  display: block;
  width: 100%;
  margin-top: var(--r5);
}

.freq-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.freq-row {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 12px;
  padding: 14px 16px;
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: 14px;
  align-items: center;
}
.freq-row .freq-photo {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  overflow: hidden;
  position: relative;
  background: var(--rule);
  flex-shrink: 0;
}
.freq-row .freq-photo img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 1;
}
.freq-row .freq-photo .food-letter {
  font-size: 20px;
}
.freq-row .freq-info {
  min-width: 0;
}
.freq-row .freq-name {
  font-family: var(--serif);
  font-style: italic;
  font-size: 15px;
  color: var(--ink);
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.freq-row .freq-cat {
  font-size: 10px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 600;
  margin-top: 2px;
}
.freq-row .freq-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
}
.portion-toggle {
  display: flex;
  background: var(--cream);
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 2px;
  gap: 2px;
}
.portion-btn {
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-mute);
  border-radius: 999px;
  letter-spacing: 0.3px;
  transition: background 0.15s ease, color 0.15s ease;
}
.portion-btn[aria-pressed="true"] {
  background: var(--ink);
  color: var(--surface);
}
.freq-stepper {
  display: flex;
  align-items: center;
  gap: 4px;
}
.freq-step-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--cream);
  border: 1px solid var(--rule);
  color: var(--ink-soft);
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.freq-step-btn:hover { background: var(--cream-warm); color: var(--ink); }
.freq-step-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.freq-step-value {
  font-family: var(--serif);
  font-size: 16px;
  font-weight: 500;
  min-width: 60px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.freq-step-value small {
  display: block;
  font-family: var(--sans);
  font-size: 9px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--ink-mute);
  font-weight: 600;
  margin-top: 1px;
}

@media (max-width: 600px) {
  .freq-row {
    grid-template-columns: 48px 1fr;
    grid-template-rows: auto auto;
    row-gap: 10px;
  }
  .freq-row .freq-controls {
    grid-column: 1 / -1;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }
}

/* ============================================================
   RESULTS SCREEN (Phase 5)
   ============================================================ */

#screen-results {
  display: none;
  background: var(--cream);
  overflow-y: auto;
}
#screen-results[data-active="true"] {
  display: block;
}

.results-stage {
  max-width: 880px;
  margin: 0 auto;
  padding: var(--r4) var(--r4) var(--r8);
}

.panel {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 14px;
  padding: var(--r5) var(--r5);
  margin-bottom: var(--r4);
}
.panel-eyebrow {
  font-size: 10px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 600;
  margin-bottom: var(--r2);
}
.panel-title {
  font-family: var(--serif);
  font-size: 28px;
  font-weight: 400;
  letter-spacing: -0.6px;
  margin-bottom: var(--r3);
}
.panel-intro {
  color: var(--ink-soft);
  font-size: 14px;
  margin-bottom: var(--r4);
}

/* --- Score panel --- */
.panel-score {
  text-align: center;
}

/* Profile + Baseline toggles above the score */
.profile-toggles {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin: var(--r3) auto var(--r4);
  max-width: 480px;
}
.toggle-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}
.toggle-label {
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--ink-mute);
  font-weight: 600;
  min-width: 56px;
  text-align: left;
}
.sex-toggle, .mode-toggle {
  display: flex;
  background: var(--cream-warm);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}
.toggle-pill {
  padding: 7px 16px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
  border-radius: 999px;
  letter-spacing: 0.2px;
  transition: background 0.18s ease, color 0.18s ease;
  white-space: nowrap;
}
.toggle-pill[aria-pressed="true"] {
  background: var(--ink);
  color: var(--surface);
}
.toggle-pill:hover:not([aria-pressed="true"]) {
  color: var(--ink);
}
.toggle-source-note {
  font-size: 10px;
  color: var(--ink-mute);
  font-style: italic;
  letter-spacing: 0.3px;
  text-align: center;
}

/* Dual score readout — both numbers always visible under the bar */
.dual-score {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  max-width: 460px;
  margin: var(--r4) auto 0;
  padding-top: var(--r3);
  border-top: 1px solid var(--rule);
}
.dual-score-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 12px 8px;
  border-radius: 10px;
  transition: background 0.2s ease;
}
.dual-score-item[data-active="true"] {
  background: var(--cream-warm);
  box-shadow: 0 0 0 1.5px var(--gold) inset;
}
.dual-score-num {
  font-family: var(--serif);
  font-size: 32px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  letter-spacing: -1.5px;
  line-height: 1;
}
.dual-score-divider {
  font-size: 14px;
  color: var(--ink-mute);
}
.dual-score-label {
  font-size: 10px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--ink-mute);
  font-weight: 600;
  margin-top: 4px;
  text-align: center;
}
.dual-score-item[data-active="true"] .dual-score-label {
  color: var(--gold-deep);
}

@media (max-width: 480px) {
  .toggle-row { gap: 8px; }
  .toggle-label { min-width: 48px; font-size: 9px; letter-spacing: 1.5px; }
  .toggle-pill { padding: 6px 12px; font-size: 11px; }
  .dual-score-num { font-size: 26px; }
}
.score-headline {
  font-family: var(--serif);
  font-weight: 400;
  margin: var(--r2) 0 4px;
  letter-spacing: -2px;
  line-height: 1;
}
.score-num {
  font-size: clamp(60px, 14vw, 96px);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.score-of {
  font-size: clamp(32px, 7vw, 48px);
  color: var(--ink-mute);
  letter-spacing: -1px;
}
.score-label {
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--ink-mute);
  font-weight: 600;
  margin-bottom: var(--r5);
}

.score-bar-wrap {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 12px;
  margin: 0 auto var(--r4);
  max-width: 100%;
}
.score-group {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 460px;
}
.score-group-label {
  font-size: 9px;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 700;
  text-align: left;
}
.score-bar {
  display: flex;
  gap: 2px;
  height: 28px;
  align-items: stretch;
}
.score-divider {
  width: 1px;
  height: 28px;
  background: var(--rule);
  margin-top: 22px;
  flex-shrink: 0;
}
.score-seg {
  flex: 1 1 0;
  min-width: 6px;
  background: var(--rule);
  border-radius: 2px;
  position: relative;
  transition: background 0.2s ease;
}
.score-seg[data-state="green"] { background: var(--score-green); }
.score-seg[data-state="amber"] { background: var(--score-amber); }
.score-seg[data-state="red"]   { background: var(--score-red); }
.score-seg[data-state="empty"] { background: rgba(26,26,26,0.08); }

/* Nutrient labels under each segment — angled so full names fit under thin segments */
.score-labels {
  display: flex;
  gap: 2px;
  margin-top: 4px;
  align-items: flex-start;
  height: 96px; /* room for rotated labels */
  margin-bottom: -12px;
}
.score-label {
  flex: 1 1 0;
  min-width: 6px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}
.score-label-text {
  display: inline-block;
  font-family: var(--sans);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1px;
  white-space: nowrap;
  transform: rotate(-55deg);
  transform-origin: top center;
  margin-top: 6px;
  transition: color 0.2s ease;
}
.score-label[data-state="green"] .score-label-text { color: var(--score-green); }
.score-label[data-state="amber"] .score-label-text { color: var(--score-amber); }
.score-label[data-state="red"]   .score-label-text { color: var(--score-red); }
.score-label[data-state="empty"] .score-label-text { color: var(--ink-mute); }

/* Legend below the bars */
.score-key {
  display: flex;
  justify-content: center;
  gap: var(--r4);
  margin-top: var(--r4);
  margin-bottom: 0;
  font-size: 11px;
  color: var(--ink-soft);
  letter-spacing: 0.3px;
  flex-wrap: wrap;
}
.score-key .dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: -1px;
}
.score-key .dot-green { background: var(--score-green); }
.score-key .dot-amber { background: var(--score-amber); }
.score-key .dot-red   { background: var(--score-red); }

@media (max-width: 600px) {
  .score-key { gap: var(--r3); font-size: 10px; }
  .score-labels { height: 84px; }
  .score-label-text { font-size: 9px; }
}

@media (max-width: 380px) {
  .score-labels { height: 78px; }
  .score-label-text { font-size: 8.5px; letter-spacing: 0; }
}

.score-summary {
  font-family: var(--serif);
  font-style: italic;
  font-size: 16px;
  color: var(--ink-soft);
  max-width: 540px;
  margin: 0 auto;
  line-height: 1.5;
}

@media (max-width: 600px) {
  .score-bar-wrap { gap: 6px; }
  .score-bar { height: 24px; gap: 1.5px; }
  .score-divider { height: 24px; }
  .score-seg { min-width: 4px; }
}

/* --- Advisory cards --- */
.advisories {
  display: flex;
  flex-direction: column;
  gap: var(--r3);
  margin-bottom: var(--r4);
}
.advisory-card {
  background: #fff7df;
  border: 1px solid #e6c777;
  border-left: 5px solid var(--gold);
  border-radius: 12px;
  padding: var(--r4);
}
.advisory-card .adv-title {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 17px;
  color: var(--gold-deep);
  margin-bottom: 6px;
}
.advisory-card .adv-body {
  color: #5a4810;
  font-size: 14px;
  line-height: 1.55;
}

/* --- Gap rows --- */
.gap-list {
  display: flex;
  flex-direction: column;
  gap: var(--r4);
}
.gap-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--r2);
}
.gap-row-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--r3);
}
.gap-name {
  font-family: var(--serif);
  font-style: italic;
  font-size: 16px;
  color: var(--ink);
}
.gap-name-type {
  font-family: var(--sans);
  font-style: normal;
  font-size: 9px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--ink-mute);
  font-weight: 600;
  margin-left: 8px;
}
.gap-pct {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 16px;
  font-variant-numeric: tabular-nums;
  color: var(--ink-soft);
}
.gap-bar {
  width: 100%;
  height: 8px;
  background: rgba(26,26,26,0.06);
  border-radius: 4px;
  overflow: hidden;
}
.gap-bar-fill {
  height: 100%;
  border-radius: 4px;
  width: 0;
  transition: width 1.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
.gap-bar-fill[data-state="red"]   { background: var(--score-red); }
.gap-bar-fill[data-state="amber"] { background: var(--score-amber); }
.gap-sources {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 6px;
}
.gap-sources-label {
  font-size: 11px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--ink-mute);
  font-weight: 600;
}
.gap-source {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 4px;
  background: var(--cream);
  border: 1px solid var(--rule);
  border-radius: 999px;
  font-size: 12px;
  font-family: var(--serif);
  font-style: italic;
}
.gap-source-photo {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  position: relative;
  overflow: hidden;
  background: var(--rule);
  flex-shrink: 0;
}
.gap-source-photo img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 1;
}
.gap-source-photo .food-letter {
  font-size: 14px;
}

.no-gaps {
  text-align: center;
  padding: var(--r5);
  color: var(--ink-soft);
}

/* Warning footnote on gap rows and recommendation cards */
.gap-warning, .rec-warning {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 10px;
  padding: 8px 12px;
  background: #fef3e0;
  border-left: 3px solid var(--gold);
  border-radius: 4px;
  font-size: 12px;
  color: #6b4f10;
  line-height: 1.45;
}
.gap-warning-icon, .rec-warning-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  background: var(--gold);
  color: var(--surface);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  font-family: Georgia, serif;
  font-style: italic;
}
.rec-warning {
  margin-top: 12px;
  font-size: 11.5px;
}

/* Anomaly note (only shown on optimised mode for NHS/NIH disagreements) */
.gap-note {
  margin-top: 8px;
  padding: 6px 10px;
  background: #f4ecd6;
  border-left: 3px solid var(--ink-mute);
  border-radius: 4px;
  font-size: 11.5px;
  color: var(--ink-soft);
  line-height: 1.45;
}
.gap-note strong { color: var(--ink); }

/* Reference panel — 4 non-scored nutrients */
.panel-reference .panel-intro {
  font-style: italic;
}
.ref-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
@media (max-width: 600px) {
  .ref-list { grid-template-columns: 1fr; }
}
.ref-item {
  padding: 14px 16px;
  background: var(--cream);
  border: 1px solid var(--rule);
  border-radius: 10px;
}
.ref-item-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 6px;
}
.ref-item-name {
  font-family: var(--serif);
  font-style: italic;
  font-size: 16px;
  font-weight: 500;
  color: var(--ink);
}
.ref-item-target {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 14px;
  color: var(--gold-deep);
  font-variant-numeric: tabular-nums;
}
.ref-item-sources {
  font-size: 12px;
  color: var(--ink-soft);
  line-height: 1.4;
  margin-bottom: 4px;
}
.ref-item-sources strong {
  font-size: 10px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--ink-mute);
  font-weight: 700;
  margin-right: 4px;
}
.ref-item-warning {
  font-size: 11.5px;
  font-style: italic;
  color: var(--ink-mute);
  margin-top: 4px;
}

/* --- Recommendation cards --- */
.rec-list {
  display: flex;
  flex-direction: column;
  gap: var(--r3);
}
.rec-card {
  display: grid;
  grid-template-columns: 84px 1fr;
  gap: var(--r4);
  padding: var(--r4);
  background: var(--cream);
  border: 1px solid var(--rule);
  border-radius: 12px;
  align-items: center;
}
.rec-photo {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  position: relative;
  overflow: hidden;
  background: var(--rule);
  flex-shrink: 0;
}
.rec-photo img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 1;
}
.rec-photo .food-letter {
  font-size: 32px;
}
.rec-name {
  font-family: var(--serif);
  font-style: italic;
  font-size: 22px;
  color: var(--ink);
  margin-bottom: 2px;
  letter-spacing: -0.3px;
}
.rec-cat {
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 600;
  margin-bottom: 10px;
}
.rec-closes {
  font-size: 13px;
  color: var(--ink-soft);
  margin-bottom: 8px;
}
.rec-closes strong { color: var(--ink); font-weight: 600; }
.rec-frequency {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 16px;
  color: var(--gold-deep);
}
.rec-frequency .rec-portion-note {
  font-family: var(--sans);
  font-style: normal;
  font-size: 11px;
  color: var(--ink-mute);
  letter-spacing: 0.3px;
  margin-left: 8px;
}

.no-recs {
  text-align: center;
  padding: var(--r5);
  color: var(--ink-soft);
  font-family: var(--serif);
  font-style: italic;
}

@media (max-width: 600px) {
  .rec-card {
    grid-template-columns: 64px 1fr;
    gap: var(--r3);
    padding: var(--r3);
  }
  .rec-photo { width: 64px; height: 64px; }
  .rec-photo .food-letter { font-size: 26px; }
  .rec-name { font-size: 18px; }
  .panel { padding: var(--r4); }
}

/* --- Results CTAs --- */
.results-ctas {
  display: flex;
  flex-direction: column;
  gap: var(--r2);
  margin-top: var(--r5);
}
@media (min-width: 600px) {
  .results-ctas {
    flex-direction: row;
    justify-content: center;
    gap: var(--r3);
  }
  .results-ctas .cta { min-width: 200px; }
}
.cta-secondary {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--ink);
  padding: 16px 32px;
  font-weight: 600;
  border-radius: 8px;
}
.cta-secondary:hover {
  background: var(--ink);
  color: var(--surface);
}

.cta-body-explorer {
  background: linear-gradient(135deg, #0E0E14, #1a1a2e);
  color: #b8860b;
  border: 1px solid #b8860b;
  padding: 16px 32px;
  font-weight: 600;
  border-radius: 8px;
  transition: background 0.2s, box-shadow 0.2s;
}
.cta-body-explorer:hover {
  background: linear-gradient(135deg, #1a1a2e, #2d2d44);
  box-shadow: 0 0 16px rgba(184, 134, 11, 0.3);
}

/* --- Save panel modal --- */
.save-panel {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--r4);
}
.save-panel[hidden] { display: none; }
.save-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(26,26,26,0.55);
  backdrop-filter: blur(4px);
}
.save-card {
  position: relative;
  background: var(--cream);
  border-radius: 16px;
  padding: var(--r5);
  max-width: 420px;
  width: 100%;
  z-index: 1;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}
.save-close {
  position: absolute;
  top: 12px;
  right: 16px;
  font-size: 24px;
  color: var(--ink-mute);
  width: 32px;
  height: 32px;
  line-height: 1;
}
.save-close:hover { color: var(--ink); }
.save-card h3 {
  font-family: var(--serif);
  font-size: 24px;
  font-weight: 400;
  margin-bottom: 4px;
}
.save-sub {
  color: var(--ink-mute);
  font-size: 13px;
  margin-bottom: var(--r4);
}
.save-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: var(--r4) 0;
}
.save-divider::before,
.save-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--rule);
}
.save-divider span {
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--ink-mute);
  font-weight: 600;
}
.save-label {
  display: block;
  font-size: 12px;
  letter-spacing: 0.5px;
  color: var(--ink-soft);
  margin-bottom: 6px;
}
.save-input {
  width: 100%;
  padding: 12px 14px;
  font-family: inherit;
  font-size: 15px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 8px;
  color: var(--ink);
  margin-bottom: var(--r3);
}
.save-input:focus {
  outline: none;
  border-color: var(--gold);
}
.save-note {
  font-size: 11px;
  color: var(--ink-mute);
  margin-top: var(--r3);
  text-align: center;
}

/* ============================================================
   PRINT STYLES — for PDF generation via window.print()
   ============================================================ */

@media print {
  body { background: white; padding: 32px; }
  .screen { display: none !important; }
  .screen#screen-results { display: block !important; position: static; }
  .results-ctas, .save-panel, #toast-container, .brand-bar { display: none !important; }
  .panel { box-shadow: none; border: 1px solid #ddd; page-break-inside: avoid; }
  .rec-card { page-break-inside: avoid; }
  .gap-bar-fill { transition: none !important; }
}

/* ============================================================
   PLACEHOLDER (Phase 4 will fill the grid)
   ============================================================ */

.placeholder-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--r4);
  text-align: center;
  gap: var(--r3);
}
.placeholder-stage h2 {
  font-size: 28px;
  color: var(--ink);
  letter-spacing: -0.5px;
}
.placeholder-stage p {
  color: var(--ink-mute);
  font-size: 14px;
  max-width: 380px;
}

/* ============================================================
   TOAST
   ============================================================ */

#toast-container {
  position: fixed;
  bottom: var(--r4);
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-left: 4px solid var(--gold);
  border-radius: 8px;
  padding: 12px 18px;
  font-size: 13px;
  color: var(--ink);
  max-width: 320px;
  box-shadow: 0 8px 24px rgba(26,26,26,0.08);
  pointer-events: auto;
  transform: translateY(20px);
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
}
.toast.visible {
  transform: translateY(0);
  opacity: 1;
}

/* ============================================================
   ACCESSIBILITY + REDUCED MOTION
   ============================================================ */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .loader-wordmark,
  .loader-tagline { opacity: 1 !important; }
  .loader-rule { transform: scaleX(1) !important; }
}

/* Focus rings for keyboard nav */
:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
  border-radius: 4px;
}
.cta:focus-visible {
  outline-offset: 4px;
}

/* ============================================================
   MOBILE TIGHTENING
   ============================================================ */

@media (max-width: 600px) {
  .brand-bar {
    padding: var(--r3) var(--r3) 0;
  }
  .hook-stage {
    padding: 0 var(--r3);
  }
  .cta-primary {
    padding: 14px 32px;
    font-size: 14px;
  }
}

/* ============================================================
   v7a — GROUPED GAP SOURCES + WEEKLY DOSE
   ============================================================ */

.gap-uk-sources {
  font-size: 13px;
  color: var(--ink-soft);
  font-family: var(--sans);
  margin-top: 4px;
}
.gap-uk-sources strong {
  font-weight: 600;
  color: var(--ink);
}

.gap-sources-summary {
  font-size: 13px;
  color: var(--ink-soft);
  font-family: var(--sans);
  margin-top: 10px;
  padding: 10px 12px;
  background: var(--gold-soft);
  border-left: 3px solid var(--gold);
  border-radius: 4px;
  line-height: 1.5;
}

.gap-source-groups {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.gap-source-group {
  background: var(--cream);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--group-color, var(--gold));
  border-radius: 6px;
  padding: 10px 12px;
}

.gap-source-group-head {
  font-size: 10px;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: var(--group-color, var(--gold));
  font-weight: 700;
  margin-bottom: 8px;
}

.gap-source-item {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 10px;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px dashed rgba(26,26,26,0.06);
}
.gap-source-item:last-child {
  border-bottom: none;
}
.gap-source-item[data-selected="true"] {
  opacity: 0.65;
}

.gap-source-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.gap-source-name {
  font-family: var(--serif);
  font-style: italic;
  font-size: 14px;
  color: var(--ink);
  line-height: 1.3;
}
.gap-source-tag {
  font-family: var(--sans);
  font-style: normal;
  font-size: 10px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 600;
}
.gap-source-dose {
  font-family: var(--sans);
  font-size: 12px;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
  line-height: 1.4;
}
.gap-source-dose strong {
  color: var(--ink);
  font-weight: 700;
}
.gap-source-density {
  color: var(--ink-mute);
  font-size: 11px;
}

/* ============================================================
   v7a — MISSING FOOD GROUPS
   ============================================================ */

.panel-missing-groups .panel-intro {
  color: var(--ink-soft);
}
.missing-group-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
  margin-top: 12px;
}
.missing-group-card {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-left: 4px solid var(--group-color, var(--gold));
  border-radius: 8px;
  padding: 14px 14px 12px;
}
.missing-group-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
}
.missing-group-name {
  font-family: var(--serif);
  font-size: 17px;
  font-style: italic;
  color: var(--ink);
}
.missing-group-status {
  font-family: var(--sans);
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--score-red);
  font-weight: 700;
}
.missing-group-why {
  font-size: 13px;
  color: var(--ink-soft);
  line-height: 1.5;
  margin-bottom: 10px;
}
.missing-group-sample-label {
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--ink-mute);
  font-weight: 600;
  margin-bottom: 6px;
}
.missing-group-samples {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.missing-group-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px 6px 6px;
  background: var(--cream);
  border: 1px solid var(--rule);
  border-radius: 999px;
  cursor: pointer;
  font-family: var(--serif);
  font-style: italic;
  font-size: 13px;
  color: var(--ink);
  text-align: left;
  transition: transform 0.15s ease, background 0.2s ease;
}
.missing-group-chip:hover {
  background: var(--gold-soft);
}
.missing-group-chip:active {
  transform: scale(0.97);
}
.missing-group-chip span:not(.missing-group-plus) {
  flex: 1;
  min-width: 0;
}
.missing-group-plus {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--gold);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-style: normal;
  font-size: 14px;
}

/* ============================================================
   v7a — BUILD-PLAN SCREEN
   ============================================================ */

#screen-buildplan {
  background: var(--cream);
  overflow-y: auto;
}
.buildplan-stage {
  max-width: 900px;
  margin: 0 auto;
  padding: 20px var(--r4) 80px;
}
.buildplan-intro {
  text-align: center;
  margin-bottom: 28px;
}
.buildplan-title {
  font-family: var(--serif);
  font-size: 36px;
  letter-spacing: -0.5px;
  color: var(--ink);
  margin: 8px 0 10px;
}
.buildplan-sub {
  font-size: 15px;
  color: var(--ink-soft);
  line-height: 1.55;
  max-width: 560px;
  margin: 0 auto;
}

.buildplan-block {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 16px;
}
.buildplan-block-title {
  font-family: var(--serif);
  font-style: italic;
  font-size: 22px;
  color: var(--ink);
  margin: 0 0 6px;
}
.buildplan-block-sub {
  font-size: 13px;
  color: var(--ink-soft);
  line-height: 1.5;
  margin: 0 0 14px;
}

.buildplan-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}
.bp-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px 8px 10px;
  background: var(--cream);
  border: 1.5px solid var(--rule);
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.2s ease, background 0.2s ease;
}
.bp-card:hover {
  background: var(--surface);
  border-color: var(--gold-soft);
}
.bp-card[data-added="true"] {
  border-color: var(--gold);
  background: var(--gold-soft);
}
.bp-card:active {
  transform: scale(0.97);
}
.bp-photo-wrap {
  position: relative;
  width: 64px;
  height: 64px;
}
.bp-photo-wrap .rec-photo {
  width: 64px;
  height: 64px;
}
.bp-check {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--gold);
  display: none;
  align-items: center;
  justify-content: center;
}
.bp-card[data-added="true"] .bp-check {
  display: flex;
}
.bp-check svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: white;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.bp-info {
  text-align: center;
}
.bp-name {
  font-family: var(--serif);
  font-style: italic;
  font-size: 13px;
  color: var(--ink);
  line-height: 1.2;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}
.bp-cat {
  font-size: 9px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--ink-mute);
  font-weight: 600;
  margin-top: 4px;
}
.bp-empty {
  grid-column: 1 / -1;
  text-align: center;
  font-style: italic;
  color: var(--ink-mute);
  padding: 20px;
  font-size: 14px;
}

.buildplan-summary {
  position: sticky;
  bottom: 0;
  background: var(--cream);
  padding: 14px var(--r3);
  margin: 20px calc(var(--r4) * -1) calc(var(--r4) * -1);
  border-top: 1px solid var(--rule);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  z-index: 5;
}
.buildplan-count {
  font-family: var(--serif);
  font-size: 16px;
  color: var(--ink-soft);
}
.buildplan-count strong {
  font-size: 24px;
  color: var(--gold);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.buildplan-ctas {
  display: flex;
  gap: 10px;
}

/* ============================================================
   v7a — MEAL PLANS SCREEN
   ============================================================ */

#screen-mealplans {
  background: var(--cream);
  overflow-y: auto;
}
.mealplans-stage {
  max-width: 920px;
  margin: 0 auto;
  padding: 20px var(--r4) 60px;
}
.mealplans-intro {
  text-align: center;
  margin-bottom: 28px;
}
.mealplans-title {
  font-family: var(--serif);
  font-size: 36px;
  letter-spacing: -0.5px;
  color: var(--ink);
  margin: 8px 0 10px;
}
.mealplans-sub {
  font-size: 15px;
  color: var(--ink-soft);
  line-height: 1.55;
  max-width: 560px;
  margin: 0 auto;
}

.mp-block {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 22px;
  margin-bottom: 16px;
}
.mp-block-title {
  font-family: var(--serif);
  font-style: italic;
  font-size: 22px;
  color: var(--ink);
  margin: 0 0 6px;
}
.mp-block-sub {
  font-size: 13px;
  color: var(--ink-soft);
  line-height: 1.5;
  margin: 0 0 14px;
}

.curated-plans {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}
.curated-plan {
  background: var(--cream);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 16px 18px;
}
.curated-head {
  margin-bottom: 10px;
}
.curated-name {
  font-family: var(--serif);
  font-size: 22px;
  color: var(--ink);
  margin: 0;
  font-style: italic;
}
.curated-tagline {
  font-size: 13px;
  color: var(--ink-soft);
  line-height: 1.5;
  margin: 4px 0 0;
}
.curated-anchors {
  font-size: 12px;
  color: var(--ink-soft);
  margin-bottom: 12px;
  padding: 8px 10px;
  background: var(--gold-soft);
  border-radius: 4px;
}
.curated-anchors strong {
  color: var(--gold);
  font-weight: 700;
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.curated-days {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.curated-plan:not([data-expanded="true"]) .curated-day:not([data-first="true"]) {
  display: none;
}
.curated-day {
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 6px;
}
.curated-day-name {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 600;
  font-size: 14px;
  color: var(--gold);
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.mp-meal {
  display: grid;
  grid-template-columns: 80px 1fr;
  gap: 10px;
  align-items: baseline;
  padding: 4px 0;
  font-size: 13px;
  line-height: 1.5;
}
.mp-meal-label {
  font-family: var(--sans);
  font-size: 10px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--ink-mute);
  font-weight: 700;
}
.mp-meal-foods {
  color: var(--ink);
  font-family: var(--sans);
}
.mp-food-chip {
  display: inline;
}
.mp-food-chip[data-selected="true"] {
  color: var(--gold);
  font-weight: 600;
}
.mp-food-chip[data-external="true"] {
  color: var(--ink-mute);
  font-style: italic;
}
.mp-meal-empty .mp-meal-foods {
  color: var(--ink-mute);
  font-style: italic;
}

.curated-toggle {
  display: inline-block;
  margin-top: 10px;
  background: none;
  border: none;
  color: var(--gold);
  font-size: 12px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  font-weight: 600;
  cursor: pointer;
  padding: 6px 0;
}
.curated-toggle:hover {
  text-decoration: underline;
}

.dynamic-plan {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}
.dynamic-day {
  padding: 10px 12px;
  background: var(--cream);
  border: 1px solid var(--rule);
  border-radius: 6px;
}
.dynamic-day .dynamic-day-name {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 600;
  font-size: 14px;
  color: var(--gold);
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.dynamic-empty {
  text-align: center;
  font-style: italic;
  color: var(--ink-mute);
  padding: 20px;
}

.mealplans-ctas {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 24px;
}

@media (max-width: 600px) {
  .buildplan-title, .mealplans-title { font-size: 28px; }
  .buildplan-stage, .mealplans-stage { padding: 16px var(--r3) 60px; }
  .buildplan-block, .mp-block { padding: 16px; }
  .buildplan-grid { grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); }
  .mp-meal { grid-template-columns: 1fr; gap: 2px; }
  .gap-source-groups { grid-template-columns: 1fr; }
}

/* ============================================================
   v7b — FOOD FOOTNOTES (verified vs traditional claims)
   ============================================================ */

.rec-footnote,
.gap-source-footnote,
.bp-footnote {
  font-size: 11px;
  line-height: 1.5;
  color: var(--ink-mute);
  font-style: italic;
  font-family: var(--sans);
  background: rgba(184, 134, 11, 0.06);
  border-left: 2px solid var(--gold);
  padding: 6px 8px;
  margin-top: 8px;
  border-radius: 0 4px 4px 0;
}
.bp-footnote {
  font-size: 10px;
  margin-top: 6px;
  padding: 4px 6px;
  text-align: left;
}
.gap-source-footnote {
  font-size: 11px;
  margin-top: 4px;
}

/* Superfoods category accent — emerald to differentiate from spices */
.bp-card[data-food$="(powder)"],
.bp-card[data-food$="(dried)"],
.bp-card[data-food$="(resin)"] {
  /* generic supplement-style cards lean toward the emerald accent */
}

/* ============================================================
   v8 — ENGINEERED MEAL PLAN DAYS (meals left / checklist right)
   ============================================================ */

.eng-day-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 16px;
}

/* Collapsed (everything except Monday) hidden until plan is expanded */
.curated-plan:not([data-expanded="true"]) .eng-day-card[data-collapsed="true"] {
  display: none;
}

.eng-day-card {
  position: relative;
  background: linear-gradient(135deg, var(--cream) 0%, #f6f1e3 100%);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 18px 20px;
  overflow: hidden;
}
.eng-day-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 100% 0%, rgba(184,134,11,0.06) 0%, transparent 50%),
    radial-gradient(circle at 0% 100%, rgba(74,158,92,0.05) 0%, transparent 50%);
  pointer-events: none;
}
.eng-day-card > * {
  position: relative;
}

.eng-day-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px dashed var(--rule);
}
.eng-day-name {
  font-family: var(--serif);
  font-style: italic;
  font-size: 22px;
  color: var(--ink);
  margin: 0;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.eng-day-score {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 500;
  font-size: 15px;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}

.eng-day-body {
  display: grid;
  grid-template-columns: 60fr 40fr;
  gap: 20px;
}

/* === Meals column === */
.eng-day-meals {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.eng-meal {
  background: rgba(255,255,255,0.6);
  border-radius: 8px;
  padding: 10px 12px;
  border: 1px solid rgba(184,134,11,0.15);
}
.eng-meal-head {
  font-family: var(--sans);
  font-size: 10px;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 700;
  margin-bottom: 8px;
}
.eng-meal-foods {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.eng-meal-food {
  display: grid;
  grid-template-columns: 28px 1fr auto auto;
  gap: 10px;
  align-items: center;
  padding: 4px 0;
  font-size: 13px;
  border-bottom: 1px dashed rgba(26,26,26,0.04);
}
.eng-meal-food:last-child {
  border-bottom: none;
}
.eng-meal-food[data-boost="true"] {
  background: rgba(45,106,62,0.06);
  border-radius: 4px;
  padding: 4px 6px;
}
.eng-meal-thumb {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--rule);
}
.eng-meal-name {
  font-family: var(--serif);
  font-style: italic;
  color: var(--ink);
  font-size: 14px;
}
.eng-meal-food[data-inplan="true"] .eng-meal-name {
  color: var(--gold);
  font-weight: 600;
}
.eng-meal-grams {
  font-family: var(--sans);
  font-size: 12px;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  white-space: nowrap;
}
.eng-meal-boost {
  font-family: var(--sans);
  font-size: 8px;
  letter-spacing: 1.5px;
  background: #2d6a3e;
  color: white;
  padding: 2px 6px;
  border-radius: 3px;
  font-weight: 700;
}

/* === Checklist column === */
.eng-day-check {
  background: rgba(255,255,255,0.75);
  border-radius: 8px;
  padding: 14px 14px 12px;
  border: 1px solid rgba(184,134,11,0.15);
}
.day-checklist-head {
  border-bottom: 1px solid var(--rule);
  padding-bottom: 8px;
  margin-bottom: 10px;
}
.day-checklist-headline {
  margin-top: 4px;
  display: flex;
  align-items: baseline;
  gap: 4px;
}
.day-checklist-big {
  font-family: var(--serif);
  font-size: 28px;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.day-checklist-small {
  font-family: var(--sans);
  font-size: 11px;
  color: var(--ink-soft);
  letter-spacing: 0.5px;
}
.day-checklist-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 12px;
}
.dcl-row {
  display: grid;
  grid-template-columns: 70px 1fr 38px;
  gap: 6px;
  align-items: center;
  font-size: 11px;
  padding: 1px 0;
}
.dcl-name {
  color: var(--ink-soft);
  font-family: var(--sans);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dcl-bar {
  height: 6px;
  background: rgba(26,26,26,0.06);
  border-radius: 3px;
  overflow: hidden;
}
.dcl-bar-fill {
  height: 100%;
  width: 0;
  transition: width 0.6s ease-out;
  border-radius: 3px;
}
.dcl-bar-fill[data-state="green"] { background: var(--score-green); }
.dcl-bar-fill[data-state="amber"] { background: var(--score-amber); }
.dcl-bar-fill[data-state="red"]   { background: var(--score-red); }
.dcl-pct {
  font-family: var(--sans);
  font-size: 11px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  text-align: right;
  font-weight: 600;
}
.dcl-row[data-state="green"] .dcl-pct { color: var(--score-green); }
.dcl-row[data-state="amber"] .dcl-pct { color: var(--score-amber); }
.dcl-row[data-state="red"]   .dcl-pct { color: var(--score-red); }

.day-boosts {
  border-top: 1px dashed var(--rule);
  padding-top: 10px;
  margin-top: 6px;
}
.day-boosts-list {
  list-style: none;
  padding: 0;
  margin: 6px 0 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.day-boost {
  font-size: 11px;
  color: var(--ink);
  padding: 4px 8px;
  background: rgba(45,106,62,0.08);
  border-left: 2px solid #2d6a3e;
  border-radius: 0 3px 3px 0;
  font-family: var(--sans);
}

@media (max-width: 800px) {
  .eng-day-body {
    grid-template-columns: 1fr;
    gap: 14px;
  }
  .eng-meal-food {
    grid-template-columns: 24px 1fr auto;
  }
  .eng-meal-food .eng-meal-boost {
    grid-column: 2 / -1;
    justify-self: start;
    margin-top: 2px;
  }
  .dcl-row {
    grid-template-columns: 60px 1fr 32px;
  }
}

@media (max-width: 600px) {
  .curated-plan { padding: 10px 12px; }
  .eng-day-card { padding: 12px 10px; }
  .eng-day-name { font-size: 18px; }
  .eng-day-score { font-size: 13px; }
  .eng-day-body { gap: 10px; }
  .eng-day-head { margin-bottom: 10px; padding-bottom: 8px; }
  .eng-meal { padding: 8px 10px; }
  .eng-meal-head { font-size: 9px; margin-bottom: 6px; }
  .eng-meal-name { font-size: 13px; }
  .eng-meal-grams { font-size: 11px; }
  .eng-meal-food { gap: 8px; }
  .eng-meal-thumb { width: 24px; height: 24px; }
  .eng-day-check { padding: 10px; }
  .day-checklist-big { font-size: 24px; }
  .dcl-row { grid-template-columns: 54px 1fr 30px; font-size: 10px; }
  .dcl-pct { font-size: 10px; }
  .day-boost { font-size: 10px; padding: 3px 6px; }
  .day-boosts-list { gap: 3px; }
}

@media (max-width: 360px) {
  .curated-plan { padding: 8px; }
  .eng-day-card { padding: 10px 8px; }
  .eng-day-name { font-size: 16px; }
  .eng-meal-food { gap: 6px; }
  .eng-meal-thumb { width: 20px; height: 20px; }
  .eng-meal-name { font-size: 12px; }
  .dcl-row { grid-template-columns: 48px 1fr 28px; }
  .dcl-name { font-size: 9px; }
}

/* ============================================================
   CHATBOT — Decision-tree guided nutrition advisor
   ============================================================ */

#cb-fab {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 900;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--gold);
  color: var(--cream);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(0,0,0,0.18);
  transition: transform 0.2s ease, opacity 0.2s ease;
}
#cb-fab:hover { transform: scale(1.08); }
#cb-fab:active { transform: scale(0.95); }
#cb-fab.cb-fab-hidden { opacity: 0; pointer-events: none; transform: scale(0.8); }

#cb-panel {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 901;
  width: 370px;
  max-width: calc(100vw - 24px);
  height: 520px;
  max-height: calc(100vh - 40px);
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 14px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.15);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateY(16px) scale(0.96);
  transition: opacity 0.25s ease, transform 0.25s ease;
}
#cb-panel.cb-open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.cb-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  background: var(--gold);
  color: var(--cream);
  flex-shrink: 0;
}
.cb-head-title {
  font-family: var(--serif);
  font-style: italic;
  font-size: 17px;
  letter-spacing: 0.3px;
}
.cb-head-actions {
  display: flex;
  gap: 8px;
}
.cb-reset, .cb-close {
  background: none;
  border: none;
  color: var(--cream);
  font-size: 20px;
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 0.15s ease;
}
.cb-reset:hover, .cb-close:hover {
  background: rgba(255,255,255,0.15);
}

.cb-log {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}

.cb-bubble {
  max-width: 88%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
}
.cb-bot {
  align-self: flex-start;
  background: var(--cream);
  color: var(--ink);
  border-bottom-left-radius: 4px;
}
.cb-bot strong {
  color: var(--gold-deep);
  font-weight: 700;
}
.cb-user {
  align-self: flex-end;
  background: var(--gold);
  color: var(--cream);
  border-bottom-right-radius: 4px;
}

.cb-options {
  padding: 10px 16px 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  border-top: 1px solid var(--rule);
  flex-shrink: 0;
  background: var(--cream);
}

.cb-opt {
  padding: 8px 16px;
  border-radius: 999px;
  border: 1.5px solid var(--gold);
  background: var(--surface);
  color: var(--gold-deep);
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, transform 0.1s ease;
  white-space: nowrap;
}
.cb-opt:hover {
  background: var(--gold);
  color: var(--cream);
}
.cb-opt:active {
  transform: scale(0.96);
}

@media (max-width: 420px) {
  #cb-panel {
    bottom: 0;
    right: 0;
    width: 100vw;
    height: 100vh;
    max-height: 100vh;
    max-width: 100vw;
    border-radius: 0;
  }
  #cb-fab { bottom: 14px; right: 14px; width: 50px; height: 50px; }
  .cb-opt { font-size: 12px; padding: 7px 12px; }
}

/* ============================================================
   PORTION POPUP — bottom sheet (mobile) / centered modal (desktop)
   ============================================================ */

.portion-popup {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.portion-popup[hidden] { display: none; }

.portion-popup-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(26, 26, 26, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.portion-popup-sheet {
  position: relative;
  background: var(--cream);
  width: 100%;
  max-width: 440px;
  max-height: 88vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: var(--r3) var(--r4) var(--r4);
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.2);
  z-index: 1;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
}
.portion-popup[data-open="true"] .portion-popup-sheet {
  transform: translateY(0);
}

.portion-popup-handle {
  width: 36px;
  height: 4px;
  background: var(--rule);
  border-radius: 2px;
  margin: 0 auto var(--r3);
}

.portion-popup-close {
  position: absolute;
  top: var(--r3);
  right: var(--r3);
  width: 32px;
  height: 32px;
  border: none;
  background: var(--gold-soft);
  border-radius: 50%;
  font-size: 18px;
  line-height: 32px;
  text-align: center;
  cursor: pointer;
  color: var(--ink);
  transition: background 0.15s;
}
.portion-popup-close:hover { background: var(--rule); }

/* Header */
.portion-popup-header {
  display: flex;
  align-items: center;
  gap: var(--r3);
  margin-bottom: var(--r4);
}
.pp-photo {
  width: 56px;
  height: 56px;
  flex-shrink: 0;
}
.pp-photo .food-photo {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  position: relative;
  overflow: hidden;
}
.pp-photo .food-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.pp-photo .food-letter {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--serif);
  font-size: 22px;
  color: rgba(255, 255, 255, 0.7);
}
.pp-name {
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 600;
  color: var(--ink);
  margin: 0;
}
.pp-category {
  font-size: 13px;
  color: var(--ink-mute);
  margin-top: 2px;
}

/* Portion description */
.pp-portion-desc {
  text-align: center;
  font-family: var(--serif);
  font-size: 17px;
  font-style: italic;
  color: var(--ink-soft);
  margin-bottom: var(--r2);
  min-height: 24px;
}

/* Plate ring */
.pp-viz-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: var(--r2);
}
.pp-plate-svg {
  display: block;
}
.pp-plate-text {
  font-family: var(--serif);
  font-size: 32px;
  font-weight: 700;
  fill: var(--ink);
}
.pp-plate-subtext {
  font-family: var(--sans);
  font-size: 13px;
  fill: var(--ink-mute);
}
.pp-plate-fill {
  transition: stroke-dashoffset 0.3s ease;
}

/* Presets */
.pp-presets {
  display: flex;
  gap: var(--r2);
  justify-content: center;
  margin-bottom: var(--r2);
}
.pp-preset-btn {
  flex: 1;
  max-width: 120px;
  padding: 8px 8px;
  border: 2px solid var(--rule);
  border-radius: 12px;
  background: var(--surface);
  cursor: pointer;
  text-align: center;
  transition: border-color 0.15s, background 0.15s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.pp-preset-btn[aria-pressed="true"] {
  border-color: var(--gold);
  background: var(--gold-soft);
}
.pp-preset-btn:hover { border-color: var(--gold); }
.pp-preset-label,
.pp-preset-desc {
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-soft);
  line-height: 1.3;
}
.pp-preset-grams {
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
}

/* Gram stepper */
.pp-grams {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--r3);
  margin-bottom: var(--r2);
}
.pp-step-btn {
  width: 44px;
  height: 44px;
  border: 2px solid var(--rule);
  border-radius: 50%;
  background: var(--surface);
  font-size: 22px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, border-color 0.15s;
  color: var(--ink);
}
.pp-step-btn:hover {
  border-color: var(--gold);
  background: var(--gold-soft);
}
.pp-step-btn:active { transform: scale(0.93); }
.pp-gram-display {
  text-align: center;
  min-width: 80px;
}
.pp-gram-value {
  font-family: var(--serif);
  font-size: 28px;
  font-weight: 700;
  color: var(--ink);
}
.pp-gram-unit {
  font-size: 16px;
  color: var(--ink-mute);
  margin-left: 2px;
}

/* Day pills */
.pp-days {
  margin-bottom: var(--r2);
}
.pp-days-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: var(--r2);
  text-align: center;
}
.pp-day-pills {
  display: flex;
  gap: 6px;
  justify-content: center;
}
.pp-day-pill {
  width: 40px;
  height: 40px;
  border: 2px solid var(--rule);
  border-radius: 50%;
  background: var(--surface);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  color: var(--ink-soft);
}
.pp-day-pill[aria-pressed="true"] {
  border-color: var(--gold);
  background: var(--gold);
  color: var(--cream);
}
.pp-day-pill:hover { border-color: var(--gold); }

/* Nutrient preview */
.pp-nutrients {
  margin-bottom: var(--r3);
  padding: var(--r2) var(--r3);
  background: var(--surface);
  border-radius: 12px;
  border: 1px solid var(--rule);
}
.pp-nutrient-row {
  display: grid;
  grid-template-columns: 100px 1fr 72px;
  align-items: center;
  gap: var(--r2);
  padding: 5px 0;
}
.pp-nutrient-row + .pp-nutrient-row {
  border-top: 1px solid var(--rule);
}
.pp-nutrient-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pp-nutrient-bar {
  height: 8px;
  background: var(--rule);
  border-radius: 4px;
  overflow: hidden;
}
.pp-nutrient-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s ease;
}
.pp-nutrient-bar-fill[data-state="green"] { background: var(--score-green); }
.pp-nutrient-bar-fill[data-state="amber"] { background: var(--score-amber); }
.pp-nutrient-bar-fill[data-state="red"]   { background: var(--score-red); }
.pp-nutrient-pct {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
  text-align: right;
}
.pp-nutrient-empty {
  font-size: 13px;
  color: var(--ink-mute);
  text-align: center;
  padding: var(--r2) 0;
}

/* Done + Remove buttons */
.pp-done {
  margin-bottom: var(--r2);
}
.pp-remove {
  display: block;
  width: 100%;
  text-align: center;
  font-size: 13px;
  color: var(--score-red);
  border: none;
  background: none;
  cursor: pointer;
  padding: var(--r2);
}
.pp-remove:hover { text-decoration: underline; }

/* Desktop: centered modal instead of bottom sheet */
@media (min-width: 601px) {
  .portion-popup {
    align-items: center;
  }
  .portion-popup-sheet {
    border-radius: 20px;
    max-height: 85vh;
    transform: translateY(30px);
    opacity: 0;
    transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1), opacity 0.25s ease;
  }
  .portion-popup[data-open="true"] .portion-popup-sheet {
    transform: translateY(0);
    opacity: 1;
  }
}

@media print {
  #cb-fab, #cb-panel { display: none; }
  .portion-popup { display: none; }
}
