/* ============================================
 * Jabis Chat - 루트(/) 챗봇 화면 스타일
 * 다크 기본, body.theme-light 로 라이트 전환
 * ============================================ */
:root {
    --bg: #1f2023;
    --bg-side: #17181a;
    --bg-elev: #26272b;
    --bg-input: #2a2b30;
    --bg-hover: #2c2d32;
    --bg-active: #34353b;
    --border: #34353a;
    --border-strong: #45464d;
    --text: #e8e8ec;
    --text-2: #b4b5bc;
    --muted: #8a8b93;
    --accent: #a78bfa;
    --accent-2: #8b5cf6;
    --accent-soft: rgba(167, 139, 250, .14);
    --user-bubble: #2f3036;
    --code-bg: #141517;
    --danger: #f87171;
    --ok: #4ade80;
    --shadow: 0 8px 30px rgba(0, 0, 0, .35);
    --radius: 14px;
    --sb-w: 272px;
}
body.theme-light {
    --bg: #ffffff;
    --bg-side: #f7f7f8;
    --bg-elev: #ffffff;
    --bg-input: #ffffff;
    --bg-hover: #ececf0;
    --bg-active: #e4e4ea;
    --border: #e3e3e8;
    --border-strong: #cfcfd6;
    --text: #1d1d22;
    --text-2: #45464d;
    --muted: #7a7b84;
    --accent: #7c3aed;
    --accent-2: #6d28d9;
    --accent-soft: rgba(124, 58, 237, .10);
    --user-bubble: #f0f0f4;
    --code-bg: #f6f6f8;
    --danger: #dc2626;
    --shadow: 0 8px 30px rgba(0, 0, 0, .12);
}

[ng-cloak] { display: none !important; }
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
    background: var(--bg);
    color: var(--text);
    font-family: "Pretendard", -apple-system, BlinkMacSystemFont, "Segoe UI", "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
    font-size: 15px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
}
button { font: inherit; color: inherit; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }
a { color: var(--accent); }

/* ---------- 공통 버튼 ---------- */
.icon-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 34px; height: 34px; border: 0; border-radius: 8px;
    background: transparent; color: var(--text-2); transition: background .12s, color .12s;
}
.icon-btn:hover, .icon-btn.on { background: var(--bg-hover); color: var(--text); }
.btn-primary {
    height: 42px; border: 0; border-radius: 10px; background: var(--accent-2); color: #fff; font-weight: 600;
}
.btn-primary:disabled { opacity: .6; }
.btn-ghost, .btn-danger {
    height: 36px; padding: 0 16px; border-radius: 9px; border: 1px solid var(--border-strong); background: transparent;
}
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.mini-btn {
    height: 26px; padding: 0 10px; border-radius: 7px; border: 1px solid var(--border); background: transparent;
    color: var(--muted); font-size: 12px;
}
.mini-btn:hover { color: var(--text); background: var(--bg-hover); }

/* ---------- 브랜드 ---------- */
/* 로고: 말풍선 + J 마크(chat/logo.svg) + 워드마크 "Jabis"(굵게) "Chat"(가늘게) */
.brand {
    display: inline-flex; align-items: center; gap: 9px; font-size: 18px; line-height: 1;
    color: var(--text); text-decoration: none; letter-spacing: -.4px;
}
.brand-logo { width: 28px; height: 28px; flex: 0 0 auto; display: block; }
.brand-nm { font-weight: 800; }
.brand-sub { margin-left: -4px; font-weight: 400; color: var(--text-2); }
.brand-lg { font-size: 24px; gap: 11px; }
.brand-lg .brand-logo { width: 36px; height: 36px; }
.brand-lg .brand-sub { margin-left: -5px; }

/* ---------- 로그인 ---------- */
.login-wrap { height: 100%; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card {
    width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 12px;
    padding: 32px 28px; border: 1px solid var(--border); border-radius: 18px; background: var(--bg-elev); box-shadow: var(--shadow);
}
.login-sub { margin: 0 0 8px; color: var(--muted); font-size: 14px; }
.login-input {
    height: 44px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--bg-input); outline: none;
}
.login-input:focus { border-color: var(--accent); }
.login-err { color: var(--danger); font-size: 13px; }
.login-save { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--text-2); cursor: pointer; user-select: none; }
.login-save input { width: 15px; height: 15px; margin: 0; accent-color: var(--accent); cursor: pointer; }

