:root {
  --ink: #1f2933;
  --muted: #64748b;
  --line: #dbe3ef;
  --paper: #fbfcfe;
  --panel: #ffffff;
  --accent: #0f766e;
  --accent-strong: #115e59;
  --accent-soft: #d9f4ef;
  --coral: #c2410c;
  --coral-soft: #ffedd5;
  --blue: #1d4ed8;
  --blue-soft: #dbeafe;
  --green: #15803d;
  --green-soft: #dcfce7;
  --red: #b91c1c;
  --red-soft: #fee2e2;
  --shadow: 0 18px 60px rgba(15, 23, 42, 0.09);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(15, 118, 110, 0.14), transparent 30rem),
    linear-gradient(180deg, #f8fbfc 0%, #edf4f8 100%);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 30px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 0;
  background: transparent;
  color: var(--ink);
  padding: 0;
  text-align: left;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-weight: 800;
  letter-spacing: 0;
}

.brand-title {
  font-weight: 800;
  line-height: 1.15;
}

.brand-subtitle {
  color: var(--muted);
  font-size: 0.9rem;
}

.nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.nav button,
.ghost-btn,
.secondary-btn,
.primary-btn,
.icon-btn {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--ink);
  min-height: 42px;
  padding: 0 14px;
  font-weight: 700;
}

.nav button.active,
.nav button:hover,
.ghost-btn:hover,
.secondary-btn:hover,
.icon-btn:hover {
  border-color: rgba(15, 118, 110, 0.35);
  background: var(--accent-soft);
}

.primary-btn {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

.primary-btn:hover {
  background: var(--accent-strong);
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
  gap: 28px;
  align-items: stretch;
  margin-bottom: 28px;
}

.hero-copy {
  padding: 36px 0;
}

.eyebrow {
  color: var(--coral);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  max-width: 780px;
  margin-top: 12px;
  font-size: clamp(2.1rem, 5vw, 4.7rem);
  line-height: 0.98;
}

.lead {
  max-width: 680px;
  color: #405064;
  font-size: 1.12rem;
  line-height: 1.75;
}

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

.insight-panel,
.exam-card,
.mode-card,
.question-panel,
.result-card {
  border: 1px solid rgba(219, 227, 239, 0.9);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow);
}

.insight-panel {
  padding: 24px;
  display: grid;
  align-content: center;
  gap: 14px;
}

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

.stat {
  min-height: 92px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--paper);
}

.stat strong {
  display: block;
  font-size: 2rem;
  line-height: 1;
}

.stat span {
  color: var(--muted);
  font-size: 0.9rem;
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: end;
  margin: 28px 0 14px;
}

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

.exam-grid,
.mode-grid,
.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.exam-card,
.mode-card {
  padding: 18px;
  text-align: left;
}

.exam-card {
  min-height: 178px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.exam-card p,
.mode-card p {
  color: var(--muted);
  line-height: 1.55;
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 0.82rem;
  font-weight: 800;
}

.screen {
  animation: fade 160ms ease-out;
}

.quiz-layout {
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.quiz-sidebar {
  position: sticky;
  top: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  padding: 16px;
}

.progress-track {
  height: 10px;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
  margin: 14px 0;
}

.progress-fill {
  height: 100%;
  width: var(--progress);
  background: var(--accent);
}

.question-map {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  margin-top: 14px;
}

.question-map button {
  min-width: 0;
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  font-weight: 800;
}

.question-map button.current {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.question-map button.answered {
  background: var(--blue-soft);
  color: var(--blue);
}

.question-panel {
  padding: 24px;
}

.question-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-weight: 800;
  margin-bottom: 16px;
}

.question-prompt {
  white-space: pre-wrap;
  line-height: 1.7;
  font-size: 1.08rem;
}

.options {
  display: grid;
  gap: 10px;
  margin: 22px 0;
}

.option {
  width: 100%;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  min-height: 58px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  padding: 10px 14px 10px 10px;
  text-align: left;
}

.option:hover {
  border-color: rgba(15, 118, 110, 0.4);
}

.option-letter {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: #edf2f7;
  font-weight: 900;
}

.option.selected {
  border-color: var(--blue);
  background: var(--blue-soft);
}

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

.option.wrong {
  border-color: var(--red);
  background: var(--red-soft);
}

.feedback {
  border-left: 4px solid var(--accent);
  background: var(--accent-soft);
  padding: 14px 16px;
  line-height: 1.6;
  border-radius: 0 8px 8px 0;
}

.feedback strong {
  display: block;
  margin-bottom: 4px;
}

.quiz-controls {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 20px;
}

.result-hero {
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
  gap: 20px;
  align-items: stretch;
}

.score-ring {
  display: grid;
  place-items: center;
  min-height: 270px;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  text-align: center;
}

.score-ring strong {
  display: block;
  font-size: clamp(3.8rem, 10vw, 7rem);
  line-height: 0.95;
}

.result-card {
  padding: 22px;
}

.review-list {
  display: grid;
  gap: 12px;
  margin-top: 22px;
}

.review-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  padding: 16px;
}

.review-item.good {
  border-color: rgba(21, 128, 61, 0.38);
}

.review-item.bad {
  border-color: rgba(185, 28, 28, 0.34);
}

.review-item p {
  line-height: 1.58;
}

.markdown-page {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.toc {
  position: sticky;
  top: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.84);
}

.toc button {
  display: block;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 9px 0;
  text-align: left;
  font-weight: 700;
}

.content {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  padding: 28px;
  box-shadow: var(--shadow);
}

.content h1 {
  font-size: clamp(1.8rem, 4vw, 3.2rem);
}

.content h2 {
  margin-top: 30px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.content h3 {
  margin-top: 22px;
}

.content p,
.content li {
  line-height: 1.7;
}

.content table {
  width: 100%;
  border-collapse: collapse;
  margin: 18px 0;
  font-size: 0.92rem;
}

.content th,
.content td {
  border: 1px solid var(--line);
  padding: 10px;
  text-align: left;
  vertical-align: top;
}

.content th {
  background: #eef6f7;
}

.content a {
  color: var(--blue);
  font-weight: 700;
}

@keyframes fade {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
}

@media (max-width: 880px) {
  .topbar,
  .section-head,
  .quiz-controls {
    align-items: stretch;
    flex-direction: column;
  }

  .hero,
  .quiz-layout,
  .result-hero,
  .markdown-page {
    grid-template-columns: 1fr;
  }

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

  .quiz-sidebar,
  .toc {
    position: static;
  }
}

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

  .nav {
    justify-content: stretch;
  }

  .nav button {
    flex: 1 1 auto;
  }

  .hero-copy {
    padding: 12px 0;
  }

  .question-panel,
  .content {
    padding: 18px;
  }

  .option {
    grid-template-columns: 34px minmax(0, 1fr);
  }

  .option-letter {
    width: 32px;
    height: 32px;
  }
}
