/* =============================================================
   Pipeline Simulator — design-system-grade styles
   =============================================================
   Uses: tokens.css (semantic colors + typography)
         device-frame-*.css (canonical device frames)
   Layout: cinematic 4-stage stack + 2-axis variation dock
   ============================================================= */

.pipeline-page {
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding-top: 56px;     /* nav clearance */
  font-family: var(--font-sans);
}

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

/* ─── HERO ─── */
.pipe-hero {
  padding: clamp(80px, 11vw, 140px) clamp(20px, 4vw, 48px) clamp(56px, 7vw, 88px);
  background: #08070b;
  color: #f0ece4;
  text-align: center;
  position: relative;
  overflow: hidden;
  isolation: isolate;
}
.pipe-hero__bg {
  position: absolute;
  inset: 0;
  z-index: -2;
  overflow: hidden;
}
.pipe-hero__bg img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 60%;
  opacity: 0.35;
  filter: saturate(0.85) contrast(1.05);
}
.pipe-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse 60% 60% at 30% 30%, rgba(8,7,11,0.4), transparent 65%),
    radial-gradient(ellipse 60% 60% at 70% 70%, rgba(8,7,11,0.6), transparent 65%),
    linear-gradient(180deg, rgba(8,7,11,0.5) 0%, rgba(8,7,11,0.85) 100%);
  pointer-events: none;
}
.pipe-hero__inner {
  position: relative; z-index: 1;
  max-width: 760px; margin: 0 auto;
}
.pipe-hero__eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: rgba(240, 236, 228, 0.55);
  margin: 0 0 24px;
}
.pipe-hero__title {
  font-weight: 500;
  font-size: clamp(28px, 4vw, 48px);
  line-height: 1.15;
  letter-spacing: -1.5px;
  margin: 0 0 20px;
}
.pipe-hero__title em {
  font-style: italic;
  font-weight: 400;
  color: rgba(240, 236, 228, 0.78);
}
.pipe-hero__sub {
  font-size: clamp(15px, 1.15vw, 17px);
  line-height: 1.7;
  color: rgba(240, 236, 228, 0.72);
  margin: 0 0 28px;
  max-width: 640px;
  margin-left: auto;
  margin-right: auto;
}
.pipe-hero__btns {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.pipe-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 22px;
  background: #f0ece4;
  color: #08070b;
  border: none;
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  letter-spacing: -0.1px;
  text-decoration: none;
  transition: background 0.18s var(--ease-hover);
}
.pipe-btn:focus-visible {
  outline: 2px solid var(--color-grammar);
  outline-offset: 2px;
}
.pipe-btn--ghost {
  background: transparent;
  color: #f0ece4;
  border: 1px solid rgba(240,236,228,0.22);
}
@media (hover: hover) and (pointer: fine) {
  .pipe-btn:hover { background: #fff; }
  .pipe-btn--ghost:hover { background: rgba(255,255,255,0.05); border-color: rgba(255,255,255,0.5); }
}
@media (max-width: 520px) {
  .pipe-hero {
    text-align: left;
    padding: 104px 24px 56px;
  }
  .pipe-hero__title {
    font-size: 31px;
    line-height: 1.18;
    letter-spacing: 0;
  }
  .pipe-hero__title em {
    display: block;
   }
  .pipe-hero__sub {
    font-size: 15px;
    line-height: 1.62;
  }
  .pipe-hero__btns {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
  }
  .pipe-btn {
    justify-content: center;
    min-height: 44px;
  }
}

/* ─── HOW TO USE guide ─── */
.pipe-how {
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  padding: clamp(20px, 2.5vw, 28px) clamp(20px, 4vw, 48px);
}
.pipe-how__inner {
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  align-items: flex-start;
  gap: 16px;
}
.pipe-how__step {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  flex: 1;
}
.pipe-how__num {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  background: var(--text);
  color: var(--bg);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  margin-top: 2px;
}
.pipe-how__step p {
  font-size: 14px;
  line-height: 1.55;
  color: var(--text-2);
  margin: 0;
}
.pipe-how__step strong {
  color: var(--text);
  font-weight: 600;
}
.pipe-how__arrow {
  color: var(--text-3);
  font-size: 18px;
  flex-shrink: 0;
  margin-top: 4px;
}
@media (max-width: 640px) {
  .pipe-how__inner {
    flex-direction: column;
    gap: 12px;
  }
  .pipe-how__arrow { display: none; }
}

/* ─── PIPELINE TIMELINE ─── */
.pipe-timeline {
  display: flex;
  justify-content: center;
  gap: 6px;
  padding: 28px clamp(20px, 4vw, 48px) 0;
  flex-wrap: wrap;
}
.timeline-step {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  padding: 7px 12px;
  border: 1px solid var(--border);
  color: var(--text-3);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: border-color 0.3s var(--ease-out-soft), color 0.3s var(--ease-out-soft);
  background: var(--bg);
}
.timeline-step__dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--text-3);
  transition: background-color 0.3s var(--ease-out-soft), box-shadow 0.3s var(--ease-out-soft);
}
.timeline-step.is-active {
  border-color: var(--color-grammar);
  color: var(--text);
  background: var(--chip-blue-bg);
  font-weight: 600;
}
.timeline-step.is-active .timeline-step__dot {
  background: var(--color-grammar);
  width: 8px;
  height: 8px;
  box-shadow: 0 0 0 0 rgba(74, 106, 144, 0.4);
  animation: timeline-pulse 1.6s var(--ease-out-soft) infinite;
}
@keyframes timeline-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(74, 106, 144, 0.5); }
  60%  { box-shadow: 0 0 0 8px rgba(74, 106, 144, 0); }
  100% { box-shadow: 0 0 0 0 rgba(74, 106, 144, 0); }
}
@media (prefers-reduced-motion: reduce) {
  .timeline-step.is-active .timeline-step__dot { animation: none; }
}
.timeline-step.is-done {
  color: var(--text-2);
  border-color: var(--border-hover);
}
.timeline-step.is-done .timeline-step__dot { background: var(--text-2); }

/* ─── CONSOLE LAYOUT (variation dock + main pipeline) ─── */
.pipe-console {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 0;
  max-width: 1640px;
  margin: 0 auto;
}
@media (max-width: 1023px) {
  .pipe-console { grid-template-columns: 1fr; }
}

