/* 기출회독 — OMR 답안지와 컴퓨터용 사인펜에서 가져온 화면.
   흰 종이, 답안지 인쇄선의 분홍, 사인펜 먹색으로 칠하는 타원 마킹, 채점은 붉은 색연필과 파란 볼펜. */
:root {
  --paper: #f6f5f8;
  --surface: #ffffff;
  --ink: #1b1d26;
  --muted: #5d6275;
  --line: #d9dbe4;
  --chip: #eceef5;
  --omr: #e39bae;          /* 답안지 인쇄선 */
  --omr-soft: #fdf0f3;
  --accent: #b3264f;       /* 사인펜 뚜껑·채점 색연필 */
  --accent-ink: #ffffff;
  --accent-soft: #fbe6ec;
  --ok: #1d55b5;           /* 정답 표시는 파란 볼펜 */
  --ok-soft: #e6eefb;
  --flag: #a8650a;
  --flag-soft: #fdf1dc;
  --shadow: 0 1px 2px rgb(27 29 38 / .06), 0 6px 20px rgb(27 29 38 / .06);
  --font: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, "D2Coding", monospace;
  --tabs-h: 58px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #121319; --surface: #1c1e27; --ink: #ecedf3; --muted: #a3a7ba; --line: #343744; --chip: #272a37;
    --omr: #8f4a5c; --omr-soft: #2a1a20; --accent: #f0729a; --accent-ink: #1b0a11; --accent-soft: #3b1c28;
    --ok: #7fb0ff; --ok-soft: #17263f; --flag: #f1b453; --flag-soft: #33270f;
    --shadow: 0 1px 2px rgb(0 0 0 / .4), 0 6px 20px rgb(0 0 0 / .3);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: var(--font); font-size: 16px; line-height: 1.6; word-break: keep-all; overflow-wrap: anywhere;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin: 0; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

#app { max-width: 760px; margin: 0 auto; padding: 20px max(16px, env(safe-area-inset-left)) calc(var(--tabs-h) + 40px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-right)); display: flex; flex-direction: column; gap: 22px; }
body.solving #app { max-width: 1120px; padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
.boot { color: var(--muted); text-align: center; padding: 80px 0; }

/* ── 공통 부품 ── */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 18px; box-shadow: var(--shadow); }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.grow { flex: 1 1 0; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: 13.5px; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.sect { display: flex; flex-direction: column; gap: 12px; }
.sect > h2 { font-size: 18px; font-weight: 700; display: flex; align-items: baseline; gap: 8px; }
.sect > h2 small { font-size: 13px; font-weight: 500; color: var(--muted); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 16px;
  border-radius: 10px; border: 1px solid var(--line); background: var(--surface); font-weight: 600; font-size: 15px;
  text-decoration: none; color: var(--ink); white-space: nowrap; transition: transform .08s, background .15s;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.ink { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.btn.ghost { background: transparent; }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 14px; border-radius: 8px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .45; cursor: default; }
.btn.danger { color: var(--accent); }

.chip { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; font-weight: 600; padding: 2px 9px; border-radius: 999px; background: var(--chip); color: var(--muted); white-space: nowrap; }
.chip.accent { background: var(--accent-soft); color: var(--accent); }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.flag { background: var(--flag-soft); color: var(--flag); }

.seg { display: inline-flex; background: var(--chip); border-radius: 10px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; min-height: 38px; padding: 0 14px; border-radius: 8px; font-weight: 600; font-size: 14.5px; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgb(0 0 0 / .14); }

.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 600; }
.field input, .field textarea, .field select { min-height: 46px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); font-weight: 400; font-size: 16px; }
.field textarea { min-height: 96px; resize: vertical; }
.notice { background: var(--omr-soft); border: 1px dashed var(--omr); border-radius: 10px; padding: 10px 12px; font-size: 13.5px; color: var(--muted); }
.error { color: var(--accent); font-size: 14px; font-weight: 600; }

