:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --ink: #111827;
  --muted: #65707d;
  --line: #dfe4ea;
  --red: #b51f2a;
  --red-dark: #8f1620;
  --green: #198754;
  --green-soft: #e8f6ef;
  --blue: #2364aa;
  --blue-soft: #e8f0fb;
  --amber: #c27803;
  --amber-soft: #fff4dc;
  --danger: #d92d20;
  --danger-soft: #fff0ef;
  --shadow: 0 18px 45px rgba(17, 24, 39, 0.11);
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background:
    linear-gradient(180deg, rgba(181, 31, 42, 0.08), rgba(35, 100, 170, 0.04) 38%, rgba(244, 246, 248, 1) 72%),
    var(--bg);
  color: var(--ink);
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
}

.ghost-reset {
  appearance: none;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  cursor: pointer;
  text-align: left;
}

.app-shell {
  min-height: 100vh;
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 82px;
  padding: 16px 0;
}

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

.brand-row {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  flex-wrap: wrap;
}

.brand img {
  width: 188px;
  max-width: 52vw;
  height: auto;
  display: block;
}

.brand small {
  display: block;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
  margin-top: 2px;
}

.forum-return-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 13px;
  border: 1px solid rgba(181, 31, 42, 0.24);
  border-radius: 6px;
  background: #ffffff;
  color: var(--red-dark);
  font-size: 0.86rem;
  font-weight: 850;
  text-decoration: none;
  box-shadow: 0 8px 18px rgba(17, 24, 39, 0.08);
  transition: background 160ms ease, color 160ms ease, border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.forum-return-btn:hover {
  background: var(--red);
  border-color: var(--red);
  color: #ffffff;
  box-shadow: 0 12px 24px rgba(181, 31, 42, 0.22);
  transform: translateY(-1px);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.76);
  color: var(--muted);
  border-radius: 999px;
  font-size: 0.86rem;
  font-weight: 800;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.06fr) minmax(320px, 0.94fr);
  gap: 28px;
  align-items: stretch;
  padding: 18px 0 36px;
}

.hero-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 430px;
}

.eyebrow {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  gap: 8px;
  color: var(--red-dark);
  background: rgba(181, 31, 42, 0.08);
  border: 1px solid rgba(181, 31, 42, 0.22);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 0.84rem;
  font-weight: 900;
}

.hero h1 {
  margin: 18px 0 14px;
  font-size: clamp(2.35rem, 6vw, 5.4rem);
  line-height: 0.96;
  letter-spacing: 0;
}

.hero p {
  margin: 0;
  max-width: 720px;
  color: #344050;
  font-size: 1.08rem;
  line-height: 1.65;
}

.class-grid {
  display: grid;
  gap: 14px;
  align-content: center;
}

.class-card {
  min-height: 190px;
  padding: 24px;
  text-align: left;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  border: 1px solid rgba(17, 24, 39, 0.06);
  color: var(--ink);
  cursor: pointer;
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.class-card:hover,
.class-card:focus-visible {
  transform: translateY(-3px);
  border-color: rgba(181, 31, 42, 0.28);
  box-shadow: 0 22px 56px rgba(17, 24, 39, 0.16);
  outline: none;
}

.class-card strong {
  display: block;
  font-size: 1.38rem;
  margin-bottom: 10px;
}

.class-card span {
  color: var(--muted);
  line-height: 1.55;
  display: block;
}

.class-card .meta-row {
  margin-top: 20px;
}

.meta-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

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

.stat {
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}

.stat b {
  display: block;
  font-size: 1.35rem;
  color: var(--ink);
}

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

.setup-panel,
.result-panel {
  background: var(--surface);
  border: 1px solid rgba(17, 24, 39, 0.08);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 38px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 18px;
  margin-bottom: 20px;
}

.panel-header h2,
.result-panel h2 {
  margin: 0;
  font-size: clamp(1.55rem, 3vw, 2.35rem);
}

.panel-header p,
.result-panel p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.setup-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
  gap: 24px;
}

.section-title {
  margin: 0 0 12px;
  color: #253143;
  font-size: 0.94rem;
  font-weight: 900;
  text-transform: uppercase;
}

.segmented,
.category-grid,
.option-grid {
  display: grid;
  gap: 10px;
}

.segmented {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 24px;
}

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

.choice-tile,
.toggle-tile {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 62px;
  padding: 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  font-weight: 850;
}

.choice-tile small,
.toggle-tile small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
  line-height: 1.35;
}

.choice-tile.active,
.toggle-tile.active {
  background: var(--blue-soft);
  border-color: rgba(35, 100, 170, 0.45);
}

.toggle-dot {
  width: 38px;
  height: 22px;
  flex: 0 0 38px;
  border-radius: 999px;
  background: #c8d0da;
  position: relative;
}

.toggle-dot::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  top: 2px;
  left: 2px;
  border-radius: 50%;
  background: #fff;
  transition: left 160ms ease;
}

.toggle-tile.active .toggle-dot {
  background: var(--green);
}

.toggle-tile.active .toggle-dot::after {
  left: 18px;
}

.summary-box {
  background: #111827;
  color: #fff;
  border-radius: var(--radius);
  padding: 18px;
}

.summary-box .row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.summary-box .row:last-child {
  border-bottom: 0;
}

.summary-box span {
  color: rgba(255, 255, 255, 0.72);
  font-weight: 800;
}

.summary-box b {
  font-size: 1rem;
}

