:root {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #242628;
  background: #fff;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --muted: #6e7276;
  --line: #e2e4e6;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
button, input, select { font: inherit; }
button, select, input[type="checkbox"] { cursor: pointer; }
button { color: inherit; }
button:disabled { cursor: default; }
button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 3px solid #546d85;
  outline-offset: 3px;
}

.toolbar {
  max-width: 1440px;
  margin: auto;
  padding: 22px 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid var(--line);
}
.site-title { font-size: 15px; font-weight: 600; white-space: nowrap; }
.settings { display: flex; align-items: center; flex-wrap: wrap; gap: 24px; font-size: 14px; }
.settings label { display: flex; align-items: center; gap: 8px; }
.settings select { min-width: 0; max-width: 260px; padding: 5px 8px; border: 1px solid #c9cdd0; border-radius: 4px; background: #fff; }
.shuffle-option input { width: 17px; height: 17px; margin: 0; accent-color: #343a40; }
.settings button, .restart-link { padding: 6px 0; border: 0; background: none; color: var(--muted); }
.settings button:hover, .restart-link:hover { color: #242628; text-decoration: underline; }

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 250px;
  gap: 64px;
  max-width: 1440px;
  margin: auto;
  padding: 52px 40px 80px;
  align-items: start;
}
#quiz-root { min-width: 0; }
.question-meta { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; color: var(--muted); }
.question-title {
  font-size: clamp(30px, 3.1vw, 46px);
  font-weight: 600;
  line-height: 1.24;
  letter-spacing: -0.025em;
  margin: 20px 0 36px;
  overflow-wrap: break-word;
}
.question-title:focus { outline: none; }
.choices { display: grid; gap: 10px; }
.choice {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 16px;
  width: 100%;
  padding: 18px 20px;
  text-align: left;
  border: 1px solid #d7dadd;
  border-radius: 5px;
  background: #fff;
  font-size: 18px;
  line-height: 1.5;
  transition: background 120ms, border-color 120ms;
}
.choice:not(:disabled):hover { background: #f6f7f8; border-color: #8a9096; }
.choice:not(:disabled):active { background: #eceff1; }
.choice-letter { color: var(--muted); font-size: 15px; }
.choice.correct { background: #f1f7f1; border-color: #6a946b; }
.choice.wrong { background: #fcf3f1; border-color: #b87b70; }
.choice-status { font-size: 12px; color: #426444; white-space: nowrap; }
.choice.wrong .choice-status { color: #955045; }
.feedback { font-size: 16px; line-height: 1.6; }
.feedback p { margin: 22px 0 0; }
.quiz-controls { display: flex; justify-content: flex-end; margin-top: 26px; }
.primary-button {
  padding: 12px 20px;
  border: 1px solid #30363b;
  border-radius: 5px;
  background: #30363b;
  color: #fff;
  font-size: 16px;
}
.primary-button:hover:not(:disabled) { background: #495159; }
.primary-button:active:not(:disabled) { transform: translateY(1px); }
.primary-button:disabled { opacity: .6; }

.sidebar { border-left: 1px solid var(--line); padding-left: 28px; position: sticky; top: 28px; max-height: calc(100dvh - 56px); overflow-y: auto; }
.sidebar h2 { font-size: 17px; font-weight: 600; margin: 0 0 18px; }
.ranking-group + .ranking-group { margin-top: 28px; }
.ranking-group h3 { font-size: 14px; line-height: 1.5; font-weight: 600; margin: 0 0 6px; }
.sidebar p { font-size: 14px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; table-layout: fixed; }
th, td { padding: 12px 0; border-bottom: 1px solid var(--line); text-align: left; }
thead th { color: var(--muted); font-size: 12px; font-weight: 400; }
tbody th { font-weight: 400; overflow-wrap: anywhere; padding-right: 12px; }
th:first-child { width: 26px; }
th:last-child { width: 76px; }
.numeric { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rank { color: var(--muted); font-size: 12px; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }

.score-form { max-width: 460px; margin: 30px 0; }
.score-form label { display: block; margin-bottom: 8px; font-size: 15px; }
.save-row { display: flex; gap: 10px; }
.save-row input { width: 100%; min-width: 0; padding: 10px 12px; border: 1px solid #c9cdd0; border-radius: 5px; }
.score-form p { font-size: 14px; }
.restart-link { font-size: 15px; }
.review { border-top: 1px solid var(--line); margin: 36px 0 24px; padding-top: 24px; }
.review h2 { font-size: 22px; font-weight: 600; margin: 0 0 24px; }
.review-question { padding-bottom: 24px; }
.review-question + .review-question { border-top: 1px solid var(--line); padding-top: 24px; }
.review-question h3 { font-size: 19px; line-height: 1.5; font-weight: 600; margin: 0 0 16px; overflow-wrap: anywhere; }
.review-question p { font-size: 16px; line-height: 1.6; margin: 8px 0; overflow-wrap: anywhere; }
.review-wrong { color: #955045; }
.review-correct { color: #426444; }
.review-empty { margin: 28px 0; }

@media (max-width: 1000px) {
  .layout { gap: 32px; grid-template-columns: minmax(0, 1fr) 210px; padding: 36px 24px 64px; }
  .toolbar { padding: 18px 24px; }
  .settings { gap: 16px; }
  .choice { font-size: 17px; }
  .choice-status { grid-column: 2 / -1; margin-top: -8px; }
}
@media (max-width: 720px) {
  .toolbar { align-items: flex-start; flex-direction: column; gap: 16px; padding: 18px 20px; }
  .settings { gap: 12px 20px; font-size: 13px; }
  #batch-option { width: 100%; }
  #question-batch { flex: 1; max-width: 100%; width: 0; }
  .layout { grid-template-columns: 1fr; padding: 28px 20px 48px; gap: 48px; }
  .question-title { font-size: 30px; margin: 18px 0 28px; }
  .question-meta { font-size: 13px; }
  .choice { padding: 15px; gap: 10px; font-size: 16px; grid-template-columns: 20px minmax(0, 1fr); }
  .sidebar { border-left: 0; border-top: 1px solid var(--line); padding: 24px 0 0; position: static; max-height: none; overflow-y: visible; }
  .quiz-controls .primary-button { width: 100%; }
  .save-row { flex-direction: column; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}
