:root {
    --cb-primary:       #9fcd22;
    --cb-primary-light: #c8e96a;
    --cb-primary-bg:    #eef7cc;
    --cb-green:         #3f5504;
    --cb-primary-glow:  #9fcd2230;
    --cb-green-dark:    #2d6a1e;
    --cb-black:         #111111;
    --cb-dark:          #f5f5f5;
    --cb-card:          #ebebeb;
    --cb-border:        #d8eea0;
    --cb-muted:         #7a9a30;
    --cb-text:          #1a2e00;
    --cb-text-soft:     #5a7a20;
    --cb-white:         #ffffff;
    --cb-accent-333:    #eeeeee;
    --cb-radius-modal:  20px;
    --cb-radius-bubble: 18px;
    --cb-shadow:        0 24px 64px rgba(0,0,0,0.18), 0 0 0 1px rgba(159,205,34,0.18);
}

/* overlay */
.cb-modal-overlay {
    display: none;
    position: fixed;
    bottom: 90px;
    right: 24px;
    z-index: 999999;
    animation: cb-slide-up 0.32s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.cb-modal-overlay.cb-active {
    display: block;
}

@keyframes cb-slide-up {
    from { opacity: 0; transform: translateY(30px) scale(0.94); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* container */
.cb-modal-container {
    width: 370px;
    max-width: calc(100vw - 32px);
    height: 560px;
    max-height: calc(100vh - 120px);
    background: var(--cb-white);
    border-radius: var(--cb-radius-modal);
    box-shadow: var(--cb-shadow);
    border: 1px solid var(--cb-border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

/* header — solid green */
.cb-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 18px;
    background: var(--cb-primary);
    border-bottom: 1px solid #8ab81e;
    flex-shrink: 0;
}

.cb-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.cb-header-avatar {
    position: relative;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
}

.cb-header-avatar img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--cb-white);
}

.cb-online-dot {
    position: absolute;
    bottom: 1px;
    right: 1px;
    width: 10px;
    height: 10px;
    background: var(--cb-white);
    border-radius: 50%;
    border: 2px solid var(--cb-primary);
    box-shadow: 0 0 6px rgba(255,255,255,0.6);
}

.cb-header-title {
    margin: 0;
    font-size: 14px;
    font-weight: 700;
    color: var(--cb-black);
    letter-spacing: 0.2px;
}

.cb-header-status {
    font-size: 11px;
    color: var(--cb-green-dark);
    display: block;
    margin-top: 1px;
    font-weight: 600;
}

.cb-close-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid rgba(0,0,0,0.15);
    background: rgba(255,255,255,0.3);
    color: var(--cb-black);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
    flex-shrink: 0;
}

.cb-close-btn:hover {
    background: rgba(255,255,255,0.55);
    color: var(--cb-green-dark);
    border-color: rgba(0,0,0,0.2);
}

/* chat body — white */
.cb-chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: var(--cb-white);
}

.cb-chat-body::-webkit-scrollbar { width: 4px; }
.cb-chat-body::-webkit-scrollbar-track { background: transparent; }
.cb-chat-body::-webkit-scrollbar-thumb { background: var(--cb-border); border-radius: 2px; }

/* date divider */
.cb-date-divider {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 4px 0;
}

.cb-date-divider::before,
.cb-date-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--cb-border);
}

