/* =============================================================
   @mypinio/ui — Design Tokens
   Phase 1a base + Phase 1c additive semantic tokens.
   Translated from docs/design/current/tokens.css + tokens-1c.css
   per Spec 0001 §6 (Tokens) and §7.12 (Phase 1c tokens).
   The `--bp-*` breakpoint variables from the reference are
   intentionally dropped — Tailwind v4 owns breakpoints.
   ============================================================= */

/* ---------- Base scales (raw, not semantic) ---------- */
:root {
  /* Slate (neutrals) */
  --slate-50: #f8fafc;
  --slate-100: #f1f5f9;
  --slate-200: #e2e8f0;
  --slate-300: #cbd5e1;
  --slate-400: #94a3b8;
  --slate-500: #64748b;
  --slate-600: #475569;
  --slate-700: #334155;
  --slate-800: #1e293b;
  --slate-900: #0f172a;
  --slate-950: #020617;

  /* Navy (primary scale — modern web-app navy) */
  --navy-50: #eff4ff;
  --navy-100: #dbe6fe;
  --navy-200: #bfd3fe;
  --navy-300: #93b5fd;
  --navy-400: #608dfa;
  --navy-500: #3b66f5;
  --navy-600: #2547ea;
  --navy-700: #1d4ed8;
  --navy-800: #1e40af;
  --navy-900: #1e3a8a;
  --navy-950: #172554;

  /* Status — green / amber / red */
  --green-50: #ecfdf5;
  --green-100: #d1fae5;
  --green-500: #10b981;
  --green-600: #059669;
  --green-700: #047857;
  --green-900: #064e3b;

  --amber-50: #fffbeb;
  --amber-100: #fef3c7;
  --amber-500: #f59e0b;
  --amber-600: #d97706;
  --amber-700: #b45309;
  --amber-900: #78350f;

  --red-50: #fef2f2;
  --red-100: #fee2e2;
  --red-500: #ef4444;
  --red-600: #dc2626;
  --red-700: #b91c1c;
  --red-900: #7f1d1d;

  /* Brand-only — reserved for logo & brand moments.
     Per Spec 0001 §6.3, NOT bound into Tailwind's @theme block. */
  --brand-deep-navy: #0b132b;
  --brand-petrol: #157a8a;
  --brand-teal: #24d0c5;
  --brand-off-white: #f2f4f7;

  /* ---------- Typography ---------- */
  --font-sans: 'Geist', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'Geist Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;

  --text-xs: 0.75rem;   /* 12 */
  --text-sm: 0.875rem;  /* 14 */
  --text-base: 1rem;    /* 16 */
  --text-lg: 1.125rem;  /* 18 */
  --text-xl: 1.25rem;   /* 20 */
  --text-2xl: 1.5rem;   /* 24 */
  --text-3xl: 1.875rem; /* 30 */
  --text-4xl: 2.25rem;  /* 36 */
  --text-5xl: 3rem;     /* 48 */

  --leading-tight: 1.2;
  --leading-snug: 1.35;
  --leading-normal: 1.5;
  --leading-relaxed: 1.65;

  --weight-regular: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-bold: 700;

  --tracking-tight: -0.015em;
  --tracking-normal: 0;
  --tracking-wide: 0.025em;

  /* ---------- Spacing (4px base) ---------- */
  --space-0: 0;
  --space-1: 0.25rem; /* 4  */
  --space-2: 0.5rem;  /* 8  */
  --space-3: 0.75rem; /* 12 */
  --space-4: 1rem;    /* 16 */
  --space-5: 1.25rem; /* 20 */
  --space-6: 1.5rem;  /* 24 */
  --space-8: 2rem;    /* 32 */
  --space-10: 2.5rem; /* 40 */
  --space-12: 3rem;   /* 48 */
  --space-16: 4rem;   /* 64 */
  --space-20: 5rem;   /* 80 */
  --space-24: 6rem;   /* 96 */

  /* ---------- Radii ---------- */
  --radius-xs: 2px;
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-xl: 12px;
  --radius-2xl: 16px;
  --radius-full: 9999px;

  /* ---------- Shadows ---------- */
  --shadow-xs: 0 1px 2px 0 rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 1px 3px 0 rgba(15, 23, 42, 0.06), 0 1px 2px -1px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 4px 8px -2px rgba(15, 23, 42, 0.08), 0 2px 4px -2px rgba(15, 23, 42, 0.05);
  --shadow-lg: 0 10px 20px -4px rgba(15, 23, 42, 0.1), 0 4px 8px -3px rgba(15, 23, 42, 0.06);
  --shadow-xl: 0 20px 35px -8px rgba(15, 23, 42, 0.14), 0 8px 16px -6px rgba(15, 23, 42, 0.08);
  --shadow-2xl: 0 32px 60px -12px rgba(15, 23, 42, 0.22);
  --shadow-focus: 0 0 0 3px rgba(30, 58, 138, 0.28);

  /* Breakpoint vars from the reference (--bp-*) are intentionally
     omitted — Tailwind v4 owns breakpoints. See Spec 0001 §6.1. */

  /* ---------- Touch target floor ---------- */
  --touch-min: 44px;

  /* ---------- Motion ---------- */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --duration-fast: 120ms;
  --duration-base: 180ms;
  --duration-slow: 240ms;
}

