:root {
  color-scheme: light;
  --navy: #173f68;
  --navy-2: #245884;
  --blue: #3178b8;
  --blue-soft: #eaf4fc;
  --ink: #172536;
  --muted: #607186;
  --line: #d7e2ed;
  --paper: #ffffff;
  --canvas: #f3f7fb;
  --success: #13764b;
  --success-bg: #e6f6ee;
  --danger: #b4232f;
  --danger-bg: #fdecef;
  --warning: #8b5d10;
  --warning-bg: #fff5d9;
  --shadow: 0 16px 42px rgba(25, 63, 104, 0.1);
  font-family: "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  font-size: 16px;
}

* { box-sizing: border-box; }

html { min-width: 320px; scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% -10%, rgba(49, 120, 184, 0.16), transparent 32rem),
    var(--canvas);
  line-height: 1.65;
}

button, input, select { font: inherit; }

button, select, .option { -webkit-tap-highlight-color: transparent; }

a { color: var(--navy-2); }

.skip-link {
  position: fixed;
  left: 1rem;
  top: -5rem;
  z-index: 100;
  padding: 0.75rem 1rem;
  border-radius: 0.6rem;
  color: #fff;
  background: var(--navy);
}

.skip-link:focus { top: 1rem; }

:focus-visible {
  outline: 3px solid #f2a900;
  outline-offset: 3px;
}

