/* Storytellrs by MagicLabs.ai — B2B Demo Design System v3
   Light theme · Spectral + Figtree · OKLCH violet-tinted neutrals
   ──────────────────────────────────────────────────────────────────────────── */

@import url('https://fonts.googleapis.com/css2?family=Spectral:ital,wght@0,400;0,600;0,700;1,400;1,600&family=Figtree:wght@400;500;600;700;800&display=swap');

/* ── Tokens ────────────────────────────────────────────────────────────────── */
:root {
  /* Backgrounds — OKLCH, all neutrals tinted toward brand violet (hue 277) */
  --canvas:    oklch(97.2% 0.006 277);
  --surface:   oklch(99%   0.003 277);
  --surface-2: oklch(95%   0.010 277);
  --surface-3: oklch(93%   0.013 277);

  /* Borders */
  --border:     oklch(91%  0.012 277);
  --border-mid: oklch(88%  0.016 277);

  /* Core accent: indigo */
  --primary:       oklch(48%  0.195 277);
  --primary-hover: oklch(43%  0.195 277);
  --primary-dim:   oklch(94%  0.040 277);
  --primary-glow:  oklch(82%  0.080 277);

  /* Violet */
  --accent:      oklch(44%  0.195 300);
  --accent-dim:  oklch(94%  0.035 300);
  --accent-glow: oklch(82%  0.070 300);

  /* Pink — used sparingly */
  --pink:     oklch(62%  0.18  350);
  --pink-dim: oklch(94%  0.04  350);
  --sky:      oklch(70%  0.13  225);

  /* Dark section surfaces */
  --dark:         oklch(11%  0.025 277);
  --dark-surface: oklch(16%  0.025 277);
  --dark-border:  oklch(22%  0.030 277);

  /* Backward-compat aliases (wizard.js inline styles reference these) */
  --olive:       oklch(48%  0.195 277);
  --olive-dim:   oklch(94%  0.040 277);
  --olive-glow:  oklch(82%  0.080 277);
  --purple:      oklch(44%  0.195 300);
  --purple-dim:  oklch(94%  0.035 300);
  --purple-glow: oklch(82%  0.070 300);
  --cream:       oklch(16%  0.025 277);  /* legacy → primary text */

  /* Text */
  --text-primary:   oklch(16%  0.025 277);
  --text-secondary: oklch(40%  0.020 277);
  --text-muted:     oklch(62%  0.012 277);

  /* Typography — Spectral (editorial serif) + Figtree (humanist geometric) */
  --font-display: 'Spectral', Georgia, serif;
  --font-body:    'Figtree', system-ui, sans-serif;
  --font-mono:    'Figtree', system-ui, sans-serif;

  /* Radii */
  --radius-sm: 10px;
  --radius:    16px;
  --radius-lg: 20px;
  --radius-xl: 28px;

  /* Timing — ease-out-quart (no bounce) */
  --transition:      200ms cubic-bezier(0.25, 0, 0, 1);
  --transition-slow: 380ms cubic-bezier(0.25, 0, 0, 1);

  /* Phase colours */
  --phase-1: oklch(58%  0.170 250);
  --phase-2: oklch(56%  0.160 168);
  --phase-3: oklch(72%  0.160  75);
  --phase-4: oklch(48%  0.195 277);
  --phase-5: oklch(62%  0.180 350);
  --phase-6: oklch(44%  0.195 300);

  /* Shadows */
  --shadow-card:       0 1px 2px oklch(0% 0 0 / 0.05), 0 8px 24px oklch(48% 0.195 277 / 0.05);
  --shadow-card-hover: 0 2px 8px oklch(0% 0 0 / 0.07), 0 12px 28px oklch(48% 0.195 277 / 0.09);

  /* Wizard: one number for content padding, toast offset, and footer stack */
  --wizard-footer-stack: 5.5rem;
  --wizard-toast-gap: 0.625rem;
}

/* ── Reset ─────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-font-smoothing: antialiased; }
body {
  font-family: var(--font-body);
  background: var(--canvas);
  color: var(--text-primary);
  min-height: 100dvh;
  overflow-x: hidden;
}

/* Wizard — header rail + single footer: shared tokens for scroll padding & toasts */
body.btob-wizard {
  padding-top: 56px;
  padding-bottom: max(
    var(--wizard-footer-stack),
    calc(env(safe-area-inset-bottom, 0px) + 3.25rem)
  );
}
body.btob-wizard .btob-page {
  padding-bottom: 3.5rem;
}
@media (min-width: 601px) {
  body.btob-wizard .btob-page { padding-bottom: 4.5rem; }
}

