:root {
  --bg: #f1f6f8;
  --card: #ffffff;
  --text: #0f2a3a;
  --muted: #5b7181;
  --line: #d9e4ea;
  --brand: #0e7490;
  --brand-strong: #155e75;
  --brand-soft: #e0f2f7;
  --danger: #b42318;
  --danger-soft: #fdecec;
  --ok: #15803d;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1820;
    --card: #10232e;
    --text: #e6f1f5;
    --muted: #93a9b6;
    --line: #23404f;
    --brand: #22a6c3;
    --brand-strong: #5cc8de;
    --brand-soft: #143745;
    --danger: #ff8a80;
    --danger-soft: #3b1c1c;
    --ok: #4ade80;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
}
input, textarea, button { font: inherit; color: inherit; }

.hero {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 28px max(16px, env(safe-area-inset-left)) 56px;
  background: linear-gradient(135deg, #0e7490, #155e75 60%, #0f2a3a);
  color: #fff;
}
.hero .logo { width: 64px; height: 64px; border-radius: 16px; background: #fff; padding: 6px; object-fit: contain; flex: none; }
.hero h1 { margin: 0; font-size: clamp(1.6rem, 5vw, 2.2rem); letter-spacing: -0.02em; }
.tagline { margin: 2px 0 0; opacity: 0.85; }

main { width: 100%; max-width: 760px; margin: -36px auto 0; padding: 0 16px 32px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px;
  margin: 0 0 16px;
  box-shadow: 0 1px 2px rgba(15, 42, 58, 0.06);
  min-width: 0;
}
.intro h2 { margin: 0 0 8px; font-size: 1.25rem; }
.intro p { margin: 0 0 8px; }
.muted { color: var(--muted); font-size: 0.9rem; }

.progress { position: sticky; top: 0; z-index: 5; height: 6px; margin: 0 -16px 16px; background: var(--line); }
.progress span { display: block; height: 100%; width: 0; background: var(--brand); transition: width 0.25s ease; }

fieldset { border: 1px solid var(--line); }
legend {
  display: flex;
  align-items: center;
  gap: 10px;
  float: left;
  width: 100%;
  margin: 0 0 12px;
  padding: 0;
  font-size: 1.1rem;
  font-weight: 700;
}
legend + * { clear: both; }
.step {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand-strong);
  font-size: 0.9rem;
  flex: none;
}

.question { margin: 18px 0 0; padding-top: 16px; border-top: 1px solid var(--line); }
.q { margin: 0 0 10px; font-weight: 600; }
.req { color: var(--danger); }
.hint { display: block; font-weight: 400; font-size: 0.85rem; color: var(--muted); }

.field { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 4px; margin: 12px 0 0; font-weight: 600; font-size: 0.95rem; min-width: 0; }
.field input, .field textarea {
  flex: 1 0 100%;
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  font-weight: 400;
}
.field textarea { resize: vertical; }
.field input:focus, .field textarea:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: transparent; }

.grid-2, .grid-3 { display: grid; grid-template-columns: 1fr; gap: 0 14px; }
.full { grid-column: 1 / -1; margin: 6px 0 0; }

.options { display: grid; grid-template-columns: 1fr; gap: 8px; }
.opt {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.opt:hover { border-color: var(--brand); }
.opt input { width: 20px; height: 20px; margin: 0; accent-color: var(--brand); flex: none; }
.opt:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.opt:has(input:disabled) { opacity: 0.5; cursor: not-allowed; }
.chips { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
.feature { align-items: flex-start; }
.feature input { margin-top: 2px; }
.feature span { display: grid; gap: 2px; }
.feature small { color: var(--muted); }

.scale { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.scale label { position: relative; cursor: pointer; }
.scale input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.scale span {
  display: grid;
  place-items: center;
  height: 52px;
  border: 1px solid var(--line);
  border-radius: 12px;
  font-weight: 700;
  font-size: 1.1rem;
  transition: background 0.15s, border-color 0.15s;
}
.scale input:checked + span { background: var(--brand); border-color: var(--brand); color: #fff; }
.scale input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; }
.scale-legend { display: flex; justify-content: space-between; margin-top: 6px; font-size: 0.82rem; color: var(--muted); }

.switch-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px;
  margin: 0 0 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
}
.switch-row input { width: 22px; height: 22px; margin: 2px 0 0; accent-color: var(--brand); flex: none; }
.switch-row span { display: grid; gap: 2px; }
.switch-row small { color: var(--muted); }
.switch-row:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }

.question.invalid .q, .field.invalid { color: var(--danger); }
.question.invalid .opt, .question.invalid .scale span, .field.invalid input { border-color: var(--danger); }

.trap { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

.form-error { margin: 0 0 12px; padding: 12px 14px; border-radius: 10px; background: var(--danger-soft); color: var(--danger); font-weight: 600; }
.submit {
  width: 100%;
  min-height: 54px;
  border: 0;
  border-radius: 14px;
  background: var(--brand);
  color: #fff;
  font-weight: 700;
  font-size: 1.05rem;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
.submit:hover { background: var(--brand-strong); }
.submit:active { transform: scale(0.99); }
.submit:disabled { opacity: 0.6; cursor: progress; }

.thanks { text-align: center; padding: 40px 20px; }
.thanks:focus { outline: none; }
.check { width: 64px; height: 64px; margin: 0 auto 12px; border-radius: 50%; display: grid; place-items: center; background: var(--brand-soft); color: var(--ok); font-size: 2rem; font-weight: 700; }
.thanks h2 { margin: 0 0 8px; }

footer { text-align: center; padding: 8px 16px 28px; color: var(--muted); font-size: 0.85rem; }

@media (min-width: 640px) {
  .hero { padding: 40px 32px 72px; justify-content: center; }
  .hero .logo { width: 72px; height: 72px; }
  main { margin-top: -48px; padding: 0 24px 40px; }
  .card { padding: 26px 28px; }
  .progress { margin: 0 0 16px; border-radius: 99px; overflow: hidden; }
  .grid-2 { grid-template-columns: 1fr 1fr; }
  .grid-3 { grid-template-columns: repeat(3, 1fr); }
  .options { grid-template-columns: 1fr 1fr; }
  .chips { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .feature-list { grid-template-columns: 1fr 1fr; }
  .submit { width: auto; padding: 0 40px; float: right; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
