.chat-plugin-root {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 1200;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
}

.chat-plugin-actions {
    display: grid;
    gap: 10px;
    justify-items: end;
}

.chat-plugin-root.is-open .chat-plugin-actions {
    gap: 0;
}

.chat-plugin-root.is-open .chat-plugin-action {
    display: none;
}

.chat-plugin-action,
.chat-plugin-toggle {
    width: 58px;
    height: 58px;
    border: 0;
    border-radius: 999px;
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    text-decoration: none;
    cursor: pointer;
    box-shadow: 0 16px 34px rgba(2, 8, 23, 0.22);
    transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
    -webkit-tap-highlight-color: transparent;
}

.chat-plugin-action:hover,
.chat-plugin-toggle:hover {
    transform: translateY(-2px);
    box-shadow: 0 20px 42px rgba(2, 8, 23, 0.28);
    filter: saturate(1.04);
}

.chat-plugin-action:focus-visible,
.chat-plugin-toggle:focus-visible {
    outline: 3px solid rgba(96, 165, 250, 0.52);
    outline-offset: 3px;
}

.chat-plugin-action.is-line {
    background: #06c755;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0;
}

.chat-plugin-action.is-phone {
    background: rgba(255, 255, 255, 0.96);
    color: #0f766e;
    border: 1px solid rgba(15, 118, 110, 0.18);
}

.chat-plugin-toggle {
    background: linear-gradient(135deg, #0f172a, #2563eb);
    color: #fff;
}

.chat-plugin-toggle::after {
    content: '';
    position: absolute;
    inset: -5px;
    border-radius: 999px;
    border: 1px solid rgba(96, 165, 250, 0.34);
    animation: chatPulse 2.8s ease-out infinite;
    pointer-events: none;
}

.chat-plugin-unread {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    border-radius: 999px;
    background: #ef4444;
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    box-shadow: 0 8px 18px rgba(239, 68, 68, 0.35);
}

.chat-plugin-unread-external {
    top: -2px;
    right: -2px;
}

.chat-plugin-panel {
    width: min(380px, calc(100vw - 24px));
    height: min(560px, calc(100dvh - 170px));
    display: none;
    flex-direction: column;
    overflow: hidden;
    border-radius: 28px;
    background: rgba(255, 255, 255, 0.88);
    box-shadow: 0 24px 55px rgba(15, 23, 42, 0.26);
    backdrop-filter: blur(24px);
    border: 1px solid rgba(255, 255, 255, 0.34);
    margin-bottom: 0;
}

.chat-plugin-root.is-open .chat-plugin-panel {
    display: flex;
}

.chat-plugin-root.has-external-toggle .chat-plugin-toggle {
    display: none;
}

.chat-plugin-root.has-unread-alert .chat-plugin-toggle,
[data-chat-toggle].has-unread-alert {
    animation: chatUnreadShake 0.9s ease-in-out infinite;
}

.chat-plugin-header {
    padding: 18px 18px 16px;
    background: linear-gradient(180deg, rgba(12, 71, 138, 0.96), rgba(10, 54, 105, 0.9));
    color: #fff;
}

.chat-plugin-footer {
    padding: 10px 12px 12px;
    background: rgba(255, 255, 255, 0.96);
    border-top: 1px solid rgba(148, 163, 184, 0.16);
}

.chat-plugin-header-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.chat-plugin-header h3 {
    margin: 0 0 6px;
    font-size: 18px;
}

.chat-plugin-header p {
    margin: 0;
    font-size: 13px;
    opacity: 0.85;
}

.chat-plugin-close {
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
    font-size: 26px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex: 0 0 auto;
}

.chat-plugin-close:hover {
    background: rgba(255, 255, 255, 0.24);
}

.chat-plugin-body {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    background:
        radial-gradient(circle at top left, rgba(58, 125, 255, 0.08), transparent 32%),
        linear-gradient(180deg, rgba(255,255,255,0.94), rgba(244,247,251,0.9));
}

.chat-plugin-lead,
.chat-plugin-form,
.chat-plugin-composer {
    display: grid;
    gap: 10px;
}

.chat-plugin-message-list {
    display: grid;
    gap: 12px;
}

.chat-plugin-message {
    max-width: 86%;
    padding: 12px 14px;
    border-radius: 18px 18px 18px 8px;
    line-height: 1.55;
    font-size: 14px;
    background: rgba(255, 255, 255, 0.92);
    color: #243146;
    box-shadow: 0 8px 22px rgba(15, 23, 42, 0.06);
}

.chat-plugin-message-sender {
    margin-bottom: 6px;
    font-size: 12px;
    font-weight: 700;
    color: #64748b;
}

.chat-plugin-message.is-self .chat-plugin-message-sender {
    color: rgba(255,255,255,.82);
    text-align: right;
}

.chat-plugin-message-text {
    white-space: pre-wrap;
}

.chat-plugin-message.is-self {
    margin-left: auto;
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: #fff;
    border-radius: 18px 18px 8px 18px;
}

.chat-plugin-message.is-pending {
    opacity: .72;
    filter: saturate(.82);
}

.chat-plugin-message-time {
    margin-top: 8px;
    font-size: 11px;
    opacity: 0.68;
}

.chat-plugin-attachment {
    display: grid;
    gap: 4px;
    margin-top: 10px;
    padding: 10px 12px;
    border-radius: 14px;
    text-decoration: none;
    background: rgba(15, 23, 42, 0.08);
    color: inherit;
}

.chat-plugin-attachment.is-image {
    background: rgba(255, 255, 255, 0.18);
}

.chat-plugin-attachment img {
    width: 100%;
    max-width: 210px;
    height: auto;
    border-radius: 12px;
    display: block;
}

.chat-plugin-message.is-self .chat-plugin-attachment {
    background: rgba(255, 255, 255, 0.14);
}

.chat-plugin-input,
.chat-plugin-textarea {
    width: 100%;
    border: 1px solid rgba(148, 163, 184, 0.28);
    background: rgba(255, 255, 255, 0.88);
    color: #0f172a;
    border-radius: 16px;
    padding: 12px 14px;
    font: inherit;
    caret-color: #0f172a;
}

.chat-plugin-input::placeholder,
.chat-plugin-textarea::placeholder {
    color: #64748b;
    opacity: 1;
}

.chat-plugin-input:focus,
.chat-plugin-textarea:focus {
    border-color: #38bdf8;
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.18);
    outline: none;
}

