#htai-root,
#htai-root *,
#htai-root *::before,
#htai-root *::after {
    box-sizing: border-box;
}

#htai-root {
    --htai-bg: #07111f;
    --htai-panel: #0d1b2a;
    --htai-panel-2: #14263a;
    --htai-text: #f7f9fc;
    --htai-muted: #b8c5d3;
    --htai-blue: #38bdf8;
    --htai-blue-dark: #0876a8;
    --htai-gold: #d6aa6d;
    --htai-line: rgba(255, 255, 255, 0.13);
    --htai-danger: #ffb4ab;
    position: fixed;
    z-index: 2147482000;
    right: max(22px, env(safe-area-inset-right));
    bottom: max(22px, env(safe-area-inset-bottom));
    color: var(--htai-text);
    font-family: inherit;
    font-size: 18px;
    line-height: 1.55;
    text-align: left;
    text-rendering: optimizeLegibility;
}

#htai-root button,
#htai-root input,
#htai-root textarea,
#htai-root select {
    font: inherit;
}

#htai-root button,
#htai-root a {
    -webkit-tap-highlight-color: transparent;
}

#htai-root button:focus-visible,
#htai-root a:focus-visible,
#htai-root input:focus-visible,
#htai-root textarea:focus-visible,
#htai-root select:focus-visible {
    outline: 3px solid #ffffff;
    outline-offset: 3px;
}

#htai-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;
}

.htai__launcher {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 64px;
    min-height: 64px;
    padding: 7px 16px 7px 7px;
    color: #fff;
    background: linear-gradient(135deg, #102337, #07111f);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 999px;
    box-shadow: 0 16px 42px rgba(0, 0, 0, 0.42);
    cursor: pointer;
    transition: transform 180ms ease, box-shadow 180ms ease;
}

.htai__launcher:hover {
    transform: translateY(-2px);
    box-shadow: 0 20px 52px rgba(0, 0, 0, 0.52);
}

.htai__launcher-ring {
    position: absolute;
    width: 58px;
    height: 58px;
    left: 9px;
    border: 1px solid rgba(56, 189, 248, 0.42);
    border-radius: 50%;
    animation: htai-pulse 2.8s ease-out infinite;
    pointer-events: none;
}

.htai__launcher-label {
    white-space: nowrap;
    font-weight: 700;
}

.htai__avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 46px;
    width: 46px;
    height: 46px;
    color: #fff;
    background:
        linear-gradient(145deg, rgba(255, 255, 255, 0.18), transparent 42%),
        linear-gradient(135deg, #0f95c9, #0b314d 70%);
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 50%;
    box-shadow: inset 0 0 0 3px rgba(0, 0, 0, 0.12);
    font-size: 15px;
    font-weight: 800;
    letter-spacing: 0.04em;
}

.htai__avatar--launcher {
    flex-basis: 50px;
    width: 50px;
    height: 50px;
}

.htai__dialog {
    position: absolute;
    right: 0;
    bottom: 78px;
    display: grid;
    grid-template-rows: auto auto minmax(190px, 1fr) auto auto;
    width: min(420px, calc(100vw - 32px));
    height: min(720px, calc(100vh - 120px));
    height: min(720px, calc(100svh - 120px));
    overflow: hidden;
    color: var(--htai-text);
    background: var(--htai-bg);
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 24px;
    box-shadow: 0 28px 80px rgba(0, 0, 0, 0.54);
    opacity: 0;
    visibility: hidden;
    transform: translateY(18px) scale(0.98);
    transform-origin: bottom right;
    transition: opacity 180ms ease, transform 180ms ease, visibility 180ms ease;
}

#htai-root[data-state="open"] .htai__dialog {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

#htai-root[data-state="open"] .htai__launcher {
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
}

.htai__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 76px;
    padding: 12px 14px;
    background: linear-gradient(135deg, #0f2438, #0a1726);
    border-bottom: 1px solid var(--htai-line);
}

.htai__identity {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.htai__identity strong,
.htai__identity small {
    display: block;
}

.htai__identity strong {
    color: #fff;
    font-size: 19px;
    line-height: 1.2;
}

.htai__identity small {
    margin-top: 5px;
    color: var(--htai-muted);
    font-size: 14px;
    line-height: 1.2;
}

.htai__status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    margin-right: 7px;
    background: #4ade80;
    border-radius: 50%;
    box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.15);
}

.htai__header-actions {
    display: flex;
    gap: 4px;
}

.htai__close,
.htai__reset,
.htai__lead-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    padding: 0;
    color: #fff;
    background: transparent;
    border: 0;
    border-radius: 12px;
    cursor: pointer;
}

.htai__close:hover,
.htai__reset:hover,
.htai__lead-close:hover {
    background: rgba(255, 255, 255, 0.1);
}

.htai__close,
.htai__lead-close {
    font-size: 31px;
    line-height: 1;
}

