.catalog-chat-launcher {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 10055;
    display: flex;
    align-items: center;
    gap: 8px;
    height: 52px;
    padding: 0 18px 0 16px;
    border: none;
    border-radius: 26px;
    background: linear-gradient(135deg, #1a73e8, #4f8df7);
    color: #fff;
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(26, 115, 232, 0.32);
    transition: transform 0.2s, box-shadow 0.2s;
}

.catalog-chat-launcher:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 30px rgba(26, 115, 232, 0.4);
}

.catalog-chat-launcher i {
    font-size: 18px;
}

.catalog-chat-launcher.is-hidden {
    display: none;
}

.catalog-chat-launcher-badge {
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: #d93025;
    color: #fff;
    font-size: 11px;
    line-height: 18px;
    text-align: center;
}

.catalog-chat-launcher-badge[hidden] {
    display: none;
}

.catalog-chat-window {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 10060;
    display: none;
    flex-direction: column;
    width: min(380px, calc(100vw - 32px));
    height: min(560px, calc(100vh - 60px));
    border: 1px solid #e6eaf0;
    border-radius: 14px;
    background: #fff;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(15, 34, 68, 0.22);
}

.catalog-chat-window.is-open {
    display: flex;
    animation: catalogChatIn 0.2s ease;
}

@keyframes catalogChatIn {
    from { opacity: 0; transform: translateY(14px); }
    to { opacity: 1; transform: translateY(0); }
}

.catalog-chat-head {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    padding: 13px 14px;
    background: linear-gradient(135deg, #1a73e8, #4f8df7);
    color: #fff;
}

.catalog-chat-avatar {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    font-size: 15px;
}

.catalog-chat-head-text {
    flex: 1;
    min-width: 0;
}

.catalog-chat-title {
    font-size: 14px;
    font-weight: 700;
    line-height: 1.3;
}

.catalog-chat-status {
    font-size: 11px;
    opacity: 0.82;
    line-height: 1.4;
}

.catalog-chat-close {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
}

.catalog-chat-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.catalog-chat-body {
    flex: 1;
    min-height: 0;
    padding: 14px;
    overflow-y: auto;
    background: #f6f8fb;
    scrollbar-width: thin;
}

.catalog-chat-tip {
    margin-bottom: 12px;
    padding: 10px 12px;
    border-radius: 8px;
    background: #fff;
    color: #6b7280;
    font-size: 12px;
    line-height: 1.6;
    box-shadow: 0 1px 3px rgba(15, 34, 68, 0.06);
}

.catalog-chat-history-tip {
    color: #9aa4b2;
    font-size: 11px;
    text-align: center;
}

.catalog-chat-history-tip:not(:empty) {
    margin-bottom: 10px;
}

.catalog-chat-msg {
    display: flex;
    margin-bottom: 12px;
}

.catalog-chat-msg.is-mine {
    justify-content: flex-end;
}

.catalog-chat-bubble {
    max-width: 78%;
    padding: 9px 12px;
    border-radius: 12px;
    background: #fff;
    color: #1f2937;
    font-size: 13px;
    line-height: 1.6;
    word-break: break-word;
    white-space: pre-wrap;
    box-shadow: 0 1px 3px rgba(15, 34, 68, 0.08);
}

.catalog-chat-msg.is-mine .catalog-chat-bubble {
    background: #1a73e8;
    color: #fff;
}

.catalog-chat-bubble img {
    display: block;
    max-width: 100%;
    max-height: 220px;
    border-radius: 8px;
    cursor: zoom-in;
}

.catalog-chat-meta {
    margin-top: 4px;
    font-size: 10px;
    color: #9aa4b2;
    text-align: right;
}

.catalog-chat-msg.is-mine .catalog-chat-meta {
    color: rgba(255, 255, 255, 0.72);
}

.catalog-chat-editor {
    flex-shrink: 0;
    border-top: 1px solid #eef0f3;
    background: #fff;
}

.catalog-chat-profile {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 10px 12px 0;
}

.catalog-chat-profile input {
    width: 100%;
    box-sizing: border-box;
    padding: 6px 9px;
    border: 1px solid #dde1e6;
    border-radius: 6px;
    font: inherit;
    font-size: 12px;
}

.catalog-chat-profile input:focus {
    outline: none;
    border-color: #1a73e8;
}

.catalog-chat-input-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 12px 12px;
}

.catalog-chat-input-row textarea {
    flex: 1;
    min-height: 38px;
    max-height: 96px;
    box-sizing: border-box;
    padding: 9px 10px;
    border: 1px solid #dde1e6;
    border-radius: 8px;
    font: inherit;
    font-size: 13px;
    line-height: 1.4;
    resize: none;
}

.catalog-chat-input-row textarea:focus {
    outline: none;
    border-color: #1a73e8;
    box-shadow: 0 0 0 2px rgba(26, 115, 232, 0.12);
}

.catalog-chat-icon-btn,
.catalog-chat-send {
    flex-shrink: 0;
    height: 38px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font: inherit;
    font-size: 13px;
}

.catalog-chat-icon-btn {
    width: 38px;
    background: #f1f3f7;
    color: #5b6472;
    font-size: 15px;
}

.catalog-chat-icon-btn:hover {
    background: #e5e9f0;
    color: #1a73e8;
}

.catalog-chat-send {
    padding: 0 16px;
    background: #1a73e8;
    color: #fff;
    font-weight: 600;
}

.catalog-chat-send:hover:not(:disabled) {
    background: #1557b0;
}

.catalog-chat-send:disabled,
.catalog-chat-icon-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.catalog-chat-hint {
    min-height: 15px;
    padding: 0 12px 8px;
    font-size: 11px;
    line-height: 1.35;
    color: #9aa4b2;
}

.catalog-chat-hint.is-error {
    color: #d93025;
}

.catalog-chat-lightbox {
    position: fixed;
    inset: 0;
    z-index: 10070;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(0, 0, 0, 0.72);
    cursor: zoom-out;
}

.catalog-chat-lightbox.is-open {
    display: flex;
}

.catalog-chat-lightbox img {
    max-width: 100%;
    max-height: 100%;
    border-radius: 8px;
}

/* 搜索结果页「返回结构图」同处右下角，客服入口上移避免遮挡 */
body:has(.fab-structure) .catalog-chat-launcher,
body:has(.fab-structure) .catalog-chat-window {
    bottom: calc(28px + 44px + 12px);
}

@media (max-width: 767px) {
    body:has(.fab-structure) .catalog-chat-launcher,
    body:has(.fab-structure) .catalog-chat-window {
        bottom: calc(16px + 40px + 12px + env(safe-area-inset-bottom, 0px));
    }

    body.has-catalog-side-actions:has(.fab-structure) .catalog-chat-launcher,
    body.has-catalog-side-actions:has(.fab-structure) .catalog-chat-window {
        bottom: calc(56px + 16px + 40px + 12px + env(safe-area-inset-bottom, 0px));
    }
}

@media (max-width: 480px) {
    .catalog-chat-window {
        right: 8px;
        bottom: 8px;
        width: calc(100vw - 16px);
        height: calc(100vh - 24px);
    }

    .catalog-chat-launcher {
        right: 14px;
        bottom: 14px;
    }

    .catalog-chat-profile {
        grid-template-columns: 1fr;
    }
}
