/* 레이아웃: 휴대폰 폭의 시험지 한 장. 표지(문제지) → 문항(OMR) → 판독 → 성적통지표 */
:root {
  --paper: #ECECE6;      /* 책상 */
  --sheet: #FDFDFA;      /* 시험지 */
  --ink: #18181C;        /* 컴퓨터용 사인펜 */
  --muted: #66656B;
  --rule: #D6D4CB;
  --omr: #D3365A;        /* OMR 답안지 붉은 선 */
  --omr-tint: #FBE8EC;
  --on-omr: #FFFFFF;
  --g-sj: #2F5D8A;
  --g-sp: #B85A22;
  --g-nt: #5B4AA0;
  --g-nf: #2A7A57;
  --shadow: 0 1px 0 rgba(24, 24, 28, .04), 0 12px 32px -12px rgba(24, 24, 28, .18);
  --photo: #F7F6F0;      /* 캐릭터 칸은 다크 모드에서도 밝게 (검은 외곽선 유지) */

  --f-display: 'Nanum Myeongjo', 'AppleMyungjo', 'Batang', serif;
  --f-body: 'IBM Plex Sans KR', -apple-system, 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
  --f-mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0F1013; --sheet: #1A1B1F; --ink: #ECEBE6; --muted: #A09FA6; --rule: #34353B;
    --omr: #FF6F8A; --omr-tint: #3A1C25; --on-omr: #1A1B1F;
    --g-sj: #7FAEDB; --g-sp: #E79A66; --g-nt: #A99BEB; --g-nf: #6FC79E;
    --shadow: 0 0 0 1px #2A2B30; --photo: #E6E4DB;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0F1013; --sheet: #1A1B1F; --ink: #ECEBE6; --muted: #A09FA6; --rule: #34353B;
  --omr: #FF6F8A; --omr-tint: #3A1C25; --on-omr: #1A1B1F;
  --g-sj: #7FAEDB; --g-sp: #E79A66; --g-nt: #A99BEB; --g-nf: #6FC79E;
  --shadow: 0 0 0 1px #2A2B30; --photo: #E6E4DB;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--f-body);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  word-break: keep-all;
  overflow-wrap: anywhere;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--omr); outline-offset: 2px; }
[hidden] { display: none !important; }
.mono { font-family: var(--f-mono); }

.sheet {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--sheet);
  box-shadow: var(--shadow);
  padding-left: max(20px, env(safe-area-inset-left, 0px));
  padding-right: max(20px, env(safe-area-inset-right, 0px));
  padding-block: 20px 32px;
}
.screen { display: flex; flex-direction: column; gap: 24px; animation: rise .35s ease both; }
@keyframes rise { from { transform: translateY(6px); } to { transform: none; } }

/* ── 공통 ───────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 52px; padding: 0 20px;
  border-radius: 6px; border: 1.5px solid var(--ink);
  background: transparent; font-weight: 700; font-size: 16px;
  transition: transform .08s ease, background .15s ease;
}
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--ink); color: var(--sheet); width: 100%; }
.btn--ghost { flex: 1; min-width: 0; font-size: 14px; min-height: 46px; padding: 0 10px; }
.btn--sm { min-height: 40px; width: auto; font-size: 14px; }
.link-btn { background: none; border: 0; padding: 4px 0; color: var(--muted); font-size: 14px; text-decoration: underline; text-underline-offset: 3px; }

.section-label {
  margin: 0 0 8px; font-size: 12px; font-weight: 700; letter-spacing: .08em; color: var(--omr);
}
.section-label--warn { color: var(--muted); }

/* ── 1. 표지 ────────────────────── */
.exam-head { border-bottom: 3px double var(--ink); padding-bottom: 14px; text-align: center; }
.exam-head__row { display: flex; justify-content: space-between; align-items: center; font-size: 13px; }
.exam-head__year { font-family: var(--f-display); font-weight: 700; }
.exam-head__type { border: 1.5px solid var(--ink); padding: 1px 10px; font-weight: 700; font-size: 13px; }
.exam-head__title { margin: 10px 0 6px; font-family: var(--f-display); font-weight: 800; font-size: 22px; letter-spacing: .02em; }
.exam-head__period { display: inline-flex; gap: 10px; align-items: baseline; font-size: 13px; }
.exam-head__period strong { font-family: var(--f-display); font-size: 16px; padding: 0 8px; border-left: 1px solid var(--rule); }

