/* ============================================================
   IslaIntel — Real Estate Survey
   Brand: #00ace4 · Charcoal #1F2224 · Cream #E9E6DD
   Type: Inter · JetBrains Mono
   ============================================================ */

:root,
:root[data-theme="light"] {
  /* ===== Brand tokens (constant across themes) ===== */
  --blue: #00ace4;
  --blue-deep: #008fc0;
  --blue-soft: rgba(0, 172, 228, 0.12);
  --blue-hairline: rgba(0, 172, 228, 0.28);

  /* ===== Role tokens (swap between light/dark) ===== */
  --bg: #E9E6DD;
  --bg-raised: rgba(31, 34, 36, 0.03);
  --surface: #ffffff;
  --surface-2: #f6f3ea;
  --ink: #1F2224;
  --ink-2: #2a2e31;
  --ink-3: #3a3f42;
  --ink-4: #5a6165;
  --ink-on-accent: #ffffff;
  --border: rgba(31, 34, 36, 0.08);
  --border-2: rgba(31, 34, 36, 0.12);
  --scrim: rgba(31, 34, 36, 0.08);
  --noise-opacity: 0.35;

  --shadow-sm: 0 1px 0 rgba(0,0,0,0.04), 0 2px 8px rgba(31,34,36,0.04);
  --shadow-md: 0 12px 40px -12px rgba(31,34,36,0.18);
  --shadow-glow: 0 0 0 1px var(--blue-hairline), 0 12px 40px -16px rgba(0,172,228,0.35);

  /* Legacy aliases (so existing rules keep working — will resolve through role tokens) */
  --charcoal: var(--ink);
  --charcoal-2: var(--ink-2);
  --charcoal-3: var(--ink-3);
  --cream: var(--bg);
  --cream-dim: var(--bg-raised);

  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --t-fast: 180ms;
  --t-base: 320ms;
  --t-slow: 520ms;

  --safe-bot: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
  /* Mobile Safari: area covered by the bottom toolbar/address bar (not in safe-area env on web). */
  --browser-ui-h: 0px;
}

:root[data-theme="dark"] {
  --bg: #141617;
  --bg-raised: rgba(255, 255, 255, 0.03);
  --surface: #1f2224;
  --surface-2: #25282a;
  --ink: #E9E6DD;
  --ink-2: rgba(233, 230, 221, 0.85);
  --ink-3: rgba(233, 230, 221, 0.62);
  --ink-4: rgba(233, 230, 221, 0.42);
  --ink-on-accent: #0b0d0e;
  --border: rgba(255, 255, 255, 0.07);
  --border-2: rgba(255, 255, 255, 0.12);
  --scrim: rgba(255, 255, 255, 0.04);
  --noise-opacity: 0.12;

  --shadow-sm: 0 1px 0 rgba(0,0,0,0.3), 0 2px 8px rgba(0,0,0,0.25);
  --shadow-md: 0 14px 40px -14px rgba(0,0,0,0.55);
  --shadow-glow: 0 0 0 1px var(--blue-hairline), 0 16px 48px -20px rgba(0,172,228,0.45);
}

/* Smooth cross-fade when theme changes */
html { transition: background-color 260ms var(--ease); }
body { transition: background-color 260ms var(--ease), color 260ms var(--ease); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-weight: 400;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
}

.mono {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-weight: 500;
  letter-spacing: 0.02em;
}

/* Soft grain / noise overlay for texture */
.noise {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 1;
  opacity: var(--noise-opacity);
  mix-blend-mode: multiply;
  background-image: radial-gradient(rgba(31,34,36,0.04) 1px, transparent 1px);
  background-size: 3px 3px;
  transition: opacity 260ms var(--ease);
}

[data-theme="dark"] .noise {
  mix-blend-mode: screen;
  background-image: radial-gradient(rgba(255,255,255,0.04) 1px, transparent 1px);
}

/* ===== Top bar ===== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  background: linear-gradient(180deg, var(--bg) 78%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: background 260ms var(--ease);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  outline: none;
}

.brand-logo {
  width: 44px;
  height: auto;
  display: block;
  filter: var(--logo-filter, none);
}

[data-theme="dark"] .brand-logo {
  /* The logo is a blue signature on transparent; it already works on dark.
     A subtle brightness lift keeps it crisp over the darker backdrop. */
  filter: brightness(1.05);
}

.brand-name {
  font-family: 'Inter', sans-serif;
  font-weight: 700;
  letter-spacing: -0.015em;
  font-size: 17px;
  color: var(--ink);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

/* Theme toggle — sun/moon icon button */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--ink-2);
  cursor: pointer;
  transition: background 180ms var(--ease), border-color 180ms var(--ease), color 180ms var(--ease), transform 180ms var(--ease);
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

