:root {
  /* 메신저 감성: 노랑 + 진한 갈색 글씨 + 하늘빛 회색 채팅방 */
  --bg: #f2f3f5;
  --panel: #ffffff;
  --panel-2: #f7f7f8;
  --border: #e5e5e8;
  --border-strong: #c9c9cf;
  --text: #191919;
  --text-2: #3b3b3f;
  --muted: #6e6e73;
  --faint: #9a9aa0;
  --accent: #3c1e1e;
  --accent-2: #6b5ce7;
  --accent-soft: rgba(254, 229, 0, 0.22);
  --brand: #fee500;
  --brand-press: #f2d900;
  --room: #b2c7da;
  --ok: #1aa260;
  --warn: #c98a00;
  --bad: #e5484d;
  --overlap: rgba(254, 229, 0, 0.45);
  --code-bg: #f7f7f8;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  --mono: "JetBrains Mono", "D2Coding", Consolas, "SFMono-Regular", monospace;
  --sans: "Noto Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  --c-fixed: #f0b400;
  --c-recursive: #6b5ce7;
  --c-article: #1aa260;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
  word-break: keep-all;
}
button, input, select { font: inherit; color: inherit; }
b { font-weight: 600; }
.muted { color: var(--muted); font-weight: 400; font-size: 12px; }

