.sparkles-chat-btn {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 10001;
    display: flex;
    width: 56px;
    height: 56px;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 50%;
    background: color-mix(in srgb, var(--color-primary-light) 50%, var(--color-white));
    box-shadow: var(--shadow-xl);
    cursor: pointer;
    padding: 0;
    transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.25s ease;
}

.sparkles-chat-btn:hover {
    transform: scale(1.08);
    box-shadow: var(--shadow-2xl);
    background: var(--color-primary-dark);
}

.sparkles-chat-btn.sparkles-hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.8);
}

.sparkles-chat-btn .sparkles-chat-btn-icon {
    display: block;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: transparent;
    object-fit: contain;
    padding: 0;
    pointer-events: none;
    user-select: none;
}

.sparkles-chat-btn.sparkles-has-nudge::after {
    content: "";
    position: absolute;
    top: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--color-primary);
    border: 2px solid var(--color-white);
    animation: sparklesNudgePulse 2s ease-in-out 3;
}

@keyframes sparklesNudgePulse {
    0%,
    100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.3);
        opacity: 0.7;
    }
}

.sparkles-chat-window {
    position: fixed;
    right: 20px;
    bottom: 88px;
    z-index: 10001;
    display: flex;
    width: 380px;
    height: 32.5rem;
    flex-direction: column;
    overflow: hidden;
    border-radius: 16px;
    background: var(--color-white);
    box-shadow: var(--shadow-xl);
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px) scale(0.98);
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.sparkles-chat-window.sparkles-open {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0) scale(1);
}

.sparkles-chat-header {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    background: var(--color-secondary);
    color: var(--color-white);
    padding: 0.875rem 1rem;
}

.sparkles-chat-header .sparkles-header-logo {
    display: flex;
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    margin-right: 0.625rem;
    border-radius: 50%;
    background: var(--color-primary-light);
}

.sparkles-chat-header .sparkles-chat-header-logo-image {
    display: block;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: transparent;
    object-fit: contain;
    padding: 0;
}

.sparkles-chat-header .sparkles-header-title {
    flex: 1;
    font-size: 1rem;
    font-weight: var(--font-semibold);
}

.sparkles-chat-close {
    border: 0;
    background: none;
    color: var(--color-white);
    cursor: pointer;
    font-size: 1.375rem;
    line-height: 1;
    opacity: 0.8;
    padding: 0 0 0 8px;
    transition: opacity 0.15s;
}

.sparkles-chat-close:hover {
    opacity: 1;
}

.sparkles-chat-messages {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 0.625rem;
    overflow-y: auto;
    background: var(--color-accent);
    padding: 1rem;
}

.sparkles-msg {
    max-width: 85%;
    border-radius: 14px;
    font-size: 0.875rem;
    line-height: 1.5;
    padding: 0.625rem 0.875rem;
    word-wrap: break-word;
}

.sparkles-msg a {
    color: var(--color-primary);
    text-decoration: underline;
}

.sparkles-msg-bot {
    align-self: flex-start;
    border: 1px solid var(--color-border);
    border-radius: 14px 14px 14px 4px;
    background: var(--color-white);
    color: var(--color-secondary);
}

.sparkles-msg-bot ul,
.sparkles-msg-bot ol {
    margin: 4px 0 4px 20px;
    padding: 0;
}

.sparkles-msg-bot ul {
    list-style: disc;
}

.sparkles-msg-bot ol {
    list-style: decimal;
}

.sparkles-msg-bot li {
    margin: 2px 0;
}

.sparkles-msg-bot ul + ul,
.sparkles-msg-bot ol + ol,
.sparkles-msg-bot ul + ol,
.sparkles-msg-bot ol + ul {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--gray-100);
}

.sparkles-msg-bot .cb {
    color: var(--color-secondary);
}

.sparkles-msg-bot .cp {
    color: var(--color-primary);
    font-weight: var(--font-semibold);
    white-space: nowrap;
}