.intro { display: flex; flex-direction: column; gap: 16px; padding-top: 8px; }
.dday {
  align-self: flex-start; margin: 0;
  font-family: var(--f-mono); font-weight: 600; font-size: 13px; letter-spacing: .04em;
  color: var(--omr); border: 1.5px solid var(--omr); padding: 2px 10px; border-radius: 3px;
  transform: rotate(-2deg);
}
.intro__title {
  margin: 0; font-family: var(--f-display); font-weight: 800;
  font-size: clamp(38px, 11vw, 50px); line-height: 1.15; letter-spacing: -.02em; text-wrap: balance;
}
.intro__lead { margin: 0; color: var(--muted); }
.intro__meta { margin: -6px 0 0; text-align: center; font-size: 12px; color: var(--muted); }

.id-box {
  display: grid; grid-template-columns: 64px 1fr; border: 1.5px solid var(--ink);
}
.id-box label {
  display: grid; place-items: center; font-size: 13px; font-weight: 700;
  border-right: 1.5px solid var(--ink); background: var(--omr-tint); color: var(--omr);
}
.id-box input {
  border: 0; background: transparent; padding: 12px; min-width: 0; font-size: 16px;
}
.id-box input:focus { outline: none; background: var(--omr-tint); }

.intro__types { border-top: 1px solid var(--rule); padding-top: 20px; }

.type-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.type-chip {
  display: flex; flex-direction: column; gap: 2px; align-items: flex-start;
  padding: 6px 6px 9px; border: 1px solid var(--rule); border-radius: 4px; background: transparent;
  text-align: left; min-width: 0;
}
.type-chip img, .mate img {
  display: block; width: 100%; height: auto; aspect-ratio: 1; border-radius: 3px;
  background: var(--photo); margin-bottom: 4px;
}
.type-chip b { font-family: var(--f-mono); font-size: 13px; color: var(--gc); }
.type-chip span { font-size: 11px; line-height: 1.3; color: var(--muted); }
.type-chip:hover { border-color: var(--gc); }
.type-chip[aria-current="true"] { border-color: var(--gc); background: color-mix(in srgb, var(--gc) 10%, transparent); }

[data-group="SJ"] { --gc: var(--g-sj); }
[data-group="SP"] { --gc: var(--g-sp); }
[data-group="NT"] { --gc: var(--g-nt); }
[data-group="NF"] { --gc: var(--g-nf); }

/* ── 2. 문항 ────────────────────── */
.quiz-top { display: flex; justify-content: space-between; align-items: center; }
.quiz-count { font-family: var(--f-mono); font-size: 14px; color: var(--muted); }
.quiz-count b { color: var(--ink); }

.omr-strip {
  list-style: none; margin: 0; padding: 10px 8px;
  display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 4px;
  border: 1.5px solid var(--omr); background: var(--omr-tint);
}
.omr-strip li { display: flex; flex-direction: column; align-items: center; gap: 4px; font-family: var(--f-mono); font-size: 9px; color: var(--omr); }
.omr-strip i {
  width: 12px; height: 18px; border-radius: 6px; border: 1px solid var(--omr); background: var(--sheet);
  transition: background .2s ease;
}
.omr-strip li.is-done i { background: var(--ink); border-color: var(--ink); }
.omr-strip li.is-now i { border-width: 2px; }

