:root {
  --fg: #0a0a0a;
  --fg-soft: #1f2937;
  --fg-muted: #64748b;
  --fg-subtle: #94a3b8;
  --accent: #22c55e;
  --accent-hover: #16a34a;
  --accent-soft: rgba(34, 197, 94, 0.12);
  --accent-soft-2: rgba(34, 197, 94, 0.2);
  --accent-fg: #ffffff;
  --surface: rgba(15, 23, 42, 0.02);
  --surface-hover: rgba(15, 23, 42, 0.045);
  --surface-active: rgba(34, 197, 94, 0.08);
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --border-selected: #0f172a;
  --progress-track: rgba(15, 23, 42, 0.08);
  --progress-fill: #0f172a;
  --logo-filter: none;
  --error: #dc2626;
  --error-bg: #fef2f2;
  --success: #22c55e;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --t-fast: 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  --t-base: 0.32s cubic-bezier(0.4, 0, 0.2, 1);
  --t-slow: 0.52s cubic-bezier(0.22, 1, 0.36, 1);
  --t-slide: 0.5s cubic-bezier(0.65, 0, 0.35, 1);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --header-h: 72px;
  --footer-h: 56px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body {
  height: 100%;
  color: var(--fg);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overscroll-behavior: none;
}
body {
  overflow: hidden;
  font-feature-settings: "ss01", "cv11";
  background: #ffffff;
}
body.has-bg-image {
  --fg: #ffffff;
  --fg-soft: rgba(255, 255, 255, 0.92);
  --fg-muted: rgba(255, 255, 255, 0.64);
  --fg-subtle: rgba(255, 255, 255, 0.42);
  --surface: rgba(255, 255, 255, 0.04);
  --surface-hover: rgba(255, 255, 255, 0.07);
  --surface-active: rgba(255, 255, 255, 0.11);
  --border: rgba(255, 255, 255, 0.14);
  --border-strong: rgba(255, 255, 255, 0.24);
  --border-selected: rgba(255, 255, 255, 0.85);
  --progress-track: rgba(255, 255, 255, 0.12);
  --progress-fill: #ffffff;
  --accent-fg: #0a1f10;
  --error: #fca5a5;
  --error-bg: rgba(248, 113, 113, 0.12);
  --logo-filter: invert(1) brightness(1.2);
  background: #0a1847;
}
body.has-bg-image::before {
  content: '';
  position: fixed; inset: 0;
  background-image: var(--page-bg);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  z-index: -2;
}
body.has-bg-image::after {
  content: '';
  position: fixed; inset: 0;
  background: linear-gradient(135deg, rgba(5, 9, 31, 0.55) 0%, rgba(14, 30, 92, 0.4) 100%);
  z-index: -1;
}

#root {
  position: relative;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* ============ Top brand + progress header ============ */
.brand-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 40;
  padding-top: var(--safe-top);
  pointer-events: none;
}
.brand-progress-wrap {
  height: 3px;
  background: var(--progress-track);
  overflow: hidden;
}
.brand-progress-bar {
  height: 100%; width: 0%;
  background: var(--progress-fill);
  transition: width var(--t-slow);
}
body.has-bg-image .brand-progress-bar {
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.5);
}
.brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 28px;
  pointer-events: auto;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--fg);
  letter-spacing: 0.08em;
  font-weight: 800;
  font-size: 15px;
}
.brand-logo {
  height: 14px;
  width: auto;
  display: block;
  filter: var(--logo-filter);
}
@media (max-width: 600px) {
  .brand-logo { height: 12px; }
}
.brand-fallback {
  display: inline-block;
  font-weight: 800;
  font-size: 15px;
  letter-spacing: 0.08em;
}