/* ---------- Semantic — LIGHT (default) ---------- */
:root,
[data-theme='light'] {
  --bg: #ffffff;
  --bg-subtle: var(--slate-50);
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --surface-sunken: var(--slate-50);
  --overlay: rgba(15, 23, 42, 0.55);

  --fg: var(--slate-900);
  --fg-muted: var(--slate-500);
  --fg-subtle: var(--slate-400);
  --fg-on-primary: #ffffff;
  --fg-on-destructive: #ffffff;

  --border: var(--slate-200);
  --border-strong: var(--slate-300);
  --input-border: var(--slate-300);
  --input-bg: #ffffff;
  --input-bg-disabled: var(--slate-100);

  --primary: var(--navy-900);
  --primary-hover: var(--navy-950);
  --primary-active: var(--navy-950);
  --primary-subtle: var(--navy-50);

  --secondary: var(--slate-100);
  --secondary-hover: var(--slate-200);
  --secondary-fg: var(--slate-900);

  --accent: var(--slate-100);
  --accent-hover: var(--slate-200);
  --accent-fg: var(--slate-900);

  --destructive: var(--red-600);
  --destructive-hover: var(--red-700);
  --destructive-subtle: var(--red-50);

  --success: var(--green-600);
  --success-subtle: var(--green-50);
  --warning: var(--amber-600);
  --warning-subtle: var(--amber-50);

  --ring: var(--navy-900);
  --ring-shadow: 0 0 0 3px rgba(30, 58, 138, 0.28);

  --switch-track-off: var(--slate-300);
  --switch-thumb: #ffffff;

  /* App shell */
  --sidebar-bg: var(--slate-50);
  --sidebar-border: var(--border);
  --sidebar-item-active-bg: var(--primary-subtle);
  --sidebar-item-active-fg: var(--primary);
  --sidebar-item-hover-bg: rgba(15, 23, 42, 0.04);
  --topbar-bg: color-mix(in srgb, var(--bg) 86%, transparent);
  --scrim: rgba(15, 23, 42, 0.5);

  /* Chart series — 6 distinct hues, calibrated against semantic tokens. */
  --chart-1: #1e3a8a; /* navy    — mirrors --primary     */
  --chart-2: #10b981; /* emerald — mirrors --success     */
  --chart-3: #f59e0b; /* amber   — mirrors --warning     */
  --chart-4: #e11d48; /* rose    — mirrors --destructive */
  --chart-5: #8b5cf6; /* violet  — accent for 5th series */
  --chart-6: #0ea5e9; /* sky     — accent for 6th series */
  --chart-grid: var(--border);
  --chart-axis-fg: var(--fg-muted);
  --chart-tooltip-bg: var(--surface-raised);

  color-scheme: light;
}

