:root {
  --ink: #17272e;
  --muted: #68787d;
  --paper: #f3f1e9;
  --surface: #fffdf8;
  --soft: #eef4f1;
  --line: #d7ded9;
  --navy: #173c47;
  --accent: #247d72;
  --accent-soft: #e4f1ed;
  --red: #b34b48;
  --red-soft: #f8e4e1;
  --green: #2f7c57;
  --green-soft: #e0efe5;
  --font: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  --mono: "Cascadia Code", Consolas, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--font);
  background:
    radial-gradient(circle at 7% 4%, rgba(36,125,114,.12), transparent 25rem),
    radial-gradient(circle at 94% 20%, rgba(187,121,36,.09), transparent 22rem),
    var(--paper);
}

button, select, input { font: inherit; }

button:focus-visible, select:focus-visible, input:focus-visible, a:focus-visible {
  outline: 3px solid rgba(36,125,114,.32);
  outline-offset: 3px;
}

.page {
  width: min(1080px, calc(100% - 40px));
  margin: 0 auto;
  padding: 24px 0 44px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 2px 1px 20px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 9px;
}

.back-link {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  gap: 7px;
  padding: 0 13px;
  border: 1px solid #bfccc8;
  border-radius: 11px;
  background: rgba(255,253,248,.9);
  color: var(--navy);
  font-size: 11px;
  font-weight: 700;
  text-decoration: none;
}

.subject-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 12px;
  font-weight: 700;
}

.subject-brand-icon {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 10px;
  background: var(--navy);
  color: #fff;
  font: 700 12px/1 var(--mono);
}

.wrong-book-link {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  border: 1px solid #c9d5d1;
  border-radius: 10px;
  background: rgba(255,253,248,.92);
  color: var(--navy);
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
}

.wrong-book-link span {
  display: grid;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  place-items: center;
  border-radius: 999px;
  background: var(--navy);
  color: #fff;
  font: 700 9px/1 var(--mono);
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, .8fr);
  gap: 20px;
  min-width: 0;
}

.hero-main {
  padding: clamp(30px, 5vw, 54px);
  border-radius: 27px;
  background: var(--navy);
  color: #f8fbf9;
  box-shadow: 0 20px 50px rgba(24,52,58,.14);
  min-width: 0;
}

.kicker {
  color: #b9dcd4;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .17em;
}

h1 {
  margin: 16px 0 12px;
  font-size: clamp(38px, 6vw, 62px);
  line-height: 1.05;
  letter-spacing: -.04em;
}

.hero-main p {
  margin: 0;
  color: #ccded9;
  font-size: 14px;
  line-height: 1.75;
}

.stats {
  display: flex;
  gap: 9px;
  margin-top: 25px;
}

.stat {
  min-width: 92px;
  padding: 12px 14px;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 12px;
  background: rgba(255,255,255,.055);
}

