/* Chat Page — full-page AI chat (độc lập robot-ai float) */
/* Focus mode: full 100% width giống /write focus — body.chat-focus */
body.chat-focus .page-content { max-width: 100% !important; }

.chat-page {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 80px);
    min-height: 480px;
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    padding: 16px 24px 20px;
    background: #000000;
    border: none;
    border-radius: 15px;
    box-shadow: none;
}

/* Header */
.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 4px 0 14px;
    flex-shrink: 0;
}
.chat-header-title {
    display: flex;
    align-items: center;
    gap: 10px;
}
.chat-logo {
    font-size: 26px;
}
.chat-header-title strong {
    font-size: 1.05rem;
    color: #ececed;
    display: block;
}
.chat-header-sub {
    display: block;
    font-size: .75rem;
    color: #7a7a7e;
    margin-top: 2px;
}
.chat-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    position: relative;   /* neo menu ⋮ */
}

/* Messages */
body.chat-focus .main { min-width: 0; overflow-x: hidden; }   /* chặn flex main phình rộng khi content dài (think box) */
.chat-messages {
    flex: 1;
    min-width: 0;        /* không bị content dài đẩy rộng */
    max-width: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 12px 4px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
}

/* Actions */
.chat-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    margin: 4px 0 6px;
    flex-shrink: 0;
}
/* Nút search/img/+ — pill button hiện đại */
.chat-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(201, 169, 78, 0.04);
    border: 1px solid rgba(201, 169, 78, 0.08);
    color: #b0b0b6;
    border-radius: 999px;
    padding: 5px 14px;
    font-size: .78rem;
    font-weight: 500;
    cursor: pointer;
    opacity: .8;
    transition: background .15s, color .15s, border-color .15s, opacity .15s;
}
.chat-action-btn:hover {
    opacity: 1;
    background: rgba(201, 169, 78, 0.08);
    border-color: rgba(201, 169, 78, 0.14);
    color: #fff;
}
/* Nút search/img — icon-only, tròn gọn, nằm sát nhau */
#chat-search-btn, #chat-img-btn, #chat-upload-btn {
    letter-spacing: .02em;
    line-height: 1;
    padding: 0;
    font-size: 0;           /* ẩn text "search"/"img" — chỉ hiện icon */
    font-weight: 600;
    width: 32px;
    height: 32px;
    min-width: 32px;
    justify-content: center;
    align-items: center;
    display: inline-flex;
    border-radius: 50%;
}
#chat-search-btn svg, #chat-img-btn svg, #chat-upload-btn svg, #chat-expand-btn svg { width: 15px; height: 15px; }
#chat-search-btn:hover, #chat-img-btn:hover, #chat-upload-btn:hover, #chat-expand-btn:hover { background: rgba(201,169,78,.08); }
#chat-expand-btn {
    width: 32px; height: 32px; min-width: 32px;
    justify-content: center; align-items: center;
    padding: 0; font-size: 0; border-radius: 50%; line-height: 1;
}
/* Header: 1 nút  + menu tuỳ chọn (gom nút cũ 17/9 — id giữ nguyên cho JS) */
#chat-menu-btn {
    width: 34px; height: 34px; min-width: 34px;
    justify-content: center; align-items: center;
    padding: 0; font-size: 0; border-radius: 50%; line-height: 1;
}
#chat-menu-btn svg { width: 18px; height: 18px; }
.chat-menu { position: absolute; top: calc(100% + 8px); right: 0; z-index: 60; min-width: 236px; max-width: min(92vw, 320px); background: #1c1c20; border: 1px solid rgba(201,169,78,.28); border-radius: 12px; padding: 6px; box-shadow: 0 18px 60px rgba(0,0,0,.5); }
.chat-menu-item { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; background: none; border: none; border-radius: 8px; color: #c8c8ce; font-size: .82rem; font-family: inherit; padding: 9px 10px; cursor: pointer; transition: background .12s, color .12s; }
.chat-menu-item svg { flex: none; opacity: .8; }
.chat-menu-item:hover { background: rgba(201,169,78,.10); color: #fff; }
.chat-menu-item:hover svg { opacity: 1; color: #c9a94e; }
.chat-menu-sep { height: 1px; background: rgba(255,255,255,.08); margin: 5px 8px; }
.chat-menu-danger { color: #ff8f8f; }
.chat-menu-danger:hover { background: rgba(255,107,107,.12); color: #ff6b6b; }
.chat-menu-danger:hover svg { color: #ff6b6b; }
/* Input đổi tên phiên — sửa inline ngay trên title header */
.chat-name-input { font-family: inherit; font-size: .85rem; font-weight: 600; color: var(--text); background: rgba(255,255,255,.06); border: 1px solid rgba(201,169,78,.35); border-radius: 6px; padding: 2px 8px; outline: none; min-width: 150px; max-width: min(60vw, 300px); }
#chat-search-btn.chat-search-on, #chat-img-btn.chat-search-on {
    opacity: 1;
    color: #fff;
    background: rgba(201, 169, 78, 0.14);
    border-color: rgba(201, 169, 78, 0.28);
    box-shadow: 0 0 0 1px rgba(201,169,78,0.12), 0 0 12px rgba(201,169,78,0.06);
}
.chat-loading {
    display: none;
    align-items: center;
    gap: 6px;
    font-size: .78rem;
    color: #7a7a7e;
    margin-left: 4px;
}
.chat-loading .spinner {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(201, 169, 78, 0.15);
    border-top-color: #c9a94e;
    border-radius: 50%;
    animation: ra-spin .7s linear infinite;
    display: inline-block;
}
@keyframes ra-spin { to { transform: rotate(360deg); } }

/* Suggestion chips — empty state */
/* Gợi ý câu hỏi tiếp theo (17/9) — row chips dưới reply AI */
.chat-suggest-row { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 4px 4px; }
.chat-suggest-row .chat-chip { font-size: .78rem; padding: 5px 12px; }

.chat-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(201, 169, 78, 0.05);
    border: 1px solid rgba(201, 169, 78, 0.10);
    color: #d5d5d9;
    border-radius: 999px;
    padding: 8px 16px;
    font-size: .82rem;
    cursor: pointer;
    transition: background .15s, border-color .15s, color .15s, transform .1s;
}
.chat-chip:hover {
    background: rgba(201, 169, 78, 0.10);
    border-color: rgba(201, 169, 78, 0.18);
    color: #fff;
    transform: translateY(-1px);
}
.chat-chip:active { transform: translateY(0); }

/* Input — màu nền/border theo #robot-ai-input */
.chat-input-wrap {
    position: relative;
    flex-shrink: 0;
    border-radius: 10px;   /* khớp input bên trong (như robot-ai) */
}
.chat-input-wrap:focus-within {
    box-shadow: 0 0 0 3px rgba(201, 169, 78, 0.05);
}
#chat-input {
    width: 100%;
    padding: 13px 52px 13px 16px;
    border: 1px solid rgba(201, 169, 78, 0.3);
    background: rgba(201, 169, 78, 0.04);
    border-radius: 10px;                           /* giống #robot-ai-input */
    color: #ececed;
    font-size: .95rem;
    line-height: 1.5;
    resize: none;
    outline: none;
    font-family: inherit;
    box-sizing: border-box;
    min-height: 46px;
    max-height: 160px;
    scrollbar-width: none;
    -ms-overflow-style: none;
    transition: min-height .2s ease;
}
#chat-input.expanded {
    min-height: 220px;
    max-height: 220px;
    overflow-y: auto;
}
#chat-input:focus {
    border-color: rgba(201, 169, 78, 0.5);
}
#chat-input::-webkit-scrollbar { display: none; }
#chat-input::placeholder { color: #5a5a5e; }
.chat-send-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 10px;
    background: rgba(201,169,78,0.14);
    color: var(--primary);
    font-size: 1rem;
    line-height: 1;
    padding: 0;
    cursor: pointer;
    transition: background .15s, transform .1s, opacity .15s;
}
.chat-send-btn svg { width: 15px; height: 15px; }
.chat-send-btn:hover { background: var(--primary); color: #000; transform: translateY(-50%) scale(1.05); }
.chat-send-btn:active { transform: translateY(-50%) scale(0.95); }
.chat-send-btn.chat-stop { background: rgba(201,169,78,0.12); color: #ff6b6b; }
.chat-send-btn.chat-stop:hover { background: rgba(255,107,107,0.2); color: #ff6b6b; }
/* Rỗng → mờ, có chữ → nổi bật (đổi qua JS toggle .has-text) */
.chat-send-btn:not(.has-text):not(.chat-stop) { opacity: 0.35; }
.chat-send-btn:not(.has-text):not(.chat-stop):hover { background: rgba(201,169,78,0.14); color: var(--primary); }

/* Restore message items — đồng bộ 100% robot-ai (.ra-messages .sp-item) */
.chat-messages .sp-item {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 14px 16px;
    text-decoration: none;
    color: var(--text);
    border: 1px solid transparent;
    border-radius: var(--radius);
    transition: background 0.15s, border-color 0.15s;
    margin-bottom: 6px;
}
.chat-messages .sp-item:first-child { border-top: none; }
.chat-messages .sp-item:hover {
    background: rgba(201,169,78,0.05);
    border-color: rgba(201,169,78,0.07);
}
.chat-messages .sp-icon {
    font-size: 1.3rem;
    flex-shrink: 0;
    width: 28px;
    text-align: center;
    margin-top: 2px;
}
.chat-messages .sp-icon svg { width: 22px; height: 22px; color: var(--primary); vertical-align: middle; }
.chat-messages .sp-body { flex: 1; min-width: 0; }

/* ─── User vs AI: chat convention — user bubble phải, AI trái ─── */
.chat-messages .sp-item { max-width: 100%; }
.chat-messages .sp-item.ai-msg { max-width: 780px; }
.chat-messages .sp-item.user-msg {
    flex-direction: row-reverse;
    justify-content: flex-start;
    max-width: 72%;
    margin-left: auto;
    background: rgba(201,169,78,0.08);
    border: 1px solid rgba(201,169,78,0.14);
    border-radius: 14px 14px 4px 14px;
    padding: 10px 14px;
}
.chat-messages .sp-item.user-msg .sp-icon { margin: 2px 0 0 10px; }
.chat-messages .sp-item.user-msg .ra-copy-btn { margin-left: 0; margin-right: 6px; align-self: center; }
.chat-messages .ra-copy-btn svg { width: 14px; height: 14px; vertical-align: -2px; }
.chat-messages .sp-type {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--primary);
    background: rgba(201,169,78,0.08);
    padding: 1px 8px;
    border-radius: 8px;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.chat-messages .sp-highlight {
    font-size: 0.82rem;
    color: var(--text-muted);
    line-height: 1.5;
    margin-top: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}
.chat-messages .sp-highlight b { color: var(--primary); font-weight: 600; }
.chat-messages .sp-more {
    display: block;
    padding: 14px 16px;
    text-align: center;
    font-size: 0.88rem;
    color: var(--primary);
    text-decoration: none;
    border: 1px solid rgba(201,169,78,0.07);
    border-radius: var(--radius);
    margin-top: 8px;
    transition: background 0.15s;
}
.chat-messages .sp-title {
    display: block;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 2px;
    white-space: normal;
    word-break: break-word;
    line-height: 1.6;
}
.chat-messages .sp-title > p:last-child { margin-bottom: 0; }
.chat-messages .ra-streaming { display: inline; word-break: break-word; }

/* Thời gian trả lời (chung class ra-time từ robot-ai) */
.ra-time {
    display: inline-block;
    font-size: 10px;
    color: #999;
    opacity: 0.75;
    margin-left: 6px;
    font-weight: 400;
    vertical-align: middle;
}
.ra-time svg { vertical-align: -1px; margin-right: 2px; }

/* Nút Hỏi lại (regen) — gắn cuối bubble AI, đồng bộ .ra-time */
.ra-regen-btn {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 24px; width: 24px; height: 24px;
    margin-left: 6px; padding: 0;
    border: none; background: none; border-radius: 6px;
    color: #c9a94e; opacity: .7; cursor: pointer; vertical-align: middle;
    transition: opacity 0.15s, background 0.15s;
}
.ra-regen-btn:hover { opacity: 1; background: rgba(201, 169, 78, 0.12); }

/* Quick actions menu — dùng chung class ra-qa-menu/ra-qa-btn (robot-ai) */
.ra-qa-menu {
    position: fixed;
    z-index: 10001;
    display: none;
    background: rgba(20, 22, 28, 0.98);
    border: 1px solid rgba(201, 169, 78, 0.25);
    border-radius: 8px;
    padding: 4px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    gap: 2px;
}
.ra-qa-btn {
    background: none;
    border: none;
    color: #e8c96a;
    font-size: .8rem;
    padding: 6px 10px;
    border-radius: 5px;
    cursor: pointer;
    white-space: nowrap;
    text-align: left;
    width: 100%;
}
.ra-qa-btn:hover { background: rgba(201, 169, 78, 0.08); }

/* Cursor blink — chung với robot-ai */
@keyframes ra-blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }

/* Responsive */
@media (max-width: 640px) {
    .chat-page {
        height: calc(100vh - 70px);
        padding: 10px 10px 14px;
        border-radius: 0;
        border: none;
    }
    .chat-header-sub { display: none; }
    /* Mobile: menu ⋮ đã gom nút — không cần ẩn riêng export nữa (17/9) */
    .chat-header-actions { gap: 6px; }
    /* Menu ⋮ neo phải header — chặn tràn mép viewport (header 289px + margin sidebar 42px) */
    .chat-header-actions { padding-right: 8px; }
    /* Title 1 dòng trên mobile — tránh wrap tốn chiều dọc + tràn ngang */
    .chat-header-title { flex-shrink: 0; }
    .chat-header-title strong {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 160px;
        font-size: .95rem;
    }
    .chat-logo { font-size: 22px; }
}
/* === Code & Quote trong tin nhắn AI — tách biệt rõ, tone đen-vàng === */
.chat-msg.incoming pre {
    background: #0d0d10;
    border: 1px solid rgba(201, 169, 78, 0.25);
    border-radius: 10px;
    padding: 12px 14px;
    margin: 8px 0;
    overflow-x: auto;
    box-shadow: inset 0 1px 3px rgba(0,0,0,.4);
}
.chat-msg.incoming pre code {
    font-family: 'JetBrains Mono', 'Fira Code', Consolas, Monaco, 'Courier New', monospace;
    font-size: .82rem;
    line-height: 1.55;
    color: #e6e6e6;
    background: none;
    padding: 0;
}
.chat-msg.incoming pre code .token.keyword,
.chat-msg.incoming pre code .hljs-keyword { color: #e8c96a; }
.chat-msg.incoming pre code .token.string,
.chat-msg.incoming pre code .hljs-string { color: #a8c9a0; }
.chat-msg.incoming pre code .token.comment,
.chat-msg.incoming pre code .hljs-comment { color: #6a6a6e; font-style: italic; }
.chat-msg.incoming pre code .token.function,
.chat-msg.incoming pre code .hljs-title { color: #d4a843; }
.chat-msg.incoming p code {
    background: rgba(201, 169, 78, 0.12);
    color: #e8c96a;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'JetBrains Mono', Consolas, Monaco, monospace;
    font-size: .8rem;
}
.chat-msg.incoming blockquote {
    background: rgba(201, 169, 78, 0.07);
    border-left: 4px solid rgba(201, 169, 78, 0.5);
    padding: 10px 16px;
    margin: 8px 0;
    border-radius: 0 8px 8px 0;
    color: #c9c9cc;
    font-style: italic;
}
.chat-msg.incoming blockquote strong { color: #e8c96a; }

/* ─── Think block (model reasoning) — box thu gọn, giữ nguyên nội dung ── */
.think-box {
    margin: 8px 0;
    border: 1px solid rgba(201, 169, 78, 0.18);
    border-radius: 8px;
    background: rgba(201, 169, 78, 0.05);
    overflow: hidden;
    max-width: 100%;   /* không đẩy rộng message — giới hạn theo container */
}
.think-box summary {
    cursor: pointer;
    list-style: none;
    padding: 6px 12px;
    font-size: 0.78rem;
    font-weight: 600;
    color: #c9a94e;
    opacity: 0.9;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 6px;
    overflow: hidden;   /* chặn text con giãn rộng summary */
}
.think-summary-icon { flex-shrink: 0; font-size: 0.85rem; }
.think-summary-text-static {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    height: 1.3em;
    line-height: 1.3em;
    opacity: 0.85;
}
.think-box summary::-webkit-details-marker { display: none; }
.think-box summary::before {
    content: '▾';
    display: inline-block;
    transition: transform 0.15s ease;
    font-size: 0.7rem;
    opacity: 0.7;
}
.think-box:not(.open) summary::before { transform: rotate(-90deg); }
.think-box:not(.open) .think-inner { display: none; }
.think-inner {
    padding: 2px 14px 10px;
    font-size: 0.85rem;
    color: #9a9aa0;
    border-top: 1px solid rgba(201, 169, 78, 0.1);
}
.think-inner p { margin: 6px 0; }
.think-inner code { background: rgba(201,169,78,0.1); color: #e8c96a; padding: 1px 5px; border-radius: 4px; font-size: 0.8rem; }
.think-inner pre { background: rgba(0,0,0,0.3); border: 1px solid rgba(201,169,78,0.1); border-radius: 6px; padding: 8px 10px; overflow-x: auto; }
.think-inner strong { color: #c9a94e; }
.think-inner ul, .think-inner ol { margin: 4px 0; padding-left: 20px; }

/* ─── Think stream — 1 div, stream chảy vào (HIỆN ALL), xong đổi class thành think-box 1 dòng ── */
.think-stream {
    display: flex;
    align-items: flex-start;   /* icon trên cùng khi text nhiều dòng */
    gap: 6px;
    padding: 6px 12px;
    margin: 0 0 8px;
    background: rgba(201,169,78,0.05);
    border: 1px solid rgba(201,169,78,0.15);
    border-radius: var(--radius);
    overflow: hidden;
    font-size: 0.82rem;
    color: var(--text-muted);
    max-width: 100%;
}
.think-stream-icon {
    font-size: 0.9rem;
    flex-shrink: 0;
    animation: chat-ticker-pulse 1.2s ease-in-out infinite;
    margin-top: 1px;
}
.think-stream-text {
    flex: 1;
    min-width: 0;
    white-space: normal;       /* wrap — HIỆN TOÀN BỘ khi stream */
    line-height: 1.4em;
    word-break: break-word;
}
@keyframes chat-ticker-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ─── Print: in trực tiếp trang /chat (window.print), không tạo trang riêng ─── */
@media print {
    /* Ẩn chrome UI */
    .sidebar, .sidebar-overlay,
    .sm-root, .sm-panel, .sm-backdrop,
    .chat-header, .chat-actions, .chat-input-wrap, .chat-image-preview,
    #chat-welcome, #chat-suggest, .chat-loading, #chat-counter {
        display: none !important;
    }
    /* Full width, không margin */
    .main, .page-content, #pageMainView {
        margin: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        padding: 0 !important;
    }
    /* Nền trắng toàn trang */
    html, body {
        background: #fff !important;
        color: #000 !important;
    }
    /* Chat page: bỏ height giới hạn, nền trắng */
    .chat-page {
        height: auto !important;
        min-height: 0 !important;
        padding: 0 !important;
        background: #fff !important;
        border: none !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        display: block !important;
    }
    /* Messages: bỏ scroll, nội dung chảy hết */
    .chat-messages {
        overflow: visible !important;
        height: auto !important;
        flex: none !important;
        padding: 0 !important;
        gap: 8px !important;
    }
    /* Bubble: nền trắng/xám nhạt, chữ đen, tránh cắt ngang trang */
    .chat-messages .sp-item {
        background: transparent !important;
        border: 1px solid #ddd !important;
        color: #000 !important;
        break-inside: avoid;
        page-break-inside: avoid;
    }
    .chat-messages .sp-item.user-msg {
        background: #f5f5f5 !important;
        border-color: #ccc !important;
        color: #000 !important;
    }
    /* Text màu đen */
    .chat-messages .sp-type {
        color: #000 !important;
        background: #eee !important;
    }
    .chat-messages .sp-title,
    .chat-messages .sp-title *,
    .chat-messages .sp-body,
    .chat-messages .sp-highlight {
        color: #000 !important;
    }
    .chat-messages .sp-icon svg { color: #000 !important; }
    /* Ẩn nút copy */
    .chat-messages .ra-copy-btn { display: none !important; }
    /* Code block: nền xám nhạt, xuống dòng */
    .chat-messages pre, .chat-messages code {
        background: #f0f0f0 !important;
        color: #000 !important;
        border: 1px solid #ddd !important;
        white-space: pre-wrap !important;
        word-break: break-word !important;
    }
}


/* ─── MCP popup (chọn workspace public) — nền overlay ĐC qua class ─── */
#chat-mcp-overlay {
    position: fixed; inset: 0; z-index: 10050;
    background: rgba(0, 0, 0, .55);
    display: flex; align-items: center; justify-content: center;
}
#chat-mcp-pop {
    width: min(430px, calc(100vw - 32px));
    max-height: 70vh; display: flex; flex-direction: column;
    background: #1c1c20; border: 1px solid rgba(201, 169, 78, .35); border-radius: 14px;
    box-shadow: 0 18px 60px rgba(0, 0, 0, .5); padding: 16px;
}
.chat-mcp-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--text); }
.chat-mcp-sub { font-size: .8rem; color: var(--text-muted); margin: 8px 0 10px; }
.chat-mcp-search {
    width: 100%; padding: 8px 12px; margin-bottom: 8px;
    background: rgba(255, 255, 255, .05); border: 1px solid rgba(255, 255, 255, .12);
    border-radius: 8px; color: var(--text); font-size: .87rem; outline: none;
    transition: border-color .15s;
}
.chat-mcp-search:focus { border-color: rgba(201, 169, 78, .5); }
.chat-mcp-search::placeholder { color: var(--text-muted); }
.chat-mcp-list { overflow-y: auto; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; min-height: 60px; align-content: start; }
@media (max-width: 600px) { .chat-mcp-list { grid-template-columns: 1fr; } }
.chat-mcp-item {
    display: flex; align-items: center; gap: 9px;
    padding: 9px 11px; border-radius: 10px; cursor: pointer;
    background: rgba(255, 255, 255, .04); border: 1px solid rgba(255, 255, 255, .08);
    color: var(--text); font-size: .84rem; text-align: left;
    transition: background .15s, border-color .15s;
    min-width: 0;
}
.chat-mcp-item:hover { background: rgba(201, 169, 78, .12); border-color: rgba(201, 169, 78, .45); }
.chat-mcp-item .chat-mcp-av {
    width: 34px; height: 34px; border-radius: 9px; flex: none;
    object-fit: cover; background: rgba(255, 255, 255, .06);
    display: flex; align-items: center; justify-content: center;
    color: #c9a94e; overflow: hidden;
}
.chat-mcp-item .chat-mcp-av img { width: 100%; height: 100%; object-fit: cover; }
.chat-mcp-item .chat-mcp-main { min-width: 0; flex: 1; }
.chat-mcp-item .chat-mcp-name { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-mcp-item .chat-mcp-docs { display: block; font-size: .72rem; color: #c9a94e; }
.chat-mcp-empty { color: var(--text-muted); font-size: .85rem; padding: 14px; text-align: center; }
/* Nút MCP đang ON — đồng bộ .an-tog.on (vàng đậm) */
#chat-mcp-btn.on { color: #c9a94e; background: rgba(201, 169, 78, .15); border-radius: 8px; opacity: 1; }
#chat-mcp-btn.on:hover { color: #e8c96a; }

/* File đính kèm chat — chip preview hàng ngang (17/9: multi-file, lưu datafiles cá nhân) */
.chat-file-chip { position: relative; display: flex; align-items: center; gap: 6px; background: rgba(255,255,255,.05); border: 1px solid rgba(201,169,78,.25); border-radius: 8px; padding: 4px 26px 4px 6px; max-width: 200px; }
.chat-file-chip img { width: 40px; height: 40px; object-fit: cover; border-radius: 5px; flex: none; }
.chat-file-chip .chat-file-ext { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 5px; background: rgba(201,169,78,.15); color: #c9a94e; font-size: .68rem; font-weight: 700; flex: none; }
.chat-file-chip .chat-file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .75rem; color: var(--text); max-width: 110px; }
.chat-file-chip .chat-file-x { position: absolute; top: -6px; right: -6px; width: 20px; height: 20px; min-width: 20px; border-radius: 50%; background: #2a2a2e; border: 1px solid rgba(255,255,255,.2); color: #bbb; font-size: .8rem; line-height: 1; display: flex; align-items: center; justify-content: center; cursor: pointer; padding: 0; }
.chat-file-chip .chat-file-x:hover { background: #ff6b6b; color: #fff; border-color: #ff6b6b; }

/* File đính kèm trong bubble user (render lại từ DB + live) */
.chat-doc-attach { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chat-doc-attach-chip { display: inline-flex; align-items: center; border-radius: 8px; overflow: hidden; border: 1px solid rgba(201,169,78,.3); background: rgba(0,0,0,.25); }
.chat-doc-attach-chip img { width: 56px; height: 56px; object-fit: cover; display: block; }
.chat-doc-attach-chip .doc-ext { display: inline-flex; align-items: center; justify-content: center; min-width: 40px; height: 40px; padding: 0 8px; background: rgba(201,169,78,.15); color: #c9a94e; font-size: .68rem; font-weight: 700; }