.theme-toggle:hover {
  background: var(--bg-raised);
  border-color: var(--border-2);
  color: var(--ink);
}

.theme-toggle:active {
  transform: scale(0.94);
}

.theme-toggle svg {
  width: 16px;
  height: 16px;
  transition: transform 420ms var(--ease), opacity 260ms var(--ease);
}

.theme-toggle .icon-sun,
.theme-toggle .icon-moon {
  position: absolute;
}

.theme-toggle {
  position: relative;
  overflow: hidden;
}

[data-theme="light"] .theme-toggle .icon-sun { opacity: 1; transform: rotate(0deg) scale(1); }
[data-theme="light"] .theme-toggle .icon-moon { opacity: 0; transform: rotate(-90deg) scale(0.6); }
[data-theme="dark"]  .theme-toggle .icon-sun { opacity: 0; transform: rotate(90deg) scale(0.6); }
[data-theme="dark"]  .theme-toggle .icon-moon { opacity: 1; transform: rotate(0deg) scale(1); }

/* Autosave indicator */
.autosave {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
  opacity: 0;
  transition: opacity 240ms var(--ease);
}

.autosave.show {
  opacity: 1;
}

.autosave-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-soft);
  animation: savePulse 1.4s ease-out;
}

@keyframes savePulse {
  0%   { transform: scale(0.6); }
  40%  { transform: scale(1.15); }
  100% { transform: scale(1); }
}

.lang-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--ink-3);
}

.lang-toggle button {
  background: transparent;
  border: none;
  font-family: inherit;
  font-size: inherit;
  color: var(--ink-3);
  cursor: pointer;
  padding: 6px 8px;
  min-height: 32px;
  letter-spacing: 0.04em;
  transition: color var(--t-fast), background var(--t-fast);
  border-radius: 6px;
  -webkit-tap-highlight-color: transparent;
}

.lang-toggle button.active {
  color: var(--blue);
  font-weight: 600;
}

.lang-toggle button:hover {
  color: var(--ink);
  background: var(--bg-raised);
}

.lang-toggle button:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.lang-toggle .sep {
  opacity: 0.4;
}

/* ===== Resume banner ===== */
.resume-banner {
  position: relative;
  z-index: 40;
  margin: 0 auto;
  max-width: 760px;
  padding: 0 28px;
  animation: slideDown 420ms var(--ease);
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.resume-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #1F2224;
  color: #E9E6DD;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  font-size: 14px;
  flex-wrap: wrap;
  box-shadow: var(--shadow-md);
}

[data-theme="dark"] .resume-inner {
  background: #25282a;
  border: 1px solid var(--border-2);
}

.resume-icon {
  color: var(--blue);
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

.resume-text {
  flex: 1;
  min-width: 160px;
  line-height: 1.4;
}

.resume-btn,
.resume-btn-ghost {
  appearance: none;
  border: none;
  background: var(--blue);
  color: #fff;
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 13px;
  padding: 8px 14px;
  border-radius: 100px;
  cursor: pointer;
  transition: transform var(--t-fast), background var(--t-fast);
  min-height: 36px;
}

.resume-btn:hover {
  background: var(--blue-deep);
  transform: translateY(-1px);
}

.resume-btn-ghost {
  background: transparent;
  color: rgba(233,230,221,0.65);
  font-weight: 500;
}

.resume-btn-ghost:hover {
  color: var(--cream);
}

/* ===== App layout ===== */
.app {
  position: relative;
  z-index: 2;
  max-width: 760px;
  margin: 0 auto;
  padding: 0 28px 80px;
  min-height: calc(100vh - 180px);
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}

/* ===== Progress — segmented pills ===== */
.progress {
  margin: 4px 0 36px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.progress-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--charcoal-3);
}

.progress-cheer {
  color: var(--blue);
  font-weight: 600;
  letter-spacing: 0.08em;
  animation: cheerIn 500ms var(--ease);
}

@keyframes cheerIn {
  from { opacity: 0; transform: translateY(-2px); }
  to { opacity: 1; transform: translateY(0); }
}

.progress-label {
  color: var(--charcoal-3);
}

.progress-segments {
  display: flex;
  gap: 6px;
  width: 100%;
  height: 8px;
}

.segment {
  flex: 1;
  border-radius: 100px;
  background: var(--scrim);
  position: relative;
  overflow: hidden;
  transition: background-color 220ms var(--ease);
}