.sparkles-msg-bot .cn {
    color: var(--gray-500);
    font-size: 0.75rem;
    font-style: normal;
}

.sparkles-msg-bot h4,
.sparkles-msg-bot h5,
.sparkles-msg-bot h6 {
    margin: 8px 0 4px;
    font-size: 0.875rem;
    font-weight: var(--font-bold);
    line-height: 1.3;
}

.sparkles-msg-bot code {
    border-radius: 3px;
    background: var(--gray-100);
    font-family: var(--font-mono, "SFMono-Regular", Consolas, monospace);
    font-size: 0.75rem;
    padding: 1px 5px;
}

.sparkles-msg-bot pre {
    margin: 6px 0;
    overflow-x: auto;
    border-radius: 6px;
    background: var(--gray-100);
    padding: 8px 10px;
}

.sparkles-msg-bot pre code {
    background: none;
    font-size: 0.75rem;
    padding: 0;
    white-space: pre-wrap;
}

.sparkles-chat-messages .sparkles-products {
    display: flex;
    max-width: 100%;
    flex-shrink: 0;
    align-self: flex-start;
    align-items: flex-start;
    gap: 0.625rem;
    overflow-x: auto;
    padding: 4px 0 8px;
    scrollbar-width: thin;
    scroll-behavior: smooth;
}

.sparkles-chat-messages .sparkles-products::-webkit-scrollbar {
    height: 4px;
}

.sparkles-chat-messages .sparkles-products::-webkit-scrollbar-thumb {
    border-radius: 2px;
    background: var(--gray-350);
}

.sparkles-chat-messages .sparkles-product-card {
    display: flex;
    flex: 0 0 130px;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--color-border);
    border-radius: 10px;
    background: var(--color-white);
    color: var(--color-secondary);
    text-decoration: none;
    transition: box-shadow 0.15s, transform 0.15s;
}

.sparkles-chat-messages .sparkles-product-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.sparkles-chat-messages .sparkles-product-card img {
    width: 100%;
    height: 110px;
    border-bottom: 1px solid var(--gray-100);
    background: var(--gray-50);
    object-fit: contain;
}

.sparkles-chat-messages .sparkles-product-card.sparkles-no-image img {
    display: none;
}

.sparkles-chat-messages .sparkles-product-info {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    padding: 4px 8px;
}

.sparkles-chat-messages .sparkles-product-card.sparkles-no-image .sparkles-product-info {
    padding-top: 1rem;
}

.sparkles-chat-messages .sparkles-product-name {
    display: -webkit-box;
    overflow: hidden;
    font-size: 0.75rem;
    font-weight: var(--font-semibold);
    line-height: 1.3;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.sparkles-chat-messages .sparkles-product-price {
    color: var(--color-primary);
    font-size: 0.8125rem;
    font-weight: var(--font-bold);
}

.sparkles-swatch-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.1875rem;
    margin-top: 1px;
    padding-top: 0;
}

.sparkles-swatch-dot {
    display: inline-block;
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    aspect-ratio: 1;
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 4px;
    background-position: center;
    background-size: cover;
    box-shadow: 0 0 0 0.5px rgba(255, 255, 255, 0.5) inset;
    cursor: pointer;
    line-height: 0;
    min-height: unset;
    overflow: hidden;
}

.sparkles-swatch-dot:hover {
    border-color: rgba(0, 0, 0, 0.35);
    transform: scale(1.15);
}

.sparkles-swatch-dot.sparkles-swatch-selected {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px var(--color-primary);
    transform: scale(1.15);
}

.sparkles-suggestions {
    display: flex;
    flex-wrap: wrap;
    align-self: flex-start;
    gap: 0.5rem;
    margin-top: 4px;
}

.sparkles-suggestion-btn {
    border: 1.5px solid var(--color-primary);
    border-radius: 20px;
    background: transparent;
    color: var(--color-secondary);
    cursor: pointer;
    font-size: 0.8125rem;
    line-height: 1.3;
    padding: 8px 16px;
    transition: background 0.15s, color 0.15s;
}

