.linkai-chat {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 99999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.linkai-chat__toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 0;
    border-radius: 999px;
    padding: 12px 18px;
    color: #fff;
    background: linear-gradient(135deg, #d71920, #ff8a00);
    box-shadow: 0 12px 30px rgba(215, 25, 32, 0.35);
    cursor: pointer;
    font-weight: 700;
}

.linkai-chat__toggle-icon {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.22);
    letter-spacing: -0.04em;
}

.linkai-chat__panel {
    width: min(380px, calc(100vw - 32px));
    height: 560px;
    max-height: calc(100vh - 48px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: 20px;
    background: #fff;
    box-shadow: 0 24px 70px rgba(15, 23, 42, 0.24);
    border: 1px solid rgba(15, 23, 42, 0.08);
}

.linkai-chat__panel[hidden] {
    display: none;
}

.linkai-chat__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 20px;
    color: #fff;
    background: linear-gradient(135deg, #111827, #d71920);
}

.linkai-chat__header span {
    display: block;
    margin-top: 3px;
    font-size: 12px;
    opacity: 0.82;
}

.linkai-chat__close {
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 50%;
    color: #fff;
    background: rgba(255, 255, 255, 0.16);
    cursor: pointer;
    font-size: 24px;
    line-height: 1;
}

.linkai-chat__messages {
    flex: 1;
    overflow-y: auto;
    padding: 18px;
    background: #f8fafc;
}

.linkai-chat__message {
    max-width: 86%;
    margin-bottom: 12px;
    padding: 10px 12px;
    border-radius: 14px;
    line-height: 1.55;
    font-size: 14px;
    white-space: pre-wrap;
}

.linkai-chat__message--assistant {
    color: #111827;
    background: #fff;
    border-top-left-radius: 4px;
}

.linkai-chat__message--user {
    margin-left: auto;
    color: #fff;
    background: #d71920;
    border-top-right-radius: 4px;
}

.linkai-chat__message--loading {
    color: #64748b;
    font-style: italic;
}

.linkai-chat__form {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 14px;
    border-top: 1px solid #e2e8f0;
    background: #fff;
}

.linkai-chat__customer-fields,
.linkai-chat__composer {
    display: flex;
    gap: 10px;
}

.linkai-chat__customer-input {
    min-width: 0;
    flex: 1;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    padding: 8px 10px;
    font: inherit;
    font-size: 13px;
}

.linkai-chat__input {
    flex: 1;
    min-height: 44px;
    max-height: 120px;
    resize: vertical;
    border: 1px solid #cbd5e1;
    border-radius: 12px;
    padding: 10px 12px;
    font: inherit;
}

.linkai-chat__send {
    align-self: flex-end;
    border: 0;
    border-radius: 12px;
    padding: 0 18px;
    min-height: 44px;
    color: #fff;
    background: #d71920;
    cursor: pointer;
    font-weight: 700;
}

.linkai-chat__send:disabled,
.linkai-chat__customer-input:disabled,
.linkai-chat__input:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

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

    .linkai-chat__panel {
        height: 70vh;
    }

    .linkai-chat__customer-fields {
        flex-direction: column;
    }
}

.linkai-chat--human-takeover .linkai-chat__header {
    background: linear-gradient(135deg, #0f766e, #111827);
}

.linkai-chat--human-takeover .linkai-chat__header span::after {
    content: " · 人工接管中";
    font-weight: 700;
}

.linkai-chat__message--human {
    border-left: 3px solid #0f766e;
    box-shadow: 0 8px 20px rgba(15, 118, 110, 0.12);
}

.linkai-chat--offline .linkai-chat__header {
    background: linear-gradient(135deg, #334155, #64748b);
}

.linkai-chat__satisfaction {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 12px;
    color: #475569;
    font-size: 13px;
}

.linkai-chat__satisfaction button {
    border: 1px solid #cbd5e1;
    border-radius: 999px;
    padding: 4px 10px;
    background: #fff;
    cursor: pointer;
    font: inherit;
}

.linkai-chat__attachment {
    max-width: 92px;
    font-size: 12px;
}

@media (max-width: 782px) {
    .linkai-chat {
        right: 12px;
        bottom: 12px;
    }
    .linkai-chat__panel {
        width: calc(100vw - 24px);
        height: min(640px, calc(100vh - 24px));
    }
    .linkai-chat__composer {
        flex-wrap: wrap;
    }
}

.linkai-chat--left {
    right: auto;
    left: 24px;
}

.linkai-chat__toggle,
.linkai-chat__send,
.linkai-chat__message--user {
    background: var(--linkai-primary, #d71920);
}

.linkai-chat__header {
    background: linear-gradient(135deg, #111827, var(--linkai-primary, #d71920));
}

@media (max-width: 782px) {
    .linkai-chat--left {
        left: 12px;
    }
}
