:root {
  --navy: #0b2a4a;
  --blue: #1f5fbf;
  --blue-soft: #e8f0fc;
  --line: #e2e6ec;
  --bg: #f5f7fa;
  --text: #1d2733;
  --muted: #6b7684;
  --ok: #1a7f37;
  --ok-soft: #e6f4ea;
  --warn: #b35c00;
  --warn-soft: #fff1e0;
  --check: #8a2bb9;
  --check-soft: #f4e9fb;
  --radius: 10px;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: Pretendard, -apple-system, "Noto Sans KR", sans-serif;
  color: var(--text); background: var(--bg); display: flex; flex-direction: column;
}
button { font: inherit; }
.hidden { display: none !important; }
.empty { color: var(--muted); font-size: 14px; line-height: 1.6; }
.hint { color: var(--muted); font-size: 12.5px; }

/* ---------- top ---------- */
.topbar {
  height: 56px; flex: none; background: var(--navy); color: #fff;
  display: flex; align-items: center; gap: 24px; padding: 0 20px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.logo { font-weight: 800; letter-spacing: 1px; background: #fff; color: var(--navy); padding: 2px 8px; border-radius: 4px; }
.title { font-size: 17px; font-weight: 700; }
.badge { font-size: 12px; background: #f0a500; color: #222; padding: 2px 8px; border-radius: 10px; font-weight: 700; }
.audience { display: flex; background: rgba(255, 255, 255, .12); border-radius: 18px; padding: 3px; }
.audience button { border: 0; background: none; color: #cfd9e6; padding: 4px 12px; border-radius: 14px; cursor: pointer; font-size: 13px; }
.audience button.active { background: #fff; color: var(--navy); font-weight: 700; }
.status { font-size: 12px; opacity: .85; margin-left: auto; }
.status.bad { color: #ffb4b4; opacity: 1; }

.layout { flex: 1; display: flex; min-height: 0; }

/* ---------- left: plan + chat ---------- */
.chat { width: 42%; min-width: 440px; display: flex; flex-direction: column; border-right: 1px solid var(--line); background: #fff; }

.plan { border-bottom: 1px solid var(--line); background: #fbfcfe; flex: none; }
.plan-head { display: flex; align-items: center; gap: 10px; padding: 10px 16px; }
.plan-toggle { border: 0; background: none; font-weight: 800; font-size: 14.5px; cursor: pointer; padding: 0; color: var(--navy); }
.plan-toggle .caret { display: inline-block; transition: transform .15s; }
.plan.collapsed .caret { transform: rotate(-90deg); }
.plan-summary { flex: 1; color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.plan-summary b { color: var(--text); font-weight: 600; }
button.link { border: 0; background: none; color: var(--blue); cursor: pointer; font-size: 12.5px; padding: 0; white-space: nowrap; }
button.link:hover { text-decoration: underline; }
.plan-body { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px 10px; padding: 0 16px 12px; }
.plan.collapsed .plan-body { display: none; }
.plan label { display: flex; flex-direction: column; font-size: 11.5px; color: var(--muted); gap: 3px; min-width: 0; }
.plan .w2 { grid-column: span 2; }
.plan .w4 { grid-column: span 4; }
.plan input, .plan select {
  border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; font: inherit; font-size: 13px;
  color: var(--text); background: #fff; outline: none; min-width: 0;
}
.plan input:focus, .plan select:focus { border-color: var(--blue); }
.plan-actions { display: flex; align-items: center; gap: 8px; justify-content: flex-end; }
.plan-actions .hint { margin-right: auto; }
button.primary { border: 0; background: var(--blue); color: #fff; border-radius: 8px; padding: 7px 14px; font-weight: 700; cursor: pointer; }
button.primary:disabled { background: #9db3d6; cursor: default; }
button.ghost { border: 1px solid var(--line); background: #fff; color: var(--muted); border-radius: 8px; padding: 6px 12px; cursor: pointer; }

.messages { flex: 1; overflow-y: auto; padding: 18px 22px; }
.welcome { text-align: center; margin-top: 26px; }
.welcome h2 { margin: 0 0 8px; font-size: 21px; }
.welcome p { color: var(--muted); margin: 0 0 20px; font-size: 14px; line-height: 1.6; }
.suggestions { display: flex; flex-direction: column; gap: 7px; align-items: stretch; max-width: 560px; margin: 0 auto; }
.suggestions button {
  border: 1px solid var(--line); background: var(--bg); border-radius: 10px; text-align: left;
  padding: 9px 14px; font-size: 13.5px; cursor: pointer; color: var(--text);
}
.suggestions button:hover { border-color: var(--blue); color: var(--blue); background: var(--blue-soft); }

.msg { margin-bottom: 18px; display: flex; }
.msg.user { justify-content: flex-end; }
.msg.user .bubble { background: var(--blue); color: #fff; border-radius: 14px 14px 2px 14px; padding: 10px 14px; max-width: 85%; white-space: pre-wrap; font-size: 14px; }
.msg.assistant .bubble { width: 100%; }

.steps { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.step { font-size: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--muted); border-radius: 12px; padding: 3px 10px; display: inline-flex; align-items: center; gap: 4px; }
.step.done { color: var(--ok); border-color: #cfe8d6; background: var(--ok-soft); }
.step.done::before { content: "✓"; font-weight: 800; }
.step .sub { color: var(--muted); }
.spinner {
  display: inline-block; width: 10px; height: 10px; border: 2px solid #b9c4d3; border-top-color: var(--blue);
  border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -1px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.thinking { color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 8px; }

.answer { line-height: 1.7; font-size: 14.5px; }
.answer h1, .answer h2, .answer h3 { font-size: 15px; margin: 16px 0 6px; color: var(--navy); padding-bottom: 3px; border-bottom: 1px solid var(--line); }
.answer h3:first-child { margin-top: 0; }
.answer p { margin: 6px 0; }
.answer table { border-collapse: collapse; margin: 8px 0; font-size: 12.8px; width: 100%; }
.answer th, .answer td { border: 1px solid var(--line); padding: 5px 7px; text-align: left; vertical-align: top; }
.answer th { background: var(--bg); white-space: nowrap; }
.answer ul, .answer ol { padding-left: 22px; margin: 6px 0; }
.answer code { background: var(--bg); padding: 1px 4px; border-radius: 4px; }
.answer em { color: var(--muted); }
.error { color: #c0392b; background: #fdecea; padding: 10px 12px; border-radius: 8px; white-space: pre-wrap; font-size: 13px; }
.answer-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.answer-actions button { border: 1px solid #c9d8f0; background: var(--blue-soft); color: var(--blue); border-radius: 14px; padding: 4px 12px; font-size: 12.5px; cursor: pointer; }
.answer-actions button:hover { background: #d9e6fa; }

a.cite {
  display: inline-block; font-size: 11px; line-height: 16px; min-width: 18px; text-align: center;
  background: var(--blue-soft); color: var(--blue); border-radius: 8px; padding: 0 5px; margin: 0 1px;
  text-decoration: none; vertical-align: 2px; cursor: pointer; font-weight: 700;
}
a.proj, a.guide {
  font-size: 12.5px; border-radius: 6px; padding: 0 5px; text-decoration: none; cursor: pointer; font-weight: 600;
}
a.proj { background: #fff4e0; color: #8a4b00; }
a.guide { background: #eef7ee; color: #1f6b33; }
a.cite:hover, a.proj:hover, a.guide:hover { filter: brightness(.93); }

.composer { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); flex: none; }
.composer textarea { flex: 1; resize: none; border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; font: inherit; font-size: 14px; max-height: 140px; outline: none; }
.composer textarea:focus { border-color: var(--blue); }
.composer button { border: 0; background: var(--blue); color: #fff; border-radius: var(--radius); padding: 0 18px; font-weight: 700; cursor: pointer; }
.composer button:disabled { background: #9db3d6; cursor: default; }

/* ---------- right ---------- */
.side { flex: 1; display: flex; flex-direction: column; min-width: 0; background: #fff; }
.tabs { display: flex; border-bottom: 1px solid var(--line); flex: none; overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 13px 15px; font-size: 14px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button.active { color: var(--blue); border-bottom-color: var(--blue); font-weight: 700; }
.tabs button.pulse { animation: pulse 1.2s; }
@keyframes pulse { 0% { background: #fff4c2; } 100% { background: none; } }
.cnt { font-size: 11px; background: var(--blue-soft); color: var(--blue); border-radius: 8px; padding: 0 6px; }
.cnt:empty { display: none; }
.tab-body { flex: 1; overflow-y: auto; padding: 16px 20px 30px; position: relative; }
.empty-state { max-width: 560px; margin: 40px auto; text-align: center; color: var(--muted); line-height: 1.7; }
.empty-state h3 { color: var(--text); }
h4.sec { margin: 18px 0 8px; font-size: 14px; color: var(--navy); display: flex; align-items: center; gap: 8px; }
h4.sec:first-child { margin-top: 0; }
h4.sec small { font-weight: 400; color: var(--muted); }

/* roadmap */
.rm-head { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: baseline; margin-bottom: 4px; }
.rm-head h3 { margin: 0; font-size: 18px; }
.rm-meta { color: var(--muted); font-size: 13px; }
.assume { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 14px; }
.chip { font-size: 12px; border-radius: 12px; padding: 3px 10px; background: var(--bg); border: 1px solid var(--line); }
.chip b { color: var(--navy); }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 8px; }
.check { border: 1px solid var(--line); border-left: 4px solid var(--muted); border-radius: 8px; padding: 9px 11px; font-size: 12.8px; line-height: 1.55; }
.check .k { font-size: 12px; color: var(--muted); }
.check .v { font-weight: 800; font-size: 14px; margin: 1px 0 3px; }
.check.ok { border-left-color: var(--ok); } .check.ok .v { color: var(--ok); }
.check.warn { border-left-color: var(--warn); } .check.warn .v { color: var(--warn); }
.check.conditional, .check.check { border-left-color: var(--check); } .check.conditional .v, .check.check .v { color: var(--check); }
.check.info { border-left-color: var(--blue); } .check.info .v { color: var(--blue); }
.refs { margin-top: 4px; display: flex; flex-wrap: wrap; gap: 4px; }
.ref { font-size: 11px; color: var(--blue); background: var(--blue-soft); border-radius: 6px; padding: 1px 6px; cursor: pointer; border: 0; }
.ref:hover { filter: brightness(.94); }

.timeline { position: relative; margin-top: 6px; }
.stage { display: grid; grid-template-columns: 28px 1fr; gap: 10px; position: relative; }
.stage::before { content: ""; position: absolute; left: 13px; top: 28px; bottom: -6px; width: 2px; background: var(--line); }
.stage:last-child::before { display: none; }
.stage .dot { width: 28px; height: 28px; border-radius: 50%; background: var(--navy); color: #fff; font-size: 12.5px; font-weight: 800; display: flex; align-items: center; justify-content: center; z-index: 1; }
.stage.mine .dot { background: var(--blue); box-shadow: 0 0 0 4px var(--blue-soft); }
.stage .box { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; }
.stage.mine .box { border-color: #b9cdee; background: #fafcff; }
.stage .top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.stage .name { font-weight: 800; font-size: 14.5px; }
.stage .who { font-size: 12px; color: var(--muted); }
.stage .dur { margin-left: auto; font-size: 12px; font-weight: 700; color: var(--navy); background: var(--bg); border-radius: 10px; padding: 2px 9px; }
.stage .cond { font-size: 11px; color: var(--warn); background: var(--warn-soft); border-radius: 8px; padding: 1px 7px; }
.gantt { height: 6px; background: var(--bg); border-radius: 3px; margin: 8px 0 6px; position: relative; }
.gantt i { position: absolute; top: 0; bottom: 0; background: #9fbbe6; border-radius: 3px; }
.gantt i.min { background: var(--blue); }
.stage ul { margin: 4px 0 6px; padding-left: 18px; font-size: 13px; line-height: 1.6; }
.stage .row { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; font-size: 12px; margin-top: 4px; }
.stage .row .lbl { color: var(--muted); min-width: 52px; }
.doc-chip { font-size: 12px; border-radius: 6px; padding: 2px 8px; background: #fff4e0; color: #8a4b00; }
.guide-chip { font-size: 12px; border-radius: 6px; padding: 2px 8px; background: #eef7ee; color: #1f6b33; text-decoration: none; }
.guide-chip:hover { text-decoration: underline; }
.mini-btn { border: 1px solid #c9d8f0; background: var(--blue-soft); color: var(--blue); border-radius: 12px; padding: 2px 10px; font-size: 12px; cursor: pointer; }
.mini-btn.strong { background: var(--blue); color: #fff; border-color: var(--blue); font-weight: 700; }
.notice { font-size: 12.5px; color: #6b5300; background: #fff9e3; border: 1px solid #f2e3a6; border-radius: 8px; padding: 8px 12px; margin: 12px 0; line-height: 1.6; }
.total { display: flex; align-items: center; gap: 10px; margin: 14px 0 8px; font-size: 13.5px; }
.total b { font-size: 18px; color: var(--navy); }

/* cases */
.map-wrap { height: 300px; position: relative; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; margin-bottom: 14px; }
#map { position: absolute; inset: 0; }
.legend {
  position: absolute; z-index: 500; right: 8px; bottom: 18px; background: rgba(255, 255, 255, .94);
  border-radius: 8px; padding: 5px 9px; font-size: 11.5px; box-shadow: 0 1px 4px rgba(0, 0, 0, .15);
  display: grid; grid-template-columns: repeat(4, auto); gap: 2px 10px;
}
.legend span { display: flex; align-items: center; gap: 4px; }
.legend i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.callout { font-size: 13px; background: var(--check-soft); color: #4c1d6b; border-radius: 8px; padding: 9px 12px; margin-bottom: 12px; line-height: 1.6; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 9px; }
.card { border: 1px solid var(--line); border-radius: var(--radius); padding: 9px 11px; cursor: pointer; background: #fff; font-size: 12.8px; }
.card:hover { border-color: var(--blue); box-shadow: 0 1px 6px rgba(31, 95, 191, .12); }
.card .name { font-weight: 700; font-size: 13.5px; margin: 4px 0 2px; }
.card .meta { color: var(--muted); }
.tag { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 9px; color: #fff; margin-right: 4px; }
.tag.stage { background: #e9edf2; color: #3c4857; }
.item { border: 1px solid var(--line); border-radius: 10px; margin-bottom: 9px; background: #fff; }
.item header { padding: 9px 12px; display: flex; gap: 8px; align-items: flex-start; cursor: pointer; }
.item header .kind { font-size: 11px; background: var(--blue-soft); color: var(--blue); padding: 1px 7px; border-radius: 8px; white-space: nowrap; margin-top: 2px; }
.item header .kind.study { background: var(--check-soft); color: var(--check); }
.item header .kind.qna { background: #fff4e0; color: #8a4b00; }
.item header .t { font-weight: 700; font-size: 13.5px; flex: 1; }
.item .meta { font-size: 12px; color: var(--muted); padding: 0 12px 8px; }
.item .body { padding: 0 12px 12px; font-size: 13px; white-space: pre-wrap; line-height: 1.65; max-height: 340px; overflow-y: auto; }
.item .body .q { font-weight: 700; color: var(--navy); }
.item .src { font-size: 12px; color: var(--muted); padding: 0 12px 10px; }
.item .src a { color: var(--blue); }
.item.flash { animation: flash 1.2s; }
@keyframes flash { from { background: #fff4c2; } to { background: #fff; } }
.item .num { font-weight: 800; color: var(--blue); }

/* guides */
.guide-row { display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--line); padding: 9px 2px; font-size: 13.5px; }
.guide-row .g-kind { font-size: 11px; color: #1f6b33; background: #eef7ee; border-radius: 8px; padding: 1px 7px; white-space: nowrap; }
.guide-row .g-title { flex: 1; }
.guide-row .g-date { color: var(--muted); font-size: 12px; white-space: nowrap; }
.guide-row a { font-size: 12px; color: var(--blue); white-space: nowrap; text-decoration: none; border: 1px solid #c9d8f0; border-radius: 12px; padding: 2px 10px; }
.guide-row a:hover { background: var(--blue-soft); }

/* drawer (project detail) */
.tab-body.locked { overflow: hidden; }
.drawer { position: absolute; inset: 0; background: #fff; z-index: 1100; padding: 16px 20px 30px; overflow-y: auto; }
.drawer .close { float: right; border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 4px 12px; cursor: pointer; }
.detail h3 { margin: 0 0 4px; font-size: 18px; }
.detail .sub { color: var(--muted); font-size: 13px; margin-bottom: 10px; }
.dtabs { display: flex; gap: 4px; margin: 10px 0; flex-wrap: wrap; }
.dtabs button { border: 1px solid var(--line); background: #fff; border-radius: 6px; padding: 5px 12px; font-size: 13px; cursor: pointer; }
.dtabs button.active { background: var(--navy); color: #fff; border-color: var(--navy); }
table.kv, table.grid { border-collapse: collapse; width: 100%; font-size: 13px; }
table.kv th, table.kv td, table.grid th, table.grid td { border: 1px solid var(--line); padding: 6px 9px; text-align: left; }
table.kv th { background: var(--bg); width: 130px; font-weight: 600; }
table.grid th { background: var(--bg); text-align: center; font-weight: 600; }
table.grid td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.grid tr.zero td { color: #aab2bd; }
.files a { display: block; margin: 4px 0; color: var(--blue); }

/* draft */
.draft-start h3 { margin: 0 0 6px; }
.draft-start p { color: var(--muted); font-size: 13.5px; line-height: 1.6; margin: 0 0 12px; }
.draft-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.draft-btn { text-align: left; border: 1px solid #c9d8f0; background: var(--blue-soft); border-radius: 10px; padding: 12px 14px; cursor: pointer; display: flex; flex-direction: column; gap: 4px; }
.draft-btn b { color: var(--navy); font-size: 14px; }
.draft-btn span { color: var(--muted); font-size: 12.5px; }
.draft-btn:hover { border-color: var(--blue); }
.draft-btn:disabled { opacity: .55; cursor: default; }
.progress { display: flex; align-items: center; gap: 10px; margin: 12px 0; font-size: 12.5px; color: var(--muted); }
.progress .bar { flex: 1; height: 8px; background: var(--bg); border-radius: 4px; overflow: hidden; }
.progress .bar i { display: block; height: 100%; width: 0; background: var(--blue); transition: width .3s; }
.dv-head { border-top: 1px solid var(--line); margin-top: 16px; padding-top: 14px; }
.dv-head h3 { margin: 0 0 4px; font-size: 17px; }
.dv-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 8px 0; font-size: 13px; }
.dv-tools .stat { color: var(--muted); }
.dv-tools .stat b { color: var(--text); }
.dv-tools a { text-decoration: none; }
.dv-tools label { display: flex; align-items: center; gap: 4px; cursor: pointer; margin-left: auto; }
.dv { display: grid; grid-template-columns: 210px 1fr; gap: 14px; margin-top: 8px; }
.toc { position: sticky; top: 0; align-self: start; max-height: calc(100vh - 220px); overflow-y: auto; font-size: 12.5px; border-right: 1px solid var(--line); padding-right: 8px; }
.toc .ch { font-weight: 700; color: var(--navy); margin: 8px 0 3px; font-size: 12px; }
.toc a { display: block; color: var(--text); text-decoration: none; padding: 2px 4px; border-radius: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.toc a.ai { color: var(--blue); font-weight: 700; }
.toc a:hover { background: var(--bg); }
.sec-card { border: 1px solid var(--line); border-radius: 10px; margin-bottom: 10px; }
.sec-card.ai { border-color: #b9cdee; }
.sec-card header { padding: 8px 12px; background: var(--bg); border-radius: 10px 10px 0 0; display: flex; align-items: center; gap: 8px; }
.sec-card.ai header { background: var(--blue-soft); }
.sec-card header .h { font-weight: 800; font-size: 13.5px; flex: 1; }
.sec-card .mode { font-size: 11px; border-radius: 8px; padding: 1px 7px; background: #e9edf2; color: #4c5866; }
.sec-card.ai .mode { background: var(--blue); color: #fff; }
.sec-card .txt { padding: 10px 12px; font-size: 13px; line-height: 1.75; white-space: pre-wrap; }
.sec-card .txt mark { background: #fff1a8; padding: 0 2px; border-radius: 3px; }
.sec-card .chk { margin: 0 12px 10px; background: #fff9e3; border: 1px solid #f2e3a6; border-radius: 8px; padding: 8px 10px; font-size: 12.5px; }
.sec-card .chk b { color: #6b5300; }
.sec-card .chk ul { margin: 4px 0 0; padding-left: 18px; }
.sec-card .orig { margin: 0 12px 10px; font-size: 12px; }
.sec-card .orig summary { cursor: pointer; color: var(--muted); }
.sec-card .orig div { white-space: pre-wrap; color: #59636e; background: var(--bg); border-radius: 6px; padding: 8px 10px; margin-top: 6px; max-height: 260px; overflow-y: auto; }
.chapter-title { font-size: 14px; font-weight: 800; color: var(--navy); margin: 16px 0 8px; }
