:root{--bg:#F8F7F5;--card:#fff;--fg:#111827;--muted:#6B7280;--line:#E7E2DD;--accent:#F25C19;--accent-d:#C2410C;--soft:#FFF1E8}
*{box-sizing:border-box}body{margin:0;background:var(--bg);color:var(--fg);font:15px/1.6 'Noto Sans KR',system-ui,sans-serif}
.consent{background:var(--soft);border-bottom:1px solid #FBD5BF;padding:10px max(16px,env(safe-area-inset-left));font-size:14px;color:#7C2D12;text-align:center}
main{max-width:1320px;margin:0 auto;padding:32px max(16px,env(safe-area-inset-left)) 48px;display:flex;flex-direction:column;gap:24px}
.eyebrow{margin:0;color:var(--accent);font-weight:700;letter-spacing:.06em;font-size:13px}
h1{margin:4px 0;font-size:clamp(24px,4vw,36px);font-weight:800;text-wrap:balance}.sub{margin:0;color:var(--muted)}
.card{background:var(--card);border:1px solid var(--line);border-radius:16px;padding:20px;display:flex;flex-direction:column;gap:14px}

.doc.on{border-color:var(--accent);background:var(--soft);color:var(--accent-d)}
.row{display:flex;flex-wrap:wrap;gap:12px;align-items:center;justify-content:space-between}
.seg{display:inline-flex;border:1px solid var(--line);border-radius:10px;overflow:hidden}
.seg input{position:absolute;opacity:0}.seg span{display:block;padding:8px 14px;cursor:pointer}
.seg input:checked+span{background:var(--fg);color:#fff}.check{color:var(--muted);display:flex;gap:6px;align-items:center}
input[type=text]{border:1px solid var(--line);border-radius:10px;padding:10px 12px;font:inherit}
button[type=submit]{background:var(--accent);color:#fff;border:0;border-radius:10px;padding:12px;font:inherit;font-weight:700;cursor:pointer}
button[disabled]{opacity:.5;cursor:default}.status{margin:0;min-height:1.4em;color:var(--muted)}.status.err{color:#B91C1C}
.pane{background:var(--card);border:1px solid var(--line);border-radius:16px;padding:12px;min-width:0}
.tabs{display:flex;gap:6px;margin-bottom:8px}.tabs button{border:1px solid var(--line);background:#fff;border-radius:8px;padding:6px 10px;font:inherit;cursor:pointer}
.tabs button.on{background:var(--fg);color:#fff}.view{max-height:70vh;overflow:auto}
pre{margin:0;white-space:pre-wrap;word-break:break-word;font:13px/1.55 ui-monospace,Menlo,monospace}
.view table{border-collapse:collapse;margin:0 0 12px;font-size:13px}.view td,.view th{border:1px solid var(--line);padding:4px 6px;vertical-align:top}
footer{text-align:center;color:var(--muted);font-size:13px;padding:0 16px 32px}
.work{display:grid;grid-template-columns:minmax(0,1.1fr) minmax(0,1fr);gap:16px;align-items:start}
@media(max-width:860px){.work{grid-template-columns:1fr}}
.side{display:flex;flex-direction:column;gap:16px;min-width:0}
.doc{position:sticky;top:16px;display:flex;align-items:center;justify-content:center;height:calc(100vh - 32px);min-height:320px;max-height:960px;border:2px dashed var(--line);cursor:pointer;overflow:hidden}
.doc.has{border-style:solid}.doc .ph{color:var(--muted);text-align:center;padding:24px}
.imgwrap{position:relative;display:inline-block;max-width:100%;max-height:100%}
.imgwrap img{display:block;max-width:100%;max-height:calc(min(100vh - 32px, 960px) - 28px);width:auto;height:auto;border-radius:8px}
.imgwrap canvas{position:absolute;inset:0;width:100%;height:100%;pointer-events:none}
@media(max-width:860px){.doc{position:static;height:auto;min-height:220px}.imgwrap img{max-height:70vh}}
.pager{display:flex;gap:10px;align-items:center;justify-content:center;color:var(--muted)}.pager label{display:flex;gap:6px;align-items:center}.pager button{width:40px;height:40px;display:grid;place-items:center;border:1px solid var(--line);border-radius:10px;background:var(--card);color:var(--fg);font:inherit;font-size:22px;line-height:1;cursor:pointer}.pager button[disabled]{opacity:.35;cursor:default}#page{width:70px;text-align:center;border:1px solid var(--line);border-radius:8px;padding:6px 8px;font:inherit}
.out .view{max-height:calc(100vh - 360px);min-height:240px}
.colhead{display:flex;justify-content:space-between;align-items:center;gap:12px;min-height:40px}
.colhead .pager button{width:32px;height:32px;font-size:18px}.colhead #page{width:56px;padding:3px 6px}
[hidden]{display:none!important}
.beta{font-style:normal;font-size:11px;font-weight:700;color:var(--accent);margin-left:2px}
.seg input:checked+span .beta{color:#FDBA8C}
.kie{display:flex;flex-direction:column;gap:8px}.hint{margin:0;color:var(--muted);font-size:13px}
.chips{display:flex;flex-wrap:wrap;gap:6px}.chips button{border:1px solid var(--line);background:var(--card);border-radius:999px;padding:5px 12px;font:inherit;font-size:13px;cursor:pointer}
.chips button:hover{border-color:var(--accent);color:var(--accent-d)}
.kv{border-collapse:collapse;width:100%;font-size:14px}.kv th{text-align:left;color:var(--muted);font-weight:500;width:34%;white-space:nowrap}
.kv th,.kv td{border-bottom:1px solid var(--line);padding:6px 8px;vertical-align:top}
.doc{position:relative}.clear{position:absolute;top:12px;right:12px;width:36px;height:36px;display:grid;place-items:center;border:1px solid var(--line);border-radius:10px;background:var(--card);color:var(--muted);cursor:pointer;z-index:2}
.clear:hover{color:#B91C1C;border-color:#FCA5A5}
@media(min-width:861px){.doc{position:sticky}}

.pg{margin:0 0 20px}.pgh{margin:0 0 6px;padding:0 0 4px;border-bottom:1px solid var(--line);font-weight:700;color:var(--accent)}

.bar{position:sticky;top:0;z-index:5;padding:12px 16px;gap:8px;box-shadow:0 1px 0 var(--line)}
.bar-row{display:flex;flex-wrap:wrap;gap:12px;align-items:center}
.bar-row #question{flex:1;min-width:220px}.bar-row #go{margin-left:auto;padding:10px 28px}
.bar .status{min-height:0}.bar .status:empty{display:none}
.col{display:flex;flex-direction:column;gap:10px;min-width:0}
.colh{margin:0;font-weight:800;font-size:15px;color:var(--muted);letter-spacing:.04em}
@media(min-width:861px){.doc{top:96px;height:calc(100vh - 200px)}}
.imgwrap img{max-height:calc(100vh - 228px)}
.out .view{max-height:calc(100vh - 250px)}
.empty{margin:0;color:var(--muted);display:grid;place-items:center;min-height:320px;height:calc(100vh - 200px);max-height:960px;text-align:center}
@media(max-width:860px){.doc{height:auto}.empty{height:auto;min-height:160px}.bar{position:static}}

/* result actions + preview (Markdown, tables, KaTeX) */
.tabs{flex-wrap:wrap;align-items:center}.tabs .acts{margin-left:auto;display:flex;gap:6px}.tabs .acts button{font-size:13px;padding:5px 9px}
#vTable{font-size:14px;line-height:1.7;overflow-wrap:anywhere}#vTable p{margin:0 0 10px}#vTable p.li{margin:0 0 4px;padding-left:4px}
#vTable h3,#vTable h4,#vTable h5,#vTable h6{margin:14px 0 8px;line-height:1.4}#vTable h3{font-size:18px}#vTable h4{font-size:16px}#vTable h5,#vTable h6{font-size:15px}
#vTable .tw{overflow-x:auto;margin:0 0 12px}#vTable .tw table{margin:0}#vTable th{background:#f5f6f8}
#vTable .katex-display{overflow-x:auto;overflow-y:hidden;margin:8px 0;padding:2px 0}#vTable .katex{font-size:1.08em}
#vTable .fig{color:#9aa0a6;font-size:13px}