.site-header {
  color: #fff;
  background: linear-gradient(115deg, #123858, var(--navy-2));
  box-shadow: 0 4px 18px rgba(23, 63, 104, 0.18);
}

.header-inner,
#app,
.site-footer {
  width: min(100% - 2rem, 960px);
  margin-inline: auto;
}

.header-inner {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.8rem;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 42px;
  aspect-ratio: 1;
  place-items: center;
  border: 1px solid rgba(255,255,255,.55);
  border-radius: 12px;
  background: rgba(255,255,255,.12);
  font-size: 1.25rem;
  font-weight: 800;
}

.brand strong, .brand small { display: block; }
.brand strong { font-size: 1.05rem; letter-spacing: .02em; }
.brand small { color: #cfe4f6; font-size: .78rem; }

.question-count {
  padding: .32rem .72rem;
  border: 1px solid rgba(255,255,255,.28);
  border-radius: 999px;
  color: #eaf6ff;
  font-size: .84rem;
}

.status-message {
  width: min(100% - 2rem, 960px);
  min-height: 0;
  margin: .75rem auto 0;
}

.status-message:not(:empty) {
  padding: .7rem 1rem;
  border: 1px solid #efd18b;
  border-radius: .75rem;
  color: var(--warning);
  background: var(--warning-bg);
}

#app { padding-block: 2.25rem 4rem; }

.panel {
  border: 1px solid rgba(215, 226, 237, .9);
  border-radius: 1.1rem;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.panel-body { padding: clamp(1.25rem, 4vw, 2.2rem); }

.eyebrow {
  margin: 0 0 .35rem;
  color: var(--blue);
  font-size: .78rem;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
}

h1, h2, h3, p { overflow-wrap: anywhere; }
h1, h2, h3 { margin-top: 0; line-height: 1.3; }
h1 { margin-bottom: .65rem; font-size: clamp(1.65rem, 4vw, 2.35rem); }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.05rem; }

.lead { max-width: 52rem; margin: 0; color: var(--muted); }

.hero {
  padding: clamp(1.35rem, 4vw, 2.35rem);
  color: #fff;
  background: linear-gradient(135deg, #173f68, #28689e 70%, #3988c4);
}

.hero .eyebrow, .hero .lead { color: #d9edfb; }

.hero-actions,
.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  margin-top: 1.35rem;
}

.button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .35rem;
  padding: .72rem 1.1rem;
  border: 1px solid transparent;
  border-radius: .72rem;
  font-weight: 750;
  cursor: pointer;
  transition: transform .16s ease, box-shadow .16s ease, background .16s ease;
}

.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:disabled { opacity: .46; cursor: not-allowed; }
.button-primary { color: #fff; background: var(--navy); box-shadow: 0 6px 16px rgba(23,63,104,.2); }
.hero .button-primary { color: var(--navy); background: #fff; }
.button-secondary { border-color: var(--line); color: var(--navy); background: #fff; }
.button-ghost { border-color: rgba(255,255,255,.45); color: #fff; background: rgba(255,255,255,.08); }
.button-danger { border-color: #efb9bf; color: var(--danger); background: #fff; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: .85rem;
  margin: 1rem 0 1.4rem;
}

.stat-card {
  padding: 1.1rem;
  border: 1px solid var(--line);
  border-radius: .9rem;
  background: rgba(255,255,255,.92);
}

.stat-card span { display: block; color: var(--muted); font-size: .82rem; }
.stat-card strong { display: block; margin-top: .15rem; font-size: 1.55rem; line-height: 1.25; }

.subject-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }

.subject-card { padding: 1.2rem; border: 1px solid var(--line); border-radius: .9rem; background: #fbfdff; }
.subject-card p { margin: .2rem 0 .7rem; color: var(--muted); }

.meter, .quiz-progress {
  overflow: hidden;
  height: 8px;
  border-radius: 999px;
  background: #dbe8f3;
}

.meter > span, .quiz-progress > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--blue), #53a9dc);
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  margin: 1.6rem 0 .8rem;
}

.section-heading h2, .section-heading p { margin: 0; }
.section-heading p { color: var(--muted); font-size: .88rem; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.field { display: grid; gap: .35rem; }
.field label { font-weight: 700; }
.field select {
  width: 100%;
  min-height: 46px;
  padding: .65rem .8rem;
  border: 1px solid #b8c8d8;
  border-radius: .7rem;
  color: var(--ink);
  background: #fff;
}

.availability {
  margin: 1.2rem 0 0;
  padding: .85rem 1rem;
  border-left: 4px solid var(--blue);
  border-radius: .55rem;
  color: var(--navy);
  background: var(--blue-soft);
}

.quiz-meta { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: .75rem; }
.tag { padding: .25rem .55rem; border-radius: 999px; color: var(--navy); background: var(--blue-soft); font-size: .8rem; font-weight: 700; }
.progress-label { display: flex; justify-content: space-between; gap: 1rem; margin-bottom: .35rem; color: var(--muted); font-size: .86rem; }
.question-title { margin: 1.4rem 0 1rem; font-size: clamp(1.15rem, 3vw, 1.45rem); }

.options { display: grid; gap: .72rem; margin: 0; padding: 0; border: 0; }
.options legend { margin-bottom: .55rem; color: var(--muted); font-size: .9rem; }

.option {
  display: grid;
  grid-template-columns: auto 2rem minmax(0, 1fr);
  gap: .7rem;
  align-items: start;
  padding: .9rem 1rem;
  border: 1px solid var(--line);
  border-radius: .85rem;
  background: #fff;
  cursor: pointer;
}

.option:hover { border-color: #8fb7d5; background: #f8fbfe; }
.option input { width: 1.12rem; height: 1.12rem; margin-top: .24rem; accent-color: var(--navy-2); }
.option-letter { display: grid; width: 2rem; aspect-ratio: 1; place-items: center; border-radius: .55rem; color: var(--navy); background: var(--blue-soft); font-weight: 800; }
.option.is-selected { border-color: var(--blue); background: #f2f8fd; }
.option.is-correct { border-color: #73c49e; background: var(--success-bg); }
.option.is-correct .option-letter { color: #fff; background: var(--success); }
.option.is-wrong { border-color: #e49ba4; background: var(--danger-bg); }
.option.is-wrong .option-letter { color: #fff; background: var(--danger); }

.feedback {
  margin-top: 1.1rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: .85rem;
}

.feedback.is-correct { border-color: #8bceb0; background: var(--success-bg); }
.feedback.is-wrong { border-color: #e9afb6; background: var(--danger-bg); }
.feedback h3 { margin-bottom: .45rem; }
.feedback p { margin: .45rem 0; }
.explanation { white-space: pre-line; }
.source-link { font-size: .85rem; }

.result-score { display: flex; align-items: center; gap: 1.2rem; margin: 1rem 0 1.4rem; }
.score-ring { display: grid; width: 100px; aspect-ratio: 1; place-items: center; border: 9px solid #d9e8f3; border-top-color: var(--blue); border-radius: 50%; font-size: 1.35rem; font-weight: 850; }
.result-score p { margin: .2rem 0; color: var(--muted); }

.wrong-list { display: grid; gap: .7rem; }
.wrong-list details { padding: .8rem 1rem; border: 1px solid var(--line); border-radius: .7rem; background: #fff; }
.wrong-list summary { cursor: pointer; font-weight: 700; }
.empty-state { padding: 1.2rem; border: 1px dashed #9eb4c7; border-radius: .8rem; color: var(--muted); text-align: center; }
.loading-card { padding: 2rem; text-align: center; }
.error-card { border-color: #e9afb6; }

.site-footer { padding-bottom: 2rem; color: var(--muted); font-size: .82rem; text-align: center; }

@media (max-width: 720px) {
  .header-inner, #app, .site-footer, .status-message { width: min(100% - 1.2rem, 960px); }
  .header-inner { min-height: 68px; }
  .question-count { display: none; }
  #app { padding-block: 1.1rem 2.8rem; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .subject-grid, .form-grid { grid-template-columns: 1fr; }
  .section-heading { align-items: flex-start; flex-direction: column; }
  .panel-body, .hero { padding: 1.1rem; }
  .hero-actions .button, .button-row .button { flex: 1 1 100%; }
  .option { grid-template-columns: auto 1.8rem minmax(0, 1fr); padding: .8rem; }
  .option-letter { width: 1.8rem; }
  .result-score { align-items: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}
