.cai-root {
    --cai-c1: #7b2ff7;
    --cai-c2: #d6259e;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* ---------- Floating launcher ---------- */
#cora-chat-launcher.cai-root {
    position: fixed;
    bottom: 24px;
    z-index: 999999;
}
.cai-pos-right { right: 24px; }
.cai-pos-left { left: 24px; }

.cai-launcher {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    background: linear-gradient(135deg, var(--cai-c1), var(--cai-c2));
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s ease, opacity 0.15s ease;
}
.cai-launcher:hover { transform: scale(1.06); }
.cai-launcher svg { width: 26px; height: 26px; }
.cai-launcher img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.cai-launcher-hidden { opacity: 0; pointer-events: none; transform: scale(0.8); }

/* ---------- Panel ---------- */
.cai-panel {
    position: absolute;
    bottom: 76px;
    width: 360px;
    max-width: calc(100vw - 32px);
    height: 520px;
    max-height: 70vh;
    background: #fff;
    border-radius: 22px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.22);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(16px) scale(0.98);
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.18s ease;
}
.cai-pos-right .cai-panel { right: 0; }
.cai-pos-left .cai-panel { left: 0; }
.cai-panel.cai-open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}
.cai-panel-inline {
    position: static;
    width: 100%;
    max-width: 420px;
    height: 520px;
    margin: 0;
}

/* ---------- Header ---------- */
.cai-header {
    background: linear-gradient(135deg, var(--cai-c1), var(--cai-c2));
    padding: 22px 20px;
    border-radius: 22px 22px 0 0;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    position: relative;
    flex-shrink: 0;
}
.cai-header-title {
    color: #fff;
    font-size: 20px;
    font-weight: 700;
    line-height: 1.25;
}
.cai-header-sub {
    color: rgba(255, 255, 255, 0.8);
    font-size: 12px;
    margin-top: 4px;
}
.cai-header-icon {
    opacity: 0.55;
    flex-shrink: 0;
}
.cai-header-icon svg { width: 30px; height: 30px; }
.cai-close {
    position: absolute;
    top: 14px;
    right: 14px;
    background: rgba(255, 255, 255, 0.18);
    border: none;
    border-radius: 50%;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.cai-close svg { width: 12px; height: 12px; }

/* ---------- Thread ---------- */
.cai-thread {
    flex: 1;
    overflow-y: auto;
    padding: 18px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #fafafa;
}

.cai-bubble {
    max-width: 82%;
    padding: 11px 15px;
    font-size: 14px;
    line-height: 1.45;
    word-wrap: break-word;
}

.cai-bubble-assistant {
    align-self: flex-start;
    background: linear-gradient(135deg, var(--cai-c1), var(--cai-c2));
    color: #fff;
    border-radius: 18px 18px 18px 4px;
}

.cai-bubble-visitor {
    align-self: flex-end;
    background: #fff;
    color: #24222b;
    border: 1px solid #ececec;
    border-radius: 18px 18px 4px 18px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.cai-typing {
    align-self: flex-start;
    display: none;
    align-items: center;
    gap: 4px;
    padding: 12px 15px;
    background: linear-gradient(135deg, var(--cai-c1), var(--cai-c2));
    border-radius: 18px 18px 18px 4px;
}
.cai-typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #fff;
    opacity: 0.85;
    animation: cai-bounce 1s infinite ease-in-out;
}
.cai-typing span:nth-child(2) { animation-delay: 0.15s; }
.cai-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes cai-bounce {
    0%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-4px); }
}

/* ---------- Input row ---------- */
.cai-input-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px;
    background: #fff;
    border-top: 1px solid #f0f0f0;
    flex-shrink: 0;
}
.cai-input {
    flex: 1;
    border: 1px solid #e6e6e6;
    background: #f7f7f9;
    border-radius: 999px;
    padding: 11px 16px;
    font-size: 14px;
    outline: none;
}
.cai-input:focus { border-color: var(--cai-c1); }
.cai-send {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--cai-c1), var(--cai-c2));
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.cai-send svg { width: 17px; height: 17px; }

@media (max-width: 480px) {
    .cai-panel {
        width: calc(100vw - 24px);
        height: 72vh;
        bottom: 84px;
    }
}