/* ---------- 레이아웃 ---------- */
.app { display: flex; height: 100%; }
.sidebar {
    width: var(--sb-w); flex: 0 0 var(--sb-w); display: flex; flex-direction: column;
    background: var(--bg-side); border-right: 1px solid var(--border); transition: margin-left .2s ease;
    min-height: 0;
}
body.sb-closed .sidebar { margin-left: calc(-1 * var(--sb-w)); }
.sb-backdrop { display: none; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* ---------- 사이드바 ---------- */
.sb-head { height: 56px; display: flex; align-items: center; padding: 0 18px; flex: 0 0 auto; }
.sb-actions { display: flex; align-items: center; gap: 4px; padding: 6px 12px 10px; }
.sb-new {
    flex: 1; display: flex; align-items: center; gap: 10px; height: 38px; padding: 0 12px;
    border: 0; border-radius: 10px; background: transparent; font-weight: 600; text-align: left;
}
.sb-new:hover { background: var(--bg-hover); }
.sb-search { padding: 0 12px 10px; }
.sb-search input {
    width: 100%; height: 36px; padding: 0 12px; border-radius: 9px; border: 1px solid var(--border-strong);
    background: var(--bg-input); outline: none; font-size: 14px;
}
.sb-search input:focus { border-color: var(--accent); }
.sb-scroll { flex: 1; overflow-y: auto; padding: 0 8px 12px; min-height: 0; }
.sb-scroll::-webkit-scrollbar { width: 6px; }
.sb-scroll::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
.sb-section { margin-top: 6px; }
.sb-label {
    display: flex; align-items: center; gap: 6px; padding: 8px 10px 6px; font-size: 12.5px; font-weight: 600;
    color: var(--muted); user-select: none; cursor: default;
}
.sb-label .badge {
    margin-left: auto; min-width: 22px; height: 18px; padding: 0 7px; border-radius: 9px; background: var(--bg-active);
    color: var(--text-2); font-size: 11px; line-height: 18px; text-align: center;
}
.fold { display: inline-block; font-size: 10px; transition: transform .15s; }
.fold.folded { transform: rotate(-90deg); }
.sb-group { padding: 12px 10px 4px; font-size: 11.5px; color: var(--muted); }
.sb-empty { padding: 10px; font-size: 13px; color: var(--muted); }
.nav-list { list-style: none; margin: 0; padding: 0; }
/* 즐겨찾기·최근 사용 항목: 제목(▾ 즐겨찾기) 글자 위치에 맞춰 들여쓰기 → 섹션 제목과 구분 */
.nav-list.sub .nav-item { padding-left: 26px; }
.nav-item {
    position: relative; display: flex; align-items: center; gap: 8px; height: 34px; padding: 0 10px;
    border-radius: 9px; color: var(--text-2); cursor: pointer; font-size: 14px; user-select: none;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text); }