/* ── Subtle atmospheric glow (wizard/dashboard only) ────────────────────────── */
.btob-spotlight {
  position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden;
}
.btob-spotlight::before {
  content: '';
  position: absolute;
  width: 900px; height: 900px;
  background: radial-gradient(ellipse at 65% 30%, oklch(88% 0.05 277 / 0.5) 0%, transparent 65%);
  top: -200px; right: -150px;
  border-radius: 50%;
}
.btob-spotlight::after {
  content: '';
  position: absolute;
  width: 600px; height: 600px;
  background: radial-gradient(ellipse at 35% 65%, oklch(82% 0.05 350 / 0.28) 0%, transparent 60%);
  bottom: -100px; left: -100px;
  border-radius: 50%;
}

/* ── Typography ────────────────────────────────────────────────────────────── */
.t-display {
  font-family: var(--font-display);
  font-size: clamp(2.25rem, 5.5vw, 3.75rem);
  line-height: 1.1;
  letter-spacing: -.02em;
  color: var(--text-primary);
}
.t-display-sm {
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 3.5vw, 2.5rem);
  line-height: 1.15;
  letter-spacing: -.015em;
  color: var(--text-primary);
}
.t-display-italic {
  font-family: var(--font-display);
  font-style: italic;
  font-size: clamp(1.6rem, 3.5vw, 2.5rem);
  line-height: 1.15;
  letter-spacing: -.015em;
  color: var(--text-primary);
}
.t-label {
  font-family: var(--font-mono);
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.t-body { font-size: .9375rem; line-height: 1.7; color: var(--text-secondary); }
.t-body-sm { font-size: .8125rem; line-height: 1.65; color: var(--text-secondary); }

/* Text accent (solid for readability) */
.t-accent { color: var(--primary); }

/* ── Cards / surfaces ──────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  box-shadow: var(--shadow-card);
}
.card-sm {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow-card);
}
.card-hover {
  transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
  cursor: pointer;
}
.card-hover:hover {
  transform: translateY(-2px) scale(1.005);
  border-color: var(--border-mid);
  box-shadow: var(--shadow-card-hover);
}
.card-glow-olive {
  border-color: oklch(48% 0.195 277 / 0.25);
  box-shadow: var(--shadow-card), 0 0 0 2px oklch(48% 0.195 277 / 0.06);
}
.card-glow-purple {
  border-color: oklch(44% 0.195 300 / 0.25);
  box-shadow: var(--shadow-card), 0 0 0 2px oklch(44% 0.195 300 / 0.06);
}

/* Glass card variant */
.card-glass {
  background: rgba(255,255,255,.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,.8);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  box-shadow: var(--shadow-card);
}

/* ── Gradient card accent strip ────────────────────────────────────────────── */
.card-accent {
  position: relative;
  overflow: hidden;
}
.card-accent::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), var(--accent), var(--pink));
}

/* ── Pill CTAs ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: .5rem;
  font-family: var(--font-body); font-size: .875rem; font-weight: 600;
  border: none; border-radius: 100px;
  cursor: pointer; outline: none;
  transition: transform var(--transition), box-shadow var(--transition), background var(--transition);
  text-decoration: none;
  white-space: nowrap;
}
.btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
}
.btn-primary {
  background: var(--primary);
  color: oklch(99% 0.003 277);
  padding: .75rem 1.75rem;
  box-shadow: 0 1px 4px oklch(48% 0.195 277 / 0.2);
}
.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 20px oklch(48% 0.195 277 / 0.32);
}
.btn-dark {
  background: var(--dark);
  color: oklch(96% 0.006 277);
  padding: .85rem 2rem;
}
.btn-dark:hover {
  background: var(--dark-surface);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px oklch(0% 0 0 / 0.25);
}
.btn-secondary {
  background: var(--surface);
  color: var(--text-primary);
  padding: .75rem 1.5rem;
  border: 1px solid var(--border-mid);
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.btn-secondary:hover {
  background: var(--surface-2);
  border-color: oklch(48% 0.195 277 / 0.25);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px oklch(48% 0.195 277 / 0.1);
}
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  padding: .65rem 1.25rem;
}
.btn-ghost:hover { color: var(--primary); }
.btn-purple {
  background: var(--accent);
  color: oklch(99% 0.003 277);
  padding: .75rem 1.75rem;
  box-shadow: 0 1px 4px oklch(44% 0.195 300 / 0.2);
}
.btn-purple:hover {
  background: oklch(39% 0.195 300);
  transform: translateY(-1px);
  box-shadow: 0 4px 20px oklch(44% 0.195 300 / 0.32);
}
.btn-lg { padding: 1rem 2.25rem; font-size: 1rem; }
.btn-sm { padding: .5rem 1.1rem; font-size: .8rem; }
.btn-icon { padding: .65rem; border-radius: 50%; }

/* ── Chips / tags ──────────────────────────────────────────────────────────── */
.chip {
  display: inline-flex; align-items: center; gap: .35rem;
  font-size: .75rem; font-weight: 600;
  padding: .3rem .75rem;
  border-radius: 100px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: default;
}
.chip-olive  { background: var(--primary-dim); border-color: oklch(48% 0.195 277 / 0.2); color: var(--primary); }
.chip-purple { background: var(--accent-dim);  border-color: oklch(44% 0.195 300 / 0.2); color: var(--accent); }
.chip-active { background: var(--primary-dim); border-color: oklch(48% 0.195 277 / 0.25); color: var(--primary); cursor: pointer; }
.chip-selectable { cursor: pointer; transition: background var(--transition), border-color var(--transition); }
.chip-selectable:hover { border-color: oklch(48% 0.195 277 / 0.25); background: var(--primary-dim); }
.chip-selectable.selected { background: var(--primary-dim); border-color: oklch(48% 0.195 277 / 0.3); color: var(--primary); }