/* ---------- Semantic — DARK ---------- */
[data-theme='dark'] {
  --bg: #0a1024; /* slightly tinted toward brand deep-navy */
  --bg-subtle: #0f1730;
  --surface: #131c3a;
  --surface-raised: #1a2447;
  --surface-sunken: #0a1024;
  --overlay: rgba(2, 6, 23, 0.7);

  --fg: #f2f4f7; /* brand off-white */
  --fg-muted: #94a3b8;
  --fg-subtle: #64748b;
  --fg-on-primary: #ffffff;
  --fg-on-destructive: #ffffff;

  --border: #233056;
  --border-strong: #2f3f6e;
  --input-border: #2f3f6e;
  --input-bg: #0f1730;
  --input-bg-disabled: #131c3a;

  --primary: var(--navy-500);
  --primary-hover: var(--navy-400);
  --primary-active: var(--navy-300);
  --primary-subtle: rgba(59, 102, 245, 0.16);

  --secondary: #1a2447;
  --secondary-hover: #233056;
  --secondary-fg: #f2f4f7;

  --accent: #1a2447;
  --accent-hover: #233056;
  --accent-fg: #f2f4f7;

  --destructive: var(--red-500);
  --destructive-hover: #f87171;
  --destructive-subtle: rgba(239, 68, 68, 0.14);

  --success: var(--green-500);
  --success-subtle: rgba(16, 185, 129, 0.14);
  --warning: var(--amber-500);
  --warning-subtle: rgba(245, 158, 11, 0.14);

  --ring: var(--navy-400);
  --ring-shadow: 0 0 0 3px rgba(96, 141, 250, 0.32);

  --switch-track-off: #2f3f6e;
  --switch-thumb: #f2f4f7;

  /* App shell */
  --sidebar-bg: #0a1024;
  --sidebar-border: var(--border);
  --sidebar-item-active-bg: rgba(96, 141, 250, 0.16);
  --sidebar-item-active-fg: #93b5fd;
  --sidebar-item-hover-bg: rgba(242, 244, 247, 0.05);
  --topbar-bg: color-mix(in srgb, var(--bg) 84%, transparent);
  --scrim: rgba(2, 6, 23, 0.7);

  /* Chart series — brighter shades for dark surfaces */
  --chart-1: #608dfa; /* navy-400    */
  --chart-2: #34d399; /* emerald-400 */
  --chart-3: #fbbf24; /* amber-400   */
  --chart-4: #fb7185; /* rose-400    */
  --chart-5: #a78bfa; /* violet-400  */
  --chart-6: #38bdf8; /* sky-400     */
  --chart-grid: #233056;
  --chart-axis-fg: var(--fg-muted);
  --chart-tooltip-bg: var(--surface-raised);

  color-scheme: dark;
}

/* =============================================================
   Phase 1c — additive semantic tokens
   Loaded after the Phase 1a/1b semantic blocks above. Adds tokens
   for code blocks, diff viewer, heatmap ramp, password strength,
   and keyboard-shortcut chips. Per Spec 0001 §7.12, these are NOT
   bound into Tailwind's @theme block — components consume them
   directly via var(--code-bg) etc.
   ============================================================= */

:root,
[data-theme='light'] {
  /* Code blocks — slightly more contrast than --surface-sunken so
     inline + block code reads as "code" without flagging as alert. */
  --code-bg: var(--slate-50);
  --code-fg: var(--slate-800);
  --code-border: var(--slate-200);
  --code-comment: var(--slate-500);
  --code-keyword: #1d4ed8; /* navy-700  */
  --code-string: #047857;  /* green-700 */
  --code-number: #b45309;  /* amber-700 */
  --code-punct: var(--slate-500);

  /* Diff (additions / removals) — derived from success / destructive
     subtle, with a stronger gutter accent. */
  --diff-add-bg: #ecfdf5;
  --diff-add-gutter: #10b981;
  --diff-add-fg: #064e3b;
  --diff-rem-bg: #fef2f2;
  --diff-rem-gutter: #ef4444;
  --diff-rem-fg: #7f1d1d;

  /* Heatmap — 5-stop ramp from neutral → navy. Used by Heatmap +
     Geo choropleth. Calibrated against --primary so the strongest
     cell reads as "primary intensity". */
  --heat-0: var(--slate-100);
  --heat-1: #dbe6fe; /* navy-100 */
  --heat-2: #93b5fd; /* navy-300 */
  --heat-3: #3b66f5; /* navy-500 */
  --heat-4: #1e3a8a; /* navy-900 */

  /* Password strength — 4 steps */
  --pw-1: var(--destructive); /* weak   */
  --pw-2: var(--warning);     /* fair   */
  --pw-3: #0ea5e9;            /* sky — good */
  --pw-4: var(--success);     /* strong */

  /* Code shortcut chips ("⌘K") */
  --kbd-bg: var(--surface);
  --kbd-border: var(--border);
  --kbd-fg: var(--fg-muted);
  --kbd-shadow: inset 0 -1px 0 var(--border-strong);
}

