:root {
  color-scheme: light;
  --bg: #f4f6fb;
  --card: #ffffff;
  --text: #1a1d29;
  --muted: #6b7280;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-tint: #eef2ff;
  --border: #e5e7eb;
  --danger: #dc2626;
  --danger-tint: #fef2f2;
  --success: #059669;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0f1115;
    --card: #1a1d24;
    --text: #f1f2f6;
    --muted: #9aa0ac;
    --accent: #818cf8;
    --accent-hover: #a5b4fc;
    --accent-tint: #23253a;
    --border: #2d3038;
    --danger: #f87171;
    --danger-tint: #2a1a1c;
    --success: #34d399;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}
.wrap {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px 16px 32px;
}
h1 { font-size: 1.3rem; margin: 0 0 4px; }
.subtitle { color: var(--muted); margin: 0 0 16px; font-size: 0.9rem; }
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
  margin-bottom: 14px;
  transition: box-shadow .2s ease, border-color .2s ease;
}
label.q-title {
  display: block; font-weight: 600; margin-bottom: 12px;
  font-size: 1.02rem; line-height: 1.35;
}
.q-num { color: var(--accent); font-weight: 700; margin-right: 4px; }

/* --- progress bar --- */
.progress-wrap {
  position: sticky; top: 0; z-index: 20;
  background: var(--bg);
  padding: 10px 0 8px;
  margin-bottom: 4px;
}
.progress-track {
  height: 6px; border-radius: 999px; background: var(--border); overflow: hidden;
}
.progress-fill {
  height: 100%; background: var(--accent); border-radius: 999px;
  transition: width .3s ease;
  width: 0%;
}
.progress-label {
  font-size: 0.78rem; color: var(--muted); margin-top: 6px; text-align: right;
}

/* --- vertical option list (multi-select) --- */
.options { display: flex; flex-direction: column; gap: 8px; }
.option {
  display: flex; align-items: center; gap: 12px;
  border: 1.5px solid var(--border); border-radius: 10px; padding: 13px 14px;
  cursor: pointer; min-height: 48px;
  transition: background .15s ease, border-color .15s ease;
}
.option input { accent-color: var(--accent); width: 19px; height: 19px; flex-shrink: 0; }
.option:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-tint);
  font-weight: 600;
}
.option:focus-within { outline: 2px solid var(--accent); outline-offset: 1px; }
@media (hover: hover) {
  .option:hover { border-color: var(--accent); }
}
.option.disabled-choice {
  opacity: 0.45; cursor: not-allowed;
}

/* --- segmented grid (single-choice / rating questions) --- */
.options.grid { flex-direction: row; flex-wrap: wrap; gap: 8px; }
.options.grid .chip {
  position: relative;
  flex: 1 1 auto;
  min-width: 46px;
  text-align: center;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 12px 6px;
  min-height: 48px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  font-weight: 600;
  transition: background .15s ease, border-color .15s ease, transform .1s ease;
}
.options.grid .chip input {
  position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer;
}
.options.grid .chip:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}
.options.grid .chip:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.options.grid .chip:active { transform: scale(0.96); }
.options.grid .chip span { font-size: 0.88rem; line-height: 1.15; }

.multi-counter { font-size: 0.78rem; color: var(--muted); margin-top: 8px; }
.multi-counter.full { color: var(--accent); font-weight: 600; }

textarea, input[type=text] {
  width: 100%; padding: 12px 14px; border: 1.5px solid var(--border);
  border-radius: 10px; font-size: 1rem; font-family: inherit;
  background: var(--card); color: var(--text);
}
textarea:focus, input[type=text]:focus, .option:focus-within, .options.grid .chip:focus-within {
  border-color: var(--accent);
}
textarea { min-height: 90px; resize: vertical; }

button {
  background: var(--accent); color: #fff; border: none; border-radius: 10px;
  padding: 14px 20px; font-size: 1rem; font-weight: 600; cursor: pointer;
  min-height: 48px;
}
button:hover { background: var(--accent-hover); }
button.secondary { background: var(--border); color: var(--text); }
button:disabled { opacity: 0.55; cursor: not-allowed; }

.error { color: var(--danger); font-size: 0.9rem; margin-top: 8px; }
.hint { color: var(--muted); font-size: 0.8rem; margin-top: 6px; }
.center { text-align: center; }

.card.current-slide {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-tint);
}

.card.invalid {
  border-color: var(--danger);
  background: var(--danger-tint);
  animation: shake .3s ease;
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* --- sticky submit bar --- */
.submit-bar {
  position: sticky; bottom: 0; left: 0; right: 0;
  background: linear-gradient(to top, var(--bg) 60%, transparent);
  padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
  margin: 0 -16px;
}
.submit-bar .inner {
  max-width: 640px; margin: 0 auto;
}
.submit-bar button { width: 100%; }
.submit-bar .nav-inner {
  display: flex; align-items: center; gap: 10px;
}
.submit-bar .nav-inner #back-btn { width: auto; flex: 0 0 auto; padding-left: 16px; padding-right: 16px; }
.submit-bar .nav-inner #next-btn { flex: 1 1 auto; }
.step-error {
  color: var(--danger); font-size: 0.85rem; margin-top: 10px;
}

/* --- one-question-at-a-time wizard --- */
#step-viewport { min-height: 1px; }
.step-card {
  padding: 28px 22px 26px;
  box-shadow: 0 1px 2px rgba(16,18,30,.04), 0 8px 28px rgba(16,18,30,.06);
  transition: transform 240ms cubic-bezier(.4,0,.2,1), opacity 240ms cubic-bezier(.4,0,.2,1);
}
.step-card .q-title {
  font-size: 1.22rem; line-height: 1.4; margin-bottom: 18px;
}
.step-card .options.grid .chip {
  min-width: 56px; padding: 16px 10px; min-height: 56px;
}
.step-card .options.grid .chip span { font-size: 0.98rem; }
.step-card .option { padding: 15px 16px; min-height: 52px; font-size: 1rem; }

.step-card.leave-forward { transform: translateX(-28px); opacity: 0; }
.step-card.leave-backward { transform: translateX(28px); opacity: 0; }
.step-card.enter-prep-forward { transition: none; transform: translateX(28px); opacity: 0; }
.step-card.enter-prep-backward { transition: none; transform: translateX(-28px); opacity: 0; }

.step-counter {
  font-size: 0.78rem; color: var(--accent); font-weight: 700;
  letter-spacing: .02em; margin-bottom: 8px; text-transform: uppercase;
}

#intro-screen .card {
  animation: intro-in 420ms cubic-bezier(.4,0,.2,1);
}
@keyframes intro-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes thanks-in {
  from { opacity: 0; transform: scale(.96); }
  to { opacity: 1; transform: scale(1); }
}
#thanks.card { animation: thanks-in 380ms cubic-bezier(.4,0,.2,1); }
.thanks-check {
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--accent-tint); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 14px; font-size: 1.6rem;
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