/* ── Wizard Progress Rail (fixed: sticky breaks when body has overflow-x) ── */
.wizard-rail {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  background: oklch(97.2% 0.006 277 / 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0 2rem;
}
.wizard-rail-inner {
  max-width: 1200px; margin: 0 auto;
  display: flex; align-items: center; gap: 0;
  height: 56px;
}
.rail-brand {
  font-family: var(--font-display);
  font-size: .95rem;
  color: var(--text-primary);
  white-space: nowrap;
  margin-right: 1.25rem;
  padding-right: 1.25rem;
  border-right: 1px solid var(--border);
  flex-shrink: 0;
  display: flex; align-items: center; gap: .35rem;
}
.rail-brand-star { color: var(--primary); font-size: 1rem; }
.rail-steps {
  display: flex; align-items: center; gap: 0;
  flex: 1; overflow: hidden;
}
.rail-step {
  display: flex; align-items: center; gap: .5rem;
  padding: 0 .85rem; height: 56px;
  position: relative;
  font-size: .75rem; font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  transition: color var(--transition);
  cursor: default; flex-shrink: 0;
}
.rail-step .step-num {
  width: 20px; height: 20px; border-radius: 50%;
  border: 1.5px solid currentColor;
  display: flex; align-items: center; justify-content: center;
  font-size: .65rem; font-weight: 700; flex-shrink: 0;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}
.rail-step.active { color: var(--primary); }
.rail-step.active .step-num { background: var(--primary); border-color: var(--primary); color: #fff; }
.rail-step.done  { color: var(--text-secondary); }
.rail-step.done  .step-num { background: var(--surface-2); border-color: var(--primary-glow); color: var(--primary); }
.rail-step::after {
  content: ''; position: absolute; bottom: 0; left: 0; right: 0;
  height: 2px; background: transparent; transition: background var(--transition);
}
.rail-step.active::after {
  background: linear-gradient(90deg, var(--primary), var(--accent));
}
.rail-connector { width: 16px; height: 1px; background: var(--border); flex-shrink: 0; }
.rail-home {
  display: flex; align-items: center; gap: .4rem;
  font-size: .75rem; font-weight: 600; color: var(--text-muted);
  text-decoration: none; padding-right: 1rem;
  border-right: 1px solid var(--border);
  flex-shrink: 0; white-space: nowrap;
  transition: color var(--transition);
}
.rail-home:hover { color: var(--primary); }
.rail-home:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; border-radius: 3px; }

/* ── Wizard footer: HITL + CTA in one bar (single band, not “double footer”) ─ */
.wizard-footer-bar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  background: linear-gradient(180deg, oklch(99% 0.006 277 / 0.99) 0%, oklch(97.6% 0.008 277 / 0.99) 100%);
  backdrop-filter: blur(14px) saturate(1.15);
  -webkit-backdrop-filter: blur(14px) saturate(1.15);
  border-top: 1px solid oklch(90% 0.012 277);
  padding: 0.5rem 1.25rem max(0.5rem, env(safe-area-inset-bottom));
  box-shadow: 0 -1px 0 oklch(92% 0.01 277 / 0.9), 0 -8px 32px oklch(48% 0.12 277 / 0.04);
}
.wizard-footer-inner {
  max-width: 1200px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.75rem 1rem; flex-wrap: wrap;
  min-height: 2.7rem;
}
.wizard-footer-bar #hitl-rail,
.wizard-footer-bar .wizard-hitl {
  position: static; inset: auto;
  flex: 1 1 12rem; min-width: 0;
  margin: 0; padding: 0;
  background: transparent; border: none; box-shadow: none;
  backdrop-filter: none; -webkit-backdrop-filter: none;
  display: flex; align-items: center; justify-content: flex-start;
  gap: 0.5rem 0.75rem; flex-wrap: nowrap;
}
.wizard-footer-bar .hitl-dot {
  flex-shrink: 0; align-self: center;
  margin-top: 0.05rem;
}
.wizard-footer-bar .hitl-text {
  font-size: 0.7rem;
  line-height: 1.3;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.01em;
  flex: 1 1 auto;
  min-width: 0;
  max-width: min(36rem, 48vw);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wizard-footer-bar .hitl-badge {
  flex-shrink: 0; align-self: center;
  font-size: 0.65rem;
  padding: 0.2rem 0.6rem;
}
.wizard-footer-cta {
  flex: 0 1 auto;
  min-width: min(100%, 20rem);
  display: flex; align-items: center; justify-content: flex-end;
  gap: 0.65rem; flex-wrap: wrap;
}
@media (min-width: 720px) {
  .wizard-footer-inner { flex-wrap: nowrap; }
  .wizard-footer-cta {
    justify-content: space-between;
    min-width: 16rem;
    max-width: 32rem;
    border-left: 1px solid var(--border);
    padding-left: 1.1rem;
    margin-left: 0.1rem;
  }
}
@media (max-width: 719px) {
  .wizard-footer-bar #hitl-rail,
  .wizard-footer-bar .wizard-hitl {
    flex-wrap: wrap;
    align-items: flex-start;
  }
  .wizard-footer-bar .hitl-text {
    max-width: none;
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: unset;
  }
  .wizard-footer-inner {
    flex-direction: column;
    align-items: stretch;
    gap: 0.65rem;
  }
  .wizard-footer-cta {
    min-width: 0;
    max-width: none;
    width: 100%;
    border-top: 1px solid var(--border);
    padding-top: 0.65rem;
    padding-left: 0;
    margin-left: 0;
    border-left: none;
    justify-content: space-between;
  }
}
@media (max-width: 600px) {
  .wizard-footer-bar { padding-left: 1rem; padding-right: 1rem; }
}
@media (max-width: 720px) {
  .p6-grid { grid-template-columns: 1fr !important; }
}
.p3-test-stack { max-width: min(100%, 1120px); }
.p3-synth-wrap {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  align-items: start;
}
.p3-guard-card {
  position: sticky; top: 4.5rem;
  min-width: 0;
  display: flex;
  flex-direction: column;
  transition: box-shadow var(--transition), border-color var(--transition);
}
.p3-guard-card--active {
  border-color: oklch(88% 0.04 277);
  box-shadow: 0 0 0 1px oklch(90% 0.06 277 / 0.8), 0 12px 32px oklch(48% 0.12 277 / 0.08);
  background: linear-gradient(180deg, oklch(99% 0.01 277) 0%, var(--surface) 100%);
}
.p3-guard-head { margin-bottom: 0.75rem; }
.p3-guard-title {
  font-size: 0.9rem; font-weight: 700; color: var(--text-primary);
  margin: 0.25rem 0 0.25rem 0; letter-spacing: -0.02em;
}
.p3-guard-sub { color: var(--text-secondary); margin: 0; font-size: 0.8rem; line-height: 1.4; }
.p3-gr-summary {
  display: flex; flex-direction: column; gap: 0.65rem;
  margin-bottom: 1rem;
  padding: 0.75rem 0.65rem;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.p3-gr-kpis { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.p3-gr-kpi {
  font-size: 0.72rem; font-weight: 600;
  display: inline-flex; align-items: center; gap: 0.25rem;
  padding: 0.3rem 0.5rem; border-radius: 100px;
  font-family: var(--font-body);
}
.p3-gr-kpi--pass  { color: oklch(35% 0.12 162); background: oklch(95% 0.04 162); }
.p3-gr-kpi--rev   { color: oklch(40% 0.12 75);  background: oklch(97% 0.06 90);  }
.p3-gr-kpi--block { color: oklch(40% 0.14 25);  background: oklch(97% 0.04 25);  }
.p3-gr-kpi-n { font-size: 0.8rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.p3-gr-kpi-pct { font-size: 0.65rem; font-weight: 600; opacity: 0.9; }
.p3-gr-meta { font-size: 0.65rem; color: var(--text-muted); margin: 0; line-height: 1.35; }
.p3-gr-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.35rem; }
.p3-gr-item { border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); overflow: hidden; }
.p3-gr-toggle {
  width: 100%; display: flex; align-items: center; gap: 0.5rem;
  padding: 0.55rem 0.6rem; text-align: left; cursor: pointer;
  font: inherit; color: inherit; background: transparent; border: none;
  min-height: 2.75rem; transition: background var(--transition);
}
.p3-gr-toggle:hover { background: var(--surface-2); }
.p3-gr-toggle:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.p3-gr-badge { flex-shrink: 0; font-size: 0.6rem; padding: 0.2rem 0.45rem; }
.p3-gr-label { flex: 1; min-width: 0; font-size: 0.8rem; font-weight: 600; color: var(--text-primary); line-height: 1.3; }
.p3-gr-chev { flex-shrink: 0; font-size: 0.7rem; color: var(--text-muted); width: 1rem; text-align: center; transition: transform 0.2s ease; }
.p3-gr-item[data-expanded="true"] .p3-gr-chev { transform: rotate(90deg); }
.p3-gr-panel { padding: 0 0.75rem 0.75rem; }
.p3-gr-p { font-size: 0.78rem; line-height: 1.5; color: var(--text-secondary); margin: 0 0 0.6rem; }
.p3-gr-example-h {
  font-size: 0.6rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted); margin: 0 0 0.2rem;
}
.p3-gr-example {
  font-size: 0.75rem; line-height: 1.5; color: var(--text-primary);
  margin: 0; padding: 0.5rem 0.55rem; border-radius: 8px; background: var(--surface-2);
  border-left: 3px solid var(--primary-dim); font-style: italic;
}
@media (max-width: 900px) {
  .p3-synth-wrap { grid-template-columns: 1fr !important; }
  .p3-guard-card { position: static; }
}
@media (prefers-reduced-motion: reduce) {
  .p3-gr-chev { transition: none; }
}
@media (max-width: 800px) {
  .p1-cols { grid-template-columns: 1fr !important; }
}

/* Phase 6 — launch celebration overlay (before redirect to dashboard) */
.p6-launch-overlay {
  position: fixed; inset: 0; z-index: 500;
  display: flex; align-items: center; justify-content: center;
  padding: 1.5rem;
  background: oklch(18% 0.04 277 / 0.55);
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity 0.35s ease, visibility 0.35s;
}
.p6-launch-overlay.open { opacity: 1; visibility: visible; pointer-events: auto; }
.p6-launch-card {
  max-width: 22rem; text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem 1.75rem;
  box-shadow: 0 20px 60px oklch(20% 0.06 277 / 0.35);
  animation: p6-launch-in 0.5s ease-out;
}
.p6-launch-sparkles {
  font-size: 2.75rem; line-height: 1; margin-bottom: 0.75rem;
  animation: p6-sparkle 1.2s ease-in-out infinite;
}
@keyframes p6-launch-in {
  from { transform: scale(0.92); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
@keyframes p6-sparkle {
  0%, 100% { transform: scale(1) rotate(-4deg); filter: brightness(1); }
  50% { transform: scale(1.1) rotate(4deg); filter: brightness(1.15); }
}

/* HITL strip (only when not inside merged footer — e.g. legacy) */
.hitl-rail {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 91;
  background: oklch(97.2% 0.006 277 / 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  padding: .65rem 2rem;
  display: flex; align-items: center; justify-content: center; gap: 1.25rem;
  box-shadow: 0 -1px 0 var(--border), 0 -4px 16px oklch(48% 0.195 277 / 0.04);
}
.hitl-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--primary);
  animation: pulse-dot 2s ease-in-out infinite;
}
.hitl-text { font-size: .75rem; font-weight: 500; color: var(--text-muted); letter-spacing: .02em; }
.hitl-badge {
  display: inline-flex; align-items: center; gap: .35rem;
  font-size: .7rem; font-weight: 700;
  padding: .2rem .65rem; border-radius: 100px;
  background: var(--accent-dim);
  border: 1px solid oklch(44% 0.195 300 / 0.22);
  color: var(--accent);
}

/* ── Progress ring ─────────────────────────────────────────────────────────── */
.progress-ring { transform: rotate(-90deg); }
.progress-ring-track { fill: none; stroke: var(--border); stroke-width: 3; }
.progress-ring-fill {
  fill: none; stroke: var(--primary); stroke-width: 3;
  stroke-linecap: round; stroke-dasharray: 100; stroke-dashoffset: 100;
  transition: stroke-dashoffset 2.4s ease-out;
}

/* ── Toggle switch ─────────────────────────────────────────────────────────── */
.toggle-wrap {
  display: flex; align-items: center; gap: .75rem;
  cursor: pointer; user-select: none;
}
.toggle {
  width: 44px; height: 24px;
  background: var(--surface-3);
  border: 1px solid var(--border-mid);
  border-radius: 100px; position: relative;
  transition: background var(--transition);
  flex-shrink: 0;
}
.toggle::after {
  content: ''; width: 18px; height: 18px; border-radius: 50%;
  background: var(--text-muted);
  position: absolute; top: 2px; left: 2px;
  transition: transform var(--transition), background var(--transition);
}
.toggle-wrap.on .toggle { background: var(--primary-dim); border-color: oklch(48% 0.195 277 / 0.3); }
.toggle-wrap.on .toggle::after { transform: translateX(20px); background: var(--primary); }

/* ── Range slider ──────────────────────────────────────────────────────────── */
.slider-wrap { display: flex; flex-direction: column; gap: .5rem; }
.slider-labels { display: flex; justify-content: space-between; }
input[type=range] {
  -webkit-appearance: none; width: 100%; height: 4px;
  background: var(--surface-3); border-radius: 100px;
  outline: none; cursor: pointer;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%;
  background: var(--primary); border: 2px solid oklch(99% 0.003 277);
  box-shadow: 0 0 0 3px var(--primary-dim), 0 2px 4px oklch(48% 0.195 277 / 0.28);
  transition: box-shadow var(--transition);
}
input[type=range]::-webkit-slider-thumb:hover {
  box-shadow: 0 0 0 5px var(--primary-dim), 0 2px 8px oklch(48% 0.195 277 / 0.38);
}
input[type=range]:focus-visible { outline: 2px solid var(--primary); outline-offset: 4px; }

/* ── Drop-zone ─────────────────────────────────────────────────────────────── */
.drop-zone {
  border: 1.5px dashed var(--border-mid);
  border-radius: var(--radius);
  padding: 1.75rem;
  display: flex; flex-direction: column; align-items: center; gap: .65rem;
  text-align: center; cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  background: var(--surface);
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: oklch(48% 0.195 277 / 0.4);
  background: var(--primary-dim);
}
.drop-zone .dz-icon {
  width: 40px; height: 40px; border-radius: var(--radius-sm);
  background: var(--surface-2);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); font-size: 1.1rem;
}
.drop-zone.ingested {
  border-color: oklch(48% 0.195 277 / 0.25); background: var(--primary-dim); cursor: default;
}

/* ── Shimmer skeleton ──────────────────────────────────────────────────────── */
@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
.shimmer {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}

/* ── Modal overlay ─────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 500;
  background: oklch(11% 0.025 277 / 0.5);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center; padding: 1.5rem;
  opacity: 0; pointer-events: none; transition: opacity var(--transition-slow);
}
.modal-overlay.open { opacity: 1; pointer-events: auto; }
.modal-box {
  background: var(--surface);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-xl); padding: 2rem;
  max-width: 520px; width: 100%;
  max-height: 90dvh; overflow-y: auto;
  transform: translateY(16px); transition: transform var(--transition-slow);
  box-shadow: 0 20px 60px oklch(48% 0.195 277 / 0.12), 0 4px 16px oklch(0% 0 0 / 0.08);
  position: relative;
}
.modal-overlay.open .modal-box { transform: translateY(0); }
.modal-close {
  position: absolute; top: 1.25rem; right: 1.25rem;
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--surface-2); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--text-secondary); font-size: 1rem;
  transition: background var(--transition);
}
.modal-close:hover { background: var(--surface-3); color: var(--text-primary); }

/* ── Drawer ────────────────────────────────────────────────────────────────── */
.drawer-overlay {
  position: fixed; inset: 0; z-index: 400;
  background: rgba(26,16,51,.3); backdrop-filter: blur(4px);
  opacity: 0; pointer-events: none; transition: opacity var(--transition-slow);
}
.drawer-overlay.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 410;
  width: min(520px, 100vw);
  background: var(--surface); border-left: 1px solid var(--border-mid);
  padding: 2rem; overflow-y: auto;
  transform: translateX(100%); transition: transform var(--transition-slow);
  display: flex; flex-direction: column; gap: 1.5rem;
  box-shadow: -8px 0 40px oklch(48% 0.195 277 / 0.08);
}
.drawer-overlay.open .drawer { transform: translateX(0); }