/* ============ Initial loading ============ */
.boot-loading {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  z-index: 1;
}
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--fg);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============ Screens ============ */
.screen {
  position: absolute; inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(var(--header-h) + var(--safe-top) + 24px) 32px calc(var(--footer-h) + var(--safe-bottom) + 24px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: transparent;
  opacity: 0;
  transform: translateY(48px);
  transition: opacity var(--t-slide), transform var(--t-slide);
  pointer-events: none;
  will-change: transform, opacity;
}
.screen.active { opacity: 1; transform: translateY(0); pointer-events: auto; }
.screen.exit-up { opacity: 0; transform: translateY(-48px); pointer-events: none; }
.screen.enter-from-top { transform: translateY(-48px); }
.screen.exit-down { opacity: 0; transform: translateY(48px); pointer-events: none; }

.screen-inner {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  background: transparent;
  padding: 0;
}

/* ============ Welcome screen ============ */
.screen-welcome .screen-inner { text-align: left; }
.welcome-title {
  font-size: clamp(34px, 6.2vw, 58px);
  font-weight: 800;
  line-height: 1.08;
  letter-spacing: -0.03em;
  margin-bottom: 18px;
  color: var(--fg);
}
body.has-bg-image .welcome-title { text-shadow: 0 2px 20px rgba(0, 0, 0, 0.25); }
.welcome-subtitle {
  font-size: clamp(16px, 2.1vw, 19px);
  color: var(--fg-soft);
  line-height: 1.55;
  margin-bottom: 36px;
  max-width: 560px;
}

/* ============ Question screen ============ */
.q-number {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--fg-muted);
  margin-bottom: 20px;
  letter-spacing: 0.02em;
  background: var(--surface);
  padding: 5px 11px 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
}
body.has-bg-image .q-number {
  color: var(--fg);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.q-number svg { stroke: currentColor; opacity: 0.85; }
.q-index { font-variant-numeric: tabular-nums; }

.q-title {
  font-size: clamp(24px, 3.6vw, 34px);
  font-weight: 700;
  line-height: 1.24;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
  color: var(--fg);
}
body.has-bg-image .q-title { text-shadow: 0 2px 18px rgba(0, 0, 0, 0.2); }
.q-title .req-asterisk {
  color: var(--accent);
  margin-left: 4px;
  font-weight: 600;
}
.q-subtitle {
  font-size: clamp(14.5px, 1.8vw, 17px);
  color: var(--fg-muted);
  line-height: 1.5;
  margin-top: 6px;
  margin-bottom: 32px;
}
.q-video {
  margin-bottom: 30px;
  border-radius: var(--radius);
  overflow: hidden;
  background: #000;
  aspect-ratio: 16 / 9;
  max-width: 560px;
  border: 1px solid var(--border);
}
.q-video iframe { width: 100%; height: 100%; border: 0; display: block; }
.q-video:empty { display: none; }
.q-input { margin-bottom: 28px; }
.q-error {
  color: var(--error);
  background: var(--error-bg);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  margin-bottom: 16px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  animation: shake 0.4s ease;
  border: 1px solid rgba(248, 113, 113, 0.35);
}
.q-error[hidden], .q-error.is-hidden { display: none !important; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-4px); }
  40%, 80% { transform: translateX(4px); }
}

