.ensup-chat {
    --ensup-chat-blue: #06377c;
    --ensup-chat-red: #e30616;
    position: fixed;
    right: max(22px, env(safe-area-inset-right));
    bottom: max(22px, env(safe-area-inset-bottom));
    z-index: 10000;
    font-family: inherit;
}

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

.ensup-chat__toggle {
    position: relative;
    display: grid;
    width: 68px;
    height: 68px;
    place-items: center;
    border: 0;
    border-radius: 50%;
    color: #fff;
    background: linear-gradient(145deg, #0b55a3, var(--ensup-chat-blue));
    box-shadow: 0 9px 28px rgb(0 35 83 / 28%), inset 0 0 0 1px rgb(255 255 255 / 18%);
    cursor: pointer;
    transition: transform .2s ease, box-shadow .2s ease;
}

.ensup-chat__toggle::before {
    position: absolute;
    inset: -3px;
    padding: 1.5px;
    border-radius: inherit;
    background: conic-gradient(
        from 0deg,
        #06377c,
        #1688e8 24%,
        #e30616 50%,
        #ff6470 70%,
        #06377c
    );
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    filter: drop-shadow(0 0 3px rgb(21 111 202 / 24%));
    content: "";
    animation: ensup-chat-halo-spin 5s linear infinite;
}

.ensup-chat__toggle:hover {
    transform: translateY(-3px) scale(1.03);
    box-shadow: 0 13px 32px rgb(0 35 83 / 34%), inset 0 0 0 1px rgb(255 255 255 / 18%);
}

.ensup-chat__toggle:focus-visible,
.ensup-chat button:focus-visible,
.ensup-chat textarea:focus-visible {
    outline: 3px solid #ffca3a;
    outline-offset: 3px;
}

.ensup-chat__avatar {
    display: block;
    width: 57px;
    height: 57px;
    overflow: hidden;
    border: 1px solid rgb(255 255 255 / 35%);
    border-radius: 50%;
    background: #fff;
}

.ensup-chat__avatar img,
.ensup-chat__header-avatar img {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: inherit;
    object-fit: cover;
    object-position: center;
}

.ensup-chat__online {
    position: absolute;
    top: 0;
    right: 0;
    width: 14px;
    height: 14px;
    border: 2px solid #fff;
    border-radius: 50%;
    background: #20b26b;
}

.ensup-chat__panel {
    position: absolute;
    right: 0;
    bottom: 84px;
    display: flex;
    width: min(350px, calc(100vw - 32px));
    height: min(560px, calc(100dvh - 128px));
    min-height: 370px;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgb(6 55 124 / 12%);
    border-radius: 20px;
    background: #fff;
    box-shadow: 0 20px 60px rgb(12 33 64 / 24%);
    transform-origin: bottom right;
    animation: ensup-chat-open .18s ease-out;
}

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

.ensup-chat__header {
    display: flex;
    min-height: 52px;
    align-items: center;
    justify-content: space-between;
    padding: 6px 10px;
    color: #fff;
    background: linear-gradient(112deg, #06377c 0%, #0758a6 34%, #174d8b 53%, #a91e3a 78%, #e30616 100%);
    background-size: 190% 190%;
    animation: ensup-chat-header-flow 9s ease-in-out infinite alternate;
}

.ensup-chat__identity {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 11px;
}

.ensup-chat__header-avatar {
    display: block;
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    overflow: hidden;
    border: 1px solid rgb(255 255 255 / 30%);
    border-radius: 50%;
    background: #fff;
}

.ensup-chat__heading {
    margin: 0;
    color: inherit;
    font-size: 15px;
    font-weight: 700;
    line-height: 1.3;
}

.ensup-chat__availability {
    display: block;
    margin-top: 3px;
    color: rgb(255 255 255 / 82%);
    font-size: 12px;
}

.ensup-chat__close {
    display: grid;
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
    place-items: center;
    border: 0;
    border-radius: 50%;
    color: #fff;
    background: rgb(255 255 255 / 12%);
    cursor: pointer;
}

.ensup-chat__messages {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 12px;
    overflow: auto;
    padding: 18px 15px;
    background: #f5f7fb;
    overscroll-behavior: contain;
}

.ensup-chat__message {
    max-width: 88%;
    align-self: flex-start;
    padding: 11px 13px;
    border: 1px solid #e5eaf2;
    border-radius: 15px 15px 15px 5px;
    color: #26364b;
    background: #fff;
    box-shadow: 0 2px 8px rgb(20 48 82 / 4%);
    font-size: 14px;
    line-height: 1.5;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}

.ensup-chat__message--user {
    align-self: flex-end;
    border-color: var(--ensup-chat-blue);
    border-radius: 15px 15px 5px 15px;
    color: #fff;
    background: var(--ensup-chat-blue);
}

.ensup-chat__links {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    margin-top: 10px;
}

.ensup-chat__link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 10px;
    border: 1px solid rgb(6 55 124 / 16%);
    border-radius: 999px;
    color: var(--ensup-chat-blue);
    background: #f4f8ff;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.3;
    text-decoration: none;
}

.ensup-chat__link:hover {
    border-color: var(--ensup-chat-blue);
    background: #e9f1ff;
}

.ensup-chat__typing {
    display: inline-flex;
    min-width: 48px;
    align-items: center;
    gap: 4px;
}

.ensup-chat__typing i {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #8796aa;
    animation: ensup-chat-dot .9s infinite ease-in-out;
}

.ensup-chat__typing i:nth-child(2) { animation-delay: .12s; }
.ensup-chat__typing i:nth-child(3) { animation-delay: .24s; }

.ensup-chat__form {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 12px 12px;
    background: #fff;
}

.ensup-chat__input {
    display: block;
    width: 100%;
    min-height: 40px;
    max-height: 96px;
    resize: none;
    padding: 9px 11px;
    border: 1px solid #dce3ed;
    border-radius: 14px;
    color: #172a43;
    background: #f8fafd;
    font: inherit;
    font-size: 14px;
    line-height: 1.45;
}

.ensup-chat__input::placeholder { color: #7e8ca0; }
.ensup-chat__input:focus { border-color: #2a6db6; outline: 0; }

.ensup-chat__send {
    display: grid;
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
    place-items: center;
    border: 0;
    border-radius: 14px;
    color: #fff;
    background: var(--ensup-chat-blue);
    cursor: pointer;
    transition: background .18s ease, transform .18s ease;
}

.ensup-chat__send:hover { background: #0b55a3; transform: translateY(-1px); }
.ensup-chat__send:disabled { cursor: wait; opacity: .6; }

.ensup-chat__note {
    margin: 0;
    padding: 0 14px 10px;
    color: #768499;
    background: #fff;
    font-size: 10px;
    text-align: center;
}

.ensup-chat__sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@keyframes ensup-chat-open {
    from { opacity: 0; transform: translateY(8px) scale(.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes ensup-chat-halo-spin {
    to { transform: rotate(1turn); }
}

@keyframes ensup-chat-header-flow {
    from { background-position: 0% 50%; }
    to { background-position: 100% 50%; }
}

@keyframes ensup-chat-dot {
    0%, 60%, 100% { opacity: .45; transform: translateY(0); }
    30% { opacity: 1; transform: translateY(-3px); }
}

@media (max-width: 520px) {
    .ensup-chat { right: max(15px, env(safe-area-inset-right)); bottom: max(15px, env(safe-area-inset-bottom)); }
    .ensup-chat__toggle { width: 60px; height: 60px; }
    .ensup-chat__avatar { width: 52px; height: 52px; }
    .ensup-chat__panel {
        position: fixed;
        right: 10px;
        bottom: max(84px, calc(env(safe-area-inset-bottom) + 74px));
        width: min(350px, calc(100vw - 20px));
        height: min(590px, calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 108px));
        min-height: 340px;
        border-radius: 18px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .ensup-chat *, .ensup-chat *::before, .ensup-chat *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
        transition-duration: .01ms !important;
    }
}
