/* KU-Ration · 수능수학 출제팀 — 크림슨 + 마젠타, 모던(Pretendard) 글꼴, 자동 다크 모드 */
:root {
  color-scheme: light dark;
  --paper: #FBF7F1; --card: #FFFDF9; --ink: #2A1A18; --muted: #6F5B55;
  --rule: #CDB9B1; --line: #E6D9D0;
  --crimson: #8B0029; --crimson-text: #8B0029; --crimson-tint: #F5E1E6;
  --magenta: #BD005F; --magenta-hover: #A30053; --magenta-text: #BD005F; --magenta-tint: #FCE3EE;
  --good: #1F7A46; --bad: #B3261E; --warn-bg: #FFF4DD; --ok-bg: #E8F5EC; --err-bg: #FCE9E7;
  --stripe: rgba(139, 0, 41, .07); --stripe-bar: rgba(255, 255, 255, .16);
  /* 글꼴: Pretendard (static/fonts/pretendard, SIL OFL). 예전 이름(--serif)은 제목용으로 그대로 두고 같은 글꼴을 씀 */
  --sans: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, system-ui, "Apple SD Gothic Neo",
          "Malgun Gothic", sans-serif;
  --serif: var(--sans);
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #1A1213; --card: #231819; --ink: #F3E8E4; --muted: #B9A59F;
    --rule: #5A4745; --line: #3A2C2C;
    --crimson: #6E0022; --crimson-text: #F08AA0; --crimson-tint: #3A1620;
    --magenta: #BD005F; --magenta-hover: #D1126F; --magenta-text: #FF8DBB; --magenta-tint: #3B1428;
    --good: #6FD3A0; --bad: #FF9C94; --warn-bg: #3A2D14; --ok-bg: #12301F; --err-bg: #3B1815;
    --stripe: rgba(255, 255, 255, .05); --stripe-bar: rgba(255, 255, 255, .13);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column; position: relative;
  background: var(--paper); color: var(--ink); font: 16px/1.65 var(--sans);
  word-break: keep-all; overflow-wrap: break-word; /* 한글은 단어 단위로 줄바꿈 */
}
/* 호랑이 줄무늬(추상) 워터마크 */
body::before {
  content: ""; position: absolute; top: 68px; right: 0; width: 200px; height: 260px; pointer-events: none;
  background: var(--stripe);
  -webkit-mask: url(stripes-page.svg) right top / contain no-repeat;
  mask: url(stripes-page.svg) right top / contain no-repeat;
}
.wrap { width: 100%; max-width: 880px; margin: 0 auto; padding: 0 20px; }
main.wrap { flex: 1; position: relative; padding-top: 30px; padding-bottom: 48px; }
a { color: var(--magenta-text); }
:focus-visible { outline: 2px solid var(--magenta); outline-offset: 2px; }

