:root {
  color-scheme: light;
  --bg: #f6f7fb;
  --panel: #ffffff;
  --ink: #20242c;
  --muted: #667085;
  --line: #d9dee8;
  --primary: #1769aa;
  --primary-dark: #0f4f82;
  --accent: #2b8a66;
  --warning: #a05a00;
  --danger: #b42318;
  --shadow: 0 18px 50px rgba(32, 36, 44, 0.1);
}

* {
  box-sizing: border-box;
}

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

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0;
}

.setup-view {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 32px;
  align-items: center;
  min-height: calc(100vh - 64px);
}

.brand-block h1 {
  margin: 0;
  max-width: 760px;
  font-size: clamp(2.4rem, 6vw, 5.2rem);
  line-height: 0.96;
  letter-spacing: 0;
}

.intro {
  max-width: 680px;
  color: var(--muted);
  font-size: 1.12rem;
  line-height: 1.7;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--primary);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.config-panel,
.question-panel,
.question-map,
.results-header,
.summary-card,
.review-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.config-panel {
  display: grid;
  gap: 18px;
  padding: 24px;
}

.field {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-weight: 650;
}

.field input,
.field select,
.manual-answer {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px 14px;
  background: #fff;
  color: var(--ink);
}

.toggle {
  display: flex;
  gap: 10px;
  align-items: center;
  color: var(--muted);
  font-weight: 650;
}

.primary-action,
.secondary-action,
.ghost-button,
.icon-button {
  min-height: 42px;
  border-radius: 6px;
  border: 1px solid transparent;
  padding: 0 16px;
  font-weight: 750;
}

.primary-action {
  background: var(--primary);
  color: #fff;
}

.primary-action:hover {
  background: var(--primary-dark);
}

.secondary-action,
.ghost-button,
.icon-button {
  background: #fff;
  color: var(--ink);
  border-color: var(--line);
}

.ghost-button {
  min-height: 36px;
}

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

.icon-button.active {
  color: var(--warning);
  border-color: #e8b461;
  background: #fff8e8;
}

.topbar,
.results-header {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  margin-bottom: 18px;
}

.topbar h2,
.results-header h2 {
  margin: 0;
  font-size: 1.7rem;
}

.exam-stats {
  display: flex;
  gap: 12px;
}

.exam-stats div,
.summary-card {
  min-width: 120px;
  padding: 14px 16px;
}

.exam-stats span,
.summary-card span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.exam-stats strong,
.summary-card strong {
  display: block;
  margin-top: 4px;
  font-size: 1.35rem;
}

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

.question-map {
  position: sticky;
  top: 16px;
  padding: 16px;
}

.map-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

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

.palette button {
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font-weight: 750;
}

.palette button.current {
  outline: 3px solid rgba(23, 105, 170, 0.24);
  border-color: var(--primary);
}

.palette button.answered {
  background: #eaf6f0;
  border-color: #99d4bd;
}

.palette button.marked {
  box-shadow: inset 0 -4px 0 #e8b461;
}

.question-panel {
  min-height: 620px;
  padding: 24px;
}

.question-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.question-meta span {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  background: #eef4fb;
  color: var(--primary-dark);
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
}

.question-panel h3 {
  margin: 0 0 14px;
  font-size: 1.28rem;
}

.question-text {
  margin: 0;
  max-height: 280px;
  overflow: auto;
  padding-right: 8px;
  color: #303642;
  line-height: 1.62;
  white-space: pre-wrap;
}

.answers {
  display: grid;
  gap: 10px;
  margin-top: 22px;
}

.answer-option {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 12px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
}

.answer-option:hover {
  border-color: #9abbd7;
}

.answer-key {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #eef4fb;
  color: var(--primary-dark);
  font-weight: 800;
}

.manual-answer {
  min-height: 140px;
  resize: vertical;
  line-height: 1.5;
}

.feedback {
  margin-top: 16px;
  border-left: 4px solid var(--primary);
  background: #eef4fb;
  padding: 14px 16px;
  color: #26394b;
  line-height: 1.5;
}

.feedback.correct {
  border-color: var(--accent);
  background: #eaf6f0;
}

.feedback.incorrect {
  border-color: var(--danger);
  background: #fff0ee;
}

.question-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 26px;
}

.results-header {
  padding: 24px;
}

.results-header p {
  margin: 8px 0 0;
  color: var(--muted);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.review-list {
  display: grid;
  gap: 14px;
}

.review-card {
  padding: 18px;
}

.review-card h3 {
  margin: 0 0 8px;
  font-size: 1rem;
}

.review-card p {
  margin: 8px 0;
  color: #303642;
  line-height: 1.5;
}

.review-card .status {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 800;
}

.status.ok {
  color: #0b6b49;
  background: #dff4eb;
}

.status.bad {
  color: #a3150c;
  background: #ffe6e2;
}

.status.manual {
  color: #7b4a00;
  background: #fff3d6;
}

@media (max-width: 860px) {
  .setup-view,
  .content-grid {
    grid-template-columns: 1fr;
  }

  .question-map {
    position: static;
  }

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

  .topbar,
  .results-header {
    align-items: stretch;
    flex-direction: column;
  }

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

@media (max-width: 560px) {
  .app-shell {
    width: min(100% - 20px, 1180px);
    padding: 18px 0;
  }

  .exam-stats,
  .question-actions {
    flex-wrap: wrap;
  }

  .palette {
    grid-template-columns: repeat(5, 1fr);
  }

  .summary-grid {
    grid-template-columns: 1fr;
  }
}