/* Inner fill — scales from left to right when a segment becomes "done".
   Single animation, no glow, no flicker. */
.segment::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--blue);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 620ms cubic-bezier(0.32, 0.72, 0.24, 1);
  border-radius: inherit;
}

.segment.done::before {
  transform: scaleX(1);
}

/* Current: soft blue wash — static, no shimmer, no glow */
.segment.current {
  background: var(--blue-soft);
}

[data-theme="dark"] .segment.current {
  background: rgba(0, 172, 228, 0.22);
}

/* ===== Steps (screens) =====
   Smooth, GPU-accelerated slide-in from the right. Using only transform +
   opacity keeps the paint cheap. No paint containment here — it would clip
   box-shadow halos on primary buttons sitting near the step's edges. */
.step {
  display: none;
}

.step.active {
  display: block;
  animation: stepIn 460ms cubic-bezier(0.32, 0.72, 0.24, 1);
  will-change: transform, opacity;
}

@keyframes stepIn {
  from {
    opacity: 0;
    transform: translate3d(24px, 0, 0);
  }
  to {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
}

/* When returning via "Back", slide in from the left instead — feels natural */
.step.active.back-in {
  animation: stepInBack 440ms cubic-bezier(0.32, 0.72, 0.24, 1);
}

@keyframes stepInBack {
  from {
    opacity: 0;
    transform: translate3d(-24px, 0, 0);
  }
  to {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
}

/* ===== Hero (language picker) ===== */
.hero {
  padding-top: 24px;
}

.hero-logo {
  width: 96px;
  height: auto;
  margin: 0 0 28px -8px;
  display: block;
  animation: logoIn 900ms var(--ease) both;
}

@keyframes logoIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.trust-bar {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  padding: 12px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 100px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
}

.trust-item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  color: var(--ink-2);
  line-height: 1;
}

.trust-item svg {
  color: var(--blue);
  flex-shrink: 0;
}

.trust-divider {
  width: 1px;
  height: 14px;
  background: var(--border-2);
}

.eyebrow {
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--blue);
  margin-bottom: 24px;
  display: inline-block;
}

.display {
  font-family: 'Inter', sans-serif;
  font-weight: 700;
  font-size: clamp(40px, 6vw, 64px);
  line-height: 1.02;
  letter-spacing: -0.035em;
  margin: 0 0 24px;
  color: var(--charcoal);
}

.display .accent {
  color: var(--blue);
  font-style: italic;
  font-weight: 500;
}

.display-sm {
  font-family: 'Inter', sans-serif;
  font-weight: 700;
  font-size: clamp(28px, 3.6vw, 38px);
  line-height: 1.1;
  letter-spacing: -0.03em;
  margin: 0 0 20px;
  color: var(--charcoal);
}

.lede {
  font-size: 18px;
  line-height: 1.5;
  color: var(--charcoal-2);
  margin: 0 0 40px;
  max-width: 540px;
}

.muted-es {
  color: var(--charcoal-3);
  font-style: italic;
}

.lang-picker {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin-bottom: 48px;
  max-width: 520px;
}

.lang-card {
  text-align: left;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 22px 22px 20px;
  cursor: pointer;
  transition: transform var(--t-base) var(--ease), border-color var(--t-base), box-shadow var(--t-base);
  font-family: inherit;
  color: var(--ink);
  position: relative;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

.lang-card::after {
  content: '';
  position: absolute;
  top: 20px;
  right: 20px;
  width: 10px;
  height: 10px;
  border-right: 2px solid var(--ink-3);
  border-top: 2px solid var(--ink-3);
  transform: rotate(45deg);
  opacity: 0;
  transition: opacity var(--t-base), transform var(--t-base);
}

.lang-card:hover {
  border-color: var(--blue);
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow);
}

.lang-card:hover::after {
  opacity: 1;
  transform: rotate(45deg) translate(4px, -4px);
  border-color: var(--blue);
}

.lang-code {
  font-size: 12px;
  color: var(--blue);
  letter-spacing: 0.14em;
  margin-bottom: 12px;
}

.lang-name {
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 22px;
  letter-spacing: -0.015em;
  margin-bottom: 4px;
}

.lang-meta {
  font-size: 13px;
  color: var(--charcoal-3);
}

.microcopy {
  font-size: 11px;
  color: var(--charcoal-3);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-top: 16px;
}

/* ===== Intro ===== */
.intro {
  padding-top: 8px;
  max-width: 640px;
}

.intro-body {
  font-size: 17px;
  line-height: 1.6;
  color: var(--charcoal-2);
  margin: 0 0 28px;
  white-space: pre-line;
}

