.ai-chat {
    --ai-wine: #7c1837;
    --ai-wine-dark: #591026;
    --ai-ink: #202124;
    --ai-muted: #6c7075;
    --ai-line: #e6e7e9;
    --ai-soft: #f5f4f2;
    --ai-success: #2f8b57;
    position: fixed;
    right: auto;
    left: 24px;
    bottom: 24px;
    z-index: 9999990;
    font-family: "Roboto Condensed", Arial, sans-serif;
    color: var(--ai-ink);
    letter-spacing: 0;
}

.ai-chat *,
.ai-chat *::before,
.ai-chat *::after {
    box-sizing: border-box;
}

.ai-chat__launcher {
    width: 108px;
    height: 108px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    overflow: hidden;
    border: 0;
    border-radius: 12px;
    background: transparent;
    filter: drop-shadow(0 10px 18px rgba(50, 18, 29, 0.28));
    cursor: pointer;
    transition: transform 160ms ease, filter 160ms ease;
}

.ai-chat__launcher:hover,
.ai-chat__launcher:focus-visible {
    filter: drop-shadow(0 13px 22px rgba(50, 18, 29, 0.36));
    transform: translateY(-2px) scale(1.02);
    outline: 2px solid var(--ai-wine);
    outline-offset: 3px;
}

.ai-chat__launcher-video {
    width: 100%;
    height: 100%;
    display: block;
    border-radius: inherit;
    object-fit: cover;
    pointer-events: none;
}

.ai-chat__panel {
    position: absolute;
    right: auto;
    bottom: 124px;
    left: 0;
    width: min(390px, calc(100vw - 32px));
    height: min(640px, calc(100vh - 172px));
    min-height: 480px;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto auto;
    overflow: hidden;
    border: 1px solid rgba(32, 33, 36, 0.12);
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 18px 55px rgba(24, 20, 21, 0.24);
    transform-origin: left bottom;
    animation: ai-chat-open 180ms ease-out;
}

.ai-chat__panel[hidden] {
    display: none;
}

@keyframes ai-chat-open {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.ai-chat__header {
    min-height: 68px;
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr) 38px;
    align-items: center;
    gap: 11px;
    padding: 12px 14px;
    color: #fff;
    background: var(--ai-wine-dark);
}

.ai-chat__avatar {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: var(--ai-wine-dark);
    background: #fff;
    font-size: 14px;
    font-weight: 700;
}

