/* ── CATALYST HUB CHAT WIDGET ── */
#ch-chat-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: linear-gradient(135deg, #7367f0, #9f94f5);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 24px rgba(115,103,240,.45);
    z-index: 9999;
    transition: transform .25s, box-shadow .25s;
}
#ch-chat-btn:hover { transform: scale(1.1); box-shadow: 0 8px 30px rgba(115,103,240,.6); }
#ch-chat-btn svg { width: 24px; height: 24px; }

#ch-chat-badge {
    position: absolute;
    top: -4px; right: -4px;
    width: 18px; height: 18px;
    background: #ea5455;
    border-radius: 50%;
    font-size: 10px;
    font-weight: 700;
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    border: 2px solid var(--bg-base, #1a1a27);
}

#ch-chat-panel {
    position: fixed;
    bottom: 86px;
    right: 24px;
    width: 340px;
    max-height: 520px;
    background: var(--bg-card, #27293d);
    border: 1px solid var(--border-alt, #34384b);
    border-radius: 18px;
    box-shadow: 0 20px 60px rgba(0,0,0,.5);
    display: flex;
    flex-direction: column;
    z-index: 9998;
    overflow: hidden;
    transform: scale(.92) translateY(16px);
    opacity: 0;
    pointer-events: none;
    transition: transform .25s ease, opacity .25s ease;
}
#ch-chat-panel.open {
    transform: scale(1) translateY(0);
    opacity: 1;
    pointer-events: auto;
}

.ch-header {
    background: linear-gradient(135deg, #7367f0, #9f94f5);
    padding: 16px 18px;
    display: flex;
    align-items: center;
    gap: 12px;
}
.ch-header-avatar {
    width: 38px; height: 38px;
    border-radius: 50%;
    background: rgba(255,255,255,.2);
    display: flex; align-items: center; justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}
.ch-header-info strong { display: block; color: #fff; font-size: 14px; font-weight: 700; }
.ch-header-info span { font-size: 12px; color: rgba(255,255,255,.75); }
.ch-header-status { width: 8px; height: 8px; border-radius: 50%; background: #28c76f; display: inline-block; margin-right: 4px; }
.ch-close {
    margin-left: auto;
    background: rgba(255,255,255,.15);
    border: none;
    color: #fff;
    width: 28px; height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    display: flex; align-items: center; justify-content: center;
    transition: background .2s;
}
.ch-close:hover { background: rgba(255,255,255,.3); }

.ch-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scrollbar-width: thin;
    scrollbar-color: var(--border-alt, #34384b) transparent;
}

.ch-msg {
    max-width: 86%;
    padding: 10px 13px;
    border-radius: 14px;
    font-size: 13px;
    line-height: 1.5;
    animation: ch-pop .2s ease;
}
@keyframes ch-pop { from{opacity:0;transform:translateY(8px)} to{opacity:1;transform:none} }

.ch-msg.bot {
    background: var(--bg-base, #1a1a27);
    color: var(--text-sub, #8f9bb3);
    border-bottom-left-radius: 4px;
    align-self: flex-start;
}
.ch-msg.bot strong { color: var(--text-main, #fff); }
.ch-msg.user {
    background: #7367f0;
    color: #fff;
    border-bottom-right-radius: 4px;
    align-self: flex-end;
}

.ch-quick-btns {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0 16px 10px;
}
.ch-q-btn {
    background: var(--bg-base, #1a1a27);
    border: 1px solid var(--border-alt, #34384b);
    color: var(--text-sub, #8f9bb3);
    border-radius: 20px;
    padding: 5px 12px;
    font-size: 12px;
    cursor: pointer;
    transition: border-color .2s, color .2s;
    white-space: nowrap;
}
.ch-q-btn:hover { border-color: #7367f0; color: #7367f0; }

.ch-input-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    border-top: 1px solid var(--border-alt, #34384b);
}
#ch-input {
    flex: 1;
    background: var(--bg-base, #1a1a27);
    border: 1px solid var(--border-alt, #34384b);
    border-radius: 20px;
    padding: 9px 14px;
    font-size: 13px;
    color: var(--text-main, #fff);
    outline: none;
    font-family: inherit;
    transition: border-color .2s;
}
#ch-input:focus { border-color: #7367f0; }
#ch-input::placeholder { color: var(--text-muted, #5c6277); }
#ch-send {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: #7367f0;
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    transition: background .2s;
}
#ch-send:hover { background: #8f85f3; }
#ch-send svg { width: 16px; height: 16px; }

/* Light mode */
body.light-mode #ch-chat-panel {
    background: #ffffff;
    border-color: #e2e5ef;
    box-shadow: 0 20px 60px rgba(0,0,0,.15);
}
body.light-mode .ch-msg.bot { background: #f0f2f8; color: #5a6275; }
body.light-mode #ch-input { background: #f0f2f8; border-color: #d1d5e0; color: #1a1a2e; }
body.light-mode .ch-q-btn { background: #f0f2f8; border-color: #d1d5e0; color: #5a6275; }
body.light-mode .ch-input-row { border-color: #e2e5ef; }
body.light-mode #ch-chat-badge { border-color: #f0f2f8; }

@media (max-width: 400px) {
    #ch-chat-panel { width: calc(100vw - 24px); right: 12px; bottom: 78px; }
    #ch-chat-btn { right: 12px; bottom: 16px; }
}