.q-footer {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

/* ============ Inputs ============ */
.text-input, .textarea-input {
  width: 100%;
  font-family: inherit;
  font-size: clamp(22px, 2.6vw, 28px);
  font-weight: 500;
  color: var(--fg);
  background: transparent;
  border: 0;
  border-bottom: 2px solid var(--border-strong);
  padding: 10px 0 14px;
  transition: border-color var(--t-fast);
  outline: none;
  resize: none;
}
.text-input:focus, .textarea-input:focus { border-bottom-color: var(--fg); }
.text-input::placeholder, .textarea-input::placeholder {
  color: var(--fg-subtle);
  font-weight: 400;
  opacity: 1;
}
.textarea-input {
  min-height: 104px;
  line-height: 1.45;
  font-size: clamp(18px, 2vw, 21px);
}

.phone-input {
  display: flex;
  gap: 12px;
  align-items: center;
  border-bottom: 2px solid var(--border-strong);
  padding-bottom: 6px;
  transition: border-color var(--t-fast);
}
.phone-input:focus-within { border-bottom-color: var(--fg); }
.phone-input select {
  font-family: inherit;
  font-size: 18px;
  border: 0;
  background: transparent;
  padding: 10px 4px;
  color: var(--fg);
  outline: none;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  padding-right: 20px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5'><path d='M6 9l6 6 6-6'/></svg>");
  background-repeat: no-repeat;
  background-position: right 0 center;
}
body.has-bg-image .phone-input select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='white' stroke-opacity='0.65' stroke-width='2.5'><path d='M6 9l6 6 6-6'/></svg>");
}
.phone-input select option { color: #0a1f10; background: #ffffff; }
.phone-input input {
  flex: 1;
  border: 0;
  background: transparent;
  font-family: inherit;
  font-size: clamp(22px, 2.6vw, 28px);
  font-weight: 500;
  color: var(--fg);
  padding: 10px 0;
  outline: none;
  min-width: 0;
}

/* ============ Group (multi-field) ============ */
.group-fields {
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.group-field { display: flex; flex-direction: column; gap: 6px; }
.group-field-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* ============ Choices ============ */
.choices {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.choice-item {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 15px 18px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  font-family: inherit;
  font-size: clamp(15.5px, 1.8vw, 17px);
  color: var(--fg);
  text-align: left;
  cursor: pointer;
  transition: border-color var(--t-fast), background var(--t-fast), transform var(--t-fast);
  position: relative;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.choice-item:hover {
  border-color: var(--border-selected);
  background: var(--surface-hover);
}
.choice-item:active { transform: translateY(1px); }
.choice-item.selected {
  border-color: var(--border-selected);
  background: var(--surface-active);
  box-shadow: 0 0 0 1px var(--border-selected) inset, 0 6px 22px -10px rgba(15, 23, 42, 0.18);
}
body.has-bg-image .choice-item.selected {
  box-shadow: 0 0 0 1px var(--border-selected) inset, 0 10px 30px -10px rgba(0, 0, 0, 0.6);
}
.choice-letter {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 7px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--fg-muted);
  transition: all var(--t-fast);
  font-family: inherit;
}
.choice-item:hover .choice-letter {
  border-color: var(--border-selected);
  background: var(--surface-hover);
  color: var(--fg);
}
.choice-item.selected .choice-letter {
  background: var(--fg);
  border-color: var(--fg);
  color: #ffffff;
}
body.has-bg-image .choice-item.selected .choice-letter {
  background: #ffffff;
  border-color: #ffffff;
  color: #0a1f10;
}
.choice-label { flex: 1; font-weight: 500; line-height: 1.4; }
.choice-check {
  color: var(--fg);
  opacity: 0;
  transform: scale(0.8);
  transition: opacity var(--t-fast), transform var(--t-fast);
  flex-shrink: 0;
}
body.has-bg-image .choice-check { color: #ffffff; }
.choice-item.selected .choice-check { opacity: 1; transform: scale(1); }

/* ============ Yes/No ============ */
.yes-no { display: flex; flex-direction: column; gap: 10px; }
.yes-no .choice-item { min-width: 0; }

/* ============ Rating ============ */
.rating { display: flex; gap: 10px; flex-wrap: wrap; }
.rating-star {
  width: 58px; height: 58px;
  border: 1.5px solid var(--border-strong);
  background: var(--surface);
  border-radius: 12px;
  font-size: 20px;
  font-weight: 700;
  color: var(--fg);
  cursor: pointer;
  transition: all var(--t-fast);
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(6px);
}
.rating-star:hover { border-color: var(--border-selected); background: var(--surface-hover); }
.rating-star.selected {
  background: var(--fg);
  border-color: var(--fg);
  color: #ffffff;
}
body.has-bg-image .rating-star.selected {
  background: #ffffff;
  border-color: #ffffff;
  color: #0a1f10;
}

/* ============ Buttons ============ */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 26px;
  background: var(--accent);
  color: var(--accent-fg);
  border: 0;
  border-radius: 10px;
  font-family: inherit;
  font-size: 15.5px;
  font-weight: 700;
  cursor: pointer;
  transition: background var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast);
  box-shadow: 0 8px 28px -6px rgba(34, 197, 94, 0.55), 0 2px 6px rgba(0, 0, 0, 0.25);
  letter-spacing: -0.005em;
}
.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 12px 34px -6px rgba(34, 197, 94, 0.7), 0 3px 8px rgba(0, 0, 0, 0.3);
}
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-primary svg { display: block; }

.kbd-hint {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--fg-muted);
}
.kbd-hint kbd {
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  padding: 2px 7px;
  border-radius: 5px;
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--fg);
  line-height: 1.3;
}
@media (max-width: 600px) { .kbd-hint { display: none; } }

