:root {
  --bg: #f4f7f9;
  --surface: #fff;
  --ink: #303c47;
  --muted: #687583;
  --line: #d8e1e8;
  --accent: #7d93a7;
  --accent-dark: #5d7488;
  --accent-soft: #e8eef2;
  --focus: #1683f7;
  --danger: #a73b3b;
  --danger-bg: #fff0f0;
  --good: #35764a;
  --good-bg: #e5f3e9;
  --warning: #8c641a;
  --shadow: 0 10px 30px rgba(44, 58, 70, 0.08);
  font-family: "Segoe UI", Arial, sans-serif;
  color-scheme: light;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}
button,
input {
  font: inherit;
}
button {
  border: 0;
  border-radius: 8px;
  padding: 12px 18px;
  font-weight: 800;
  color: var(--ink);
  cursor: pointer;
}
button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}
button:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(22, 131, 247, 0.35);
  outline-offset: 2px;
}
.hidden {
  display: none !important;
}
.primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 8px 18px rgba(93, 116, 136, 0.22);
}
.primary:hover:not(:disabled) {
  background: var(--accent-dark);
}
.primary.blocked {
  opacity: 0.52;
  box-shadow: none;
}
.quiet {
  background: var(--accent-soft);
}
.outline {
  background: #fff;
  border: 1px solid var(--line);
}
.wide {
  width: 100%;
}
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 13px 28px;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}
.participant-identity {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: center;
  gap: 11px;
  min-width: 0;
  max-width: min(720px, calc(100vw - 160px));
  padding: 0;
  text-align: left;
  background: transparent;
}
.participant-avatar {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  color: #fff;
  border-radius: 50%;
  background: var(--accent);
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0.03em;
}
.participant-identity-copy {
  display: grid;
  min-width: 0;
  line-height: 1.15;
}
.participant-identity-copy strong {
  display: -webkit-box;
  overflow: hidden;
  color: var(--ink);
  font-size: 16px;
  white-space: normal;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.participant-identity-copy > span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
.top-actions {
  display: flex;
  gap: 10px;
}
main {
  width: min(1180px, calc(100% - 32px));
  margin: auto;
  padding: 34px 0 64px;
}
.screen {
  animation: appear 0.18s ease;
}
.surface,
.auth-card,
.state-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
}
.auth-screen {
  min-height: calc(100vh - 68px);
  display: grid;
  place-items: center;
}
.auth-card {
  width: min(440px, 100%);
  padding: 38px;
}
.auth-card h1,
.page-heading h1,
.instruction-card h1 {
  margin: 0;
  color: #64798c;
  font-size: clamp(34px, 5vw, 50px);
  line-height: 1.05;
}
.auth-card h1 span {
  white-space: nowrap;
}
.lead,
.page-heading > p,
.split-heading p,
.instruction-card p {
  color: var(--muted);
  line-height: 1.55;
}
.eyebrow {
  margin: 0 0 8px;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}
