:root {
  --bg: #0f1220;
  --surface: #191e2f;
  --surface-2: #222a3d;
  --surface-3: #111725;
  --border: #303953;
  --border-strong: #596783;
  --text: #eee9dd;
  --muted: #a4adbe;
  --gold: #e8b830;
  --gold-dark: #b98716;
  --teal: #45b7a5;
  --green: #3fb477;
  --red: #d86659;
  --radius: 6px;
}

* {
  box-sizing: border-box;
}

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

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "EB Garamond", Georgia, serif;
  font-size: 18px;
  line-height: 1.45;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

.app-shell {
  width: min(1440px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 22px 28px 52px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 64px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.brand-kicker,
.eyebrow,
.counter,
.metric,
.chapter-chip,
.part-label,
.small-note,
.feedback,
.btn,
label,
table,
.evidence-label {
  font-family: "IBM Plex Mono", Consolas, monospace;
  letter-spacing: 0;
}

.brand-kicker,
.eyebrow {
  margin: 0 0 4px;
  color: var(--gold);
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
}

.brand-title {
  margin: 0;
  font-family: "Cinzel", Georgia, serif;
  font-size: 1.32rem;
  line-height: 1.15;
}

.top-actions,
.home-actions,
.action-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 9px 16px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  font-size: .84rem;
  font-weight: 700;
  text-decoration: none;
}

.btn:hover:not(:disabled),
.btn:focus-visible {
  border-color: var(--gold);
}

.btn.primary {
  border-color: var(--gold);
  background: var(--gold);
  color: #15130d;
}

.btn.next {
  border-color: var(--teal);
  background: var(--teal);
  color: #081714;
}

.btn:disabled {
  opacity: .42;
}

.home-screen {
  max-width: 1120px;
  margin: 0 auto;
  padding: 52px 0 20px;
}

.home-screen h1,
.question-heading h1,
.complete-screen h1 {
  margin: 0;
  font-family: "Cinzel", Georgia, serif;
  font-weight: 700;
  line-height: 1.12;
}

.home-screen h1 {
  max-width: 900px;
  font-size: clamp(2.25rem, 5vw, 3.45rem);
}

.lead {
  max-width: 790px;
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 1.15rem;
}

.metrics {
  display: flex;
  gap: 9px;
  flex-wrap: wrap;
  margin: 24px 0 30px;
}

.metric,
.chapter-chip {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--muted);
  font-size: .72rem;
  font-weight: 700;
}

.test-map {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 0 0 28px;
  padding: 0;
  list-style: none;
}

.test-map li {
  display: grid;
  grid-template-columns: 50px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  min-height: 84px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.test-number {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  color: var(--gold);
  font-family: "IBM Plex Mono", Consolas, monospace;
  font-weight: 700;
}

.test-map strong,
.test-map span {
  display: block;
}

.test-map strong {
  color: var(--text);
  font-size: 1.08rem;
}

.test-map span {
  color: var(--muted);
  font-size: .9rem;
}

.progress-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  color: var(--muted);
  font-family: "IBM Plex Mono", Consolas, monospace;
  font-size: .78rem;
}

.progress-track {
  height: 8px;
  overflow: hidden;
  border-radius: 3px;
  background: var(--surface-2);
}

.progress-fill {
  height: 100%;
  background: var(--gold);
  transition: width .2s ease;
}

.home-actions {
  margin-top: 24px;
}

.question-screen {
  padding-top: 30px;
}

.question-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 16px;
}

.question-heading h1 {
  font-size: clamp(1.75rem, 4vw, 2.65rem);
}

.counter {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: .78rem;
  font-weight: 700;
}

.question-chapter {
  margin: 12px 0 20px;
}

.question-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(390px, .92fr);
  gap: 18px;
  align-items: start;
  margin-top: 20px;
}

.visual-section,
.answer-section {
  min-width: 0;
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.visual-section h2,
.answer-section h2 {
  margin: 0 0 8px;
  font-family: "Cinzel", Georgia, serif;
  font-size: 1.35rem;
}

.section-intro {
  margin: 0 0 18px;
  color: var(--muted);
}

.diagram-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.diagram-tile,
.evidence-card {
  position: relative;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-3);
}

.diagram-tile {
  min-height: 238px;
  padding: 12px;
}

.part-badge,
.evidence-label {
  position: absolute;
  z-index: 2;
  top: 9px;
  left: 10px;
  color: var(--gold);
  font-size: .76rem;
  font-weight: 700;
}

.geometry-svg {
  display: block;
  width: 100%;
  height: auto;
  min-height: 190px;
}

