/* ==========================================================================
   Meal Plan Generator — Design System
   The tokens below are the Redefining Wellness Center (drjabanmoore.com) defaults;
   each brand's brands/<id>/brand.css overrides them.
   ========================================================================== */

/* ---------- Tokens ---------- */
:root {
  /* drjabanmoore.com palette */
  --navy:        #040e68;
  --navy-bright: #0a1fa8;
  --ink:         #0d1440;   /* headings */
  --ink2:        #2a3a6e;   /* body text */
  --muted-soft:  #7a8ab0;   /* minor meta only (low contrast) */
  --accent:      #00c4cc;
  --orange:      #ff8d28;   /* calls to action */
  --orange2:     #ffaa55;   /* CTA hover */
  --cream:       #f0f8ff;

  /* Semantic tokens used by the components */
  --teal:        #00c4cc;
  --aqua:        #00e5ee;
  --light-aqua:  #5fe3e8;
  --bg:          #f4f6fb;
  --white:       #ffffff;
  --text:        #0d1440;
  --muted:       #2a3a6e;
  --border:      rgba(var(--ink-rgb), 0.12);
  --red:         #ef4444;
  --red-light:   #fef2f2;
  --grad:        linear-gradient(135deg, #040e68 0%, #0a1fa8 40%, #051575 100%);
  --pinstripe:   repeating-linear-gradient(-45deg, rgba(var(--accent-rgb), 0.06) 0 1px, transparent 1px 40px);
  --teal-strip:  linear-gradient(120deg, #5fe3e8 0%, #00c4cc 55%, #04979e 100%);

  --selected-bg: #f0f8ff;
  --teal-dark:   #04979e;
  --success:     #0f8a5f;
  --success-bg:  #ecfdf5;

  --font-body:   'Poppins', system-ui, -apple-system, 'Segoe UI', Arial, sans-serif;
  --font-accent: 'Fraunces', Georgia, serif;

  /* RGB triplets for translucent tints: rgba(var(--accent-rgb), 0.3) */
  --accent-rgb:  0, 196, 204;
  --ink-rgb:     13, 20, 64;
  --shadow-rgb:  0, 33, 91;
  --cta-rgb:     255, 141, 40;
  --cta-hover-text: #0d1440;

  --radius-card: 16px;
  --radius-btn:  10px;
  --radius-pill: 50px;
  --shadow-card: 0 6px 20px rgba(var(--shadow-rgb), 0.06);
  --shadow-hover: 0 14px 34px rgba(var(--shadow-rgb), 0.10);

  --header-h: 68px;
  --progress-h: 4px;
  --gutter: 24px;
  --maxw: 880px;

  --t-fast: 0.2s ease;
  --t-slide: 250ms ease;
  --focus: 0 0 0 3px rgba(var(--accent-rgb), 0.45);
}

/* ---------- Reset / base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 18px;
  line-height: 1.55;
  color: var(--ink2);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; line-height: 1.2; font-weight: 800; letter-spacing: -0.03em; color: var(--ink); }

/* Fraunces italic accent words, as on drjabanmoore.com */
.accent {
  font-family: var(--font-accent);
  font-style: italic;
  font-weight: 900;
  color: var(--accent);
  letter-spacing: -0.01em;
}

/* Small uppercase kicker with a short teal rule */
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}
.eyebrow::before {
  content: '';
  width: 24px;
  height: 2px;
  background: currentColor;
}
p { margin: 0; }
img, svg { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

[hidden] { display: none !important; }

/* Visible focus rings everywhere — never suppressed */
:focus-visible {
  outline: 3px solid var(--aqua);
  outline-offset: 2px;
}

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

/* ==========================================================================
   Header + progress bar
   ========================================================================== */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  border-top: 4px solid transparent;
  border-image: var(--teal-strip) 1;
  border-image-width: 4px 0 0 0;
}

.app-header__inner {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  height: var(--header-h);
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.app-header__left { justify-self: start; }
.app-header__logo { height: 40px; width: auto; }

.app-header__title {
  justify-self: center;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ink);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 50vw;
}

.app-header__right { justify-self: end; }

.back-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border: 1.5px solid var(--border);
  border-radius: 50%;
  background: var(--white);
  color: var(--teal);
  font-size: 22px;
  line-height: 1;
  transition: all var(--t-fast);
}
.back-btn { color: var(--ink); }
.back-btn:hover { border-color: var(--accent); background: var(--selected-bg); color: var(--teal-dark); }

