:root {
  --ink: #1d2733;
  --muted: #5f6c7a;
  --line: #d9dfe5;
  --bg: #f4f6f7;
  --paper: #ffffff;
  --accent: #17607a;
  --accent-soft: #e3f0f4;
  --good: #1f7a4d;
  --good-soft: #e4f3ea;
  --bad: #b3352b;
  --bad-soft: #fbe9e7;
  --warn: #b3352b;
  font-family: "Pretendard", "Malgun Gothic", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  color: var(--ink);
  line-height: 1.6;
}
* { box-sizing: border-box; }
html { scroll-padding-top: 76px; }
body { margin: 0; background: var(--bg); }
h1, h2, p { margin: 0; }
a { color: var(--accent); }
[hidden] { display: none !important; }

.btn {
  font: inherit; font-weight: 600; padding: 9px 16px; border: 1px solid var(--line); border-radius: 6px;
  background: var(--paper); color: var(--ink); cursor: pointer;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #124e64; }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.ghost { background: transparent; }
.btn.wide { width: 100%; }
.link { font: inherit; background: none; border: 0; color: var(--muted); cursor: pointer; padding: 0; text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

input, select, textarea {
  font: inherit; color: inherit; width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 6px; background: #fff;
}
input[type="checkbox"] { width: auto; }
label { font-size: 14px; font-weight: 600; display: block; }

.eyebrow { color: var(--accent); font-size: 14px; font-weight: 700; }
.mono { font-family: Consolas, "Cascadia Mono", monospace; word-break: break-all; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.empty { color: var(--muted); padding: 28px 0; text-align: center; }
.hint { color: var(--muted); font-size: 14px; margin-bottom: 14px; }

/* 로그인 */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(380px, 100%); background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 32px; display: grid; gap: 10px; }
.login-card h1 { font-size: 26px; margin-bottom: 10px; }
.login-card .btn { margin-top: 10px; }
.form-error { color: var(--bad); font-size: 14px; }

/* 상단 */
.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 28px; padding: 0 24px; min-height: 58px;
  background: var(--paper); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 800; color: var(--ink); text-decoration: none; white-space: nowrap; }
.topbar nav { display: flex; gap: 22px; flex: 1; }
.topbar nav a { color: var(--muted); text-decoration: none; font-weight: 600; padding: 17px 0 15px; border-bottom: 3px solid transparent; white-space: nowrap; }
.topbar nav a.on { color: var(--ink); border-color: var(--accent); }
.who { display: flex; gap: 14px; font-size: 14px; white-space: nowrap; }
.page { max-width: 1040px; margin: 0 auto; padding: 32px 24px 80px; }
.page-head { margin-bottom: 22px; }
.page-head h1 { font-size: 26px; }
.page-head p { color: var(--muted); }
.notice { display: block; padding: 12px 16px; background: var(--accent-soft); border-radius: 6px; margin-bottom: 20px; font-weight: 600; text-decoration: none; }

/* 시험 선택 */
.level-tabs { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-bottom: 18px; }
.level-tabs button {
  font: inherit; display: grid; gap: 1px; text-align: left; padding: 12px 14px; background: var(--paper);
  border: 1px solid var(--line); border-radius: 8px; cursor: pointer; color: var(--ink);
}
.level-tabs button span { font-size: 13px; color: var(--muted); }
.level-tabs button.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.level-tabs button.on span { color: #d8ebf1; }
.round-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.round {
  font: inherit; color: var(--ink); text-align: left; padding: 14px; background: var(--paper); border: 1px solid var(--line);
  border-radius: 8px; cursor: pointer; display: grid; gap: 2px;
}
.round:hover { border-color: var(--accent); }
.round span { font-size: 13px; color: var(--muted); }
.round.done { background: var(--accent-soft); border-color: #b9d9e3; }
.rules { margin: 0; padding-left: 20px; }

/* 시험 화면 */
.exam-bar {
  position: sticky; top: 0; z-index: 10; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: 8px 24px; background: var(--ink); color: #fff; min-height: 58px;
}
.timer { font-size: 28px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: 1px; }
.timer.warn { color: #ffb4ab; }
.omr-open { display: none; justify-self: end; }
.exam-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; max-width: 1240px; margin: 0 auto; padding: 20px 24px 60px; align-items: start; }
.paper { background: var(--paper); border: 1px solid var(--line); border-radius: 8px; padding: 12px 36px; min-width: 0; }
.q { padding: 24px 0; border-bottom: 1px solid var(--line); }
.q:last-child { border-bottom: 0; }
.stem { font-size: 17px; }
.points { color: var(--muted); font-size: 14px; white-space: nowrap; }
.table-wrap { overflow-x: auto; margin-top: 12px; }
table { border-collapse: collapse; width: 100%; }
table.data { font-size: 15px; }
table.data th, table.data td { border: 1px solid #aeb8c2; padding: 6px 10px; text-align: center; }
table.data th { background: #eef1f3; font-weight: 600; }
.bogi { position: relative; margin-top: 16px; padding: 16px 16px 10px; border: 1px solid #aeb8c2; }
.bogi p { margin-bottom: 6px; }
.bogi-label { position: absolute; top: -11px; left: 50%; transform: translateX(-50%); background: var(--paper); padding: 0 10px; font-size: 14px; font-weight: 700; }
.choices { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 3px; }
.choices li { display: flex; gap: 10px; padding: 5px 8px; border-radius: 5px; }
.paper .choices li { cursor: pointer; }
.paper .choices li:hover { background: var(--bg); }
.choices li.picked { background: var(--accent-soft); font-weight: 600; }
.mark { flex: none; }

.omr {
  position: sticky; top: 74px; max-height: calc(100vh - 90px); display: flex; flex-direction: column; gap: 10px;
  background: var(--paper); border: 1px solid var(--line); border-radius: 8px; padding: 14px;
}
.omr-head { display: flex; justify-content: space-between; align-items: baseline; }
.omr-close { display: none; }
.progress-text { color: var(--muted); font-size: 14px; }
.omr-rows { overflow-y: auto; flex: 1; min-height: 0; padding-right: 4px; }
.omr-row { display: grid; grid-template-columns: 34px repeat(5, 1fr); align-items: center; gap: 4px; padding: 3px 0; }
.omr-row:nth-child(5n) { border-bottom: 1px solid var(--line); padding-bottom: 7px; margin-bottom: 4px; }
.omr-num { font: inherit; font-weight: 700; background: none; border: 0; cursor: pointer; color: var(--ink); padding: 0; }
.bubble {
  font: 12px inherit; font-family: inherit; height: 28px; width: 36px; justify-self: center; border: 1px solid #c98a84; border-radius: 50%;
  background: #fff; color: #a4574f; cursor: pointer; padding: 0;
}
.bubble:hover { background: var(--bad-soft); }
.bubble.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.save-state { font-size: 12px; color: var(--muted); }
.save-state.bad { color: var(--bad); font-weight: 700; }

/* 표·패널 */
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: 8px; padding: 20px; margin-bottom: 18px; }
.panel h2 { font-size: 18px; margin-bottom: 8px; }
.list { background: var(--paper); font-size: 15px; }
.list th { text-align: left; font-size: 13px; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.list td { padding: 9px 10px; border-bottom: 1px solid #eceff2; }
.tag.live { background: var(--accent-soft); color: var(--accent); font-size: 13px; font-weight: 700; padding: 2px 8px; border-radius: 10px; white-space: nowrap; }
.builder { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.builder > div { min-width: 140px; }
.builder .grow { flex: 1; min-width: 240px; }
.personal-list { display: grid; gap: 8px; }
.personal-row { display: flex; align-items: center; gap: 14px; padding: 10px 0; border-top: 1px solid #eceff2; }
.personal-row:first-child { border-top: 0; }
.personal-row > div { flex: 1; display: grid; }
.personal-row span { font-size: 13px; color: var(--muted); }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.url { background: var(--bg); padding: 8px 10px; border-radius: 6px; font-size: 14px; }

/* 결과 */
.score-card { display: flex; justify-content: space-between; gap: 24px; flex-wrap: wrap; background: var(--paper); border: 1px solid var(--line); border-radius: 8px; padding: 24px; margin-bottom: 14px; }
.score { font-size: 46px; font-weight: 800; line-height: 1.2; }
.score small { font-size: 18px; font-weight: 500; color: var(--muted); }
.facts { display: grid; grid-template-columns: repeat(4, auto); gap: 8px 30px; margin: 0; align-self: center; }
.facts dt { font-size: 13px; color: var(--muted); }
.facts dd { margin: 0; font-weight: 700; white-space: nowrap; }
.domain-bars { background: var(--paper); border: 1px solid var(--line); border-radius: 8px; padding: 14px 24px; margin-bottom: 14px; }
.bar-row { display: grid; grid-template-columns: 150px 1fr 50px; gap: 12px; align-items: center; font-size: 14px; padding: 3px 0; }
.bar-row progress { width: 100%; height: 10px; accent-color: var(--accent); }
.answer-strip { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 24px; }
.answer-strip a { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 5px; text-decoration: none; font-weight: 700; font-size: 14px; }
.answer-strip a.ok { background: var(--good-soft); color: var(--good); }
.answer-strip a.no { background: var(--bad-soft); color: var(--bad); }
.review-tools { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.review-tools h2 { font-size: 20px; }
.check { display: flex; gap: 6px; align-items: center; font-weight: 500; }
.review-list { display: grid; gap: 12px; }
.q.review { background: var(--paper); border: 1px solid var(--line); border-left: 4px solid var(--good); border-radius: 6px; padding: 20px 24px; }
.q.review.is-wrong { border-left-color: var(--bad); }
.verdict { display: inline-block; font-size: 13px; font-weight: 700; color: var(--good); margin-bottom: 4px; }
.is-wrong .verdict { color: var(--bad); }
.choices li.answer { background: var(--good-soft); font-weight: 600; }
.choices li.mine:not(.answer) { background: var(--bad-soft); }
.choices li em { font-style: normal; font-size: 12px; font-weight: 700; margin-left: auto; white-space: nowrap; color: var(--muted); }
.explain { margin-top: 14px; padding: 12px 14px; background: var(--bg); border-radius: 6px; }
.explain-title { font-weight: 700; }
.meta { font-size: 13px; color: var(--muted); margin-top: 4px; }

/* 대화상자 */
.overlay { position: fixed; inset: 0; z-index: 50; background: rgba(20, 28, 36, .5); display: grid; place-items: center; padding: 16px; }
.dialog { background: var(--paper); border-radius: 10px; padding: 24px; width: min(460px, 100%); max-height: 90vh; overflow: auto; display: grid; gap: 14px; }
.dialog:has(table) { width: min(820px, 100%); }
.dialog h2 { font-size: 20px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
.stack { display: grid; gap: 10px; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 60; background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 6px; max-width: calc(100vw - 32px); }

@media (max-width: 920px) {
  .exam-layout { grid-template-columns: minmax(0, 1fr); padding: 0 0 40px; }
  .exam-bar { padding: 8px 16px; }
  .timer { font-size: 22px; }
  .omr-open { display: block; padding: 6px 12px; }
  .paper { border-width: 0; border-radius: 0; padding: 4px 16px; }
  .omr { display: none; position: fixed; inset: 58px 0 0 auto; width: min(340px, 100%); max-height: none; z-index: 20; border-radius: 0; }
  .omr.open { display: flex; }
  .omr-close { display: inline; }
  .topbar { flex-wrap: wrap; gap: 0 16px; padding: 8px 16px 0; }
  .topbar nav { order: 3; flex-basis: 100%; overflow-x: auto; }
  .topbar nav a { padding: 8px 0; }
  .who { margin-left: auto; }
  .page { padding: 20px 16px 60px; }
  .level-tabs { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; }
  .level-tabs button { padding: 8px 6px; text-align: center; }
  .level-tabs button span { display: none; }
  .round-grid { grid-template-columns: repeat(2, 1fr); }
  .facts { grid-template-columns: repeat(2, auto); }
  .bar-row { grid-template-columns: 110px 1fr 44px; }
  .q.review { padding: 16px; }
}

@media print {
  body { background: #fff; }
  .topbar, .no-print { display: none !important; }
  .page { max-width: none; padding: 0; }
  .print-paper { border: 0; padding: 0; }
  .q { break-inside: avoid; padding: 12px 0; }
  .print-break { break-before: page; }
}
