:root {
  --ink: #151a18;
  --muted: #66706b;
  --paper: #f3f1e9;
  --panel: #fbfaf5;
  --line: #d8d7cd;
  --orange: #f35b28;
  --orange-dark: #d64316;
  --green: #145f49;
  --green-soft: #dbe9df;
  --yellow: #f2bc3b;
  --red: #bf3a2b;
  --mono: "DM Mono", monospace;
  --sans: "Manrope", sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; }
button { color: inherit; }

.paper-noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .18;
  z-index: 20;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.12'/%3E%3C/svg%3E");
}

.topbar {
  height: 72px;
  padding: 0 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  background: rgba(243, 241, 233, .92);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(12px);
}

.wordmark {
  color: var(--ink);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font: 500 12px/1 var(--mono);
  letter-spacing: .11em;
}

.mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  color: white;
  background: var(--orange);
  font: 500 15px/1 var(--mono);
}

.topbar-meta {
  display: flex;
  align-items: center;
  gap: 18px;
  color: var(--muted);
  font: 400 12px/1 var(--mono);
}

.divider { height: 18px; width: 1px; background: var(--line); }

main { min-height: calc(100vh - 72px); }
.view { display: none; }
.view.active { display: flex; }

.intro {
  width: min(1240px, calc(100% - 80px));
  min-height: calc(100vh - 72px);
  margin: 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 80px;
  padding: 72px 0;
}

.intro-copy { max-width: 740px; }
.eyebrow {
  margin: 0 0 24px;
  color: var(--orange-dark);
  text-transform: uppercase;
  font: 500 11px/1.4 var(--mono);
  letter-spacing: .14em;
}

h1 {
  max-width: 760px;
  margin: 0;
  font-size: clamp(58px, 7.2vw, 108px);
  font-weight: 500;
  line-height: .94;
  letter-spacing: -.065em;
}

h1 em { font-family: Georgia, serif; font-weight: 400; color: var(--green); }

.lede {
  max-width: 650px;
  margin: 36px 0;
  color: #4f5854;
  font-size: 18px;
  line-height: 1.65;
}

.primary-button, .secondary-button, .text-button, .flag-button, .icon-button {
  border: 0;
  cursor: pointer;
}

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 44px;
  min-width: 272px;
  padding: 17px 20px;
  border-radius: 4px;
  background: var(--ink);
  color: white;
  font-size: 14px;
  font-weight: 600;
  transition: transform .16s ease, background .16s ease;
}

.primary-button:hover { transform: translateY(-2px); background: var(--green); }
.primary-button.compact { min-width: 130px; gap: 20px; }
.primary-button:disabled, .secondary-button:disabled { opacity: .35; pointer-events: none; }

.resume-note { color: var(--green); font: 500 12px/1.4 var(--mono); }

.brief-card {
  flex: 0 0 330px;
  padding: 30px;
  border: 1px solid var(--line);
  border-top: 5px solid var(--orange);
  background: rgba(251, 250, 245, .65);
  box-shadow: 16px 16px 0 rgba(20, 95, 73, .08);
}

.brief-number { font: 400 84px/.9 Georgia, serif; color: var(--green); letter-spacing: -.06em; }
.brief-card > p { margin: 8px 0 30px; color: var(--muted); font: 400 11px/1 var(--mono); text-transform: uppercase; letter-spacing: .12em; }
.brief-card dl { margin: 0; }
.brief-card dl div { display: flex; justify-content: space-between; padding: 14px 0; border-top: 1px solid var(--line); }
.brief-card dt, .brief-card dd { margin: 0; font-size: 13px; }
.brief-card dt { color: var(--muted); }
.brief-card dd { font-weight: 600; text-align: right; }
.brief-card .fine-print { margin: 20px 0 0; text-transform: none; letter-spacing: 0; line-height: 1.55; }
.brief-card .fine-print a { color: var(--green); text-decoration-color: rgba(20, 95, 73, .35); text-underline-offset: 2px; }