.progress {
  height: var(--progress-h);
  background: transparent;
  overflow: hidden;
}
.progress__fill {
  height: 100%;
  width: 0%;
  background: var(--teal);
  transition: width 300ms ease;
}

/* ==========================================================================
   Screen container + slide transitions
   ========================================================================== */
.screen-viewport {
  position: relative;
  overflow-x: hidden;
  overflow-x: clip; /* clip (not hidden) so position: sticky still works inside */
  min-height: calc(100vh - var(--header-h) - var(--progress-h));
}

.screen {
  width: 100%;
  outline: none;
}

/* Headings receive programmatic focus after each transition (for screen readers) */
[tabindex="-1"]:focus { outline: none; }

/* During a transition the outgoing screen is pinned on top of the incoming one */
.screen.is-leaving {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
}

/* Forward: new screen enters from the right, old exits to the left */
.slide-in-right  { animation: slideInRight  var(--t-slide) both; }
.slide-out-left  { animation: slideOutLeft  var(--t-slide) both; }
/* Back: new screen enters from the left, old exits to the right */
.slide-in-left   { animation: slideInLeft   var(--t-slide) both; }
.slide-out-right { animation: slideOutRight var(--t-slide) both; }

@keyframes slideInRight  { from { transform: translateX(100%); }  to { transform: translateX(0); } }
@keyframes slideOutLeft  { from { transform: translateX(0); }     to { transform: translateX(-100%); } }
@keyframes slideInLeft   { from { transform: translateX(-100%); } to { transform: translateX(0); } }
@keyframes slideOutRight { from { transform: translateX(0); }     to { transform: translateX(100%); } }

.screen__inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 48px var(--gutter) 64px;
}
.screen__inner--narrow { max-width: 528px; } /* 480px content + gutters */
.screen__inner--wide   { max-width: 1200px; }

.screen-headline {
  font-size: clamp(28px, 3.6vw, 38px);
  font-weight: 800;
  line-height: 1.1;
  text-align: center;
  color: var(--ink);
  margin-bottom: 12px;
}

.screen-subhead {
  font-size: 18px;
  color: var(--muted);
  text-align: center;
  max-width: 620px;
  margin: 0 auto 32px;
}

.screen-headline + .card-grid,
.screen-headline + .form-stack,
.screen-headline + .field-row,
.screen-headline + .category-grid { margin-top: 32px; }

.screen-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  margin-top: 40px;
}

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 14px 32px;
  border-radius: var(--radius-btn);
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  transition: all var(--t-fast);
}

.btn--primary {
  background: var(--orange);
  color: var(--white);
  border: none;
  box-shadow: 0 6px 18px rgba(var(--cta-rgb), 0.28);
}
.btn--primary:hover:not(:disabled) { background: var(--orange2); color: var(--cta-hover-text); transform: translateY(-1px); box-shadow: 0 10px 24px rgba(var(--cta-rgb), 0.32); }
.btn--primary:active:not(:disabled) { transform: translateY(0); }

.btn--ghost {
  background: var(--white);
  color: var(--ink);
  border: 1.5px solid rgba(var(--ink-rgb), 0.25);
}
.btn--ghost:hover:not(:disabled) { border-color: var(--accent); background: var(--selected-bg); }

/* White button on gradient (landing CTA) */
.btn--white {
  background: var(--white);
  color: var(--teal);
  border: none;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
}
.btn--white:hover { transform: translateY(-1px); box-shadow: 0 10px 26px rgba(0, 0, 0, 0.16); }

/* Text-only link-style button */
.btn--text {
  background: none;
  border: none;
  color: var(--teal-dark);
  padding: 12px 16px;
  text-decoration: underline;
  text-underline-offset: 3px;
  font-weight: 600;
}
.btn--text:hover { color: var(--ink); }

.btn--block { width: 100%; }
.btn--lg { padding: 16px 40px; font-size: 18px; }

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

/* Small inline spinner for buttons in a loading state */
.btn .spinner {
  width: 18px; height: 18px;
  border: 2.5px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ==========================================================================
   Screen 0 — Landing hero
   ========================================================================== */
.hero {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--pinstripe), var(--grad);
  color: var(--white);
  text-align: center;
  padding: 48px var(--gutter);
}

.hero__content { max-width: 680px; }

.hero__logo {
  height: 72px;
  width: auto;
  margin: 0 auto 32px;
}

