:root {
  color-scheme: light;
  --ink: #18202f;
  --muted: #667085;
  --paper: #f7f8fb;
  --surface: #ffffff;
  --line: #dce3ee;
  --primary: #126a6d;
  --primary-ink: #ffffff;
  --accent: #c44536;
  --ok: #237a45;
  --warn-bg: #fff2ec;
  --ok-bg: #eef8f1;
  --shadow: 0 18px 42px rgba(24, 32, 47, 0.12);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  background: var(--paper);
  color: var(--ink);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at top left, rgba(18, 106, 109, 0.16), transparent 28rem),
    linear-gradient(180deg, #fdfefe 0%, var(--paper) 28rem);
}

button {
  font: inherit;
}

svg {
  width: 1.05rem;
  height: 1.05rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: 0 0 auto;
}

.shell {
  width: min(100%, 760px);
  margin: 0 auto;
  padding: 20px 16px 32px;
}

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

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 2.8rem;
  line-height: 1;
  letter-spacing: 0;
}

h2 {
  font-size: 1.1rem;
  line-height: 1.35;
  letter-spacing: 0;
}

.eyebrow {
  color: var(--primary);
  font-size: 0.86rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.score-pill {
  min-width: 92px;
  min-height: 72px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  display: grid;
  place-items: center;
  box-shadow: var(--shadow);
}

.score-pill span {
  font-size: 1.8rem;
  font-weight: 800;
}

.score-pill small {
  color: var(--muted);
  margin-top: -14px;
}

.quick-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}

.primary,
.secondary,
.ghost,
.icon-text,
.clear-button {
  min-height: 48px;
  border-radius: 8px;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
  font-weight: 750;
  text-decoration: none;
}

.primary {
  color: var(--primary-ink);
  background: var(--primary);
}

.secondary,
.ghost,
.icon-text {
  color: var(--ink);
  background: var(--surface);
  border-color: var(--line);
}

.secondary b {
  color: var(--accent);
}

button:disabled {
  opacity: 0.45;
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin: 12px 0 18px;
}

.stats-row div {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 12px;
}

.stats-row strong,
.stats-row span {
  display: block;
}

.stats-row strong {
  font-size: 1.35rem;
}

.stats-row span,
.chapter-card p,
.last-attempt,
.complete p {
  color: var(--muted);
  font-size: 0.94rem;
  line-height: 1.6;
}

.chapter-list {
  display: grid;
  gap: 10px;
}

.chapter-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
}

.chapter-card .progress {
  grid-column: 1 / -1;
}

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

.progress span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #6f7c2f);
}

.clear-button {
  width: 100%;
  margin-top: 18px;
  color: var(--muted);
  background: transparent;
  border-color: var(--line);
}

.quiz-shell {
  min-height: 100vh;
  display: grid;
  align-content: start;
  gap: 14px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px 0;
  background: rgba(247, 248, 251, 0.92);
  backdrop-filter: blur(12px);
}

.topbar span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 800;
  text-align: center;
}

.topbar small {
  color: var(--muted);
  font-weight: 700;
}

.question-card,
.result,
.complete,
.loading,
.error {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  box-shadow: 0 12px 30px rgba(24, 32, 47, 0.08);
}

.stem {
  font-size: 1.05rem;
  line-height: 1.75;
  white-space: normal;
  overflow-wrap: anywhere;
}

.options {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.option {
  width: 100%;
  min-height: 58px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  color: var(--ink);
  padding: 12px;
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 10px;
  text-align: left;
  align-items: start;
}

.option span {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #e9f2f2;
  color: var(--primary);
  font-weight: 900;
}

.option p {
  font-size: 1rem;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.option.correct {
  border-color: rgba(35, 122, 69, 0.45);
  background: var(--ok-bg);
}

.option.correct span {
  color: #ffffff;
  background: var(--ok);
}

.option.wrong {
  border-color: rgba(196, 69, 54, 0.45);
  background: var(--warn-bg);
}

.option.wrong span {
  color: #ffffff;
  background: var(--accent);
}

.result {
  display: grid;
  gap: 12px;
}

.result h2 {
  display: flex;
  align-items: center;
  gap: 8px;
}

.result.right h2 {
  color: var(--ok);
}

.result.miss h2 {
  color: var(--accent);
}

.explanation {
  padding: 14px;
  border-radius: 8px;
  background: #f5f7fa;
  color: #2f3848;
  line-height: 1.75;
  overflow-wrap: anywhere;
}

.last-attempt {
  padding: 0 4px;
}

.complete {
  margin-top: 24px;
  display: grid;
  gap: 12px;
}

.loading,
.error {
  margin-top: 24px;
}

@media (max-width: 430px) {
  .shell {
    padding: 16px 12px 28px;
  }

  h1 {
    font-size: 2.35rem;
  }

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

  .chapter-card {
    grid-template-columns: 1fr;
  }

  .chapter-card .ghost {
    width: 100%;
  }

  .stats-row {
    gap: 8px;
  }

  .stats-row div {
    padding: 12px 8px;
  }

  .topbar {
    grid-template-columns: 44px 1fr 42px;
  }

  .icon-text {
    min-width: 44px;
    padding: 0;
  }

  .icon-text svg + * {
    display: none;
  }
}