.ai-chat__heading {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.ai-chat__heading strong {
    overflow: hidden;
    font-size: 17px;
    line-height: 1.25;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ai-chat__heading span {
    display: flex;
    align-items: center;
    gap: 6px;
    color: rgba(255, 255, 255, 0.8);
    font-size: 13px;
    line-height: 1.2;
}

.ai-chat__heading span i {
    width: 7px;
    height: 7px;
    flex: 0 0 auto;
    border-radius: 50%;
    background: #6fd49a;
}

.ai-chat__close,
.ai-chat__send {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 50%;
    cursor: pointer;
}

.ai-chat__close {
    color: #fff;
    background: transparent;
    font-size: 20px;
}

.ai-chat__close:hover,
.ai-chat__close:focus-visible {
    background: rgba(255, 255, 255, 0.12);
    outline: none;
}

.ai-chat__messages {
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 18px 14px 12px;
    background: var(--ai-soft);
    scrollbar-width: thin;
}

.ai-chat__message {
    max-width: 86%;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 15px;
    line-height: 1.42;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}

.ai-chat__message--assistant {
    align-self: flex-start;
    border: 1px solid var(--ai-line);
    background: #fff;
    white-space: normal;
}

.ai-chat__message--assistant p {
    margin: 0;
}

.ai-chat__message--assistant p + p,
.ai-chat__message--assistant p + ul,
.ai-chat__message--assistant p + ol,
.ai-chat__message--assistant ul + p,
.ai-chat__message--assistant ol + p {
    margin-top: 8px;
}

.ai-chat__message--assistant ul,
.ai-chat__message--assistant ol {
    margin: 0;
    padding-left: 20px;
}

.ai-chat__message--assistant ul {
    list-style: disc;
}

.ai-chat__message--assistant ol {
    list-style: decimal;
}

.ai-chat__message--assistant li + li {
    margin-top: 5px;
}

.ai-chat__message--assistant a {
    color: var(--ai-wine);
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.ai-chat__message--assistant code {
    padding: 1px 4px;
    border-radius: 3px;
    background: var(--ai-soft);
    font: 0.92em/1.4 monospace;
}

.ai-chat__message--user {
    align-self: flex-end;
    color: #fff;
    background: var(--ai-wine);
}

.ai-chat__message--error {
    color: #8e1b1b;
    border-color: #efc9c9;
    background: #fff4f4;
}

.ai-chat__typing {
    width: 58px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 13px 12px;
}

.ai-chat__typing i {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--ai-muted);
    animation: ai-chat-typing 1.1s infinite ease-in-out;
}

.ai-chat__typing i:nth-child(2) {
    animation-delay: 130ms;
}

.ai-chat__typing i:nth-child(3) {
    animation-delay: 260ms;
}

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

.ai-chat__product-carousel {
    position: relative;
    width: 100%;
    min-width: 0;
}

.ai-chat__products {
    width: 100%;
    display: flex;
    gap: 10px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-behavior: smooth;
    scroll-snap-type: x mandatory;
    scrollbar-color: #c9b3bb transparent;
    scrollbar-width: thin;
    padding: 2px 2px 10px;
}

.ai-chat__products::-webkit-scrollbar {
    height: 5px;
}

.ai-chat__products::-webkit-scrollbar-track {
    background: transparent;
}

.ai-chat__products::-webkit-scrollbar-thumb {
    border-radius: 5px;
    background: #c9b3bb;
}

.ai-chat__product {
    width: clamp(238px, 78%, 280px);
    height: 350px;
    min-width: clamp(238px, 78%, 280px);
    flex: 0 0 clamp(238px, 78%, 280px);
    display: grid;
    grid-template-rows: 210px minmax(0, 1fr);
    overflow: hidden;
    border: 1px solid var(--ai-line);
    border-radius: 8px;
    background: #fff;
    scroll-snap-align: start;
    scroll-snap-stop: always;
}

.ai-chat__carousel-button {
    position: absolute;
    top: 91px;
    z-index: 2;
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid #d8c9ce;
    border-radius: 50%;
    color: var(--ai-wine);
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 3px 12px rgba(32, 33, 36, 0.16);
    cursor: pointer;
}

.ai-chat__carousel-button--previous {
    left: 6px;
}

.ai-chat__carousel-button--next {
    right: 6px;
}

.ai-chat__carousel-button:hover,
.ai-chat__carousel-button:focus-visible {
    border-color: var(--ai-wine);
    color: var(--ai-wine-dark);
    outline: none;
}

.ai-chat__carousel-button:disabled {
    visibility: hidden;
    pointer-events: none;
}

.ai-chat__product-image {
    width: 100%;
    height: 210px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
    border-bottom: 1px solid var(--ai-line);
    background: #fff;
}

.ai-chat__product img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #fff;
}

.ai-chat__product-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #b49ba4;
    background: #f2edef;
    font-size: 42px;
}

.ai-chat__product-info {
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 11px;
}