.hero__eyebrow {
  font-size: 14px;
  letter-spacing: 0.18em;
  margin-bottom: 20px;
}

.hero__title {
  font-size: clamp(40px, 5.8vw, 60px);
  font-weight: 800;
  line-height: 1.05;
  color: var(--white);
  margin-bottom: 20px;
}

.hero__sub {
  font-size: 18px;
  font-weight: 300;
  opacity: 0.75;
  max-width: 560px;
  margin: 0 auto 36px;
}

.hero__note {
  font-size: 14px;
  opacity: 0.6;
  margin-top: 18px;
}

.hero .btn--primary { box-shadow: 0 10px 28px rgba(0, 0, 0, 0.25); }

/* ==========================================================================
   Forms (Screens 1 & 2)
   ========================================================================== */
.form-stack {
  display: flex;
  flex-direction: column;
  gap: 24px;
  max-width: 480px;
  margin: 0 auto;
}

.field { display: flex; flex-direction: column; gap: 8px; }

.field__label {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.field__hint {
  font-size: 14px;
  color: var(--muted);
}

.field__error {
  font-size: 14px;
  color: var(--red);
  font-weight: 600;
  min-height: 1em;
}
.field__error:not(:empty)::before { content: '⚠ '; }

.input {
  width: 100%;
  min-height: 56px;
  padding: 14px 20px;
  font-size: 18px;
  color: var(--text);
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  -moz-appearance: textfield;
}
.input::placeholder { color: #8fb0b0; }
.input:hover { border-color: var(--light-aqua); }
.input:focus { outline: none; border-color: var(--teal); box-shadow: var(--focus); }
.input:focus-visible { outline: none; }
.input[aria-invalid="true"] { border-color: var(--red); background: var(--red-light); }
.input::-webkit-outer-spin-button,
.input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.input--lg {
  min-height: 64px;
  font-size: 20px;
  text-align: center;
}

/* Age + weight side by side on desktop */
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  max-width: 560px;
  margin: 0 auto;
}

.input-with-toggle {
  display: flex;
  gap: 10px;
  align-items: stretch;
}
.input-with-toggle .input { flex: 1; min-width: 0; }

/* lbs / kg pill */
.unit-toggle {
  display: inline-flex;
  padding: 4px;
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-pill);
  flex-shrink: 0;
}
.unit-toggle__btn {
  min-width: 56px;
  min-height: 48px;
  padding: 0 14px;
  border: none;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--muted);
  font-size: 16px;
  font-weight: 600;
  transition: all var(--t-fast);
}
.unit-toggle__btn[aria-pressed="true"] {
  background: var(--ink);
  color: var(--white);
}

/* ==========================================================================
   Option cards (protocols, meals, skill, time, servings)
   ========================================================================== */
.card-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.card-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.card-grid--narrow { max-width: 640px; margin-left: auto; margin-right: auto; }

.option-card {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-card);
  padding: 20px;
  box-shadow: var(--shadow-card);
  transition: all var(--t-fast);
  cursor: pointer;
  text-align: left;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  min-height: 48px;
}
.option-card:hover { border-color: var(--accent); box-shadow: var(--shadow-hover); transform: translateY(-2px); }

.option-card__icon {
  font-size: 32px;
  line-height: 1;
  flex-shrink: 0;
}

.option-card__body { display: flex; flex-direction: column; gap: 4px; min-width: 0; padding-right: 28px; }

.option-card__title {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.option-card__desc {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.45;
}

/* Large stacked variant (meals / skill / time / servings) */
.option-card--lg {
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 32px 24px;
  gap: 12px;
}
.option-card--lg .option-card__icon { font-size: 48px; }
.option-card--lg .option-card__body { align-items: center; padding-right: 0; }
.option-card--lg .option-card__title { font-size: 20px; }
.option-card--lg .option-card__desc { font-size: 16px; }

/* Selected state — color + checkmark badge (never color alone) */
.option-card.is-selected,
.option-card[aria-pressed="true"],
.option-card[aria-checked="true"] {
  border: 2.5px solid var(--teal);
  background: var(--selected-bg);
  padding: 19px; /* compensate for thicker border so layout doesn't shift */
}
.option-card--lg.is-selected,
.option-card--lg[aria-pressed="true"],
.option-card--lg[aria-checked="true"] { padding: 31px 23px; }

.option-card.is-selected::after,
.option-card[aria-pressed="true"]::after,
.option-card[aria-checked="true"]::after {
  content: '✓';
  position: absolute;
  top: 10px;
  right: 10px;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--teal);
  color: var(--white);
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
  animation: pop 0.2s ease;
}

