/* 在线客服浮窗 v4.2.7：网站与商城共用，不依赖主题变量 */
.tw-chat-launcher {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 99980;
    width: 58px;
    height: 58px;
    border: 0;
    border-radius: 50%;
    background: linear-gradient(135deg, #2563eb, #0ea5e9);
    color: #fff;
    font-size: 26px;
    line-height: 58px;
    text-align: center;
    cursor: pointer;
    box-shadow: 0 8px 26px rgba(37, 99, 235, .35);
    transition: transform .18s ease, box-shadow .18s ease;
}
.tw-chat-launcher:hover { transform: translateY(-3px); box-shadow: 0 12px 30px rgba(37, 99, 235, .45); }
.tw-chat-launcher .tw-chat-dot {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #ef4444;
    border: 2px solid #fff;
    display: none;
}
.tw-chat-launcher.has-new .tw-chat-dot { display: block; }

.tw-chat-panel {
    position: fixed;
    right: 22px;
    bottom: 92px;
    z-index: 99981;
    width: 360px;
    max-width: calc(100vw - 32px);
    height: 520px;
    max-height: calc(100vh - 120px);
    display: none;
    flex-direction: column;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    box-shadow: 0 18px 50px rgba(15, 23, 42, .22);
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Microsoft YaHei", sans-serif;
}
.tw-chat-panel.open { display: flex; }
.tw-chat-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 13px 14px;
    background: linear-gradient(135deg, #1e40af, #2563eb);
    color: #fff;
}
.tw-chat-avatar {
    width: 34px; height: 34px; border-radius: 50%;
    background: rgba(255,255,255,.2);
    display: flex; align-items: center; justify-content: center; font-size: 18px;
}
.tw-chat-head strong { display: block; font-size: 14px; }
.tw-chat-head small { display: block; font-size: 11px; opacity: .82; margin-top: 2px; }
.tw-chat-close {
    margin-left: auto; background: none; border: 0; color: #fff; font-size: 20px; cursor: pointer; line-height: 1;
}
.tw-chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    background: #f8fafc;
}
.tw-chat-msg { margin-bottom: 12px; max-width: 86%; }
.tw-chat-msg .bubble {
    padding: 10px 12px; border-radius: 12px; font-size: 13px; line-height: 1.6;
    white-space: pre-wrap; word-break: break-word;
}
.tw-chat-msg.visitor { margin-left: auto; text-align: right; }
.tw-chat-msg.visitor .bubble { background: #2563eb; color: #fff; border-bottom-right-radius: 3px; }
.tw-chat-msg.ai .bubble,
.tw-chat-msg.system .bubble { background: #fff; color: #1e293b; border: 1px solid #e2e8f0; border-bottom-left-radius: 3px; }
.tw-chat-msg.agent .bubble { background: #e0f2fe; color: #075985; border: 1px solid #bae6fd; border-bottom-left-radius: 3px; }
.tw-chat-msg .meta { display: block; font-size: 10px; color: #94a3b8; margin-top: 4px; }
.tw-chat-msg.visitor .meta { text-align: right; }
.tw-chat-typing { color: #94a3b8; font-size: 12px; padding: 4px 2px; display: none; }
.tw-chat-foot { border-top: 1px solid #e2e8f0; padding: 10px; background: #fff; }
.tw-chat-input-row { display: flex; gap: 8px; }
.tw-chat-input {
    flex: 1; min-width: 0; border: 1px solid #cbd5e1; border-radius: 8px;
    padding: 9px 10px; font-size: 13px; outline: none; resize: none; max-height: 90px;
}
.tw-chat-input:focus { border-color: #2563eb; }
.tw-chat-send {
    border: 0; border-radius: 8px; padding: 0 16px; background: #2563eb; color: #fff;
    font-size: 13px; cursor: pointer; font-weight: 600;
}
.tw-chat-send:disabled { background: #94a3b8; cursor: not-allowed; }
.tw-chat-tip { font-size: 10px; color: #94a3b8; margin-top: 6px; text-align: center; }
html[dir="rtl"] .tw-chat-launcher { right: auto; left: 22px; }
html[dir="rtl"] .tw-chat-panel { right: auto; left: 22px; }
html[dir="rtl"] .tw-chat-msg.visitor { margin-left: 0; margin-right: auto; }
html[dir="rtl"] .tw-chat-msg.visitor .bubble { border-bottom-right-radius: 12px; border-bottom-left-radius: 3px; }
@media (max-width: 480px) {
    .tw-chat-panel { right: 8px; left: 8px; width: auto; bottom: 84px; }
    html[dir="rtl"] .tw-chat-panel { left: 8px; right: 8px; }
}


/* ---- v4.2.7 声音开关 / 排队提示 / 图文消息 ---- */
.tw-chat-headtxt { flex: 1; min-width: 0; }
.tw-chat-sound {
    border: 0; background: rgba(255,255,255,.16); color: #fff; width: 28px; height: 28px;
    border-radius: 7px; cursor: pointer; font-size: 13px; line-height: 1; margin-right: 4px;
    display: flex; align-items: center; justify-content: center; flex: 0 0 28px;
}
.tw-chat-sound:hover { background: rgba(255,255,255,.3); }
.tw-chat-queue {
    background: linear-gradient(90deg, #fff7ed, #fef3c7); color: #92400e;
    font-size: 11.5px; padding: 7px 12px; border-top: 1px solid #fde68a; text-align: center;
}
.tw-chat-img { display: block; max-width: 100%; max-height: 190px; border-radius: 8px; margin-top: 8px; border: 1px solid rgba(0,0,0,.06); }
.tw-chat-msg .bubble a { display: block; }