/* ─── LEFT DOCK: variation controls ─── */
.pipe-dock {
  border-right: 1px solid var(--border);
  padding: clamp(20px, 2.4vw, 28px);
  position: sticky;
  top: 56px;
  align-self: start;
  max-height: calc(100vh - 56px);
  overflow-y: auto;
  background: var(--bg);
}
@media (max-width: 1023px) {
  .pipe-dock {
    position: static;
    max-height: none;
    border-right: none;
    border-bottom: 1px solid var(--border);
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
  }
  .pipe-dock__group { margin-bottom: 0; }
  .pipe-dock__group:first-child { grid-column: 1 / -1; }
  .scenario-picker {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    max-height: 260px;
    overflow-y: auto;
    padding-right: 4px;
  }
}
@media (max-width: 640px) {
  .pipe-timeline {
    justify-content: flex-start;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
  }
  .pipe-timeline::-webkit-scrollbar { display: none; }
  .timeline-step { flex: 0 0 auto; }
  .pipe-dock {
    grid-template-columns: 1fr;
    padding: 20px;
  }
  .pipe-dock__group:first-child { grid-column: auto; }
  .scenario-picker { max-height: 230px; }
  .toggles-dock {
    max-height: 240px;
    overflow-y: auto;
    padding-right: 4px;
  }
  .lens-tab {
    grid-template-columns: 1fr;
    gap: 2px;
  }
}
.pipe-dock__group {
  margin-bottom: 24px;
}
.pipe-dock__group--scenario {
  padding-bottom: 20px;
  border-bottom: 2px solid var(--text);
  margin-bottom: 20px;
}
.pipe-dock__group:last-child { margin-bottom: 0; }
@media (max-width: 1023px) {
  .pipe-dock__group { margin-bottom: 0; }
}
.pipe-dock__heading {
  font-size: 13px;
  font-weight: 600;
  margin: 0 0 4px;
  letter-spacing: -0.1px;
  color: var(--text);
}
.pipe-dock__hint {
  font-size: 12px;
  color: var(--text-3);
  margin: 0 0 12px;
  line-height: 1.55;
}

/* Scenario picker (top of dock) — emphasized */
.scenario-picker {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.scenario-tab {
  text-align: left;
  padding: 12px 14px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-family: var(--font-sans);
  transition: border-color 0.18s var(--ease-hover), background 0.18s var(--ease-hover);
}
@media (hover: hover) and (pointer: fine) {
  .scenario-tab:hover { border-color: var(--text-2); background: var(--bg-2); }
}
.scenario-tab:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}
.scenario-tab.is-active {
  border-color: var(--text);
  background: var(--text);
  color: var(--bg);
}
.scenario-tab__label {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.1px;
}
.scenario-tab__sub {
  font-size: 11px;
  opacity: 0.7;
  font-family: var(--font-mono);
}

/* Device tabs */
.devices-dock {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.dev-tab {
  text-align: left;
  padding: 12px 14px;
  background: transparent;
  border: 1px solid var(--border);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-family: var(--font-sans);
  transition: border-color 0.18s var(--ease-hover), background 0.18s var(--ease-hover);
}
@media (hover: hover) and (pointer: fine) {
  .dev-tab:hover { border-color: var(--text-3); background: var(--bg-2); }
}
.dev-tab:focus-visible {
  outline: 2px solid var(--color-grammar);
  outline-offset: 2px;
}
.dev-tab.is-active {
  border-color: var(--color-grammar);
  background: var(--chip-blue-bg);
}
.dev-tab__label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}
.dev-tab__sub {
  font-size: 11px;
  color: var(--text-3);
}

/* Context toggles · grouped by category */
.toggles-dock {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.toggle-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.toggle-group__heading {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: var(--text-3);
  margin: 0 0 4px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}
.ctx-toggle {
  text-align: left;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-family: var(--font-sans);
  transition: border-color 0.18s var(--ease-hover), background-color 0.18s var(--ease-hover), color 0.18s var(--ease-hover);
}
@media (hover: hover) and (pointer: fine) {
  .ctx-toggle:hover { border-color: var(--text-3); background: var(--bg-2); }
}
.ctx-toggle:focus-visible {
  outline: 2px solid var(--color-intent);
  outline-offset: 2px;
}
.ctx-toggle.is-active {
  border-color: var(--color-intent);
  background: var(--chip-amber-bg);
}
.ctx-toggle__label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}
.ctx-toggle__sub {
  font-size: 11px;
  color: var(--text-3);
}
.ctx-toggle.is-active .ctx-toggle__label { color: var(--chip-amber-text); }

/* Review lens segmented control */
.lens-dock {
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--border);
  background: var(--bg-2);
}
.lens-tab {
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  text-align: left;
  font-family: var(--font-sans);
  transition:
    background-color var(--dur-micro) var(--ease-hover),
    border-color var(--dur-micro) var(--ease-hover),
    color var(--dur-micro) var(--ease-hover);
}
@media (hover: hover) and (pointer: fine) {
  .lens-tab:hover {
    background: var(--bg);
    color: var(--text);
  }
}
.lens-tab:focus-visible {
  outline: 2px solid var(--color-brain);
  outline-offset: 2px;
}
.lens-tab.is-active {
  background: var(--text);
  border-color: var(--text);
  color: var(--bg);
}
.lens-tab__label {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0;
}
.lens-tab__sub {
  font-family: var(--font-mono);
  font-size: var(--text-mono-sm);
  color: inherit;
  opacity: 0.68;
}
@media (max-width: 640px) {
  .lens-tab {
    grid-template-columns: 1fr;
    gap: 2px;
  }
}

/* ─── MAIN PIPELINE ─── */
.pipe-main {
  display: flex;
  flex-direction: column;
}

