:root {
  --bg: #f6f7fb; --panel: #ffffff; --side: #f1f3f8; --line: #e5e7ef; --text: #1d2130; --muted: #6b7185;
  --accent: #3b4fe0; --accent-soft: #e4e8fd; --danger: #d64545; --ok: #22a06b; --warn: #d9a400;
  --code: #f2f3f7; --radius: 12px;
  --shadow: 0 1px 2px rgba(20,24,40,.05), 0 2px 8px rgba(20,24,40,.04);
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #14161d; --panel: #1b1e27; --side: #171a22; --line: #2a2e3b; --text: #e7e9f0; --muted: #959bb0;
    --accent: #7184ff; --accent-soft: #262d55; --code: #232735; --shadow: none; }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: "Pretendard", "Segoe UI", "Malgun Gothic", system-ui, sans-serif; background: var(--bg); color: var(--text); font-size: 14.5px; }
button, input, select, textarea { font: inherit; color: inherit; }
#app { display: flex; height: 100dvh; }

/* sidebar */
#sidebar { width: 270px; flex-shrink: 0; background: var(--side); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 18px 12px; gap: 14px; overflow: hidden; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; padding: 0 6px; }
.brand .icon-btn { margin-left: auto; }
.logo { width: 30px; height: 30px; border-radius: 9px; background: var(--text); color: var(--panel); display: grid; place-items: center; font-weight: 800; }
.side-section { display: flex; flex-direction: column; gap: 4px; min-height: 0; }
.side-section.grow { flex: 1; }
.side-section.grow #convList { overflow-y: auto; flex: 1; }
.side-head { display: flex; justify-content: space-between; align-items: center; font-size: 12.5px; color: var(--muted); padding: 4px 8px; }
.item { display: flex; align-items: center; gap: 8px; padding: 9px 10px; border-radius: 9px; cursor: pointer; min-width: 0; }
.item:hover { background: rgba(127,127,160,.1); }
.item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.item .t { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .sub { font-size: 11.5px; color: var(--muted); font-weight: 400; }
.item .x { opacity: 0; border: 0; background: none; cursor: pointer; color: var(--muted); }
.item:hover .x { opacity: 1; }
.proj-item { flex-direction: column; align-items: stretch; gap: 0; }
.proj-item .p { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.badge { font-size: 10.5px; padding: 2px 6px; border-radius: 5px; font-weight: 600; flex-shrink: 0; }
.b-claude { background: #fbe7dc; color: #b4501f; } .b-codex { background: #dff3ea; color: #137a52; } .b-opencode { background: #e6e6ef; color: #3d3d55; }
.b-dsh { background: #e1e9fd; color: #2a4fc4; }
@media (prefers-color-scheme: dark) { .b-claude { background: #4a2a1b; color: #f5a57a; } .b-codex { background: #163a2d; color: #6fd8a8; } .b-opencode { background: #2c2c3d; color: #c0c0d8; } .b-dsh { background: #1d2a52; color: #93acff; } }

.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex-shrink: 0; }
.dot.on { background: var(--ok); } .dot.run { background: var(--accent); animation: pulse 1.2s infinite; } .dot.err { background: var(--danger); }
@keyframes pulse { 50% { opacity: .3; } }

/* main */
#main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
#topbar { height: 60px; display: flex; align-items: center; gap: 12px; padding: 0 24px; background: var(--panel); border-bottom: 1px solid var(--line); }
.crumbs { display: flex; gap: 10px; align-items: center; min-width: 0; color: var(--muted); }
.crumbs b { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }

#messages { flex: 1; overflow-y: auto; padding: 28px max(24px, calc((100% - 860px) / 2)); }
#welcome h1 { font-size: 28px; margin: 30px 0 8px; }
#welcome p { color: var(--muted); margin: 0 0 24px; }
.agent-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.agent-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; cursor: pointer; box-shadow: var(--shadow); }
.agent-card.sel { border-color: var(--accent); outline: 2px solid var(--accent-soft); }
.agent-card b { display: block; margin-bottom: 4px; } .agent-card small { color: var(--muted); }

.msg { margin-bottom: 22px; min-width: 0; overflow-wrap: anywhere; } /* 긴 경로·주소·인라인 코드가 줄바꿈 없이 화면을 밀어내지 않게 */
#messages { overflow-x: hidden; } /* 코드 블록·표는 각자 안에서 가로 스크롤 */
.msg .meta { font-size: 12px; color: var(--muted); margin-bottom: 6px; display: flex; gap: 8px; align-items: center; }
.msg.user .bubble { background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: 10px; padding: 12px 16px; white-space: pre-wrap; box-shadow: var(--shadow); }
.msg.assistant .body { line-height: 1.65; }
.md p { margin: .5em 0; } .md pre { background: var(--code); padding: 12px; border-radius: 8px; overflow-x: auto; font-size: 13px; }
.md code { background: var(--code); padding: 1px 5px; border-radius: 4px; font-family: Consolas, "D2Coding", monospace; font-size: .92em; }
.md pre code { background: none; padding: 0; }
.md table { border-collapse: collapse; margin: .6em 0; display: block; overflow-x: auto; }
.md th, .md td { border: 1px solid var(--line); padding: 6px 10px; text-align: left; vertical-align: top; }
.md th { background: var(--code); }
.md h1, .md h2, .md h3 { margin: .9em 0 .4em; line-height: 1.3; } .md h1 { font-size: 1.3em; } .md h2 { font-size: 1.15em; } .md h3 { font-size: 1.05em; }
.md ul, .md ol { padding-left: 1.4em; }
.tool { border: 1px solid var(--line); background: var(--panel); border-radius: 8px; margin: 6px 0; font-size: 12.5px; }
.tool summary { cursor: pointer; padding: 7px 10px; display: flex; gap: 8px; align-items: center; list-style: none; }
.tool summary::-webkit-details-marker { display: none; }
.tool summary .nm { font-weight: 600; } .tool summary .pv { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; font-family: Consolas, monospace; }
.tool pre { margin: 0; padding: 8px 10px; border-top: 1px solid var(--line); white-space: pre-wrap; word-break: break-all; max-height: 320px; overflow: auto; font-size: 12px; background: var(--code); }
.tool.err { border-color: var(--danger); }
.thinking { color: var(--muted); font-size: 13px; border-left: 2px solid var(--line); padding-left: 10px; margin: 6px 0; white-space: pre-wrap; }
.error-box { background: rgba(214,69,69,.08); border: 1px solid rgba(214,69,69,.35); color: var(--danger); border-radius: 8px; padding: 10px 12px; white-space: pre-wrap; font-size: 13px; margin: 6px 0; }
.usage { font-size: 11.5px; color: var(--muted); margin-top: 6px; }
.typing { display: inline-flex; gap: 4px; padding: 8px 0; } .typing i { width: 6px; height: 6px; background: var(--muted); border-radius: 50%; animation: pulse 1s infinite; } .typing i:nth-child(2) { animation-delay: .2s; } .typing i:nth-child(3) { animation-delay: .4s; }

/* refine */
#refinePanel { margin: 0 max(24px, calc((100% - 860px) / 2)); background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius) var(--radius) 0 0; padding: 14px 16px; max-height: 45vh; overflow-y: auto; box-shadow: var(--shadow); }
.refine-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.issue { padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.issue b { color: var(--accent); } .issue span { color: var(--muted); }
.improved { background: var(--code); border-radius: 8px; padding: 12px; white-space: pre-wrap; margin: 10px 0; }

/* composer */
#composer { padding: 8px max(24px, calc((100% - 860px) / 2)) calc(14px + env(safe-area-inset-bottom)); }
select, input:not([type]) { border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 7px 9px; max-width: 200px; }
select.mini { padding: 2px 4px; font-size: 12px; }

.btn { border: 1px solid var(--line); background: var(--panel); padding: 8px 14px; border-radius: 9px; cursor: pointer; font-weight: 600; white-space: nowrap; }
.btn:hover { filter: brightness(.97); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.block { width: 100%; padding: 11px; }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn { border: 0; background: none; cursor: pointer; font-size: 16px; padding: 6px 8px; border-radius: 8px; color: var(--muted); }
.icon-btn:hover { background: rgba(127,127,160,.12); }
.link { border: 0; background: none; color: var(--accent); cursor: pointer; font-size: 12.5px; }
.muted { color: var(--muted); font-size: 13px; }
.empty { color: var(--muted); font-size: 12.5px; padding: 6px 10px; }
.empty .link { padding: 4px 0 0; text-align: left; white-space: normal; }
.side-head > span { white-space: nowrap; }

dialog { border: 1px solid var(--line); border-radius: 14px; padding: 22px; width: min(440px, 92vw); background: var(--panel); color: var(--text); }
dialog::backdrop { background: rgba(10,12,20,.4); }
dialog h3 { margin: 0 0 14px; }
dialog label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 12px; }
dialog input { width: 100%; max-width: none !important; margin-top: 4px; }
dialog label.fld select, dialog label.fld textarea { display: block; width: 100%; margin-top: 4px; font: inherit; font-size: 14px; color: var(--text);
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; resize: vertical; }
/* 추가 폴더 */
.dir-ask { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.dir-ask > span { flex: 1; min-width: 0; }
.dir-ask-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.dir-ask-row { display: flex; align-items: center; gap: 6px; cursor: pointer; overflow-wrap: anywhere; min-width: 0; }
.dir-ask-row input { flex: none; margin: 0; }
.dir-ask-note { font-size: 12px; overflow-wrap: anywhere; }
.dir-ask .act { font-size: 12px; color: #fff; background: var(--accent); border: 0; border-radius: 999px; padding: 4px 12px; cursor: pointer; }
.dir-ask .act:disabled { opacity: .5; cursor: default; }
.dir-base { font-size: 12.5px; display: flex; gap: 6px; align-items: center; margin-bottom: 8px; overflow-wrap: anywhere; }
.dir-list { border: 1px solid var(--line); border-radius: 10px; max-height: 40vh; overflow-y: auto; }
.dir-item { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-bottom: 1px solid var(--line); font-size: 13px; }
.dir-item:last-child { border-bottom: 0; }
.dir-item span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
#dirsBtn .count[hidden] { display: none; }
/* 교차 검토 */
.msg-acts { display: flex; gap: 6px; margin-top: 6px; }
.msg-acts .act { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); background: none;
  border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; cursor: pointer; }
.msg-acts .act:hover { color: var(--accent); border-color: var(--accent); }
.msg-acts .act svg { width: 13px; height: 13px; }
.msg.review .body { border-left: 3px solid var(--accent); padding-left: 12px; }
.rv-tag { color: var(--accent); font-weight: 600; margin-right: 4px; }
.rv-tag svg { width: 13px; height: 13px; }
.rv-verdict { font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 999px; margin-right: 6px; border: 1px solid currentColor; }
.rv-verdict.pass { color: #16a34a; }
.rv-verdict.fix { color: #d97706; }
.rv-verdict.redo { color: #dc2626; }
.ap-list { display: flex; flex-direction: column; gap: 6px; max-height: 55vh; overflow-y: auto; margin-bottom: 10px; }
.ap-list { overflow-x: hidden; }
/* 실행 중 권한 질문 카드 */
.perm-card { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin: 8px 0; font-size: 13px; min-width: 0; }
.perm-card.wait { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 18%, transparent); }
.perm-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.perm-head svg { width: 15px; height: 15px; color: var(--accent); flex: none; }
.perm-sum { font-family: ui-monospace, Consolas, monospace; font-size: 12px; color: var(--muted); overflow-wrap: anywhere; min-width: 0; flex: 1 1 200px; }
.perm-st { font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 999px; border: 1px solid currentColor; }
.perm-st.ok { color: #16a34a; } .perm-st.bad { color: #dc2626; }
.perm-card details summary { cursor: pointer; color: var(--muted); font-size: 12px; margin-top: 6px; }
.perm-card pre { max-height: 240px; overflow: auto; font-size: 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.perm-acts { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.perm-acts .btn { font-size: 13px; padding: 6px 12px; }
#permSel[data-v="ask"] { color: var(--accent); }
dialog label.ap-item { display: flex; align-items: flex-start; gap: 8px; margin: 0; color: var(--text); font-size: 13px; line-height: 1.45; padding: 8px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; overflow-wrap: anywhere; min-width: 0; }
dialog label.ap-item input { width: auto; margin: 3px 0 0; flex: none; }
.ap-item > span:last-child { min-width: 0; }
.ap-g { flex: none; font-size: 11px; font-weight: 600; padding: 0 6px; border-radius: 999px; border: 1px solid currentColor; }
.ap-g.redo { color: #dc2626; } .ap-g.fix { color: #d97706; } .ap-g.minor { color: #6b7280; }
.row-end { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.err { color: var(--danger); font-size: 13px; min-height: 1em; }

dialog.wide { width: min(680px, 94vw); }
.fb-bar { display: flex; gap: 8px; }
.fb-bar input { flex: 1; max-width: none !important; margin: 0 !important; font-family: Consolas, monospace; font-size: 13px; }
.fb-bar .btn { padding: 6px 12px; }
.fb-quick { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0; }
.chip { border: 1px solid var(--line); background: var(--bg); border-radius: 999px; padding: 4px 10px; font-size: 12.5px; cursor: pointer; }
.chip:hover { border-color: var(--accent); color: var(--accent); }
.fb-list { height: min(46vh, 380px); overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; }
.fb-item { display: flex; gap: 8px; align-items: center; padding: 8px 12px; cursor: pointer; border-bottom: 1px solid var(--line); }
.fb-item:last-child { border-bottom: 0; }
.fb-item:hover { background: var(--accent-soft); }
.fb-item .t { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fb-item .arr { color: var(--muted); }
.fb-item.hid { opacity: .6; }
.b-proj { background: var(--accent-soft); color: var(--accent); }
.fb-foot { display: flex; justify-content: space-between; align-items: center; margin: 8px 0 12px; font-size: 12.5px; }
.fb-hidden { display: flex !important; gap: 6px; align-items: center; margin: 0 !important; }
.fb-hidden input { width: auto !important; margin: 0 !important; }
.imp-head { display: flex; justify-content: space-between; align-items: center; margin: 6px 0; font-size: 13px; }
.imp-list { max-height: 46vh; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; }
dialog label.imp { display: flex; gap: 10px; align-items: center; padding: 9px 12px; border-bottom: 1px solid var(--line); cursor: pointer; margin: 0; color: var(--text); font-size: 14px; }
dialog .imp input { width: auto; margin: 0; flex-shrink: 0; }
.imp:last-child { border-bottom: 0; }
.imp:hover { background: rgba(127,127,160,.06); }
.imp.done { opacity: .5; cursor: default; }
.imp-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.imp-main .p { font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.imp-meta { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; justify-content: flex-end; max-width: 45%; }
.imp-meta .sub { font-size: 11.5px; color: var(--muted); margin-left: 4px; white-space: nowrap; }
.imp-etc { margin-top: 10px; } .imp-etc summary { cursor: pointer; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.model-note { margin-top: 8px; font-size: 12px; color: var(--warn); }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--panel); padding: 10px 18px; border-radius: 10px; z-index: 50; font-size: 13.5px; }
.qr { display: flex; justify-content: center; margin: 14px 0 8px; }
.qr img, .qr canvas { background: #fff; padding: 10px; border-radius: 10px; }
.steps { padding-left: 1.2em; line-height: 1.7; }
.only-mobile { display: none; }
#scrim { display: none; }
@media (max-width: 800px) {
  .only-mobile { display: inline-block; }
  #sidebar { position: fixed; inset: 0 auto 0 0; z-index: 20; transform: translateX(-100%); transition: transform .2s; box-shadow: 4px 0 20px rgba(0,0,0,.15); }
  #app.side-open #sidebar { transform: none; }
  #app.side-open #scrim { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.3); z-index: 10; }
  #topbar { padding: 0 10px; }
  #messages { padding: 18px 14px; }
  #composer { padding-left: 12px; padding-right: 12px; }
  #refinePanel { margin: 0 8px; }
}

/* 남은 사용량 */
#usageBox { border-top: 1px solid var(--line); padding-top: 10px; flex-shrink: 0; }
#usageList { display: flex; flex-direction: column; gap: 10px; padding: 0 8px; }
.usage .u-head { display: flex; justify-content: space-between; align-items: baseline; font-size: 12.5px; margin-bottom: 4px; }
.usage .sub, .u-note { font-size: 11px; color: var(--muted); }
.u-row { display: grid; grid-template-columns: 36px 1fr 36px; align-items: center; gap: 6px; font-size: 12px; }
.u-l { color: var(--muted); }
.u-bar { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
.u-bar i { display: block; height: 100%; background: var(--accent); border-radius: 3px; transition: width .4s; }
.u-bar i.warn { background: var(--warn); } .u-bar i.bad { background: var(--danger); }
.u-p { text-align: right; font-variant-numeric: tabular-nums; } .u-p.warn { color: var(--warn); } .u-p.bad { color: var(--danger); font-weight: 600; }
.u-reset { padding-left: 42px; margin: 1px 0 3px; }
.usage-pill { border: 1px solid var(--line); background: var(--panel); color: var(--muted); border-radius: 999px; padding: 3px 10px; font-size: 12px; cursor: pointer; font-variant-numeric: tabular-nums; }
.usage-pill.warn { color: var(--warn); border-color: var(--warn); } .usage-pill.bad { color: var(--danger); border-color: var(--danger); }

/* 예약 보내기 */
.notice { background: var(--accent-soft); color: var(--accent); border-radius: 8px; padding: 8px 12px; font-size: 13px; margin: 6px 0; }
#queueBox { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.queued { align-self: flex-end; max-width: min(640px, 92%); opacity: .9; }
.queued .meta { font-size: 12px; color: var(--accent); margin-bottom: 4px; text-align: right; }
.queued .bubble { border: 1.5px dashed var(--accent); background: var(--panel); border-radius: 14px; padding: 10px 14px; white-space: pre-wrap; }
.q-actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 4px; font-size: 12px; }
.link.danger { color: var(--danger); }
dialog label.radio { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 10px 0; font-size: 14px; }
dialog label.radio input[type=radio] { width: auto; margin: 0; }
dialog label.radio input[type=datetime-local] { width: auto; }
.u-model { display: flex; justify-content: space-between; font-size: 11.5px; margin: 6px 0 2px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#usageBox { max-height: 45vh; overflow-y: auto; }

/* 결과물 패널 */
#preview { width: 46%; min-width: 360px; max-width: 900px; flex-shrink: 0; display: flex; flex-direction: column; background: var(--panel); border-left: 1px solid var(--line); }
#preview[hidden] { display: none; }
.pv-head { height: 60px; display: flex; align-items: center; gap: 6px; padding: 0 12px; border-bottom: 1px solid var(--line); flex-shrink: 0; }
.pv-head select { flex: 1; min-width: 0; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
.pv-head .icon-btn { width: auto; padding: 0 8px; font-size: 13px; }
#pvBody { flex: 1; min-height: 0; overflow: auto; position: relative; }
#pvBody iframe { width: 100%; height: 100%; border: 0; background: #fff; display: block; }
#pvBody .empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.pv-img { padding: 20px; display: grid; place-items: center; min-height: 100%; background: repeating-conic-gradient(var(--line) 0 25%, transparent 0 50%) 0 0 / 16px 16px; }
.pv-img img { max-width: 100%; height: auto; box-shadow: var(--shadow); }
.pv-md { padding: 20px 26px; }
.pv-code { margin: 0; padding: 14px 0; font: 12.5px/1.55 ui-monospace, Consolas, monospace; white-space: pre; background: var(--code); min-height: 100%; counter-reset: ln; }
.pv-code .ln { display: inline-block; width: 44px; padding-right: 12px; text-align: right; color: var(--muted); user-select: none; opacity: .7; }
.pv-link { margin-left: auto; border: 1px solid var(--accent); color: var(--accent); background: transparent; border-radius: 6px; padding: 1px 8px; font-size: 12px; cursor: pointer; flex-shrink: 0; }
.btn.small { padding: 4px 10px; font-size: 12.5px; }
@media (max-width: 1100px) { #preview { width: 50%; min-width: 300px; } #app.pv-open #sidebar { display: none; } }
@media (max-width: 800px) {
  #preview { position: fixed; inset: 0; width: auto; min-width: 0; max-width: none; z-index: 30; border-left: 0; }
  .pv-head { height: 54px; padding: 0 8px; }
  #app.pv-open #sidebar { display: flex; }
}
.usage-pill { white-space: nowrap; }
.fb-bar .btn { white-space: nowrap; flex-shrink: 0; }

/* 첨부 파일 */
#attachList { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.att-chip { display: flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--bg); border-radius: 10px; padding: 4px 6px 4px 8px; font-size: 12.5px; max-width: 260px; }
.att-chip img { width: 28px; height: 28px; object-fit: cover; border-radius: 6px; }
.att-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.att-chip small { color: var(--muted); flex-shrink: 0; }
.att-chip.up { opacity: .6; } .att-chip.bad { border-color: var(--danger); } .att-chip.bad small { color: var(--danger); }
.att-chip .x { border: 0; background: none; cursor: pointer; color: var(--muted); padding: 0 2px; }
#composer.drop { outline: 2px dashed var(--accent); outline-offset: -6px; }
.att-row { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; margin-bottom: 6px; }
.att-img img { max-width: 220px; max-height: 180px; border-radius: 10px; border: 1px solid var(--line); display: block; object-fit: cover; }
.att-file { display: flex; align-items: center; gap: 6px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--text); text-decoration: none; font-size: 12.5px; max-width: 260px; }
.att-file span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .att-file small { color: var(--muted); }
@media (max-width: 800px) { .att-img img { max-width: 160px; max-height: 140px; } }

/* ===== 아이콘 + 간결한 입력창 (공식 앱 스타일) ===== */
[hidden] { display: none !important; } /* 아래 display 지정이 hidden 속성을 덮어쓰지 않게 */
.icon-btn.only-mobile { display: none; }
@media (max-width: 800px) { .icon-btn.only-mobile { display: inline-flex; } }
.ic { width: 18px; height: 18px; flex-shrink: 0; vertical-align: middle; }
.ic.inline { width: 15px; height: 15px; vertical-align: -2px; color: var(--accent); }
.with-ic { display: inline-flex; align-items: center; gap: 6px; }
.with-ic .ic { width: 15px; height: 15px; }
h3.with-ic { display: flex; } h3.with-ic .ic { width: 19px; height: 19px; color: var(--accent); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn .ic { width: 16px; height: 16px; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; position: relative; width: 34px; height: 34px; padding: 0; }
.icon-btn .ic { width: 18px; height: 18px; }
.icon-btn.sm { width: 26px; height: 26px; border-radius: 7px; } .icon-btn.sm .ic { width: 15px; height: 15px; }
.icon-btn.bordered { border: 1px solid var(--line); background: var(--panel); width: 36px; height: 36px; flex-shrink: 0; }
.icon-btn .count { position: absolute; top: 2px; right: 1px; min-width: 15px; height: 15px; padding: 0 4px; border-radius: 8px; background: var(--accent); color: #fff; font-size: 10px; font-weight: 700; line-height: 15px; }
.icon-btn .count:empty { display: none; }
.icon-btn.spinning .ic, .ic.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.side-acts { display: inline-flex; align-items: center; gap: 2px; }
.top-actions { gap: 2px; } .top-actions .dot { margin-left: 6px; }
.item .x .ic { width: 14px; height: 14px; }
.chip.with-ic .ic { width: 14px; height: 14px; color: var(--muted); }
.fb-item .muted-ic { color: var(--muted); } .fb-item .arr { width: 16px; height: 16px; color: var(--muted); margin-left: auto; }
.error-box { display: flex; gap: 8px; align-items: flex-start; } .error-box .ic { width: 16px; height: 16px; margin-top: 1px; }
.notice { display: flex; gap: 8px; align-items: center; } .notice .ic { width: 15px; height: 15px; }
.tool summary .ic.st { width: 15px; height: 15px; } .ic.st.ok { color: var(--ok); } .ic.st.bad { color: var(--danger); } .ic.st.spin { color: var(--accent); } .ic.st.cut { color: var(--muted, #999); }
.pv-link { display: inline-flex; align-items: center; gap: 4px; } .pv-link .ic { width: 13px; height: 13px; }
.att-file .ic, .att-chip > .ic { width: 16px; height: 16px; color: var(--muted); }
.att-chip .x .ic { width: 13px; height: 13px; }
.queued .meta.with-ic { display: flex; justify-content: flex-end; }
.thinking { font-style: italic; }

/* 입력 상자: 글 + 아래 한 줄 도구 */
.cbox { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 10px 10px 8px 14px; box-shadow: 0 1px 8px rgba(20, 24, 40, .05); transition: border-color .15s; }
.cbox:focus-within { border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); }
#input { display: block; width: 100%; resize: none; border: 0; outline: none; background: transparent; padding: 4px 2px 6px; min-height: 28px; max-height: 40vh; line-height: 1.5; font-size: 15px; }
.cbar { display: flex; align-items: center; gap: 2px; margin-top: 4px; }
.cbar .chips { flex: 1; min-width: 0; display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; padding: 0 2px; mask-image: linear-gradient(90deg, #000 calc(100% - 18px), transparent); }
.cbar .chips::-webkit-scrollbar { display: none; }
.ib { flex-shrink: 0; width: 34px; height: 34px; border: 0; border-radius: 10px; background: none; color: var(--muted); display: grid; place-items: center; cursor: pointer; }
.ib:hover { background: rgba(127,127,160,.12); color: var(--text); }
.ib:disabled { opacity: .45; cursor: default; }
.send { flex-shrink: 0; width: 34px; height: 34px; margin-left: 4px; border: 0; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; cursor: pointer; }
.send .ic { width: 18px; height: 18px; stroke-width: 2.4; }
.send:disabled { opacity: .45; }
.send.stop { background: var(--text); color: var(--panel); } .send.stop .ic { width: 14px; height: 14px; }
.send.queue { background: var(--accent-soft); color: var(--accent); } /* 작업 중: 대기열에 추가 */
.send.queue .ic { stroke-width: 2.2; }
.chip-sel { flex-shrink: 0; max-width: 180px; border: 0; background: transparent; color: var(--muted); font-size: 12.5px; font-weight: 500; padding: 6px 18px 6px 8px; border-radius: 8px; cursor: pointer; text-overflow: ellipsis; white-space: nowrap;
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23959bb0' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 4px center; background-size: 11px; }
.chip-sel:hover, .chip-sel:focus { background-color: rgba(127,127,160,.12); color: var(--text); outline: none; }
.chip-sel:disabled { opacity: .55; cursor: default; background-image: none; padding-right: 8px; }
#agentSel { color: var(--text); font-weight: 600; }
#permSel[data-v="full"] { color: var(--danger); font-weight: 600; }
#permSel[data-v="auto"] { color: var(--accent); font-weight: 600; }
.model-note { margin: 6px 4px 0; }
#refinePanel { margin-bottom: 8px; border-radius: var(--radius); }
#topbar, .pv-head { height: 52px; }
/* 사용량: 기본은 접혀서 한 줄 요약만, 누르면 펼침 */
#usageBox { padding-top: 6px; }
.usage-head { cursor: pointer; user-select: none; border-radius: 8px; gap: 6px; }
.usage-head:hover { background: rgba(127,127,160,.08); }
.usage-head > .with-ic { flex-shrink: 0; }
.u-chev { transition: transform .15s; color: var(--muted); }
#usageBox.open .u-chev { transform: rotate(90deg); }
.u-mini { flex: 1; min-width: 0; display: flex; gap: 8px; justify-content: flex-end; overflow: hidden; white-space: nowrap; font-size: 11.5px; font-variant-numeric: tabular-nums; color: var(--muted); }
.u-mini .warn { color: var(--warn); } .u-mini .bad { color: var(--danger); font-weight: 600; }
#usageBox.open .u-mini { display: none; }
#usageList { padding-top: 4px; }
#topbar { gap: 8px; } .crumbs { font-size: 14px; gap: 6px; } .crumbs .sep { opacity: .5; }
.pv-head .icon-btn { width: 32px; padding: 0; }
@media (max-width: 800px) {
  #composer { padding: 6px 10px calc(10px + env(safe-area-inset-bottom)); }
  .cbox { border-radius: 16px; padding: 8px 6px 6px 12px; }
  .chip-sel { max-width: 160px; padding: 6px 16px 6px 6px; }
  /* 폰: 설정 칩은 옆으로 숨기지 말고 줄바꿈해서 전부 보이게 → 그 아래 줄에 첨부(왼쪽) · 다듬기 · 예약 · 보내기(오른쪽) */
  .cbar { flex-wrap: wrap; }
  .cbar .chips { order: -1; flex: 1 1 100%; flex-wrap: wrap; overflow: visible; mask-image: none; -webkit-mask-image: none; margin: 0 0 2px -6px; padding: 0; }
  #refineBtn { margin-left: auto; }
  .ib { width: 32px; height: 32px; } .send { width: 34px; height: 34px; }
  .top-actions .icon-btn { width: 32px; height: 32px; }
}

/* ---------- 외부 접속 ---------- */
[hidden] { display: none !important; }
.brand-acts { margin-left: auto; display: flex; align-items: center; gap: 2px; }
.brand-acts .icon-btn { margin-left: 0; }
.ext-banner { display: flex; gap: 8px; align-items: center; padding: 7px 24px; font-size: 12.5px; background: #fff7e6; color: #8a5a00; border-bottom: 1px solid #f0dca8; }
.ext-banner .ic { width: 15px; height: 15px; flex-shrink: 0; }
.ext-tag { font-size: 10.5px; font-weight: 700; color: #8a5a00; background: #ffedc2; border-radius: 999px; padding: 1px 7px; }
@media (prefers-color-scheme: dark) {
  .ext-banner { background: #2c2413; color: #eacb78; border-color: #4a3c1a; }
  .ext-tag { background: #4a3c1a; color: #eacb78; }
}

/* ---------- 설정 ---------- */
dialog.settings { width: min(640px, 94vw); max-height: 88vh; overflow-y: auto; }
.set-sec { border-top: 1px solid var(--line); padding: 12px 0; }
.set-sec:first-of-type { border-top: 0; padding-top: 0; }
.set-sec h4 { margin: 0 0 6px; font-size: 14px; }
.set-row { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.set-row input { flex: 1; min-width: 0; }
.chk { display: flex !important; gap: 8px; align-items: flex-start; font-size: 13.5px; color: var(--text) !important; margin: 6px 0 !important; cursor: pointer; }
.chk input { width: auto !important; margin: 3px 0 0 !important; }
.chk.dis { opacity: .65; cursor: default; }
#extSessions .sess { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin: 6px 0; font-size: 13px; }
#extProjects { max-height: 180px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; margin-top: 6px; }
#extOtpQr { margin: 12px 0 6px; }
#extProjects .empty { padding: 4px 0; }
.ok { color: var(--ok); }

/* ---------- 외부 로그인 ---------- */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100dvh; padding: 20px; }
.login-card { width: min(380px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 28px 26px; box-shadow: var(--shadow); }
.login-card .logo { margin: 0 auto 10px; width: 44px; height: 44px; }
.login-card h1 { font-size: 22px; text-align: center; margin: 0 0 4px; }
.login-card > p { text-align: center; margin: 0 0 18px; }
.login-card label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.login-card input { width: 100%; margin-top: 5px; padding: 10px 11px; font-size: 15px; }
.login-card .err { min-height: 18px; }
.login-card .small { font-size: 11.5px; line-height: 1.5; margin: 16px 0 0; text-align: left; }

/* 사이드바 정리: 새 대화 버튼 작게, 프로젝트 목록은 짧게(스크롤), 대화 목록에 공간 몰아주기 */
#sidebar { gap: 10px; }
.btn.new-conv { padding: 6px 10px; font-size: 13px; border-radius: 8px; justify-content: flex-start; }
.btn.new-conv .ic { width: 14px; height: 14px; }
.proj-section { flex-shrink: 0; }
#projectList { max-height: 22vh; overflow-y: auto; }
.proj-item { padding: 5px 10px; }
.proj-item .p { display: none; } /* 경로는 마우스를 올리면 보여요 */
#convList .item { padding: 7px 10px; }
.item .sub { overflow: hidden; text-overflow: ellipsis; }
/* 대화 목록의 플랫폼 표시: 박스 대신 설명 줄의 색 글자 */
.ag { font-weight: 600; }
.ag-claude { color: #b4501f; } .ag-codex { color: #137a52; } .ag-opencode { color: #3d3d55; } .ag-dsh { color: #2a4fc4; }
@media (prefers-color-scheme: dark) { .ag-claude { color: #f5a57a; } .ag-codex { color: #6fd8a8; } .ag-opencode { color: #c0c0d8; } .ag-dsh { color: #93acff; } }
/* 사용량: 펼쳤을 때 머리줄(접기)은 고정, 아래 목록만 스크롤 */
#usageBox { overflow: hidden; }
#usageList { overflow-y: auto; min-height: 0; flex: 1; }
.usage-head { flex-shrink: 0; }
#usageBox { max-height: 38vh; }

/* ===================== 디자인 정리 v2: 글꼴 · 색 · 여백 ===================== */
@font-face { font-family: "Pretendard Variable"; font-weight: 45 920; font-style: normal; font-display: swap;
  src: local("Pretendard Variable"), url("/vendor/fonts/PretendardVariable.woff2") format("woff2-variations"); }
:root {
  --bg: #ffffff; --panel: #ffffff; --side: #f7f7f8; --line: #e9e9ec; --text: #1a1a1e; --muted: #73737d;
  --accent: #3f5bd9; --accent-soft: #eceffc; --hover: rgba(24,24,32,.05); --sel: rgba(24,24,32,.08);
  --code: #f4f4f6; --radius: 12px;
  --shadow: 0 1px 2px rgba(20,20,30,.04);
  --sans: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Segoe UI", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  --mono: "Cascadia Mono", "Cascadia Code", "SF Mono", ui-monospace, Consolas, "D2Coding", "Pretendard Variable", monospace;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #18181b; --panel: #1f1f23; --side: #131316; --line: #2b2b31; --text: #ececef; --muted: #9a9aa4;
    --accent: #8fa2ff; --accent-soft: #262b47; --hover: rgba(255,255,255,.05); --sel: rgba(255,255,255,.09); --code: #26262b; --shadow: none; }
}
body { font-family: var(--sans); font-size: 14px; line-height: 1.5; letter-spacing: -.006em; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
* { scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--muted) 35%, transparent) transparent; }
:focus-visible { outline: 2px solid color-mix(in srgb, var(--accent) 60%, transparent); outline-offset: 1px; }
b, strong { font-weight: 650; }

/* 사이드바 */
#sidebar { width: 264px; padding: 14px 10px 10px; gap: 12px; }
.brand { font-size: 15.5px; font-weight: 700; letter-spacing: -.02em; gap: 8px; padding: 2px 6px 2px 8px; }
.logo { width: 24px; height: 24px; border-radius: 7px; }
.btn.new-conv { background: var(--panel); color: var(--text); border-color: var(--line); font-weight: 550; padding: 7px 10px; box-shadow: var(--shadow); }
.btn.new-conv:hover { filter: none; background: var(--hover); }
.btn.new-conv .ic { color: var(--muted); }
.side-head { font-size: 11.5px; font-weight: 600; letter-spacing: .01em; padding: 2px 4px 2px 10px; min-height: 26px; }
.side-section { gap: 2px; }
.item { padding: 6px 10px; border-radius: 8px; font-size: 13.5px; gap: 8px; }
.item:hover { background: var(--hover); }
.item.active { background: var(--sel); color: var(--text); font-weight: 600; }
.item .sub { font-size: 11.5px; line-height: 1.4; margin-top: 1px; letter-spacing: 0; }
.proj-item { padding: 5px 10px; }
.proj-item .with-ic .ic { color: var(--muted); }
#convList .item { padding: 7px 10px; align-items: flex-start; }
#convList .dot { margin-top: 7px; width: 7px; height: 7px; }
#convList .dot:not(.run):not(.err) { display: none; } /* 쉬는 대화는 점 없이 제목만 */
.ag { font-weight: 550; }
select.mini { appearance: none; -webkit-appearance: none; border: 0; background: transparent; color: var(--muted); font-size: 11.5px; font-weight: 500; padding: 3px 16px 3px 6px; border-radius: 6px; cursor: pointer; max-width: 110px; text-overflow: ellipsis;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23959bb0' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 3px center; background-size: 10px; }
select.mini:hover { background-color: var(--hover); color: var(--text); }
select.mini option { color: var(--text); background: var(--panel); }
.icon-btn:hover, .ib:hover, .chip-sel:hover, .chip-sel:focus, .usage-head:hover { background-color: var(--hover); }
.icon-btn:hover { color: var(--text); }
.usage-head { padding: 4px 4px 4px 6px; }
.u-bar { height: 4px; }

/* 상단 */
#topbar, .pv-head { height: 48px; }
#topbar { padding: 0 16px 0 20px; background: var(--bg); }
.crumbs { font-size: 13.5px; }
.crumbs b { font-weight: 600; }
.usage-pill { font-size: 11.5px; padding: 3px 9px; background: transparent; }

/* 대화 */
#messages { padding-top: 24px; }
.msg { margin-bottom: 26px; }
.msg .meta { font-size: 11.5px; margin-bottom: 6px; }
.msg.user { display: flex; flex-direction: column; align-items: flex-end; }
.msg.user .bubble { max-width: min(680px, 88%); background: var(--side); border: 0; border-radius: 16px 16px 4px 16px; padding: 10px 14px; box-shadow: none; line-height: 1.6; }
@media (prefers-color-scheme: dark) { .msg.user .bubble { background: var(--panel); } }
.msg.assistant .body { line-height: 1.72; font-size: 14.5px; }
.md p { margin: .65em 0; }
.md h1, .md h2, .md h3, .md h4 { margin: 1.3em 0 .45em; line-height: 1.35; font-weight: 700; letter-spacing: -.015em; }
.md h1 { font-size: 1.28em; } .md h2 { font-size: 1.14em; } .md h3, .md h4 { font-size: 1.02em; }
.md > :first-child { margin-top: 0; }
.md ul, .md ol { padding-left: 1.5em; margin: .5em 0; }
.md li { margin: .22em 0; } .md li::marker { color: var(--muted); }
.md code, .tool summary .pv, .perm-sum, .fb-bar input, .pv-code { font-family: var(--mono); }
.md code { font-size: .86em; padding: .12em .38em; border-radius: 5px; letter-spacing: 0; }
.md pre { padding: 12px 14px; border-radius: 10px; font-size: 12.5px; line-height: 1.6; border: 1px solid var(--line); }
.md pre code { font-size: 1em; padding: 0; }
.md table { font-size: 13.5px; }
.md th { font-weight: 600; }
.md th, .md td { padding: 6px 12px; }
.md a { color: var(--accent); text-decoration: none; } .md a:hover { text-decoration: underline; }
.badge { font-size: 10.5px; font-weight: 600; padding: 2px 7px; border-radius: 999px; letter-spacing: 0; }
.tool { border-radius: 9px; background: transparent; }
.tool summary { padding: 6px 10px; }
.thinking { font-style: normal; }
.usage { font-variant-numeric: tabular-nums; }
.msg-acts .act { padding: 4px 11px; }
.msg.review .body { border-left-width: 2px; padding-left: 14px; }

/* 입력창 */
.cbox { border-radius: 16px; box-shadow: 0 2px 12px rgba(20,20,30,.06); }
#input { font-size: 14.5px; line-height: 1.55; }
#input::placeholder { color: color-mix(in srgb, var(--muted) 75%, transparent); }
.chip-sel { font-size: 12px; }
.send { width: 32px; height: 32px; }

/* 버튼 · 대화상자 */
.btn { font-size: 13.5px; border-radius: 8px; padding: 7px 14px; }
.btn.new-conv { padding: 7px 10px; font-size: 13px; }
dialog { border-radius: 16px; padding: 22px 24px; box-shadow: 0 16px 48px rgba(10,10,20,.18); }
dialog h3 { font-size: 16px; letter-spacing: -.015em; }
#welcome h1 { font-size: 24px; font-weight: 700; letter-spacing: -.03em; }
.agent-card { box-shadow: none; transition: border-color .15s, background .15s; }
.agent-card:hover { background: var(--hover); }
@media (max-width: 800px) {
  #topbar { padding: 0 10px; }
  #sidebar { width: min(300px, 86vw); }
  .msg.user .bubble { max-width: 92%; }
}
