:root {
    /* =========================================================
       CORES
       ========================================================= */

    --chat--color--primary: #2563eb;
    --chat--color--primary-shade-50: #1d4ed8;
    --chat--color--primary--shade-100: #1e40af;

    --chat--color--secondary: #16a34a;
    --chat--color-secondary-shade-50: #15803d;

    --chat--color-white: #ffffff;

    --chat--color-light: #f8fafc;
    --chat--color-light-shade-50: #f1f5f9;
    --chat--color-light-shade-100: #e2e8f0;

    --chat--color-medium: #cbd5e1;

    --chat--color-dark: #0f172a;

    --chat--color-disabled: #cbd5e1;

    --chat--color-typing: #64748b;

    /* =========================================================
       BASE
       ========================================================= */

    --chat--spacing: 1rem;

    --chat--border-radius: 8px;

    --chat--transition-duration: 0.2s;

    --chat--font-family:
        Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Helvetica Neue",
        sans-serif;

    /* =========================================================
       JANELA
       ========================================================= */

    --chat--window--width: 390px;
    --chat--window--height: 620px;

    --chat--window--bottom: 100px;
    --chat--window--right: 20px;

    --chat--window--z-index: 10050;

    --chat--window--border: 1px solid #e2e8f0;

    --chat--window--border-radius: 16px;

    --chat--window--margin-bottom: 12px;

    /* =========================================================
       HEADER
       ========================================================= */

    --chat--header-height: auto;

    --chat--header--padding: 14px 16px;

    --chat--header--background: #ffffff;

    --chat--header--color: #1c1f24;

    --chat--header--border-top: none;
    --chat--header--border-bottom: 1px solid #e3e6ea;
    --chat--header--border-left: none;
    --chat--header--border-right: none;

    --chat--heading--font-size: 1.05rem;

    --chat--subtitle--font-size: 0.82rem;

    --chat--subtitle--line-height: 1.4;

    /* =========================================================
       MENSAGENS
       ========================================================= */

    --chat--message--font-size: 0.94rem;

    --chat--message--padding: 11px 14px;

    --chat--message--border-radius: 16px;

    --chat--message-line-height: 1.5;

    --chat--message--margin-bottom: 10px;

    /* BOT */

    --chat--message--bot--background: #eceef2;

    --chat--message--bot--color: #1e293b;

    --chat--message--bot--border: none;

    /* USUÁRIO */

    --chat--message--user--background: #2563eb;

    --chat--message--user--color: #ffffff;

    --chat--message--user--border: none;

    /* Código */

    --chat--message--pre--background: #f1f5f9;

    --chat--messages-list--padding: 16px;

    /* =========================================================
       BOTÃO FLUTUANTE
       ========================================================= */

    --chat--toggle--size: 58px;

    --chat--toggle--width: 58px;

    --chat--toggle--height: 58px;

    --chat--toggle--border-radius: 50%;

    --chat--toggle--background: #2563eb;

    --chat--toggle--hover--background: #1d4ed8;

    --chat--toggle--active--background: #1e40af;

    --chat--toggle--color: #ffffff;

    /* =========================================================
       INPUT
       ========================================================= */

    --chat--textarea--height: 44px;

    --chat--textarea--max-height: 160px;

    --chat--input--font-size: 0.95rem;

    --chat--input--border: 0;

    --chat--input--border-radius: 0;

    --chat--input--padding: 10px 12px;

    --chat--input--background: #ffffff;

    --chat--input--text-color: #0f172a;

    --chat--input--line-height: 1.4;

    --chat--input--placeholder--font-size: 0.9rem;

    --chat--input--border-active: 0;

    --chat--input--left--panel--width: 2rem;

    --chat--input--container--background: #ffffff;

    --chat--input--container--border: 0;

    --chat--input--container--border-radius: 0;

    --chat--input--container--padding: 6px 8px 6px 6px;

    --chat--input--button--border-radius: 8px;

    /* =========================================================
       BOTÕES
       ========================================================= */

    --chat--button--padding: 10px 16px;

    --chat--button--border-radius: 10px;

    --chat--button--font-size: 0.9rem;

    --chat--button--line-height: 1.2;

    --chat--button--color--primary: #ffffff;

    --chat--button--background--primary: #2563eb;

    --chat--button--border--primary: none;

    --chat--button--color--primary--hover: #ffffff;

    --chat--button--background--primary--hover: #1d4ed8;

    --chat--button--border--primary--hover: none;

    --chat--button--color--primary--disabled: #ffffff;

    --chat--button--background--primary--disabled: #93c5fd;

    --chat--button--border--primary--disabled: none;

    --chat--button--color--secondary: #ffffff;

    --chat--button--background--secondary: #64748b;

    --chat--button--border--secondary: none;

    --chat--button--color--secondary--hover: #ffffff;

    --chat--button--background--secondary--hover: #475569;

    --chat--button--border--secondary--hover: none;

    --chat--button--color--secondary--disabled: #ffffff;

    --chat--button--background--secondary--disabled: #cbd5e1;

    --chat--close--button--color-hover: #93c5fd;

    /* =========================================================
       ENVIO / ARQUIVOS
       ========================================================= */

    --chat--input--send--button--background: var(--n8n-chat-primary, #2563eb);

    --chat--input--send--button--color: #ffffff;

    --chat--input--send--button--background-hover: var(--n8n-chat-primary, #2563eb);

    --chat--input--send--button--color-hover: #ffffff;

    --chat--input--file--button--background: transparent;

    --chat--input--file--button--color: #64748b;

    --chat--input--file--button--background-hover: #f1f5f9;

    --chat--input--file--button--color-hover: #2563eb;

    --chat--files-spacing: 0.25rem;

    /* =========================================================
       BODY / FOOTER
       ========================================================= */

    --chat--body--background: #ffffff;

    --chat--footer--background: #ffffff;

    --chat--footer--color: #0f172a;
}

/* =========================================================
     MENSAGENS
     ========================================================= */

.chat-message {
    width: fit-content;
    max-width: 82%;
    border-radius: 8px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

/* Mensagem do usuário: canto reto do lado de quem fala (balão sem "pílula") */

.chat-message.chat-message-from-user {
    margin-left: auto;
    width: fit-content;
    max-width: 82%;
    border-radius: 16px 16px 5px 16px;
}

/* Mensagem do bot */

.chat-message.chat-message-from-bot {
    margin-right: auto;
    width: fit-content;
    max-width: 82%;
    border-radius: 16px 16px 16px 5px;
}

/* Indicador "digitando..." — compacto, centralizado; sem bounce (desalinha visualmente) */
.n8n-chat .chat-message.chat-message-typing {
    max-width: none !important;
    width: auto !important;
    min-height: 0 !important;
    height: auto !important;
    padding: 12px 16px !important;
    margin-top: var(--chat--message--margin-bottom, 10px);
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-sizing: border-box !important;
    overflow: visible !important;
    line-height: 0 !important;
}

.n8n-chat .chat-message-typing .chat-message-typing-body {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 5px;
    margin: 0 !important;
    padding: 0 !important;
    height: 10px !important;
    min-height: 10px !important;
    line-height: 0 !important;
}

.n8n-chat .chat-message-typing .chat-message-typing-circle {
    width: 8px !important;
    height: 8px !important;
    margin: 0 !important;
    padding: 0 !important;
    display: block !important;
    flex-shrink: 0;
    position: relative;
    top: 0 !important;
    transform: none;
    animation-name: n8n-chat-typing-pulse !important;
    animation-duration: 0.9s !important;
    animation-timing-function: ease-in-out !important;
    animation-iteration-count: infinite !important;
}

.n8n-chat .chat-message-typing .chat-message-typing-circle:nth-child(1) {
    animation-delay: 0s !important;
}

.n8n-chat .chat-message-typing .chat-message-typing-circle:nth-child(2) {
    animation-delay: 0.15s !important;
}

.n8n-chat .chat-message-typing .chat-message-typing-circle:nth-child(3) {
    animation-delay: 0.3s !important;
}

@keyframes n8n-chat-typing-pulse {
    0%,
    80%,
    100% {
        transform: scale(0.85);
        opacity: 0.45;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* =========================================================
     JANELA
     ========================================================= */

.chat-window {
    box-shadow:
        0 20px 50px rgba(15, 23, 42, 0.18),
        0 5px 15px rgba(15, 23, 42, 0.08);
}

/* =========================================================
     HEADER
     ========================================================= */

.chat-header {
    border-radius: 16px 16px 0 0;
}


.n8n-chat .chat-heading {
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    width: 100%;
}

.n8n-chat .chat-close-button {
    color: #1c1f24;
    opacity: 0.9;
    padding: 4px;
    margin: 0;
    flex-shrink: 0;
    cursor: pointer;
    background: transparent;
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: opacity 0.15s ease, background 0.15s ease;
}

.n8n-chat .chat-close-button:hover {
    opacity: 1;
    color: #1c1f24;
    background: rgba(15, 23, 42, 0.08);
}

/* =========================================================
     ÁREA DAS MENSAGENS
     ========================================================= */

.chat-messages-list {
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}

/* Chrome / Edge / Safari */

.chat-messages-list::-webkit-scrollbar {
    width: 6px;
}

.chat-messages-list::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages-list::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}

.chat-messages-list::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* =========================================================
     INPUT
     ========================================================= */

.n8n-chat .chat-input {
    transition:
        border-color 0.2s ease,
        box-shadow 0.2s ease;
}

.n8n-chat .chat-input:focus-within {
    outline: none;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.n8n-chat .chat-inputs {
    align-items: center !important;
    gap: 4px;
}

.n8n-chat .chat-inputs textarea {
    display: block;
    margin: 0;
    padding: 10px 12px !important;
    line-height: 1.4;
    min-height: 44px !important;
    max-height: var(--chat--textarea--max-height, 160px);
    box-sizing: border-box !important;
    /* Sem setas em 1 linha; o n8n ajusta a altura ao digitar */
    overflow-y: hidden !important;
    resize: none;
    scrollbar-width: none;
}

.n8n-chat .chat-inputs textarea::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
}

.n8n-chat .chat-inputs {
    position: relative;
}

/* Selo pequeno acima do botão de enviar; só aparece depois que o cliente começa a digitar. */
.n8n-chat .n8n-chat-counter {
    position: absolute;
    right: 10px;
    top: -9px;
    z-index: 1;
    display: none;
    padding: 0 6px;
    border: 1px solid #e2e8f0;
    border-radius: 999px;
    background: #ffffff;
    font-size: 10px;
    line-height: 16px;
    color: #64748b;
    pointer-events: none;
}

.n8n-chat .n8n-chat-counter.is-visible {
    display: block;
}

.n8n-chat .n8n-chat-counter.is-limit {
    color: #b45309;
    font-weight: 600;
}

.n8n-chat .n8n-chat-counter.is-over {
    color: #b91c1c;
    font-weight: 700;
}

.n8n-chat .chat-inputs-controls {
    display: flex;
    align-items: center;
    align-self: center;
    height: 44px;
}

.n8n-chat .chat-input-send-button,
.n8n-chat .chat-input-file-button {
    margin: 0 !important;
    height: 40px !important;
    width: 40px !important;
    flex-shrink: 0;
    align-self: center !important;
    font-size: 20px;
}

/* =========================================================
     BOTÃO FLUTUANTE
     ========================================================= */

/* Sobe o chat acima do WhatsApp (70px + bottom 20px) e fica na frente */
.n8n-chat .chat-window-wrapper {
    z-index: var(--chat--window--z-index, 10050);
}

.n8n-chat .chat-window-toggle {
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.25);
    transition:
        transform 0.2s ease,
        box-shadow 0.2s ease;
    position: relative;
    z-index: 1;
}

.n8n-chat .chat-window-toggle:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 25px rgba(15, 23, 42, 0.3);
}

/* Quando o chat está ativo, o WhatsApp não cobre o toggle */
body:has(.chat-window-wrapper) .wpp-floater {
    z-index: 10;
    bottom: 20px;
    right: 15px;
}


/* Cartão do WhatsApp no handoff (prévia de link) */
.n8n-wa-card {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    box-sizing: border-box;
    max-width: 100%;
    padding: 12px;
    border: 1px solid #bbf7d0;
    border-left: 4px solid #25d366;
    border-radius: 12px;
    background: #f0fdf4;
    color: #0f172a;
    text-decoration: none;
}

.n8n-wa-card,
.n8n-wa-card * {
    text-decoration: none !important;
}

.n8n-wa-card:hover,
.n8n-wa-card:focus-visible {
    background: #dcfce7;
}

.n8n-wa-card__icon {
    display: flex;
    flex: 0 0 40px;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #25d366;
    color: #ffffff;
}

.n8n-wa-card__body {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.n8n-wa-card__title {
    font-weight: 600;
}

.n8n-wa-card__protocol {
    font-size: 0.8rem;
    color: #15803d;
}

.n8n-wa-card__summary {
    display: -webkit-box;
    overflow: hidden;
    font-size: 0.82rem;
    color: #475569;
    overflow-wrap: anywhere;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

/* Cards de produto e de cupom: bolhas retas, em vez do balão de texto */
.chat-message.n8n-card-bubble {
    width: 100%;
    max-width: 82%;
    padding: 0;
    overflow: hidden;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}

.chat-message.n8n-card-bubble .chat-message-markdown {
    padding: 0;
}

.chat-message.n8n-card-bubble img {
    display: block;
    width: 100%;
    height: 150px;
    margin: 0;
    object-fit: contain;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
}

.chat-message.n8n-card-bubble p {
    margin: 0;
    padding: 8px 12px 0;
}

.chat-message.n8n-card-bubble p:last-child {
    padding-bottom: 12px;
}

.chat-message.n8n-card-bubble p > img {
    margin: 0 -12px;
    width: calc(100% + 24px);
}

.chat-message.n8n-card-bubble a {
    color: #0f172a;
    text-decoration: none;
}

.chat-message.n8n-card-bubble a:hover {
    text-decoration: underline;
}

/* Card de produto: foto à esquerda, dados à direita, card inteiro clicável */
.n8n-product-card {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 12px;
    color: #0f172a;
}

.chat-message.n8n-card-bubble a.n8n-product-card,
.chat-message.n8n-card-bubble a.n8n-product-card:hover {
    text-decoration: none;
}

.n8n-product-card:hover .n8n-product-card__name,
.n8n-product-card:focus-visible .n8n-product-card__name {
    text-decoration: underline;
}

.n8n-product-card__thumb {
    flex: 0 0 72px;
    width: 72px;
    height: 72px;
    overflow: hidden;
    border-radius: 8px;
    background: #f1f5f9;
}

.chat-message.n8n-card-bubble .n8n-product-card__thumb img {
    width: 100%;
    height: 100%;
    border: 0;
    object-fit: contain;
    background: transparent;
}

.n8n-product-card__body {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.n8n-product-card__name {
    display: -webkit-box;
    overflow: hidden;
    font-weight: 700;
    line-height: 1.3;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.n8n-product-card__subtitle {
    overflow: hidden;
    font-size: 0.8rem;
    color: #64748b;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.n8n-product-card__old-price {
    font-size: 0.8rem;
    color: #64748b;
    text-decoration: line-through;
}

.n8n-product-card__price {
    font-size: 1.15rem;
    font-weight: 700;
}

.n8n-product-card__pix {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    font-size: 0.85rem;
    color: #15803d;
}

.n8n-product-card__badge {
    padding: 1px 6px;
    border-radius: 4px;
    background: #dcfce7;
    font-size: 0.75rem;
    font-weight: 600;
}

.n8n-product-card__meta {
    font-size: 0.8rem;
    color: #475569;
}

/* Cartão de cupom (faixa na cor da loja; só o código em destaque, com botão de copiar) */
.n8n-coupon-card {
    display: flex;
    flex-direction: column;
    gap: 4px;
    box-sizing: border-box;
    padding: 12px 14px;
    border-left: 4px solid var(--n8n-chat-primary, #2563eb);
    background: #f8fafc;
}

.n8n-coupon-card__label {
    font-size: 0.75rem;
    color: #64748b;
}

.n8n-coupon-card__row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.n8n-coupon-card__code {
    padding: 2px 8px;
    border: 1px dashed var(--n8n-chat-primary, #94a3b8);
    border-radius: 4px;
    background: #ffffff;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #0f172a;
}

.n8n-coupon-card__copy {
    padding: 3px 10px;
    border: 0;
    border-radius: 4px;
    background: var(--n8n-chat-primary, #2563eb);
    color: #ffffff;
    font-size: 0.75rem;
    cursor: pointer;
}

.n8n-coupon-card__discount {
    font-size: 0.9rem;
    color: #0f172a;
}

.n8n-coupon-card__rule {
    font-size: 0.8rem;
    color: #475569;
}

/* Cartão do carrinho: cabeçalho, itens com foto e subtotal, total em destaque e botão na cor da loja */
.n8n-cart-card {
    display: flex;
    flex-direction: column;
    color: #0f172a;
}

.n8n-cart-card__header {
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 10px 12px;
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
}

.n8n-cart-card__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--n8n-chat-primary, #2563eb);
    color: #ffffff;
}

.n8n-cart-card__title {
    flex: 1;
    font-weight: 700;
}

.n8n-cart-card__count {
    padding: 2px 8px;
    border-radius: 999px;
    background: #e2e8f0;
    font-size: 0.75rem;
    font-weight: 600;
    color: #334155;
}

.n8n-cart-card__items {
    display: flex;
    flex-direction: column;
    padding: 4px 12px;
}

.chat-message.n8n-card-bubble a.n8n-cart-card__item {
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 8px 0;
    color: #0f172a;
    text-decoration: none;
}

.n8n-cart-card__item + .n8n-cart-card__item {
    border-top: 1px dashed #e2e8f0;
}

.n8n-cart-card__item:hover .n8n-cart-card__name,
.n8n-cart-card__item:focus-visible .n8n-cart-card__name {
    text-decoration: underline;
}

.n8n-cart-card__thumb {
    flex: 0 0 48px;
    width: 48px;
    height: 48px;
    overflow: hidden;
    border-radius: 6px;
    background: #f1f5f9;
}

.chat-message.n8n-card-bubble .n8n-cart-card__thumb img {
    width: 100%;
    height: 100%;
    border: 0;
    object-fit: contain;
    background: transparent;
}

.n8n-cart-card__info {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.n8n-cart-card__name {
    display: -webkit-box;
    overflow: hidden;
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1.3;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.n8n-cart-card__qty {
    font-size: 0.75rem;
    color: #64748b;
}

.n8n-cart-card__subtotal {
    font-size: 0.85rem;
    font-weight: 700;
    white-space: nowrap;
}

.n8n-cart-card__summary {
    display: grid;
    grid-template-columns: 1fr auto;
    row-gap: 2px;
    align-items: baseline;
    padding: 10px 12px;
    border-top: 1px solid #e2e8f0;
}

.n8n-cart-card__total-label {
    font-size: 0.85rem;
    color: #475569;
}

.n8n-cart-card__total {
    font-size: 1.2rem;
    font-weight: 800;
}

.n8n-cart-card__pix {
    grid-column: 1 / -1;
    justify-self: end;
    font-size: 0.8rem;
    font-weight: 600;
    color: #15803d;
}

.chat-message.n8n-card-bubble a.n8n-cart-card__cta {
    display: flex;
    gap: 6px;
    align-items: center;
    justify-content: center;
    margin: 0 12px 12px;
    padding: 10px 12px;
    border-radius: 8px;
    background: var(--n8n-chat-primary, #2563eb);
    font-weight: 700;
    color: #ffffff;
    text-decoration: none;
}

.chat-message.n8n-card-bubble a.n8n-cart-card__cta:hover,
.chat-message.n8n-card-bubble a.n8n-cart-card__cta:focus-visible {
    filter: brightness(0.92);
    text-decoration: none;
}

/* =========================================================
     CABEÇALHO: avatar, nome e status
     ========================================================= */

.n8n-chat .chat-heading h1 {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    column-gap: 10px;
    align-items: center;
    flex: 1;
    min-width: 0;
    margin: 0;
    font-weight: 700;
    line-height: 1.25;
}

.n8n-chat-avatar {
    position: relative;
    display: grid;
    grid-row: 1 / span 2;
    grid-column: 1;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--n8n-chat-primary, #2563eb);
    color: #ffffff;
    font-size: 16px;
    font-weight: 700;
    line-height: 1;
}

.n8n-chat-avatar::after {
    content: "";
    position: absolute;
    right: -1px;
    bottom: -1px;
    width: 10px;
    height: 10px;
    border: 2px solid #ffffff;
    border-radius: 50%;
    background: #22c55e;
}

.n8n-chat-avatar img {
    position: absolute;
    inset: 0;
    display: none;
    box-sizing: border-box;
    width: 100%;
    height: 100%;
    padding: 6px;
    border-radius: 50%;
    background: #ffffff;
    object-fit: contain;
    box-shadow: inset 0 0 0 1px #e3e6ea;
}

.n8n-chat-avatar.has-logo img {
    display: block;
}

.n8n-chat .n8n-chat-status {
    grid-column: 2;
    grid-row: 2;
    font-size: 0.75rem;
    font-weight: 400;
    opacity: 0.7;
}

/* =========================================================
     MENSAGENS: avatar do assistente e atalhos
     ========================================================= */

.chat-messages-list .chat-message.chat-message-from-bot,
.chat-messages-list .n8n-quick-replies {
    margin-left: 34px;
}

.chat-messages-list .chat-message.chat-message-from-bot {
    position: relative;
}

.chat-messages-list .chat-message.chat-message-from-bot:not(.n8n-card-bubble) {
    overflow: visible;
    overflow-wrap: anywhere;
}

.chat-messages-list .chat-message.chat-message-from-bot:not(.n8n-card-bubble):not(:has(+ .chat-message-from-bot))::before {
    content: var(--n8n-chat-initial, "A");
    position: absolute;
    bottom: 0;
    left: -34px;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--n8n-chat-primary, #2563eb);
    color: #ffffff;
    font-size: 12px;
    font-weight: 700;
    line-height: 26px;
    text-align: center;
}

.chat-message.n8n-card-bubble {
    max-width: calc(100% - 46px);
}

.n8n-quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 14px;
    margin-bottom: 4px;
}

.n8n-quick-reply {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 36px;
    padding: 0 14px;
    border: 1px solid #d0d5dd;
    border-radius: 8px;
    background: #ffffff;
    color: #1c1f24;
    font: 500 0.85rem/1.2 var(--chat--font-family, sans-serif);
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.n8n-quick-reply svg {
    flex: none;
    width: 18px;
    height: 18px;
    fill: none;
    stroke: var(--n8n-chat-primary, #2563eb);
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.n8n-quick-reply:hover,
.n8n-quick-reply:focus-visible {
    border-color: var(--n8n-chat-primary, #2563eb);
    background: #f6f7f9;
    outline: none;
}

/* =========================================================
     CAMPO DE TEXTO E ENVIO
     ========================================================= */

.n8n-chat .chat-footer {
    padding: 8px 12px 12px;
    border-top: 0;
    background: #ffffff;
}

.n8n-chat .chat-input {
    border-radius: 22px;
    background: #f0f2f5;
}

.n8n-chat .chat-inputs textarea {
    background: transparent;
}

.n8n-chat .chat-input-send-button {
    border-radius: 50%;
}

.n8n-chat .chat-input-send-button:disabled {
    opacity: 0.4;
}

/* =========================================================
     MOBILE: gaveta que sobe do rodapé
     ========================================================= */

@media (max-width: 640px) {
    :root {
        /* 100% da área visível: 100vw inclui a barra de rolagem e cortava a gaveta na borda. */
        --chat--window--width: 100%;
        --chat--window--height: 88vh;
        --chat--window--right: 0;
        --chat--window--bottom: 0;
        --chat--window--margin-bottom: 0;
        --chat--window--border-radius: 24px 24px 0 0;
    }

    @supports (height: 100dvh) {
        :root {
            --chat--window--height: 88dvh;
        }
    }

    .chat-window-wrapper:has(.chat-window:not([style*="display: none"]))::before {
        content: "";
        position: fixed;
        inset: 0;
        z-index: -1;
        background: rgba(10, 12, 16, 0.45);
    }

    /* A gaveta zera right/bottom do wrapper; o botão fechado volta acima do WhatsApp em vez de colar no canto. */
    .n8n-chat .chat-window-toggle {
        margin: 0 10px calc(100px + env(safe-area-inset-bottom, 0px)) auto;
    }

    .chat-window-wrapper:has(.chat-window:not([style*="display: none"])) .chat-window-toggle {
        display: none;
    }

    /* Aberta, a gaveta vai de borda a borda; fechada, o wrapper volta ao tamanho do botão. */
    .chat-window-wrapper:has(.chat-window:not([style*="display: none"])) {
        left: 0;
    }

    /* O arraste do cabeçalho (alça) é do script, não do scroll da página. */
    .n8n-chat .chat-header {
        touch-action: none;
        cursor: grab;
    }

    .n8n-chat .chat-window {
        border: 0;
        border-radius: 24px 24px 0 0;
        box-shadow: 0 -8px 40px rgba(15, 23, 42, 0.28);
    }

    .chat-header {
        position: relative;
        padding-top: 24px;
        border-radius: 24px 24px 0 0;
    }

    .chat-header::before {
        content: "";
        position: absolute;
        top: 9px;
        left: 50%;
        width: 42px;
        height: 5px;
        margin-left: -21px;
        border-radius: 9px;
        background: #cfd3da;
    }

    .n8n-chat .chat-message.chat-message-from-user {
        background: #15171b;
        color: #ffffff;
    }

    .n8n-chat .chat-message.chat-message-from-bot:not(.n8n-card-bubble) {
        background: #f0f1f4;
    }

    .chat-message,
    .chat-message.chat-message-from-user,
    .chat-message.chat-message-from-bot {
        max-width: 88%;
    }

    .n8n-quick-replies {
        flex-direction: column;
        flex-wrap: nowrap;
        gap: 0;
        overflow: hidden;
        border: 1px solid #d0d5dd;
        border-radius: 12px;
        background: #ffffff;
    }

    .n8n-quick-reply {
        justify-content: flex-start;
        gap: 12px;
        min-height: 48px;
        padding: 13px 14px;
        border: 0;
        border-bottom: 1px solid #e3e6ea;
        border-radius: 0;
        font-size: 0.9rem;
    }

    .n8n-quick-reply:last-child {
        border-bottom: 0;
    }

    .n8n-quick-reply:hover,
    .n8n-quick-reply:focus-visible {
        border-bottom-color: #e3e6ea;
    }

    .n8n-chat .chat-footer {
        padding: 10px 12px calc(14px + env(safe-area-inset-bottom, 0px));
    }

    .n8n-chat .chat-input {
        border: 1.5px solid #e3e6ea;
        border-radius: 14px;
        background: #ffffff;
    }

    .n8n-chat .chat-input-send-button {
        border-radius: 12px;
    }
}