/* ─── PRODUCT DECISION WORKBENCH ─── */
.decision-workbench {
  padding: clamp(28px, 4vw, 48px) clamp(20px, 4vw, 48px);
  border-bottom: 1px solid var(--border);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--bg-2) 72%, transparent), var(--bg));
}
.decision-workbench__inner {
  max-width: 1080px;
  margin: 0 auto;
}
.decision-workbench__head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 20px;
  align-items: end;
  margin-bottom: 18px;
}
.decision-workbench__eyebrow,
.decision-lens-read__eyebrow,
.decision-metric__label,
.decision-evidence__label {
  display: block;
  font-family: var(--font-mono);
  font-size: var(--text-mono-sm);
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--text-3);
  font-weight: 600;
}
.decision-workbench__eyebrow {
  margin: 0 0 8px;
  color: var(--color-brain);
}
.decision-workbench__title {
  max-width: 760px;
  margin: 0;
  font-size: clamp(24px, 3vw, 36px);
  line-height: 1.12;
  letter-spacing: 0;
  font-weight: 500;
  color: var(--text);
}
.decision-workbench__context {
  margin: 0;
  padding: 8px 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-2);
  font-family: var(--font-mono);
  font-size: var(--text-mono-sm);
  line-height: 1.5;
  max-width: 360px;
}
.decision-workbench__body {
  display: grid;
  gap: 12px;
}
.decision-verdict {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 116px;
  gap: 18px;
  align-items: stretch;
  padding: clamp(18px, 2.3vw, 24px);
  border: 1px solid var(--border);
  background: var(--bg);
  animation: decisionIn var(--dur-base) var(--ease-out-soft) both;
}
.decision-verdict[data-risk="medium"] { border-color: color-mix(in srgb, var(--color-intent) 34%, var(--border)); }
.decision-verdict[data-risk="high"] { border-color: color-mix(in srgb, var(--illust-red) 34%, var(--border)); }
.decision-verdict__main {
  min-width: 0;
}
.decision-verdict__chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  margin-bottom: 12px;
  background: var(--chip-purple-bg);
  color: var(--chip-purple-text);
  font-family: var(--font-mono);
  font-size: var(--text-mono-sm);
  letter-spacing: 0.8px;
  text-transform: uppercase;
  font-weight: 600;
}
.decision-verdict h3 {
  margin: 0 0 8px;
  font-size: clamp(22px, 2.4vw, 30px);
  line-height: 1.16;
  letter-spacing: 0;
  font-weight: 500;
}
.decision-verdict p {
  max-width: 720px;
  margin: 0;
  color: var(--text-2);
  font-size: clamp(15px, 1.1vw, 17px);
  line-height: 1.62;
}
.decision-verdict__score {
  display: grid;
  place-content: center;
  min-height: 112px;
  border-left: 1px solid var(--border);
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.decision-verdict__score span {
  font-family: var(--font-mono);
  font-size: clamp(34px, 4vw, 48px);
  line-height: 1;
  font-weight: 600;
  color: var(--text);
}
.decision-verdict__score small {
  margin-top: 6px;
  color: var(--text-3);
  font-size: var(--text-mono-sm);
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 1px;
}
.decision-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.decision-metric,
.decision-note,
.decision-evidence > div {
  border: 1px solid var(--border);
  background: var(--bg);
}
.decision-metric {
  padding: 14px;
}
.decision-metric strong {
  display: block;
  margin: 6px 0 5px;
  color: var(--text);
  font-size: clamp(20px, 1.9vw, 26px);
  font-weight: 500;
  line-height: 1.15;
}
.decision-metric p {
  margin: 0;
  color: var(--text-2);
  font-size: 14px;
  line-height: 1.55;
}
.decision-lens-read {
  padding: 16px;
  border: 1px solid var(--border);
  background: var(--bg-2);
}
.decision-lens-read__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}
.decision-lens-read__head h3 {
  margin: 3px 0 0;
  font-size: 20px;
  font-weight: 500;
  letter-spacing: 0;
}
.decision-copy {
  min-height: 44px;
  padding: 10px 14px;
  border: 1px solid var(--border-hover);
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition:
    background-color var(--dur-micro) var(--ease-hover),
    border-color var(--dur-micro) var(--ease-hover);
}
@media (hover: hover) and (pointer: fine) {
  .decision-copy:hover {
    background: var(--text);
    color: var(--bg);
    border-color: var(--text);
  }
}
.decision-copy:focus-visible {
  outline: 2px solid var(--color-brain);
  outline-offset: 2px;
}
.decision-lens-read__grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.decision-note {
  padding: 14px;
}
.decision-note span {
  display: block;
  margin-bottom: 8px;
  color: var(--color-grammar);
  font-family: var(--font-mono);
  font-size: var(--text-mono-sm);
  font-weight: 600;
  letter-spacing: 0.5px;
}
.decision-note p {
  margin: 0;
  color: var(--text);
  font-size: 14px;
  line-height: 1.58;
}
.decision-evidence {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 8px;
}
.decision-evidence > div {
  padding: 12px 14px;
}
.decision-evidence p {
  margin: 6px 0 0;
  color: var(--text-2);
  font-size: 14px;
  line-height: 1.55;
}
@keyframes decisionIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@media (max-width: 900px) {
  .decision-workbench__head,
  .decision-verdict,
  .decision-metrics,
  .decision-lens-read__grid,
  .decision-evidence {
    grid-template-columns: 1fr;
  }
  .decision-workbench__context {
    max-width: none;
  }
  .decision-verdict__score {
    min-height: 86px;
    border-left: none;
    border-top: 1px solid var(--border);
  }
}

.stage {
  padding: clamp(40px, 5vw, 72px) clamp(20px, 4vw, 48px);
  border-bottom: 1px solid var(--border);
  opacity: 0.6;
  transition: opacity 0.5s var(--ease-out-soft);
}
.stage.is-active,
.stage.is-done {
  opacity: 1;
}
.stage:last-child { border-bottom: none; }

.stage__inner {
  max-width: 1080px;
  margin: 0 auto;
}
.stage__head {
  display: flex;
  align-items: baseline;
  gap: 14px;
  margin-bottom: clamp(20px, 2.5vw, 32px);
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.stage__num {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  font-weight: 600;
  padding: 4px 10px;
  background: var(--color-grammar);
  color: #fff;
}
.stage--intent .stage__num { background: var(--color-intent); }
.stage--brain .stage__num  { background: var(--color-brain); }
.stage--ui    .stage__num  { background: var(--color-success); }
.stage__title {
  font-weight: 500;
  font-size: clamp(20px, 2.4vw, 28px);
  letter-spacing: -0.5px;
  margin: 0;
  color: var(--text);
}
.stage__subtitle {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 1px;
  color: var(--text-3);
  text-transform: uppercase;
}

/* ─── STAGE 1 — Intent ─── */
.intent-card {
  padding: clamp(24px, 3vw, 36px);
  border: 1px solid var(--border);
  background: var(--bg-feature);
  color: var(--bg-feature-text);
  max-width: 720px;
  position: relative;
}
/* Accent bar via ::before (CLAUDE.md §9.5 — no colored border on rounded rect) */
.intent-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--color-intent);
}
.intent-meta {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--color-intent);
  margin: 0 0 14px;
}
.intent-quote {
  font-size: clamp(20px, 2.4vw, 28px);
  font-weight: 400;
  line-height: 1.4;
  letter-spacing: -0.4px;
  margin: 0 0 12px;
}
.intent-quote::before { content: '"'; color: var(--text-3); margin-right: 4px; }
.intent-quote::after  { content: '"'; color: var(--text-3); margin-left: 4px; }
.intent-context {
  font-size: 14px;
  color: var(--bg-feature-text);
  line-height: 1.65;
  margin: 0;
  opacity: 0.85;
}
.intent-context em { font-style: italic; }

/* ─── STAGE 2 — Tokens ─── */
.tokens-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}
.token-cell {
  padding: 14px;
  border: 1px solid var(--border);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: border-color 0.4s var(--ease-out-soft), background 0.4s var(--ease-out-soft);
}
.token-cell.is-firing {
  border-color: var(--color-grammar);
  background: var(--chip-blue-bg);
}
.token-cell__head {
  display: flex;
  align-items: center;
  gap: 10px;
}
.token-cell__icon {
  width: 32px;
  height: 32px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
  background: var(--bg-3);
}
.token-cell__title-block {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.token-cell__num {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 1px;
  color: var(--text-3);
}
.token-cell__name {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.2px;
  color: var(--text-2);
}
.token-cell__value {
  font-size: 14px;
  color: var(--text);
  font-weight: 500;
  line-height: 1.4;
  margin: 0;
}
.token-cell__signal {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-3);
  margin: 0;
  line-height: 1.5;
}

/* ─── STAGE 3 — Brain · Rules · AX (sub-stages) ─── */
.brain-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
}
@media (max-width: 880px) {
  .brain-grid { grid-template-columns: 1fr; }
}

.brain-column__title,
.rules-column__title,
.ax-column__title {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-3);
  margin: 0 0 12px;
}

/* Brain layer */
.brain-layer {
  padding: 12px 14px;
  border: 1px solid var(--border);
  background: var(--bg);
  margin-bottom: 8px;
  position: relative;
}
.brain-layer::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--color-brain);
}
.brain-layer__name {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--color-brain);
  margin: 0 0 8px;
  font-weight: 600;
}
.brain-layer__signal {
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-2);
  margin: 0 0 4px;
}
.brain-layer__signal.is-highlight {
  color: var(--text);
  font-weight: 500;
}
.brain-layer__signal:last-child { margin-bottom: 0; }