.stat strong { display: block; font: 700 20px/1 var(--mono); }
.stat span { display: block; margin-top: 6px; color: #b5cfca; font-size: 9px; }

.start-panel {
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 25px;
  background: var(--surface);
  box-shadow: 0 18px 44px rgba(25,52,56,.08);
  min-width: 0;
}

.start-panel h2 { margin: 0; font-size: 20px; }
.start-panel > p { margin: 7px 0 20px; color: var(--muted); font-size: 11px; line-height: 1.6; }

.field-label {
  display: block;
  margin: 15px 0 7px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .09em;
}

.mode-group {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  border: 0;
}

.mode-option { position: relative; cursor: pointer; }
.mode-option input { position: absolute; opacity: 0; }

.mode-card {
  display: block;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fff;
  color: #53646a;
  font-size: 11px;
  line-height: 1.55;
}

.mode-card strong { display: block; color: var(--ink); font-size: 12px; }
.mode-option input:checked + .mode-card {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.start-flow {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 9px;
  align-items: end;
  margin-top: 13px;
}

.start-flow select {
  width: 100%;
  min-height: 38px;
  padding: 0 30px 0 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
}

.shuffle {
  display: flex;
  min-height: 38px;
  align-items: center;
  gap: 7px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  font-size: 10px;
  font-weight: 700;
}

.btn {
  min-height: 42px;
  padding: 0 16px;
  border-radius: 11px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.btn-primary {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover { filter: brightness(.92); }
.btn-primary:disabled { opacity: .55; cursor: not-allowed; }

.btn-secondary {
  border: 1px solid #bfcdc9;
  background: #fff;
  color: var(--navy);
}

.btn-ghost {
  border: 0;
  background: transparent;
  color: var(--muted);
}

.block { width: 100%; margin-top: 13px; }

.wrong-retry {
  display: block;
  width: 100%;
  margin-top: 9px;
}

.wrong-retry:disabled {
  opacity: .5;
  cursor: not-allowed;
}

.quiz-shell {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.status-panel {
  position: sticky;
  top: 18px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
}

.status-head { display: flex; justify-content: space-between; gap: 10px; }
.status-label { color: var(--muted); font-size: 9px; letter-spacing: .1em; }
.timer { display: block; margin-top: 4px; font: 700 23px/1 var(--mono); }

.mode-badge {
  align-self: flex-start;
  padding: 5px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 9px;
  font-weight: 700;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  margin: 22px 0 7px;
  color: var(--muted);
  font-size: 10px;
}

.progress-track {
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: #e5e9e6;
}

.progress-fill {
  width: 0;
  height: 100%;
  background: var(--accent);
  transition: width .18s ease;
}

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

.map-btn {
  display: grid;
  aspect-ratio: 1;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--muted);
  font: 600 9px/1 var(--mono);
  cursor: pointer;
}

.map-btn.answered { border-color: #acd1c7; background: var(--accent-soft); color: var(--accent); }
.map-btn.current { border-color: var(--navy); background: var(--navy); color: #fff; }

.panel {
  min-height: 540px;
  padding: clamp(22px, 4vw, 40px);
  border: 1px solid var(--line);
  border-radius: 23px;
  background: var(--surface);
  box-shadow: 0 16px 40px rgba(25,52,56,.07);
}

.q-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; }

.tag {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 9px;
  font-weight: 700;
}

.difficulty {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
}

.q-number { margin-left: auto; color: #82908d; font: 600 10px/1 var(--mono); }

.q-title {
  margin: 20px 0 0;
  font-size: clamp(20px, 3vw, 28px);
  line-height: 1.5;
  letter-spacing: -.025em;
}

.type-hint {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.6;
}

.answers {
  display: grid;
  gap: 9px;
  margin-top: 24px;
}

.answer {
  display: grid;
  grid-template-columns: 33px minmax(0, 1fr) 20px;
  gap: 10px;
  align-items: center;
  width: 100%;
  min-height: 56px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: #374a50;
  text-align: left;
  cursor: pointer;
}

.answer:hover:not(:disabled) { border-color: #9fc7bd; background: #f8fbf9; }

.answer-key {
  display: grid;
  width: 31px;
  height: 31px;
  place-items: center;
  border: 1px solid #cbd5d1;
  border-radius: 8px;
  background: #f7f8f5;
  color: #697874;
  font: 700 11px/1 var(--mono);
}

.answer-text { font-size: 13px; line-height: 1.55; }
.answer-mark { color: transparent; font-weight: 800; }

.answer.selected { border-color: var(--accent); background: var(--accent-soft); }
.answer.selected .answer-key { border-color: var(--accent); background: var(--accent); color: #fff; }
.answer.correct { border-color: #6eac86; background: var(--green-soft); color: #1d5b3d; }
.answer.correct .answer-key, .answer.correct .answer-mark { background: #4b936d; border-color: #4b936d; color: #fff; }
.answer.wrong { border-color: #d69892; background: var(--red-soft); color: #783c38; }
.answer.wrong .answer-key, .answer.wrong .answer-mark { background: var(--red); border-color: var(--red); color: #fff; }
.answer:disabled { cursor: default; }

.feedback {
  margin-top: 15px;
  padding: 13px 15px;
  border-left: 4px solid var(--accent);
  border-radius: 5px 11px 11px 5px;
  background: var(--accent-soft);
  color: #31524c;
  font-size: 12px;
  line-height: 1.7;
}

.feedback.wrong { border-left-color: var(--red); background: var(--red-soft); color: #6f3935; }
.feedback strong { display: block; margin-bottom: 3px; }

.q-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 26px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.footer-actions { display: flex; gap: 8px; margin-left: auto; }
.keyboard-note { color: #84918e; font-size: 9px; }

.result-hero {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 30px;
  align-items: center;
  padding: clamp(28px, 5vw, 50px);
  border: 1px solid var(--line);
  border-radius: 25px;
  background: var(--surface);
  box-shadow: 0 20px 50px rgba(25,52,56,.09);
}

.score-ring {
  display: grid;
  width: 170px;
  height: 170px;
  place-items: center;
  border-radius: 50%;
  background: radial-gradient(circle, var(--surface) 0 59%, transparent 60%), conic-gradient(var(--accent) 0 var(--angle), #e4e9e6 var(--angle) 360deg);
}

.score-ring strong { display: block; text-align: center; font: 800 48px/1 var(--mono); letter-spacing: -.06em; }
.score-ring span { display: block; margin-top: 6px; color: var(--muted); font-size: 9px; text-align: center; }

.result-kicker { color: var(--accent); font-size: 10px; font-weight: 800; letter-spacing: .14em; }
.result-hero h2 { margin: 10px 0 8px; font-size: clamp(29px, 4vw, 42px); letter-spacing: -.04em; }
.result-hero p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.7; }

.result-metrics { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px; }
.metric { min-width: 95px; padding: 11px 13px; border-radius: 11px; background: var(--soft); }
.metric strong { display: block; font-size: 18px; }
.metric span { display: block; margin-top: 5px; color: var(--muted); font-size: 9px; }

.result-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px; }

.analysis {
  display: grid;
  grid-template-columns: .7fr 1.3fr;
  gap: 15px;
  margin-top: 16px;
}

.wrong-view-card { margin-top: 4px; }

.wrong-view-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.wrong-view-head h2 {
  margin: 0;
  font-size: 22px;
}

.wrong-view-head p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.wrong-view-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.analysis-card {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
}

.analysis-card h3 { margin: 0; font-size: 17px; }
.analysis-card > p { margin: 6px 0 0; color: var(--muted); font-size: 10px; line-height: 1.6; }

.topic-list { display: grid; gap: 12px; margin-top: 18px; }
.topic-row { display: grid; gap: 6px; }
.topic-line { display: flex; justify-content: space-between; gap: 10px; font-size: 10px; }
.topic-line span:last-child { color: var(--muted); font-family: var(--mono); }
.bar { height: 6px; overflow: hidden; border-radius: 999px; background: #e7ebe8; }
.bar-fill { height: 100%; background: var(--accent); }

.review-list { display: grid; gap: 10px; margin-top: 18px; }
.review {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fcfbf7;
}

.review-head { color: var(--muted); font-size: 9px; }
.review h4 { margin: 8px 0 0; font-size: 13px; line-height: 1.6; }
.review-answer { margin-top: 10px; font-size: 11px; line-height: 1.7; }
.review-answer .right { color: var(--green); }
.review-answer .bad { color: var(--red); }
.review-explain { margin: 9px 0 0; padding-top: 9px; border-top: 1px solid #e4e7e2; color: #506267; font-size: 11px; line-height: 1.65; }
.empty { padding: 25px; color: var(--muted); font-size: 12px; text-align: center; }

[hidden] { display: none !important; }

@media (max-width: 760px) {
  .page { width: min(100% - 24px, 1080px); padding-top: 16px; }
  .hero { grid-template-columns: 1fr; }
  .quiz-shell { grid-template-columns: 1fr; }
  .status-panel { position: static; }
  .question-map { grid-template-columns: repeat(10, minmax(0, 1fr)); }
  .result-hero { grid-template-columns: 1fr; justify-items: center; text-align: center; }
  .result-actions { justify-content: center; }
  .analysis { grid-template-columns: 1fr; }
}

@media (max-width: 430px) {
  .topbar { align-items: flex-start; }
  .subject-brand { display: none; }
  .top-actions { margin-left: auto; }
  .wrong-book-link { min-height: 37px; padding: 0 10px; }
  .wrong-view-head { flex-direction: column; }
  .wrong-view-actions { width: 100%; }
  .wrong-view-actions .btn { flex: 1; }
  .hero-main { padding: 30px 22px; border-radius: 22px; }
  .stat { flex: 1 1 80px; min-width: 0; }
  .start-panel, .panel, .analysis-card { border-radius: 18px; }
  .start-flow { grid-template-columns: 1fr; }
  .shuffle { justify-content: center; }
  .panel { padding: 21px 17px; }
  .q-number { width: 100%; margin-left: 0; }
  .answer { grid-template-columns: 31px minmax(0, 1fr) 18px; padding-right: 9px; }
  .answer-text { font-size: 12px; }
  .q-footer { flex-wrap: wrap; }
  .keyboard-note { width: 100%; order: 2; text-align: center; }
  .footer-actions { width: 100%; }
  .footer-actions .btn { flex: 1; }
}