.cb-date-divider span {
    font-size: 10px;
    color: var(--cb-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

/* message rows */
.cb-msg-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    max-width: 88%;
}

.cb-msg-row.cb-msg-ai  { align-self: flex-start; }
.cb-msg-row.cb-msg-user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.cb-msg-avatar {
    width: 30px;
    height: 30px;
    flex-shrink: 0;
}

.cb-msg-avatar img {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    object-fit: cover;
    border: 1.5px solid var(--cb-border);
}

/* bubbles */
.cb-msg-bubble {
    padding: 10px 14px;
    border-radius: var(--cb-radius-bubble);
    font-size: 13.5px;
    line-height: 1.55;
    position: relative;
    word-break: break-word;
}

/* AI bubble — light gray */
.cb-msg-bubble-ai {
    background: #f0f0f0;
    color: var(--cb-text);
    border-bottom-left-radius: 4px;
    border: 1px solid #e0e0e0;
}

/* User bubble — light green */
.cb-msg-bubble-user {
    background: var(--cb-primary-bg);
    color: var(--cb-green-dark);
    border-bottom-right-radius: 4px;
    border: 1px solid var(--cb-border);
    font-weight: 500;
}

.cb-msg-time {
    display: block;
    font-size: 10px;
    margin-top: 5px;
    opacity: 0.6;
    text-align: right;
}

/* typing indicator */
.cb-typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 10px 14px;
    background: #f0f0f0;
    border-radius: var(--cb-radius-bubble);
    border-bottom-left-radius: 4px;
    border: 1px solid #e0e0e0;
    width: fit-content;
}

.cb-typing-dot {
    width: 6px;
    height: 6px;
    background: var(--cb-primary);
    border-radius: 50%;
    animation: cb-typing 1.2s infinite;
}

.cb-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.cb-typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes cb-typing {
    0%, 60%, 100% { transform: translateY(0);    opacity: 0.4; }
    30%            { transform: translateY(-4px); opacity: 1;   }
}

/* image in message */
.cb-msg-image {
    max-width: 200px;
    border-radius: 12px;
    display: block;
    margin-top: 4px;
}

/* footer — green */
.cb-chat-footer {
    padding: 10px 14px 12px;
    background: var(--cb-primary);
    border-top: 1px solid #8ab81e;
    flex-shrink: 0;
}

/* image preview strip */
.cb-image-preview-strip {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.cb-preview-thumb {
    position: relative;
    width: 48px;
    height: 48px;
}

.cb-preview-thumb img {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    object-fit: cover;
    border: 1.5px solid var(--cb-white);
}

.cb-preview-remove {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 16px;
    height: 16px;
    background: #cc2200;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: #fff;
    line-height: 1;
}

/* input row */
.cb-input-row {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--cb-white);
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: 50px;
    padding: 6px 6px 6px 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.cb-input-row:focus-within {
    border-color: var(--cb-green-dark);
    box-shadow: 0 0 0 3px rgba(63,85,4,0.15);
}

.cb-attach-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    color: var(--cb-muted);
    cursor: pointer;
    transition: color 0.2s;
    flex-shrink: 0;
}

.cb-attach-btn:hover { color: var(--cb-green-dark); }

.cb-input-wrap { flex: 1; }

.cb-text-input {
    width: 100%;
    background: transparent;
    border: none;
    outline: none;
    color: var(--cb-text);
    font-size: 13.5px;
    font-family: inherit;
    caret-color: var(--cb-green-dark);
}

.cb-text-input::placeholder { color: #aaaaaa; }

.cb-send-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--cb-green-dark);
    border: none;
    color: var(--cb-white);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.15s, background 0.2s, box-shadow 0.2s;
}

.cb-send-btn:hover {
    background: var(--cb-green);
    box-shadow: 0 0 12px rgba(63,85,4,0.35);
    transform: scale(1.06);
}

.cb-send-btn:active { transform: scale(0.95); }

.cb-footer-note {
    margin: 6px 0 0;
    font-size: 10px;
    color: var(--cb-green-dark);
    text-align: center;
    letter-spacing: 0.3px;
    opacity: 0.75;
}

/* responsive */
@media (max-width: 768px) {
    .cb-modal-overlay {
        bottom: 0;
        right: 0;
        left: 0;
        top: 0;
        z-index: 99999;
    }

    .cb-modal-container {
        width: 100%;
        height: 100%;
        max-height: 100%;
        max-width: 100%;
        border-radius: 0;
    }
}

/* 
@media (max-width: 480px) {
    .cb-modal-overlay {
        bottom: 80px;
        right: 12px;
        left: 12px;
    }

    .cb-modal-container {
        width: 100%;
        height: 70vh;
    }
} */