/* Rules list */
.rules-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.rule-row {
  padding: 10px 12px 10px 15px;
  background: var(--bg);
  border: 1px solid var(--border);
  display: grid;
  grid-template-columns: auto auto 1fr;
  gap: 6px 8px;
  align-items: baseline;
  font-size: 12px;
  position: relative;
}
.rule-row::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--color-grammar);
}
.rule-row__name {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--color-grammar);
}
.rule-row__arrow { color: var(--text-3); }
.rule-row__output {
  color: var(--text);
  font-weight: 500;
}
.rule-row__drivers {
  grid-column: 1 / -1;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-3);
  margin-top: 4px;
}

/* AX patterns */
.ax-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ax-row {
  padding: 10px 12px 10px 15px;
  background: var(--chip-blue-bg);
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 4px 10px;
  align-items: baseline;
  font-size: 12px;
  position: relative;
}
.ax-row::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--color-grammar);
}
.ax-row.is-overruled {
  background: var(--bg-2);
  opacity: 0.65;
}
.ax-row.is-overruled::before {
  background: var(--text-3);
}
.ax-row.is-overruled .ax-row__essence {
  font-style: italic;
}
.ax-row__id {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--chip-blue-text);
}
.ax-row__name {
  font-weight: 500;
  color: var(--text);
}
.ax-row__essence {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-3);
}

.intent-test {
  margin-top: 16px;
  padding: 14px 16px 14px 19px;
  background: var(--chip-amber-bg);
  position: relative;
}
.intent-test::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--color-intent);
}
.intent-test__chip {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1.5px;
  color: var(--chip-amber-text);
  margin: 0 0 8px;
}
.intent-test p {
  font-size: 13px;
  line-height: 1.65;
  color: var(--bg-feature-text);
  margin: 0;
}
.intent-test em { font-style: italic; font-weight: 500; }

/* ─── STAGE 4 — UI Output (per device) ─── */
#stage-4-body {
  display: flex;
  justify-content: center;
}
.frame-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: 100%;
}
.frame-meta {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-3);
  margin: 0;
}

