:root {
  color-scheme: light;
  --ink: #172033;
  --muted: #5e6a7d;
  --paper: #fbf8f2;
  --panel: rgba(255, 255, 255, 0.86);
  --blue: #132744;
  --blue-soft: #dfe8f5;
  --lime: #d8f247;
  --apricot: #f1b06d;
  --rose: #c85c6d;
  --line: rgba(23, 32, 51, 0.15);
  --shadow: 0 24px 80px rgba(19, 39, 68, 0.18);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--paper);
}

body {
  min-height: 100%;
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    linear-gradient(rgba(7, 18, 36, 0.36), rgba(7, 18, 36, 0.46)),
    url("/assets/diagnostic-background-1600.jpg") center / cover fixed,
    #071224;
}

button,
input,
textarea {
  font: inherit;
}

button {
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 180ms ease, background 180ms ease, color 180ms ease, opacity 240ms ease;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: 3px solid rgba(200, 92, 109, 0.45);
  outline-offset: 4px;
}

.shell {
  width: min(1120px, calc(100% - 32px));
  min-height: 100svh;
  margin: 0 auto;
  padding: 32px 0;
  display: grid;
  align-items: center;
}

.intro,
.quiz,
.success {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.7);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.intro {
  display: grid;
  grid-template-columns: minmax(280px, 0.92fr) minmax(320px, 1.08fr);
  align-items: stretch;
  overflow: hidden;
  border-radius: 8px;
  min-height: min(720px, calc(100svh - 64px));
}

.portrait-wrap {
  position: relative;
  min-height: 420px;
  background: #071224;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(14px, 2.2vw, 28px);
}

.portrait {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  object-position: center;
}

.intro-copy {
  padding: clamp(28px, 5vw, 72px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 22px;
}

.eyebrow {
  margin: 0;
  color: var(--rose);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  line-height: 1.02;
  letter-spacing: 0;
}

h1 {
  max-width: 11ch;
  font-size: clamp(3rem, 7vw, 6.2rem);
}

.intro-title-line {
  max-width: none;
  color: var(--blue);
  font-size: 0.92rem;
  line-height: 1.35;
  text-transform: none;
}

.intro-title-line span {
  color: inherit;
  text-transform: none;
}

h2 {
  font-size: clamp(2.3rem, 5vw, 4.8rem);
}

.lead {
  max-width: 34rem;
  margin: 0;
  color: var(--muted);
  font-size: clamp(1.04rem, 1.5vw, 1.28rem);
  line-height: 1.55;
}

.intro-text {
  display: grid;
  gap: 12px;
}

.intro-text p {
  margin: 0;
}

.primary,
.secondary,
.ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  white-space: nowrap;
}

.primary {
  width: fit-content;
  padding: 0 26px;
  color: white;
  background: var(--blue);
}

.primary:hover {
  transform: translateY(-1px);
  background: #0d1b30;
}

.secondary,
.ghost {
  padding: 0 18px;
  color: var(--blue);
  background: var(--blue-soft);
}

.icon-button {
  width: 48px;
  padding: 0;
  font-size: 1.35rem;
}

.quiz {
  max-width: 760px;
  margin: 0 auto;
  padding: clamp(22px, 4vw, 42px);
  border-radius: 8px;
}

.quiz-top {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 28px;
}

.progress {
  flex: 1;
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.92rem;
}

.progress-track {
  width: 100%;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(19, 39, 68, 0.11);
}

#progressBar {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--rose), var(--apricot), var(--lime));
  transition: width 520ms ease;
}

.question-stage {
  min-height: 350px;
  transition: opacity 380ms ease, transform 380ms ease;
}

.question-stage.is-changing {
  opacity: 0;
  transform: translateY(8px);
}

.question {
  display: grid;
  gap: 18px;
}

.question h2 {
  font-size: clamp(1.35rem, 2.4vw, 2.2rem);
  line-height: 1.14;
}

.hint {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.field {
  display: grid;
  gap: 10px;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  padding: 15px 16px;
}

textarea {
  min-height: 150px;
  resize: vertical;
  line-height: 1.45;
}

.options {
  display: grid;
  gap: 10px;
}

.option {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-height: 56px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.74);
  cursor: pointer;
}

.option input {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  accent-color: var(--rose);
}

.option:has(input:checked) {
  border-color: rgba(200, 92, 109, 0.65);
  background: rgba(255, 240, 238, 0.96);
}

.error {
  min-height: 24px;
  margin: 8px 0 0;
  color: #a33145;
  font-weight: 700;
  opacity: 1;
  transition: opacity 240ms ease, min-height 240ms ease, margin 240ms ease;
}

.error.is-empty {
  min-height: 0;
  margin-top: 0;
  opacity: 0;
}

.history {
  margin: 18px 0 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 12px 0;
}

.history[hidden] {
  display: none;
}

.history summary {
  cursor: pointer;
  color: var(--blue);
  font-weight: 800;
}

.history-list {
  display: grid;
  gap: 8px;
  padding-top: 12px;
}

.history-list button {
  min-height: 42px;
  justify-content: flex-start;
  padding: 0 12px;
  background: rgba(19, 39, 68, 0.08);
  color: var(--ink);
  white-space: normal;
  text-align: left;
}

.actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 24px;
}

.actions .primary,
.actions .secondary {
  min-width: 132px;
}

.consent-label {
  align-items: flex-start;
}

.success {
  max-width: 760px;
  margin: 0 auto;
  padding: clamp(34px, 6vw, 72px);
  border-radius: 8px;
  display: grid;
  gap: 20px;
  justify-items: start;
}

.success p:not(.eyebrow) {
  margin: 0;
  color: var(--muted);
  font-size: 1.12rem;
  line-height: 1.55;
}

.telegram-link {
  text-decoration: none;
}

.is-hidden {
  display: none;
}

.fade-in {
  animation: fadeIn 700ms ease both;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 780px) {
  .shell {
    width: min(100% - 20px, 560px);
    padding: 10px 0;
    align-items: start;
  }

  .intro {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .portrait-wrap {
    min-height: 42svh;
    max-height: 470px;
  }

  .portrait {
    object-position: center;
  }

  .intro-copy {
    padding: 24px;
  }

  h1 {
    max-width: 12ch;
    font-size: clamp(2.6rem, 14vw, 4.4rem);
  }

  .quiz {
    padding: 18px;
  }

  .quiz-top {
    margin-bottom: 20px;
  }

  .question-stage {
    min-height: 390px;
  }

  .actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .actions .primary,
  .actions .secondary {
    width: 100%;
    min-width: 0;
    padding-inline: 12px;
  }
}

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