/* ── KPI cards ─────────────────────────────────────────────────────────────── */
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  display: flex; flex-direction: column; gap: .35rem;
  box-shadow: var(--shadow-card);
}
.kpi-value { font-size: 1.75rem; font-weight: 800; color: var(--text-primary); font-variant-numeric: tabular-nums; }
.kpi-delta { font-size: .75rem; font-weight: 600; color: oklch(42% 0.14 162); }

/* ── Progress bar ──────────────────────────────────────────────────────────── */
.progress-bar {
  width: 100%; height: 6px; background: var(--surface-3);
  border-radius: 100px; overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: 100px; width: 0%;
  transition: width 1.8s ease-out;
}
.progress-fill-purple { background: linear-gradient(90deg, var(--accent), var(--pink)); }
.progress-fill-blue   { background: var(--phase-1); }

/* ── Divider ───────────────────────────────────────────────────────────────── */
.divider { width: 100%; height: 1px; background: var(--border); flex-shrink: 0; }

/* ── Section wrapper ───────────────────────────────────────────────────────── */
.btob-page {
  position: relative; z-index: 1;
  min-height: calc(100dvh - 56px - 44px);
  padding: 2.5rem 2rem 6rem;
}
.page-inner { max-width: 1200px; margin: 0 auto; }