/* Inner screen padding (shared) */
.screen-pad {
  padding: 22px 18px;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  gap: 14px;
  font-family: var(--font-sans);
  box-sizing: border-box;
}
.screen-pad--fridge {
  padding: 18px 14px;
  gap: 12px;
}
.screen-pad--ipad { background: linear-gradient(180deg, #fafafa 0%, #f4f4f4 100%); color: var(--bg); }
.samfh__screen { overflow-y: auto; }
.samfh__screen .screen-pad { color: #ededed; }
.samfh__screen .screen-title { font-size: 15px; }
.samfh__screen .screen-header__brand { font-size: 10px; }
.samfh__screen .recipe-card__title { font-size: 12px; line-height: 1.3; }
.samfh__screen .recipe-card__media { aspect-ratio: 4 / 3; }
.samfh__screen .recipe-card__body { padding: 8px 10px; gap: 4px; }
.samfh__screen .recipe-card__meta { font-size: 10px; }

/* ─── Custom Fridge-Screen Frame (Stage 4 fridge surface) ───
   The canonical .samfh shows the WHOLE fridge — content is squished into
   ~25% of the width (the actual screen on the door). For a content-focused
   demo we render just the 21" portrait display.                          */
.fridge-screen-frame {
  width: 100%;
  max-width: 460px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.fridge-screen-frame {
  position: relative;
}
.fridge-screen-frame__bezel {
  position: relative;
  width: 100%;
  aspect-ratio: 9 / 16;
  background: #1a1a1a;
  padding: 14px 12px 16px;
  border-radius: 10px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06), 0 28px 56px -20px rgba(0,0,0,0.45);
  box-sizing: border-box;
}
.fridge-screen-frame__cam {
  position: absolute;
  top: 6px;
  left: 50%;
  transform: translateX(-50%);
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #3a3a3a;
}
.fridge-screen-frame__screen {
  width: 100%;
  height: 100%;
  background:
    radial-gradient(ellipse 80% 40% at 50% 0%, rgba(74, 106, 144, 0.18), transparent 60%),
    linear-gradient(180deg, #14131c 0%, #0a0a0a 100%);
  color: #ededed;
  border-radius: 4px;
  overflow-y: auto;
  overflow-x: hidden;
  transition: filter 0.4s var(--ease-out-soft);
}

/* Dim mode (toggled via state.ui.dim — late-night context) */
.fridge-screen-frame.is-dimmed .fridge-screen-frame__screen {
  filter: brightness(0.7) saturate(0.85);
}
.fridge-screen-frame.is-dimmed::before {
  content: 'LATE MODE';
  position: absolute;
  top: 8px;
  right: 14px;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 1.4px;
  font-weight: 600;
  padding: 3px 7px;
  border: 1px solid rgba(240, 236, 228, 0.32);
  color: rgba(240, 236, 228, 0.72);
  z-index: 1;
}

/* ─── Unified banner system (chip + text · no emoji in functional UI) ─── */
.banner {
  font-family: var(--font-sans);
  font-size: 12px;
  padding: 8px 12px;
  margin: 0;
  line-height: 1.5;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  letter-spacing: -0.05px;
}
.banner__chip {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 1.4px;
  font-weight: 700;
  padding: 3px 7px;
  flex-shrink: 0;
}
.banner--useup {
  background: var(--chip-amber-bg);
  color: var(--chip-amber-text);
}
.banner--useup .banner__chip {
  background: var(--color-intent);
  color: #fff;
}
.banner--shopping {
  background: var(--chip-blue-bg);
  color: var(--chip-blue-text);
}
.banner--shopping .banner__chip {
  background: var(--color-grammar);
  color: #fff;
}
.banner--delivery {
  background: var(--chip-amber-bg);
  color: var(--chip-amber-text);
}
.banner--delivery .banner__chip {
  background: var(--color-intent);
  color: #fff;
}

/* Dark surfaces (fridge screen, no-screen surface) need their own banner palette */
.fridge-screen-frame__screen .banner--useup,
.fridge-screen-frame__screen .banner--delivery {
  background: rgba(184, 138, 74, 0.18);
  color: #e6d2b1;
}
.fridge-screen-frame__screen .banner--shopping {
  background: rgba(74, 106, 144, 0.22);
  color: #c5d4ec;
}
.fridge-screen-frame__caption {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--text-3);
  margin: 0;
  text-align: center;
}
.fridge-screen-frame__screen .screen-pad {
  padding: 16px 14px;
  gap: 12px;
  height: 100%;
}
.fridge-screen-frame__screen .screen-title {
  font-size: 15px;
}
.fridge-screen-frame__screen .screen-header__brand {
  font-size: 10px;
}
.fridge-screen-frame__screen .recipe-card__title {
  font-size: 12px;
  line-height: 1.3;
}
.fridge-screen-frame__screen .recipe-card__media {
  aspect-ratio: 4 / 3;
}
.fridge-screen-frame__screen .recipe-card__body {
  padding: 8px 10px;
  gap: 4px;
}
.fridge-screen-frame__screen .recipe-card__meta {
  font-size: 10px;
}

.screen-header {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px 14px;
  border-bottom: 1px solid currentColor;
  border-bottom-color: rgba(0,0,0,0.08);
  padding-bottom: 10px;
}
.samfh__screen .screen-header { border-bottom-color: rgba(255,255,255,0.12); }
.screen-header__brand {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  font-weight: 600;
  opacity: 0.65;
}
.screen-title {
  font-size: 17px;
  font-weight: 500;
  letter-spacing: -0.2px;
  margin: 0;
  line-height: 1.3;
}
.screen-hint {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.5px;
  margin: 0;
  opacity: 0.55;
  padding-top: 8px;
  border-top: 1px dashed currentColor;
  border-top-color: rgba(0,0,0,0.1);
  text-align: center;
}
.samfh__screen .screen-hint { border-top-color: rgba(255,255,255,0.12); }

/* TV rig (TV + remote side by side) */
.tv-rig {
  display: flex;
  align-items: stretch;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: center;
  width: 100%;
}
.proto-tv {
  flex: 1 1 480px;
  max-width: 640px;
  background: #0a0a0a;
  padding: 12px;
  border-radius: 6px;
  position: relative;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06), 0 24px 48px -20px rgba(0,0,0,0.4);
}
.proto-tv::before {
  content: '';
  position: absolute;
  bottom: -16px; left: 50%;
  transform: translateX(-50%);
  width: 8px; height: 16px;
  background: #1a1a1a;
}
.proto-tv::after {
  content: '';
  position: absolute;
  bottom: -20px; left: 50%;
  transform: translateX(-50%);
  width: 110px; height: 4px;
  background: #1a1a1a;
  border-radius: 2px;
}
.proto-tv__screen {
  background: linear-gradient(180deg, #fafaf6 0%, #f3f0e7 100%);
  color: #1a1816;
  border-radius: 4px;
  min-height: 320px;
}
.proto-tv__screen .screen-pad { padding: 24px 22px; }

.proto-remote {
  flex: 0 0 200px;
  background: #08070b;
  padding: 16px;
  border-radius: 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  color: #f0ece4;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06), 0 12px 28px -16px rgba(0,0,0,0.4);
}
.proto-remote__label {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: rgba(240, 236, 228, 0.55);
  margin: 0;
  text-align: center;
}
.proto-remote__highlight {
  background: rgba(240, 236, 228, 0.08);
  padding: 10px 12px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: center;
  border-left: 2px solid var(--color-success);
  font-size: 12px;
  font-weight: 500;
}
.proto-remote__sub {
  font-family: var(--font-mono);
  font-size: 10px;
  color: rgba(240, 236, 228, 0.6);
}
.proto-dpad {
  display: grid;
  grid-template-columns: repeat(3, 40px);
  grid-template-rows: repeat(3, 40px);
  gap: 4px;
}
.proto-dpad > span {
  background: rgba(240, 236, 228, 0.04);
  border: 1.5px solid rgba(240, 236, 228, 0.1);
  border-radius: 8px;
}
.proto-dpad .dp-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: rgba(240, 236, 228, 0.7);
}
.proto-dpad .dp-btn--ok {
  background: #f0ece4;
  color: #08070b;
  border: none;
  font-weight: 600;
  font-size: 11px;
}

/* Recipe card layouts (per device density) */
.recipe-stack { display: flex; flex-direction: column; gap: 10px; }
.recipe-stack--2col { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.recipe-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.recipe-detail-list { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 580px) {
  .recipe-row, .recipe-detail-list, .recipe-stack--2col { grid-template-columns: 1fr; }
}

/* Recipe card atom — image + body composition */
.recipe-card {
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(0,0,0,0.08);
  display: flex;
  flex-direction: column;
  color: #1a1816;
  overflow: hidden;
  transition: border-color 0.3s var(--ease-out-soft), box-shadow 0.3s var(--ease-out-soft);
}
.samfh__screen .recipe-card { background: rgba(255,255,255,0.96); }
.recipe-card.is-highlighted {
  border-color: var(--color-success);
  box-shadow: 0 0 0 1px var(--color-success);
}
.recipe-card__media {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  background: linear-gradient(135deg, #e8e4dc 0%, #d8d2c4 100%);
  overflow: hidden;
}
.recipe-card__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.recipe-card__pick {
  position: absolute;
  top: 8px;
  left: 8px;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  font-weight: 600;
  padding: 3px 7px;
  background: var(--color-success);
  color: #fff;
}
.recipe-card__body {
  padding: 12px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}
.recipe-card__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.recipe-card__title {
  font-size: 14px;
  font-weight: 500;
  margin: 0;
  letter-spacing: -0.1px;
  line-height: 1.35;
}
.recipe-card__meta {
  font-family: var(--font-mono);
  font-size: 11px;
  color: rgba(26,24,22,0.55);
  margin: 0;
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}
.recipe-card__tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 2px;
}

/* Atom: kcal ring */
.kcal-ring {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.kcal-ring__num {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--stroke, var(--color-success));
}

/* Atom: price badge — keep size constant under emphasis to prevent layout shift */
.price-badge {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  color: rgba(26,24,22,0.7);
  font-variant-numeric: tabular-nums;
}
.price-badge.is-emphasized {
  color: var(--color-intent);
  font-weight: 700;
  /* same size, just bolder + accented — no CLS */
}
.price-badge--free {
  background: var(--chip-green-bg);
  color: var(--chip-green-text);
  padding: 1px 6px;
  border-radius: 2px;
}

/* Atom: kcal num — keep numbers aligned across cards */
.kcal-ring__num {
  font-variant-numeric: tabular-nums;
}
.weight-trend__remaining {
  font-variant-numeric: tabular-nums;
}
.recipe-card__meta {
  font-variant-numeric: tabular-nums;
}

/* Atom: tag chip */
.tag-chip {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 2px 6px;
  background: var(--chip-green-bg);
  color: var(--chip-green-text);
  font-weight: 600;
}

/* Atom: allergen chip */
.allergen-chip {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 2px 6px;
  background: rgba(196, 123, 90, 0.12);
  color: #993820;
  font-weight: 600;
}

/* Atom: vote avatars */
.vote-avatars {
  display: flex;
  gap: 4px;
  margin-left: auto;
}
.avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--bg-2);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
}

/* Atom: weight trend (legacy shallow chip — still referenced by some renderers) */
.weight-trend {
  display: inline-flex;
  flex-direction: column;
  gap: 2px;
  margin-left: auto;
  padding: 4px 10px;
  background: rgba(74, 106, 144, 0.1);
  border: 1px solid rgba(74, 106, 144, 0.25);
}
.weight-trend__label {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 1px;
  font-weight: 600;
  color: var(--color-grammar);
  text-transform: uppercase;
}
.weight-trend__remaining {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-2);
}

/* ─── DEEP HEALTH MODE ─── */