@keyframes pop { from { transform: scale(0.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.protocol-warning { margin-top: 20px; }

.selection-count {
  text-align: center;
  font-size: 16px;
  color: var(--muted);
  margin-top: 20px;
}
.selection-count strong { color: var(--teal-dark); }

/* ==========================================================================
   Guidance notes, protocol-locked chips, toggles, review warnings
   ========================================================================== */
.screen-note {
  text-align: center;
  font-size: 16px;
  font-weight: 600;
  color: var(--teal-dark);
  margin: -16px auto 28px;
}

.instructions {
  max-width: 760px;
  margin: 0 auto 28px;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--cream);
  border: 1px solid rgba(var(--accent-rgb), 0.35);
  border-radius: var(--radius-card);
}
.instructions__step { display: flex; gap: 12px; align-items: flex-start; margin: 0; font-size: 16px; color: var(--ink2); }
.instructions__step > span:first-child { font-size: 20px; line-height: 1.3; }
.instructions__step strong { color: var(--ink); }

.food-chip.is-locked,
.food-chip.is-locked[aria-pressed="true"] {
  cursor: not-allowed;
  border-style: dashed;
  padding-right: 18px;
  opacity: 0.85;
}
.food-chip.is-locked.is-restricted::after,
.food-chip.is-locked[aria-pressed="true"]::after { display: none; }

.toggle-row {
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: 640px;
  margin: 24px auto 0;
  padding: 14px 18px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
}
.toggle-row__text { display: flex; flex-direction: column; gap: 2px; }
.toggle-row__label { font-size: 18px; font-weight: 700; color: var(--ink); }
.toggle-row__hint { font-size: 14px; color: var(--muted); }
.switch.switch--positive[aria-checked="true"] .switch__track { background: var(--teal-dark); }

.plan-warnings {
  margin-bottom: 16px;
  padding: 12px 18px;
  border-radius: var(--radius-card);
  background: #fff7ed;
  border: 1px solid rgba(255, 141, 40, 0.55);
  color: var(--ink2);
  font-size: 16px;
}
.plan-warnings summary { cursor: pointer; font-weight: 700; color: var(--ink); min-height: 32px; }
.plan-warnings p { margin: 8px 0; font-size: 15px; }
.plan-warnings ul { margin: 0; padding-left: 20px; font-size: 15px; }

/* ==========================================================================
   Macro targets (optional screen) + results macro bar
   ========================================================================== */
.option-card[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }

.macro-panel {
  margin: 28px auto 0;
  max-width: 720px;
  padding: 28px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.macro-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 20px 24px;
  align-items: start;
}
.macro-grid__wide { grid-column: 1 / -1; }

.height-ftin { display: flex; gap: 10px; }
.height-ftin .input { max-width: 120px; }

select.input {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 48px;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink) 50%), linear-gradient(135deg, var(--ink) 50%, transparent 50%);
  background-position: calc(100% - 24px) 50%, calc(100% - 18px) 50%;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  cursor: pointer;
}

.choice-pills { display: flex; flex-wrap: wrap; gap: 10px; }
.choice-pill {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 8px 18px;
  border: 1.5px solid rgba(var(--ink-rgb), 0.18);
  border-radius: var(--radius-btn);
  background: var(--white);
  color: var(--ink);
  font-size: 16px;
  font-weight: 600;
  line-height: 1.2;
  transition: all var(--t-fast);
}
.choice-pill small { font-size: 14px; font-weight: 400; color: var(--muted); }
.choice-pill:hover { border-color: var(--accent); }
.choice-pill[aria-pressed="true"] {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--white);
}
.choice-pill[aria-pressed="true"] small { color: rgba(255, 255, 255, 0.75); }

.macro-result {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 18px 24px;
  align-items: center;
  padding: 22px 24px;
  border-radius: var(--radius-card);
  background: var(--pinstripe), var(--grad);
  color: var(--white);
}
.macro-result__empty { grid-column: 1 / -1; margin: 0; font-size: 16px; color: rgba(255, 255, 255, 0.8); }
.macro-result__calories { display: flex; flex-direction: column; gap: 2px; }
.macro-result__number {
  font-family: var(--font-accent);
  font-style: italic;
  font-weight: 900;
  font-size: 48px;
  line-height: 1;
  color: var(--white);
}
.macro-result__unit { font-size: 14px; color: rgba(255, 255, 255, 0.75); }
.macro-result__boxes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }

.macro-box {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(var(--accent-rgb), 0.35);
}
.macro-box__label { font-size: 14px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent); }
.macro-box__value { font-size: 28px; font-weight: 800; color: var(--white); line-height: 1.1; }
.macro-box__value small { font-size: 16px; font-weight: 600; margin-left: 2px; }
.macro-box__pct { font-size: 14px; color: rgba(255, 255, 255, 0.7); }
.macro-box__input { display: flex; align-items: center; gap: 6px; color: var(--white); font-weight: 600; }
.macro-box__input .input { min-height: 48px; padding: 8px 10px; font-size: 18px; text-align: center; box-shadow: none; }

.macro-warning {
  grid-column: 1 / -1;
  margin: 0;
  padding: 10px 14px;
  border-radius: 10px;
  background: rgba(255, 141, 40, 0.16);
  border: 1px solid rgba(255, 141, 40, 0.5);
  color: var(--white);
  font-size: 15px;
}
.macro-note { font-size: 14px; color: var(--muted); margin: -8px 0 0; }

.macro-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 16px;
  padding: 14px 18px;
  margin-bottom: 16px;
  border-radius: var(--radius-card);
  background: var(--cream);
  border: 1px solid rgba(var(--accent-rgb), 0.35);
}
.macro-bar__targets { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; }
.macro-bar__targets .eyebrow { color: var(--teal-dark); font-size: 14px; }
.macro-bar__values { font-size: 18px; color: var(--ink); }
.macro-bar__values b { font-weight: 800; }
.macro-bar__meta { font-size: 14px; color: var(--muted); }
.macro-bar__adjust { min-height: 44px; padding: 10px 20px; font-size: 15px; }
.macro-bar--empty { font-size: 16px; color: var(--ink2); }
.macro-bar--empty .btn--text { padding: 8px 4px; }

.target-delta {
  display: inline-block;
  margin-left: 4px;
  padding: 1px 8px;
  border-radius: var(--radius-pill);
  background: rgba(255, 141, 40, 0.22);
  color: #ffd2a8;
  font-size: 14px;
  font-weight: 700;
}
.target-delta--ok { background: rgba(var(--accent-rgb), 0.22); color: var(--accent); }

/* ==========================================================================
   Screen 7 — Food restriction categories + chips
   ========================================================================== */
.category-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-auto-flow: row dense; /* backfill gaps left when an open card spans the row */
  gap: 16px;
  align-items: start;
}

.category-card {
  position: relative;
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  transition: all var(--t-fast);
}
.category-card:hover { border-color: var(--accent); }
.category-card.has-restrictions { border-color: #f6b4b4; }

/* Open card spans the full row so chips have room */
.category-card.is-open {
  grid-column: 1 / -1;
  border-color: var(--teal);
  box-shadow: var(--shadow-hover);
}

.category-card__header {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 72px;
  padding: 20px;
  background: none;
  border: none;
  border-radius: var(--radius-card);
  text-align: left;
  cursor: pointer;
}

.category-card__icon { font-size: 30px; line-height: 1; flex-shrink: 0; }

.category-card__text { display: flex; flex-direction: column; flex: 1; min-width: 0; }

.category-card__name {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.category-card__count {
  font-size: 14px;
  color: var(--muted);
}

.category-card__chevron {
  font-size: 18px;
  color: var(--teal);
  transition: transform var(--t-fast);
  flex-shrink: 0;
}
.category-card.is-open .category-card__chevron { transform: rotate(180deg); }

/* Red count badge — includes text ("2 avoided") so state isn't color-only */
.restrict-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  background: var(--red);
  color: var(--white);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  flex-shrink: 0;
}
.restrict-badge:empty { display: none; }

/* Accordion panel — animates height via grid rows (200ms) */
.category-card__panel {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 200ms ease;
}
.category-card.is-open .category-card__panel { grid-template-rows: 1fr; }

.category-card__panel-inner {
  overflow: hidden;
  min-height: 0;
}
.category-card.is-open .category-card__panel-inner {
  padding: 0 20px 20px;
  border-top: 1px solid var(--border);
}

.select-all {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 16px 0;
}
.select-all__label { font-size: 16px; font-weight: 600; }

/* Toggle switch used by "Select all" */
.switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 4px;
  background: none;
  border: none;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}