.chat-plugin-composer {
    gap: 8px;
}

.chat-plugin-composer-shell {
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-plugin-textarea {
    min-height: 42px;
    max-height: 42px;
    padding: 10px 14px;
    resize: none;
    overflow: hidden;
    border: 0;
    border-radius: 999px;
    background: #eef2ff;
    color: #111827;
    flex: 1 1 auto;
}

.chat-plugin-textarea::placeholder {
    color: #64748b;
    opacity: 1;
}

.chat-plugin-composer.is-expanded .chat-plugin-composer-shell {
    align-items: flex-end;
}

.chat-plugin-composer.is-expanded .chat-plugin-textarea {
    min-height: 112px;
    max-height: 34vh;
    padding: 14px 16px;
    border-radius: 22px;
    overflow-y: auto;
}

.chat-plugin-row {
    display: flex;
    gap: 10px;
}

.chat-plugin-row-composer {
    align-items: center;
}

.chat-plugin-tools {
    display: flex;
    gap: 6px;
    flex: 0 0 auto;
}

.chat-plugin-tool-btn,
.chat-plugin-send-btn {
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex: 0 0 auto;
}

.chat-plugin-tool-btn {
    background: transparent;
    color: #2563eb;
}

.chat-plugin-send-btn {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: #fff;
    box-shadow: 0 10px 22px rgba(37, 99, 235, 0.28);
}

.chat-plugin-file-chip {
    min-width: 0;
    flex: 1 1 auto;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 0 12px;
    min-height: 36px;
    border-radius: 999px;
    background: #e2e8f0;
    color: #111827;
}

.chat-plugin-file-chip span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
}

.chat-plugin-file-chip button {
    border: 0;
    background: transparent;
    color: #334155;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
}

.chat-plugin-btn {
    border: 0;
    border-radius: 14px;
    padding: 12px 16px;
    background: #0d4e8a;
    color: #fff;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

.chat-plugin-meta {
    font-size: 12px;
    color: #64748b;
    min-height: 16px;
}

.chat-plugin-footer-meta {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
}

.chat-plugin-hidden {
    display: none !important;
}

@keyframes chatPulse {
    0% {
        transform: scale(1);
        opacity: 0.7;
    }
    70% {
        transform: scale(1.08);
        opacity: 0;
    }
    100% {
        transform: scale(1.08);
        opacity: 0;
    }
}

@keyframes chatUnreadShake {
    0%, 100% {
        transform: translateX(0) scale(1);
        box-shadow: 0 18px 45px rgba(8, 30, 61, 0.25);
    }
    20% {
        transform: translateX(-2px) scale(1.04);
        box-shadow: 0 18px 45px rgba(37, 99, 235, 0.32);
    }
    40% {
        transform: translateX(2px) scale(1.08);
        box-shadow: 0 18px 45px rgba(37, 99, 235, 0.4);
    }
    60% {
        transform: translateX(-1px) scale(1.05);
        box-shadow: 0 18px 45px rgba(37, 99, 235, 0.34);
    }
    80% {
        transform: translateX(1px) scale(1.02);
        box-shadow: 0 18px 45px rgba(37, 99, 235, 0.28);
    }
}

@media (max-width: 640px) {
    .chat-plugin-root {
        right: 12px;
        bottom: 12px;
        gap: 10px;
    }

    .chat-plugin-actions {
        gap: 8px;
    }

    .chat-plugin-action,
    .chat-plugin-toggle {
        width: 54px;
        height: 54px;
    }

    .chat-plugin-panel {
        width: calc(100vw - 24px);
        height: min(62dvh, 500px);
        border-radius: 22px;
    }

    .chat-plugin-header {
        padding: 14px 14px 12px;
    }

    .chat-plugin-header h3 {
        font-size: 17px;
    }

    .chat-plugin-header p {
        font-size: 12px;
    }

    .chat-plugin-body {
        padding: 12px;
    }

    .chat-plugin-footer {
        padding: 8px 10px 10px;
    }

    .chat-plugin-message {
        max-width: 82%;
    }

    .chat-plugin-composer.is-expanded .chat-plugin-textarea {
        max-height: 28dvh;
    }
}
