.ahd-widget {
    --ahd-color: #1769ff;
    position: fixed;
    right: 24px;
    bottom: 24px;
    width: min(380px, calc(100vw - 24px));
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.ahd-panel {
    background: #ffffff;
    border-radius: 26px;
    overflow: hidden;
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.22);
    border: 1px solid rgba(15, 23, 42, 0.06);
    transition: opacity 0.22s ease, transform 0.22s ease, max-height 0.22s ease, margin-bottom 0.22s ease;
    max-height: 640px;
    margin-bottom: 16px;
}

.ahd-widget:not(.is-open) .ahd-panel {
    opacity: 0;
    transform: translateY(18px);
    pointer-events: none;
    max-height: 0;
    margin-bottom: 0;
}

.ahd-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 18px 16px;
    color: #fff;
    background: linear-gradient(135deg, var(--ahd-color) 0%, #0f172a 145%);
}

.ahd-header-profile {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ahd-header-profile img {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    border: 3px solid rgba(255,255,255,0.48);
    background: rgba(255,255,255,0.15);
}

.ahd-header-profile strong,
.ahd-header-profile span {
    display: block;
}

.ahd-header-profile strong {
    font-size: 18px;
    line-height: 1.2;
}

.ahd-header-profile span {
    font-size: 13px;
    opacity: 0.92;
}

.ahd-minimize {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    background: rgba(255,255,255,0.16);
    color: #fff;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
}

.ahd-panel-body {
    background: linear-gradient(180deg, #f8fbff 0%, #f8fafc 100%);
    padding: 16px;
    min-height: 250px;
    max-height: 340px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ahd-msg-wrap {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ahd-msg-wrap-agent {
    align-items: flex-start;
}

.ahd-msg-wrap-user {
    align-items: flex-end;
}

.ahd-msg {
    max-width: 82%;
    border-radius: 18px;
    padding: 12px 14px;
    font-size: 14px;
    line-height: 1.5;
    color: #0f172a;
}

.ahd-msg-agent {
    background: #fff;
    box-shadow: 0 10px 22px rgba(15, 23, 42, 0.08);
}

.ahd-msg-user {
    background: rgba(23, 105, 255, 0.11);
}

.ahd-brand-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-left: 6px;
    text-decoration: none;
    font-size: 12px;
    color: #334155;
    background: rgba(255,255,255,0.92);
    padding: 6px 10px;
    border-radius: 999px;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08);
}

.ahd-brand-link:hover {
    color: var(--ahd-color);
}

.ahd-brand-logo {
    width: 22px;
    height: 22px;
    object-fit: contain;
    display: block;
}

.ahd-brand-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 22px;
    padding: 0 8px;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--ahd-color) 0%, #0f172a 155%);
    color: #fff;
    font-weight: 700;
    font-size: 11px;
}

.ahd-brand-copy {
    white-space: nowrap;
}

.ahd-panel-input {
    display: flex;
    gap: 10px;
    padding: 14px;
    background: #fff;
    border-top: 1px solid #e5e7eb;
}

.ahd-panel-input input {
    flex: 1;
    border: 1px solid #dbe3ef;
    border-radius: 999px;
    padding: 12px 14px;
    font-size: 14px;
    outline: none;
    min-width: 0;
}

.ahd-panel-input input:focus {
    border-color: var(--ahd-color);
    box-shadow: 0 0 0 3px rgba(23, 105, 255, 0.14);
}

.ahd-panel-input button {
    border: none;
    border-radius: 999px;
    padding: 12px 16px;
    color: #fff;
    background: var(--ahd-color);
    font-weight: 600;
    cursor: pointer;
}

.ahd-dock {
    position: relative;
    display: flex;
    justify-content: flex-end;
    align-items: flex-end;
    min-height: 92px;
}

.ahd-teaser-group {
    position: absolute;
    right: 6px;
    bottom: calc(100% + 12px);
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    width: max-content;
    max-width: 290px;
    transition: opacity 0.28s ease, transform 0.28s ease;
}

.ahd-teaser-group.is-hidden {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
    pointer-events: none;
}

.ahd-greeting {
    position: relative;
    width: auto;
    max-width: 290px;
    margin: 0;
    background: #ffffff !important;
    padding: 14px 16px;
    border-radius: 18px;
    box-shadow: 0 16px 34px rgba(15, 23, 42, 0.18);
    border: 1px solid rgba(15, 23, 42, 0.08) !important;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.45;
    color: #0f172a !important;
    text-align: left;
    cursor: pointer;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ahd-greeting::after {
    content: '';
    position: absolute;
    right: 18px;
    bottom: -7px;
    width: 14px;
    height: 14px;
    background: #ffffff;
    border-right: 1px solid rgba(15, 23, 42, 0.08);
    border-bottom: 1px solid rgba(15, 23, 42, 0.08);
    transform: rotate(45deg);
}

.ahd-greeting:focus,
.ahd-fab:focus {
    outline: none;
}

.ahd-fab {
    position: relative;
    width: 90px;
    height: 90px;
    padding: 4px !important;
    border-radius: 50% !important;
    border: none !important;
    outline: none !important;
    background: #ffffff !important;
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.24) !important;
    cursor: pointer;
    flex: 0 0 auto;
    overflow: hidden !important;
    -webkit-appearance: none;
    appearance: none;
    display: flex;
    align-items: center;
    justify-content: center;
    clip-path: circle(50% at 50% 50%);
}

.ahd-fab::before {
    content: none !important;
}

.ahd-fab img {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100%;
    margin: 0;
    object-fit: cover;
    border-radius: 50% !important;
    display: block;
    background: #ffffff;
    clip-path: circle(50% at 50% 50%);
}

.ahd-status {
    position: absolute;
    right: 12px;
    bottom: 12px;
    z-index: 2;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 3px solid #fff;
    background: #14c768;
}

@media (max-width: 680px) {
    .ahd-widget {
        right: 12px;
        bottom: 12px;
        width: calc(100vw - 24px);
    }

    .ahd-teaser-group {
        right: 0;
        bottom: calc(100% + 10px);
        max-width: min(260px, calc(100vw - 30px));
    }

    .ahd-greeting {
        max-width: min(260px, calc(100vw - 30px));
        font-size: 13px;
        padding: 12px 14px;
        -webkit-line-clamp: 2;
    }

    .ahd-fab {
        width: 78px;
        height: 78px;
    }

    .ahd-brand-copy {
        max-width: 120px;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

.ahd-widget .ahd-fab,
.ahd-widget button.ahd-fab,
.ahd-widget .ahd-fab:hover,
.ahd-widget .ahd-fab:active,
.ahd-widget .ahd-fab:focus {
    background: #ffffff !important;
    border: none !important;
    border-radius: 50% !important;
    outline: none !important;
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.24) !important;
}

.ahd-widget .ahd-greeting,
.ahd-widget button.ahd-greeting,
.ahd-widget .ahd-greeting:hover,
.ahd-widget .ahd-greeting:active,
.ahd-widget .ahd-greeting:focus {
    background: #ffffff !important;
    color: #0f172a !important;
}