.switch__track {
  position: relative;
  width: 48px;
  height: 28px;
  border-radius: var(--radius-pill);
  background: var(--border);
  transition: background var(--t-fast);
  flex-shrink: 0;
}
.switch__track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--white);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
  transition: transform var(--t-fast);
}
.switch[aria-checked="true"] .switch__track { background: var(--red); }
.switch[aria-checked="true"] .switch__track::after { transform: translateX(20px); }

.subgroup + .subgroup { margin-top: 18px; }
.subgroup__title {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--teal-dark);
  margin-bottom: 10px;
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.food-chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-height: 48px;
  padding: 10px 18px;
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-pill);
  font-size: 16px;
  font-weight: 400;
  color: var(--text);
  cursor: pointer;
  transition: all var(--t-fast);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.food-chip:hover { border-color: var(--light-aqua); background: #f8fdfd; }

/* Restricted — red + × badge (never color alone) */
.food-chip.is-restricted,
.food-chip[aria-pressed="true"] {
  border: 2px solid var(--red);
  background: var(--red-light);
  color: var(--red);
  font-weight: 600;
  padding: 9.5px 30px 9.5px 17.5px;
}
.food-chip.is-restricted::after,
.food-chip[aria-pressed="true"]::after {
  content: '×';
  position: absolute;
  top: -8px;
  right: -6px;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--red);
  color: var(--white);
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
  animation: pop 0.2s ease;
}

.restriction-summary {
  text-align: center;
  font-size: 16px;
  color: var(--muted);
  margin-top: 24px;
}
.restriction-summary strong { color: var(--red); }

/* ==========================================================================
   Screen 9 — Generation
   ========================================================================== */
.gen {
  min-height: calc(100vh - var(--header-h) - var(--progress-h));
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px var(--gutter);
  text-align: center;
}

.gen__content { max-width: 560px; width: 100%; }

.gen__mark {
  width: 96px;
  height: 96px;
  margin: 0 auto 28px;
  border-radius: 50%;
  background: var(--pinstripe), var(--grad);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  color: var(--white);
  animation: pulse 1.8s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1);    box-shadow: 0 0 0 0 rgba(var(--accent-rgb), 0.45); }
  50%      { transform: scale(1.06); box-shadow: 0 0 0 18px rgba(var(--accent-rgb), 0); }
}

.gen__title { font-size: 32px; font-weight: 800; margin-bottom: 10px; }
.gen__sub { font-size: 18px; color: var(--muted); margin-bottom: 36px; }

.gen-steps {
  list-style: none;
  margin: 0 auto;
  padding: 24px 28px;
  max-width: 460px;
  text-align: left;
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
}

.gen-step {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 0;
  font-size: 16px;
  color: var(--muted);
  transition: color var(--t-fast);
}

.gen-step__dot {
  position: relative;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--white);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--white);
  transition: all 0.3s ease;
}

.gen-step[data-status="active"] { color: var(--text); font-weight: 600; }
.gen-step[data-status="active"] .gen-step__dot {
  border-color: var(--aqua);
  border-right-color: transparent;
  animation: spin 0.9s linear infinite;
}

.gen-step[data-status="done"] { color: var(--text); }
.gen-step[data-status="done"] .gen-step__dot {
  border-color: var(--teal-dark);
  background: var(--teal-dark);
}
.gen-step[data-status="done"] .gen-step__dot::after { content: '✓'; }

.gen-step[data-status="error"] { color: var(--red); font-weight: 600; }
.gen-step[data-status="error"] .gen-step__dot { border-color: var(--red); background: var(--red); }
.gen-step[data-status="error"] .gen-step__dot::after { content: '!'; }

.gen__note {
  font-size: 14px;
  color: var(--muted);
  margin-top: 24px;
}

/* Error state */
.alert {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 16px 20px;
  border-radius: var(--radius-card);
  font-size: 16px;
  text-align: left;
}
.alert__icon { font-size: 20px; line-height: 1.3; flex-shrink: 0; }
.alert--error   { background: var(--red-light); border: 1.5px solid #f8c4c4; color: #b42318; }
.alert--success { background: var(--success-bg); border: 1.5px solid #a7e3c9; color: var(--success); }
.alert--info    { background: var(--selected-bg); border: 1.5px solid var(--border); color: var(--text); }

.gen-error { margin-top: 28px; display: flex; flex-direction: column; align-items: center; gap: 20px; }
.gen-error .alert { width: 100%; }

/* ==========================================================================
   Screen 10 — Preview & delivery
   ========================================================================== */
.results {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); /* 60 / 40 */
  gap: 28px;
  align-items: start;
}

.panel {
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
}

.preview-panel { padding: 24px; min-width: 0; }

/* Client summary bar */
.summary-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding: 16px 20px;
  margin-bottom: 20px;
  background: var(--pinstripe), var(--grad);
  color: var(--white);
  border-radius: var(--radius-card);
}
.summary-bar__name { font-size: 20px; font-weight: 700; margin-right: 6px; }
.summary-bar .pill { background: rgba(255, 255, 255, 0.06); color: var(--white); border-color: rgba(var(--accent-rgb), 0.4); white-space: normal; max-width: 100%; }