/* ── Phase header ──────────────────────────────────────────────────────────── */
.phase-header { display: flex; flex-direction: column; gap: .5rem; margin-bottom: 2.5rem; }
.phase-eyebrow { display: flex; align-items: center; gap: .6rem; }
.phase-dot { width: 8px; height: 8px; border-radius: 50%; }

/* ── Grid layouts ──────────────────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
@media (max-width: 768px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

/* ── Toast (high-contrast: dark bar + light text) ─────────────────────────── */
.toast {
  position: fixed; bottom: 1.15rem; left: 50%;
  transform: translate3d(-50%, 20px, 0);
  z-index: 600;
  background: oklch(24% 0.045 277);
  border: 1px solid oklch(40% 0.04 277);
  border-radius: var(--radius);
  padding: 0.8rem 1.2rem 0.85rem;
  max-width: min(92vw, 420px);
  display: flex; align-items: flex-start; gap: 0.6rem;
  box-shadow: 0 12px 40px oklch(15% 0.05 277 / 0.35);
  opacity: 0; pointer-events: none;
  transition: opacity var(--transition), transform var(--transition-slow);
  white-space: normal;
  will-change: transform, opacity;
}
/* Clear the wizard’s fixed footer: toast sits just above the bar, not on it */
body.btob-wizard .toast {
  bottom: calc(
    env(safe-area-inset-bottom, 0px) + var(--wizard-footer-stack) + var(--wizard-toast-gap)
  );
}
.toast .toast-icon {
  font-size: 1.02rem; line-height: 1.35; flex-shrink: 0;
  margin-top: 0.12rem;
}
.toast .toast-msg {
  font-size: 0.8125rem; font-weight: 600; font-family: var(--font-body);
  color: oklch(99% 0.01 277);
  line-height: 1.4;
  flex: 1;
  min-width: 0;
}
.toast.show {
  opacity: 1;
  transform: translate3d(-50%, 0, 0);
  pointer-events: auto;
}
@media (prefers-reduced-motion: reduce) {
  .toast { transition: opacity 0.2s ease; }
  .toast.show { transform: translate3d(-50%, 0, 0); }
}