/* Weight tracker card — the headline of health mode */
.weight-tracker {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 16px;
  background: linear-gradient(180deg, rgba(58, 106, 58, 0.18) 0%, rgba(58, 106, 58, 0.06) 100%);
  border: 1px solid rgba(58, 106, 58, 0.28);
  position: relative;
}
.weight-tracker::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--color-success);
}
.weight-tracker__numbers {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
}
.weight-tracker__stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.weight-tracker__stat:last-child { text-align: right; }
.weight-tracker__value {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.4px;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.fridge-screen-frame__screen .weight-tracker__value,
.proto-tv__screen .weight-tracker__value { color: #1a1816; }
.samfh__screen .weight-tracker__value,
.fridge-screen-frame__screen .weight-tracker__value { color: #ededed; }
.weight-tracker__unit {
  font-size: 13px;
  font-weight: 400;
  margin-left: 2px;
  opacity: 0.6;
}
.weight-tracker__caption {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--text-3);
  font-weight: 600;
}
.weight-tracker__spark {
  display: flex;
  align-items: center;
  justify-content: center;
}
.weight-tracker__pace {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.3px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--text-2);
  margin: 0;
  font-variant-numeric: tabular-nums;
}
.fridge-screen-frame__screen .weight-tracker__pace,
.fridge-screen-frame__screen .weight-tracker__caption {
  color: rgba(240, 236, 228, 0.7);
}

/* Meal budget header */
.meal-budget {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 14px;
  background: rgba(74, 106, 144, 0.08);
  border-left: 3px solid var(--color-grammar);
}
.meal-budget__row {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.3px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 6px;
  align-items: baseline;
  font-variant-numeric: tabular-nums;
}
.meal-budget__used {
  color: var(--color-grammar);
  font-weight: 600;
  margin-left: auto;
}
.meal-budget__sep { color: var(--text-3); }
.meal-budget__bar {
  position: relative;
  width: 100%;
  height: 6px;
  background: rgba(0, 0, 0, 0.08);
  overflow: hidden;
  border-radius: 3px;
}
.fridge-screen-frame__screen .meal-budget__bar { background: rgba(255,255,255,0.1); }
.meal-budget__bar-used,
.meal-budget__bar-tonight {
  position: absolute;
  top: 0;
  height: 100%;
  border-radius: 3px;
}
.meal-budget__bar-used {
  left: 0;
  background: var(--color-grammar);
  opacity: 0.85;
}
.meal-budget__bar-tonight {
  background: var(--color-success);
  opacity: 0.95;
}
.meal-budget__tonight {
  font-size: 13px;
  font-weight: 500;
  margin: 0;
  letter-spacing: -0.2px;
}
.meal-budget__tonight strong {
  font-family: var(--font-mono);
  color: var(--color-success);
  font-size: 15px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.meal-budget__sub {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 400;
  color: var(--text-3);
  margin-left: 4px;
}
.fridge-screen-frame__screen .meal-budget__row,
.fridge-screen-frame__screen .meal-budget__tonight {
  color: rgba(240, 236, 228, 0.92);
}
.fridge-screen-frame__screen .meal-budget__used { color: #8aa9d4; }
.fridge-screen-frame__screen .meal-budget__sub { color: rgba(240, 236, 228, 0.5); }

/* Sparkline svg */
.spark { display: block; }

/* Recipe card · health mode */
.recipe-card--health-mode .recipe-card__media {
  position: relative;
}
.kcal-badge {
  position: absolute;
  bottom: 8px;
  right: 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.4px;
  padding: 4px 8px;
  background: rgba(255, 255, 255, 0.95);
  color: #1a1816;
  border-radius: 0;
  font-variant-numeric: tabular-nums;
}
.kcal-badge--under  { background: var(--color-success); color: #fff; }
.kcal-badge--close  { background: var(--color-intent);  color: #fff; }
.kcal-badge--over   { background: #993820;              color: #fff; }

/* Macro bars — wrap with inline legend (no absolute overlap) */
.macro-bars-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.macro-bars {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 6px;
  background: rgba(0, 0, 0, 0.08);
  border-radius: 3px;
  overflow: hidden;
}
.fridge-screen-frame__screen .macro-bars { background: rgba(255,255,255,0.12); }
.macro-bar {
  height: 100%;
  width: calc(var(--w) * 1%);
  display: block;
}
.macro-bar--p { background: var(--color-grammar); }
.macro-bar--f { background: var(--color-intent); }
.macro-bar--c { background: var(--color-brain); }
.macro-bars__legend {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.5px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}
.fridge-screen-frame__screen .macro-bars__legend { color: rgba(240,236,228,0.55); }
.recipe-card--health-mode .recipe-card__body { gap: 10px; }

/* Fit chip */
.fit-chip {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 2px 6px;
  font-weight: 600;
}
.fit-chip--under { background: var(--chip-green-bg); color: var(--chip-green-text); }
.fit-chip--close { background: var(--chip-amber-bg); color: var(--chip-amber-text); }
.fit-chip--over  { background: rgba(196, 123, 90, 0.15); color: #993820; }

/* Card outline reflects fit */
.recipe-card--fit-under  { border-color: rgba(58, 106, 58, 0.45); }
.recipe-card--fit-close  { border-color: rgba(122, 85, 32, 0.4); }
.recipe-card--fit-over   { border-color: rgba(153, 56, 32, 0.4); opacity: 0.92; }

/* Health footnote */
.health-footnote {
  font-size: 12px;
  font-style: italic;
  color: var(--text-2);
  margin: 6px 0 0;
  text-align: center;
}
.fridge-screen-frame__screen .health-footnote { color: rgba(240, 236, 228, 0.7); }

/* Atom: use-up banner */
.use-up-banner {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.5px;
  padding: 8px 12px;
  background: rgba(122, 85, 32, 0.12);
  color: var(--color-intent);
  font-weight: 600;
  margin: 0;
}

/* Allergen warning banner (top of screen) */
.allergen-warning {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.5px;
  padding: 8px 12px;
  background: rgba(153, 56, 32, 0.1);
  color: #993820;
  font-weight: 600;
  margin: 0;
}

/* iPad has its own background */
.ipad11__screen { background: #fafafa; }

/* ─── FLIP transitions ─── */
.is-fading-in {
  animation: fade-in 0.4s var(--ease-out-soft);
}
@keyframes fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

/* ─── FOOTER ─── */
.pipe-foot {
  border-top: 1px solid var(--border);
  padding: 32px clamp(20px, 4vw, 48px);
  text-align: center;
  font-size: 12px;
  color: var(--text-3);
  line-height: 1.7;
}
.pipe-foot__breadcrumb {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.pipe-foot__breadcrumb a { color: var(--text-3); text-decoration: none; }
.pipe-foot__breadcrumb a:hover { color: var(--text); }
.pipe-foot p { margin: 0; }
.pipe-foot a { color: var(--text-2); text-decoration: underline; text-underline-offset: 2px; }
.pipe-foot a:hover { color: var(--text); }

/* ─── PHONE SURFACE (iPhone 15 Pro canonical frame) ─── */
.stage--ui .iphone15pro--lg {
  --iphone-w: 320px;
}
.iphone15pro__screen {
  background: linear-gradient(180deg, #fafaf6 0%, #f3f0e7 100%);
  color: #1a1816;
}
.screen-pad--phone {
  padding: 18px 14px;
  gap: 12px;
}
.screen-pad--phone .screen-title {
  font-size: 15px;
}
.screen-pad--phone .recipe-card {
  display: grid;
  grid-template-columns: 70px 1fr;
  gap: 0;
}
.screen-pad--phone .recipe-card__media {
  aspect-ratio: 1 / 1;
  border-right: 1px solid rgba(0,0,0,0.08);
}
.screen-pad--phone .recipe-card__body {
  padding: 10px 12px;
  gap: 4px;
}
.screen-pad--phone .recipe-card__title { font-size: 13px; }
.screen-pad--phone .recipe-card__meta { font-size: 10px; }
.screen-pad--phone .recipe-card__pick {
  font-size: 8px;
  padding: 2px 5px;
  top: 4px;
  left: 4px;
}
.screen-pad--phone .kcal-badge {
  font-size: 9px;
  padding: 2px 5px;
  bottom: 4px;
  right: 4px;
}
.screen-pad--phone .macro-bars { display: none; }
.screen-pad--phone .recipe-stack { gap: 8px; }

/* One-thumb mode: bottom-anchored thumb arc */
.iphone15pro.is-thumb .iphone15pro__screen {
  background: linear-gradient(180deg, #f3f0e7 0%, #fafaf6 100%);
}
.screen-pad--thumb {
  justify-content: flex-end;
  padding-bottom: 28px;
}
.screen-pad--thumb .screen-header { opacity: 0.55; }
.screen-pad--thumb .recipe-card {
  grid-template-columns: 90px 1fr;
}
.screen-pad--thumb .recipe-card__title { font-size: 14px; }
.screen-pad--thumb .recipe-card__media { aspect-ratio: 1 / 1; }
.screen-pad--thumb .recipe-stack { gap: 10px; }
.screen-pad--thumb .screen-hint {
  font-weight: 600;
  font-size: 11px;
  color: var(--color-grammar);
  background: var(--chip-blue-bg);
  padding: 8px 12px;
  margin-top: 6px;
}

/* ─── Apple Watch frame (wind-down scenario) ─── */
.watch-frame {
  display: flex;
  justify-content: center;
  padding: 24px;
}
.watch-frame__chrome {
  position: relative;
  width: 220px;
  aspect-ratio: 1 / 1.18;
  background: #08070b;
  border-radius: 38px;
  padding: 14px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06), 0 28px 56px -20px rgba(0,0,0,0.45);
  box-sizing: border-box;
}
.watch-frame__crown {
  position: absolute;
  top: 22%;
  right: -5px;
  width: 8px;
  height: 28px;
  background: #2a2a2a;
  border-radius: 0 4px 4px 0;
}
.watch-frame__btn {
  position: absolute;
  top: 50%;
  right: -3px;
  width: 4px;
  height: 36px;
  background: #2a2a2a;
  border-radius: 0 2px 2px 0;
}
.watch-frame__screen {
  width: 100%;
  height: 100%;
  background: linear-gradient(180deg, #1a1410 0%, #0a0a0a 100%);
  color: #f0ece4;
  border-radius: 28px;
  padding: 20px 16px 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  text-align: center;
  box-sizing: border-box;
}
.watch-frame__time {
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0.5px;
  margin: 0;
  color: rgba(240, 236, 228, 0.7);
  font-variant-numeric: tabular-nums;
}
.watch-frame__title {
  font-size: 14px;
  font-weight: 500;
  margin: 4px 0;
  line-height: 1.3;
  letter-spacing: -0.2px;
}
.watch-frame__meta {
  font-family: var(--font-mono);
  font-size: 10px;
  color: rgba(240, 236, 228, 0.55);
  margin: 0;
}
.watch-frame__actions {
  display: flex;
  gap: 6px;
  width: 100%;
  margin-top: 6px;
}
.watch-frame__btn-yes,
.watch-frame__btn-later {
  flex: 1;
  padding: 8px 6px;
  background: transparent;
  border: 1px solid rgba(240, 236, 228, 0.2);
  color: #f0ece4;
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  border-radius: 4px;
}
.watch-frame__btn-yes {
  background: var(--color-success);
  border-color: var(--color-success);
}
.watch-frame__btn-later {
  background: transparent;
  color: rgba(240, 236, 228, 0.65);
}

/* ─── NO-SCREEN SURFACE (earphones / voice-only) ─── */
.no-screen-surface {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  width: 320px;
  aspect-ratio: 9 / 16;
  background: #08070b;
  color: #f0ece4;
  border-radius: 36px;
  text-align: center;
  padding: 40px 28px;
  box-sizing: border-box;
  position: relative;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06), 0 28px 56px -20px rgba(0,0,0,0.45);
}
.no-screen-surface--audio {
  background: radial-gradient(ellipse 80% 60% at 50% 30%, #1a1a2a 0%, #0a0a14 100%);
}
.no-screen-surface--voice {
  background: radial-gradient(ellipse 80% 60% at 50% 30%, #2a1f1a 0%, #14100a 100%);
  color: #f5e6d3;
}
.no-screen-surface__icon {
  font-size: 48px;
  line-height: 1;
}
.no-screen-surface__mode {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: rgba(240, 236, 228, 0.55);
  margin: 0;
}
.no-screen-surface--voice .no-screen-surface__mode {
  color: rgba(245, 230, 211, 0.55);
}
.no-screen-surface__instruction {
  font-size: 15px;
  line-height: 1.5;
  margin: 0;
  letter-spacing: -0.1px;
}
.no-screen-surface__instruction strong {
  color: #fff;
  font-weight: 600;
}
.no-screen-surface__sub {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.6px;
  color: rgba(240, 236, 228, 0.4);
  margin: 0;
}
.no-screen-surface__waves {
  display: flex;
  gap: 4px;
  align-items: center;
  height: 24px;
  margin-top: 4px;
}
.no-screen-surface__waves span {
  width: 3px;
  height: 100%;
  background: rgba(240, 236, 228, 0.7);
  border-radius: 2px;
  animation: nss-wave 1.4s ease-in-out infinite alternate;
}
.no-screen-surface__waves span:nth-child(2) { animation-delay: 0.2s; }
.no-screen-surface__waves span:nth-child(3) { animation-delay: 0.4s; }
@keyframes nss-wave {
  0%   { transform: scaleY(0.3); }
  100% { transform: scaleY(1); }
}

/* Reduced motion — targeted (no nuclear * !important) */
@media (prefers-reduced-motion: reduce) {
  .stage,
  .timeline-step,
  .timeline-step__dot,
  .token-cell,
  .recipe-card,
  .pattern-fired,
  .device,
  .preview-stage *,
  .pipe-btn,
  .dev-tab,
  .ctx-toggle,
  .lens-tab,
  .decision-verdict,
  .decision-copy,
  .no-screen-surface__waves span,
  .ai-card__voice-wave span,
  .diff-chip,
  .framework-decisions {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ─── Framework decisions: diff chips + summary banner ────────────────────
   Stage 4 needs to make the framework's named moves *legible*. Every toggle
   fires rules that add / re-rank / rewrite / hide cards — without explicit
   chips the viewer just sees "different output" and never connects it back
   to the rule engine. These chips bridge that gap.
   Chip taxonomy: ADDED · CHANGED · PROMOTED · SORTED · HIDDEN (summary only)
*/
.diff-chip {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 3;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  font-weight: 600;
  padding: 3px 7px;
  border-radius: 2px;
  line-height: 1.3;
  background: rgba(20, 18, 14, 0.86);
  color: #fff;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: diffChipIn 360ms cubic-bezier(0.2, 0.8, 0.2, 1.0) both;
  white-space: nowrap;
  pointer-events: none;
}
.diff-chip--added    { background: var(--color-success);   color: #fff; }
.diff-chip--changed  { background: var(--color-grammar);   color: #fff; }
.diff-chip--promoted { background: var(--color-intent);    color: #fff; }
.diff-chip--sorted   { background: var(--color-brain);     color: #fff; }

/* Card itself becomes the positioning context so the chip sits inside it */
.recipe-card { position: relative; }

/* Subtle outer ring on the card itself, matched to the chip color, so the
   chip + card read as one decision unit. Only on cards where decisions fire. */
.recipe-card--diff-added    { box-shadow: 0 0 0 1.5px var(--color-success) inset, 0 1px 2px rgba(20,18,14,0.05); }
.recipe-card--diff-changed  { box-shadow: 0 0 0 1.5px var(--color-grammar) inset, 0 1px 2px rgba(20,18,14,0.05); }
.recipe-card--diff-promoted { box-shadow: 0 0 0 1.5px var(--color-intent)  inset, 0 1px 2px rgba(20,18,14,0.05); }
.recipe-card--diff-sorted   { box-shadow: 0 0 0 1.5px var(--color-brain)   inset, 0 1px 2px rgba(20,18,14,0.05); }

@keyframes diffChipIn {
  0%   { opacity: 0; transform: translateY(-4px) scale(0.92); }
  60%  { opacity: 1; transform: translateY(0) scale(1.04); }
  100% { opacity: 1; transform: translateY(0) scale(1.0); }
}

/* Top-of-Stage4 summary — reads like a verdict line above the screen title */
.framework-decisions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px;
  margin: 0 0 10px;
  border-radius: 6px;
  background: linear-gradient(180deg, rgba(104, 137, 180, 0.06) 0%, rgba(104, 137, 180, 0.02) 100%);
  border-left: 2px solid var(--color-grammar);
  font-family: var(--font-sans);
  animation: diffChipIn 320ms cubic-bezier(0.2, 0.8, 0.2, 1.0) both;
}
.framework-decisions--quiet {
  background: rgba(20, 18, 14, 0.03);
  border-left-color: var(--gray-400, #b0a89c);
}
.framework-decisions__chip {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--color-grammar);
}
.framework-decisions--quiet .framework-decisions__chip { color: var(--gray-700, #5a544c); }
.framework-decisions__msg {
  font-size: 12px;
  color: var(--gray-700, #5a544c);
}
.framework-decisions__stats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  align-items: baseline;
}
.fwd-stat {
  font-size: 11.5px;
  color: var(--gray-800, #3a3630);
  font-feature-settings: 'tnum';
  font-variant-numeric: tabular-nums;
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
}
.fwd-stat b {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 2px;
  color: #fff;
  line-height: 1.4;
}
.fwd-stat--added    b { background: var(--color-success); }
.fwd-stat--changed  b { background: var(--color-grammar); }
.fwd-stat--promoted b { background: var(--color-intent); }
.fwd-stat--sorted   b { background: var(--color-brain); }
.fwd-stat--hidden   b { background: var(--gray-800, #3a3630); }

.framework-decisions__hidden {
  font-size: 11.5px;
  color: var(--gray-700, #5a544c);
  margin-top: 2px;
}
.framework-decisions__hidden summary {
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--gray-700, #5a544c);
  list-style: none;
  padding: 2px 0;
  user-select: none;
}
.framework-decisions__hidden summary::-webkit-details-marker { display: none; }
.framework-decisions__hidden summary::before {
  content: '▸ ';
  display: inline-block;
  transition: transform 180ms ease;
}
.framework-decisions__hidden[open] summary::before { content: '▾ '; }
.framework-decisions__hidden ul {
  list-style: none;
  padding: 6px 0 2px;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.framework-decisions__hidden li { line-height: 1.45; }
.framework-decisions__hidden .strike {
  text-decoration: line-through;
  text-decoration-thickness: 1px;
  color: var(--gray-600, #786f63);
}
.framework-decisions__hidden em {
  color: var(--gray-600, #786f63);
  font-style: normal;
}

/* Surface-specific tweaks — Fridge cards are media-rich, chip stays on photo.
   For TV (cast), keep chip prominent. iPad list-view cards may not have media
   on every item — the diff-anchor fallback positions it correctly. */
.tv-rig .diff-chip,
.fridge-screen-frame__screen .diff-chip {
  font-size: 10px;
  padding: 4px 8px;
}

/* When a card is media-less (no .recipe-card__media), the body needs padding
   on the right so the chip doesn't overlap the title. */
.recipe-card:not(:has(.recipe-card__media)) .recipe-card__body { padding-right: 80px; }
@supports not (selector(:has(*))) {
  /* Conservative fallback: extra right padding on iPad detail-list cards */
  .recipe-detail-list .recipe-card .recipe-card__body { padding-right: 80px; }
}

/* ─────────────────────────────────────────────
   Checklist — expandable section below simulator
   ───────────────────────────────────────────── */
.pipe-checklist-wrap {
  max-width: 860px;
  margin: 0 auto;
  padding: 0 24px 48px;
}

.pipe-checklist {
  border-top: 1px solid var(--border);
}

.pipe-checklist__toggle {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 20px 0;
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.pipe-checklist__toggle::-webkit-details-marker { display: none; }

.pipe-checklist__label {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text);
}

.pipe-checklist__sub {
  font-size: 13px;
  color: var(--text-3);
  flex: 1;
}

.pipe-checklist__arrow {
  font-size: 12px;
  color: var(--text-3);
  transition: transform .25s ease;
}
.pipe-checklist[open] .pipe-checklist__arrow {
  transform: rotate(180deg);
}

.pipe-checklist__body {
  padding-bottom: 40px;
}

.pipe-checklist__legend {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  padding: 12px 16px;
  background: var(--bg-2);
  border-radius: 6px;
  margin-bottom: 28px;
  font-size: 13px;
  color: var(--text-2);
}
.pipe-checklist__legend b { color: var(--color-brand); margin-right: 4px; }
.pipe-checklist__rule {
  width: 100%;
  font-style: italic;
  color: var(--text-3);
  font-size: 12px;
}

.pipe-checklist__list {
  display: grid;
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  padding: 0;
  list-style: none;
  counter-reset: checklist;
}

.pipe-checklist__list li {
  background: var(--bg);
  padding: 16px 20px;
  counter-increment: checklist;
}

.pipe-checklist__list li b {
  display: inline-block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}
.pipe-checklist__list li b::before {
  content: counter(checklist, decimal-leading-zero) " · ";
  font-family: var(--font-mono);
  font-weight: 400;
  color: var(--text-3);
  font-size: 11px;
  margin-right: 4px;
}

.pipe-checklist__list li p {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.6;
  margin: 0;
}