[data-theme='dark'] {
  --code-bg: #0f1730;
  --code-fg: #e2e8f0;
  --code-border: #233056;
  --code-comment: #64748b;
  --code-keyword: #93b5fd;
  --code-string: #34d399;
  --code-number: #fbbf24;
  --code-punct: #94a3b8;

  --diff-add-bg: rgba(16, 185, 129, 0.1);
  --diff-add-gutter: #34d399;
  --diff-add-fg: #a7f3d0;
  --diff-rem-bg: rgba(239, 68, 68, 0.1);
  --diff-rem-gutter: #f87171;
  --diff-rem-fg: #fecaca;

  --heat-0: #131c3a;
  --heat-1: #1e3a8a;
  --heat-2: #2547ea;
  --heat-3: #608dfa;
  --heat-4: #bfd3fe;

  --pw-1: var(--destructive);
  --pw-2: var(--warning);
  --pw-3: #38bdf8;
  --pw-4: var(--success);

  --kbd-bg: #1a2447;
  --kbd-border: #2f3f6e;
  --kbd-fg: #94a3b8;
  --kbd-shadow: inset 0 -1px 0 #2f3f6e;
}

/* =============================================================
   @mypinio/ui — Participant surfaces (Stream profiler, holding)
   Vanilla HTML apps consume CSS variables only — no React/Tailwind.
   Mobile-first: grid shell, scrollable content, fixed chrome rows.
   ============================================================= */



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

html {
  height: 100%;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  height: 100%;
  overflow: hidden;
}

.participant-page {
  margin: 0;
  min-height: 100%;
  min-height: 100dvh;
  min-height: 100svh;
  overflow: hidden;
  background: var(--bg-subtle);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.participant-page > .participant-shell {
  width: 100%;
  max-width: 100%;
  flex: 1 1 auto;
  min-height: 0;
}

/* ---------- Shell layout (mobile-first grid) ---------- */
.participant-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: 100%;
  height: 100%;
  height: 100dvh;
  height: 100svh;
  overflow: hidden;
  background: var(--bg-subtle);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
}

.participant-header {
  z-index: 10;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  padding-top: env(safe-area-inset-top, 0px);
}

.participant-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  max-width: 36rem;
  margin: 0 auto;
  padding: var(--space-3) max(var(--space-4), env(safe-area-inset-left, 0px))
    var(--space-2) max(var(--space-4), env(safe-area-inset-right, 0px));
}

.participant-theme-switcher {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
  padding: 2px;
  border-radius: var(--radius-lg);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
}

.participant-theme-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: none;
  border-radius: calc(var(--radius-lg) - 2px);
  background: transparent;
  color: var(--fg-muted);
  cursor: pointer;
  touch-action: manipulation;
  transition:
    background var(--duration-fast) var(--ease-out),
    color var(--duration-fast) var(--ease-out);
}

.participant-theme-btn:hover {
  color: var(--fg);
  background: var(--surface-raised);
}

.participant-theme-btn.is-active {
  color: var(--primary);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}

.participant-theme-btn:focus-visible {
  outline: none;
  box-shadow: var(--ring-shadow);
}

.participant-logo {
  display: block;
  height: 1.75rem;
  width: auto;
  max-width: min(9.5rem, 55vw);
  object-fit: contain;
}

.participant-progress-wrap {
  max-width: 36rem;
  margin: 0 auto;
  padding: 0 max(var(--space-4), env(safe-area-inset-left, 0px)) var(--space-3)
    max(var(--space-4), env(safe-area-inset-right, 0px));
  width: 100%;
}

.participant-progress-bar {
  height: 4px;
  border-radius: var(--radius-full);
  background: var(--border);
  overflow: hidden;
  direction: ltr;
}

.participant-progress-fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: var(--primary);
  transition: width var(--duration-slow) var(--ease-out);
}

/* Scrollable content — minmax(0,1fr) parent + min-height:0 enables scroll */
.participant-main {
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
  min-height: 0;
  width: 100%;
  max-width: 36rem;
  margin: 0 auto;
  padding: var(--space-5) max(var(--space-4), env(safe-area-inset-left, 0px))
    calc(var(--space-8) + var(--space-2)) max(var(--space-4), env(safe-area-inset-right, 0px));
}

.participant-step {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  width: 100%;
  min-height: 0;
  animation: participant-step-enter var(--duration-slow) var(--ease-out);
}

.participant-step:has(> .participant-loading),
.participant-step:has(> .participant-terminal),
.participant-step:has(> .participant-finalize) {
  justify-content: center;
  align-items: center;
  text-align: center;
}

@keyframes participant-step-enter {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.participant-step-header {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-5);
  text-align: center;
}

.participant-step-title {
  margin: 0;
  font-size: clamp(1.125rem, 4vw, 1.375rem);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
  color: var(--fg);
  overflow-wrap: break-word;
  hyphens: auto;
}

.participant-step-description {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--fg-muted);
  overflow-wrap: break-word;
}