/* ── Floating feedback pill ────────────────────────────────────────────────── */
.feedback-pill {
  position: fixed; bottom: 5rem; right: 1.5rem; z-index: 80;
  background: var(--surface);
  border: 1px solid var(--border-mid);
  border-radius: 100px;
  padding: .6rem 1.1rem;
  display: flex; align-items: center; gap: .5rem;
  font-size: .8rem; font-weight: 600; color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: var(--shadow-card);
  font-family: var(--font-body);
}
.feedback-pill:hover {
  background: var(--surface-2); color: var(--primary);
  border-color: oklch(48% 0.195 277 / 0.25);
  transform: translateY(-2px);
  box-shadow: var(--shadow-card-hover);
}

/* ── Storyline card ─────────────────────────────────────────────────────────── */
.story-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg); overflow: hidden;
  transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
  cursor: pointer;
  box-shadow: var(--shadow-card);
}
.story-card:hover {
  transform: translateY(-4px);
  border-color: var(--border-mid);
  box-shadow: var(--shadow-card-hover);
}
.story-card-cover { width: 100%; aspect-ratio: 4/3; background: var(--surface-2); overflow: hidden; position: relative; }
.story-card-cover img { width: 100%; height: 100%; object-fit: cover; }
.story-card-body { padding: 1.25rem; }