.question { display: flex; flex-direction: column; gap: 14px; padding-top: 8px; }
.question__no { margin: 0; font-family: var(--f-display); font-weight: 800; font-size: 28px; line-height: 1; }
.question__text { margin: 0 0 8px; font-family: var(--f-display); font-weight: 700; font-size: 22px; line-height: 1.45; text-wrap: balance; min-height: 64px; }

.choices { display: flex; flex-direction: column; gap: 10px; }
.choice {
  display: grid; grid-template-columns: 30px 1fr; gap: 12px; align-items: start;
  padding: 16px 14px; text-align: left;
  border: 1.5px solid var(--rule); border-radius: 6px; background: transparent; font-size: 16px; line-height: 1.5;
  transition: border-color .15s ease, background .15s ease;
}
.choice:hover { border-color: var(--ink); }
.choice__mark {
  width: 26px; height: 26px; border-radius: 50%; border: 1.5px solid var(--omr);
  display: grid; place-items: center; font-family: var(--f-mono); font-size: 13px; color: var(--omr);
  position: relative; overflow: hidden;
}
.choice__mark::after {
  content: ""; position: absolute; inset: 0; background: var(--ink); border-radius: 50%;
  transform: scale(0); transition: transform .18s ease;
}
.choice.is-picked { border-color: var(--ink); background: var(--omr-tint); }
.choice.is-picked .choice__mark { border-color: var(--ink); }
.choice.is-picked .choice__mark::after { transform: scale(1); }
.quiz-hint { margin: 0; font-size: 12px; color: var(--muted); text-align: center; }

/* ── 3. 판독 ────────────────────── */
.loading { display: flex; flex-direction: column; align-items: center; gap: 18px; padding-top: 24px; }
.scanner { position: relative; width: 168px; padding: 12px; border: 1.5px solid var(--omr); background: var(--omr-tint); overflow: hidden; }
.scanner__card { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px 10px; }
.scanner__card i { height: 10px; border-radius: 5px; border: 1px solid var(--omr); background: var(--sheet); }
.scanner__card i.on { background: var(--ink); border-color: var(--ink); }
.scanner__beam {
  position: absolute; left: 0; right: 0; height: 3px; top: 0;
  background: var(--omr); box-shadow: 0 0 12px 2px var(--omr);
  animation: scan 1.1s ease-in-out infinite alternate;
}
@keyframes scan { from { top: 0; } to { top: calc(100% - 3px); } }
.loading__title { margin: 0; font-family: var(--f-display); font-weight: 800; font-size: 22px; }
.dots::after { content: ""; animation: dots 1.2s steps(4) infinite; }
@keyframes dots { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; } }
.tip { width: 100%; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); padding: 14px 0; text-align: center; }
.tip__label { margin: 0 0 4px; font-size: 12px; font-weight: 700; color: var(--omr); letter-spacing: .08em; }
.tip__text { margin: 0; min-height: 48px; }

/* ── 4. 성적통지표 ──────────────── */
.shared-banner {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between;
  padding: 12px 14px; background: var(--omr-tint); border-radius: 6px;
}
.shared-banner p { margin: 0; font-size: 14px; font-weight: 500; flex: 1 1 180px; }