/* ============ Footer bar (nav only, bottom) ============ */
.footer-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: transparent;
  border-top: 0;
  z-index: 50;
  padding-bottom: var(--safe-bottom);
  transition: opacity var(--t-base), transform var(--t-base);
  pointer-events: none;
}
.footer-bar.hidden { opacity: 0; transform: translateY(100%); pointer-events: none; }
.footer-bar > .progress-wrap { display: none; }
.footer-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 10px 22px;
  max-width: 1080px;
  margin: 0 auto;
  gap: 14px;
  pointer-events: none;
}
.footer-status {
  font-size: 13px;
  color: var(--fg-muted);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  pointer-events: auto;
}
.footer-nav { display: flex; gap: 4px; pointer-events: auto; }
.nav-btn {
  width: 36px; height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--fg-muted);
  cursor: pointer;
  transition: all var(--t-fast);
}
.nav-btn:hover:not(:disabled) {
  border-color: var(--border-selected);
  background: var(--surface-hover);
  color: var(--fg);
}
body.has-bg-image .nav-btn {
  color: var(--fg);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.nav-btn:disabled { opacity: 0.3; cursor: not-allowed; }

/* ============ Thank you screen ============ */
.screen-thankyou .screen-inner {
  text-align: center;
  max-width: 760px;
}
.screen-thankyou .q-footer {
  justify-content: center;
  margin-top: 8px;
}
.screen-thankyou .ty-subtitle {
  margin-left: auto;
  margin-right: auto;
}
.ty-title {
  font-size: clamp(30px, 5vw, 44px);
  font-weight: 800;
  line-height: 1.14;
  letter-spacing: -0.025em;
  margin-bottom: 16px;
  color: var(--fg);
}
.ty-subtitle {
  font-size: clamp(16px, 2.1vw, 19px);
  color: var(--fg-soft);
  line-height: 1.55;
  margin-bottom: 32px;
  white-space: pre-line;
  max-width: 560px;
}
.ty-cta { display: inline-flex; }
.ty-redirect-note {
  margin-top: 16px;
  font-size: 13.5px;
  color: var(--fg-muted);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.ty-redirect-note .spinner-tiny {
  width: 12px; height: 12px;
  border: 2px solid var(--border);
  border-top-color: var(--fg);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ============ Mobile ============ */
@media (max-width: 600px) {
  :root { --header-h: 60px; }
  .brand-row { padding: 14px 18px; }
  .brand { font-size: 13.5px; }
  .brand img { width: 24px; height: 24px; }
  .screen { padding: calc(var(--header-h) + var(--safe-top) + 16px) 22px calc(var(--footer-h) + var(--safe-bottom) + 16px); }
  .footer-controls { padding: 8px 16px; }
  .rating-star { width: 50px; height: 50px; font-size: 17px; }
  .btn-primary { padding: 13px 22px; font-size: 15px; }
  .choice-item { padding: 14px 15px; gap: 12px; }
  .choice-letter { width: 26px; height: 26px; font-size: 12px; }
  .text-input, .phone-input input { font-size: 19px; }
  .textarea-input { font-size: 17px; }
  .nav-btn { width: 34px; height: 34px; }
  .welcome-title { font-size: clamp(28px, 8vw, 38px); }
  .q-title { font-size: clamp(22px, 6vw, 28px); }
}

/* ============ Tablet medium ============ */
@media (max-width: 900px) and (min-width: 601px) {
  .screen-inner { max-width: 620px; }
}

/* ============ Reduce motion ============ */
@media (prefers-reduced-motion: reduce) {
  .screen, .choice-item, .btn-primary, .brand-progress-bar, .ty-icon { transition: none; animation: none; }
}