/* ── Dashboard sidebar ─────────────────────────────────────────────────────── */
.dash-layout { display: flex; min-height: calc(100dvh - 56px); }
.dash-sidebar {
  width: 220px; flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1.25rem .75rem;
  display: flex; flex-direction: column; gap: .15rem;
  position: sticky; top: 56px;
  height: calc(100dvh - 56px); overflow-y: auto;
}
.dash-main { flex: 1; overflow: auto; padding: 2rem; max-width: calc(100vw - 220px); }
.dash-nav-item {
  display: flex; align-items: center; gap: .65rem;
  padding: .55rem .8rem; border-radius: var(--radius-sm);
  font-size: .825rem; font-weight: 500;
  color: var(--text-secondary); cursor: pointer;
  transition: background var(--transition), color var(--transition);
  text-decoration: none;
}
.dash-nav-item:hover { background: var(--surface-2); color: var(--text-primary); }
.dash-nav-item.active { background: var(--primary-dim); color: var(--primary); font-weight: 600; }
.dash-nav-item .nav-icon { font-size: .9rem; width: 18px; text-align: center; flex-shrink: 0; }
.dash-section-title {
  font-size: .65rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--text-muted); padding: .65rem .8rem .2rem;
}

/* ── QA badges ──────────────────────────────────────────────────────────────── */
.qa-badge {
  display: inline-flex; align-items: center; gap: .4rem;
  font-size: .7rem; font-weight: 700; padding: .25rem .7rem; border-radius: 100px;
}
.qa-pass  { background: oklch(94% 0.06 162 / 0.5); color: oklch(38% 0.14 162); border: 1px solid oklch(78% 0.10 162 / 0.4); }
.qa-warn  { background: oklch(94% 0.08  80 / 0.5); color: oklch(48% 0.16  80); border: 1px solid oklch(78% 0.12  80 / 0.4); }
.qa-block { background: oklch(94% 0.06  25 / 0.5); color: oklch(45% 0.18  25); border: 1px solid oklch(78% 0.10  25 / 0.4); }

