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

.hvai-root {
    --hvai-primary: #3157e7;
    --hvai-secondary: #7a48ee;
    --hvai-text: #172033;
    --hvai-muted: #71809a;
    --hvai-border: #e7eaf2;
    --hvai-surface: #ffffff;
    --hvai-soft: #f5f7fb;
    --hvai-font: inherit;
    --hvai-font-size: 16px;
    --hvai-panel-width: 410px;
    --hvai-panel-height: 650px;
    --hvai-bottom: 24px;
    --hvai-side: 24px;
    position: fixed;
    right: var(--hvai-side);
    bottom: var(--hvai-bottom);
    z-index: 2147483000;
    width: 0;
    height: 0;
    color: var(--hvai-text);
    font-family: var(--hvai-font);
    font-size: var(--hvai-font-size);
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

.hvai-root.hvai-root--left {
    right: auto;
    left: var(--hvai-side);
}

.hvai-root--inline {
    position: relative;
    inset: auto;
    width: 100%;
    height: auto;
    min-height: var(--hvai-panel-height);
}

.hvai-launcher,
.hvai-header__button,
.hvai-composer__send,
.hvai-quick__button {
    appearance: none;
    border: 0;
    margin: 0;
    font: inherit;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.hvai-launcher {
    position: absolute;
    right: 0;
    bottom: 0;
    display: grid;
    place-items: center;
    width: 68px;
    height: 68px;
    padding: 8px;
    border-radius: 50%;
    background: linear-gradient(145deg, var(--hvai-primary), var(--hvai-secondary));
    box-shadow: 0 18px 38px rgba(29, 52, 118, .26), 0 4px 12px rgba(29, 52, 118, .16);
    transition: transform .22s ease, box-shadow .22s ease, opacity .2s ease;
}

.hvai-root--left .hvai-launcher {
    right: auto;
    left: 0;
}

.hvai-launcher:hover {
    transform: translateY(-3px);
    box-shadow: 0 22px 46px rgba(29, 52, 118, .32), 0 5px 14px rgba(29, 52, 118, .18);
}

.hvai-launcher:focus-visible,
.hvai-header__button:focus-visible,
.hvai-composer__send:focus-visible,
.hvai-quick__button:focus-visible,
.hvai-composer__input:focus-visible {
    outline: 3px solid rgba(49, 87, 231, .25);
    outline-offset: 3px;
}

.hvai-launcher__ring {
    position: absolute;
    inset: 5px;
    border: 2px solid rgba(255, 255, 255, .62);
    border-radius: inherit;
}

.hvai-launcher__avatar {
    display: block;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    background: #fff;
}

.hvai-launcher__status {
    position: absolute;
    right: 7px;
    bottom: 8px;
    width: 15px;
    height: 15px;
    border: 3px solid #fff;
    border-radius: 50%;
    background: #25c868;
}

.hvai-root--open .hvai-launcher {
    pointer-events: none;
    opacity: 0;
    transform: scale(.88);
}

.hvai-panel {
    position: absolute;
    right: 0;
    bottom: 0;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto auto auto;
    width: var(--hvai-panel-width);
    height: var(--hvai-panel-height);
    max-height: calc(100vh - 32px);
    overflow: hidden;
    border: 1px solid rgba(28, 42, 72, .08);
    border-radius: 28px;
    background: var(--hvai-surface);
    box-shadow: 0 30px 80px rgba(24, 35, 65, .2), 0 6px 24px rgba(24, 35, 65, .1);
    opacity: 0;
    pointer-events: none;
    transform: translateY(18px) scale(.97);
    transform-origin: right bottom;
    transition: opacity .22s ease, transform .28s cubic-bezier(.2, .8, .2, 1);
}

.hvai-root--left .hvai-panel {
    right: auto;
    left: 0;
    transform-origin: left bottom;
}

.hvai-root--open .hvai-panel {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0) scale(1);
}

.hvai-root--inline .hvai-launcher {
    display: none;
}

.hvai-root--inline .hvai-panel {
    position: relative;
    inset: auto;
    width: 100%;
    height: var(--hvai-panel-height);
    max-height: none;
    opacity: 1;
    pointer-events: auto;
    transform: none;
}

.hvai-header {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 112px;
    padding: 20px 22px;
    overflow: hidden;
    color: #fff;
    background: linear-gradient(130deg, #172a57 0%, var(--hvai-primary) 52%, var(--hvai-secondary) 100%);
}

.hvai-header::after {
    content: "";
    position: absolute;
    right: -55px;
    bottom: -82px;
    width: 270px;
    height: 190px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .09);
    transform: rotate(-13deg);
}

.hvai-header__identity,
.hvai-header__actions {
    position: relative;
    z-index: 1;
}

.hvai-header__identity {
    display: flex;
    align-items: center;
    min-width: 0;
    gap: 13px;
}

.hvai-header__avatar-wrap {
    position: relative;
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    width: 64px;
    height: 64px;
    padding: 7px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .18);
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .42);
}