.geometry-svg .line {
  fill: none;
  stroke: var(--text);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.geometry-svg .mark {
  fill: none;
  stroke: var(--gold);
  stroke-width: 3;
  stroke-linecap: round;
}

.geometry-svg .parallel-mark {
  fill: none;
  stroke: var(--teal);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.geometry-svg .shade-gold {
  fill: rgba(232, 184, 48, .25);
  stroke: var(--gold);
  stroke-width: 1.5;
}

.geometry-svg .shade-teal {
  fill: rgba(69, 183, 165, .22);
  stroke: var(--teal);
  stroke-width: 1.5;
}

.geometry-svg text {
  fill: var(--text);
  font-family: "IBM Plex Mono", Consolas, monospace;
  font-size: 17px;
  font-weight: 700;
}

.geometry-svg .x-label {
  fill: var(--gold);
}

.answer-list {
  display: grid;
  gap: 0;
}

.answer-block {
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}

.answer-block:first-child {
  padding-top: 0;
}

.answer-block:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.answer-block h3 {
  margin: 0 0 12px;
  color: var(--gold);
  font-family: "Cinzel", Georgia, serif;
  font-size: 1.05rem;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.field-grid.one {
  grid-template-columns: 1fr;
}

.field {
  min-width: 0;
}

.field.full {
  grid-column: 1 / -1;
}

label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: .76rem;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-width: 0;
  min-height: 46px;
  padding: 9px 11px;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  outline: 0;
  background: #0d1320;
  color: var(--text);
  font-family: "IBM Plex Mono", Consolas, monospace;
  font-size: .95rem;
}

input:focus,
select:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(232, 184, 48, .16);
}

input:disabled,
select:disabled {
  opacity: .82;
}

.input-unit {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.unit {
  color: var(--muted);
  font-family: "IBM Plex Mono", Consolas, monospace;
  font-size: .78rem;
}

.scaffold {
  margin: 0 0 18px;
  padding: 14px 16px;
  border-left: 3px solid var(--gold);
  background: rgba(232, 184, 48, .08);
  color: var(--muted);
}

.scaffold strong {
  color: var(--text);
}

.expression-row {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 14px 0;
}

.expression-row span {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface-3);
  color: var(--gold);
  font-family: "IBM Plex Mono", Consolas, monospace;
  font-weight: 700;
}

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

.evidence-card {
  min-height: 196px;
  padding: 14px 8px 6px;
}

.evidence-card .geometry-svg {
  min-height: 170px;
}

.pair-row {
  display: grid;
  grid-template-columns: 50px minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
  align-items: end;
}

.pair-anchor {
  display: grid;
  place-items: center;
  min-height: 46px;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  color: var(--gold);
  font-family: "IBM Plex Mono", Consolas, monospace;
  font-weight: 700;
}

.survey-context {
  margin: 0 0 16px;
  color: var(--muted);
}

.small-note {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: .7rem;
}

.feedback {
  min-height: 58px;
  margin-top: 18px;
  padding: 15px 17px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
  font-size: .82rem;
}

.feedback.good {
  border-color: var(--green);
  background: rgba(63, 180, 119, .1);
  color: #a4e3c1;
}

.feedback.bad {
  border-color: var(--red);
  background: rgba(216, 102, 89, .1);
  color: #efb3aa;
}

.action-row {
  justify-content: flex-end;
  margin-top: 14px;
}

.complete-screen {
  max-width: 760px;
  margin: 0 auto;
  padding: 84px 0 30px;
  text-align: center;
}

.complete-mark {
  display: grid;
  place-items: center;
  width: 84px;
  height: 84px;
  margin: 0 auto 20px;
  border: 2px solid var(--green);
  border-radius: 50%;
  color: var(--green);
  font-family: "IBM Plex Mono", Consolas, monospace;
  font-size: 1.3rem;
  font-weight: 700;
}

.complete-screen .home-actions {
  justify-content: center;
}

.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: 1040px) {
  .question-grid {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 700px) {
  body {
    font-size: 16px;
  }

  .app-shell {
    padding: 14px 14px 36px;
  }

  .topbar,
  .question-heading {
    align-items: flex-start;
  }

  .topbar {
    flex-direction: column;
  }

  .test-map,
  .diagram-grid,
  .field-grid,
  .evidence-grid {
    grid-template-columns: 1fr;
  }

  .visual-section,
  .answer-section {
    padding: 16px;
  }

  .pair-row {
    grid-template-columns: 44px minmax(0, 1fr);
  }

  .pair-row .field:last-child {
    grid-column: 2;
  }

  .action-row {
    justify-content: stretch;
  }

  .action-row .btn {
    flex: 1 1 150px;
  }
}
