:root {
  --bg: #f7f7f5; --surface: #fff; --text: #1f2328; --muted: #656d76; --line: #d8dadd;
  --accent: #2357d4; --ok: #1a7f37; --ok-bg: #e6f4ea; --bad: #c62828; --bad-bg: #fdecea; --warn: #9a6700; --warn-bg: #fff8e1;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15171a; --surface: #1e2125; --text: #e6e8eb; --muted: #9aa1a9; --line: #353a40;
    --accent: #7aa2ff; --ok: #5cc879; --ok-bg: #16301e; --bad: #ff7b72; --bad-bg: #3a1b1b; --warn: #e3b341; --warn-bg: #33290f;
  }
}
* { box-sizing: border-box; }
/* 프리텐다드: 한글·영문·숫자 모두 고른 화면용 서체. 로딩 전·실패 시 시스템 한글 서체로 대체 */
body { margin: 0; font-family: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, system-ui, "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", sans-serif;
  font-size: 17px; line-height: 1.7; letter-spacing: -0.01em; word-break: keep-all; overflow-wrap: anywhere;
  -webkit-font-smoothing: antialiased; background: var(--bg); color: var(--text); }
a { color: var(--accent); }
.top { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; text-decoration: none; color: var(--text); }
main { max-width: 1100px; margin: 0 auto; padding: 16px; }
h1 { font-size: 1.4rem; margin: 8px 0 16px; }
h2 { font-size: 1.1rem; margin: 24px 0 8px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 16px; margin-bottom: 12px; }
.muted { color: var(--muted); font-size: .9rem; }
.badge { display: inline-block; font-size: .75rem; padding: 2px 8px; border-radius: 99px; background: var(--warn-bg); color: var(--warn); margin-left: 6px; }
button { font: inherit; padding: 10px 16px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--text); cursor: pointer; min-height: 44px; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button:focus-visible, input:focus-visible + span, a:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* 풀이 화면: PC는 문제 + OMR 병렬, 모바일은 OMR 접기 */
.solve { display: grid; grid-template-columns: 1fr 260px; gap: 16px; align-items: start; }
/* 답안표에 광고가 함께 있어 고정(sticky)하지 않는다: 스크롤 따라오는 광고 정책 위험 회피 */
.omr { position: static; }
@media (max-width: 800px) { .solve { grid-template-columns: 1fr; } .omr { position: static; order: -1; } }
.omr-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
.omr-grid a { display: block; text-align: center; padding: 6px 0; border: 1px solid var(--line); border-radius: 6px; text-decoration: none; color: var(--text); font-size: .85rem; }
.omr-grid a.done { background: var(--accent); color: #fff; border-color: var(--accent); }
.omr-grid a.marked { box-shadow: inset 0 -3px 0 var(--warn); }
.status { font-size: .85rem; color: var(--muted); }
.status.error { color: var(--bad); }

.q-head { display: flex; justify-content: space-between; gap: 8px; }
.q-subject { font-size: .8rem; color: var(--muted); }
.choices { list-style: none; padding: 0; margin: 12px 0 0; }
.choices label { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 6px; cursor: pointer; }
.choices input { margin-top: 5px; width: 18px; height: 18px; }
.choices label.is-answer { border-color: var(--ok); background: var(--ok-bg); }
.choices label.is-wrong { border-color: var(--bad); background: var(--bad-bg); }
.fb { margin-top: 8px; padding: 10px 12px; border-radius: 8px; }
.fb.ok { background: var(--ok-bg); color: var(--ok); }
.fb.bad { background: var(--bad-bg); color: var(--bad); }
.fb p { color: var(--text); margin: 4px 0 0; }
.mark { font-size: .85rem; display: flex; gap: 6px; align-items: center; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px; border-bottom: 1px solid var(--line); font-size: .95rem; }
th, td:nth-child(n+2) { white-space: nowrap; }
.fail { color: var(--bad); font-weight: 600; }
.pass { color: var(--ok); font-weight: 600; }
.big { font-size: 2rem; font-weight: 700; }

/* 광고: 콘텐츠·버튼과 충분히 띄우고 "광고" 표기. 높이를 미리 잡아 화면 밀림(CLS) 방지 */
.ad { margin: 32px 0; min-height: 120px; text-align: center; clear: both; }
.ad::before { content: "광고"; display: block; font-size: .7rem; color: var(--muted); text-align: left; margin-bottom: 4px; }
.ad-placeholder { display: flex; align-items: center; justify-content: center; border: 2px dashed var(--line); border-radius: 10px; color: var(--muted); font-size: .85rem; }
.ad-placeholder::before { content: none; }
.omr .ad { margin: 24px 0 0; min-height: 250px; }
.btn { display: inline-flex; align-items: center; padding: 10px 16px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--text); text-decoration: none; min-height: 44px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.foot { max-width: 1100px; margin: 24px auto; padding: 16px; font-size: .85rem; color: var(--muted); border-top: 1px solid var(--line); }
ol.plain { list-style: none; padding: 0; }
details { margin-top: 8px; border-top: 1px solid var(--line); padding-top: 8px; }
summary { cursor: pointer; color: var(--accent); min-height: 32px; }

/* 문항 보기 박스·표·그림 */
.qbox { border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; margin: 10px 0; white-space: pre-wrap; font-weight: normal; }
.qtable { width: auto; margin: 10px 0; border: 1px solid var(--line); font-weight: normal; }
.qtable th, .qtable td { border: 1px solid var(--line); padding: 4px 10px; text-align: center; }
.qimg { display: block; max-width: 100%; height: auto; margin: 8px 0; background: #fff; border-radius: 4px; }
.choices .qimg, ol.plain .qimg { display: inline-block; vertical-align: middle; margin: 4px 0 4px 6px; }
legend { width: 100%; }

.done-card { text-align: center; padding: 40px 16px; }
.big-btn { font-size: 1.1rem; padding: 14px 28px; margin-top: 12px; }
.next-card { justify-content: space-between; }

/* 해설 페이지 과목 제목·페이지 이동 */
.subject-head { font-size: 1rem; color: var(--muted); margin: 24px 0 8px; }
.pager-main { justify-content: space-between; }
.page-index { margin-top: 12px; }
.page-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 6px; margin-top: 8px; }
.page-grid a { text-align: center; padding: 6px 0; border: 1px solid var(--line); border-radius: 6px; text-decoration: none; color: var(--text); font-size: .85rem; }
.page-grid a[aria-current] { background: var(--accent); color: #fff; border-color: var(--accent); }
.subject-link { display: flex; justify-content: space-between; align-items: center; text-decoration: none; color: var(--text); }