.htai__reset {
    font-size: 23px;
}

.htai__notice {
    min-height: 38px;
    padding: 9px 16px;
    color: #dbeafe;
    background: rgba(56, 189, 248, 0.1);
    border-bottom: 1px solid rgba(56, 189, 248, 0.18);
    font-size: 13px;
    line-height: 1.4;
    text-align: center;
}

.htai__messages {
    min-height: 0;
    padding: 18px 16px 8px;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-color: rgba(255, 255, 255, 0.25) transparent;
}

.htai__message {
    display: flex;
    flex-direction: column;
    margin-bottom: 16px;
}

.htai__message--user {
    align-items: flex-end;
}

.htai__message--assistant {
    align-items: flex-start;
}

.htai__message-name {
    margin: 0 0 5px 3px;
    color: var(--htai-muted);
    font-size: 13px;
    line-height: 1.2;
}

.htai__bubble {
    max-width: 92%;
    padding: 13px 15px;
    color: var(--htai-text);
    background: var(--htai-panel-2);
    border: 1px solid var(--htai-line);
    border-radius: 8px 18px 18px 18px;
    overflow-wrap: anywhere;
}

.htai__message--user .htai__bubble {
    max-width: 86%;
    color: #fff;
    background: #0c6995;
    border-color: rgba(255, 255, 255, 0.16);
    border-radius: 18px 8px 18px 18px;
}

.htai__bubble p {
    margin: 0 0 9px;
}

.htai__bubble p:last-child {
    margin-bottom: 0;
}

.htai__bubble ul {
    margin: 4px 0 0;
    padding-left: 21px;
}

.htai__bubble li {
    margin: 0 0 6px;
}

.htai__bubble strong {
    color: #fff;
}

.htai__sources {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    max-width: 92%;
    margin-top: 8px;
}

.htai__sources-title {
    flex-basis: 100%;
    color: var(--htai-muted);
    font-size: 13px;
}

.htai__source {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    padding: 6px 10px;
    color: #e0f2fe;
    background: rgba(56, 189, 248, 0.09);
    border: 1px solid rgba(56, 189, 248, 0.24);
    border-radius: 999px;
    font-size: 12px;
    line-height: 1.3;
    text-decoration: none;
}

a.htai__source:hover {
    color: #fff;
    background: rgba(56, 189, 248, 0.18);
}

.htai__cta {
    max-width: 92%;
    margin-top: 9px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.055);
    border-left: 3px solid var(--htai-gold);
    border-radius: 4px 14px 14px 4px;
}

.htai__cta p {
    margin: 0 0 10px;
    color: var(--htai-muted);
    font-size: 14px;
}

.htai__cta-link,
.htai__lead-open {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 48px;
    padding: 10px 14px;
    color: #04121c !important;
    background: #e0f2fe;
    border: 0;
    border-radius: 12px;
    font-weight: 800;
    line-height: 1.3;
    text-align: center;
    text-decoration: none !important;
    cursor: pointer;
}

.htai__lead-open {
    max-width: 92%;
    margin-top: 9px;
    color: #fff !important;
    background: #0c6995;
}

.htai__quick {
    display: flex;
    gap: 8px;
    padding: 9px 12px 12px;
    overflow-x: auto;
    border-top: 1px solid var(--htai-line);
    scrollbar-width: none;
}

.htai__quick::-webkit-scrollbar {
    display: none;
}

.htai__quick:empty {
    display: none;
}

.htai__quick-button {
    flex: 0 0 auto;
    min-height: 48px;
    padding: 9px 13px;
    color: #fff;
    background: var(--htai-panel-2);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.25;
    cursor: pointer;
}

.htai__quick-button:hover {
    background: #1c3550;
    border-color: rgba(56, 189, 248, 0.5);
}

.htai__composer {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 11px 12px;
    padding-bottom: max(11px, env(safe-area-inset-bottom));
    background: #091523;
    border-top: 1px solid var(--htai-line);
}

.htai__composer textarea {
    display: block;
    flex: 1;
    width: 100%;
    min-height: 50px;
    max-height: 128px;
    margin: 0;
    padding: 12px 13px;
    resize: none;
    overflow-y: auto;
    color: #fff;
    background: #14263a;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 14px;
    box-shadow: none;
}

.htai__composer textarea::placeholder {
    color: #9fb0c1;
    opacity: 1;
}

.htai__send {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 50px;
    width: 50px;
    height: 50px;
    padding: 0;
    color: #04121c;
    background: var(--htai-blue);
    border: 0;
    border-radius: 14px;
    cursor: pointer;
}

.htai__send svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
}

.htai__send:disabled,
.htai__composer textarea:disabled {
    cursor: wait;
    opacity: 0.55;
}

.htai__typing .htai__bubble {
    display: flex;
    align-items: center;
    gap: 5px;
    min-width: 68px;
}