/* 헤더 */
.top { position: relative; overflow: hidden; background: var(--crimson); border-bottom: 4px solid var(--magenta); }
.top::after {
  content: ""; position: absolute; right: 0; top: 0; width: 220px; height: 100%; pointer-events: none;
  background: var(--stripe-bar);
  -webkit-mask: url(stripes-bar.svg) right center / auto 100% no-repeat;
  mask: url(stripes-bar.svg) right center / auto 100% no-repeat;
}
.bar { position: relative; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 64px; }
.brand { display: flex; align-items: center; min-height: 44px; }
.brand img { display: block; height: 34px; width: auto; }
.top nav { display: flex; align-items: center; flex-wrap: wrap; justify-content: flex-end; gap: 0 18px; font-size: 14px; font-weight: 500; }
.top nav a, .top nav .who, .top nav button.link { color: #fff; text-decoration: none; margin: 0; }
.top nav a, .top nav button.link { display: inline-flex; align-items: center; min-height: 44px; }
.top nav a:hover, .top nav button.link:hover { text-decoration: underline; }
.top nav .who { opacity: .8; }
button.link { font: inherit; background: none; border: 0; padding: 0; cursor: pointer; color: var(--magenta-text); }
form.inline { display: inline; }

.foot { text-align: center; color: var(--muted); font-size: 12px; letter-spacing: .18em; padding-bottom: 32px; }

/* 제목 */
h1, h2 { font-family: var(--serif); }
h1 { font-size: 30px; line-height: 1.3; font-weight: 800; margin: 6px 0 10px; letter-spacing: -.025em; }
h2 { font-size: 20px; font-weight: 700; margin: 26px 0 8px; letter-spacing: -.015em; }
h3 { font-size: 16px; margin: 22px 0 8px; }
.eyebrow { font-family: var(--serif); font-size: 12px; letter-spacing: .3em; font-weight: 600; color: var(--crimson-text); }
.pagehead { text-align: center; padding-bottom: 20px; margin-bottom: 22px; border-bottom: 4px double var(--crimson); }
.pagehead h1 { margin-bottom: 6px; }
.muted { color: var(--muted); } .small { font-size: 13px; }
.meta { color: var(--muted); margin: 0; }
.center { text-align: center; }

/* 버튼 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 20px;
  font: inherit; font-weight: 600; font-size: 15px; color: var(--crimson-text); text-decoration: none; cursor: pointer;
  background: transparent; border: 1.5px solid var(--crimson-text); border-radius: 3px;
}
.btn:hover { background: var(--crimson-tint); }
.btn.primary { color: #fff; background: var(--magenta); border-color: var(--magenta); }
.btn.primary:hover { background: var(--magenta-hover); border-color: var(--magenta-hover); }
.btn.danger { color: var(--bad); border-color: var(--bad); }
.btn.danger:hover { background: var(--err-bg); }
.actions .btn { min-height: 36px; padding: 0 12px; font-size: 13px; }

/* 안내 / 박스 */
.flash { padding: 11px 16px; border-radius: 3px; margin-bottom: 12px; background: var(--magenta-tint); border: 1px solid var(--line); }
.flash.ok { background: var(--ok-bg); } .flash.error { background: var(--err-bg); } .flash.warn { background: var(--warn-bg); }
.box { padding: 13px 16px; border: 1px solid var(--line); background: var(--card); border-radius: 3px; }
.box.ok { background: var(--ok-bg); } .box.warn { background: var(--warn-bg); }

/* 시험 목록 */
.cards { display: grid; gap: 14px; }
.card { display: block; padding: 18px 20px; background: var(--card); border: 1px solid var(--line); border-radius: 3px; text-decoration: none; color: var(--ink); }
.card:hover { border-color: var(--magenta); }
.card strong { font-family: var(--serif); font-size: 18px; line-height: 1.4; }
.row { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 4px; }
.badge { flex-shrink: 0; display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 11px; border-radius: 99px; background: var(--line); color: var(--muted); }
.badge.open { background: var(--magenta-tint); color: var(--magenta-text); }
.badge.upcoming { background: var(--crimson-tint); color: var(--crimson-text); }
.badge.super { background: var(--crimson); color: #fff; }
.badge.admin { background: var(--magenta-tint); color: var(--magenta-text); }

/* 로그인 / 가입 */
.auth { max-width: 380px; margin: 0 auto; padding-top: 14px; }
.auth-brand { text-align: center; padding: 8px 0 18px; }
.auth-brand img { display: block; margin: 0 auto 10px; height: 92px; width: auto; }
.auth-brand .logo-dark { display: none; }
.auth-rule { border-top: 4px double var(--crimson); margin-bottom: 8px; }
.auth h1 { text-align: center; font-size: 24px; margin-top: 18px; }
@media (prefers-color-scheme: dark) {
  .auth-brand .logo-light { display: none; }
  .auth-brand .logo-dark { display: block; }
}

/* 폼 */
.form label { display: block; margin: 14px 0; font-weight: 600; }
.form.narrow { max-width: 380px; margin: 0 auto; }
.form input:not([type=radio]):not([type=file]), .form textarea, .form select, .searchbar input {
  display: block; width: 100%; margin-top: 5px; padding: 10px 12px; min-height: 44px; font: inherit;
  color: var(--ink); background: var(--card); border: 1px solid var(--rule); border-radius: 3px;
}
.form input[type=file] { display: block; margin-top: 6px; font: inherit; color: var(--ink); max-width: 100%; }
/* 동의 체크박스 (가입) */
.form label.check { display: flex; align-items: center; gap: 10px; min-height: 44px; font-weight: 500; cursor: pointer; }
.form label.check input[type=checkbox] { display: inline-block; flex: none; width: 20px; height: 20px; min-height: 0;
  margin: 0; padding: 0; accent-color: var(--magenta); }
.form details.notice { margin: 14px 0 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 3px; background: var(--card); }
.form details.notice summary { cursor: pointer; font-weight: 600; min-height: 28px; }
.form details.notice p { margin: 8px 0 0; line-height: 1.7; }
/* 개인정보 처리방침 */
.policy { line-height: 1.8; }
.policy h2 { margin-top: 32px; }
.policy ol, .policy ul { padding-left: 22px; }
.policy li { margin: 6px 0; }
.policy table.grid { margin: 10px 0; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* 표 */
table { border-collapse: collapse; width: 100%; }
th, td { padding: 9px 10px; text-align: left; vertical-align: middle; border-bottom: 1px dotted var(--rule); }
table.grid { background: var(--card); }
table.grid thead th { font-size: 12.5px; color: var(--muted); font-weight: 700; border-bottom: 2px solid var(--ink); }
table.grid td:first-child { font-family: var(--serif); font-weight: 700; }
tr.me td { background: var(--magenta-tint); font-weight: 700; }
tr.top3 td:first-child { color: var(--crimson-text); font-size: 18px; }
tr.right td:nth-child(4) { color: var(--good); font-weight: 700; }
tr.wrong td:nth-child(4) { color: var(--bad); font-weight: 700; }

/* 답안 입력 (OMR 대신 클래식 번호표) */
table.answer { background: transparent; }
table.answer tr.sec th {
  padding: 26px 0 8px; border-bottom: 1.5px solid var(--ink); text-align: left;
  font-family: var(--serif); font-size: 18px; font-weight: 700;
}
table.answer tr.sec th .part { margin-right: 10px; font-size: 13px; letter-spacing: .1em; color: var(--crimson-text); }
table.answer tr.sec th small { margin-left: 10px; font-family: var(--sans); font-size: 12px; font-weight: 400; color: var(--muted); }
table.answer td.num { width: 64px; padding-right: 14px; text-align: right; font-family: var(--serif); font-weight: 700; font-size: 17px; }
table.answer td.num small.pts { display: block; font-family: var(--sans); font-size: 11px; font-weight: 400; color: var(--muted); line-height: 1.2; }
table.answer td.choices { width: 100%; }
.opts { display: flex; justify-content: flex-end; gap: 8px; }
.opt { position: relative; flex: 0 1 44px; min-width: 0; cursor: pointer; }
.opt input { position: absolute; opacity: 0; inset: 0; }
.opt span {
  display: flex; align-items: center; justify-content: center; width: 100%; aspect-ratio: 1; border-radius: 50%;
  font-family: var(--serif); font-size: 16px; color: var(--ink); background: var(--card); border: 1px solid var(--rule);
}
.opt:hover span { border-color: var(--magenta); }
.opt input:checked + span { background: var(--crimson-text); border-color: var(--crimson-text); color: var(--paper); font-weight: 700; }
.opt input:focus-visible + span { outline: 2px solid var(--magenta); outline-offset: 2px; }
@media (prefers-color-scheme: light) { .opt input:checked + span { color: #fff; } }
input.short {
  display: inline-block; width: 140px; padding: 4px 8px; font-family: var(--serif); font-size: 22px; font-weight: 700; text-align: center;
  color: var(--ink); background: transparent; border: 0; border-bottom: 2px solid var(--ink); border-radius: 0;
}
input.short:focus { outline: none; border-bottom-color: var(--magenta); }
table.answer td.choices:has(input.short) { text-align: right; }
table.admin th { font-size: 12.5px; color: var(--muted); border-bottom: 2px solid var(--ink); }
.form table.admin input.short { width: 90px !important; margin: 0; font-size: 16px; min-height: 40px; padding: 4px 8px; border: 1px solid var(--rule); border-radius: 3px; }
table.admin td.num { font-size: 16px; }

/* 탭 */
nav.tabs { display: flex; gap: 2px; margin: 4px 0 8px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
nav.tabs a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 16px; margin-bottom: -1px; color: var(--muted); text-decoration: none; font-size: 14px; border-bottom: 3px solid transparent; }
nav.tabs a:hover { color: var(--ink); }
nav.tabs a[aria-current=page] { color: var(--crimson-text); font-weight: 700; border-bottom-color: var(--magenta); }

/* 결과 / 통계 */
.score { font-size: 20px; }
.score .big { font-family: var(--serif); font-size: 52px; font-weight: 900; color: var(--crimson-text); }
.score .rank { margin-left: 14px; padding: 4px 14px; background: var(--magenta-tint); color: var(--magenta-text); border-radius: 99px; font-size: 16px; font-weight: 700; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; }
.kpis div { background: var(--card); border: 1px solid var(--line); border-radius: 3px; padding: 12px 14px; }
.kpis span { display: block; color: var(--muted); font-size: 12px; }
.kpis b { font-family: var(--serif); font-size: 22px; }
.hist { background: var(--card); border: 1px solid var(--line); border-radius: 3px; padding: 10px 14px; }
.hrow { display: grid; grid-template-columns: 70px 1fr 36px; gap: 8px; align-items: center; font-size: 13px; padding: 2px 0; }
.hbar { display: inline-block; vertical-align: middle; width: 100%; height: 10px; border-radius: 99px; overflow: hidden; background: var(--line); }
.hbar i { display: block; height: 100%; background: var(--magenta); }
.hbar.mini { width: 70px; margin-right: 6px; }
.chip { display: inline-block; margin: 1px 3px 1px 0; padding: 1px 9px; font-size: 12px; border-radius: 99px; background: var(--line); }
.chip.ans { background: var(--ok-bg); color: var(--good); font-weight: 700; }
.pager { text-align: center; margin-top: 16px; }
.searchbar { display: flex; gap: 8px; margin: 12px 0 4px; }
.searchbar input { margin-top: 0; max-width: 260px; }

/* 모바일 */
@media (max-width: 640px) {
  h1 { font-size: 25px; }
  .score .big { font-size: 44px; }
  .top::after { width: 130px; }
  .brand img { height: 30px; }
  .top nav { gap: 0 12px; font-size: 13px; }
  table.grid { display: block; overflow-x: auto; white-space: nowrap; }
  .two { grid-template-columns: 1fr; }
  nav.tabs a { padding: 0 12px; }
  .searchbar input { max-width: none; }
}
@media (max-width: 400px) {
  .wrap { padding: 0 14px; }
  .opts { gap: 5px; }
  table.answer td.num { width: 52px; padding-right: 8px; }
  .auth-brand img { height: 72px; }
}
@media (prefers-reduced-motion: no-preference) {
  .btn, .card, .opt span { transition: background-color .15s, border-color .15s; }
}