/* top bar */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 24px; border-bottom: 1px solid var(--border);
  background: #fff;
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo { color: var(--accent); font-size: 22px; }
.brand-name { font-weight: 700; letter-spacing: 0.04em; }
.brand-sub { color: var(--muted); font-size: 12px; font-family: var(--mono); }
.status { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; font-family: var(--mono); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.status.ok .dot { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.status.bad .dot { background: var(--bad); }

/* layout */
.layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 280px;
  grid-template-areas: "settings results stats" "compare compare compare";
  gap: 16px; padding: 16px 24px 32px; max-width: 1680px; margin: 0 auto;
}
.settings { grid-area: settings; align-self: start; }
.results {
  grid-area: results; min-height: 520px; height: calc(100vh - 110px);
  display: flex; flex-direction: column;
}
.stats { grid-area: stats; align-self: start; }
.compare { grid-area: compare; }

.panel {
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 16px;
}
.panel-title { margin: 0 0 14px; font-size: 13px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.sub-title { margin: 18px 0 8px; font-size: 12px; font-weight: 600; color: var(--muted); }

/* settings */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 18px; }
.field-label { font-size: 12px; color: var(--muted); }
.field-label b { color: var(--text); font-family: var(--mono); font-size: 14px; }
.field-hint { font-size: 11px; color: var(--faint); }
select, input[type="search"] {
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; outline: none;
}
select:focus, input[type="search"]:focus { border-color: var(--accent); }
input[type="range"] { width: 100%; accent-color: var(--accent); }
.range-scale { display: flex; justify-content: space-between; font-size: 10px; color: var(--faint); font-family: var(--mono); }

.method-list { display: flex; flex-direction: column; gap: 6px; }
.method {
  display: block; text-align: left; padding: 9px 11px; border-radius: 8px; cursor: pointer;
  background: var(--panel-2); border: 1px solid var(--border); transition: border-color .15s, background .15s;
}
.method:hover { border-color: var(--border-strong); }
.method.active { border-color: var(--accent); background: var(--accent-soft); }
.method-name { font-weight: 600; font-size: 13px; }
.method-desc { display: block; color: var(--muted); font-size: 11px; margin-top: 2px; line-height: 1.45; }

.actions { display: flex; flex-direction: column; gap: 8px; }
.btn {
  padding: 10px 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--panel-2);
  cursor: pointer; font-weight: 600; transition: filter .15s, border-color .15s;
}
.btn:hover:not(:disabled) { border-color: var(--border-strong); filter: brightness(1.1); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.ghost { background: transparent; color: var(--muted); font-weight: 500; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.note { font-size: 11px; color: var(--faint); margin: 12px 0 0; }
.field-error {
  font-size: 12px; color: var(--bad); background: rgba(255, 107, 107, 0.08);
  border: 1px solid rgba(255, 107, 107, 0.3); border-radius: 8px; padding: 8px 10px; margin-bottom: 12px;
}

/* results */
.results-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.results-head input { width: 220px; max-width: 100%; }
.chunk-list {
  display: flex; flex-direction: column; gap: 10px;
  flex: 1; min-height: 0; overflow-y: auto; padding-right: 4px; margin-top: 4px;
}
.chunk-list::-webkit-scrollbar, .compare-col-body::-webkit-scrollbar { width: 8px; }
.chunk-list::-webkit-scrollbar-thumb, .compare-col-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.empty { color: var(--faint); padding: 40px 12px; text-align: center; border: 1px dashed var(--border); border-radius: 10px; }
.loading { color: var(--muted); padding: 40px 12px; text-align: center; font-family: var(--mono); }

.card { background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }
.card-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.idx { font-family: var(--mono); font-size: 12px; color: var(--accent); font-weight: 700; }
.cid { font-family: var(--mono); font-size: 11px; color: var(--faint); }
.spacer { flex: 1; }
.badge {
  font-size: 11px; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--border); color: var(--muted);
  white-space: nowrap; font-family: var(--mono);
}
.badge.chars { color: var(--text); }
.badge.warn { color: var(--warn); border-color: rgba(242, 184, 75, 0.4); }
.badge.ok { color: var(--ok); border-color: rgba(79, 209, 139, 0.35); }
.badge.level { color: var(--accent-2); border-color: rgba(155, 140, 255, 0.35); }
.card-meta { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.card-meta .art { color: var(--text); font-weight: 600; }
.text {
  margin: 0; white-space: pre-wrap; word-break: break-word; font: 13px/1.65 var(--sans);
  color: var(--text); background: var(--code-bg); border-radius: 8px; padding: 10px 12px; position: relative;
}
.text.clamp { max-height: 7.2em; overflow: hidden; }
.text.clamp::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 2.4em;
  background: linear-gradient(transparent, var(--code-bg));
}
.text mark { background: var(--overlap); color: inherit; border-radius: 3px; }
.toggle {
  margin-top: 6px; background: none; border: none; padding: 2px 0; color: var(--accent);
  cursor: pointer; font-size: 12px;
}

/* stats */
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stat { background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
.stat.wide { grid-column: span 2; }
.stat-label { display: block; font-size: 11px; color: var(--muted); }
.stat-value { display: block; font-family: var(--mono); font-size: 20px; font-weight: 700; margin-top: 2px; }
.histogram {
  display: flex; align-items: flex-end; gap: 0; height: 64px; padding: 6px; overflow: hidden;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px;
}
.histogram .bar { flex: 1 1 0; min-width: 0; background: var(--accent); opacity: .75; border-radius: 1px 1px 0 0; }
.histogram .bar.limit { background: var(--warn); }
.kv { margin: 0; display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; font-size: 12px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-family: var(--mono); text-align: right; }
.kv .good { color: var(--ok); }
.kv .bad { color: var(--bad); }

/* compare */
.compare-table-wrap { overflow-x: auto; }
.compare-table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 560px; }
.compare-table th, .compare-table td { padding: 9px 12px; border-bottom: 1px solid var(--border); text-align: right; }
.compare-table th:first-child, .compare-table td:first-child { text-align: left; color: var(--muted); font-weight: 400; }
.compare-table thead th { font-size: 12px; color: var(--text); font-weight: 600; }
.compare-table td { font-family: var(--mono); }
.compare-table .best { color: var(--ok); }
.swatch { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; }
.compare-cols { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 16px; }
.compare-col { background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px; display: flex; flex-direction: column; min-width: 0; }
.compare-col-head { padding: 10px 12px; border-bottom: 1px solid var(--border); font-weight: 600; font-size: 13px; display: flex; justify-content: space-between; gap: 8px; }
.compare-col-body { max-height: 560px; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.mini { border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; background: var(--code-bg); }
.mini-head { display: flex; gap: 6px; align-items: center; font-size: 11px; margin-bottom: 4px; flex-wrap: wrap; }
.mini-text { font-size: 12px; color: var(--text-2); white-space: pre-wrap; word-break: break-word; max-height: 4.8em; overflow: hidden; line-height: 1.6; }
.mini.cross { border-color: rgba(242, 184, 75, 0.45); }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); max-width: calc(100% - 32px);
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 16px;
  font-size: 13px; box-shadow: 0 8px 30px rgba(16, 42, 90, .18); z-index: 20;
}
.toast.bad { border-color: rgba(255, 107, 107, .5); color: var(--bad); }

