:root {
  --bg: #ffffff;
  --fg: #1f2328;
  --muted: #57606a;
  --border: #d0d7de;
  --panel: #f6f8fa;
  --accent: #0969da;
  --accent-fg: #ffffff;
  --correct: #1a7f37;
  --correct-bg: #dafbe1;
  --wrong: #cf222e;
  --wrong-bg: #ffebe9;
  --code-bg: #eff1f3;
  --radius: 8px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1117;
    --fg: #e6edf3;
    --muted: #8b949e;
    --border: #30363d;
    --panel: #161b22;
    --accent: #2f81f7;
    --correct: #3fb950;
    --correct-bg: #033a16;
    --wrong: #f85149;
    --wrong-bg: #490202;
    --code-bg: #1c2128;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", sans-serif;
  line-height: 1.6;
}

.wrap {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 20px;
}

.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  padding: 12px 0;
  position: sticky;
  top: 0;
  z-index: 10;
}

.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.brand {
  color: var(--fg);
  text-decoration: none;
  font-weight: 600;
}

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

select, button {
  font: inherit;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--fg);
  padding: 6px 12px;
  border-radius: var(--radius);
  cursor: pointer;
}

button:hover { border-color: var(--accent); }
button.primary {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: var(--accent);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.main { padding: 24px 20px 60px; }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }

h1 { margin-top: 0; }
h2 { margin-top: 0; }

.stats {
  display: flex;
  gap: 24px;
  color: var(--muted);
  margin: 16px 0;
}

.progress {
  margin-bottom: 20px;
}

.progress-bar {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

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

.progress-meta {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  font-size: 14px;
  color: var(--muted);
}

.question-card .scenario-tag {
  display: inline-block;
  font-size: 12px;
  padding: 2px 8px;
  background: var(--code-bg);
  border-radius: 4px;
  color: var(--muted);
  margin-bottom: 8px;
}

.question-card .situation {
  background: var(--bg);
  border-left: 3px solid var(--accent);
  padding: 12px 16px;
  border-radius: 4px;
  margin: 12px 0 16px;
}

.question-card .question-text {
  font-weight: 600;
  margin: 12px 0;
}

.options {
  list-style: none;
  padding: 0;
  margin: 0;
}

.options li {
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 10px;
  cursor: pointer;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  transition: border-color 0.15s;
}

.options li:hover:not(.locked) { border-color: var(--accent); }
.options li.locked { cursor: default; }

.options li .letter {
  font-weight: 700;
  min-width: 20px;
}

.options li.selected {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--bg));
}

.options li.correct {
  border-color: var(--correct);
  background: var(--correct-bg);
}

.options li.wrong {
  border-color: var(--wrong);
  background: var(--wrong-bg);
}

.explanation {
  margin-top: 16px;
  padding: 12px 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-left: 3px solid var(--correct);
  border-radius: 4px;
}

.explanation .label {
  font-weight: 700;
  color: var(--correct);
  margin-right: 6px;
}

.nav {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 20px;
}

.score-summary {
  text-align: center;
  padding: 24px 0;
}

.score-big {
  font-size: 48px;
  font-weight: 700;
}

.score-big #score-total {
  color: var(--muted);
  font-size: 32px;
}

.score-percent {
  font-size: 20px;
  color: var(--muted);
  margin-top: 8px;
}

.breakdown {
  display: grid;
  gap: 8px;
  margin: 20px 0;
}

.breakdown-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
}

.results-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin: 20px 0;
}

.review-list .review-item {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}

.review-item .verdict {
  font-weight: 700;
  margin-bottom: 6px;
}
.review-item .verdict.ok { color: var(--correct); }
.review-item .verdict.bad { color: var(--wrong); }

code {
  background: var(--code-bg);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 0.92em;
}

@media (max-width: 600px) {
  .controls { width: 100%; }
  .controls select, .controls button { flex: 1; min-width: 0; }
  .score-big { font-size: 36px; }
}