.reward {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  background: linear-gradient(135deg, rgba(0,172,228,0.04) 0%, rgba(0,172,228,0.08) 100%);
  border: 1px solid var(--blue-hairline);
  border-radius: var(--radius-md);
  padding: 20px 22px;
  margin-bottom: 36px;
}

[data-theme="dark"] .reward {
  background: linear-gradient(135deg, rgba(0,172,228,0.08) 0%, rgba(0,172,228,0.16) 100%);
}

.reward-icon {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  display: grid;
  place-items: center;
}

.reward-label {
  font-size: 10.5px;
  letter-spacing: 0.16em;
  color: var(--blue);
  margin-bottom: 4px;
}

.reward-text {
  font-size: 15px;
  line-height: 1.5;
  color: var(--charcoal);
}

.legal {
  margin-top: 20px;
  font-size: 10.5px;
  letter-spacing: 0.1em;
  color: var(--charcoal-3);
  text-transform: uppercase;
}

/* "What to expect" pre-commitment list */
.expect {
  margin: 0 0 32px;
  padding: 20px 22px;
  background: var(--surface);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.expect-label {
  font-size: 10.5px;
  letter-spacing: 0.16em;
  color: var(--charcoal-3);
  margin-bottom: 14px;
}

.expect-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.expect-list li {
  display: flex;
  align-items: baseline;
  gap: 14px;
  font-size: 14.5px;
  line-height: 1.45;
  color: var(--charcoal-2);
}

.expect-num {
  font-size: 11px;
  color: var(--blue);
  letter-spacing: 0.08em;
  flex-shrink: 0;
  width: 24px;
}

/* Commit banner on email step (sunk-cost reinforcement) */
.commit-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  margin-bottom: 28px;
  background: linear-gradient(135deg, rgba(0,172,228,0.06) 0%, rgba(0,172,228,0.11) 100%);
  border: 1px solid var(--blue-hairline);
  border-radius: var(--radius-md);
  animation: commitIn 600ms var(--ease) both;
}

[data-theme="dark"] .commit-banner {
  background: linear-gradient(135deg, rgba(0,172,228,0.1) 0%, rgba(0,172,228,0.18) 100%);
}

@keyframes commitIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.commit-check {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  display: grid;
  place-items: center;
}

.commit-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--charcoal);
  line-height: 1.3;
}

.commit-sub {
  font-size: 13px;
  color: var(--charcoal-2);
  line-height: 1.4;
  margin-top: 2px;
}

/* XL button for primary CTAs that need extra pull */
.btn-xl {
  padding: 17px 34px;
  font-size: 15.5px;
  font-weight: 600;
}

/* ===== Questions ===== */
.question {
  padding-top: 8px;
}

.q-meta {
  font-size: 11px;
  color: var(--charcoal-3);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin-bottom: 18px;
}

.q-title {
  font-family: 'Inter', sans-serif;
  font-weight: 700;
  font-size: clamp(24px, 2.8vw, 30px);
  line-height: 1.22;
  letter-spacing: -0.02em;
  margin: 0 0 10px;
  color: var(--charcoal);
}

.q-help {
  font-size: 14.5px;
  color: var(--charcoal-3);
  line-height: 1.5;
  margin: 0 0 28px;
  max-width: 560px;
}

.q-title + .options,
.q-title + .options-grid {
  margin-top: 28px;
}

/* Radio "opt" rows */
.options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 36px;
}

.opt {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: transform var(--t-fast), box-shadow var(--t-fast);
  position: relative;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  /* Options are flex children of .options (flex column) — prevent the flex
     algorithm from compressing bubbles below their content height when the
     list overflows. Each bubble takes its natural content size. */
  flex-shrink: 0;
}

.opt:hover {
  border-color: var(--blue-hairline);
  transform: translateX(2px);
}

/* Instant press feedback on mobile tap */
.opt:active {
  transform: scale(0.995);
}

.opt input[type="radio"],
.opt input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.opt-marker {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--ink-4);
  flex-shrink: 0;
  position: relative;
}

.opt-marker::after {
  content: '';
  position: absolute;
  inset: 3px;
  background: var(--blue);
  border-radius: 50%;
  transform: scale(0);
  transition: transform 120ms var(--ease);
}

.opt input[type="radio"]:checked + .opt-marker {
  border-color: var(--blue);
}

.opt input[type="radio"]:checked + .opt-marker::after {
  transform: scale(1);
}

.opt:has(input[type="radio"]:checked),
.opt:has(input[type="checkbox"]:checked) {
  border-color: var(--blue);
  background: var(--surface);
  box-shadow: var(--shadow-glow);
  animation: selectPulse 180ms var(--ease);
}