/* ── 머리 ── */
.top { display: flex; align-items: center; gap: 10px; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 800; font-size: 19px; letter-spacing: -.01em; border: 0; background: none; padding: 0; }
.brand .pen { width: 26px; height: 26px; flex: none; }
.hero { position: relative; overflow: hidden; background: var(--ink); color: var(--paper); border-radius: 18px; padding: 24px 22px 22px; display: flex; flex-direction: column; gap: 10px; }
.hero h1 { font-size: clamp(23px, 6vw, 30px); line-height: 1.3; font-weight: 800; text-wrap: balance; max-width: 15em; }
.hero h1 em { font-style: normal; color: #ff9db9; }
.hero p { opacity: .78; font-size: 14.5px; max-width: 30em; }
/* 답안지 타원 줄무늬 */
.hero .marks { position: absolute; right: -12px; top: 14px; display: grid; grid-template-columns: repeat(4, 16px); gap: 9px 10px; transform: rotate(-8deg); opacity: .9; }
.hero .marks i { width: 16px; height: 24px; border-radius: 50%; border: 1.5px solid #e39bae; }
.hero .marks i.on { background: #fbfbfd; border-color: #fbfbfd; }
@media (max-width: 480px) { .hero .marks { opacity: .35; } }

/* ── 목록 ── */
.list { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; box-shadow: var(--shadow); }
.item { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: 0; }
.item .title { font-weight: 650; }
.item .acts { display: flex; gap: 6px; flex: none; }
button.item { width: 100%; text-align: left; background: none; border-width: 0 0 1px; border-color: var(--line); border-style: solid; }
button.item:hover { background: var(--omr-soft); }
.resume { border-left: 5px solid var(--accent); }
.bar { height: 6px; border-radius: 3px; background: var(--chip); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }

/* ── 풀이 화면 ── */
.solve-top { display: flex; align-items: center; gap: 10px; }
.solve-top h1 { font-size: 15px; font-weight: 650; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.net { font-size: 12.5px; color: var(--muted); white-space: nowrap; display: inline-flex; align-items: center; gap: 5px; }
.net::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.net.off { color: var(--flag); } .net.off::before { background: var(--flag); }
.solve { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; align-items: start; }
.solve .side { display: none; }
@media (min-width: 1000px) { .solve { grid-template-columns: minmax(0, 1fr) 300px; } .solve .side { display: block; position: sticky; top: 16px; } }
.qcard { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); overflow: hidden; }
.qhead { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--omr); background: var(--omr-soft); flex-wrap: wrap; }
.qno { font-family: var(--mono); font-weight: 700; font-size: 15px; }
.qno b { font-size: 22px; color: var(--accent); }
.qbody { padding: 20px 18px 6px; font-size: 17.5px; line-height: 1.65; font-weight: 500; }
.rich p { margin: 0 0 .6em; } .rich p:last-child { margin-bottom: 0; }
.rich pre { background: var(--chip); border-radius: 10px; padding: 12px 14px; overflow-x: auto; font-family: var(--mono); font-size: 14px; line-height: 1.55; font-weight: 400; margin: 10px 0; white-space: pre; word-break: normal; overflow-wrap: normal; }
.rich code { font-family: var(--mono); font-size: .92em; }
.rich :not(pre) > code { background: var(--chip); padding: 1px 5px; border-radius: 5px; }
.rich table { border-collapse: collapse; margin: 10px 0; font-size: 15px; font-weight: 400; display: block; overflow-x: auto; max-width: 100%; }
.rich th, .rich td { border: 1px solid var(--line); padding: 5px 11px; text-align: center; white-space: nowrap; }
.rich th { background: var(--chip); }
.rich img, .qimg { max-width: 100%; height: auto; border-radius: 8px; }
.rich .katex { font-size: 1.08em; }
.choices { list-style: none; margin: 0; padding: 10px 10px 14px; display: flex; flex-direction: column; gap: 6px; }
.choice { width: 100%; display: flex; align-items: flex-start; gap: 14px; text-align: left; background: none; border: 1.5px solid transparent; border-radius: 12px; padding: 11px 10px; font-size: 16.5px; line-height: 1.55; min-height: 52px; }
.choice:hover:not(:disabled) { background: var(--omr-soft); }
.choice:disabled { cursor: default; color: inherit; }
/* 타원 마킹 칸 */
.bubble { flex: none; width: 24px; height: 32px; border-radius: 50%; border: 1.5px solid var(--omr); color: var(--omr); display: grid; place-items: center; font-family: var(--mono); font-size: 13px; font-weight: 700; margin-top: -2px; transition: background .12s, transform .12s; }
.choice[aria-checked="true"] { border-color: var(--ink); background: var(--surface); }
.choice[aria-checked="true"] .bubble { background: var(--ink); border-color: var(--ink); color: var(--ink); transform: rotate(-4deg) scale(1.06); border-radius: 46% 54% 50% 50% / 52% 48% 52% 48%; }
.choice.right { border-color: var(--ok); background: var(--ok-soft); }
.choice.right .bubble { border-color: var(--ok); color: var(--ok); }
.choice.right[aria-checked="true"] .bubble { background: var(--ok); color: var(--ok); }
.choice.miss { border-color: var(--accent); background: var(--accent-soft); }
.choice.miss .bubble { background: var(--accent); border-color: var(--accent); color: var(--accent); }
.choice.miss .ctext { text-decoration: line-through; text-decoration-color: var(--accent); text-decoration-thickness: 1.5px; }
.choice .mark { margin-left: auto; flex: none; font-size: 12.5px; font-weight: 700; padding-left: 6px; }
.choice.right .mark { color: var(--ok); } .choice.miss .mark { color: var(--accent); }
.ctext { min-width: 0; flex: 1; }
.expl { margin: 0 16px 16px; border-radius: 12px; padding: 14px 16px; background: var(--chip); font-size: 15.5px; display: flex; flex-direction: column; gap: 6px; }
.expl .verdict { font-weight: 800; font-size: 16px; }
.expl .verdict.good { color: var(--ok); } .expl .verdict.bad { color: var(--accent); }
.qfoot { display: flex; align-items: center; gap: 8px; padding: 0 16px 16px; flex-wrap: wrap; }
.linkbtn { border: 0; background: none; padding: 6px 4px; color: var(--muted); font-size: 13.5px; text-decoration: underline; text-underline-offset: 3px; }
.linkbtn.on { color: var(--flag); font-weight: 700; }

/* 하단 조작 띠: 이전 · 번호표/남은 시간 · 다음 */
.dock { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(10px); border-top: 1px solid var(--line); padding: 10px max(12px, env(safe-area-inset-left)) calc(10px + env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-right)); }
.dock-in { max-width: 1088px; margin: 0 auto; display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: center; }
.dock .mid { display: flex; flex-direction: column; align-items: center; justify-content: center; min-width: 116px; min-height: 48px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); padding: 2px 12px; line-height: 1.25; }
.dock .mid .t { font-family: var(--mono); font-weight: 700; font-size: 17px; font-variant-numeric: tabular-nums; }
.dock .mid .t.hurry { color: var(--accent); }
.dock .mid .c { font-size: 11.5px; color: var(--muted); }
.dock .btn { min-height: 48px; }
.progress { position: fixed; left: 0; right: 0; top: 0; height: 3px; background: transparent; z-index: 30; }
.progress i { display: block; height: 100%; background: var(--accent); transition: width .2s; }