.quiz {
  height: calc(100vh - 72px);
  height: calc(100dvh - 72px);
  min-height: 0;
  overflow: hidden;
}
.rail {
  display: flex;
  flex-direction: column;
  width: clamp(240px, 20vw, 300px);
  min-height: 0;
  padding: clamp(14px, 2vh, 24px) clamp(14px, 1.6vw, 22px);
  border-right: 1px solid var(--line);
  background: #ebe9e0;
  overflow: hidden;
}

.rail-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: clamp(8px, 1.2vh, 14px); font: 500 10px/1 var(--mono); letter-spacing: .12em; text-transform: uppercase; }
.question-grid {
  display: grid;
  flex: 1;
  min-height: 0;
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(20, minmax(0, 1fr));
  gap: clamp(2px, .55vh, 6px);
}
.question-grid button {
  min-width: 0;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: rgba(251, 250, 245, .7);
  color: var(--muted);
  cursor: pointer;
  font: 400 clamp(8px, 1.15vh, 10px)/1 var(--mono);
  position: relative;
}

.question-grid button.current { outline: 2px solid var(--ink); outline-offset: 1px; color: var(--ink); font-weight: 500; z-index: 1; }
.question-grid button.correct { background: var(--green); border-color: var(--green); color: white; }
.question-grid button.incorrect { background: var(--red); border-color: var(--red); color: white; }
.question-grid button.current.correct, .question-grid button.current.incorrect { color: white; }
.question-grid button.flagged::after { content: ""; position: absolute; width: 7px; height: 7px; top: -3px; right: -3px; border: 2px solid #ebe9e0; border-radius: 50%; background: var(--yellow); }
.legend { margin-top: clamp(8px, 1.2vh, 14px); display: flex; flex-wrap: wrap; gap: 8px 14px; color: var(--muted); font: 400 9px/1 var(--mono); }
.legend span { display: flex; align-items: center; gap: 8px; }
.dot { width: 8px; height: 8px; border-radius: 50%; }
.dot.correct { background: var(--green); }
.dot.incorrect { background: var(--red); }
.dot.flagged { background: var(--yellow); }

.question-stage { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.question-toolbar { height: clamp(54px, 9vh, 72px); min-height: 0; padding: 0 clamp(24px, 3.2vw, 48px); border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.question-context { display: flex; align-items: center; gap: 14px; color: var(--muted); font: 400 11px/1 var(--mono); }
.subject-pill { padding: 7px 9px; border-radius: 20px; color: var(--green); background: var(--green-soft); }
.flag-button { padding: 10px 0; background: transparent; color: var(--muted); font: 500 11px/1 var(--mono); }
.flag-button.active { color: #946400; }

.question-body { width: min(1040px, calc(100% - 80px)); height: 100%; min-height: 0; margin: 0 auto; padding: clamp(14px, 2.6vh, 30px) 0; display: flex; flex-direction: column; justify-content: center; }
.question-body .eyebrow { margin-bottom: clamp(8px, 1.4vh, 14px); }
.question-body h2 { margin: 0 0 clamp(14px, 2.6vh, 28px); font-size: clamp(20px, 2.8vh, 32px); line-height: 1.22; letter-spacing: -.025em; font-weight: 500; white-space: pre-wrap; }
.choices { display: grid; gap: clamp(6px, 1vh, 10px); margin: 0; padding: 0; border: 0; }
.choice {
  display: grid;
  grid-template-columns: 38px 1fr;
  align-items: center;
  gap: 16px;
  min-height: clamp(44px, 6.5vh, 58px);
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: rgba(251, 250, 245, .72);
  cursor: pointer;
  font-size: 14px;
  line-height: 1.3;
  transition: border .12s ease, background .12s ease, transform .12s ease;
}

.choice:hover { border-color: #9b9f99; transform: translateX(3px); }
.choice.selected { border-color: var(--green); background: var(--green-soft); }
.choice-letter { display: grid; place-items: center; width: 30px; height: 30px; border: 1px solid var(--line); border-radius: 50%; font: 500 11px/1 var(--mono); }
.choice.selected .choice-letter { border-color: var(--green); background: var(--green); color: white; }
.choice.correct { border-color: var(--green); background: var(--green-soft); }
.choice.incorrect { border-color: var(--red); background: #f3ded8; }
.choice.correct .choice-letter { border-color: var(--green); background: var(--green); color: white; }
.choice.incorrect .choice-letter { border-color: var(--red); background: var(--red); color: white; }
.choice.locked { cursor: default; }
.choice.locked:hover { transform: none; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }

.instant-feedback {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 16px;
  margin-top: clamp(8px, 1.2vh, 12px);
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-left-width: 4px;
  border-radius: 4px;
  background: var(--panel);
}
.instant-feedback[hidden] { display: none; }
.instant-feedback.is-correct { border-left-color: var(--green); }
.instant-feedback.is-incorrect { border-left-color: var(--red); }
.feedback-verdict { font-size: 13px; font-weight: 700; }
.is-correct .feedback-verdict { color: var(--green); }
.is-incorrect .feedback-verdict { color: var(--red); }
.feedback-answer { grid-column: 2; color: var(--muted); font-size: 12px; line-height: 1.4; }

.question-footer { height: clamp(58px, 9vh, 72px); min-height: 0; padding: 0 clamp(24px, 3.2vw, 48px); border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.secondary-button { padding: 14px 18px; border: 1px solid var(--line); border-radius: 4px; background: transparent; font-size: 13px; font-weight: 600; }
.secondary-button:hover { border-color: var(--ink); }
.keyboard-hint { color: #8b918d; font: 400 10px/1 var(--mono); }
kbd { padding: 3px 5px; border: 1px solid var(--line); border-radius: 3px; background: #ebe9e0; }
.mobile-only { display: none; }

.question-stage[data-density="dense-1"] .question-body { padding-top: 10px; padding-bottom: 10px; }
.question-stage[data-density="dense-1"] .question-body h2 { margin-bottom: 12px; font-size: clamp(16px, 2.15vh, 22px); line-height: 1.18; }
.question-stage[data-density="dense-1"] .choice { min-height: 40px; padding-top: 6px; padding-bottom: 6px; font-size: 13px; }

.question-stage[data-density="dense-2"] .question-body,
.question-stage[data-density="dense-3"] .question-body { padding-top: 8px; padding-bottom: 8px; }
.question-stage[data-density="dense-2"] .question-body h2 { margin-bottom: 10px; font-size: clamp(14px, 1.9vh, 19px); line-height: 1.16; }
.question-stage[data-density="dense-3"] .question-body h2 { margin-bottom: 8px; font-size: clamp(12px, 1.65vh, 17px); line-height: 1.14; }
.question-stage[data-density="dense-2"] .choices,
.question-stage[data-density="dense-3"] .choices { gap: 5px; }
.question-stage[data-density="dense-2"] .choice,
.question-stage[data-density="dense-3"] .choice { min-height: 36px; padding: 5px 10px; font-size: 12px; line-height: 1.2; }
.question-stage[data-density="dense-2"] .choice-letter,
.question-stage[data-density="dense-3"] .choice-letter { width: 26px; height: 26px; font-size: 10px; }
.question-stage[data-density="dense-2"] .instant-feedback,
.question-stage[data-density="dense-3"] .instant-feedback { margin-top: 6px; padding: 7px 10px; }

.results { width: min(1180px, calc(100% - 80px)); margin: 0 auto; padding: 72px 0 100px; gap: 80px; align-items: flex-start; }
.score-hero { flex: 0 0 420px; position: sticky; top: 130px; }
.score-lockup { display: flex; align-items: flex-start; color: var(--green); letter-spacing: -.075em; }
.score-lockup strong { font: 400 150px/.8 Georgia, serif; }
.score-lockup span { margin-top: 8px; font: 400 42px/1 Georgia, serif; }
.score-fraction { margin: 28px 0 10px; font-size: 18px; font-weight: 600; }
.confidence { color: var(--muted); font: 400 12px/1.5 var(--mono); }
.estimate-note { max-width: 330px; margin-top: 32px; padding-top: 24px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; line-height: 1.6; }
.result-detail { flex: 1; min-width: 0; }
.result-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; padding-bottom: 28px; border-bottom: 1px solid var(--line); }
.result-heading .eyebrow { margin-bottom: 10px; }
.result-heading h2 { margin: 0; font-size: 36px; font-weight: 500; letter-spacing: -.035em; }
.domain-bars { padding: 10px 0 30px; }
.domain-row { padding: 22px 0; border-bottom: 1px solid var(--line); }
.domain-row header { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 11px; }
.domain-row h3 { margin: 0; font-size: 14px; font-weight: 600; }
.domain-row span { color: var(--muted); font: 400 11px/1 var(--mono); }
.bar { height: 7px; overflow: hidden; border-radius: 10px; background: #deddd5; }
.bar i { display: block; height: 100%; background: var(--orange); border-radius: inherit; }
.result-actions { display: flex; justify-content: space-between; align-items: center; padding-top: 26px; color: var(--muted); font: 400 11px/1 var(--mono); }
.text-button { padding: 8px 0; background: transparent; color: var(--green); font-size: 12px; font-weight: 600; }
.text-button.danger { color: var(--red); }

dialog { width: min(500px, calc(100% - 32px)); padding: 0; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); box-shadow: 0 20px 80px rgba(21, 26, 24, .28); }
dialog::backdrop { background: rgba(21, 26, 24, .56); backdrop-filter: blur(4px); }
dialog form { padding: 38px; position: relative; }
dialog .eyebrow { margin-bottom: 14px; }
dialog h2 { margin: 0 0 14px; font-size: 30px; font-weight: 500; }
dialog p:not(.eyebrow) { color: var(--muted); line-height: 1.6; }
.dialog-close { position: absolute; top: 18px; right: 20px; border: 0; background: transparent; font-size: 24px; cursor: pointer; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 28px; }

@media (max-width: 900px) {
  .topbar { padding: 0 20px; }
  .intro { width: min(100% - 40px, 700px); flex-direction: column; align-items: stretch; gap: 60px; padding: 54px 0; }
  .brief-card { flex-basis: auto; }
  .rail { display: none; position: fixed; inset: 72px auto 0 0; z-index: 8; width: min(330px, 92vw); box-shadow: 18px 0 60px rgba(21, 26, 24, .2); }
  .rail.open { display: flex; }
  .mobile-only { display: inline-flex; }
  .question-toolbar, .question-footer { padding-left: 24px; padding-right: 24px; }
  .question-context { margin-right: auto; }
  .question-body { width: calc(100% - 48px); }
  .keyboard-hint { display: none; }
  .results { width: calc(100% - 40px); flex-direction: column; gap: 54px; }
  .score-hero { position: static; flex-basis: auto; }
  .result-detail { width: 100%; }
}

@media (max-width: 560px) {
  .topbar-meta #answeredTop, .topbar-meta .divider { display: none; }
  .intro { min-height: auto; }
  h1 { font-size: 52px; }
  .lede { font-size: 16px; }
  .question-context { flex-direction: column; align-items: flex-start; gap: 6px; }
  .question-toolbar { min-height: 86px; }
  .question-body { padding: clamp(10px, 2vh, 18px) 0; }
  .question-body h2 { font-size: 18px; margin-bottom: 14px; }
  .choice { grid-template-columns: 32px 1fr; gap: 12px; padding: 11px 12px; }
  .choice-letter { width: 30px; height: 30px; }
  .instant-feedback { grid-template-columns: 1fr; }
  .feedback-answer { grid-column: 1; }
  .question-footer { min-height: 78px; }
  .primary-button.compact, .secondary-button { min-width: 0; padding: 13px 14px; }
  .results { padding-top: 54px; }
  .score-lockup strong { font-size: 120px; }
  .result-heading { align-items: flex-start; flex-direction: column; }
  .dialog-actions { flex-direction: column-reverse; }
  .dialog-actions button { width: 100%; }
}

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