.ai-chat__product-title {
    display: -webkit-box;
    overflow: hidden;
    color: var(--ai-ink);
    font-size: 14px;
    font-weight: 700;
    line-height: 1.25;
    text-decoration: none;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.ai-chat__product-title:hover,
.ai-chat__product-title:focus-visible {
    color: var(--ai-wine);
    outline: none;
}

.ai-chat__product-price {
    margin-top: 8px;
    font-size: 16px;
    font-weight: 700;
}

.ai-chat__product-old-price {
    margin-left: 5px;
    color: var(--ai-muted);
    font-size: 12px;
    font-weight: 400;
    text-decoration: line-through;
}

.ai-chat__product-actions {
    width: 100%;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 34px;
    gap: 6px;
    margin-top: auto;
    padding-top: 9px;
}

.ai-chat__cart-button,
.ai-chat__product-details {
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font: inherit;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}

.ai-chat__cart-button {
    gap: 6px;
    overflow: hidden;
    padding: 0 9px;
    border: 1px solid var(--ai-wine);
    color: #fff;
    background: var(--ai-wine);
    white-space: nowrap;
}

.ai-chat__cart-button:hover,
.ai-chat__cart-button:focus-visible {
    border-color: var(--ai-wine-dark);
    background: var(--ai-wine-dark);
    outline: none;
}

.ai-chat__cart-button.is-added {
    border-color: var(--ai-success);
    background: var(--ai-success);
}

.ai-chat__cart-button.is-error {
    border-color: #a52b2b;
    background: #a52b2b;
}

.ai-chat__cart-button.is-loading i {
    animation: ai-chat-spin 700ms linear infinite;
}

.ai-chat__cart-button:disabled {
    cursor: default;
}

@keyframes ai-chat-spin {
    to { transform: rotate(360deg); }
}

.ai-chat__product-details {
    border: 1px solid #c9b3bb;
    color: var(--ai-wine);
    background: #fff;
    text-decoration: none;
}

.ai-chat__product-details:hover,
.ai-chat__product-details:focus-visible {
    border-color: var(--ai-wine);
    color: var(--ai-wine-dark);
    outline: none;
}

.ai-chat__orders {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ai-chat__order {
    padding: 12px;
    border: 1px solid var(--ai-line);
    border-radius: 8px;
    background: #fff;
}

.ai-chat__order-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}

.ai-chat__order-heading strong {
    font-size: 15px;
    line-height: 1.3;
}

.ai-chat__order-status {
    max-width: 58%;
    padding: 4px 6px;
    border-radius: 6px;
    color: #315c43;
    background: #e6f3eb;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.2;
    text-align: right;
}

.ai-chat__order-status--3,
.ai-chat__order-status--4 {
    color: #62666b;
    background: #eceeef;
}

.ai-chat__order-meta {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    margin-top: 11px;
}

.ai-chat__order-meta > span {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 4px;
    color: var(--ai-muted);
    font-size: 12px;
    line-height: 1.2;
}

.ai-chat__order-meta i {
    flex: 0 0 auto;
    color: var(--ai-wine);
}

.ai-chat__order-tracking {
    margin-top: 9px;
    padding-top: 8px;
    border-top: 1px solid var(--ai-line);
    font-size: 12px;
    font-weight: 700;
}

.ai-chat__order-items {
    margin: 9px 0 0;
    padding: 8px 0 0 18px;
    border-top: 1px solid var(--ai-line);
    font-size: 12px;
    line-height: 1.35;
}

.ai-chat__order-details {
    display: inline-block;
    margin-top: 9px;
    color: var(--ai-wine);
    font-size: 12px;
    font-weight: 700;
    text-decoration: none;
}

.ai-chat__order-details:hover,
.ai-chat__order-details:focus-visible {
    color: var(--ai-wine-dark);
    text-decoration: underline;
    outline: none;
}

.ai-chat__auth {
    width: 100%;
    padding: 13px;
    border: 1px solid #d6c3ca;
    border-radius: 8px;
    background: #fff;
}

.ai-chat__auth > strong {
    display: block;
    font-size: 15px;
    line-height: 1.3;
}

.ai-chat__auth > p {
    margin: 4px 0 11px;
    color: var(--ai-muted);
    font-size: 13px;
    line-height: 1.35;
}

.ai-chat__auth-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 7px;
}

.ai-chat__auth-row[hidden] {
    display: none;
}

.ai-chat__auth input {
    width: 100%;
    min-width: 0;
    height: 40px;
    padding: 0 10px;
    border: 1px solid #cfd1d4;
    border-radius: 8px;
    color: var(--ai-ink);
    background: #fff;
    font: inherit;
    font-size: 14px;
    letter-spacing: 0;
}

.ai-chat__auth input:focus {
    border-color: var(--ai-wine);
    box-shadow: 0 0 0 2px rgba(124, 24, 55, 0.1);
    outline: none;
}

.ai-chat__auth button {
    min-height: 40px;
    padding: 0 11px;
    border: 0;
    border-radius: 8px;
    color: #fff;
    background: var(--ai-wine);
    font: inherit;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}