/* 문항 번호표(OMR) */
.omr { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 6px; }
.omr button { position: relative; aspect-ratio: 1 / 1.05; border-radius: 9px; border: 1.5px solid var(--omr); background: var(--surface); font-family: var(--mono); font-weight: 700; font-size: 13.5px; color: var(--omr); padding: 0; }
.omr button.done { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.omr button.o { background: var(--ok); border-color: var(--ok); color: #fff; }
.omr button.x { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.omr button.cur { outline: 2.5px solid var(--accent); outline-offset: 2px; }
.omr button.flag::after { content: ""; position: absolute; top: -4px; right: -4px; width: 11px; height: 11px; border-radius: 50%; background: var(--flag); border: 2px solid var(--surface); }
.omr-group { display: flex; flex-direction: column; gap: 8px; }
.omr-group h3 { font-size: 13px; color: var(--muted); font-weight: 650; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }
.legend i { display: inline-block; width: 11px; height: 11px; border-radius: 3px; border: 1.5px solid var(--omr); margin-right: 5px; vertical-align: -1px; }
.legend i.done { background: var(--ink); border-color: var(--ink); } .legend i.fl { background: var(--flag); border-color: var(--flag); border-radius: 50%; }

/* ── 결과 ── */
.result-head { display: grid; grid-template-columns: 1fr auto; gap: 16px; align-items: center; }
.bigscore { font-family: var(--mono); font-size: clamp(46px, 14vw, 68px); font-weight: 700; line-height: 1; letter-spacing: -.03em; }
.bigscore small { font-size: .32em; font-weight: 600; color: var(--muted); letter-spacing: 0; margin-left: 4px; }
/* 합격·불합격 도장 */
.stamp { width: 104px; height: 104px; border-radius: 50%; border: 4px double currentColor; display: grid; place-items: center; text-align: center; font-weight: 900; font-size: 24px; line-height: 1.1; transform: rotate(-12deg); color: var(--accent); letter-spacing: .04em; }
.stamp.pass { color: var(--ok); }
.stamp small { display: block; font-size: 10.5px; font-weight: 700; letter-spacing: .12em; margin-top: 3px; }
.subj { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: center; }
.subj .nm { font-weight: 600; font-size: 14.5px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.subj .sc { font-family: var(--mono); font-weight: 700; font-variant-numeric: tabular-nums; }
.meter { grid-column: 1 / -1; position: relative; height: 10px; border-radius: 5px; background: var(--chip); }
.meter > i { position: absolute; inset: 0 auto 0 0; border-radius: 5px; background: var(--ok); }
.meter.fail > i { background: var(--accent); }
.meter > b { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--ink); opacity: .55; }
.review { border-bottom: 1px solid var(--line); }
.review:last-child { border-bottom: 0; }
.review > summary { list-style: none; display: flex; gap: 10px; align-items: flex-start; padding: 13px 16px; cursor: pointer; }
.review > summary::-webkit-details-marker { display: none; }
.review .ox { flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 14px; }
.review .ox.o { color: var(--ok); border: 2px solid var(--ok); }
.review .ox.x { color: var(--accent); position: relative; }
.review .ox.x::before, .review .ox.x::after { content: ""; position: absolute; width: 22px; height: 2.5px; background: var(--accent); border-radius: 2px; transform: rotate(-55deg); }
.review .ox.x::after { display: none; }
.review .ox.n { color: var(--muted); border: 2px dashed var(--line); }
.review .sum { min-width: 0; flex: 1; font-size: 15px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.review[open] .sum { display: none; }
.review .full { padding: 0 6px 6px; }

/* ── 탭 · 대화상자 · 알림 ── */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: grid; grid-template-columns: repeat(4, 1fr); background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(10px); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabs button { height: var(--tabs-h); border: 0; background: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11.5px; font-weight: 600; color: var(--muted); position: relative; }
.tabs button svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabs button[aria-current="page"] { color: var(--accent); }
.tabs .badge { position: absolute; top: 7px; left: calc(50% + 6px); min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; background: var(--accent); color: var(--accent-ink); font-size: 10.5px; display: grid; place-items: center; font-family: var(--mono); }
dialog { border: 0; border-radius: 18px; padding: 0; background: var(--surface); color: var(--ink); width: min(560px, calc(100vw - 24px)); max-height: min(86vh, 760px); box-shadow: 0 20px 60px rgb(0 0 0 / .35); }
dialog::backdrop { background: rgb(15 16 22 / .55); }
.dlg { display: flex; flex-direction: column; max-height: inherit; }
.dlg > header { display: flex; align-items: center; gap: 10px; padding: 16px 18px 10px; }
.dlg > header h2 { font-size: 18px; flex: 1; }
.dlg > .body { padding: 6px 18px 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.dlg > footer { display: flex; gap: 8px; padding: 12px 18px calc(16px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.dlg > footer .btn { flex: 1; }
.x { border: 0; background: var(--chip); width: 34px; height: 34px; border-radius: 50%; font-size: 17px; line-height: 1; color: var(--muted); }
.toast { position: fixed; left: 50%; bottom: calc(var(--tabs-h) + 26px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 999px; font-size: 14px; font-weight: 600; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 100; max-width: calc(100vw - 32px); text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
body.solving .toast { bottom: calc(96px + env(safe-area-inset-bottom)); }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