.sparkles-suggestion-btn:hover {
    background: var(--color-primary);
    color: var(--color-white);
}

.sparkles-add-cart-btn {
    width: 100%;
    margin-top: 4px;
    padding: 4px 8px;
    border: 1.5px solid var(--color-primary);
    border-radius: 6px;
    background: var(--color-primary);
    color: var(--color-white);
    font-size: 0.6875rem;
    font-weight: var(--font-semibold);
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
    text-align: center;
}

.sparkles-add-cart-btn:hover {
    background: var(--color-primary-dark);
    transform: scale(1.02);
}

.sparkles-add-cart-btn:disabled {
    opacity: 0.5;
    cursor: wait;
}

.sparkles-add-cart-btn.sparkles-added {
    background: var(--color-success, #28a745);
    border-color: var(--color-success, #28a745);
}

.sparkles-typing {
    display: flex;
    align-items: center;
    align-self: flex-start;
    gap: 0.25rem;
    border: 1px solid var(--color-border);
    border-radius: 14px 14px 14px 4px;
    background: var(--color-white);
    padding: 0.625rem 1.125rem;
}

.sparkles-typing-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--gray-500);
    animation: sparklesBounce 1.2s infinite;
}

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

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

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

.sparkles-chat-input-area {
    position: relative;
    display: flex;
    flex-shrink: 0;
    align-items: center;
    border-top: 1px solid var(--color-border);
    background: var(--color-white);
    padding: 0.625rem 0.75rem;
}

.sparkles-chat-input {
    flex: 1;
    border: 1px solid var(--gray-300);
    border-radius: 22px;
    font-size: 1rem;
    outline: none;
    padding: 0.625rem 1rem;
    transition: border-color 0.15s;
}

.sparkles-chat-input:focus {
    border-color: var(--color-primary);
}

.sparkles-chat-send {
    display: flex;
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    margin-left: 8px;
    border: 0;
    border-radius: 50%;
    background: var(--color-primary);
    cursor: pointer;
    transition: background 0.15s;
}

.sparkles-chat-send:hover {
    background: var(--color-primary-dark);
}

.sparkles-chat-send svg {
    width: 18px;
    height: 18px;
    fill: var(--color-white);
}

.sparkles-char-count {
    position: absolute;
    right: 56px;
    bottom: 14px;
    color: var(--gray-500);
    font-size: 0.6875rem;
    pointer-events: none;
}

.sparkles-feedback {
    display: flex;
    gap: 0.25rem;
    margin-top: 4px;
    opacity: 0.5;
    transition: opacity 0.2s;
}

.sparkles-msg-bot:hover .sparkles-feedback {
    opacity: 1;
}

.sparkles-feedback-btn {
    border: 1px solid transparent;
    border-radius: 4px;
    background: none;
    cursor: pointer;
    font-size: 0.875rem;
    line-height: 1;
    padding: 2px 6px;
    transition: all 0.15s;
}

.sparkles-feedback-btn:hover {
    border-color: var(--gray-350);
    background: var(--gray-100);
}

.sparkles-feedback-btn:disabled {
    cursor: default;
    opacity: 0.4;
}

.sparkles-feedback-btn.sparkles-feedback-active {
    opacity: 1;
    border-color: var(--color-gold-dark);
    background: color-mix(in srgb, var(--color-gold-light) 35%, var(--color-white));
}

@media (max-width: 767px) {
    .sparkles-chat-window {
        right: 0;
        bottom: 0;
        width: 100vw;
        height: 100vh;
        height: 100dvh;
        border-radius: 0;
    }

    .sparkles-chat-window.sparkles-open {
        transform: translateY(0) scale(1);
    }

    .sparkles-chat-messages .sparkles-product-card {
        flex-basis: 120px;
    }

    .sparkles-chat-messages .sparkles-product-card img {
        height: 90px;
    }
}
