.ivx-chat-launcher {
    position: fixed;
    right: 16px;
    bottom: 18px;
    z-index: 1400;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.ivx-chat-launcher.is-open .ivx-chat-nudge {
    display: none;
}

.ivx-chat-nudge {
    position: absolute;
    right: 6px;
    bottom: calc(100% + 12px);
    max-width: 180px;
    padding: 10px 12px;
    border-radius: 18px 18px 6px 18px;
    background: rgba(17, 24, 39, 0.94);
    color: #fff;
    box-shadow: 0 20px 50px rgba(17, 24, 39, 0.25);
    font-size: 12px;
    line-height: 1.35;
    pointer-events: none;
}

.ivx-chat-button {
    width: 64px;
    height: 64px;
    margin-top: 48px;
    border: 0;
    border-radius: 999px;
    background: linear-gradient(135deg, #111827, #a66d3e);
    color: #fff;
    box-shadow: 0 22px 48px rgba(17, 24, 39, 0.28);
    cursor: pointer;
    font: inherit;
    font-weight: 900;
    position: relative;
}

.ivx-chat-badge {
    position: absolute;
    top: -4px;
    right: -2px;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    border-radius: 999px;
    background: #ef4444;
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 900;
    box-shadow: 0 10px 18px rgba(239, 68, 68, 0.28);
}

.ivx-chat-badge[hidden] {
    display: none !important;
}

.ivx-chat-panel {
    width: min(380px, calc(100vw - 24px));
    height: min(640px, calc(100vh - 104px));
    display: none;
    flex-direction: column;
    overflow: hidden;
    border-radius: 22px;
    border: 1px solid rgba(166, 109, 62, 0.18);
    background: #fffdf9;
    box-shadow: 0 28px 70px rgba(24, 20, 17, 0.22);
    backdrop-filter: blur(16px);
}

.ivx-chat-panel.is-open {
    display: flex;
}

.ivx-chat-header {
    padding: 14px 16px;
    background: linear-gradient(135deg, #171310, #6b4222);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.ivx-chat-header-main {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.ivx-chat-avatar {
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    border-radius: 999px;
    background: linear-gradient(135deg, #25d366, #128c7e);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 900;
    box-shadow: 0 10px 18px rgba(18, 140, 126, 0.26);
}

.ivx-chat-header-copy {
    min-width: 0;
}

.ivx-chat-header strong {
    display: block;
    font-size: 15px;
}

.ivx-chat-header span {
    display: block;
    margin-top: 3px;
    color: rgba(255, 255, 255, 0.82);
    font-size: 12px;
    line-height: 1.35;
}

.ivx-chat-online {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
    color: rgba(255, 255, 255, 0.9);
    font-size: 11px;
    font-weight: 700;
}

.ivx-chat-online::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: #25d366;
    box-shadow: 0 0 0 4px rgba(37, 211, 102, 0.18);
}

.ivx-chat-close {
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
}

.ivx-chat-body {
    padding: 14px 14px 6px;
    flex: 1 1 auto;
    min-height: 140px;
    overflow: auto;
    background:
        radial-gradient(circle at top right, rgba(166, 109, 62, 0.08), transparent 24%),
        #fffdf9;
    display: grid;
    gap: 10px;
    align-content: start;
}

.ivx-chat-body[hidden] {
    display: none !important;
}

.ivx-chat-prechat {
    padding: 16px 14px 8px;
    border-bottom: 1px solid rgba(166, 109, 62, 0.12);
    background: linear-gradient(180deg, #fff9f1 0%, #fffdf9 100%);
}

.ivx-chat-prechat[hidden] {
    display: none;
}

.ivx-chat-prechat-card {
    display: grid;
    gap: 10px;
    padding: 14px;
    border: 1px solid rgba(166, 109, 62, 0.16);
    border-radius: 18px;
    background: #fff;
}

.ivx-chat-prechat-card strong {
    color: #2a1d12;
    font-size: 15px;
}

.ivx-chat-prechat-card span {
    color: #6b5b4f;
    font-size: 12px;
    line-height: 1.45;
}

.ivx-chat-prechat-fields {
    display: grid;
    gap: 8px;
}

.ivx-chat-prechat-fields input,
.ivx-chat-contact input {
    min-height: 42px;
    border-radius: 12px;
    border: 1px solid rgba(93, 75, 60, 0.18);
    padding: 0 12px;
    font: inherit;
    background: #fff;
}

.ivx-chat-start {
    min-height: 44px;
    border: 0;
    border-radius: 14px;
    background: #128c7e;
    color: #fff;
    font: inherit;
    font-weight: 900;
    cursor: pointer;
}

.ivx-chat-message {
    max-width: 88%;
    display: grid;
    gap: 6px;
}

.ivx-chat-message-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.ivx-chat-message-row.user {
    justify-content: flex-end;
}

.ivx-chat-message-bubble {
    padding: 11px 13px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    white-space: pre-wrap;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.04);
}

.ivx-chat-message-avatar {
    width: 28px;
    height: 28px;
    flex: 0 0 28px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 900;
    color: #fff;
}

.ivx-chat-message-avatar.bot,
.ivx-chat-message-avatar.admin {
    background: linear-gradient(135deg, #25d366, #128c7e);
}

.ivx-chat-message-avatar.user {
    background: linear-gradient(135deg, #1f2937, #111827);
}

.ivx-chat-message.user {
    margin-left: auto;
}

.ivx-chat-message.user .ivx-chat-message-bubble {
    background: #111827;
    color: #fff;
    border-bottom-right-radius: 6px;
}

.ivx-chat-message.bot .ivx-chat-message-bubble,
.ivx-chat-message.admin .ivx-chat-message-bubble {
    margin-right: auto;
    background: #f5ede4;
    color: #251b14;
    border-bottom-left-radius: 6px;
}

.ivx-chat-message.admin .ivx-chat-message-bubble {
    background: #e9f5eb;
}

.ivx-chat-message-meta {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #7a6758;
    font-size: 11px;
}

.ivx-chat-message.user .ivx-chat-message-meta {
    justify-content: flex-end;
    color: #6b7280;
}

.ivx-chat-message-time {
    letter-spacing: 0.02em;
}

.ivx-chat-footer {
    flex: 0 0 auto;
    position: sticky;
    bottom: 0;
    border-top: 1px solid rgba(166, 109, 62, 0.06);
    background:
        linear-gradient(180deg, rgba(255, 253, 249, 0.92) 0%, rgba(255, 250, 244, 0.98) 22%, #fffaf4 100%);
    padding: 8px 10px 10px;
    box-shadow: 0 -6px 18px rgba(36, 24, 15, 0.05);
    backdrop-filter: blur(12px);
}

.ivx-chat-footer[hidden] {
    display: none !important;
}

.ivx-chat-quick {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0 0 8px;
    margin: 0;
}

.ivx-chat-quick button {
    min-height: 30px;
    padding: 0 10px;
    border-radius: 999px;
    border: 1px solid rgba(166, 109, 62, 0.18);
    background: #fff;
    color: #4a3627;
    font: inherit;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
}

.ivx-chat-human {
    margin-bottom: 8px;
    padding: 10px;
    border: 1px solid rgba(166, 109, 62, 0.16);
    border-radius: 16px;
    background: #fff;
}

.ivx-chat-human-copy strong {
    display: block;
    margin-bottom: 4px;
    color: #2a1d12;
    font-size: 13px;
}

.ivx-chat-human-copy span {
    display: block;
    color: #6b5b4f;
    font-size: 12px;
    line-height: 1.45;
}

.ivx-chat-contact {
    display: grid;
    gap: 7px;
    margin-top: 8px;
}

.ivx-chat-compose {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 6px;
    align-items: end;
}

.ivx-chat-compose input {
    min-height: 44px;
    border-radius: 14px;
    border: 1px solid rgba(93, 75, 60, 0.18);
    padding: 10px 12px;
    font: inherit;
    background: #fff;
}

.ivx-chat-compose button,
.ivx-chat-escalate {
    min-height: 44px;
    padding: 0 14px;
    border: 0;
    border-radius: 14px;
    background: #111827;
    color: #fff;
    font: inherit;
    font-weight: 900;
    cursor: pointer;
}

.ivx-chat-escalate {
    margin-top: 8px;
    width: 100%;
    min-height: 40px;
    background: #128c7e;
}

.ivx-chat-end {
    min-height: 28px;
    margin-top: 6px;
    border: 0;
    background: transparent;
    color: #7a6758;
    font: inherit;
    font-size: 12px;
    font-weight: 700;
    text-decoration: underline;
    cursor: pointer;
}

.ivx-chat-meta {
    color: #6b5b4f;
    font-size: 11px;
    line-height: 1.4;
    margin-bottom: 8px;
    min-height: 17px;
}

.ivx-chat-typing {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: #128c7e;
    font-weight: 700;
}

.ivx-chat-typing::after {
    content: "";
    width: 18px;
    height: 6px;
    border-radius: 999px;
    background:
        radial-gradient(circle, currentColor 45%, transparent 50%) 0 50%/6px 6px no-repeat,
        radial-gradient(circle, currentColor 45%, transparent 50%) 6px 50%/6px 6px no-repeat,
        radial-gradient(circle, currentColor 45%, transparent 50%) 12px 50%/6px 6px no-repeat;
    animation: ivx-chat-typing 1s linear infinite;
}

@keyframes ivx-chat-typing {
    0% { opacity: .35; transform: translateY(0); }
    50% { opacity: 1; transform: translateY(-1px); }
    100% { opacity: .35; transform: translateY(0); }
}

@media (max-width: 640px) {
    .ivx-chat-launcher {
        right: 12px;
        bottom: 12px;
        left: 12px;
        align-items: stretch;
    }

    .ivx-chat-nudge {
        right: 0;
        bottom: calc(100% + 10px);
        max-width: min(220px, calc(100vw - 96px));
    }

    .ivx-chat-panel {
        width: 100%;
        height: min(76vh, calc(100vh - 88px));
        border-radius: 22px;
    }

    .ivx-chat-footer {
        padding: 8px 8px calc(8px + env(safe-area-inset-bottom, 0px));
    }

    .ivx-chat-button {
        margin-left: auto;
        margin-top: 44px;
        width: 58px;
        height: 58px;
    }

    .ivx-chat-compose {
        grid-template-columns: 1fr;
    }

    .ivx-chat-compose input {
        min-height: 42px;
    }

    .ivx-chat-compose button,
    .ivx-chat-escalate {
        width: 100%;
    }

    .ivx-chat-compose button {
        min-height: 42px;
    }

    .ivx-chat-message {
        max-width: 92%;
    }
}