.hvai-header__avatar {
    display: block;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    object-fit: cover;
    background: #fff;
}

.hvai-header__status-dot {
    position: absolute;
    right: 4px;
    bottom: 5px;
    width: 16px;
    height: 16px;
    border: 3px solid #fff;
    border-radius: 50%;
    background: #25c868;
}

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

.hvai-header__name {
    overflow: hidden;
    color: #fff;
    font-size: 1.35em;
    font-weight: 750;
    line-height: 1.25;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.hvai-header__online {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: rgba(255, 255, 255, .9);
    font-size: .9em;
    font-weight: 600;
}

.hvai-header__online-dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    border: 2px solid rgba(255, 255, 255, .9);
    border-radius: 50%;
    background: #25c868;
}

.hvai-header__actions {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 8px;
}

.hvai-header__button {
    display: grid;
    place-items: center;
    width: 43px;
    height: 43px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, .22);
    border-radius: 50%;
    color: #fff;
    background: rgba(255, 255, 255, .12);
    transition: background .18s ease, transform .18s ease;
}

.hvai-header__button:hover {
    background: rgba(255, 255, 255, .22);
    transform: translateY(-1px);
}

.hvai-icon {
    display: block;
    width: 21px;
    height: 21px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.hvai-body {
    position: relative;
    min-height: 0;
    overflow: hidden;
    background: linear-gradient(180deg, #fff 0%, #fbfcff 100%);
}

.hvai-messages {
    height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 22px 20px 18px;
    scroll-behavior: smooth;
    scrollbar-color: rgba(82, 98, 136, .28) transparent;
    scrollbar-width: thin;
}

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

.hvai-messages::-webkit-scrollbar-thumb {
    border-radius: 10px;
    background: rgba(82, 98, 136, .24);
}

.hvai-message {
    display: flex;
    width: 100%;
    align-items: flex-end;
    gap: 9px;
    margin: 0 0 16px;
    animation: hvai-message-in .25s ease both;
}

.hvai-message--user {
    justify-content: flex-end;
}

.hvai-message__avatar,
.hvai-typing__avatar {
    flex: 0 0 auto;
    display: block;
    width: 34px;
    height: 34px;
    margin-bottom: 2px;
    border: 1px solid rgba(49, 87, 231, .12);
    border-radius: 50%;
    object-fit: cover;
    background: #fff;
}

.hvai-message__content {
    display: flex;
    max-width: calc(100% - 43px);
    flex-direction: column;
    gap: 7px;
}

.hvai-message--user .hvai-message__content {
    align-items: flex-end;
    max-width: 84%;
}

.hvai-message__bubble {
    max-width: 100%;
    padding: 13px 15px;
    border-radius: 18px 18px 18px 6px;
    color: var(--hvai-text);
    background: var(--hvai-soft);
    box-shadow: 0 10px 28px rgba(35, 49, 84, .06);
    overflow-wrap: anywhere;
    word-break: normal;
}

.hvai-message--user .hvai-message__bubble {
    border-radius: 18px 18px 6px 18px;
    color: #fff;
    background: linear-gradient(135deg, var(--hvai-primary), var(--hvai-secondary));
    box-shadow: 0 12px 26px rgba(49, 87, 231, .19);
}

.hvai-message__sources {
    display: flex;
    max-width: 100%;
    flex-wrap: wrap;
    gap: 6px;
}

.hvai-message__source {
    display: inline-flex;
    max-width: 100%;
    align-items: center;
    gap: 5px;
    padding: 6px 9px;
    border: 1px solid var(--hvai-border);
    border-radius: 999px;
    color: var(--hvai-primary);
    background: #fff;
    font-size: .76em;
    font-weight: 650;
    line-height: 1.25;
    text-decoration: none;
    transition: border-color .18s ease, background .18s ease;
}

.hvai-message__source:hover {
    border-color: rgba(49, 87, 231, .28);
    color: var(--hvai-primary);
    background: rgba(49, 87, 231, .05);
}

.hvai-message__source-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.hvai-typing {
    position: absolute;
    left: 20px;
    bottom: 14px;
    display: flex;
    align-items: flex-end;
    gap: 9px;
}

.hvai-typing[hidden] {
    display: none;
}

.hvai-typing__bubble {
    display: flex;
    align-items: center;
    gap: 4px;
    min-height: 38px;
    padding: 12px 14px;
    border-radius: 16px 16px 16px 6px;
    background: var(--hvai-soft);
    box-shadow: 0 10px 24px rgba(35, 49, 84, .06);
}

.hvai-typing__bubble i {
    display: block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--hvai-muted);
    animation: hvai-typing 1.15s infinite ease-in-out;
}

.hvai-typing__bubble i:nth-child(2) { animation-delay: .14s; }
.hvai-typing__bubble i:nth-child(3) { animation-delay: .28s; }

.hvai-quick {
    display: flex;
    width: 100%;
    gap: 8px;
    padding: 12px 20px 8px;
    overflow-x: auto;
    border-top: 1px solid rgba(231, 234, 242, .72);
    background: #fff;
    scrollbar-width: none;
}

.hvai-quick::-webkit-scrollbar {
    display: none;
}

.hvai-quick:empty {
    display: none;
}

.hvai-quick__button {
    flex: 0 0 auto;
    max-width: 240px;
    padding: 9px 13px;
    overflow: hidden;
    border: 1px solid rgba(49, 87, 231, .2);
    border-radius: 999px;
    color: var(--hvai-primary);
    background: #fff;
    font-size: .86em;
    font-weight: 650;
    line-height: 1.25;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: color .18s ease, border-color .18s ease, background .18s ease, transform .18s ease;
}

.hvai-quick__button:hover {
    border-color: var(--hvai-primary);
    color: #fff;
    background: var(--hvai-primary);
    transform: translateY(-1px);
}

.hvai-privacy {
    display: none;
    padding: 0 20px 7px;
    color: var(--hvai-muted);
    background: #fff;
    font-size: .72em;
    line-height: 1.35;
}

.hvai-privacy:not(:empty) {
    display: block;
}

.hvai-privacy a {
    color: var(--hvai-primary);
}

.hvai-composer {
    position: relative;
    display: flex;
    align-items: flex-end;
    gap: 8px;
    margin: 0;
    padding: 12px 16px 16px;
    background: #fff;
}

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

.hvai-composer__input {
    display: block;
    width: 100%;
    min-height: 52px;
    max-height: 128px;
    resize: none;
    overflow-y: auto;
    margin: 0;
    padding: 14px 61px 14px 16px;
    border: 1px solid rgba(49, 87, 231, .35);
    border-radius: 22px;
    outline: 0;
    color: var(--hvai-text);
    background: #fff;
    box-shadow: 0 10px 30px rgba(49, 87, 231, .1);
    font: inherit;
    line-height: 1.45;
    transition: border-color .18s ease, box-shadow .18s ease;
}

.hvai-composer__input::placeholder {
    color: #9aa6ba;
    opacity: 1;
}

.hvai-composer__input:focus {
    border-color: var(--hvai-primary);
    box-shadow: 0 12px 34px rgba(49, 87, 231, .16);
}

.hvai-composer__send {
    position: absolute;
    right: 24px;
    bottom: 22px;
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    padding: 0;
    border-radius: 50%;
    color: #fff;
    background: linear-gradient(145deg, var(--hvai-primary), var(--hvai-secondary));
    box-shadow: 0 9px 20px rgba(49, 87, 231, .22);
    transition: transform .18s ease, opacity .18s ease;
}

.hvai-composer__send:hover {
    transform: translateY(-1px) scale(1.02);
}

.hvai-composer__send:disabled {
    cursor: not-allowed;
    opacity: .55;
    transform: none;
}

.hvai-composer__send-icon {
    display: block;
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

@keyframes hvai-message-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes hvai-typing {
    0%, 65%, 100% { transform: translateY(0); opacity: .45; }
    35% { transform: translateY(-4px); opacity: 1; }
}

@media (max-width: 600px) {
    .hvai-root {
        --hvai-bottom: 12px;
        --hvai-side: 10px;
    }

    .hvai-panel {
        width: calc(100vw - 20px);
        height: min(var(--hvai-panel-height), calc(100dvh - 24px));
        max-height: calc(100dvh - 24px);
        border-radius: 24px;
    }

    .hvai-header {
        min-height: 96px;
        padding: 16px;
    }

    .hvai-header__avatar-wrap {
        width: 56px;
        height: 56px;
        padding: 6px;
    }

    .hvai-header__avatar {
        width: 44px;
        height: 44px;
    }

    .hvai-header__name {
        font-size: 1.18em;
    }

    .hvai-header__button {
        width: 39px;
        height: 39px;
    }

    .hvai-messages {
        padding: 18px 14px 12px;
    }

    .hvai-message__bubble {
        padding: 11px 13px;
    }

    .hvai-quick {
        padding-inline: 14px;
    }

    .hvai-composer {
        padding: 10px 12px 13px;
    }

    .hvai-composer__send {
        right: 20px;
        bottom: 19px;
    }

    .hvai-privacy {
        padding-inline: 14px;
    }
}

@media (max-width: 390px) {
    .hvai-header__actions {
        gap: 5px;
    }

    .hvai-header__button {
        width: 36px;
        height: 36px;
    }

    .hvai-header__identity {
        gap: 9px;
    }

    .hvai-header__online {
        font-size: .8em;
    }
}

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

/* Theme compatibility hardening (v1.1.1)
 * Keep critical chatbot controls isolated from Flatsome and other theme resets.
 */
.hvai-root {
    overflow: visible !important;
}

.hvai-root button,
.hvai-root textarea,
.hvai-root img,
.hvai-root svg {
    box-sizing: border-box !important;
}

.hvai-root button {
    min-width: 0;
    max-width: none;
    min-height: 0;
    max-height: none;
    letter-spacing: normal;
    text-transform: none;
    text-indent: 0;
}

.hvai-root .hvai-launcher,
.hvai-root .hvai-header__button,
.hvai-root .hvai-composer__send,
.hvai-root .hvai-quick__button {
    -webkit-appearance: none !important;
    appearance: none !important;
    margin: 0 !important;
    font-family: var(--hvai-font) !important;
    text-decoration: none !important;
}

.hvai-root .hvai-launcher::before,
.hvai-root .hvai-launcher::after,
.hvai-root .hvai-header__button::before,
.hvai-root .hvai-header__button::after,
.hvai-root .hvai-composer__send::before,
.hvai-root .hvai-composer__send::after,
.hvai-root .hvai-quick__button::before,
.hvai-root .hvai-quick__button::after {
    content: none !important;
    display: none !important;
}

.hvai-root .hvai-launcher {
    position: absolute !important;
    right: 0 !important;
    bottom: 0 !important;
    display: grid !important;
    place-items: center !important;
    width: 68px !important;
    height: 68px !important;
    min-width: 68px !important;
    max-width: 68px !important;
    min-height: 68px !important;
    max-height: 68px !important;
    padding: 8px !important;
    overflow: hidden !important;
    line-height: 1 !important;
    aspect-ratio: 1 / 1;
}

.hvai-root--left .hvai-launcher {
    right: auto !important;
    left: 0 !important;
}

.hvai-root .hvai-launcher__ring {
    width: auto !important;
    height: auto !important;
    margin: 0 !important;
    padding: 0 !important;
}

.hvai-root .hvai-launcher__avatar {
    display: block !important;
    flex: 0 0 48px !important;
    width: 48px !important;
    height: 48px !important;
    min-width: 48px !important;
    max-width: 48px !important;
    min-height: 48px !important;
    max-height: 48px !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 50% !important;
    object-fit: cover !important;
    object-position: center !important;
    aspect-ratio: 1 / 1 !important;
    transform: none !important;
}

.hvai-root .hvai-launcher__status {
    box-sizing: border-box !important;
    width: 15px !important;
    height: 15px !important;
    min-width: 15px !important;
    min-height: 15px !important;
    margin: 0 !important;
    padding: 0 !important;
}

.hvai-root .hvai-header__avatar-wrap {
    flex: 0 0 64px !important;
    width: 64px !important;
    height: 64px !important;
    min-width: 64px !important;
    min-height: 64px !important;
    overflow: hidden !important;
    aspect-ratio: 1 / 1 !important;
}

.hvai-root .hvai-header__avatar {
    display: block !important;
    width: 50px !important;
    height: 50px !important;
    min-width: 50px !important;
    max-width: 50px !important;
    min-height: 50px !important;
    max-height: 50px !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 50% !important;
    object-fit: cover !important;
    object-position: center !important;
    aspect-ratio: 1 / 1 !important;
}

.hvai-root .hvai-message__avatar,
.hvai-root .hvai-typing__avatar {
    display: block !important;
    flex: 0 0 34px !important;
    width: 34px !important;
    height: 34px !important;
    min-width: 34px !important;
    max-width: 34px !important;
    min-height: 34px !important;
    max-height: 34px !important;
    padding: 0 !important;
    border-radius: 50% !important;
    object-fit: cover !important;
    object-position: center !important;
    aspect-ratio: 1 / 1 !important;
}

.hvai-root .hvai-header__button {
    position: relative !important;
    display: grid !important;
    place-items: center !important;
    flex: 0 0 43px !important;
    width: 43px !important;
    height: 43px !important;
    min-width: 43px !important;
    max-width: 43px !important;
    min-height: 43px !important;
    max-height: 43px !important;
    padding: 0 !important;
    overflow: hidden !important;
    line-height: 0 !important;
    aspect-ratio: 1 / 1 !important;
}

.hvai-root .hvai-quick__button {
    flex: 0 0 auto !important;
    width: auto !important;
    min-width: 0 !important;
    min-height: 0 !important;
    padding: 9px 13px !important;
    border-radius: 999px !important;
    line-height: 1.25 !important;
    white-space: nowrap !important;
}

.hvai-root .hvai-composer {
    width: 100% !important;
    min-width: 0 !important;
}

.hvai-root .hvai-composer__input {
    -webkit-appearance: none !important;
    appearance: none !important;
    box-sizing: border-box !important;
    width: 100% !important;
    min-width: 0 !important;
    min-height: 52px !important;
    max-height: 128px !important;
    margin: 0 !important;
    resize: none !important;
    overflow-x: hidden !important;
    overflow-y: hidden !important;
    padding: 14px 61px 14px 16px !important;
    border: 1px solid rgba(49, 87, 231, .35) !important;
    border-radius: 22px !important;
    outline: 0 !important;
    color: var(--hvai-text) !important;
    background: #fff !important;
    font: inherit !important;
    line-height: 1.45 !important;
    scrollbar-width: none;
}

.hvai-root .hvai-composer__input::-webkit-scrollbar {
    width: 0 !important;
    height: 0 !important;
    display: none !important;
}

.hvai-root .hvai-composer__send {
    position: absolute !important;
    right: 24px !important;
    bottom: 22px !important;
    display: grid !important;
    place-items: center !important;
    flex: 0 0 42px !important;
    width: 42px !important;
    height: 42px !important;
    min-width: 42px !important;
    max-width: 42px !important;
    min-height: 42px !important;
    max-height: 42px !important;
    padding: 0 !important;
    overflow: hidden !important;
    line-height: 0 !important;
    aspect-ratio: 1 / 1 !important;
}

.hvai-root .hvai-icon,
.hvai-root .hvai-composer__send-icon {
    display: block !important;
    flex: 0 0 auto !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
    fill: none !important;
    stroke: currentColor !important;
    transform: none !important;
    pointer-events: none !important;
}

.hvai-root .hvai-icon {
    width: 21px !important;
    height: 21px !important;
}

.hvai-root .hvai-composer__send-icon {
    width: 20px !important;
    height: 20px !important;
}

.hvai-root .hvai-icon path,
.hvai-root .hvai-composer__send-icon path {
    fill: none !important;
    stroke: currentColor !important;
    vector-effect: non-scaling-stroke;
}

@media (max-width: 600px) {
    .hvai-root .hvai-composer__send {
        right: 20px !important;
        bottom: 19px !important;
    }

    .hvai-root .hvai-header__avatar-wrap {
        flex-basis: 56px !important;
        width: 56px !important;
        height: 56px !important;
        min-width: 56px !important;
        min-height: 56px !important;
    }

    .hvai-root .hvai-header__avatar {
        width: 44px !important;
        height: 44px !important;
        min-width: 44px !important;
        max-width: 44px !important;
        min-height: 44px !important;
        max-height: 44px !important;
    }

    .hvai-root .hvai-header__button {
        flex-basis: 39px !important;
        width: 39px !important;
        height: 39px !important;
        min-width: 39px !important;
        max-width: 39px !important;
        min-height: 39px !important;
        max-height: 39px !important;
    }
}

@media (max-width: 390px) {
    .hvai-root .hvai-header__button {
        flex-basis: 36px !important;
        width: 36px !important;
        height: 36px !important;
        min-width: 36px !important;
        max-width: 36px !important;
        min-height: 36px !important;
        max-height: 36px !important;
    }
}
