:root {
  --ink: #17202a;
  --muted: #617083;
  --line: #d9e0e7;
  --bg: #f6f8fb;
  --panel: #ffffff;
  --blue: #1d5f99;
  --green: #16775b;
  --red: #b34040;
  --amber: #b56b12;
  --focus: #7aa8d8;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: Arial, "Malgun Gothic", sans-serif;
  line-height: 1.55;
}

button,
input {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 6px;
  padding: 8px 11px;
  cursor: pointer;
}

button:hover,
button.active {
  border-color: var(--blue);
  color: var(--blue);
}

button:focus-visible,
input:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.primary {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

.primary:hover {
  color: #fff;
  filter: brightness(0.95);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  padding: 18px 28px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 24px;
}

h2 {
  font-size: 18px;
  margin-bottom: 12px;
}

.timer {
  display: flex;
  align-items: center;
  gap: 12px;
}

#timerText {
  min-width: 104px;
  font-size: 30px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.timer.warning #timerText {
  color: var(--amber);
}

.timer.danger #timerText {
  color: var(--red);
}

.timerActions,
.toolbarActions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 22px;
  max-width: 1420px;
  margin: 0 auto;
  padding: 24px 28px 36px;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.panel,
.toolbar,
.question {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.panel {
  padding: 16px;
}

.panel label {
  display: block;
  margin: 10px 0;
}

.note p,
footer p,
#examMeta {
  color: var(--muted);
}

.examTabs {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.examTabs button {
  min-height: 42px;
  padding: 6px;
}

.stats {
  color: var(--muted);
}

.stats span {
  color: var(--ink);
  font-weight: 700;
}

progress {
  width: 100%;
  height: 10px;
  margin-top: 12px;
}

.content {
  min-width: 0;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
  padding: 18px;
}

.toolbar h2 {
  margin-bottom: 2px;
}

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

.question {
  padding: 18px;
}

.question.hidden {
  display: none;
}

.questionHeader {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 10px;
}

.stem {
  font-weight: 700;
}

.tag {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: #edf3f9;
  color: var(--blue);
  font-size: 12px;
  white-space: nowrap;
}

.choices {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.choice {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.choice.correct {
  border-color: var(--green);
  background: #eef9f5;
}

.choice.wrong {
  border-color: var(--red);
  background: #fff1f1;
}

.explanation {
  display: none;
  margin-top: 12px;
  padding: 12px;
  border-left: 4px solid var(--blue);
  background: #f4f8fc;
}

.show .explanation {
  display: block;
}

.questionTools {
  margin-top: 12px;
}

.bookmark.active {
  border-color: var(--amber);
  color: var(--amber);
}

footer {
  max-width: 1420px;
  margin: 0 auto 28px;
  padding: 0 28px;
}

@media (max-width: 900px) {
  .topbar,
  .toolbar,
  .timer {
    align-items: stretch;
    flex-direction: column;
  }

  #timerText {
    text-align: left;
  }

  .layout {
    grid-template-columns: 1fr;
    padding: 18px;
  }

  .sidebar {
    order: 2;
  }

  .content {
    order: 1;
  }
}

@media print {
  .topbar,
  .sidebar,
  .toolbarActions,
  footer,
  .questionTools {
    display: none;
  }

  body {
    background: #fff;
  }

  .layout {
    display: block;
    padding: 0;
  }

  .question {
    break-inside: avoid;
    border: 0;
    border-radius: 0;
    padding: 10px 0;
  }
}
