#kai-toggle {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #e6602f;
    color: white;
    border: none;
    cursor: pointer;
    font-size: 24px;
    box-shadow: 0 4px 12px rgba(0,0,0,.25);
    z-index: 10000;
    transition: transform .2s;
}

#kai-toggle:hover { transform: scale(1.08); }

/* ── Open: circle centered on window's top edge ── */
/* Window: bottom:90px height:520px → top edge at 610px from bottom */
/* Circle center at 610px → bottom: 610-28 = 582px. Horizontal: 24+190-28=186 */
body:has(#kai-window.open) #kai-toggle {
    bottom: 582px;
    right: 186px;
}

#kai-window {
    display: none;
    position: fixed;
    bottom: 90px;
    right: 24px;
    width: 380px;
    height: 520px;
    background: rgba(128, 128, 128, 0.2);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0,0,0,.2);
    z-index: 9999;
    flex-direction: column;
    overflow: hidden;
}

#kai-window.open { display: flex; }

.kai-header {
    background: #e6602f;
    color: white;
    padding: 16px;
    font-size: 15px;
    font-weight: 600;
}

.kai-messages {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 200px;
}

.kai-msg {
    max-width: 95%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

.kai-msg.user {
    align-self: flex-end;
    background: #e6602f;
    color: white;
    border-bottom-right-radius: 4px;
}

.kai-msg.bot {
    align-self: flex-start;
    max-width: 95%;
    background: #f6f6f6;
    color: #333;
    border-bottom-left-radius: 4px;
}

.kai-typing {
    color: #999;
    font-size: 13px;
    font-style: italic;
}

.kai-input-wrap {
    display: flex;
    padding: 12px;
    gap: 8px;
    border-top: 1px solid rgba(238, 238, 238, 0.5);
    background: transparent;
    flex-shrink: 0;
}

#kai-input {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 14px;
    color: #000;
    background: #fff;
    outline: none;
}

#kai-input:focus { border-color: #e6602f; }

#kai-send {
    background: #e6602f;
    color: white;
    border: none;
    border-radius: 10px;
    padding: 10px 18px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
}

#kai-send:hover { background: #d0541f; }
#kai-send:disabled { opacity: .5; cursor: not-allowed; }

/* ── Mobile ── */
@media (max-width: 480px) {
    #kai-window {
        top: 10%;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        border-radius: 0;
    }
    /* Mobile open: circle centered on window top edge */
    /* Window top = 10%, circle center at 10% → top = calc(10% - 28px) */
    /* Full width window → center = calc(50% - 28px) */
    body:has(#kai-window.open) #kai-toggle {
        top: calc(10% - 28px);
        left: calc(50% - 28px);
        right: auto;
    }
}

.kai-product-link {
    display: inline-block;
    color: #2563eb;
    text-decoration: none;
    font-weight: 600;
    padding: 8px 14px;
    border: 1px solid #2563eb;
    border-radius: 6px;
    transition: background 0.15s, color 0.15s;
}

.kai-messages a {
    color: #1d4ed8;
    text-decoration: none;
    font-weight: bold;
}

.kai-product-link:hover {
    background: #2563eb;
    color: #fff;
}