.stack {
  display: grid;
  gap: 18px;
  margin-top: 28px;
}
label,
legend {
  font-weight: 750;
  color: #4b5965;
}
label small {
  font-weight: 500;
  color: var(--muted);
}
input {
  width: 100%;
  margin-top: 8px;
  padding: 13px 14px;
  border: 1px solid #acbac6;
  border-radius: 6px;
  color: var(--ink);
  background: #fff;
}
.form-error {
  margin: 0;
  padding: 11px 13px;
  border-radius: 6px;
  background: var(--danger-bg);
  color: var(--danger);
  font-weight: 700;
}
.state-card {
  width: min(480px, 100%);
  margin: 12vh auto 0;
  padding: 38px;
  text-align: center;
}
.state-card p {
  color: var(--muted);
}
.spinner {
  display: block;
  width: 38px;
  height: 38px;
  margin: 0 auto 18px;
  border: 4px solid var(--line);
  border-top-color: var(--accent-dark);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.page-heading {
  margin: 22px 0 26px;
}
.page-heading h1 {
  font-size: clamp(36px, 5vw, 54px);
}
.page-heading p {
  max-width: 700px;
}
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px 24px;
  padding: 28px;
}
.form-grid fieldset {
  display: flex;
  gap: 22px;
  margin: 0;
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: 7px;
}
.radio {
  font-weight: 600;
}
.radio input {
  width: auto;
  margin: 0 6px 0 0;
}
.full {
  grid-column: 1/-1;
}
.form-actions {
  display: flex;
  justify-content: flex-end;
}
.split-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
}
.section-heading {
  margin: 32px 0 14px;
}
.section-heading h2 {
  margin: 0;
  font-size: 28px;
}
.active-assignment {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 24px;
  margin-bottom: 28px;
  border-left: 5px solid var(--accent);
}
.active-assignment h2 {
  margin: 0 0 5px;
}
.active-assignment p {
  margin: 0;
  color: var(--muted);
}
.history-grid {
  display: grid;
  gap: 12px;
}
.history-card {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 22px;
  padding: 20px 22px;
}
.history-card h3 {
  margin: 0 0 5px;
}
.history-card p {
  margin: 0;
  color: var(--muted);
}
.empty {
  padding: 30px;
  border: 1px dashed #b9c6d0;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.55);
  text-align: center;
  color: var(--muted);
}
.narrow {
  width: min(760px, 100%);
  margin: 4vh auto;
}
.instruction-card {
  padding: 38px;
}
.instruction-card ol {
  margin: 28px 0;
  padding-left: 24px;
}
.instruction-card li {
  padding-left: 8px;
  margin: 0 0 18px;
  line-height: 1.55;
}
.instruction-actions {
  display: flex;
  justify-content: space-between;
  gap: 14px;
}
.test-screen {
  width: min(980px, 100%);
  margin: auto;
}
.test-header {
  display: grid;
  grid-template-columns: 1fr minmax(240px, 380px);
  align-items: center;
  gap: 30px;
  padding: 22px 25px;
  margin-bottom: 16px;
}
.test-header h1 {
  margin: 0 0 6px;
  font-size: 30px;
}
.save-status {
  margin: 0;
  color: var(--good);
  font-size: 14px;
}
.save-status.saving {
  color: var(--warning);
}
.save-status.error {
  color: var(--danger);
}
.progress-copy {
  display: flex;
  justify-content: space-between;
  margin-bottom: 9px;
  color: var(--muted);
}
.progress-copy strong {
  color: var(--ink);
}
.progress {
  height: 10px;
  background: #dce4ea;
  border-radius: 999px;
  overflow: hidden;
}
.progress span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--accent);
  transition: width 0.2s;
}
.questions {
  display: grid;
  gap: 12px;
}
.question-card {
  padding: 20px 22px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 9px;
}
.question-card.missing-question {
  border: 2px solid var(--danger);
  border-left-width: 7px;
  background: var(--danger-bg);
  box-shadow: 0 8px 22px rgba(167, 59, 59, 0.14);
}
.question-card.missing-question:before {
  content: "Ответ не выбран";
  display: inline-block;
  margin: 0 0 10px;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 12px;
  font-weight: 900;
}
.question-card p {
  margin: 0 0 16px;
  font-size: 18px;
  line-height: 1.5;
}
.question-number {
  color: var(--accent-dark);
  font-weight: 900;
}
.answers {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.answer {
  position: relative;
  display: block;
}
.answer input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.answer span {
  display: block;
  min-width: 104px;
  padding: 10px 15px;
  border: 1px solid var(--line);
  border-radius: 999px;
  text-align: center;
  background: #f8fafb;
  font-weight: 750;
  cursor: pointer;
}
.answer input:checked + span {
  border-color: var(--accent-dark);
  background: var(--accent);
  color: #fff;
}
.answer input:focus-visible + span {
  outline: 3px solid rgba(22, 131, 247, 0.35);
  outline-offset: 2px;
}
.answer.pending span {
  opacity: 0.65;
}
.pager {
  position: sticky;
  bottom: 12px;
  z-index: 10;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 16px;
  padding: 13px 16px;
  margin-top: 18px;
}
.pager span {
  text-align: center;
  color: var(--muted);
  font-weight: 700;
}
.complete-box {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  padding: 24px;
  margin-top: 16px;
}
.complete-box h2,
.complete-box p {
  margin: 0;
}
.complete-box p {
  margin-top: 5px;
  color: var(--muted);
}
.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 25px;
  padding: 24px;
  margin-bottom: 16px;
}
.result-header h1 {
  margin: 0 0 7px;
  color: #64798c;
  font-size: 32px;
}
.result-header p {
  margin: 0;
  color: var(--muted);
}
.result-actions,
.tabs {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.tabs {
  margin-left: 14px;
}
.tabs button {
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  background: #fff;
}
.tabs button.active {
  color: var(--focus);
  box-shadow: inset 0 -3px 0 var(--focus);
}
.tab-panel {
  display: none;
  padding: 24px;
  border-radius: 0 10px 10px 10px;
}
.tab-panel.active {
  display: block;
}
.scale-row {
  display: grid;
  grid-template-columns: 50px 1fr;
  gap: 16px;
  align-items: center;
  margin: 15px 0 25px;
}
.scale-code {
  font-size: 25px;
  font-weight: 900;
  text-align: center;
}
.bar {
  position: relative;
  height: 30px;
  border: 1px solid #d4d9dc;
  border-radius: 5px;
  background: linear-gradient(
    90deg,
    #f1cccc 0 30%,
    #f0ddb9 30% 60%,
    #d9edf3 60% 85%,
    #d6ecd8 85%
  );
}
.bar:before {
  content: "";
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 2px;
  background: rgba(0, 0, 0, 0.25);
}
.marker {
  position: absolute;
  top: -8px;
  transform: translateX(-50%);
  min-width: 48px;
  padding: 7px 8px;
  border: 1px solid #aab5bd;
  border-radius: 5px;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
  text-align: center;
  font-size: 20px;
  font-weight: 900;
}
.marker.manic-marker {
  background: #ffd800;
  border-color: #8b7600;
}
.bar-labels {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 14px;
}
.bar-labels span:last-child {
  text-align: right;
}
canvas {
  width: 100%;
  height: auto;
  max-height: 720px;
}
.table-wrap {
  overflow: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
}
th,
td {
  padding: 12px;
  text-align: left;
  border-bottom: 1px solid var(--line);
}
.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 50;
  max-width: 400px;
  padding: 13px 17px;
  border-radius: 8px;
  background: #303c47;
  color: #fff;
  box-shadow: var(--shadow);
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
@keyframes appear {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
}
@media (max-width: 720px) {
  .topbar {
    align-items: center;
    padding: 12px 14px;
  }
  .top-actions {
    align-items: stretch;
  }
  .participant-identity {
    grid-template-columns: 38px minmax(0, 1fr);
    gap: 9px;
    max-width: calc(100vw - 118px);
  }
  .participant-avatar {
    width: 38px;
    height: 38px;
    font-size: 13px;
  }
  .participant-identity-copy strong {
    display: -webkit-box;
    overflow: hidden;
    font-size: 14px;
    line-height: 1.15;
    white-space: normal;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }
  .participant-identity-copy > span {
    font-size: 11px;
  }
  #logoutButton {
    flex: 0 0 auto;
    min-height: 44px;
    padding-inline: 14px;
  }
  main {
    width: min(100% - 20px, 1180px);
    padding-top: 18px;
  }
  .auth-screen {
    min-height: calc(100vh - 36px);
  }
  .auth-card,
  .instruction-card {
    padding: 25px;
  }
  .form-grid {
    grid-template-columns: 1fr;
    padding: 20px;
  }
  .full {
    grid-column: auto;
  }
  .test-header {
    grid-template-columns: 1fr;
    padding: 19px;
  }
  .active-assignment,
  .result-header,
  .complete-box {
    display: block;
  }
  .active-assignment button,
  .complete-box button {
    width: 100%;
    margin-top: 18px;
  }
  .history-card {
    grid-template-columns: 1fr;
  }
  .history-card button {
    width: 100%;
  }
  .instruction-actions {
    flex-direction: column-reverse;
  }
  .instruction-actions button {
    width: 100%;
  }
  .question-card {
    padding: 18px 16px;
  }
  .answers {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
  }
  .answer span {
    min-width: 0;
    padding: 10px 6px;
  }
  .pager {
    bottom: 8px;
  }
  .pager span {
    font-size: 13px;
  }
  .result-actions {
    margin-top: 18px;
  }
  .result-actions button {
    flex: 1;
  }
  .tabs {
    margin-left: 0;
  }
  .tabs button {
    flex: 1;
    padding: 11px 8px;
  }
  .tab-panel {
    padding: 16px;
  }
  .scale-row {
    grid-template-columns: 1fr;
  }
  .scale-code {
    text-align: left;
  }
  .bar-labels {
    font-size: 12px;
  }
}
@media print {
  .topbar,
  .tabs,
  .result-actions {
    display: none !important;
  }
  body {
    background: #fff;
  }
  main {
    width: 100%;
    padding: 0;
  }
  .screen {
    display: none !important;
  }
  #resultScreen {
    display: block !important;
  }
  .result-header,
  .tab-panel {
    box-shadow: none;
    border: 0;
  }
  .tab-panel {
    display: none !important;
  }
  .tab-panel.active {
    display: block !important;
  }
  @page {
    margin: 12mm;
  }
}