.participant-message {
  margin: var(--space-3) 0 0;
  text-align: center;
  font-size: var(--text-sm);
  color: var(--fg-muted);
}

.participant-message.is-error {
  color: var(--destructive);
}

/* ---------- Consent step ---------- */
.participant-consent-points {
  margin: 0;
  padding: var(--space-4);
  list-style: none;
  border-radius: var(--radius-xl);
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.participant-consent-point {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  font-size: var(--text-sm);
  color: var(--fg);
  line-height: var(--leading-normal);
}

.participant-consent-point-icon {
  flex-shrink: 0;
  width: 1.25rem;
  height: 1.25rem;
  margin-top: 0.125rem;
  color: var(--primary);
}

.participant-consent-callout {
  margin-top: var(--space-5);
  padding: var(--space-4);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-strong);
  background: var(--warning-subtle);
}

.participant-consent-callout-title {
  margin: 0 0 var(--space-2);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--destructive);
  text-align: center;
}

.participant-consent-callout-text {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--fg);
  line-height: var(--leading-normal);
}

.participant-consent-checkbox {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  margin-top: var(--space-5);
  cursor: pointer;
  touch-action: manipulation;
}

.participant-consent-checkbox input {
  flex-shrink: 0;
  width: 1.25rem;
  height: 1.25rem;
  margin-top: 0.125rem;
  accent-color: var(--primary);
}

.participant-consent-checkbox-label {
  font-size: var(--text-sm);
  color: var(--fg);
  line-height: var(--leading-normal);
}

.participant-consent-checkbox-label a {
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.participant-consent-checkbox-label a:hover {
  color: var(--primary-hover);
}

.participant-footer-actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  width: 100%;
}

.participant-cta-secondary {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: var(--touch-min);
  padding: var(--space-3) var(--space-4);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xl);
  background: transparent;
  color: var(--fg-muted);
  font-family: inherit;
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  cursor: pointer;
  touch-action: manipulation;
  transition:
    border-color var(--duration-fast) var(--ease-out),
    color var(--duration-fast) var(--ease-out),
    background var(--duration-fast) var(--ease-out);
}

.participant-cta-secondary:hover:not(:disabled) {
  border-color: var(--border-strong);
  color: var(--fg);
  background: var(--surface-sunken);
}

.participant-cta-secondary:focus-visible {
  outline: none;
  box-shadow: var(--ring-shadow);
}

/* ---------- Option cards (enum / select) ---------- */
.option-cards {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  border: none;
  width: 100%;
}

.option-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  min-height: var(--touch-min);
  padding: var(--space-3) var(--space-4);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--surface);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  scroll-margin-bottom: var(--space-4);
  transition:
    border-color var(--duration-fast) var(--ease-out),
    background var(--duration-fast) var(--ease-out);
}

.option-card:hover {
  border-color: var(--border-strong);
  background: var(--surface-raised);
}

.option-card:has(input:checked),
.option-card.is-selected {
  border-color: var(--primary);
  background: var(--primary-subtle);
}

.option-card:has(input:focus-visible) {
  outline: none;
  box-shadow: var(--ring-shadow);
}

.option-card input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.option-card-label {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-1);
  text-align: start;
}

.option-card-native {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--fg);
  line-height: var(--leading-snug);
  overflow-wrap: break-word;
}

.option-card-secondary {
  font-size: var(--text-sm);
  font-weight: var(--weight-regular);
  color: var(--fg-muted);
  line-height: var(--leading-snug);
  overflow-wrap: break-word;
}

.option-card:has(input:checked) .option-card-secondary,
.option-card.is-selected .option-card-secondary {
  color: var(--fg);
  opacity: 0.85;
}

.option-card-check {
  flex-shrink: 0;
  width: 1.25rem;
  height: 1.25rem;
  border: 2px solid var(--border-strong);
  border-radius: var(--radius-full);
  transition:
    border-color var(--duration-fast) var(--ease-out),
    background var(--duration-fast) var(--ease-out);
}

.option-cards--multiple .option-card-check {
  border-radius: var(--radius-sm);
}

.option-cards--multiple .option-card:has(input:checked) .option-card-check,
.option-cards--multiple .option-card.is-selected .option-card-check {
  box-shadow: none;
  background-color: var(--primary);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='white' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3.5 8.5 6.5 11.5 12.5 4.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 0.75rem;
}

.option-card-flag {
  flex-shrink: 0;
  font-size: 1.375rem;
  line-height: 1;
}

.option-card:has(input:checked) .option-card-check,
.option-card.is-selected .option-card-check {
  border-color: var(--primary);
  background: var(--primary);
  box-shadow: inset 0 0 0 3px var(--fg-on-primary);
}

