.hce-chat-root,
.hce-chat-root * {
    box-sizing: border-box;
}

.hce-chat-root {
    position: fixed;
    bottom: 22px;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.hce-chat-right { right: 22px; }
.hce-chat-left { left: 22px; }

.hce-chat-launcher {
    width: 60px;
    height: 60px;
    border: 0;
    border-radius: 50%;
    display: grid;
    place-items: center;
    cursor: pointer;
    color: #fff;
    padding: 0 !important;
    background: transparent !important;
    box-shadow: 0 12px 32px rgba(0, 0, 0, .24);
    transition: transform .2s ease, box-shadow .2s ease;
}

.hce-chat-launcher:hover,
.hce-chat-launcher:focus-visible {
    transform: translateY(-2px);
    box-shadow: 0 15px 36px rgba(0, 0, 0, .28);
    outline: none;
}

.hce-chat-launcher img {
    display: block;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: transparent !important;
}

.hce-chat-panel {
    position: absolute;
    bottom: 76px;
    width: min(390px, calc(100vw - 32px));
    overflow: hidden;
    border-radius: 18px;
    background: #fff;
    color: #1f2937;
    box-shadow: 0 20px 55px rgba(0, 0, 0, .25);
    opacity: 0;
    visibility: hidden;
    transform: translateY(15px) scale(.98);
    transform-origin: bottom right;
    transition: opacity .2s ease, transform .2s ease, visibility .2s ease;
}

.hce-chat-right .hce-chat-panel { right: 0; }
.hce-chat-left .hce-chat-panel { left: 0; transform-origin: bottom left; }

.hce-chat-root.is-open .hce-chat-panel {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.hce-chat-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 19px 20px;
    color: #fff;
    background: var(--hce-chat-accent) !important;
}

.hce-chat-header strong {
    display: block;
    font-size: 18px;
    line-height: 1.3;
}

.hce-chat-status {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-top: 5px;
    font-size: 13px;
    opacity: .96;
}

.hce-chat-status i {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #22c55e;
    box-shadow: 0 0 0 3px rgba(255,255,255,.18);
}

.hce-chat-close {
    width: 32px;
    height: 32px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    color: #fff;
    background: rgba(255, 255, 255, .14);
    font-size: 25px;
    line-height: 28px;
    cursor: pointer;
}

.hce-chat-body {
    min-height: 270px;
    padding: 18px;
    background: #f5f7fb;
}

.hce-chat-step { display: none; }
.hce-chat-step.is-active { display: block; animation: hceChatFade .22s ease; }

@keyframes hceChatFade {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

.hce-chat-agent-message,
.hce-chat-bubble {
    position: relative;
    max-width: 91%;
    margin: 0 0 12px;
    padding: 12px 14px;
    border-radius: 4px 15px 15px 15px;
    background: #fff;
    box-shadow: 0 5px 14px rgba(16, 24, 40, .07);
    font-size: 14px;
    line-height: 1.5;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.hce-chat-bubble-agent strong,
.hce-chat-bubble-agent > span:not(.hce-chat-message-label) {
    display: block;
}

.hce-chat-bubble-agent strong { margin-bottom: 4px; }

.hce-chat-message-label {
    display: block;
    margin-bottom: 5px;
    color: #667085;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .03em;
    text-transform: uppercase;
}

.hce-chat-conversation {
    max-height: 300px;
    min-height: 155px;
    overflow-y: auto;
    padding: 2px 3px 2px 0;
    scrollbar-width: thin;
}

.hce-chat-bubble-user {
    margin-left: auto;
    border-radius: 15px 4px 15px 15px;
    color: #fff;
    background: var(--hce-chat-accent) !important;
}

.hce-chat-email-form,
.hce-chat-message-form {
    display: grid;
    gap: 8px;
}

.hce-chat-message-form {
    margin-top: 10px;
    grid-template-columns: 1fr auto;
    align-items: end;
}

.hce-chat-message-form .hce-chat-error {
    grid-column: 1 / -1;
    order: 3;
}

.hce-chat-root input,
.hce-chat-root textarea {
    width: 100%;
    margin: 0;
    border: 1px solid #d0d5dd;
    border-radius: 10px;
    padding: 12px 13px;
    color: #1f2937;
    background: #fff;
    font: inherit;
    font-size: 14px;
    line-height: 1.4;
    box-shadow: none;
    outline: none;
}

.hce-chat-root textarea {
    resize: none;
    min-height: 70px;
    max-height: 125px;
}

.hce-chat-root input:focus,
.hce-chat-root textarea:focus {
    border-color: var(--hce-chat-accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--hce-chat-accent) 16%, transparent);
}

.hce-chat-root form > button {
    min-height: 44px;
    border: 0;
    border-radius: 10px;
    padding: 11px 16px;
    color: #fff;
    background: var(--hce-chat-accent) !important;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    transition: opacity .2s ease, transform .2s ease;
}

.hce-chat-message-form > button {
    height: 70px;
    min-width: 72px;
}

.hce-chat-root form > button:hover { transform: translateY(-1px); }
.hce-chat-root button:disabled { opacity: .6; cursor: wait; }
.hce-chat-root button.is-loading::after { content: "…"; }

.hce-chat-handover {
    width: 100%;
    margin: 9px 0 0;
    padding: 9px 12px;
    border: 1px solid var(--hce-chat-accent);
    border-radius: 9px;
    color: #24627d;
    background: #fff;
    font: inherit;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}

.hce-chat-handover.is-complete {
    border-color: #86efac;
    color: #166534;
    background: #ecfdf3;
}

.hce-chat-error {
    min-height: 17px;
    margin: -2px 0 0;
    color: #b42318;
    font-size: 12px;
}

.hce-chat-notice {
    min-height: 0;
    margin: 8px 0 0;
    color: #b42318;
    font-size: 12px;
    line-height: 1.45;
}

.hce-chat-notice:empty { display: none; }
.hce-chat-notice.is-success {
    padding: 9px 10px;
    border-radius: 8px;
    color: #166534;
    background: #ecfdf3;
}

.hce-chat-root small {
    display: block;
    margin-top: 8px;
    color: #667085;
    font-size: 10px;
    line-height: 1.45;
}

.hce-chat-typing {
    width: 55px;
    margin: 4px 0 8px;
    padding: 10px 12px;
    border-radius: 4px 14px 14px 14px;
    background: #fff;
    box-shadow: 0 5px 14px rgba(16, 24, 40, .07);
}

.hce-chat-typing[hidden] { display: none !important; }

.hce-chat-typing span {
    display: inline-block;
    width: 5px;
    height: 5px;
    margin-right: 2px;
    border-radius: 50%;
    background: #98a2b3;
    animation: hceTyping 1s infinite ease-in-out;
}

.hce-chat-typing span:nth-child(2) { animation-delay: .14s; }
.hce-chat-typing span:nth-child(3) { animation-delay: .28s; }

@keyframes hceTyping {
    0%, 60%, 100% { transform: translateY(0); opacity: .5; }
    30% { transform: translateY(-3px); opacity: 1; }
}

.hce-chat-root .screen-reader-text {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@media (max-width: 480px) {
    .hce-chat-root { bottom: 16px; }
    .hce-chat-right { right: 16px; }
    .hce-chat-left { left: 16px; }

    .hce-chat-panel {
        position: fixed;
        left: 12px !important;
        right: 12px !important;
        bottom: 88px;
        width: auto;
        max-height: calc(100vh - 106px);
        overflow-y: auto;
    }

    .hce-chat-conversation { max-height: 260px; }
}
