:root {
  color-scheme: light;
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-2: #eef3f5;
  --ink: #16212f;
  --muted: #5e6a79;
  --line: #d9e1e6;
  --line-strong: #b8c5cf;
  --green: #14796f;
  --green-soft: #dff2ed;
  --blue: #285cc4;
  --blue-soft: #e7edff;
  --amber: #a95f00;
  --amber-soft: #fff0d8;
  --rose: #b23a48;
  --rose-soft: #ffe8ec;
  --shadow: 0 18px 45px rgba(24, 38, 52, 0.09);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

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

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 14px clamp(16px, 3vw, 36px);
  border-bottom: 1px solid var(--line);
  background: rgba(246, 248, 251, 0.92);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  gap: 10px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid #0e554e;
  border-radius: var(--radius);
  background: var(--green);
  color: #fff;
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
  line-height: 1.15;
}

.brand small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.78rem;
}

.status-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  color: var(--muted);
  font-size: 0.9rem;
}

.status-strip span {
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
}

.status-strip .time-danger {
  color: var(--rose);
  border-color: #f3b7c0;
  background: var(--rose-soft);
  font-weight: 800;
}

.screen {
  flex: 1;
  width: min(1240px, 100%);
  margin: 0 auto;
  padding: clamp(18px, 3vw, 34px);
}

.screen:focus {
  outline: none;
}

.start-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(310px, 0.92fr);
  gap: 24px;
  align-items: stretch;
}

.intro-panel,
.side-panel,
.question-panel,
.navigator,
.result-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.intro-panel {
  padding: clamp(24px, 4vw, 44px);
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--green);
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  max-width: 760px;
  margin-bottom: 16px;
  font-size: clamp(2.2rem, 5vw, 4.5rem);
  line-height: 0.96;
  letter-spacing: 0;
}

.lead {
  max-width: 760px;
  color: #334155;
  font-size: clamp(1.04rem, 1.9vw, 1.22rem);
  line-height: 1.65;
}

.start-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 24px;
}

.primary-btn,
.secondary-btn,
.ghost-btn,
.choice,
.nav-dot {
  border-radius: var(--radius);
  border: 1px solid transparent;
  transition:
    transform 0.16s ease,
    border-color 0.16s ease,
    background 0.16s ease,
    color 0.16s ease,
    box-shadow 0.16s ease;
}

.primary-btn,
.secondary-btn,
.ghost-btn {
  min-height: 42px;
  padding: 10px 15px;
  font-weight: 800;
}

.primary-btn {
  background: var(--green);
  color: #fff;
  border-color: #0e554e;
}

.secondary-btn {
  background: var(--ink);
  color: #fff;
  border-color: #0c1320;
}

.ghost-btn {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line-strong);
}

.primary-btn:hover,
.secondary-btn:hover,
.ghost-btn:hover,
.choice:hover,
.nav-dot:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(24, 38, 52, 0.1);
}

.primary-btn:focus-visible,
.secondary-btn:focus-visible,
.ghost-btn:focus-visible,
.choice:focus-visible,
.nav-dot:focus-visible {
  outline: 3px solid rgba(40, 92, 196, 0.28);
  outline-offset: 2px;
}

.side-panel {
  padding: 20px;
}

.metric-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}

.metric {
  min-height: 86px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.metric strong {
  display: block;
  font-size: clamp(1.35rem, 3vw, 2rem);
  line-height: 1;
}

.metric span {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.88rem;
}

.section-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.section-list li {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.section-token {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 50%;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 0.8rem;
  font-weight: 900;
}

.section-list b {
  display: block;
  line-height: 1.25;
}

.section-list small {
  color: var(--muted);
}

.note {
  margin: 18px 0 0;
  padding: 13px 14px;
  border-left: 4px solid var(--amber);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--amber-soft);
  color: #5f3a0a;
  line-height: 1.55;
}

.test-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 312px;
  gap: 18px;
  align-items: start;
}

.question-panel {
  min-height: calc(100vh - 128px);
  padding: clamp(18px, 3vw, 28px);
}

.question-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 18px;
  color: var(--muted);
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 0.86rem;
  font-weight: 800;
}

.pill.green {
  color: var(--green);
  background: var(--green-soft);
  border-color: #b9ded6;
}

.pill.blue {
  color: var(--blue);
  background: var(--blue-soft);
  border-color: #c5d2ff;
}

.pill.rose {
  color: var(--rose);
  background: var(--rose-soft);
  border-color: #f4bdc5;
}

.question-title {
  margin-bottom: 8px;
  font-size: clamp(1.35rem, 2.2vw, 2rem);
  line-height: 1.25;
}

.question-detail {
  margin-bottom: 18px;
  color: var(--muted);
  line-height: 1.55;
}

.visual-stage {
  margin: 18px 0 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfd;
  overflow: hidden;
}

.visual-stage.empty {
  border: 0;
  background: transparent;
  margin-top: 8px;
}

.matrix-board {
  display: grid;
  grid-template-columns: repeat(3, minmax(74px, 1fr));
  gap: 8px;
  width: min(430px, 100%);
  padding: 16px;
  margin: 0 auto;
}