/* Pills */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
}
.pill--teal { background: var(--selected-bg); color: var(--ink2); border-color: rgba(var(--accent-rgb), 0.35); }

/* Toolbar: servings control */
.preview-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.servings-control {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  font-weight: 600;
}
.servings-control__value {
  min-width: 32px;
  text-align: center;
  font-family: var(--font-accent);
  font-style: italic;
  font-weight: 900;
  font-size: 24px;
  color: var(--teal-dark);
}
.stepper-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1.5px solid rgba(var(--ink-rgb), 0.25);
  background: var(--white);
  color: var(--ink);
  font-size: 22px;
  font-weight: 600;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--t-fast);
}
.stepper-btn:hover:not(:disabled) { background: var(--selected-bg); }
.stepper-btn:disabled { opacity: 0.35; cursor: not-allowed; }

/* Day tabs */
.tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  border-bottom: 1.5px solid var(--border);
  margin-bottom: 20px;
  scrollbar-width: thin;
}
.tab {
  flex: 1 0 auto;
  min-height: 48px;
  padding: 10px 14px;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  margin-bottom: -1.5px;
  font-size: 15px;
  font-weight: 400;
  letter-spacing: 0.04em;
  color: var(--muted);
  transition: all var(--t-fast);
}
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] {
  color: var(--ink);
  font-weight: 700;
  border-bottom-color: var(--accent);
}
.tab--grocery { margin-left: auto; }

.preview-toolbar__note,
.macro-row__note,
.daily-totals__note {
  font-size: 14px;
  color: var(--muted);
}
.macro-row__note { align-self: center; }
.daily-totals__note { margin-left: auto; }

.grocery-intro {
  font-size: 16px;
  color: var(--muted);
  margin-bottom: 16px;
}

/* Meal card */
.meal-card {
  padding: 22px 0;
  border-bottom: 1px solid var(--border);
}
.meal-card:first-child { padding-top: 4px; }
.meal-card:last-child { border-bottom: none; }

.meal-card__label {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--teal-dark);
  margin-bottom: 4px;
}
.meal-card__name {
  font-size: 22px;
  font-weight: 800;
  margin-bottom: 10px;
}

.meta-row,
.macro-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}
.macro-row { margin: 16px 0 0; }

.macro-pill {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  background: var(--selected-bg);
  color: var(--ink2);
  border: 1px solid rgba(var(--accent-rgb), 0.3);
  font-size: 14px;
  font-weight: 600;
}
.macro-pill b { font-weight: 700; color: var(--ink); }

.section-title {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 14px 0 8px;
}

.ingredient-list,
.instruction-list {
  margin: 0;
  padding-left: 22px;
  font-size: 16px;
  line-height: 1.6;
}
.ingredient-list li,
.instruction-list li { margin-bottom: 4px; }
.ingredient-list li::marker { color: var(--teal); }
.instruction-list li::marker { color: var(--teal); font-weight: 700; }

.daily-totals {
  /* navy band like the PDF */
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  margin-top: 20px;
  padding: 14px 20px;
  border-radius: var(--radius-pill);
  background: var(--pinstripe), var(--grad);
  color: var(--white);
  font-size: 16px;
}
.daily-totals__label { font-weight: 600; color: var(--accent); text-transform: uppercase; letter-spacing: 0.14em; font-size: 14px; }
.daily-totals .daily-totals__note { color: rgba(255, 255, 255, 0.6); }

/* Grocery list */
.grocery-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.grocery-cat {
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--white);
}
.grocery-cat__title {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--teal-dark);
  margin-bottom: 8px;
}
.grocery-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-height: 44px;
  padding: 6px 0;
  font-size: 16px;
  cursor: pointer;
}
.grocery-item input[type="checkbox"] {
  width: 22px;
  height: 22px;
  margin: 2px 0 0;
  accent-color: var(--teal);
  flex-shrink: 0;
  cursor: pointer;
}
.grocery-item input:checked + span {
  text-decoration: line-through;
  color: var(--muted);
}