.primary-btn,
.ghost-btn,
.danger-btn {
  min-height: 46px;
  padding: 0 18px;
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 900;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

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

.primary-btn:hover,
.primary-btn:focus-visible {
  background: var(--red-dark);
  outline: none;
}

.ghost-btn {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
}

.danger-btn {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid rgba(217, 45, 32, 0.25);
}

.exam-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 20px;
  align-items: start;
  padding-bottom: 34px;
}

.exam-top {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(244, 246, 248, 0.92);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(223, 228, 234, 0.78);
}

.exam-top-inner {
  width: min(1180px, calc(100% - 32px));
  min-height: 76px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.progress-wrap {
  display: grid;
  gap: 8px;
  min-width: min(420px, 42vw);
}

.progress-text {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 850;
}

.progress-bar {
  height: 8px;
  border-radius: 999px;
  background: #dce3eb;
  overflow: hidden;
}

.progress-bar span {
  display: block;
  height: 100%;
  width: var(--progress, 0%);
  background: linear-gradient(90deg, var(--red), var(--blue));
}

.timer {
  min-width: 92px;
  text-align: center;
  background: #111827;
  color: #fff;
  border-radius: var(--radius);
  padding: 10px 12px;
  font-weight: 950;
}

.question-panel,
.side-panel {
  background: var(--surface);
  border: 1px solid rgba(17, 24, 39, 0.08);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.question-panel {
  padding: 24px;
}

.question-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.question-text {
  font-size: clamp(1.15rem, 2.4vw, 1.72rem);
  line-height: 1.42;
  font-weight: 900;
}

.question-text p {
  margin: 0 0 14px;
}

.question-image {
  display: block;
  max-width: min(100%, 620px);
  height: auto;
  margin: 14px auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

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

.answer {
  width: 100%;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  min-height: 62px;
  padding: 12px;
  text-align: left;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: var(--radius);
  cursor: pointer;
}

.answer:hover,
.answer:focus-visible {
  border-color: rgba(35, 100, 170, 0.45);
  outline: none;
}

.answer .letter {
  width: 38px;
  height: 38px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  background: #e8edf2;
  font-weight: 950;
}

.answer.correct {
  border-color: rgba(25, 135, 84, 0.58);
  background: var(--green-soft);
}

.answer.correct .letter {
  background: var(--green);
  color: #fff;
}

.answer.wrong {
  border-color: rgba(217, 45, 32, 0.52);
  background: var(--danger-soft);
}

.answer.wrong .letter {
  background: var(--danger);
  color: #fff;
}

.answer.dimmed {
  opacity: 0.62;
}

.answer[disabled] {
  cursor: default;
}

.feedback {
  margin-top: 18px;
  padding: 16px;
  border-radius: var(--radius);
  border: 1px solid rgba(35, 100, 170, 0.22);
  background: var(--blue-soft);
  line-height: 1.55;
}

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

.exam-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px;
  margin-top: 22px;
}

.side-panel {
  padding: 16px;
  position: sticky;
  top: 96px;
}

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

.q-dot {
  aspect-ratio: 1;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 900;
}

.q-dot.current {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(35, 100, 170, 0.16);
}

.q-dot.correct {
  background: var(--green-soft);
  color: var(--green);
  border-color: rgba(25, 135, 84, 0.42);
}

.q-dot.wrong {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: rgba(217, 45, 32, 0.38);
}

.q-dot.review {
  background: var(--amber-soft);
  color: var(--amber);
  border-color: rgba(194, 120, 3, 0.45);
}

.legend {
  display: grid;
  gap: 8px;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.legend i {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  display: inline-block;
  background: var(--line);
}

.legend .l-green {
  background: var(--green);
}

.legend .l-red {
  background: var(--danger);
}

.legend .l-amber {
  background: var(--amber);
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 20px 0;
}

.result-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  padding: 16px;
}

.result-card b {
  display: block;
  font-size: 1.55rem;
}

.result-card span {
  color: var(--muted);
  font-weight: 850;
  font-size: 0.86rem;
}

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

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

.review-item strong {
  display: block;
  margin-bottom: 8px;
}

.source-note {
  margin: 28px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.55;
}

.source-note a {
  color: var(--blue);
  font-weight: 850;
}

.source-credit {
  font-size: 1rem;
  font-weight: 900;
  text-align: center;
}

.source-credit a {
  color: inherit;
  display: inline-flex;
  gap: 6px;
  justify-content: center;
  text-decoration: none;
}

.source-credit__name {
  color: #111827;
}

.source-credit__pipe {
  color: var(--red-dark);
}

.source-credit__call {
  color: var(--red);
}

.hidden {
  display: none !important;
}

@media (max-width: 920px) {
  .hero,
  .setup-grid,
  .exam-layout {
    grid-template-columns: 1fr;
  }

  .hero-copy {
    min-height: auto;
    padding-top: 20px;
  }

  .side-panel {
    position: static;
  }

  .progress-wrap {
    min-width: 0;
    flex: 1;
  }
}

@media (max-width: 720px) {
  .page,
  .exam-top-inner {
    width: min(100% - 20px, 1180px);
  }

  .topbar,
  .panel-header,
  .exam-top-inner {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions {
    justify-content: flex-start;
  }

  .segmented,
  .category-grid,
  .stat-grid,
  .result-grid {
    grid-template-columns: 1fr;
  }

  .question-panel,
  .setup-panel,
  .result-panel {
    padding: 16px;
  }

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

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

  .answer .letter {
    width: 34px;
    height: 34px;
  }
}