/* Sprint 2: product composition */
:root {
  --ink: #172b3a;
  --muted: #536878;
  --accent: #1769aa;
  --accent-dark: #0f548d;
  --accent-soft: #e8f2fa;
}
.primary {
  background: var(--accent);
  box-shadow: 0 8px 18px rgba(23, 105, 170, 0.22);
}
.quiet {
  background: #e9f0f5;
  color: var(--ink);
}
.outline {
  color: var(--ink);
  border-color: #aebdca;
}
.cabinet-intro {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 28px;
  margin: 22px 0 24px;
}
.cabinet-intro h1 {
  margin: 0;
  color: var(--ink);
  font-size: clamp(34px, 5vw, 52px);
  line-height: 1.04;
  overflow-wrap: anywhere;
}
.cabinet-intro > p {
  max-width: 430px;
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.5;
}
.active-assignment {
  min-height: 220px;
  padding: clamp(26px, 4vw, 42px);
  border-left: 0;
  border-top: 5px solid var(--accent);
  border-radius: 18px;
  background: linear-gradient(110deg, #fff 0 68%, #edf6fc 68%);
}
.active-assignment h2 {
  max-width: 650px;
  color: var(--ink);
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.08;
}
.active-assignment p {
  max-width: 650px;
  margin-top: 12px;
  font-size: 16px;
  line-height: 1.55;
}
.assignment-copy {
  flex: 1;
}
.assignment-cta {
  min-width: 230px;
  min-height: 54px;
  font-size: 16px;
}
.cabinet-progress {
  width: min(520px, 100%);
  height: 9px;
  margin-top: 22px;
  overflow: hidden;
  border-radius: 99px;
  background: #dce7ef;
}
.cabinet-progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}
.help-link {
  color: var(--accent-dark);
  font-weight: 750;
}
.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  margin-top: 38px;
}
.history-card {
  border-radius: 14px;
  box-shadow: none;
}
.empty {
  display: grid;
  gap: 8px;
  padding: 34px;
  text-align: left;
  border-radius: 14px;
}
.empty strong {
  color: var(--ink);
  font-size: 18px;
}
.empty span {
  line-height: 1.55;
}
.test-header {
  position: sticky;
  top: 76px;
  z-index: 9;
  border-radius: 16px;
  box-shadow: 0 12px 30px rgba(16, 42, 67, 0.1);
}
.progress-jump {
  min-height: 36px;
  margin-top: 10px;
  padding: 6px 10px;
  font-size: 13px;
}
.question-card {
  position: relative;
  padding: 26px 26px 24px;
  border-radius: 14px;
  border-left: 5px solid #c8d3dc;
  transition:
    border-color 0.15s,
    background 0.15s;
}
.question-card.answered {
  border-left-color: var(--good);
}
.question-card.saving {
  border-left-color: var(--warning);
  background: #fffcf5;
}
.question-card.save-error {
  border-color: #d98f8f;
  border-left-color: var(--danger);
  background: var(--danger-bg);
}
.question-state {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.question-card.answered .question-state {
  color: var(--good);
}
.question-card.saving .question-state {
  color: var(--warning);
}
.question-card.save-error .question-state {
  color: var(--danger);
}
.pager {
  border-radius: 14px;
  box-shadow: 0 14px 34px rgba(16, 42, 67, 0.15);
}
.result-header {
  align-items: flex-start;
  padding: 30px;
  border-radius: 16px;
}
.result-header h1 {
  color: var(--ink);
  font-size: clamp(30px, 4vw, 42px);
  overflow-wrap: anywhere;
}
.result-header p {
  color: #3f5668;
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.result-summary {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 30px;
  padding: 28px 30px;
  margin-bottom: 20px;
  color: #fff;
  border-radius: 16px;
  background: #102a43;
}
.result-summary h2 {
  margin: 0 0 10px;
  font-size: clamp(24px, 3vw, 34px);
}
.result-summary p:not(.eyebrow) {
  max-width: 720px;
  margin: 0;
  color: #d7e5ef;
  line-height: 1.6;
}
.result-summary .eyebrow {
  color: #8fc8f1 !important;
}
.summary-metrics {
  display: flex;
  gap: 12px;
}
.summary-metrics span {
  display: grid;
  align-content: center;
  min-width: 100px;
  padding: 16px;
  text-align: center;
  color: #d7e5ef;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 12px;
}
.summary-metrics strong {
  display: block;
  color: #fff;
  font-size: 28px;
}
.tabs {
  margin-left: 0;
  gap: 6px;
}
.tabs button {
  min-height: 48px;
  color: #334b5d;
  border: 1px solid #afbfcb;
  border-bottom: 1px solid #afbfcb;
  border-radius: 10px;
}
.tabs button.active {
  color: #fff;
  background: var(--accent);
  box-shadow: inset 0 -4px 0 #f2b84b;
}
.tab-panel {
  border-radius: 14px;
}
.scale-code {
  color: var(--ink);
}
.bar-labels {
  color: #40586a;
  font-weight: 600;
}
.marker {
  color: var(--ink);
  border-color: #718597;
}
.marker.manic-marker {
  color: var(--ink);
  background: #f4bf26;
  border-color: #8c6900;
}

@media (max-width: 720px) {
  .cabinet-intro {
    display: block;
    margin-top: 12px;
  }
  .cabinet-intro > p {
    margin-top: 12px;
  }
  .active-assignment {
    min-height: 0;
    padding: 26px 22px;
    background: #fff;
  }
  .active-assignment h2 {
    font-size: 28px;
  }
  .assignment-cta {
    min-width: 0;
    min-height: 52px;
  }
  .test-header {
    position: static;
    top: auto;
  }
  .pager {
    position: static;
    bottom: auto;
    margin: 18px 0 max(20px, env(safe-area-inset-bottom));
    box-shadow: none;
  }
  .test-screen {
    padding-bottom: max(20px, env(safe-area-inset-bottom));
  }
  .question-card {
    padding: 20px 16px;
  }
  .result-header {
    padding: 22px 20px;
  }
  .result-header h1 {
    color: var(--ink);
  }
  .result-header p {
    color: #354d60;
  }
  .result-summary {
    grid-template-columns: 1fr;
    padding: 24px 20px;
  }
  .summary-metrics {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
  .tabs {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
  }
  .tabs button {
    width: 100%;
    font-size: 14px;
  }
  .scale-row {
    gap: 8px;
    margin-bottom: 34px;
  }
  .bar-labels {
    gap: 12px;
    font-size: 13px;
  }
  .bar-labels span {
    max-width: 48%;
    overflow-wrap: anywhere;
  }
  .marker {
    min-width: 44px;
    font-size: 17px;
  }
}
@media (max-width: 350px) {
  main {
    width: calc(100% - 14px);
  }
  .brand {
    font-size: 16px;
  }
  .topbar {
    gap: 8px;
    padding-inline: 10px;
  }
  .question-card p {
    font-size: 17px;
  }
  .answer span {
    padding-inline: 3px;
    font-size: 14px;
  }
  .pager {
    grid-template-columns: 1fr 1fr;
  }
  .pager span {
    grid-column: 1/-1;
    grid-row: 1;
  }
}
@media (min-resolution: 1.9dppx) and (max-width: 720px) {
  .pager {
    position: static;
  }
}