.ai-chat__auth button:hover,
.ai-chat__auth button:focus-visible {
    background: var(--ai-wine-dark);
    outline: none;
}

.ai-chat__auth.is-loading button {
    cursor: wait;
    opacity: 0.58;
}

.ai-chat__auth-feedback {
    min-height: 17px;
    margin-top: 7px;
    color: var(--ai-success);
    font-size: 12px;
    line-height: 1.3;
}

.ai-chat__auth-feedback.is-error {
    color: #a52b2b;
}

.ai-chat__suggestions {
    display: flex;
    gap: 7px;
    overflow-x: auto;
    padding: 10px 12px 8px;
    border-top: 1px solid var(--ai-line);
    background: #fff;
    scrollbar-width: none;
}

.ai-chat__suggestions::-webkit-scrollbar {
    display: none;
}

.ai-chat__suggestions button {
    min-height: 34px;
    flex: 0 0 auto;
    padding: 7px 10px;
    border: 1px solid #c9b3bb;
    border-radius: 8px;
    color: var(--ai-wine-dark);
    background: #fff;
    font: inherit;
    font-size: 13px;
    line-height: 1.15;
    cursor: pointer;
}

.ai-chat__suggestions button:hover,
.ai-chat__suggestions button:focus-visible {
    border-color: var(--ai-wine);
    background: #fbf5f7;
    outline: none;
}

.ai-chat__composer {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 42px;
    align-items: end;
    gap: 8px;
    padding: 9px 11px 11px;
    background: #fff;
}

.ai-chat__composer textarea {
    width: 100%;
    min-height: 42px;
    max-height: 112px;
    resize: none;
    overflow-y: auto;
    padding: 10px 12px;
    border: 1px solid #cfd1d4;
    border-radius: 8px;
    color: var(--ai-ink);
    background: #fff;
    font: inherit;
    font-size: 15px;
    line-height: 1.35;
    letter-spacing: 0;
}

.ai-chat__composer textarea:focus {
    border-color: var(--ai-wine);
    box-shadow: 0 0 0 2px rgba(124, 24, 55, 0.1);
    outline: none;
}

.ai-chat__send {
    width: 42px;
    height: 42px;
    color: #fff;
    background: var(--ai-wine);
    font-size: 15px;
}

.ai-chat__send:hover,
.ai-chat__send:focus-visible {
    background: var(--ai-wine-dark);
    outline: none;
}

.ai-chat__send:disabled {
    cursor: wait;
    opacity: 0.55;
}

html.ai-chat-page-locked,
body.ai-chat-page-locked {
    overflow: hidden;
    overscroll-behavior: none;
}

@media (max-width: 767px) {
    .ai-chat {
        right: auto;
        left: 14px;
        bottom: 78px;
    }

    .ai-chat__launcher {
        width: 92px;
        height: 92px;
    }

    .ai-chat__panel {
        position: fixed;
        top: var(--ai-viewport-top, 0px);
        right: 0;
        bottom: auto;
        left: 0;
        width: 100%;
        height: var(--ai-viewport-height, 100dvh);
        max-height: var(--ai-viewport-height, 100dvh);
        min-height: 0;
        border: 0;
        border-radius: 0;
    }

    .ai-chat--open .ai-chat__launcher {
        display: none;
    }

    .ai-chat__header {
        min-height: 64px;
        padding-top: max(10px, env(safe-area-inset-top));
    }

    .ai-chat__messages {
        overscroll-behavior-y: contain;
        padding-bottom: 14px;
    }

    .ai-chat__composer {
        padding-bottom: max(10px, env(safe-area-inset-bottom));
    }

    .ai-chat__composer textarea,
    .ai-chat__auth input {
        font-size: 16px;
    }

    .ai-chat__auth-row {
        grid-template-columns: 1fr;
    }

    .ai-chat__auth button {
        width: 100%;
    }
}

@media (prefers-reduced-motion: reduce) {
    .ai-chat__panel,
    .ai-chat__typing i {
        animation: none;
    }

    .ai-chat__launcher {
        transition: none;
    }
}