/* ── Tabs ───────────────────────────────────────────────────────────────────── */
.tabs { display: flex; border-bottom: 1px solid var(--border); margin-bottom: 1.5rem; }
.tab-btn {
  padding: .65rem 1.25rem; font-size: .85rem; font-weight: 600;
  color: var(--text-muted); background: transparent; border: none;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  cursor: pointer; transition: color var(--transition), border-color var(--transition);
  font-family: var(--font-body);
}
.tab-btn:hover { color: var(--text-secondary); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── Code block ─────────────────────────────────────────────────────────────── */
.code-block {
  background: #1E1B4B;
  border-radius: var(--radius-sm);
  padding: 1rem 1.25rem;
  font-family: 'Mono', 'JetBrains Mono', monospace;
  font-size: .75rem; line-height: 1.7;
}

/* ── Animations ─────────────────────────────────────────────────────────────── */
@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: .4; transform: scale(.7); }
}
@keyframes rise-fade {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes glow-pulse {
  0%, 100% { box-shadow: 0 0 30px rgba(79,70,229,.1); }
  50%       { box-shadow: 0 0 60px rgba(79,70,229,.25), 0 0 100px rgba(124,58,237,.1); }
}

.anim-rise   { animation: rise-fade 400ms ease-out both; }
.anim-rise-1 { animation: rise-fade 400ms  60ms ease-out both; }
.anim-rise-2 { animation: rise-fade 400ms 120ms ease-out both; }
.anim-rise-3 { animation: rise-fade 400ms 180ms ease-out both; }
.anim-rise-4 { animation: rise-fade 400ms 240ms ease-out both; }
.anim-rise-5 { animation: rise-fade 400ms 300ms ease-out both; }

/* ── Reduced motion ─────────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  .progress-fill { transition: none; }
}

/* ── Mobile overrides ───────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .dash-layout { flex-direction: column; }
  .dash-sidebar { width: 100%; height: auto; position: static; flex-direction: row; flex-wrap: wrap; padding: .5rem; }
  .dash-main { max-width: 100%; padding: 1rem; }
  .dash-section-title { display: none; }
  .rail-step .step-label { display: none; }
  .rail-step { padding: 0 .5rem; }
}
@media (max-width: 680px) {
  .btob-page { padding: 1.5rem 1rem 5rem; }
  .phase-header { margin-bottom: 1.5rem; }
}

/* ── Focus management ────────────────────────────────────────────────────────── */
.story-card:focus-visible,
.card-hover:focus-visible,
.drop-zone:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.rail-step:focus-visible  { outline: 2px solid var(--primary); outline-offset: -3px; border-radius: 2px; }

/* ── Scrollbar ──────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 100px; }
::-webkit-scrollbar-thumb:hover { background: rgba(79,70,229,.2); }

/* ── Bar chart ──────────────────────────────────────────────────────────────── */
.bar-chart { display: flex; align-items: flex-end; gap: .4rem; height: 80px; }
.bar { flex: 1; background: var(--primary-dim); border-radius: 4px 4px 0 0; }
.bar:last-child { background: linear-gradient(180deg, var(--primary), var(--accent)); }

/* ── Char avatar ────────────────────────────────────────────────────────────── */
.char-avatar {
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--surface-2); border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem; flex-shrink: 0; overflow: hidden;
}
.char-avatar img { width: 100%; height: 100%; object-fit: cover; }

/* ── Utility ────────────────────────────────────────────────────────────────── */
.flex          { display: flex; }
.flex-col      { display: flex; flex-direction: column; }
.items-center  { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center  { justify-content: center; }
.gap-1 { gap: .35rem; } .gap-2 { gap: .65rem; } .gap-3 { gap: 1rem; }
.gap-4 { gap: 1.5rem; } .gap-5 { gap: 2rem; }  .gap-6 { gap: 2.5rem; }
.w-full { width: 100%; }
.text-center { text-align: center; }
.relative { position: relative; }
.hidden { display: none !important; }