.option-card.is-filtered-out {
  display: none;
}

.participant-option-search {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  width: 100%;
}

.participant-option-search-input {
  flex-shrink: 0;
}

.participant-option-search-empty {
  margin: 0;
  padding: var(--space-4) var(--space-2);
  text-align: center;
  font-size: var(--text-sm);
  color: var(--fg-muted);
}

/* ---------- Text / number / date inputs ---------- */
.participant-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  width: 100%;
}

.participant-input {
  display: block;
  width: 100%;
  max-width: 100%;
  min-height: var(--touch-min);
  padding: var(--space-3) var(--space-4);
  border: 1.5px solid var(--input-border);
  border-radius: var(--radius-xl);
  background: var(--input-bg);
  color: var(--fg);
  font: inherit;
  /* 16px floor prevents iOS Safari zoom-on-focus */
  font-size: max(16px, 1.0625rem);
  line-height: var(--leading-normal);
  appearance: none;
  -webkit-appearance: none;
  transition:
    border-color var(--duration-fast) var(--ease-out),
    box-shadow var(--duration-fast) var(--ease-out);
}

.participant-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--ring-shadow);
}

.participant-input::placeholder {
  color: var(--fg-subtle);
}

.participant-field-error {
  min-height: 1.25rem;
  margin-top: var(--space-2);
  font-size: var(--text-sm);
  color: var(--destructive);
  text-align: center;
}

/* ---------- Footer CTA (grid row — not sticky/fixed) ---------- */
.participant-footer {
  z-index: 10;
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  background: var(--bg);
  padding: var(--space-3) max(var(--space-4), env(safe-area-inset-left, 0px))
    max(var(--space-3), env(safe-area-inset-bottom, 0px))
    max(var(--space-4), env(safe-area-inset-right, 0px));
}

.participant-footer-inner {
  max-width: 36rem;
  margin: 0 auto;
}

.participant-cta {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: var(--touch-min);
  padding: var(--space-3) var(--space-6);
  border: none;
  border-radius: var(--radius-xl);
  background: var(--primary);
  color: var(--fg-on-primary);
  font: inherit;
  font-size: max(16px, var(--text-base));
  font-weight: var(--weight-semibold);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition:
    background var(--duration-fast) var(--ease-out),
    opacity var(--duration-fast) var(--ease-out);
}

.participant-cta:hover:not(:disabled) {
  background: var(--primary-hover);
}

.participant-cta:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.participant-cta.is-loading {
  pointer-events: none;
}

/* ---------- Finalize / terminal states ---------- */
.participant-finalize {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  text-align: center;
  width: 100%;
  padding: 0;
}

.participant-finalize-icon,
.participant-status-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3.5rem;
  height: 3.5rem;
  border-radius: var(--radius-full);
  font-size: var(--text-2xl);
  flex-shrink: 0;
}

