:root{
  --navy:#1f4e9c; --navy-d:#163a75; --ink:#14171c; --mute:#5b6472; --line:#d7dce4;
  --bg:#eef1f5; --panel:#ffffff; --red:#c62828;
  --sans:'Noto Sans KR','Noto Sans CJK KR','Apple SD Gothic Neo','Malgun Gothic',sans-serif;
  --serif:'Noto Serif KR','Noto Serif CJK KR','Batang',serif;
  --math:'Times New Roman','STIX Two Text',serif;
}
*{box-sizing:border-box}
html,body{margin:0;height:100%}
body{font-family:var(--sans);color:var(--ink);background:var(--bg);-webkit-font-smoothing:antialiased}
button{font-family:inherit;cursor:pointer}

/* ---------- app shell ---------- */
.app{display:flex;min-height:100vh}
.panel{width:330px;flex:0 0 330px;background:var(--panel);border-right:1px solid var(--line);padding:20px 18px 28px;position:sticky;top:0;height:100vh;overflow-y:auto}
.brand{padding-bottom:14px;border-bottom:2px solid var(--navy);margin-bottom:16px}
.brand-t{font-size:19px;font-weight:700;color:var(--navy);letter-spacing:-.02em}
.brand-s{font-size:13px;color:var(--mute);margin-top:2px}
.grp{margin-bottom:20px}
.lbl{font-size:14px;font-weight:700;margin-bottom:8px;display:flex;justify-content:space-between;align-items:center}
.lbl.sm{font-size:13px;margin:12px 0 6px}
.cnt{font-size:12px;font-weight:500;color:#fff;background:var(--navy);border-radius:10px;padding:1px 9px}
.nums{display:grid;grid-template-columns:repeat(5,1fr);gap:6px}
.nums button{height:40px;border:1.5px solid var(--line);background:#fff;border-radius:7px;font-size:15px;font-weight:600;color:var(--ink);position:relative;transition:background .12s,border-color .12s,color .12s}
.nums button small{position:absolute;right:3px;top:1px;font-size:9px;font-weight:500;color:var(--mute)}
.nums button:hover{border-color:var(--navy)}
.nums button.on{background:var(--navy);border-color:var(--navy);color:#fff}
.nums button.on small{color:#cfdaf0}
.nums button:focus-visible,.seg button:focus-visible,.quick button:focus-visible,.print:focus-visible{outline:3px solid #9db8e8;outline-offset:1px}
.quick{display:flex;flex-wrap:wrap;gap:6px;margin-top:8px}
.quick button{flex:1 1 auto;font-size:12.5px;padding:6px 8px;border:1px solid var(--line);background:#f7f8fa;border-radius:6px;color:var(--ink)}
.quick button:hover{background:#e9eef7}
.txt{display:block;font-size:13px;color:var(--mute);margin-top:10px}
.txt .opt{font-size:11.5px}
.txt input{display:block;width:100%;margin-top:4px;font:inherit;font-size:14px;color:var(--ink);padding:8px 10px;border:1.5px solid var(--line);border-radius:7px;background:#fff}
.txt input:focus{outline:none;border-color:var(--navy)}
.seg{display:flex;border:1.5px solid var(--line);border-radius:8px;overflow:hidden}
.seg button{flex:1;border:0;background:#fff;padding:9px 6px;font-size:14px;font-weight:700;color:var(--mute);display:flex;flex-direction:column;align-items:center;gap:1px}
.seg button small{font-size:11px;font-weight:500}
.seg button+button{border-left:1.5px solid var(--line)}
.seg button.on{background:var(--navy);color:#fff}
.seg.small button{font-size:12.5px;font-weight:600;padding:7px 4px}
.act{border-top:1px solid var(--line);padding-top:16px}
.info{font-size:13px;color:var(--mute);margin-bottom:10px}
.info b{color:var(--ink)}
.print{width:100%;height:46px;border:0;border-radius:8px;background:var(--navy);color:#fff;font-size:16px;font-weight:700}
.print:hover{background:var(--navy-d)}
.print:disabled{background:#a9b4c6;cursor:not-allowed}
.newtab{display:block;text-align:center;font-size:12.5px;color:var(--navy);margin-top:8px}
.hint{font-size:11.5px;color:var(--mute);line-height:1.5;margin:10px 0 0}

.stage{flex:1;min-width:0;padding:28px 24px 60px;overflow-x:auto}
.pages{display:flex;flex-direction:column;align-items:center;gap:22px;transform-origin:top center}
.empty{margin-top:15vh;text-align:center;color:var(--mute);font-size:15px;line-height:1.7}
.empty b{display:block;font-size:18px;color:var(--ink);margin-bottom:4px}

/* ---------- exam sheet ---------- */
.page{width:210mm;height:297mm;background:#fff;box-shadow:0 2px 10px rgba(20,30,50,.14);padding:11mm 12mm 9mm;display:flex;flex-direction:column;font-family:var(--serif);color:#111;position:relative;overflow:hidden}
.ph{border:1.6px solid #111;display:grid;grid-template-columns:1fr auto;margin-bottom:4mm}
.ph-t{padding:3mm 4mm;border-right:1.6px solid #111}
.ph-t h1{font-family:var(--sans);font-size:16pt;font-weight:700;margin:0;letter-spacing:-.02em;line-height:1.3}
.ph-t .sub{font-family:var(--sans);font-size:9pt;color:#333;margin-top:1mm}
.ph-t .ver{display:inline-block;font-size:8.5pt;font-weight:700;border:1px solid currentColor;border-radius:3px;padding:0 5px;margin-left:6px;vertical-align:2px}
.ph-t .ver.t{color:var(--red)}
.ph-f{display:grid;grid-template-columns:auto 34mm;font-family:var(--sans);font-size:9.5pt}
.ph-f div{border-bottom:1px solid #111;padding:1.3mm 3mm;display:flex;align-items:center}
.ph-f div:nth-child(odd){background:#f1f3f6;border-right:1px solid #111;font-weight:700;justify-content:center}
.ph-f div:nth-last-child(-n+2){border-bottom:0}
.ph-slim{display:flex;justify-content:space-between;align-items:flex-end;border-bottom:1.6px solid #111;padding-bottom:1.5mm;margin-bottom:4mm;font-family:var(--sans);font-size:9pt}
.ph-slim b{font-size:10.5pt}
.body{flex:1;min-height:0;display:grid;grid-template-columns:1fr 1fr;grid-template-rows:1fr 1fr;grid-auto-flow:column;column-gap:0}
.cell{min-height:0;overflow:hidden;padding:1mm 5mm 2mm 0;position:relative;font-size:calc(10.5pt * var(--s,1));line-height:1.6}
.cell.r{padding:1mm 0 2mm 5mm}
.colline{position:absolute;top:0;bottom:0;left:50%;border-left:1px solid #111}
.body{position:relative}
.cell.r2{border-top:0}
.pf{font-family:var(--sans);font-size:8.5pt;text-align:center;color:#333;padding-top:2mm}

.q{display:flex;gap:1.6mm}
.num{font-family:var(--sans);font-weight:700;font-size:1.22em;line-height:1.35;min-width:7mm;white-space:nowrap}
.num .org{display:block;font-size:.55em;font-weight:500;color:#666;margin-top:-.2em}
.qt{flex:1;text-align:justify;word-break:keep-all;overflow-wrap:break-word}
.pts{white-space:nowrap;font-size:.95em}
.essay{font-family:var(--sans);font-size:.82em;color:#333;margin-bottom:.5mm}
.cell i{font-family:var(--math);font-size:1.09em}
.ov{text-decoration:overline}
.m{white-space:nowrap}
.fr{display:inline-flex;flex-direction:column;vertical-align:middle;text-align:center;font-size:.9em;line-height:1.15;margin:0 .12em}
.fr>span:first-child{border-bottom:1px solid #111;padding:0 .15em}
.fig{display:flex;justify-content:center;margin:2mm 0 1.5mm}
.fig svg{display:block;width:auto;max-width:78%;height:calc(var(--fh,40mm) * var(--s,1))}
.ch{display:grid;gap:1.2mm 4mm;margin:2mm 0 0 8.6mm;align-items:center}
.ch>div{white-space:nowrap}
.ch .cor{color:var(--red);font-weight:700}
.ch .cor .circ{display:inline-block;border-radius:50%;box-shadow:0 0 0 1.4px var(--red);line-height:1;padding:0 .02em;margin-right:.15em}
.bogi{border:1.2px solid #111;padding:1.5mm 3mm;margin:2mm 0 1mm 8.6mm}
.bt{text-align:center;font-weight:700}
.bl{padding-left:1.5em;text-indent:-1.5em;word-break:keep-all}
.blank{display:inline-block;width:1.4em;height:1.1em;border:1px solid #111;vertical-align:middle}
.sol{border:1.2px solid var(--navy);border-radius:4px;padding:1.4mm 2.6mm;margin:2mm 0 0 8.6mm;background:#f6f8fd;font-size:.88em;line-height:1.5}
.solh{font-family:var(--sans);font-weight:700;color:var(--navy);font-size:.92em}
.st{word-break:keep-all}
.ans{text-align:right;font-weight:700;color:var(--red);font-family:var(--sans)}
.ans .fr>span:first-child{border-color:var(--red)}
.work{margin:3mm 0 0 8.6mm;font-family:var(--sans);font-size:.78em;color:#888}
.essaybox{margin:3mm 0 0 8.6mm;border:1px solid #999;border-radius:3px;min-height:28mm;padding:1.5mm 2.5mm;font-family:var(--sans);font-size:.78em;color:#888}
.essaybox.t{display:none}

.akey h2{font-family:var(--sans);color:var(--navy);font-size:14pt;margin:2mm 0 4mm}
.akey .grid{display:grid;grid-template-columns:repeat(4,1fr);border-top:1.4px solid #111;border-left:1px solid #bbb}
.akey .grid>div{border-right:1px solid #bbb;border-bottom:1px solid #bbb;padding:2.2mm 3mm;font-size:10.5pt;display:flex;gap:2mm;align-items:center}
.akey .grid b{font-family:var(--sans);min-width:12mm}
.akey .grid small{font-family:var(--sans);color:#777;font-size:8pt}
.akey i{font-family:var(--math)}

/* ---------- responsive ---------- */
@media (max-width:900px){
  .app{flex-direction:column}
  .panel{position:static;width:auto;flex:none;height:auto;border-right:0;border-bottom:1px solid var(--line)}
  .stage{padding:16px 8px 40px}
}

/* ---------- print ---------- */
@page{size:A4;margin:0}
@media print{
  html,body{background:#fff;height:auto}
  .panel{display:none!important}
  .app{display:block}
  .stage{padding:0;overflow:visible}
  .pages{gap:0;zoom:1!important;transform:none!important}
  .page{box-shadow:none;break-after:page;page-break-after:always;-webkit-print-color-adjust:exact;print-color-adjust:exact}
  .page:last-child{break-after:auto;page-break-after:auto}
}

/* ---------- output kind checkboxes ---------- */
.chk{display:flex;gap:10px;align-items:flex-start;padding:9px 10px;border:1.5px solid var(--line);border-radius:8px;margin-bottom:6px;cursor:pointer}
.chk:has(input:checked){border-color:var(--navy);background:#f3f6fc}
.chk input{width:18px;height:18px;margin:2px 0 0;accent-color:var(--navy);flex:none}
.chk b{display:block;font-size:14px}
.chk small{display:block;font-size:11.5px;color:var(--mute);margin-top:1px;line-height:1.4}

/* ---------- 오답 노트 page ---------- */
.nbody{flex:1;min-height:0;display:grid;grid-template-rows:1fr 1fr;gap:4mm}
.nrow{min-height:0;display:grid;grid-template-columns:1fr 1fr;border:1.4px solid #111;border-radius:2px}
.nrow.empty-row{border:0}
.nl,.nr{min-height:0;display:flex;flex-direction:column;padding:3mm 4mm;overflow:hidden}
.nl{border-right:1px solid #111}
.ntag{font-family:var(--sans);font-size:9pt;font-weight:700;color:var(--navy);margin-bottom:2mm;flex:none}
.ntag.t{color:var(--red)}
.nimg{flex:1;min-height:0;display:flex;align-items:flex-start;justify-content:flex-start}
.nimg img{max-width:100%;max-height:100%;width:auto;height:auto;object-fit:contain;object-position:left top;display:block}
.nl .nimg img{width:100%;height:auto}
.nvar{flex:none;font-family:var(--sans);font-size:9pt;margin-top:2mm;padding-top:1.5mm;border-top:1px dashed #999;color:#333}
.nvar b{color:var(--red)}
.nvar i{font-family:var(--math)}
.why{display:grid;grid-template-columns:1fr 1fr;gap:1.4mm 3mm;font-family:var(--sans);font-size:9pt;margin-bottom:3mm;flex:none}
.why span{display:flex;align-items:center;gap:1.6mm}
.cb{display:inline-block;width:3.2mm;height:3.2mm;border:1px solid #111;flex:none}
.mine{display:flex;gap:5mm;font-family:var(--sans);font-size:9pt;margin-bottom:3.5mm;flex:none}
.mine span{flex:1;display:flex;align-items:flex-end;gap:1.5mm}
.ul{flex:1;border-bottom:1px solid #111;height:4mm}
.lines{flex:1;min-height:0;background:repeating-linear-gradient(to bottom,transparent 0,transparent 7.4mm,#c9ced6 7.4mm,#c9ced6 7.7mm);margin-bottom:3mm;-webkit-print-color-adjust:exact;print-color-adjust:exact}
.lines.s{flex:0 0 16mm;margin-bottom:0}
.akey .grid{grid-template-columns:repeat(3,1fr)}
.akey .grid span{font-family:var(--serif)}