.nav-item.active { background: var(--bg-active); color: var(--text); }
.nav-item.grp { color: var(--text); font-weight: 600; font-size: 13.5px; }
.caret { flex: 0 0 10px; font-size: 10px; color: var(--muted); transition: transform .15s; }
.caret.open { transform: rotate(90deg); }
.ni-ico { flex: 0 0 auto; display: inline-flex; color: var(--muted); }
.nav-item.grp .ni-ico { color: var(--accent); }
.ni-title { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ni-cnt {
    flex: 0 0 auto; min-width: 18px; height: 18px; padding: 0 6px; border-radius: 9px; background: var(--bg-active);
    color: var(--muted); font-size: 11px; line-height: 18px; text-align: center; font-weight: 500;
}
.ni-cnt.wait { background: rgba(250, 204, 21, .16); color: #eab308; }
.ni-cnt.err { background: rgba(248, 113, 113, .16); color: var(--danger); }
.grp-run { display: inline-flex; }
/* 최근 사용 */
.ni-time { flex: 0 0 auto; font-size: 11px; color: var(--muted); }
.nav-item.recent:hover .ni-time { color: var(--text-2); }
.sb-label { cursor: pointer; }
.sb-label:hover { color: var(--text-2); }
/* 그룹 안 항목: 들여쓰기 + 세로 안내선 (그룹 화살표 아래로 이어짐) */
.tree-guide { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--border-strong); pointer-events: none; }
.nav-item.proj .ni-title { font-size: 13.5px; }
.grp-add {
    flex: 0 0 22px; width: 22px; height: 22px; margin-right: -4px; padding: 0; border: 0; border-radius: 6px;
    display: inline-flex; align-items: center; justify-content: center;
    background: transparent; color: var(--muted); opacity: .55; transition: opacity .12s, background .12s, color .12s;
}
.nav-item.grp:hover .grp-add { opacity: 1; }
.grp-add:hover { background: var(--accent-soft); color: var(--accent); }
.ni-edit {
    flex: 1; min-width: 0; height: 28px; padding: 0 8px; border-radius: 6px; border: 1px solid var(--accent);
    background: var(--bg-input); outline: none; font-size: 14px;
}
.ni-acts { display: none; gap: 2px; }
.nav-item:hover .ni-acts { display: inline-flex; }
.ni-acts button {
    width: 24px; height: 24px; border: 0; border-radius: 6px; background: transparent; color: var(--muted);
    font-size: 13px; line-height: 1; padding: 0;
}
.ni-acts button:hover { background: var(--bg-active); color: var(--text); }
.ni-acts button.fav { color: #facc15; }
.nav-item.proj .ni-acts button.fav { display: inline-block; }

.sb-foot { position: relative; padding: 10px 12px; border-top: 1px solid var(--border); flex: 0 0 auto; }
.user-btn {
    display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 10px; cursor: pointer;
}
.user-btn:hover { background: var(--bg-hover); }
.avatar {
    width: 30px; height: 30px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
    background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 14px;
}
.user-nm { flex: 1; font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-nm small { font-weight: 400; color: var(--muted); }
.um-label { padding: 6px 12px 2px; font-size: 11.5px; color: var(--muted); }
.um-check { display: inline-block; width: 18px; color: var(--accent); }
.um-sep { height: 1px; margin: 6px 4px; background: var(--border); }
.user-menu {
    position: absolute; left: 12px; right: 12px; bottom: 58px; padding: 6px; border-radius: 12px;
    background: var(--bg-elev); border: 1px solid var(--border); box-shadow: var(--shadow); z-index: 20;
}
.user-menu a, .user-menu button {
    display: block; width: 100%; padding: 9px 12px; border: 0; border-radius: 8px; background: transparent;
    text-align: left; color: var(--text); text-decoration: none; font-size: 14px;
}
.user-menu a:hover, .user-menu button:hover { background: var(--bg-hover); }

/* ---------- 상단바 ---------- */
.topbar {
    height: 56px; flex: 0 0 auto; display: flex; align-items: center; gap: 8px; padding: 0 14px;
    border-bottom: 1px solid var(--border);
}
.sb-open-btn { display: none; }
body.sb-closed .sb-open-btn { display: inline-flex; }
.top-title { flex: 1; min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-right { display: flex; gap: 4px; }

/* ---------- 본문 스테이지 ---------- */
.stage { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.stage.dragging::after {
    content: "여기에 파일을 놓으면 첨부됩니다"; position: absolute; inset: 12px; display: flex; align-items: center; justify-content: center;
    border: 2px dashed var(--accent); border-radius: 18px; background: var(--accent-soft); color: var(--accent);
    font-weight: 600; z-index: 30; pointer-events: none;
}
.msgs { flex: 1; min-height: 0; overflow-y: auto; scroll-behavior: auto; }
.msgs::-webkit-scrollbar { width: 8px; }
.msgs::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }

.stage.empty { justify-content: center; overflow-y: auto; padding: 24px 16px 40px; }
.stage.empty .msgs { flex: 0 0 auto; overflow: visible; }

.welcome { text-align: center; margin-bottom: 26px; }
.welcome h1 { margin: 0; font-size: 30px; font-weight: 700; letter-spacing: -.5px; }
.welcome p { margin: 6px 0 0; color: var(--text-2); font-size: 15px; }
.spark { margin-right: 4px; }

.msg-col { max-width: 820px; margin: 0 auto; padding: 24px 20px 12px; }
.loading-msgs { color: var(--muted); font-size: 14px; text-align: center; padding: 30px 0; }
.msg { margin-bottom: 22px; }
.msg-user { display: flex; justify-content: flex-end; }
.bubble {
    position: relative;
    max-width: 78%; padding: 11px 16px; border-radius: 18px 18px 4px 18px; background: var(--user-bubble);
}
/* 대기 중 작업 수정 아이콘: 말풍선 위쪽 오른편에 떠 있다가 마우스를 올리면 보임 */
.q-edit {
    position: absolute; top: -13px; right: 12px; z-index: 2;
    display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 9px; border-radius: 12px;
    border: 1px solid var(--border-strong); background: var(--bg-elev); color: var(--text-2);
    font-size: 12px; cursor: pointer; box-shadow: 0 2px 8px rgba(0, 0, 0, .18);
    opacity: 0; transform: translateY(3px); transition: opacity .12s, transform .12s;
}
.bubble:hover .q-edit, .q-edit:focus-visible { opacity: 1; transform: none; }
.q-edit:hover { color: var(--accent); border-color: var(--accent); }
@media (hover: none) { .q-edit { opacity: .85; transform: none; } }   /* 터치 기기: 마우스 오버가 없어 항상 표시 */
.user-txt { white-space: pre-wrap; word-break: break-word; }
.att-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.att-chip {
    display: inline-flex; align-items: center; gap: 6px; max-width: 260px; padding: 3px 10px; border-radius: 8px;
    background: var(--bg-active); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.att-chip small { color: var(--muted); }
.att-x { border: 0; background: transparent; color: var(--muted); font-size: 16px; line-height: 1; padding: 0 0 0 2px; }
.att-x:hover { color: var(--danger); }

/* 이미지 첨부 섬네일 */
.att-row { align-items: flex-end; }
.att-thumb {
    position: relative; width: 64px; height: 64px; flex: 0 0 64px; border-radius: 10px; overflow: hidden;
    border: 1px solid var(--border-strong); background: var(--bg-active);
}
.att-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; }
.att-thumb .att-x {
    position: absolute; top: 3px; right: 3px; width: 18px; height: 18px; padding: 0; border-radius: 50%;
    background: rgba(0, 0, 0, .65); color: #fff; font-size: 13px; line-height: 18px; text-align: center;
}
.att-thumb .att-x:hover { background: var(--danger); color: #fff; }
.att-thumb.sent { width: 120px; height: 90px; flex-basis: 120px; }

/* 메시지 우클릭 메뉴 */
.ctx-menu {
    position: fixed; z-index: 130; min-width: 190px; padding: 5px; border-radius: 12px;
    background: var(--bg-elev); border: 1px solid var(--border-strong); box-shadow: var(--shadow);
    animation: ctxIn .1s ease-out;
}
@keyframes ctxIn { from { opacity: 0; transform: scale(.97); } to { opacity: 1; transform: none; } }
.ctx-menu button {
    display: flex; align-items: center; gap: 10px; width: 100%; height: 32px; padding: 0 10px; border: 0; border-radius: 8px;
    background: transparent; color: var(--text); font-size: 13.5px; text-align: left; white-space: nowrap;
}
.ctx-menu button svg { color: var(--muted); flex: 0 0 auto; }
.ctx-menu button:hover { background: var(--bg-hover); }
.ctx-menu button:hover svg { color: var(--accent); }
.ctx-sep { height: 1px; margin: 4px 6px; background: var(--border); }

/* 이미지 크게 보기 */
.img-preview {
    position: fixed; inset: 0; z-index: 120; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 10px; padding: 24px; background: rgba(0, 0, 0, .82); cursor: zoom-out;
}
.img-preview img { max-width: 100%; max-height: calc(100% - 40px); border-radius: 8px; box-shadow: 0 10px 40px rgba(0, 0, 0, .5); cursor: default; }
.img-preview-name { color: #e8e8ec; font-size: 13px; }
.img-preview-name span { color: #9a9ba1; margin-left: 6px; }

.bot { display: flex; gap: 14px; }
/* 답변 아이콘: 로고와 같은 말풍선+J 를 선으로만, 테마 색에 맞춘 차분한 원형 */
.bot-avatar {
    flex: 0 0 28px; width: 28px; height: 28px; border-radius: 50%; margin-top: 1px;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg-hover); border: 1px solid var(--border-strong); color: var(--accent);
}
.bot-avatar svg { display: block; }
.bot-body { flex: 1; min-width: 0; }
.msg-err .md { color: var(--danger); }
.bot-actions { display: flex; align-items: center; gap: 8px; margin-top: 8px; opacity: .85; }
.model-tag { font-size: 11.5px; color: var(--muted); }
.tool-status {
    display: inline-flex; align-items: center; gap: 8px; margin-bottom: 8px; padding: 4px 12px; border-radius: 999px;
    background: var(--accent-soft); color: var(--accent); font-size: 13px;
}
.dot-spin {
    width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--accent-soft); border-top-color: var(--accent);
    animation: spin .8s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }
.thinking { display: inline-flex; gap: 5px; padding: 10px 0; }
.thinking span { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite ease-in-out; }
.thinking span:nth-child(2) { animation-delay: .15s; }
.thinking span:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

/* ---------- 프로젝트 대화 ---------- */
.tt-grp { color: var(--muted); font-weight: 500; }
/* 상단: 프로젝트명(넘치면 말줄임) + 실행 모드(차분한 색, 클릭 시 메뉴) + 모델 */
.top-title.proj { display: flex; align-items: center; gap: 8px; overflow: visible; }
.tt-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-title .model-tag { flex: 0 0 auto; font-weight: 400; }
.mode-wrap { position: relative; flex: 0 0 auto; }
.mode-pill {
    display: inline-flex; align-items: center; gap: 3px; height: 24px; padding: 0 6px 0 9px; border-radius: 7px;
    border: 1px solid var(--border); background: var(--bg-hover); color: var(--text-2);
    font-size: 11.5px; font-weight: 600; letter-spacing: .2px;
}
.mode-pill:hover, .mode-pill.open { border-color: var(--border-strong); color: var(--text); }
.mode-pill svg { color: var(--muted); transition: transform .15s; }
.mode-pill.open svg { transform: rotate(90deg); }
.mode-menu {
    position: absolute; top: calc(100% + 6px); left: 0; z-index: 60; width: 300px; max-width: calc(100vw - 24px); padding: 5px; border-radius: 12px;
    background: var(--bg-elev); border: 1px solid var(--border-strong); box-shadow: var(--shadow); animation: ctxIn .1s ease-out;
}
.mode-menu button {
    display: flex; align-items: flex-start; gap: 8px; width: 100%; padding: 8px 10px; border: 0; border-radius: 8px;
    background: transparent; text-align: left; font-weight: 400;
}
.mode-menu button:hover { background: var(--bg-hover); }

/* 상단 ⋯ 더보기 메뉴 (오류 삭제 / 대기 삭제) */
.more-wrap { position: relative; display: inline-flex; }
.more-menu {
    position: absolute; top: calc(100% + 6px); right: 0; z-index: 60; width: 180px; padding: 5px; border-radius: 12px;
    background: var(--bg-elev); border: 1px solid var(--border-strong); box-shadow: var(--shadow); animation: ctxIn .1s ease-out;
}
.more-menu button {
    display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 10px; border: 0; border-radius: 8px;
    background: transparent; color: var(--text); text-align: left; font-size: 13.5px; cursor: pointer;
}
.more-menu button:hover:not(:disabled) { background: rgba(239, 68, 68, .12); color: #ef4444; }
.more-menu button:disabled { opacity: .4; cursor: default; }
.more-menu { width: 260px; }
.more-sep { height: 1px; margin: 5px 4px; background: var(--border); }
.more-proj { display: flex; align-items: center; gap: 8px; padding: 6px 10px 2px; font-size: 13px; }
.mp-label { color: var(--text-2); }
.mp-no { font-weight: 700; color: var(--accent); font-family: "JetBrains Mono", Consolas, monospace; }
.mp-copy { margin-left: auto; height: 22px; padding: 0 8px; border: 1px solid var(--border-strong); border-radius: 6px; background: transparent; color: var(--text-2); font-size: 12px; cursor: pointer; }
.mp-copy:hover { color: var(--accent); border-color: var(--accent); }
.more-help { padding: 4px 10px 6px; font-size: 11.5px; line-height: 1.5; color: var(--muted); }
.more-help code { font-family: "JetBrains Mono", Consolas, monospace; font-size: 11px; padding: 0 3px; border-radius: 4px; background: var(--bg-active); color: var(--text-2); }
/* 입력 중 "@번호" 중계 안내 */
.relay-hint { font-size: 12px; color: var(--accent); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 360px; }
.relay-hint.bad { color: var(--danger); }
.more-menu .mm-cnt { margin-left: auto; min-width: 20px; padding: 0 6px; border-radius: 9px; background: var(--bg-active); color: var(--text-2); font-size: 11px; line-height: 18px; text-align: center; }
.mm-check { flex: 0 0 14px; color: var(--accent); font-size: 13px; line-height: 20px; }
.mm-txt { display: flex; flex-direction: column; min-width: 0; }
.mm-t { font-size: 13.5px; font-weight: 600; color: var(--text); }
.mm-d { font-size: 12px; color: var(--muted); white-space: normal; word-break: keep-all; }
.mode-menu button.on .mm-t { color: var(--accent); }
.older { text-align: center; margin: 0 0 18px; }
.turn { margin-bottom: 8px; }
.q-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; font-size: 11.5px; color: var(--muted); }
.q-time { margin-left: auto; }
.st { padding: 0 7px; border-radius: 6px; font-size: 11px; font-weight: 600; line-height: 18px; background: var(--bg-active); color: var(--text-2); }
.st-done { background: rgba(74, 222, 128, .14); color: var(--ok); }
.st-running { background: var(--accent-soft); color: var(--accent); }
.st-waiting, .st-pending { background: rgba(250, 204, 21, .16); color: #eab308; }
.st-error { background: rgba(248, 113, 113, .16); color: var(--danger); }
.st-hold { background: rgba(148, 163, 184, .18); color: #94a3b8; }
.queue-note.hold { border: 1px dashed var(--border-strong); background: transparent; }
.queue-note { display: inline-block; padding: 6px 12px; border-radius: 10px; background: var(--bg-hover); color: var(--text-2); font-size: 13.5px; }
.elapsed { color: var(--muted); font-size: 12px; }
.proj-hint { max-width: 780px; margin: 0 auto 6px; padding: 0 6px; font-size: 12px; color: var(--muted); }
.proj-hint b { color: var(--text-2); font-weight: 600; }
.q-count { font-size: 12px; color: #eab308; padding: 2px 8px; border-radius: 8px; background: rgba(250, 204, 21, .14); }
.mini-btn.danger { color: var(--danger); border-color: rgba(248, 113, 113, .4); }
.send-btn + .send-btn { margin-left: -4px; }

/* ---------- 접기 / 펼치기 (답변은 기본 접힘) ---------- */
.foldable.folded {
    max-height: 9.6em; overflow: hidden;
    -webkit-mask-image: linear-gradient(to bottom, #000 55%, transparent);
    mask-image: linear-gradient(to bottom, #000 55%, transparent);
}
.user-txt.foldable.folded { max-height: 7.5em; }
.fold-btn {
    display: block; margin: 4px 0 0 auto; padding: 0; border: 0; background: transparent; color: var(--accent); font-size: 12px;
}
.md.foldable.folded.streaming > *:last-child::after { display: none; }

/* ---------- 마크다운 ---------- */
.md { word-break: break-word; }
.md > *:first-child { margin-top: 0; }
.md > *:last-child { margin-bottom: 0; }
.md p { margin: 0 0 12px; }
.md h1, .md h2, .md h3, .md h4 { margin: 20px 0 10px; line-height: 1.35; }
.md h1 { font-size: 22px; } .md h2 { font-size: 19px; } .md h3 { font-size: 17px; } .md h4 { font-size: 15px; }
.md ul, .md ol { margin: 0 0 12px; padding-left: 24px; }
.md li { margin: 3px 0; }
.md li > ul, .md li > ol { margin: 4px 0; }
.md blockquote { margin: 0 0 12px; padding: 4px 14px; border-left: 3px solid var(--accent); color: var(--text-2); }
.md hr { border: 0; border-top: 1px solid var(--border); margin: 18px 0; }
.md code {
    font-family: "JetBrains Mono", Consolas, "D2Coding", monospace; font-size: 13px; padding: 1px 6px; border-radius: 5px;
    background: var(--bg-active);
}
.md .code { margin: 0 0 14px; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--code-bg); }
.md .code-h {
    display: flex; align-items: center; justify-content: space-between; padding: 6px 12px; font-size: 12px; color: var(--muted);
    border-bottom: 1px solid var(--border);
}
.md .code-copy { border: 0; background: transparent; color: var(--muted); font-size: 12px; padding: 2px 6px; border-radius: 5px; }
.md .code-copy:hover { color: var(--text); background: var(--bg-hover); }
.md pre { margin: 0; padding: 12px 14px; overflow-x: auto; }
.md pre code { padding: 0; background: transparent; font-size: 13px; line-height: 1.55; }
.md .tbl-wrap { overflow-x: auto; margin: 0 0 14px; }
.md table { border-collapse: collapse; min-width: 50%; font-size: 14px; }
.md th, .md td { border: 1px solid var(--border); padding: 7px 12px; text-align: left; vertical-align: top; }
.md th { background: var(--bg-hover); font-weight: 600; }
.md a { word-break: break-all; }
.md.streaming > *:last-child::after {
    content: ""; display: inline-block; width: 7px; height: 15px; margin-left: 3px; vertical-align: -2px;
    background: var(--accent); animation: caret 1s steps(2) infinite;
}
@keyframes caret { 50% { opacity: 0; } }

/* ---------- 입력창 ---------- */
.composer-wrap { position: relative; flex: 0 0 auto; padding: 8px 20px 14px; }

/* 맨 아래로 버튼: 입력창 오른쪽 위에 떠 있음 */
.to-bottom {
    position: absolute; top: -48px; right: max(24px, calc(50% - 386px)); z-index: 5;
    width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--border-strong);
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--bg-elev); color: var(--text-2); box-shadow: var(--shadow);
    animation: toBottomIn .15s ease-out;
}
.to-bottom:hover { color: var(--text); background: var(--bg-hover); }
.to-bottom-dot {
    position: absolute; top: 1px; right: 1px; width: 10px; height: 10px; border-radius: 50%;
    background: var(--accent-2); border: 2px solid var(--bg-elev);
}
@keyframes toBottomIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.stage.empty .composer-wrap { padding: 0; }
.composer {
    max-width: 780px; margin: 0 auto; padding: 12px 12px 10px 16px; border-radius: 18px;
    background: var(--bg-input); border: 1px solid var(--border-strong); transition: border-color .15s, box-shadow .15s;
}
.composer.focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.composer .att-row.pending { margin-bottom: 8px; }
.composer textarea {
    display: block; width: 100%; min-height: 48px; max-height: 240px; padding: 2px 4px 6px 0; border: 0; outline: none;
    background: transparent; resize: none; line-height: 1.55;
}
.composer textarea::placeholder { color: var(--muted); }
.composer-bar { display: flex; align-items: center; gap: 10px; }
.attach-btn {
    position: relative; display: inline-flex; align-items: center; gap: 6px; padding: 5px 8px; margin-left: -8px; border-radius: 8px;
    color: var(--text-2); font-size: 13px; cursor: pointer; overflow: hidden;
}
.attach-btn:hover { background: var(--bg-hover); color: var(--text); }
.attach-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; font-size: 0; }
.hint { font-size: 12px; color: var(--muted); }
.attach-btn + .attach-btn { margin-left: -6px; }

/* download 폴더 아이콘 버튼 */
.dl-btn {
    position: relative; width: 32px; height: 30px; margin-left: -4px; border: 0; border-radius: 8px;
    display: inline-flex; align-items: center; justify-content: center; background: transparent; color: var(--text-2);
}
.dl-btn:hover:not(:disabled), .dl-btn.on { background: var(--bg-hover); color: var(--accent); }
.dl-btn:disabled { opacity: .35; cursor: default; }

/* download 파일 목록 패널 (본문 오른쪽) */
.main { position: relative; }
.dl-panel {
    position: absolute; top: 56px; right: 0; bottom: 0; z-index: 25; width: 340px; max-width: 100%;
    display: flex; flex-direction: column; background: var(--bg-side); border-left: 1px solid var(--border);
    box-shadow: -12px 0 30px rgba(0, 0, 0, .25); animation: dlIn .18s ease-out;
}
@keyframes dlIn { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.dl-head { display: flex; align-items: center; gap: 2px; padding: 10px 8px 6px 16px; }
.dl-title { flex: 1; display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 14px; }
.dl-title svg { color: var(--accent); }
.dl-cnt { padding: 0 7px; border-radius: 9px; background: var(--bg-active); color: var(--text-2); font-size: 11px; line-height: 18px; font-weight: 500; }
.dl-path {
    margin: 0 16px 8px; font-size: 11px; color: var(--muted); font-family: "JetBrains Mono", Consolas, monospace;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; direction: rtl; text-align: left;
}
.dl-body { flex: 1; min-height: 0; overflow-y: auto; padding-bottom: 12px; }
.dl-sec + .dl-sec { margin-top: 6px; border-top: 1px solid var(--border); padding-top: 8px; }
.dl-sec-h { display: flex; align-items: center; gap: 8px; padding: 4px 16px 4px; }
.dl-sec-nm { font-size: 12.5px; font-weight: 700; color: var(--text-2); font-family: "JetBrains Mono", Consolas, monospace; }
.dl-list { list-style: none; margin: 0; padding: 0 8px; }
.dl-item {
    display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; color: var(--text); text-decoration: none;
}
.dl-item:hover { background: var(--bg-hover); }
.dl-ico { flex: 0 0 auto; font-size: 18px; }
.dl-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.dl-name { font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dl-meta { font-size: 11.5px; color: var(--muted); }
.dl-get { flex: 0 0 auto; display: inline-flex; color: var(--muted); }
.dl-item:hover .dl-get { color: var(--accent); }
.dl-row { display: flex; align-items: center; }
.dl-row .dl-item { flex: 1; min-width: 0; }
.dl-del {
    flex: 0 0 auto; width: 28px; height: 28px; margin-left: 2px; border: 0; border-radius: 8px;
    display: inline-flex; align-items: center; justify-content: center; background: transparent; color: var(--muted); opacity: .45;
}
.dl-row:hover .dl-del { opacity: 1; }
.dl-del:hover:not(:disabled) { background: rgba(239, 68, 68, .14); color: #ef4444; }
.dl-del:disabled { opacity: .3; cursor: default; }
.dl-del.on { opacity: 1; background: rgba(239, 68, 68, .14); color: #ef4444; }
/* 삭제 확인 작은 팝업 (휴지통 버튼 왼쪽) */
.dl-row { position: relative; }
.dl-pop {
    position: absolute; right: 32px; top: 50%; transform: translateY(-50%); z-index: 2;
    display: flex; align-items: center; gap: 4px; padding: 4px 4px 4px 10px; border-radius: 8px;
    background: var(--bg-side); border: 1px solid var(--border); box-shadow: 0 4px 14px rgba(0, 0, 0, .25);
    font-size: 12px; white-space: nowrap; animation: dlPopIn .12s ease-out;
}
@keyframes dlPopIn { from { opacity: 0; transform: translateY(-50%) translateX(6px); } to { opacity: 1; transform: translateY(-50%); } }
.dl-pop-msg { color: var(--text-2); margin-right: 2px; }
.dl-pop-btn {
    height: 22px; padding: 0 8px; border: 0; border-radius: 6px; font-size: 12px;
    background: var(--bg-active); color: var(--text-2); cursor: pointer;
}
.dl-pop-btn:hover { background: var(--bg-hover); }
.dl-pop-btn.danger { background: #ef4444; color: #fff; }
.dl-pop-btn.danger:hover { background: #dc2626; }
.dl-empty { padding: 6px 16px 10px; color: var(--muted); font-size: 12.5px; }
.dl-path { margin-bottom: 4px; }
.spin { animation: spin .8s linear infinite; }
/* 넓은 화면: 패널이 열리면 본문을 그만큼 비켜서 입력창/전송 버튼이 가려지지 않게 */
@media (min-width: 1100px) {
    .main.dl-open .stage { margin-right: 340px; }
}
/* 답변 속 파일 경로 링크 (서버가 프로젝트 폴더에 있다고 확인한 것만) */
.md a.file-link, .md code.file-link {
    color: var(--accent); cursor: pointer; text-decoration: underline dotted; text-underline-offset: 3px;
}
.md a.file-link:hover, .md code.file-link:hover { text-decoration-style: solid; }
.md code.file-link::before, .md a.file-link::before { content: "\1F4C4"; margin-right: 3px; font-size: .9em; text-decoration: none; display: inline-block; }

/* 파일 보기 패널 (파일 목록 패널과 같은 자리, 더 넓게) */
.fv-panel { width: 560px; }
.fv-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.fv-panel .dl-title { min-width: 0; }
.fv-panel a.icon-btn { display: inline-flex; align-items: center; justify-content: center; color: inherit; }
.fv-body { flex: 1; min-height: 0; overflow: auto; padding: 4px 16px 16px; }
.fv-pre {
    margin: 0; padding: 12px; border-radius: 8px; background: var(--bg-active); color: var(--text);
    font-family: "JetBrains Mono", Consolas, monospace; font-size: 12.5px; line-height: 1.55; white-space: pre-wrap; word-break: break-word;
}
.fv-md { font-size: 14px; }
.fv-img { display: block; max-width: 100%; height: auto; border-radius: 8px; border: 1px solid var(--border); }
.fv-note { margin: 0 0 8px; padding: 6px 10px; border-radius: 6px; background: rgba(234, 179, 8, .14); color: #b45309; font-size: 12px; }
@media (min-width: 1100px) {
    .main.fv-open .stage { margin-right: 560px; }
}
.attach-btn.busy { opacity: .5; pointer-events: none; }
.upload-status { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; margin-left: -2px; }
.up-spin {
    width: 14px; height: 14px; border-radius: 50%; box-sizing: border-box;
    border: 2px solid rgba(127, 127, 127, .3); border-top-color: var(--accent); animation: spin .7s linear infinite;
}
.upload-status.done { color: #22c55e; font-size: 13px; font-weight: 700; }
.spacer { flex: 1; }
.model-sel {
    height: 30px; padding: 0 8px; border-radius: 8px; border: 1px solid transparent; background: transparent;
    color: var(--text-2); font-size: 13px; outline: none; cursor: pointer;
}
.model-sel:hover { background: var(--bg-hover); }
.model-sel option { background: var(--bg-elev); color: var(--text); }
.send-btn {
    width: 36px; height: 36px; border-radius: 50%; border: 0; display: inline-flex; align-items: center; justify-content: center;
    background: var(--accent-2); color: #fff; transition: opacity .15s, transform .1s;
}
.send-btn:hover:not(:disabled) { transform: scale(1.05); }
.send-btn:disabled { background: var(--bg-active); color: var(--muted); cursor: default; }
.send-btn.stop { background: var(--text); color: var(--bg); }
.disclaimer { max-width: 780px; margin: 6px auto 0; text-align: center; font-size: 11.5px; color: var(--muted); }

/* ---------- 빠른 작업 ---------- */
.quick { max-width: 780px; width: 100%; margin: 18px auto 0; }
.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.chip {
    display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: 999px;
    border: 1px solid var(--border-strong); background: transparent; font-size: 13.5px; color: var(--text);
}
.chip:hover { background: var(--bg-hover); }
.examples-head { margin: 30px 0 10px; font-size: 13px; color: var(--muted); }
.examples { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.example {
    min-width: 0;
    display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; text-align: left; border-radius: 12px;
    border: 1px solid var(--border); background: var(--bg-elev);
}
.example:hover { border-color: var(--border-strong); background: var(--bg-hover); }
.ex-title { font-weight: 600; font-size: 14px; }
.ex-desc { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- 모달 / 토스트 ---------- */
.modal-bg { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(0, 0, 0, .45); }
.modal { width: 100%; max-width: 380px; padding: 22px; border-radius: 16px; background: var(--bg-elev); border: 1px solid var(--border); box-shadow: var(--shadow); }
.modal-title { font-size: 17px; font-weight: 700; margin-bottom: 8px; }
.modal-msg { color: var(--text-2); font-size: 14px; word-break: break-word; white-space: pre-line; }
.modal-btns { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.btn-primary.btn-sm { height: 36px; padding: 0 18px; border-radius: 9px; }

/* 프로젝트 추가 폼 */
.modal-form { max-width: 520px; max-height: calc(100vh - 32px); overflow-y: auto; }
.modal-form .modal-title { margin-bottom: 16px; }
.mf-row { margin-bottom: 12px; }
.mf-label { display: block; margin-bottom: 5px; font-size: 12.5px; color: var(--text-2); font-weight: 600; }
.mf-label .req { color: var(--danger); }
.mf-input {
    width: 100%; height: 38px; padding: 0 12px; border-radius: 9px; border: 1px solid var(--border-strong);
    background: var(--bg-input); color: var(--text); outline: none; font-size: 14px;
}
.mf-input:focus { border-color: var(--accent); }
.mf-static { word-break: break-all; }

/* ---------- 떠 있는 창 (메모장) — 모달 아님: 확인창(z 100)보다 아래, 파일 패널(z 25)보다 위 ---------- */
.fw {
    position: fixed; right: 24px; top: 64px; z-index: 90;
    width: 560px; height: 420px; min-width: 340px; min-height: 240px; max-width: calc(100vw - 16px); max-height: calc(100vh - 16px);
    display: flex; flex-direction: column; overflow: hidden; resize: both;
    background: var(--bg-elev); border: 1px solid var(--border-strong); border-radius: 12px; box-shadow: 0 12px 40px rgba(0, 0, 0, .35);
}
.fw.dragging { opacity: .92; user-select: none; }
.fw-head {
    flex: 0 0 auto; display: flex; align-items: center; gap: 6px; height: 38px; padding: 0 6px 0 12px;
    border-bottom: 1px solid var(--border); background: var(--bg-side); cursor: move; user-select: none; touch-action: none;
}
.fw-head > svg { color: var(--accent); flex: 0 0 auto; }
.fw-title { font-weight: 700; font-size: 13.5px; }
.fw-status { flex: 1; font-size: 11.5px; color: var(--muted); }
.fw-head .icon-btn { width: 28px; height: 28px; cursor: pointer; }
.fw-body { flex: 1; min-height: 0; display: flex; }
.memo-side { flex: 0 0 170px; display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--border); }
.memo-search {
    margin: 8px; height: 28px; padding: 0 8px; border-radius: 7px; border: 1px solid var(--border-strong);
    background: var(--bg-input); color: var(--text); outline: none; font-size: 12.5px;
}
.memo-list { list-style: none; margin: 0; padding: 0 6px 6px; overflow-y: auto; flex: 1; min-height: 0; }
.memo-list li { display: flex; flex-direction: column; gap: 1px; padding: 6px 8px; border-radius: 7px; cursor: pointer; }
.memo-list li:hover { background: var(--bg-hover); }
.memo-list li.on { background: var(--bg-active); }
.memo-t { font-size: 13px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.memo-d { font-size: 11px; color: var(--muted); }
.memo-empty { padding: 10px; font-size: 12px; color: var(--muted); }
.memo-edit { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.memo-title {
    flex: 0 0 auto; height: 36px; padding: 0 12px; border: 0; border-bottom: 1px solid var(--border);
    background: transparent; color: var(--text); outline: none; font-size: 14px; font-weight: 600;
}
.memo-ta {
    flex: 1; min-height: 0; padding: 10px 12px; border: 0; resize: none; outline: none;
    background: transparent; color: var(--text); font-size: 13.5px; line-height: 1.6; font-family: inherit;
}
.memo-foot { flex: 0 0 auto; display: flex; justify-content: flex-end; padding: 4px 8px 6px; min-height: 8px; }
@media (max-width: 768px) {
    .fw { left: 8px !important; right: 8px !important; top: 56px !important; width: auto !important; height: 60vh !important; resize: none; }
    .memo-side { flex-basis: 120px; }
}

/* 요청 내용 수정 팝업 */
.modal-edit { max-width: 720px; }
.edit-ta { height: auto; min-height: 260px; padding: 10px 12px; line-height: 1.55; resize: vertical; font-family: inherit; white-space: pre-wrap; }
select.mf-input option { background: var(--bg-elev); }
.mf-static { padding: 8px 12px; border-radius: 9px; background: var(--bg-hover); font-size: 14px; }
.mf-2col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.mf-path { margin-top: 6px; font-size: 12px; color: var(--muted); word-break: break-all; font-family: "JetBrains Mono", Consolas, monospace; }
.mf-seg { display: flex; gap: 6px; }
.mf-seg button {
    flex: 1; height: 36px; border-radius: 9px; border: 1px solid var(--border-strong); background: transparent; font-size: 13.5px; color: var(--text-2);
}
.mf-seg button.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 600; }
@media (max-width: 480px) {
    .mf-2col { grid-template-columns: minmax(0, 1fr); }
    .attach-btn span { display: none; }      /* 좁은 화면: 첨부/업로드 버튼은 아이콘만 */
}
/* 화면 맨 위 가운데 — 아래 입력창을 가리지 않도록 (클릭도 통과) */
.toast {
    position: fixed; left: 50%; top: 10px; transform: translateX(-50%); z-index: 1000; max-width: calc(100% - 32px);
    padding: 8px 16px; border-radius: 10px; background: var(--text); color: var(--bg); font-size: 13px; box-shadow: var(--shadow);
    pointer-events: none; animation: toastIn .15s ease-out;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, -6px); } to { opacity: 1; transform: translateX(-50%); } }

/* ---------- 모바일 ---------- */
@media (max-width: 768px) {
    .sidebar {
        position: fixed; top: 0; bottom: 0; left: 0; z-index: 50; margin-left: calc(-1 * var(--sb-w)) !important;
        box-shadow: var(--shadow);
    }
    body.sb-mobile-open .sidebar { margin-left: 0 !important; }
    body.sb-mobile-open .sb-backdrop { display: block; position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, .45); }
    .sb-open-btn { display: inline-flex; }
    .ni-acts { display: inline-flex; }
    .welcome h1 { font-size: 23px; }
    .msg-col { padding: 16px 16px 8px; }
    .composer-wrap { padding: 6px 12px 12px; }
    .bubble { max-width: 88%; }
    .bot { gap: 10px; }
    .bot-avatar { flex-basis: 24px; width: 24px; height: 24px; }
    .bot-avatar svg { width: 14px; height: 14px; }
    .hint { display: none; }
    .examples { grid-template-columns: minmax(0, 1fr); }
    .chips { justify-content: flex-start; }
    .stage.empty { justify-content: flex-start; padding-top: 12vh; }
}