@keyframes selectPulse {
  0%   { transform: scale(1); }
  45%  { transform: scale(1.015); }
  100% { transform: scale(1); }
}

.opt-chip:has(input[type="radio"]:checked) {
  animation: selectPulse 180ms var(--ease);
}

/* Checkbox variant — rounded square marker with checkmark */
.opt-check .opt-marker {
  border-radius: 5px;
}

.opt-check .opt-marker::after {
  inset: 0;
  background: var(--blue);
  border-radius: 3px;
  transform: scale(0);
  transition: transform 120ms var(--ease);
}

.opt-check input[type="checkbox"]:checked + .opt-marker {
  border-color: var(--blue);
  background: var(--blue);
}

.opt-check input[type="checkbox"]:checked + .opt-marker::after {
  transform: scale(1);
  background: transparent;
  background-image: url("data:image/svg+xml;utf8,<svg 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'><polyline points='3,8 7,12 13,4'/></svg>");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 14px 14px;
}

.opt-label {
  font-size: 15.5px;
  line-height: 1.35;
  color: var(--charcoal);
  flex: 1;
}

.opt-other {
  flex-wrap: wrap;
}

.opt-input {
  flex: 1 1 100%;
  min-width: 100%;
  margin-top: 10px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 14px;
  background: var(--bg-raised);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  color: var(--ink);
  transition: border-color var(--t-fast), background-color var(--t-fast);
}

.opt-input::placeholder { color: var(--ink-4); }

.opt-input:focus {
  outline: none;
  border-color: var(--blue);
  background: var(--surface);
}

/* Chip-style options (for short answers like firm size, leads) */
.options-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
}

.opt-chip {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px 14px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  text-align: center;
  transition: transform var(--t-fast), box-shadow var(--t-fast);
  position: relative;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  flex-shrink: 0;
}

.opt-chip:active {
  transform: scale(0.97);
}

.opt-chip input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.opt-chip:hover {
  border-color: var(--blue-hairline);
  transform: translateY(-1px);
}

.opt-chip:has(input[type="radio"]:checked) {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
  box-shadow: var(--shadow-glow);
}

/* ===== Text inputs ===== */
.text-area,
.text-input {
  width: 100%;
  padding: 14px 16px;
  font-family: 'Inter', sans-serif;
  font-size: 15.5px;
  color: var(--ink);
  background: var(--surface);
  border: 1.5px solid var(--border-2);
  border-radius: var(--radius-md);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  resize: vertical;
}

.text-area::placeholder,
.text-input::placeholder { color: var(--ink-4); }

.text-area {
  line-height: 1.5;
  min-height: 120px;
  margin-bottom: 24px;
}

.text-input:focus,
.text-area:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-soft);
}

.field {
  margin-bottom: 20px;
}

.field-label {
  display: block;
  font-size: 11px;
  color: var(--charcoal-3);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

/* ===== Buttons ===== */
.btn-primary {
  appearance: none;
  border: none;
  background: var(--ink);
  color: var(--bg);
  font-family: 'Inter', sans-serif;
  font-weight: 500;
  font-size: 15px;
  letter-spacing: -0.005em;
  padding: 14px 28px;
  border-radius: 100px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: transform 180ms var(--ease), box-shadow 240ms var(--ease);
  position: relative;
  -webkit-tap-highlight-color: transparent;
}

[data-theme="dark"] .btn-primary {
  background: var(--blue);
  color: var(--ink-on-accent);
}

/* Hover glow on dark mode: slightly brighter halo so it reads against the dark bg */
[data-theme="dark"] .btn-primary:hover {
  box-shadow:
    0 0 0 4px rgba(0, 172, 228, 0.15),
    0 0 32px rgba(0, 172, 228, 0.5);
}

.btn-primary::after {
  content: '→';
  font-family: 'JetBrains Mono', monospace;
  transition: transform var(--t-fast);
}

/* Hover: keep the button color, add a soft uniform halo (0-offset box-shadow
   layered = radial glow, not a directional drop shadow) */
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow:
    0 0 0 4px rgba(0, 172, 228, 0.08),
    0 0 28px rgba(0, 172, 228, 0.38);
}

.btn-primary:hover::after {
  transform: translateX(3px);
}

.btn-primary:active {
  transform: translateY(0);
  box-shadow:
    0 0 0 3px rgba(0, 172, 228, 0.1),
    0 0 16px rgba(0, 172, 228, 0.32);
}

.btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-ghost {
  appearance: none;
  background: transparent;
  border: none;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  color: var(--ink-3);
  cursor: pointer;
  padding: 10px 4px;
  letter-spacing: 0.04em;
  transition: color var(--t-fast);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  -webkit-tap-highlight-color: transparent;
}

.btn-ghost::before {
  content: '←';
}

.btn-ghost:hover {
  color: var(--ink);
}

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 8px;
}

/* ===== Thank-you ===== */
.thanks {
  text-align: center;
  padding: 40px 0 20px;
  max-width: 560px;
  margin: 0 auto;
}

.check-mark {
  width: 72px;
  height: 72px;
  color: var(--blue);
  margin: 0 auto 28px;
}

.check-mark svg {
  width: 100%;
  height: 100%;
}

.summary {
  margin: 32px auto 28px;
  padding: 20px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  text-align: left;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12.5px;
  color: var(--ink-2);
  line-height: 1.7;
}

.summary:empty {
  display: none;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 4px 0;
  border-bottom: 1px dashed var(--border);
}

.summary-row:last-child {
  border-bottom: none;
}

.summary-key {
  color: var(--ink-3);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 11px;
}

.summary-value {
  color: var(--ink);
  font-weight: 600;
  text-align: right;
}

.credits {
  margin-top: 40px;
  font-size: 11px;
  color: var(--charcoal-3);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.credits .divider {
  margin: 0 12px;
  opacity: 0.5;
}

/* ===== Privacy note ===== */
.privacy {
  margin-top: 16px;
  font-size: 10.5px;
  color: var(--charcoal-3);
  letter-spacing: 0.06em;
  line-height: 1.55;
}

.submit-error {
  margin-top: 12px;
  font-size: 12px;
  color: #c53d3d;
  letter-spacing: 0.04em;
  line-height: 1.45;
  max-width: 36ch;
}
[data-theme="dark"] .submit-error {
  color: #f08080;
}

/* ===== Footer ===== */
.foot {
  position: relative;
  z-index: 2;
  border-top: 1px solid var(--border);
  margin-top: 40px;
}

.foot-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 18px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 10.5px;
  color: var(--ink-3);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.foot-loc {
  opacity: 0.7;
}

/* ===== Responsive — mobile polish =====
   Mobile layout is a strict 3-section chrome:
   ┌─ topbar (pinned top)
   ├─ progress + question header (pinned below topbar)
   ├─ options / textarea (scrollable middle)
   └─ nav: back + hint/continue (pinned bottom)

   The whole viewport is a flex column with overflow: hidden on body, so only
   the middle scroll region moves. Fixes "answers cut off by nav" and makes
   the user always see the question and the footer while scrolling choices.
*/
@media (max-width: 720px) {
  :root {
    /* iOS/Safari & Android Chrome: bottom bar overlays the page; not covered by safe-area-inset alone. */
    --browser-ui-h: 52px;
  }

  html {
    height: 100%;
  }
  body {
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    overscroll-behavior-y: contain;
  }

  .step.active {
    animation-duration: 340ms;
    animation-timing-function: cubic-bezier(0.2, 0.8, 0.2, 1);
  }

  .topbar {
    padding: 14px 18px;
  }
  .brand-logo {
    width: 38px;
  }
  .brand-name {
    font-size: 16px;
  }
  .topbar-right {
    gap: 10px;
  }
  .autosave {
    display: none;
  }

  .theme-toggle {
    width: 34px;
    height: 34px;
  }

  .resume-banner {
    padding: 0 18px;
  }
  .resume-inner {
    padding: 12px 14px;
    font-size: 13px;
  }
  .resume-text {
    min-width: 100%;
  }

  .topbar {
    flex-shrink: 0;
    position: static; /* no longer need sticky — body doesn't scroll */
  }

  .resume-banner {
    flex-shrink: 0;
  }

  .app {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 0 18px;
    overflow: hidden;
  }

  /* Active step fills remaining space; its child wrapper is a flex column.
     If a long screen (e.g. Q6 checkboxes) breaks inner flex scrolling in Safari,
     the step itself can scroll so Back/Continue are never stuck off-screen. */
  .step.active,
  .step.active > .question,
  .step.active > .intro,
  .step.active > .hero,
  .step.active > .thanks {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
  }

  /* Q6: extra scroll context if the checklist flex region fails to clip in WebKit */
  .step.active[data-step="q6"] {
    overflow-y: auto;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
  }

  .progress {
    flex-shrink: 0;
  }

  /* Question steps: every direct child except the options/textarea is a
     non-shrinking header/footer row. The options list becomes the scrollable
     middle. */
  .question > * {
    flex-shrink: 0;
  }

  .question > .options,
  .question > .text-area {
    /* flex-basis: 0 helps WebKit allow the middle pane to shrink vs. long content */
    flex: 1 1 0;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    /* Breathing room; last row must scroll clear of fixed .nav + browser bottom UI. */
    padding: 8px 2px;
    margin: 0 -2px 0;
    padding-bottom: calc(16px + 72px + var(--browser-ui-h) + var(--safe-bot));
  }

  /* Email step: whole block scrolls; leave room for fixed back/submit bar. */
  .step[data-step="email"] > .question {
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding-bottom: calc(20px + 72px + var(--browser-ui-h) + var(--safe-bot));
  }

  /* Non-question wrappers (hero/intro/thanks) scroll as a whole if they
     overflow — simpler UX since they don't have a clear "answers" section. */
  .hero, .intro, .thanks {
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  .hero {
    padding-top: 12px;
  }
  .hero-logo {
    width: 76px;
    margin: 0 0 20px -4px;
  }
  .lang-picker {
    grid-template-columns: 1fr;
    gap: 10px;
    margin-bottom: 24px;
  }
  .lang-card {
    padding: 18px 20px;
  }
  .lang-name {
    font-size: 20px;
  }

  .trust-bar {
    display: flex;
    padding: 10px 16px;
    gap: 10px;
    border-radius: 14px;
  }
  .trust-item {
    font-size: 12px;
  }

  .display {
    font-size: 36px;
    line-height: 1.05;
  }
  .display-sm {
    font-size: 24px;
  }
  .lede {
    font-size: 16px;
    margin-bottom: 28px;
  }

  .intro-body,
  .q-help,
  .opt-label {
    font-size: 15px;
  }

  .q-title {
    font-size: 22px;
    line-height: 1.25;
  }

  .reward {
    padding: 16px;
    gap: 12px;
  }
  .reward-icon {
    width: 34px;
    height: 34px;
  }
  .reward-text {
    font-size: 14px;
  }

  .expect {
    padding: 16px 18px;
  }

  .commit-banner {
    padding: 12px 14px;
  }

  .opt {
    padding: 14px 16px;
    gap: 12px;
    min-height: 52px;
  }

  .opt-chip {
    padding: 14px 12px;
    font-size: 13px;
    min-height: 52px;
  }

  .options-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .text-input,
  .text-area {
    font-size: 16px; /* prevent iOS auto-zoom on focus */
    padding: 14px 14px;
  }

  /* Back / Continue: fixed so iOS Safari's bottom bar doesn't cover the buttons.
     Lift by --browser-ui-h; add safe area inside the bar for home indicator. */
  .app .step .question > .nav {
    position: fixed;
    z-index: 30;
    left: 0;
    right: 0;
    bottom: var(--browser-ui-h);
    margin: 0;
    padding: 12px 18px;
    padding-bottom: calc(12px + var(--safe-bot));
    background: var(--bg);
    border-top: 1px solid var(--border);
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.12);
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
  }

  [data-theme="dark"] .app .step .question > .nav {
    box-shadow: 0 -4px 28px rgba(0, 0, 0, 0.45);
  }

  /* On mobile, hide Continue on single-select steps — tapping an answer
     auto-advances. Q6 is multi-select so Continue stays. "Other" in Q1/Q7
     re-reveals Continue so the user can finish typing and advance. */
  .step[data-step="q1"] .nav [data-next],
  .step[data-step="q2"] .nav [data-next],
  .step[data-step="q3"] .nav [data-next],
  .step[data-step="q4"] .nav [data-next],
  .step[data-step="q5"] .nav [data-next],
  .step[data-step="q7"] .nav [data-next],
  .step[data-step="q8"] .nav [data-next],
  .step[data-step="q9"] .nav [data-next] {
    display: none;
  }

  .step:has(input[type="radio"][value="other"]:checked) .nav [data-next] {
    display: inline-flex;
  }

  /* Subtle hint in place of Continue so the nav doesn't look unbalanced */
  .step[data-step="q1"] .nav::after,
  .step[data-step="q2"] .nav::after,
  .step[data-step="q3"] .nav::after,
  .step[data-step="q4"] .nav::after,
  .step[data-step="q5"] .nav::after,
  .step[data-step="q7"] .nav::after,
  .step[data-step="q8"] .nav::after,
  .step[data-step="q9"] .nav::after {
    content: attr(data-hint);
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    letter-spacing: 0.08em;
    color: var(--ink-3);
    opacity: 0.8;
  }

  .step:has(input[type="radio"][value="other"]:checked) .nav::after {
    display: none;
  }

  .foot {
    display: none;
  }

  .btn-primary {
    padding: 14px 24px;
    font-size: 15px;
    min-height: 48px;
    justify-content: center;
    align-self: flex-start; /* never stretch vertically in flex-column parents */
  }

  /* Only nav buttons should flex to fill width — they sit in a row with Back */
  .nav .btn-primary {
    flex: 1;
    max-width: 240px;
    align-self: auto;
  }

  .btn-xl {
    padding: 15px 26px;
    font-size: 15px;
  }

  .btn-ghost {
    font-size: 13px;
    padding: 10px 8px;
    min-height: 44px;
  }

  .progress {
    margin: 2px 0 22px;
    gap: 8px;
  }
  .progress-cheer {
    font-size: 10.5px;
  }
  .progress-label {
    font-size: 10.5px;
  }
  .progress-segments {
    gap: 4px;
    height: 7px;
  }

  .foot-inner {
    padding: 12px 18px;
    flex-direction: column;
    gap: 4px;
    text-align: center;
    font-size: 10px;
  }

  .thanks {
    padding: 20px 0;
  }
  .check-mark {
    width: 56px;
    height: 56px;
  }
  .summary {
    padding: 16px 18px;
    font-size: 11.5px;
  }
  .summary-row {
    flex-direction: column;
    gap: 2px;
    padding: 8px 0;
  }
  .summary-value {
    text-align: left;
  }
}

/* Extra-small screens */
@media (max-width: 380px) {
  .display {
    font-size: 32px;
  }
  .options-grid {
    grid-template-columns: 1fr;
  }
  .trust-item span:not(:first-child) {
    max-width: 120px;
  }
}

/* Tablet / desktop sizing */
@media (min-width: 721px) {
  .app {
    padding-bottom: 100px;
  }

  /* Long multi-select: keep Continue reachable while scrolling the checklist */
  .step[data-step="q6"] .nav {
    position: sticky;
    bottom: 0;
    z-index: 2;
    margin-top: 12px;
    padding-top: 12px;
    background: var(--bg);
    border-top: 1px solid var(--border);
    box-shadow: 0 -12px 24px -8px rgba(31, 34, 36, 0.08);
  }

  [data-theme="dark"] .step[data-step="q6"] .nav {
    box-shadow: 0 -12px 32px -10px rgba(0, 0, 0, 0.45);
  }
}

/* ===== Error state ===== */
.step.shake {
  animation: shake 420ms var(--ease);
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

.field-error .text-input,
.field-error .text-area {
  border-color: #d64545;
  background: rgba(214,69,69,0.04);
}

/* ===== CASP: mobile nav overrides ===== */
/* Q2/Q3 are multi-select; Q4/Q6 are textarea — Continue must stay visible on mobile. */
@media (max-width: 720px) {
  .step[data-step="q2"] .nav [data-next],
  .step[data-step="q3"] .nav [data-next],
  .step[data-step="q4"] .nav [data-next],
  .step[data-step="q6"] .nav [data-next] {
    display: inline-flex;
  }

  .step[data-step="q2"] .nav::after,
  .step[data-step="q3"] .nav::after,
  .step[data-step="q4"] .nav::after,
  .step[data-step="q6"] .nav::after {
    display: none;
  }

  .step[data-step="q2"] .nav,
  .step[data-step="q3"] .nav {
    position: sticky;
    bottom: 0;
    z-index: 2;
    margin-top: 12px;
    padding-top: 12px;
    background: var(--bg);
    border-top: 1px solid var(--border);
    box-shadow: 0 -12px 24px -8px rgba(31, 34, 36, 0.08);
  }

  [data-theme="dark"] .step[data-step="q2"] .nav,
  [data-theme="dark"] .step[data-step="q3"] .nav {
    box-shadow: 0 -12px 32px -10px rgba(0, 0, 0, 0.45);
  }
}

/* Rank dropdowns (Q4 — top 3 agents) */
.rank-grid {
  display: grid;
  gap: 12px;
  margin-bottom: 8px;
}

.rank-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  align-items: center;
}

@media (min-width: 560px) {
  .rank-row {
    grid-template-columns: 1fr 220px;
  }
}

.rank-row label {
  font-size: 13px;
  color: var(--ink-2);
}

select.select-input {
  width: 100%;
  max-width: 320px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-2);
  background: var(--surface);
  color: var(--ink);
  font-family: inherit;
  font-size: 14px;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%235a6165' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

select.select-input:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.step-error {
  margin: 8px 0 0;
  font-size: 12px;
  color: #c23a3a;
}