.participant-status-icon svg {
  width: 1.5rem;
  height: 1.5rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.participant-finalize-icon,
.participant-status-icon--success {
  background: var(--success-subtle);
  color: var(--success);
}

.participant-status-icon--primary {
  background: var(--primary-subtle);
  color: var(--primary);
}

.participant-status-icon--neutral {
  background: var(--surface-sunken);
  color: var(--fg-muted);
}

.participant-status-icon--warning {
  background: var(--warning-subtle);
  color: var(--warning);
}

.participant-status-icon--danger {
  background: var(--destructive-subtle);
  color: var(--destructive);
}

.participant-terminal {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  text-align: center;
  width: 100%;
  padding: 0;
}

.participant-terminal p {
  margin: 0;
  font-size: var(--text-base);
  color: var(--fg-muted);
  line-height: var(--leading-relaxed);
  overflow-wrap: break-word;
}

.participant-terminal .participant-step-title {
  margin: 0 0 var(--space-3);
}

/* Centered status content (entry, match holding, thank-you, exit) */
.participant-main--centered {
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.participant-centered-content,
.participant-match-root > .participant-loading--centered,
.participant-match-root > .participant-terminal,
.participant-match-root > .participant-finalize,
.participant-step > .participant-loading--centered,
.participant-step > .participant-loading,
.participant-step > .participant-terminal,
.participant-step > .participant-finalize {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  width: min(100%, 28rem);
  margin-inline: auto;
  text-align: center;
}

.participant-match-root {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
}

.participant-centered-title,
.participant-interstitial-title {
  margin: 0;
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
  color: var(--fg);
  line-height: var(--leading-snug);
}

.participant-centered-text,
.participant-interstitial-text {
  margin: 0;
  font-size: var(--text-base);
  color: var(--fg-muted);
  line-height: var(--leading-relaxed);
  overflow-wrap: break-word;
}

.participant-centered-promo {
  margin: var(--space-2) 0 0;
  max-width: 28rem;
  font-size: var(--text-sm);
  color: var(--fg-muted);
  line-height: var(--leading-relaxed);
}

.participant-centered-promo-link {
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

.participant-centered-promo-link:hover {
  color: var(--primary-hover);
}

.participant-centered-actions {
  width: 100%;
  margin-top: var(--space-1);
}

a.participant-cta {
  text-decoration: none;
  box-sizing: border-box;
}

.participant-loading--centered {
  flex: 1;
  min-height: 0;
  padding: 0;
  color: var(--fg-muted);
}

/* Full-viewport centered gate pages (legacy alias — prefer participant-page shell) */
.participant-interstitial {
  display: grid;
  grid-template-rows: 1fr auto 1fr;
  width: 100%;
  min-height: 100%;
  min-height: 100dvh;
  min-height: 100svh;
  margin: 0;
  overflow: hidden;
  background: var(--bg-subtle);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  padding: env(safe-area-inset-top, 0px) max(var(--space-4), env(safe-area-inset-left, 0px))
    env(safe-area-inset-bottom, 0px) max(var(--space-4), env(safe-area-inset-right, 0px));
}

.participant-interstitial-inner {
  grid-row: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  width: 100%;
  max-width: 28rem;
  margin: 0 auto;
  text-align: center;
}

.participant-interstitial-title {
  margin: 0;
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
  color: var(--fg);
  line-height: var(--leading-snug);
}

.participant-interstitial-text {
  margin: 0;
  font-size: var(--text-base);
  color: var(--fg-muted);
  line-height: var(--leading-relaxed);
}

/* ---------- Date-of-birth wheel (scroll-snap columns) ---------- */
.participant-date-wheel {
  --date-wheel-item-height: 2.75rem;
  --date-wheel-visible-rows: 5;
  --date-wheel-spacer-rows: 2;
  width: 100%;
}

.participant-date-wheel__columns {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-2);
  width: 100%;
}

.participant-date-wheel__column {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-width: 0;
}

.participant-date-wheel__label {
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-align: center;
  color: var(--fg-muted);
}

.participant-date-wheel__viewport {
  position: relative;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface);
  overflow: hidden;
}

.participant-date-wheel__highlight {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: var(--date-wheel-item-height);
  transform: translateY(-50%);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--primary) 8%, transparent);
  pointer-events: none;
  z-index: 1;
}

.participant-date-wheel__list {
  position: relative;
  z-index: 2;
  margin: 0;
  padding: 0;
  list-style: none;
  height: calc(var(--date-wheel-item-height) * var(--date-wheel-visible-rows));
  overflow-y: auto;
  overscroll-behavior-y: contain;
  scroll-snap-type: y mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  mask-image: linear-gradient(
    to bottom,
    transparent 0%,
    black calc(var(--date-wheel-item-height) * var(--date-wheel-spacer-rows)),
    black calc(100% - var(--date-wheel-item-height) * var(--date-wheel-spacer-rows)),
    transparent 100%
  );
}

.participant-date-wheel__list::-webkit-scrollbar {
  display: none;
}

.participant-date-wheel__spacer {
  height: calc(var(--date-wheel-item-height) * var(--date-wheel-spacer-rows));
  flex-shrink: 0;
  pointer-events: none;
}

.participant-date-wheel__item {
  display: flex;
  align-items: center;
  justify-content: center;
  height: var(--date-wheel-item-height);
  scroll-snap-align: center;
  font-size: var(--text-base);
  font-variant-numeric: tabular-nums;
  color: var(--fg-muted);
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
  transition: color var(--duration-fast) var(--ease-out);
}

.participant-date-wheel__item[aria-selected='true'] {
  color: var(--fg);
  font-weight: var(--font-semibold);
}

.participant-date-wheel__item:hover {
  color: var(--fg);
}

@media (min-width: 640px) {
  .participant-date-wheel__columns {
    gap: var(--space-3);
  }

  .participant-date-wheel__item {
    font-size: var(--text-lg);
  }
}

.participant-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  width: 100%;
  padding: var(--space-6) 0;
  color: var(--fg-muted);
  text-align: center;
}

.participant-loading p {
  margin: 0;
  font-size: var(--text-base);
  line-height: var(--leading-relaxed);
}