/* responsive */
@media (max-width: 1200px) {
  .layout { grid-template-columns: 260px minmax(0, 1fr); grid-template-areas: "settings results" "stats results" "compare compare"; }
  .stats { position: static; }
}
@media (max-width: 860px) {
  .layout { grid-template-columns: minmax(0, 1fr); grid-template-areas: "settings" "stats" "results" "compare"; padding: 12px 16px 24px; }
  .settings { position: static; }
  .results { height: 80vh; }
  .compare-cols { grid-template-columns: minmax(0, 1fr); }
  .topbar { padding: 12px 16px; }
}

/* ---------- navigation (shared) ---------- */
.nav { display: flex; gap: 4px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px; padding: 3px; }
.nav a { color: var(--muted); text-decoration: none; font-size: 13px; font-weight: 600; padding: 6px 12px; border-radius: 7px; }
.nav a:hover { color: var(--text); }
.nav a.active { background: var(--accent); color: #fff; }

/* ---------- Retrieval Playground ---------- */
.layout.retrieval {
  grid-template-columns: 290px minmax(0, 1fr) 320px;
  grid-template-areas: "settings search analysis" "results results results";
}
.layout.retrieval .search { grid-area: search; }
.layout.retrieval .analysis { grid-area: analysis; }
.layout.retrieval .results-3 { grid-area: results; }
.kv dd.wrap { word-break: break-all; }
.index-status { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.ready-row { display: flex; justify-content: space-between; align-items: center; font-size: 13px; }
.progress { height: 6px; background: var(--panel-2); border-radius: 999px; overflow: hidden; border: 1px solid var(--border); }
.progress-bar { height: 100%; width: 0; background: var(--accent); transition: width .3s; }
.progress-bar.bad { background: var(--bad); }
.check { font-size: 12px; color: var(--muted); display: flex; gap: 6px; align-items: center; }
textarea {
  width: 100%; resize: vertical; min-height: 64px; background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px 14px; font: 15px/1.5 var(--sans); color: var(--text); outline: none;
}
textarea:focus { border-color: var(--accent); }
.examples { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 14px; }
.chip {
  border: 1px solid var(--border); background: var(--panel-2); color: var(--muted); border-radius: 999px;
  padding: 5px 12px; font-size: 12px; cursor: pointer; text-align: left;
}
.chip b { color: var(--accent); margin-right: 4px; }
.chip:hover { color: var(--text); border-color: var(--border-strong); }
.search-controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.search-controls .btn.primary { padding: 9px 22px; }
.seg { display: inline-flex; background: var(--panel-2); border: 1px solid var(--border); border-radius: 9px; padding: 3px; flex-wrap: wrap; }
.seg button { border: none; background: transparent; color: var(--muted); padding: 6px 12px; border-radius: 6px; cursor: pointer; font-weight: 600; font-size: 13px; }
.seg button.active { background: var(--panel); color: var(--text); box-shadow: inset 0 0 0 1px var(--accent); }
.topk { font-size: 12px; color: var(--muted); display: flex; gap: 6px; align-items: center; }
.topk input { width: 56px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 7px; padding: 6px 8px; }
.legend { margin: 14px 0 0; padding: 10px 12px 10px 28px; font-size: 12px; color: var(--muted); background: var(--panel-2); border-radius: 10px; border: 1px solid var(--border); }
.legend li { margin: 2px 0; }
.legend b { color: var(--text); }
.search .field-error { margin: 12px 0 0; }
.an-block { border: 1px solid var(--border); background: var(--panel-2); border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; }
.an-head { font-weight: 600; font-size: 13px; margin-bottom: 6px; }
.top5 { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.empty.small { padding: 20px 10px; font-size: 12px; }
.results-3 .compare-cols { margin-top: 0; }
.results-3 .compare-col-body { max-height: 900px; }
.mini.result .card-meta { margin: 4px 0 6px; }
.mini.result .text { font-size: 12.5px; padding: 8px 10px; }
.mini.result .cid { font-family: var(--mono); font-size: 10px; color: var(--faint); margin-top: 4px; }
.mini.common { border-color: rgba(79, 209, 139, 0.45); }
.badge.score { color: var(--text); }
.results-3 .loading, .results-3 > .compare-cols > .empty { grid-column: 1 / -1; }

@media (max-width: 1200px) {
  .layout.retrieval { grid-template-columns: 270px minmax(0, 1fr); grid-template-areas: "settings search" "analysis analysis" "results results"; }
}
@media (max-width: 860px) {
  .layout.retrieval { grid-template-columns: minmax(0, 1fr); grid-template-areas: "search" "settings" "analysis" "results"; }
  .topbar { flex-wrap: wrap; }
  .nav { order: 3; width: 100%; justify-content: center; }
}

/* key-value lists: labels never wrap per character */
.kv { grid-template-columns: max-content minmax(0, 1fr); }
.kv dt { white-space: nowrap; }
.kv dd .muted { display: block; font-size: 11px; }
.layout.retrieval .search, .layout.retrieval .analysis { align-self: start; }

/* ---------- RAG Chat Lab ---------- */
.pills { display: flex; gap: 6px; flex-wrap: wrap; }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-family: var(--mono); color: var(--muted);
  border: 1px solid var(--border); border-radius: 999px; padding: 4px 10px; background: var(--panel-2); }
.pill.ok { color: var(--ok); border-color: rgba(79, 209, 139, .35); }
.pill.ok .dot { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.pill.bad { color: var(--bad); border-color: rgba(255, 107, 107, .4); }
.pill.bad .dot { background: var(--bad); }

.layout.chat-layout {
  grid-template-columns: 270px minmax(0, 1fr) 320px;
  grid-template-areas: "settings chat analysis";
}
.chat-layout .chat { grid-area: chat; display: flex; flex-direction: column; height: calc(100vh - 110px); min-height: 520px; padding: 0; }
.chat-layout .analysis { grid-area: analysis; max-height: calc(100vh - 110px); overflow-y: auto; }
.chat-layout .settings { max-height: calc(100vh - 110px); overflow-y: auto; }
.seg.full { display: flex; width: 100%; }
.seg.full button { flex: 1; padding: 7px 4px; }
.field.disabled { opacity: .4; pointer-events: none; }
.model-box { font-family: var(--mono); font-size: 13px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; }
.q-list { display: flex; flex-direction: column; gap: 6px; }
.q-btn { text-align: left; font-size: 12px; line-height: 1.45; color: var(--muted); background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 9px; cursor: pointer; }
.q-btn b { color: var(--accent); margin-right: 4px; }
.q-btn:hover:not(:disabled) { color: var(--text); border-color: var(--border-strong); }
.q-btn:disabled { opacity: .5; cursor: not-allowed; }

.messages { flex: 1; min-height: 0; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.welcome { margin: auto; text-align: center; max-width: 440px; }
.welcome-title { font-size: 18px; font-weight: 700; margin-bottom: 6px; }
.msg { display: flex; }
.msg.user { justify-content: flex-end; }
.msg.user .bubble { background: var(--accent); color: #fff; padding: 10px 14px; border-radius: 14px 14px 4px 14px; max-width: 80%;
  white-space: pre-wrap; word-break: break-word; font-weight: 500; }
.msg.ai { flex-direction: column; }
.answer { background: var(--panel-2); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; min-width: 0; }
.answer.insufficient { border-color: rgba(242, 184, 75, .5); }
.answer.error { border-color: rgba(255, 107, 107, .5); }
.answer-head { display: flex; justify-content: space-between; gap: 8px; align-items: center; margin-bottom: 8px; flex-wrap: wrap; }
.answer-head .meta { font-family: var(--mono); font-size: 11px; }
.answer-body { white-space: pre-wrap; word-break: break-word; line-height: 1.7; font-size: 14px; }
.answer-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.err { color: var(--bad); font-size: 13px; margin-top: 4px; }
.cite { display: inline-block; font: 600 11px/1 var(--mono); color: #fff; background: var(--c-article); border: none; border-radius: 4px;
  padding: 3px 5px; margin: 0 2px; cursor: pointer; vertical-align: 1px; }
.cite.invalid { background: var(--bad); cursor: help; text-decoration: line-through; }
.caret { display: inline-block; width: 7px; height: 15px; background: var(--accent); vertical-align: -2px; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.typing { display: inline-flex; gap: 4px; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: bounce 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .15s; } .typing i:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%, 80%, 100% { opacity: .3; } 40% { opacity: 1; } }
.answer-foot .note { margin-top: 8px; }
.cite-report { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 10px; }
.badge.bad { color: var(--bad); border-color: rgba(255, 107, 107, .4); }
.sources { margin-top: 10px; display: flex; flex-direction: column; gap: 4px; }
.sources-title { font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.source { display: grid; grid-template-columns: auto 1fr; gap: 0 8px; text-align: left; background: var(--code-bg); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 9px; cursor: pointer; color: var(--text); font-size: 12px; }
.source:hover { border-color: var(--accent); }
.source.cited { border-color: rgba(79, 209, 139, .5); }
.source.dropped { opacity: .55; }
.source .sid { grid-row: span 2; font: 700 11px var(--mono); color: var(--c-article); align-self: center; }
.source .src-sub { color: var(--faint); font-size: 11px; }
.law-line { font-size: 12px; padding: 2px 0; }
.bad-note { color: var(--warn); }

.composer { border-top: 1px solid var(--border); padding: 12px 14px; }
.composer textarea { min-height: 56px; }
.composer-row { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.composer-row .btn { padding: 8px 18px; }

.modal { position: fixed; inset: 0; background: rgba(10, 25, 50, .45); display: flex; align-items: center; justify-content: center; z-index: 30; padding: 16px; }
.modal[hidden] { display: none; }
.modal-box { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; width: min(760px, 100%); max-height: 85vh; display: flex; flex-direction: column; padding: 16px; gap: 10px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.modal-meta { font-size: 12px; color: var(--muted); }
.modal-meta a { color: var(--accent); }
.modal-box .text { overflow-y: auto; }

@media (max-width: 1200px) {
  .layout.chat-layout { grid-template-columns: 250px minmax(0, 1fr); grid-template-areas: "settings chat" "analysis analysis"; }
  .chat-layout .analysis { max-height: none; }
}
@media (max-width: 860px) {
  .layout.chat-layout { grid-template-columns: minmax(0, 1fr); grid-template-areas: "chat" "settings" "analysis"; }
  .chat-layout .chat { height: 78vh; }
  .chat-layout .settings { max-height: none; }
  .answer-grid { grid-template-columns: minmax(0, 1fr); }
  .pills { order: 4; }
}
.answer-body .md-h { display: inline-block; margin-top: 4px; color: var(--accent); }

/* =====================================================================
   메신저(카톡) 감성 테마
   ===================================================================== */
body { background: var(--bg); font-size: 14.5px; }

/* 상단 */
.utility { display: none; }
.topbar {
  position: sticky; top: 0; z-index: 10; background: var(--brand); border: none; box-shadow: none;
  padding: 0 24px; min-height: 64px;
}
.brand { text-decoration: none; color: var(--text); }
.logo-mark { width: 38px; height: 38px; }
.logo-mark path:nth-child(1) { fill: var(--accent); }
.logo-mark path:nth-child(2) { fill: #5a3a2e; }
.logo-mark path:nth-child(3) { stroke: var(--brand); }
.brand-name { font-size: 18px; font-weight: 800; color: var(--text); letter-spacing: 0; }
.brand-sub { font-family: var(--sans); font-size: 12px; color: rgba(25, 25, 25, .62); }
.nav { background: rgba(255, 255, 255, .45); border: none; padding: 4px; border-radius: 999px; gap: 2px; }
.nav a { color: rgba(25, 25, 25, .7); font-size: 14.5px; font-weight: 700; padding: 8px 18px; border-radius: 999px; }
.nav a:hover { color: var(--text); background: rgba(255, 255, 255, .5); }
.nav a.active { background: var(--accent); color: #fff; }
.status { font-family: var(--sans); color: rgba(25, 25, 25, .75); }
.status .dot { background: rgba(25, 25, 25, .3); }
.status.ok .dot { background: var(--ok); box-shadow: none; }
.pill { font-family: var(--sans); background: rgba(255, 255, 255, .7); border: none; color: var(--text-2); font-weight: 600; }
.pill.ok { color: var(--text); }
.pill.ok .dot { background: var(--ok); box-shadow: none; }
.pill.bad { color: var(--bad); }

/* 페이지 제목 */
.page-head { background: #fff; border-bottom: 1px solid var(--border); }
.page-head-inner { max-width: 1680px; margin: 0 auto; padding: 18px 24px; display: grid; grid-template-columns: auto 1fr; column-gap: 14px; align-items: center; }
.page-head-inner::before {
  content: "💬"; grid-row: span 3; width: 52px; height: 52px; border-radius: 18px; background: var(--brand);
  display: flex; align-items: center; justify-content: center; font-size: 26px;
}
.crumb { font-size: 12px; color: var(--faint); }
.page-head h1 { margin: 0; font-size: 22px; font-weight: 800; color: var(--text); }
.page-head p { margin: 2px 0 0; color: var(--muted); font-size: 13.5px; }

/* 패널 · 컨트롤 */
.layout { padding-top: 18px; }
.panel { border: none; border-radius: 18px; box-shadow: var(--shadow); }
.panel-title { text-transform: none; letter-spacing: 0; font-size: 16px; font-weight: 800; color: var(--text); }
.sub-title { color: var(--text); font-size: 13px; }
.field-label { color: var(--text-2); font-weight: 600; }
.field-label b { color: var(--text); background: var(--brand); padding: 0 6px; border-radius: 6px; }
select, input[type="search"], textarea, .topk input { background: var(--panel-2); border-color: transparent; border-radius: 12px; }
select:focus, input[type="search"]:focus, textarea:focus { border-color: var(--brand-press); background: #fff; }
input[type="range"] { accent-color: var(--accent); }
.btn { background: var(--panel-2); border: none; color: var(--text); border-radius: 12px; font-weight: 700; }
.btn:hover:not(:disabled) { filter: none; background: #ececef; }
.btn.primary { background: var(--brand); color: var(--text); }
.btn.primary:hover:not(:disabled) { background: var(--brand-press); color: var(--text); }
.btn.ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.seg { background: var(--panel-2); border: none; border-radius: 12px; padding: 4px; }
.seg button { color: var(--muted); border-radius: 9px; }
.seg button.active { background: #fff; color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.method { background: var(--panel-2); border: 1.5px solid transparent; border-radius: 14px; }
.method.active { background: #fffbd1; border-color: var(--brand-press); box-shadow: none; }
.chip, .q-btn { background: var(--panel-2); border: none; color: var(--text-2); border-radius: 999px; }
.q-btn { border-radius: 14px; }
.chip:hover, .q-btn:hover:not(:disabled) { background: #fffbd1; color: var(--text); }
.chip b, .q-btn b { color: var(--accent); background: var(--brand); border-radius: 6px; padding: 0 5px; }
.field-error { border-radius: 12px; }
.legend { background: #fffbe0; border: none; border-radius: 14px; }
.legend b { color: var(--text); }
.empty { background: var(--panel-2); border: none; border-radius: 14px; }
.progress-bar { background: var(--brand-press); }

/* 카드 · 통계 */
.card, .stat, .an-block, .compare-col { background: #fff; border: 1px solid var(--border); border-radius: 16px; }
.stat-value { color: var(--text); }
.idx { color: var(--accent); }
.badge { background: var(--panel-2); border: none; }
.badge.chars { background: #fffbd1; color: var(--text); }
.badge.ok { background: rgba(26, 162, 96, .1); }
.badge.warn { background: rgba(201, 138, 0, .1); }
.badge.bad { background: rgba(229, 72, 77, .1); }
.badge.level { background: rgba(107, 92, 231, .1); }
.text { background: var(--panel-2); border-radius: 12px; }
.histogram { background: var(--panel-2); border: none; border-radius: 14px; }
.histogram .bar { background: var(--accent); opacity: .8; }
.histogram .bar.limit { background: var(--brand-press); opacity: 1; }
.compare-table thead th { background: var(--panel-2); color: var(--text); }
.compare-col-head { background: #fffbe0; border-radius: 16px 16px 0 0; color: var(--text); }
.mini { background: var(--panel-2); border: 1px solid transparent; border-radius: 12px; }
.mini.common { border-color: rgba(26, 162, 96, .45); }
.toggle { color: var(--accent); font-weight: 700; }

/* ---------- 채팅방 ---------- */
.chat-layout .chat { background: var(--room); overflow: hidden; }
.messages { padding: 16px 18px 20px; gap: 12px; }
.day-divider { align-self: center; background: rgba(0, 0, 0, .12); color: #fff; font-size: 12px; padding: 4px 14px; border-radius: 999px; }
.welcome { margin: 0; text-align: left; max-width: none; display: flex; gap: 8px; }
.welcome .welcome-bubble { background: #fff; border-radius: 4px 16px 16px 16px; padding: 10px 14px; max-width: 520px; }
.welcome-title { font-size: 14.5px; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.avatar {
  flex: 0 0 40px; width: 40px; height: 40px; border-radius: 15px; background: var(--brand);
  display: flex; align-items: center; justify-content: center; font-size: 20px;
}
.ai-col { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1; }
.bot-name { font-size: 12.5px; color: rgba(25, 25, 25, .75); }
.msg.ai { flex-direction: row; align-items: flex-start; gap: 8px; }
.msg.user { align-items: flex-end; gap: 6px; }
.msg .time { font-size: 10.5px; color: rgba(25, 25, 25, .55); white-space: nowrap; flex-shrink: 0; }
.msg.user .bubble { background: var(--brand); color: var(--text); border-radius: 16px 4px 16px 16px; font-weight: 400; box-shadow: none; }
.answer { background: #fff; border: none; border-radius: 4px 16px 16px 16px; box-shadow: none; max-width: 820px; }
.answer-grid .answer { max-width: none; }
.answer.insufficient { box-shadow: inset 0 0 0 2px rgba(201, 138, 0, .45); }
.answer.error { box-shadow: inset 0 0 0 2px rgba(229, 72, 77, .45); }
.answer-head .badge { background: var(--panel-2); color: var(--text-2); }
.answer-head .badge.level { background: var(--brand); color: var(--text); }
.answer-head .meta { color: var(--faint); }
.answer-body .md-h { color: var(--accent); }
.cite { background: var(--brand); color: var(--accent); }
.cite.invalid { background: var(--bad); color: #fff; }
.caret { background: var(--accent); }
.typing i { background: var(--faint); }
.source { background: var(--panel-2); border: 1px solid transparent; border-radius: 12px; }
.source:hover { border-color: var(--brand-press); background: #fffbe0; }
.source.cited { background: #fffbd1; border-color: var(--brand-press); }
.source .sid { color: var(--accent); }
.composer { background: #fff; border-top: none; padding: 10px 12px 12px; }
.composer textarea { background: var(--panel-2); border-radius: 14px; min-height: 52px; }
.composer-row .btn.primary { border-radius: 10px; padding: 9px 22px; }
.model-box { background: var(--panel-2); border: none; border-radius: 12px; }
.modal-box { border: none; border-radius: 20px; box-shadow: 0 20px 60px rgba(0, 0, 0, .2); }
.toast { background: var(--accent); color: #fff; border: none; border-radius: 999px; }
.toast.bad { background: var(--bad); color: #fff; }

/* 하단 */
.site-footer { background: transparent; margin-top: 4px; }
.footer-inner { max-width: 1680px; margin: 0 auto; padding: 14px 24px 26px; font-size: 12px; color: var(--muted); line-height: 1.7; }
.footer-inner b { color: var(--text); margin-right: 8px; }
.footer-inner .disclaimer { color: var(--faint); }

.results { height: calc(100vh - 100px); }
.chat-layout .chat { height: calc(100vh - 100px); }
.chat-layout .analysis, .chat-layout .settings { max-height: calc(100vh - 100px); }

@media (max-width: 1200px) {
  .topbar { flex-wrap: wrap; padding: 10px 16px; row-gap: 8px; }
  .nav { order: 3; width: 100%; justify-content: center; }
}
@media (max-width: 860px) {
  .page-head-inner { padding: 14px 16px; }
  .page-head-inner::before { width: 44px; height: 44px; font-size: 22px; border-radius: 15px; }
  .page-head h1 { font-size: 19px; }
  .nav a { padding: 7px 10px; font-size: 13px; }
  .msg .time { display: none; }
  .avatar { flex-basis: 34px; width: 34px; height: 34px; border-radius: 13px; font-size: 17px; }
  .footer-inner { padding: 14px 16px 22px; }
}

/* ---------- 채팅방 설정: ⚙️ 를 눌렀을 때만 열리는 서랍 ---------- */
.layout.chat-layout { grid-template-columns: minmax(0, 1fr) 340px; grid-template-areas: "chat analysis"; }
.room-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 14px 10px 18px; background: rgba(178, 199, 218, .96); border-bottom: 1px solid rgba(0, 0, 0, .06);
}
.room-title { display: flex; flex-direction: column; min-width: 0; }
.room-title b { font-size: 15.5px; color: var(--text); }
.room-summary { font-size: 11.5px; color: rgba(25, 25, 25, .62); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  width: 38px; height: 38px; border: none; border-radius: 12px; background: transparent; cursor: pointer;
  font-size: 19px; line-height: 1; display: inline-flex; align-items: center; justify-content: center; color: var(--text);
}
.icon-btn:hover { background: rgba(255, 255, 255, .45); }
.icon-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.quick { display: flex; gap: 6px; overflow-x: auto; padding: 8px 12px; background: #fff; border-top: 1px solid var(--border); scrollbar-width: thin; }
.quick .q-btn { flex: 0 0 auto; max-width: 320px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-radius: 999px; padding: 6px 12px; }

.drawer-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .28); z-index: 40; }
.drawer-backdrop[hidden] { display: none; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(380px, 100%); z-index: 41; background: var(--bg);
  transform: translateX(100%); visibility: hidden; transition: transform .22s ease, visibility 0s linear .22s;
  display: flex; flex-direction: column; box-shadow: -12px 0 32px rgba(0, 0, 0, .14);
}
.drawer.open { transform: none; visibility: visible; transition: transform .22s ease; }
.drawer-head {
  display: flex; align-items: center; gap: 4px; padding: 10px 12px; min-height: 56px;
  background: #fff; border-bottom: 1px solid var(--border); font-size: 16px;
}
.drawer-head .back { font-size: 28px; font-weight: 300; }
.drawer-body { flex: 1; overflow-y: auto; padding-bottom: 24px; }
.set-profile { display: flex; align-items: center; gap: 12px; padding: 18px 18px 16px; background: #fff; }
.set-profile b { font-size: 15px; }
.avatar.big { flex-basis: 52px; width: 52px; height: 52px; border-radius: 19px; font-size: 26px; }
.set-section { padding: 18px 18px 6px; font-size: 12px; color: var(--faint); font-weight: 600; }
.set-row {
  display: flex; flex-direction: column; gap: 8px; width: 100%; padding: 14px 18px; background: #fff;
  border: none; border-bottom: 1px solid #f0f0f2; text-align: left; font: inherit; color: var(--text);
}
.set-row.disabled { opacity: .4; pointer-events: none; }
.set-label { font-size: 14px; font-weight: 600; }
.set-label b { background: var(--brand); padding: 0 6px; border-radius: 6px; margin-left: 2px; }
button.set-row { cursor: pointer; }
.set-row.danger { color: var(--bad); font-weight: 600; }
.set-row.danger:hover { background: #fff5f5; }
.drawer .note { padding: 10px 18px 0; margin: 0; }

@media (max-width: 1200px) {
  .layout.chat-layout { grid-template-columns: minmax(0, 1fr); grid-template-areas: "chat" "analysis"; }
  .chat-layout .analysis { max-height: none; }
}
@media (max-width: 860px) {
  .chat-layout .chat { height: 80vh; }
  .quick .q-btn { max-width: 240px; }
}
.quick { scrollbar-width: none; }
.quick::-webkit-scrollbar { display: none; }
.icon-btn:focus:not(:focus-visible) { outline: none; }
.icon-btn:focus-visible { border-radius: 12px; }

/* ---------- Chunking / Retrieval: 설정은 ⚙️ 서랍으로 ---------- */
.layout.chunk-layout {
  grid-template-columns: minmax(0, 1fr) 300px;
  grid-template-areas: "toolbar toolbar" "results stats" "compare compare";
}
.chunk-layout .toolbar {
  grid-area: toolbar; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 12px 14px 12px 20px;
}
.toolbar-actions { display: flex; align-items: center; gap: 8px; }
.toolbar-actions .btn { padding: 9px 18px; }
.chunk-layout .stats { position: static; }
.layout.retrieval { grid-template-columns: minmax(0, 1fr) 340px; grid-template-areas: "search analysis" "results results"; }
.search-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.search-head .panel-title { margin: 0; }
.search-head .badge { margin-left: auto; }
.drawer .set-kv { background: #fff; padding: 14px 18px; margin: 0; }
.drawer .set-block { background: #fff; padding: 14px 18px; margin: 0; }
.drawer .actions.set-block { padding-top: 0; }
.drawer .method-list { gap: 6px; }
.drawer .field-error { margin: 10px 18px; }
.drawer .field-hint { margin-top: -2px; }
.drawer select { width: 100%; }
@media (max-width: 1200px) {
  .layout.chunk-layout { grid-template-columns: minmax(0, 1fr); grid-template-areas: "toolbar" "stats" "results" "compare"; }
  .layout.retrieval { grid-template-columns: minmax(0, 1fr); grid-template-areas: "search" "analysis" "results"; }
}
@media (max-width: 860px) {
  .toolbar-actions { width: 100%; }
  .toolbar-actions .btn { flex: 1; padding: 9px 8px; }
}

/* 페이지 제목 영역(경로 · 제목 · 설명) 숨김 — 화면을 간단하게 */
.page-head { display: none; }