.report {
  position: relative; border: 2px solid var(--ink); padding: 18px 16px 20px;
  background: var(--sheet);
}
.report__head { text-align: center; border-bottom: 3px double var(--ink); padding-bottom: 10px; }
.report__year { margin: 0; font-size: 13px; font-family: var(--f-display); font-weight: 700; }
.report__title { margin: 2px 0 0; font-family: var(--f-display); font-weight: 800; font-size: 26px; letter-spacing: .3em; padding-left: .3em; }
.report__id { display: grid; grid-template-columns: 1fr 1fr; margin: 0; border-bottom: 1px solid var(--ink); }
.report__id div { display: grid; grid-template-columns: auto 1fr; }
.report__id dt { padding: 8px 10px; font-size: 12px; font-weight: 700; background: var(--omr-tint); color: var(--omr); }
.report__id dd { margin: 0; padding: 8px 10px; font-weight: 700; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.report__id div + div { border-left: 1px solid var(--ink); }
.report__main { padding: 22px 4px 18px; text-align: center; }
.photo {
  position: relative; margin: 0 auto 16px; width: 156px; aspect-ratio: 3 / 4; max-width: 100%;
  border: 1.5px solid var(--ink); background: var(--photo);
  background-image: linear-gradient(to top, color-mix(in srgb, var(--gc, var(--omr)) 22%, transparent), transparent 55%);
  display: grid; place-items: end center; overflow: hidden;
}
.photo img { width: 100%; height: auto; }
.photo img[src=""] { visibility: hidden; }
.report__code {
  margin: 0; font-family: var(--f-mono); font-weight: 600; font-size: 56px; line-height: 1; letter-spacing: .08em;
  color: var(--gc, var(--ink));
}
.report__name { margin: 10px 0 6px; font-family: var(--f-display); font-weight: 800; font-size: 28px; line-height: 1.25; text-wrap: balance; }
.report__quote { margin: 0; color: var(--muted); font-size: 14px; }
.report__quote::before { content: "“"; } .report__quote::after { content: "”"; }

.report__table { width: 100%; border-collapse: collapse; font-size: 13px; }
.report__table th { font-weight: 700; font-size: 12px; padding: 6px 4px; border-top: 1px solid var(--ink); border-bottom: 1px solid var(--ink); background: var(--omr-tint); color: var(--omr); }
.report__table td { padding: 10px 4px; border-bottom: 1px solid var(--rule); vertical-align: middle; }
.report__table td:first-child { width: 56px; font-weight: 700; text-align: center; }
.report__table td:nth-child(2) { width: 92px; }
.axis-pick { font-weight: 700; }
.axis-pick b { font-family: var(--f-mono); margin-right: 4px; color: var(--gc, var(--ink)); }
.bar { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; }
.bar__track { height: 8px; background: var(--rule); position: relative; overflow: hidden; border-radius: 1px; }
.bar__fill { position: absolute; inset: 0 auto 0 0; background: var(--gc, var(--ink)); transform-origin: left; animation: grow .8s ease both; }
@keyframes grow { from { transform: scaleX(0); } }
.bar__num { font-family: var(--f-mono); font-size: 12px; font-variant-numeric: tabular-nums; width: 36px; text-align: right; }

.report__stamp {
  position: absolute; left: calc(50% + 46px); top: 276px;
  width: 58px; height: 58px; border: 2.5px solid var(--omr); border-radius: 50%;
  display: grid; place-content: center; text-align: center;
  color: var(--omr); font-family: var(--f-display); font-weight: 800; font-size: 13px; line-height: 1.15;
  transform: rotate(-14deg); opacity: .85;
}

.share { display: flex; flex-direction: column; gap: 8px; }
.share__row { display: flex; gap: 8px; }

.block { display: flex; flex-direction: column; }
.block__text { margin: 0; }
.block__text--lg { font-family: var(--f-display); font-weight: 700; font-size: 18px; line-height: 1.55; }
.block--split { display: grid; grid-template-columns: 1fr; gap: 18px; padding: 16px; border: 1px solid var(--rule); border-radius: 6px; }
@media (min-width: 420px) { .block--split { grid-template-columns: 1fr 1fr; } }
.block--split > div { min-width: 0; }
.block--dday { padding: 18px 16px; background: var(--omr-tint); border-radius: 6px; }

.checks { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.checks li { display: grid; grid-template-columns: 22px 1fr; gap: 6px; }
.checks li::before { content: "✓"; color: var(--omr); font-weight: 700; }

.rx { margin: 0; padding: 0; list-style: none; counter-reset: rx; display: flex; flex-direction: column; }
.rx li { counter-increment: rx; display: grid; grid-template-columns: 34px 1fr; gap: 8px; padding: 10px 0; border-bottom: 1px dashed var(--rule); }
.rx li::before {
  content: counter(rx); width: 24px; height: 24px; border-radius: 50%; border: 1.5px solid var(--omr);
  display: grid; place-items: center; font-family: var(--f-mono); font-size: 12px; color: var(--omr);
}

.mates { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
.mate {
  display: grid; grid-template-columns: 56px minmax(0, 1fr); grid-template-rows: auto auto auto; column-gap: 10px; align-items: center; text-align: left;
  padding: 10px; border: 1.5px solid var(--gc); border-radius: 6px; background: transparent; min-width: 0;
}
.mate img { grid-row: 1 / 4; margin: 0; }
.mate small { font-size: 11px; font-weight: 700; color: var(--muted); }
.mate b { font-family: var(--f-mono); font-size: 18px; color: var(--gc); }
.mate span { font-size: 13px; line-height: 1.35; }
.mate--bad { border-style: dashed; }

.coffee {
  padding: 20px 16px; border: 1.5px solid var(--ink); border-radius: 6px;
  display: flex; flex-direction: column; gap: 10px;
}
.coffee__title { margin: 0; font-family: var(--f-display); font-weight: 800; font-size: 19px; }
.coffee__text { margin: 0; font-size: 14px; color: var(--muted); }
.coffee__btns { display: flex; flex-wrap: wrap; gap: 8px; }
.coffee__btns .btn { flex: 1 1 120px; min-height: 46px; font-size: 14px; text-decoration: none; color: var(--ink); }
.coffee__btns .btn--primary { color: var(--sheet); }
.coffee__note { margin: 0; font-size: 12px; color: var(--muted); }

.gift { display: flex; flex-direction: column; gap: 12px; padding: 18px 16px; border: 1.5px solid var(--gc, var(--ink)); border-radius: 6px; }
.gift .section-label { margin: 0; }
.gift__title { margin: -6px 0 0; font-family: var(--f-display); font-weight: 800; font-size: 20px; line-height: 1.35; text-wrap: balance; }
.gift__list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.gift__list li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: center; padding: 12px 0; border-top: 1px dashed var(--rule); }
.gift__list li:first-child { border-top: 0; padding-top: 4px; }
.gift__name { font-weight: 700; }
.gift__why { grid-column: 1; font-size: 13px; color: var(--muted); line-height: 1.5; }
.gift__go {
  grid-column: 2; grid-row: 1 / 3; align-self: center;
  display: inline-flex; align-items: center; min-height: 40px; padding: 0 12px; border-radius: 6px;
  background: var(--gc, var(--ink)); color: var(--sheet); font-size: 13px; font-weight: 700; text-decoration: none; white-space: nowrap;
}
.gift__ask { flex: none; width: 100%; }
.gift__note { margin: 0; font-size: 11px; line-height: 1.5; color: var(--muted); }
.coffee.is-flash { animation: flash 1s ease; }
@keyframes flash { 30% { background: var(--omr-tint); } }

.result-actions { display: flex; }

/* ── 광고 ───────────────────────── */
.ad { display: flex; justify-content: center; }
.ad:empty { display: none; }
.ad__ph {
  display: grid; place-items: center; max-width: 100%;
  border: 1px dashed var(--rule); color: var(--muted); font-size: 12px; font-family: var(--f-mono);
}
.ad__label { display: block; font-size: 10px; color: var(--muted); text-align: center; margin-bottom: 2px; }

/* ── 기타 ───────────────────────── */
.foot { margin-top: 32px; padding-top: 16px; border-top: 1px solid var(--rule); font-size: 12px; color: var(--muted); text-align: center; }
.foot p { margin: 0 0 4px; }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
  max-width: calc(100% - 32px); padding: 10px 16px; border-radius: 6px;
  background: var(--ink); color: var(--sheet); font-size: 14px; z-index: 20;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