.matrix-cell,
.choice-visual {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.matrix-cell.missing {
  border-style: dashed;
  color: var(--muted);
  font-size: 2rem;
  font-weight: 900;
  background: repeating-linear-gradient(
    45deg,
    #f6f8fb,
    #f6f8fb 8px,
    #edf2f6 8px,
    #edf2f6 16px
  );
}

.choice-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.choice {
  min-height: 78px;
  padding: 12px;
  border-color: var(--line);
  background: var(--surface);
  color: var(--ink);
  text-align: left;
}

.choice.selected {
  border-color: #0e554e;
  background: var(--green-soft);
  box-shadow: inset 0 0 0 2px rgba(20, 121, 111, 0.22);
}

.choice.correct {
  border-color: var(--green);
  background: var(--green-soft);
}

.choice.wrong {
  border-color: var(--rose);
  background: var(--rose-soft);
}

.choice-label {
  display: inline-grid;
  width: 26px;
  height: 26px;
  margin-right: 8px;
  place-items: center;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--muted);
  font-weight: 900;
  vertical-align: top;
}

.choice-text {
  display: inline;
  line-height: 1.45;
}

.choice.has-visual {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: center;
}

.choice.has-visual .choice-visual {
  width: 96px;
  max-width: 100%;
}

.symbol-key {
  display: grid;
  grid-template-columns: repeat(5, minmax(70px, 1fr));
  gap: 8px;
  padding: 16px;
}

.symbol-card {
  display: grid;
  gap: 8px;
  justify-items: center;
  padding: 12px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.symbol-sequence {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  padding: 0 16px 18px;
}

.sequence-chip {
  display: grid;
  min-width: 54px;
  min-height: 54px;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #fff;
}

.spatial-wrap {
  display: grid;
  grid-template-columns: minmax(150px, 220px) minmax(180px, 1fr);
  gap: 16px;
  align-items: center;
  padding: 18px;
}

.spatial-prompt {
  color: var(--muted);
  line-height: 1.55;
}

.navigator {
  position: sticky;
  top: 86px;
  padding: 16px;
}

.progress-line {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-2);
}

.progress-line span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--green), var(--blue));
}

.navigator h3 {
  margin: 14px 0 10px;
  font-size: 1rem;
}

.nav-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 6px;
}

.nav-dot {
  display: grid;
  min-width: 0;
  height: 32px;
  place-items: center;
  border-color: var(--line);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
}

.nav-dot.answered {
  color: var(--green);
  background: var(--green-soft);
  border-color: #b9ded6;
}

.nav-dot.current {
  color: #fff;
  background: var(--blue);
  border-color: #173c8e;
}

.nav-dot.flagged::after {
  content: "";
  position: absolute;
}

.section-progress {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.section-progress-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  color: var(--muted);
  font-size: 0.88rem;
}

.control-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.control-row .left,
.control-row .right {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.result-panel {
  padding: clamp(20px, 3vw, 34px);
}

.result-head {
  display: grid;
  grid-template-columns: minmax(240px, 0.78fr) minmax(0, 1fr);
  gap: 22px;
  align-items: center;
}

.iq-card {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfd;
}

.iq-number {
  font-size: clamp(4rem, 10vw, 7rem);
  line-height: 0.9;
  font-weight: 900;
  letter-spacing: 0;
}

.iq-band {
  margin-top: 10px;
  color: var(--muted);
  line-height: 1.55;
}

.result-copy {
  color: #334155;
  line-height: 1.65;
}

.domain-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin-top: 22px;
}

.domain-card {
  min-height: 152px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.domain-card b {
  display: block;
  margin-bottom: 8px;
}

.bar {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-2);
}

.bar span {
  display: block;
  height: 100%;
  background: var(--blue);
}

.domain-card small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.45;
}

.review-list {
  display: grid;
  gap: 10px;
  margin-top: 20px;
}

.review-item {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfd;
}

.review-item b {
  display: block;
  margin-bottom: 6px;
}

.review-item p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.55;
}

.source-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.source-list a {
  color: var(--blue);
  text-decoration-thickness: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 980px) {
  .start-grid,
  .test-layout,
  .result-head,
  .domain-grid {
    grid-template-columns: 1fr;
  }

  .navigator {
    position: static;
    order: -1;
  }

  .question-panel {
    min-height: auto;
  }

  .nav-grid {
    grid-template-columns: repeat(10, 1fr);
  }

  .domain-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 680px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .status-strip {
    justify-content: flex-start;
  }

  .screen {
    padding: 14px;
  }

  .metric-row,
  .choice-grid,
  .symbol-key,
  .domain-grid {
    grid-template-columns: 1fr;
  }

  .choice.has-visual {
    grid-template-columns: 1fr;
  }

  .choice.has-visual .choice-visual {
    width: 100%;
    max-height: 150px;
  }

  .spatial-wrap {
    grid-template-columns: 1fr;
  }

  .nav-grid {
    grid-template-columns: repeat(8, 1fr);
  }
}