.participant-spinner {
  width: 2rem;
  height: 2rem;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: var(--radius-full);
  animation: participant-spin 0.7s linear infinite;
}

@keyframes participant-spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------- Tablet & desktop enhancements ---------- */
@media (min-width: 640px) {
  .participant-header-inner {
    padding-top: var(--space-4);
    padding-bottom: var(--space-3);
  }

  .participant-brand {
    font-size: var(--text-lg);
  }

  .participant-logo {
    height: 2rem;
    max-width: 10rem;
  }

  .participant-main {
    padding-top: var(--space-8);
    padding-bottom: var(--space-8);
  }

  .participant-step-header {
    gap: var(--space-3);
    margin-bottom: var(--space-8);
  }

  .participant-step-description {
    font-size: var(--text-base);
  }

  .option-cards {
    gap: var(--space-3);
  }

  .option-card {
    padding: var(--space-4);
    box-shadow: var(--shadow-xs);
  }

  .option-card:has(input:checked),
  .option-card.is-selected {
    box-shadow: var(--shadow-sm);
  }

  .participant-footer {
    padding-top: var(--space-4);
    padding-bottom: max(var(--space-4), env(safe-area-inset-bottom, 0px));
  }

  .participant-finalize-icon,
  .participant-status-icon {
    width: 4rem;
    height: 4rem;
  }

  .participant-status-icon svg {
    width: 1.75rem;
    height: 1.75rem;
  }

  .participant-terminal p {
    font-size: var(--text-lg);
  }
}

@media (min-width: 768px) {
  .participant-page > .participant-shell {
    width: min(100%, 32rem);
    max-width: 32rem;
    border-inline-start: 1px solid var(--border);
    border-inline-end: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
  }

  /* Reserve space for the probe sidebar only while it is visible (not [hidden]). */
  .participant-page.participant-page--probe:has(.participant-probe-sidebar:not([hidden]))
    > .participant-shell {
    margin-inline-end: min(22rem, 38vw);
  }
}

.participant-probe-sidebar {
  position: fixed;
  inset-block: 0;
  inset-inline-end: 0;
  z-index: 40;
  width: min(22rem, 92vw);
  overflow: auto;
  border-inline-start: 1px solid var(--border);
  background: var(--surface);
  color: var(--fg);
  padding: var(--space-4);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
}

.participant-probe-sidebar__title {
  margin: 0 0 var(--space-3);
  font-size: var(--text-base);
  font-weight: 600;
}

.participant-probe-sidebar__meta {
  margin: 0 0 var(--space-4);
  color: var(--muted-fg);
  line-height: 1.4;
}

.participant-probe-sidebar__table {
  width: 100%;
  border-collapse: collapse;
}

.participant-probe-sidebar__table th,
.participant-probe-sidebar__table td {
  padding: var(--space-2) var(--space-1);
  border-bottom: 1px solid var(--border);
  text-align: start;
}

.participant-probe-sidebar__table th:last-child,
.participant-probe-sidebar__table td:last-child,
.participant-probe-sidebar__table th:nth-child(n + 2),
.participant-probe-sidebar__table td:nth-child(n + 2) {
  text-align: end;
}

.participant-probe-full-note {
  margin-block: var(--space-3);
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--muted);
  color: var(--muted-fg);
  font-size: var(--text-sm);
  line-height: 1.45;
}

/* ---------- Bot check (human verification) ---------- */
.participant-bot-check-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
  width: 100%;
  margin-top: var(--space-4);
}

.participant-bot-check-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: calc(var(--touch-min) + var(--space-6));
  padding: var(--space-3) var(--space-2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--card);
  color: var(--fg);
  cursor: pointer;
  transition:
    border-color var(--duration-fast) var(--ease-out),
    box-shadow var(--duration-fast) var(--ease-out),
    transform var(--duration-fast) var(--ease-out);
}

.participant-bot-check-option:hover:not(:disabled) {
  border-color: var(--primary);
  box-shadow: var(--ring-shadow);
}

.participant-bot-check-option:focus-visible {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--ring-shadow);
}

.participant-bot-check-option:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.participant-bot-check-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  color: var(--fg-muted);
}

.participant-bot-check-icon svg {
  width: 100%;
  height: 100%;
}

.participant-bot-check-label {
  max-width: 100%;
  font-size: var(--text-xs);
  font-weight: 500;
  line-height: 1.25;
  letter-spacing: 0.05em;
  text-align: center;
  text-transform: uppercase;
  color: var(--fg);
}
