/* decal 화면 — 밝은 바탕 + 검은 글자. 세 칸은 따로 스크롤됩니다. */
:root {
  --bg: #f5f6f8; --panel: #ffffff; --line: #dfe2e7; --text: #111418; --dim: #5b6270;
  --accent: #1f5fd6; --accent-bg: #e8f0fe; --ok: #1a7f37; --bad: #c62828; --user: #eef3ff;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font-family: "Noto Sans KR", "Malgun Gothic", sans-serif; font-size: 15px; color: var(--text); background: var(--bg); }
#app { display: grid; grid-template-columns: 420px 1fr; height: 100vh; }
.pane { overflow-y: auto; min-height: 0; }
#left { background: var(--panel); border-right: 1px solid var(--line); padding: 14px; display: flex; flex-direction: column; overflow: hidden; }
.brand { font-size: 22px; font-weight: 700; margin-bottom: 14px; letter-spacing: .5px; }
.side-title { font-weight: 700; margin: 16px 0 6px; }
.muted { color: var(--dim); } .small { font-size: 13px; }

#center { display: flex; flex-direction: column; overflow: hidden; }
#chat { flex: 1; overflow-y: auto; padding: 20px 28px; }
#composer { display: flex; gap: 8px; padding: 12px 28px 18px; border-top: 1px solid var(--line); background: var(--bg); }
#input { flex: 1; font: inherit; color: var(--text); padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff;
  min-height: 48px; max-height: 200px; overflow-y: auto; line-height: 1.7; white-space: pre-wrap; word-break: break-word; outline: none; }
#input:focus { border-color: var(--accent); }
#input:empty::before { content: attr(data-placeholder); color: var(--dim); pointer-events: none; }
.composer-btns { display: flex; flex-direction: column; gap: 6px; }

.btn { font: inherit; font-size: 14px; color: var(--text); background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 7px 14px; cursor: pointer; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }

.msg { margin: 0 0 18px; max-width: 900px; }
.msg.user { margin-left: auto; width: fit-content; max-width: 640px; background: var(--user); border-radius: 12px; padding: 10px 14px; white-space: pre-wrap; }
.msg.bot .bubble { line-height: 1.65; }
.bubble p { margin: 0 0 8px; } .bubble ul { margin: 4px 0 8px 18px; padding: 0; }
.bubble code { background: #f0f1f4; padding: 1px 5px; border-radius: 4px; font-family: Consolas, monospace; font-size: 13px; }

.steps { margin: 0 0 8px; font-size: 13px; color: var(--dim); }
.step::before { content: "○ "; } .step.run::before { content: "◌ "; } .step.ok::before { content: "✓ "; color: var(--ok); } .step.fail::before { content: "✕ "; color: var(--bad); }
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -2px; margin-right: 6px; }
@keyframes spin { to { transform: rotate(360deg); } }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin: 10px 0; }
.card-title { font-weight: 700; margin-bottom: 8px; }
.card-foot { font-size: 13px; color: var(--dim); margin-top: 6px; }
table.grid { border-collapse: collapse; width: 100%; font-size: 14px; }
table.grid th { background: #f2f2f2; color: var(--text); font-weight: 700; text-align: left; cursor: pointer; user-select: none; }
table.grid th, table.grid td { border: 1px solid var(--line); padding: 6px 9px; }
table.grid td.num { text-align: right; font-variant-numeric: tabular-nums; }
.chart-box { width: 100%; height: 320px; }
.ask-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.ask-btns .btn.chosen { background: var(--accent-bg); border-color: var(--accent); }
.file a { color: var(--accent); font-weight: 700; text-decoration: none; }
.error { border-color: var(--bad); }
.error .card-title { color: var(--bad); }

.msg-tools { display: flex; gap: 6px; margin-top: 6px; }
.msg-tools .btn { font-size: 12px; padding: 3px 10px; color: var(--dim); }
.meta-line { font-size: 12px; color: var(--dim); margin-left: auto; align-self: center; }

.note { font-size: 13px; color: var(--dim); margin: 6px 0; }
#topbar { display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding: 8px 28px; border-bottom: 1px solid var(--line); background: var(--panel); }
#topbar #status { margin-right: auto; }
.small-btn { font-size: 13px; padding: 4px 12px; }

/* ── 메타 패널 ── */
:root { --sib: #a3a9b3; }
.meta-search { flex: none; }
.meta-search .row { display: flex; gap: 6px; margin-bottom: 6px; }
#meta-q { flex: 1; font: inherit; color: var(--text); padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; }
.filters select { flex: 1; min-width: 0; font: inherit; font-size: 13px; color: var(--text); padding: 4px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
#meta-info { margin: 6px 0 4px; }
#meta-tree { flex: 1; overflow-y: auto; min-height: 0; margin-top: 4px; padding-right: 4px; }
.msector > summary { font-weight: 700; cursor: pointer; padding: 4px 0; }
.mdomain { margin-left: 10px; }
.mdomain > summary { cursor: pointer; padding: 3px 0; color: var(--text); }
.cnt { font-size: 12px; color: var(--dim); font-weight: 400; }
.mtable { margin: 2px 0 2px 14px; }
.mtable-head { cursor: pointer; padding: 3px 4px; border-radius: 6px; display: flex; align-items: baseline; gap: 4px; flex-wrap: wrap; }
.mtable-head:hover { background: var(--bg); }
.mtable-head.hit .mtable-ko { font-weight: 700; }
.mtable-ko { color: var(--text); }
.mtable-meta { font-size: 12px; color: var(--dim); }
.caret { color: var(--dim); width: 10px; }
.mini { font: inherit; font-size: 11px; color: var(--dim); background: none; border: 1px solid var(--line); border-radius: 5px; padding: 0 6px; margin-left: auto; cursor: pointer; visibility: hidden; }
.mtable-head:hover .mini { visibility: visible; }
.mtable-cols { margin-left: 16px; border-left: 1px solid var(--line); padding-left: 8px; }
.mcol { font-size: 13px; padding: 2px 4px; cursor: pointer; border-radius: 4px; }
.mcol:hover { background: var(--bg); }
.mcol.hit { color: #000; font-weight: 700; }
.mcol.sib, .mcol.sib .mcol-en, .mcol.sib .tag { color: var(--sib); font-weight: 400; }
.mcol.plain { color: var(--text); }
.mcol-en { font-size: 11px; color: var(--dim); font-family: Consolas, monospace; font-weight: 400; }
.tag { font-size: 10px; color: var(--dim); border: 1px solid var(--line); border-radius: 3px; padding: 0 3px; font-weight: 400; }
#meta-detail { flex: none; max-height: 42%; overflow-y: auto; border-top: 1px solid var(--line); margin-top: 8px; padding-top: 8px; font-size: 13px; }
.d-title { font-weight: 700; font-size: 14px; }
.d-sub { color: var(--dim); font-size: 12px; margin: 2px 0 6px; }
.d-body { white-space: normal; line-height: 1.55; }
.d-codes { margin-top: 8px; }
.d-codeq { width: 100%; font: inherit; font-size: 13px; padding: 4px 8px; border: 1px solid var(--line); border-radius: 6px; margin-bottom: 4px; }
.code { padding: 1px 0; }
.code-c { font-family: Consolas, monospace; color: var(--dim); display: inline-block; min-width: 60px; }
.d-btns { display: flex; gap: 6px; margin: 0 0 6px; }

/* ── 파일 가져오기 ── */
.attach { font-size: 18px; padding: 4px 10px; align-self: flex-start; }
.note-line { font-size: 13px; color: var(--dim); margin: 0 0 14px; padding-left: 10px; border-left: 3px solid var(--line); }
.note-line.bad { color: var(--bad); border-left-color: var(--bad); }
#center { position: relative; }
#drop-hint { position: absolute; inset: 46px 0 0 0; background: rgba(31, 95, 214, .08); border: 2px dashed var(--accent); color: var(--accent);
  display: flex; align-items: center; justify-content: center; font-size: 18px; font-weight: 700; pointer-events: none; z-index: 5; }
#drop-hint[hidden] { display: none; }

/* ── 칩(대화에 넣은 테이블·컬럼) ── */
.chip { display: inline-block; padding: 0 7px; margin: 0 1px; border-radius: 6px; font-size: 13px; line-height: 1.6; vertical-align: baseline;
  border: 1px solid #b9cdf3; background: #e8f0fe; color: #0b2a66; cursor: default; user-select: all; white-space: nowrap; }
.chip b { font-weight: 700; }
.chip.user { border-color: #b6dfc1; background: #e6f5ea; color: #0d4020; }
.chip.tbl { font-style: normal; }
.msg.user .chip { cursor: default; }
.mcol[draggable="true"], .mtable-head[draggable="true"] { -webkit-user-drag: element; }
#meta-q.from-decal { border-color: var(--accent); background: var(--accent-bg); transition: background .4s; }
.msector.pick > summary { color: var(--accent); }
.msector.pick { margin-bottom: 6px; border-bottom: 1px dashed var(--line); padding-bottom: 4px; }

/* SAS 코드(접힌 상태) */
.code-card { padding: 8px 14px; }
.code-card summary { cursor: pointer; color: var(--dim); font-size: 13px; }
.code-card[open] summary { margin-bottom: 8px; }
pre.code { background: #f5f6f8; color: #1d2330; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin: 0 0 8px;
  font: 13px/1.5 Consolas, "D2Coding", monospace; white-space: pre-wrap; word-break: break-all; }
.btn.small { font-size: 12px; padding: 3px 10px; }
.code-card.req { border-left: 3px solid var(--accent); }
.code-card.req summary { color: var(--text); font-weight: 600; }

/* 과정 보기(접힘) */
.proc { margin: 0 0 8px; font-size: 13px; color: var(--dim); }
.proc > summary { cursor: pointer; user-select: none; }
.proc[open] > summary { margin-bottom: 6px; }
.proc-body { border-left: 2px solid var(--line); padding-left: 10px; }
.proc-body .steps { margin: 0 0 4px; }