.restriction-notes {
  margin-top: 12px;
  padding: 16px 20px;
  border-left: 4px solid var(--red);
  background: var(--red-light);
  border-radius: 0 var(--radius-card) var(--radius-card) 0;
  font-size: 16px;
}

.protocol-notes {
  margin-top: 20px;
  padding: 16px 20px;
  border-left: 4px solid var(--teal);
  background: var(--selected-bg);
  border-radius: 0 var(--radius-card) var(--radius-card) 0;
  font-size: 16px;
}

/* Delivery card */
.delivery-card {
  position: sticky;
  top: calc(var(--header-h) + var(--progress-h) + 20px);
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.delivery-card__title { font-size: 26px; font-weight: 800; line-height: 1.2; }
.delivery-card__sub { font-size: 16px; color: var(--muted); margin-top: -8px; }

.divider-or {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  color: var(--muted);
  text-transform: lowercase;
}
.divider-or::before,
.divider-or::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.delivery-card__footer {
  display: flex;
  justify-content: center;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

/* ==========================================================================
   Responsive
   Mobile < 600px · Tablet 600–960px · Desktop > 960px
   ========================================================================== */
@media (max-width: 960px) {
  .category-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .results { grid-template-columns: 1fr; }
  .delivery-card { position: static; }
  .hero__title { font-size: 40px; }
}

@media (max-width: 599px) {
  :root { --gutter: 16px; --header-h: 60px; }

  /* Never below 16px on mobile */
  .hero__eyebrow,
  .hero__note,
  .field__hint,
  .field__error,
  .option-card__desc,
  .category-card__count,
  .restrict-badge,
  .subgroup__title,
  .pill,
  .macro-pill,
  .section-title,
  .meal-card__label,
  .gen__note,
  .divider-or,
  .grocery-cat__title,
  .daily-totals__label,
  .preview-toolbar__note,
  .macro-row__note,
  .daily-totals__note,
  .tab { font-size: 16px; }

  .app-header__logo { height: 32px; }
  .hero__logo { height: 56px; margin-bottom: 24px; }
  .app-header__title { max-width: 46vw; }

  .screen__inner { padding: 32px var(--gutter) 48px; }
  .screen-headline { font-size: 26px; }
  .screen-subhead { margin-bottom: 24px; }

  .hero__title { font-size: 34px; }

  .card-grid,
  .card-grid--3,
  .category-grid,
  .grocery-grid,
  .field-row { grid-template-columns: 1fr; }

  .option-card--lg { flex-direction: row; text-align: left; padding: 20px; align-items: center; }
  .option-card--lg.is-selected,
  .option-card--lg[aria-pressed="true"],
  .option-card--lg[aria-checked="true"] { padding: 19px; }
  .option-card--lg .option-card__body { align-items: flex-start; padding-right: 28px; }
  .option-card--lg .option-card__icon { font-size: 36px; }

  .screen-actions .btn--primary { width: 100%; }

  .preview-panel { padding: 16px; }

  .macro-panel { padding: 20px 16px; }
  .screen-note { margin-top: -8px; }
  .toggle-row__hint,
  .plan-warnings p,
  .plan-warnings ul { font-size: 16px; }
  .macro-grid { grid-template-columns: 1fr; }
  .macro-result { grid-template-columns: 1fr; padding: 18px 16px; }
  .macro-result__boxes { grid-template-columns: 1fr; }
  .macro-box { flex-direction: row; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
  .macro-box__label { min-width: 80px; }
  .macro-bar__adjust { width: 100%; min-height: 48px; }
  .eyebrow,
  .macro-warning,
  .macro-note,
  .macro-bar__meta,
  .macro-box__label,
  .macro-box__pct,
  .macro-result__unit,
  .choice-pill small,
  .target-delta { font-size: 16px; }

  /* All 8 tabs visible on phones: two rows of four instead of a hidden scroll */
  .tabs {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    overflow-x: visible;
  }
  .tab { padding: 10px 4px; }
  .tab--grocery { margin-left: 0; grid-column: 1 / -1; }
  .gen__title { font-size: 26px; }
  .gen-steps { padding: 18px 20px; }
}

/* Respect reduced-motion preferences */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