.htai__typing i {
    width: 8px;
    height: 8px;
    background: var(--htai-muted);
    border-radius: 50%;
    animation: htai-dot 1.2s infinite ease-in-out;
}

.htai__typing i:nth-child(2) {
    animation-delay: 0.14s;
}

.htai__typing i:nth-child(3) {
    animation-delay: 0.28s;
}

.htai__system {
    margin: 8px auto 16px;
    color: var(--htai-danger);
    font-size: 14px;
    text-align: center;
}

.htai__lead[hidden] {
    display: none;
}

.htai__lead {
    position: absolute;
    z-index: 3;
    inset: 76px 0 0;
    padding: 16px;
    overflow-y: auto;
    color: #fff;
    background: rgba(7, 17, 31, 0.985);
}

.htai__lead-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
    font-size: 19px;
}

.htai__lead-form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.htai__lead-form label {
    display: grid;
    gap: 6px;
    color: #e7eef7;
    font-size: 14px;
}

.htai__lead-form label > span {
    color: var(--htai-gold);
}

.htai__lead-form input,
.htai__lead-form textarea,
.htai__lead-form select {
    width: 100%;
    min-height: 48px;
    margin: 0;
    padding: 10px 11px;
    color: #fff;
    background: #14263a;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 11px;
    box-shadow: none;
}

.htai__lead-form textarea {
    min-height: 96px;
    resize: vertical;
}

.htai__lead-full {
    grid-column: 1 / -1;
}

.htai__consent {
    display: flex !important;
    grid-template-columns: none !important;
    align-items: flex-start;
    gap: 10px !important;
    color: var(--htai-muted) !important;
}

.htai__consent input {
    flex: 0 0 22px;
    width: 22px;
    min-height: 22px;
    margin-top: 3px;
}

.htai__consent span {
    color: inherit !important;
}

.htai__consent a {
    color: #bae6fd;
    text-underline-offset: 3px;
}

.htai__lead-submit {
    min-height: 52px;
    color: #04121c;
    background: #e0f2fe;
    border: 0;
    border-radius: 12px;
    font-weight: 800;
    cursor: pointer;
}

.htai__lead-result {
    margin: 0;
    color: #dbeafe;
    font-size: 14px;
}

.htai__honeypot {
    position: absolute !important;
    left: -9999px !important;
    width: 1px !important;
    height: 1px !important;
    overflow: hidden !important;
}

@keyframes htai-dot {
    0%,
    60%,
    100% {
        transform: translateY(0);
        opacity: 0.55;
    }
    30% {
        transform: translateY(-5px);
        opacity: 1;
    }
}

@keyframes htai-pulse {
    0% {
        transform: scale(0.88);
        opacity: 0.65;
    }
    75%,
    100% {
        transform: scale(1.38);
        opacity: 0;
    }
}

@media (max-width: 640px) {
    html.htai-is-open,
    html.htai-is-open body {
        overflow: hidden !important;
    }

    #htai-root {
        right: max(14px, env(safe-area-inset-right));
        bottom: max(14px, env(safe-area-inset-bottom));
        font-size: 19px;
        line-height: 1.65;
    }

    .htai__launcher {
        min-height: 62px;
    }

    .htai__dialog {
        position: fixed;
        inset: 0;
        width: 100vw;
        max-width: none;
        height: 100vh;
        height: 100svh;
        border: 0;
        border-radius: 0;
        transform-origin: bottom center;
    }

    .htai__header {
        min-height: 78px;
        padding-top: max(12px, env(safe-area-inset-top));
    }

    .htai__identity strong {
        font-size: 20px;
    }

    .htai__identity small,
    .htai__message-name,
    .htai__sources-title,
    .htai__system,
    .htai__lead-form label,
    .htai__lead-result,
    .htai__cta p,
    .htai__quick-button {
        font-size: 15px;
    }

    .htai__notice {
        font-size: 14px;
    }

    .htai__messages {
        padding-inline: 14px;
    }

    .htai__bubble,
    .htai__message--user .htai__bubble,
    .htai__sources,
    .htai__cta,
    .htai__lead-open {
        max-width: 95%;
    }

    .htai__quick {
        padding-bottom: 10px;
    }

    .htai__quick-button {
        min-height: 50px;
        padding-inline: 14px;
    }

    .htai__composer textarea {
        min-height: 54px;
        font-size: 18px;
    }

    .htai__send {
        flex-basis: 54px;
        width: 54px;
        height: 54px;
    }

    .htai__lead {
        inset: 78px 0 0;
        padding-bottom: max(24px, env(safe-area-inset-bottom));
    }

    .htai__lead-form {
        grid-template-columns: 1fr;
    }

    .htai__lead-full {
        grid-column: auto;
    }

    .htai__lead-form input,
    .htai__lead-form textarea {
        min-height: 52px;
        font-size: 18px;
    }
}

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