/* =============== 基础及动画样式 =============== */
@keyframes fadeSlideUp {
    from {
        opacity: 0;
        transform: translateY(15px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulseGlow {
    0% {
        box-shadow: 0 0 5px rgba(106, 17, 203, 0.2);
    }
    50% {
        box-shadow: 0 0 15px rgba(106, 17, 203, 0.5);
    }
    100% {
        box-shadow: 0 0 5px rgba(106, 17, 203, 0.2);
    }
}

/* COMPAT-A 说明：原实现直接给全局 body 设置渐变背景与字体，会覆盖整站主题样式。
   现改为仅在聊天容器内部生效（字体/文字颜色已在 #deepseek-chat-container 上声明），
   插件不再输出任何全局选择器，从根源上避免与 justnews 等主题冲突。 */

/* =============== 容器样式 =============== */
#deepseek-chat-container {
    display: flex;
    height: 80vh;
    max-width: 80%;
    margin: 40px auto;
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: 24px;
    overflow: hidden;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1), 0 5px 15px rgba(0, 0, 0, 0.05);
    background: rgba(255, 255, 255, 0.65);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
}

/* =============== 历史对话框样式 =============== */
#deepseek-chat-history {
    width: 240px;
    max-width: 240px;
    background: rgba(249, 251, 253, 0.5);
    border-right: 1px solid rgba(224, 224, 224, 0.5);
    padding: 24px 20px;
    overflow-y: auto;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

#deepseek-chat-history::-webkit-scrollbar {
    width: 6px;
}
#deepseek-chat-history::-webkit-scrollbar-track {
    background: transparent;
}
#deepseek-chat-history::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 10px;
}

#deepseek-chat-history ul {
    list-style: none !important;
    padding: 0;
    margin: 0;
    flex: 1;
}

#deepseek-chat-history li {
    padding: 12px 14px;
    cursor: pointer;
    list-style: none !important;
    border-radius: 14px;
    margin-bottom: 12px;
    font-size: 14px;
    color: #444;
    font-weight: 500;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.6);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.02);
    position: relative;
    overflow: hidden;
}

#deepseek-chat-history li:hover {
    background: rgba(255, 255, 255, 0.8);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.06);
}

#deepseek-chat-history li.active {
    background: linear-gradient(135deg, #6a11cb 0%, #2575fc 100%);
    color: #fff;
    border: none;
    box-shadow: 0 6px 15px rgba(37, 117, 252, 0.3);
}

#deepseek-chat-history li.deepseek-history-pinned {
    border-color: rgba(30, 185, 128, 0.38);
    background: linear-gradient(135deg, rgba(30, 185, 128, 0.12), rgba(37, 117, 252, 0.08));
}

#deepseek-chat-history li .deepseek-chat-title {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.deepseek-history-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.deepseek-history-actions button {
    border: 1px solid rgba(37, 117, 252, 0.14);
    background: rgba(255, 255, 255, 0.72);
    color: #3f4d63;
    border-radius: 999px;
    padding: 3px 8px;
    cursor: pointer;
    font-size: 11px;
    line-height: 1.6;
    transition: all 0.2s ease;
}

.deepseek-history-actions button:hover {
    transform: translateY(-1px);
    border-color: rgba(30, 185, 128, 0.42);
    color: #0f6847;
}

/* 新对话按钮 */
#deepseek-new-chat {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, #6a11cb 0%, #2575fc 100%);
    color: #fff;
    border: none;
    border-radius: 14px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    margin-bottom: 24px;
    box-shadow: 0 6px 15px rgba(37, 117, 252, 0.25);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    letter-spacing: 0.5px;
}

#deepseek-new-chat:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 25px rgba(37, 117, 252, 0.35);
}

#deepseek-new-chat:active {
    transform: scale(0.97);
}

/* 智能体应用标题 / 自定义入口标题 */
.deepseek-agent-title, .deepseek-custom-entry-title {
    display: block;
    background: linear-gradient(135deg, #00c6ff 0%, #0072ff 100%);
    color: white;
    padding: 10px 20px;
    border-radius: 12px;
    text-align: center;
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 4px 10px rgba(0, 114, 255, 0.2);
    margin: 0 auto 15px auto;
    width: 100%;
    box-sizing: border-box;
    text-decoration: none !important;
}

.deepseek-agent-title:hover, .deepseek-custom-entry-title:hover {
    background: linear-gradient(135deg, #00b4e6 0%, #005fcc 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(0, 114, 255, 0.3);
    color: white;
}

/* =============== 主对话区域 =============== */
#deepseek-chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: transparent;
}

/* 消息框 */
#deepseek-chat-messages {
    flex: 1;
    padding: 24px;
    padding-bottom: 60px;
    overflow-y: auto;
    background: transparent;
    display: flex;
    flex-direction: column;
    position: relative;
    scroll-behavior: smooth;
    white-space: pre-wrap; 
    word-wrap: break-word;
}

#deepseek-chat-messages::-webkit-scrollbar {
    width: 8px;
}
#deepseek-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}
#deepseek-chat-messages::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 10px;
}

/* 消息气泡 */
.message-bubble {
    padding: 14px 20px;
    border-radius: 20px;
    margin-bottom: 20px;
    font-size: 15.5px;
    line-height: 1.6;
    position: relative;
    max-width: 75%;
    animation: fadeSlideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.04);
}

.message-bubble:last-child {
    margin-bottom: 30px;
}

.message-bubble.user {
    background: linear-gradient(135deg, #6a11cb 0%, #2575fc 100%);
    color: #fff;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
    box-shadow: 0 5px 15px rgba(37, 117, 252, 0.2);
}

.message-bubble.bot {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.9);
    color: #333;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

#deepseek-thinking-message {
    color: #1eb980;
    font-weight: 500;
    font-style: italic;
}

/* 代码块样式 */
.message-bubble pre {
    background: #1e1e1e;
    color: #e0e0e0;
    padding: 16px;
    border-radius: 12px;
    overflow-x: auto;
    font-size: 14px;
    line-height: 1.6;
    max-width: 100%;
    margin-top: 10px;
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.2);
}

.message-bubble pre code {
    background: none;
    color: inherit;
    padding: 0;
    border: none;
    font-family: "JetBrains Mono", Consolas, Monaco, "Courier New", Courier, monospace;
}

/* 表格样式 */
.message-bubble table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(0,0,0,0.08);
    border-radius: 8px;
    font-size: 14px;
    margin-top: 10px;
    overflow: hidden;
}

.message-bubble table th {
    background: rgba(0,0,0,0.03);
    font-weight: 600;
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid rgba(0,0,0,0.08);
}

.message-bubble table td {
    padding: 12px;
    border-bottom: 1px solid rgba(0,0,0,0.05);
}

.message-bubble table tr:last-child td {
    border-bottom: none;
}

/* 图片 */
.message-bubble.bot img {
    max-width: 100%;
    border-radius: 12px;
    box-shadow: 0px 6px 15px rgba(0, 0, 0, 0.1);
    margin-top: 12px;
    display: block;
    transition: transform 0.3s ease;
}

/* 推理过程 */
.reasoning-content {
    margin-bottom: 16px;
    padding: 14px 18px;
    background: linear-gradient(135deg, rgba(240, 248, 255, 0.7), rgba(230, 240, 250, 0.5));
    border-radius: 14px;
    border-left: 5px solid #6a11cb;
    color: #4a5568;
    font-size: 14.5px;
    line-height: 1.7;
}

.reasoning-content strong {
    color: #6a11cb;
    font-weight: 700;
}

.final-content {
    color: #2d3748;
    line-height: 1.7;
}

.deepseek-kb-sources {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid rgba(45, 55, 72, 0.1);
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.deepseek-kb-sources-title {
    width: 100%;
    color: #52616b;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.deepseek-kb-source-item {
    display: inline-flex;
    align-items: center;
    max-width: 100%;
    padding: 5px 9px;
    border-radius: 999px;
    background: rgba(30, 185, 128, 0.11);
    color: #087f5b;
    font-size: 12px;
    line-height: 1.4;
    text-decoration: none;
}

a.deepseek-kb-source-item:hover {
    background: rgba(30, 185, 128, 0.18);
    color: #065f46;
}

/* =============== 输入区域 =============== */
#deepseek-chat-input-container {
    display: flex;
    position: relative;
    min-height: 85px;
    padding: 18px 24px;
    border-top: 1px solid rgba(224, 224, 224, 0.5);
    background: rgba(248, 249, 250, 0.4);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    align-items: center;
    gap: 15px;
}

#deepseek-chat-input {
    flex: 1;
    padding: 16px 22px;
    border: 1px solid rgba(200, 200, 200, 0.6);
    border-radius: 24px;
    font-size: 15px;
    transition: all 0.3s ease;
    background: rgba(255, 255, 255, 0.85);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.02);
    resize: none;
    font-family: inherit;
}

#deepseek-chat-input:focus {
    border-color: #6a11cb;
    box-shadow: 0 0 0 4px rgba(106, 17, 203, 0.15);
    outline: none;
    background: #fff;
}

/* 发送按钮 */
#deepseek-chat-send {
    padding: 16px 28px;
    background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
    color: #fff;
    border: none;
    border-radius: 24px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    letter-spacing: 0.5px;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 6px 15px rgba(250, 112, 154, 0.3);
}

#deepseek-chat-send:hover {
    background: linear-gradient(135deg, #f85788 0%, #fbd52a 100%);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(250, 112, 154, 0.4);
}

#deepseek-chat-send:active {
    transform: scale(0.96);
}

/* =============== 各种工具和按钮 =============== */

/* 删除对话 */
.deepseek-delete-log {
    background-color: #ff4d4f;
    color: white;
    border: none;
    padding: 4px 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 12px;
}

.deepseek-delete-log:hover {
    background-color: #ff2a2d;
    transform: scale(1.05);
}

/* 快捷提示词 */
#deepseek-prompt-library {
    margin: 16px 0 6px;
    padding: 16px;
    border-radius: 18px;
    background: linear-gradient(135deg, rgba(30, 185, 128, 0.08), rgba(37, 117, 252, 0.08));
    border: 1px solid rgba(30, 185, 128, 0.14);
}

.deepseek-prompt-library-title {
    margin-bottom: 10px;
    color: #263238;
    font-weight: 700;
    font-size: 14px;
}

.deepseek-prompt-library-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 10px;
}

.deepseek-prompt-template {
    text-align: left;
    padding: 12px 14px;
    border: 1px solid rgba(37, 117, 252, 0.14);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.76);
    color: #243447;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.deepseek-prompt-template:hover,
.deepseek-prompt-template.selected {
    transform: translateY(-2px);
    border-color: rgba(30, 185, 128, 0.48);
    box-shadow: 0 10px 24px rgba(30, 185, 128, 0.12);
}

.deepseek-prompt-template-title {
    display: block;
    font-weight: 700;
    font-size: 14px;
}

.deepseek-prompt-template-category {
    display: block;
    margin-top: 4px;
    color: #667085;
    font-size: 12px;
}

.deepseek-feedback {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid rgba(36, 52, 71, 0.08);
    color: #667085;
    font-size: 12px;
}

.deepseek-feedback-button {
    border: 1px solid rgba(30, 185, 128, 0.18);
    background: rgba(255, 255, 255, 0.72);
    color: #243447;
    border-radius: 999px;
    padding: 5px 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 12px;
}

.deepseek-feedback-button:hover,
.deepseek-feedback-button.selected {
    border-color: rgba(30, 185, 128, 0.55);
    background: rgba(30, 185, 128, 0.1);
    color: #0f6847;
}

.deepseek-feedback.is-loading .deepseek-feedback-button {
    opacity: 0.58;
    pointer-events: none;
}

.deepseek-feedback-status {
    color: #0f6847;
}

#deepseek-custom-prompts {
    padding: 15px;
    margin-top: 10px;
    text-align: center;
}

#deepseek-custom-prompts .deepseek-prompt {
    display: inline-block;
    background: rgba(106, 17, 203, 0.1);
    color: #6a11cb;
    padding: 10px 20px;
    margin: 6px;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14.5px;
    font-weight: 500;
    border: 1px solid rgba(106, 17, 203, 0.2);
}

#deepseek-custom-prompts .deepseek-prompt:hover {
    background: #6a11cb;
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(106, 17, 203, 0.2);
}

/* 功能栏 (模型切换等) */
#deepseek-options-bar {
    margin-top: 8px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    padding: 12px 24px 2px 24px;
    flex-wrap: wrap;
    border-top: 1px solid rgba(224,224,224,0.3);
}

.deepseek-option-item, .deepseek-interface-select {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(0,0,0,0.05);
    border-radius: 12px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.03);
    transition: all 0.3s ease;
    font-size: 13.5px;
    font-weight: 500;
}

.deepseek-option-item:hover, .deepseek-interface-select:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transform: translateY(-1px);
    background: rgba(255, 255, 255, 0.9);
}

.deepseek-interface-select select {
    padding: 4px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    font-size: 13.5px;
    font-weight: 500;
    background: #fff;
    outline: none;
    transition: border-color 0.2s;
}

.deepseek-interface-select select:focus {
    border-color: #6a11cb;
}

/* 上传按钮 */
#deepseek-upload-file-btn {
    padding: 6px 14px;
    background: linear-gradient(135deg, #00c6ff 0%, #0072ff 100%);
    color: #fff;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 4px 10px rgba(0, 114, 255, 0.2);
}

#deepseek-upload-file-btn:hover {
    background: linear-gradient(135deg, #00b4e6 0%, #005fcc 100%);
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(0, 114, 255, 0.3);
}

#deepseek-upload-file-btn:active {
    transform: scale(0.96);
}

/* 语音、复制按钮 */
.ai-tts-play, .bot-copy-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    margin-left: 8px;
    background: linear-gradient(135deg, #e0c3fc 0%, #8ec5fc 100%);
    color: #333;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s ease;
    vertical-align: middle;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.ai-tts-play:hover, .bot-copy-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.bot-copy-button.clicked {
    width: 80px;
    background: linear-gradient(135deg, #84fab0 0%, #8fd3f4 100%);
    color: #005a32;
    font-weight: 600;
    font-size: 14px;
}

.pre-copy-button {
    display: inline-block;
    background: rgba(255,255,255,0.1);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 8px;
    padding: 6px 16px;
    margin-top: 8px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.pre-copy-button:hover {
    background: rgba(255,255,255,0.2);
}

/* 开关 Toggle */
.deepseek-search-toggle .switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.deepseek-search-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.deepseek-search-toggle .slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(0,0,0,0.1);
    transition: .4s;
    border-radius: 34px;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.05);
}

.deepseek-search-toggle .slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.deepseek-search-toggle input:checked + .slider {
    background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
}

.deepseek-search-toggle input:checked + .slider:before {
    transform: translateX(20px);
}

/* =============== 通知 & 模态框 =============== */
.custom-notification {
    position: fixed;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    padding: 16px 28px;
    border-radius: 16px;
    color: #fff;
    font-size: 15.5px;
    font-weight: 600;
    z-index: 1000;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-width: 250px;
    opacity: 0;
    animation: fadeSlideUp 0.3s ease forwards;
    backdrop-filter: blur(10px);
}

.custom-notification.success {
    background: linear-gradient(135deg, rgba(67, 233, 123, 0.9), rgba(56, 249, 215, 0.9));
}

.custom-notification.error {
    background: linear-gradient(135deg, rgba(255, 8, 68, 0.9), rgba(255, 177, 153, 0.9));
}

.close-notification {
    margin-left: 15px;
    font-size: 22px;
    cursor: pointer;
    opacity: 0.8;
}
.close-notification:hover { opacity: 1; }

.deepseek-login-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 18px;
    font-weight: bold;
    color: #ff4d4f;
    cursor: not-allowed;
    z-index: 999;
    border-radius: inherit;
}

#clear-conversation-button {
    background: rgba(0,0,0,0.6);
    color: #fff;
    border: none;
    padding: 4px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.2s;
}

#clear-conversation-button:hover { background: #ff4d4f; }

/* 教程链接 */
.deepseek-tutorial-link a {
    color: #6a11cb;
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s;
}
.deepseek-tutorial-link a:hover { color: #2575fc; }

/* 公告 */
#deepseek-announcement {
    background: rgba(255,255,255,0.7);
    border-radius: 12px;
    padding: 10px 20px;
    margin: 15px auto;
    max-width: 80%;
    text-align: center;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    color: #555;
    font-size: 14px;
    line-height: 1.6;
    border: 1px solid rgba(0,0,0,0.05);
}

/* Tooltip */
.tooltip {
    position: absolute;
    background: rgba(0,0,0,0.8);
    color: #fff;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    z-index: 1000;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

/* 已上传文件列表 */
#uploaded-files-list, #agent-uploaded-file {
    display: none;
    gap: 8px;
    padding: 6px;
    background: rgba(255,255,255,0.7);
    border: 1px solid rgba(0,0,0,0.08);
    border-radius: 10px;
    max-width: 320px;
    align-items: center;
    overflow-x: auto;
}

#uploaded-files-list.visible, #agent-uploaded-file.visible { display: flex; }

#uploaded-files-list div, #agent-uploaded-file {
    background: #fff;
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 13px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    display: flex;
    align-items: center;
}

#uploaded-files-list div button, #agent-uploaded-file .remove-file-btn {
    background: #ff4d4f;
    color: #fff;
    border: none;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    margin-left: 8px;
    transition: background 0.2s;
}

#uploaded-files-list div button:hover, #agent-uploaded-file .remove-file-btn:hover {
    background: #ff2a2d;
}

#deepseek-recent-files-panel {
    display: none;
    flex-basis: 100%;
    gap: 8px;
    max-width: 520px;
    padding: 8px;
    background: rgba(255,255,255,0.78);
    border: 1px solid rgba(0,0,0,0.08);
    border-radius: 8px;
    overflow-x: auto;
}

#deepseek-recent-files-panel.visible {
    display: flex;
}

.deepseek-recent-file-item {
    min-width: 150px;
    max-width: 220px;
    padding: 7px 9px;
    border: 1px solid rgba(0,0,0,0.08);
    border-radius: 6px;
    background: #fff;
    color: #333;
    cursor: pointer;
    text-align: left;
}

.deepseek-recent-file-title {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
    font-weight: 600;
}

.deepseek-recent-file-meta,
.deepseek-recent-file-empty {
    display: block;
    margin-top: 3px;
    color: #667085;
    font-size: 12px;
    line-height: 1.4;
}

/* 智能体额外样式 */
.agent-list { display: flex; flex-wrap: wrap; gap: 16px; justify-content: flex-start; padding: 20px; }
.agent-item {
    width: calc(33.33% - 11px);
    display: flex;
    align-items: center;
    background: rgba(255,255,255,0.8);
    border-radius: 16px;
    padding: 16px;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    border: 1px solid rgba(255,255,255,0.5);
}
.agent-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.1);
    background: #fff;
}
.agent-icon { width: 44px; height: 44px; border-radius: 50%; margin-right: 14px; object-fit: cover; }
.agent-name { font-size: 16px; font-weight: 600; color: #2d3748; margin: 0; }
.agent-description { font-size: 13px; color: #718096; margin-top: 6px; line-height: 1.4; }

.opening-questions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 15px; }
.opening-question {
    background: linear-gradient(135deg, #e0c3fc 0%, #8ec5fc 100%);
    color: #333;
    border: none;
    border-radius: 20px;
    padding: 8px 18px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
}
.opening-question:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

/* 响应式手机端 */
/* COMPAT-C 说明：原移动端媒体查询（仅做全屏化 + column-reverse，无安全区/
   无小断点/无键盘遮挡处理）已整体升级为下方的 COMPAT-C 段落。 */


/* P2-14：历史会话分页按钮 */
#deepseek-chat-history .deepseek-load-more-history {
    display: block;
    width: 100%;
    margin: 8px 0 4px;
    padding: 6px 10px;
    font-size: 13px;
    color: #3c6e9f;
    background: #f3f7fb;
    border: 1px solid #d1e0e8;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s ease;
}

#deepseek-chat-history .deepseek-load-more-history:hover {
    background: #e7f0f8;
}

#deepseek-chat-history .deepseek-load-more-history[disabled] {
    opacity: 0.6;
    cursor: default;
}

/* ==========================================================================
 * 前台兼容性优化层 v1.1（由 wpai-responsive.js 配合驱动，均可安全删除）
 *   COMPAT-A 主题冲突隔离 / 设计变量
 *   COMPAT-B 容器尺寸与动态视口（dvh）
 *   COMPAT-C 移动端（≤800px）全屏布局、安全区、触控热区
 *   COMPAT-D 触控设备热区
 *   COMPAT-E 正文元素隔离与暗色主题
 * ========================================================================== */

/* --------------------------------------------------------------------------
 * COMPAT-A  主题冲突隔离层
 * 背景：① 原实现在全局 body 上设置渐变背景/字体，会覆盖整站主题样式；
 *      ② 主题的 p / h1-h6 / ul / table / a 等通用选择器会反向污染聊天气泡。
 * 处理：所有样式收敛到 #deepseek-chat-container 作用域内，双向隔离。
 * -------------------------------------------------------------------------- */
#deepseek-chat-container {
    /* ---- 可被主题 CSS 覆盖的设计变量（把本段复制到主题样式表末尾即可定制） ---- */
    --ds-chat-radius: 24px;
    --ds-chat-surface: rgba(255, 255, 255, 0.65);
    --ds-chat-surface-solid: #ffffff;
    --ds-chat-border: rgba(255, 255, 255, 0.6);
    --ds-chat-border-soft: rgba(224, 224, 224, 0.5);
    --ds-chat-text: #333333;
    --ds-chat-text-muted: #667085;
    --ds-chat-accent: #6a11cb;
    --ds-chat-accent-2: #2575fc;
    --ds-chat-bubble-bot-bg: rgba(255, 255, 255, 0.85);
    --ds-chat-bubble-bot-border: rgba(255, 255, 255, 0.9);
    --ds-chat-bubble-bot-text: #333333;
    --ds-chat-user-gradient: linear-gradient(135deg, #6a11cb 0%, #2575fc 100%);
    --ds-chat-user-text: #ffffff;
    --ds-chat-history-bg: rgba(249, 251, 253, 0.5);
    --ds-chat-history-item-bg: rgba(255, 255, 255, 0.5);
    --ds-chat-history-item-border: rgba(255, 255, 255, 0.6);
    --ds-chat-history-item-text: #444444;
    --ds-chat-input-bg: rgba(255, 255, 255, 0.85);
    --ds-chat-input-border: rgba(200, 200, 200, 0.6);
    --ds-chat-input-text: #333333;
    --ds-chat-input-area-bg: rgba(248, 249, 250, 0.4);
    --ds-chat-send-gradient: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
    --ds-chat-shadow: 0 15px 35px rgba(0, 0, 0, 0.1), 0 5px 15px rgba(0, 0, 0, 0.05);
    /* 主题若存在固定顶栏，可在外层覆盖该值，例如：#deepseek-chat-container{--ds-chat-viewport-offset:56px} */
    --ds-chat-viewport-offset: 0px;

    /* 字体与文字基线（替代原全局 body 设置） */
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial,
        "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    font-size: 16px;
    line-height: 1.6;
    color: var(--ds-chat-text);
    text-align: left;
    letter-spacing: normal;
    text-transform: none;
    font-style: normal;
    text-shadow: none;
    /* 建立独立层叠上下文，降低被主题通配选择器命中的概率 */
    isolation: isolate;
    position: relative;
}

/* 统一盒模型，避免主题 box-sizing 差异导致宽度计算错乱 */
#deepseek-chat-container,
#deepseek-chat-container *,
#deepseek-chat-container *::before,
#deepseek-chat-container *::after {
    box-sizing: border-box;
}

/* 表单元素只做“最小中立化”，不设置 box-shadow/背景，避免影响插件自身的按钮视觉 */
#deepseek-chat-container button,
#deepseek-chat-container input,
#deepseek-chat-container textarea,
#deepseek-chat-container select {
    font-family: inherit;
    text-transform: none;
    letter-spacing: normal;
    max-width: 100%;
}

/* 布局型列表（历史侧栏、工具栏）保持无项目符号；气泡正文的列表在 COMPAT-E 中单独恢复 */
#deepseek-chat-history :where(ul, ol),
#deepseek-options-bar :where(ul, ol, p),
#deepseek-chat-input-container :where(p, ul, ol) {
    margin: 0;
    padding: 0;
    list-style: none;
}
#deepseek-chat-container :where(h1, h2, h3, h4, h5, h6) {
    font-family: inherit;
    text-shadow: none;
}

/* 公告/提示条在窄屏不溢出 */
#deepseek-announcement,
.custom-notification {
    max-width: 100%;
    box-sizing: border-box;
}
.custom-notification {
    max-width: calc(100vw - 32px);
}

/* 移动端历史抽屉开关（由 wpai-responsive.js 注入，桌面隐藏） */
.ds-history-toggle {
    display: none;
}

/* “回到底部”悬浮按钮（由 wpai-responsive.js 注入，默认隐藏） */
.ds-scroll-bottom-btn {
    display: none;
    position: absolute;
    right: 18px;
    bottom: 104px;
    z-index: 20;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 1px solid rgba(37, 117, 252, 0.18);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.94);
    color: #2575fc;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}
.ds-scroll-bottom-btn.ds-visible {
    display: flex;
}

/* --------------------------------------------------------------------------
 * COMPAT-A2  设计变量绑定层
 * 背景：基础样式里的颜色是硬编码的，只声明变量、不重新声明规则，主题改变量不会生效。
 *       本节把关键外观接到 COMPAT-A 的变量上，取值与改造前逐一对应，浅色外观零变化。
 *       因此主题只需覆盖变量（例如把 --ds-chat-surface 改成 #fff）即可整体换肤。
 * -------------------------------------------------------------------------- */
#deepseek-chat-container {
    border-color: var(--ds-chat-border);
    border-radius: var(--ds-chat-radius);
    background: var(--ds-chat-surface);
    box-shadow: var(--ds-chat-shadow);
}
#deepseek-chat-history {
    background: var(--ds-chat-history-bg);
    border-right-color: var(--ds-chat-border-soft);
}
#deepseek-chat-history li {
    background: var(--ds-chat-history-item-bg);
    border-color: var(--ds-chat-history-item-border);
    color: var(--ds-chat-history-item-text);
}
#deepseek-chat-input-container {
    background: var(--ds-chat-input-area-bg);
    border-top-color: var(--ds-chat-border-soft);
}
#deepseek-chat-input {
    background: var(--ds-chat-input-bg);
    border-color: var(--ds-chat-input-border);
    color: var(--ds-chat-input-text);
}
#deepseek-chat-send {
    background: var(--ds-chat-send-gradient);
}
.message-bubble.bot {
    background: var(--ds-chat-bubble-bot-bg);
    border-color: var(--ds-chat-bubble-bot-border);
    color: var(--ds-chat-bubble-bot-text);
}
.message-bubble.user {
    background: var(--ds-chat-user-gradient);
    color: var(--ds-chat-user-text);
}

/* --------------------------------------------------------------------------
 * COMPAT-B  容器尺寸与动态视口
 * 移动端浏览器地址栏伸缩会让 100vh 大于可视区（底部被截断），dvh 与 JS 实测值双重兜底。
 * -------------------------------------------------------------------------- */
#deepseek-chat-container {
    height: 80vh;
    height: calc(80vh - var(--ds-chat-viewport-offset, 0px));
    max-height: calc(100vh - var(--ds-chat-viewport-offset, 0px));
}
@supports (height: 1dvh) {
    #deepseek-chat-container {
        max-height: calc(100dvh - var(--ds-chat-viewport-offset, 0px));
    }
}

#deepseek-chat-main {
    position: relative;
    min-width: 0;
}

/* 移动端惯性滚动 + 阻止滚动穿透（到顶/到底后不再带动页面滚动） */
#deepseek-chat-messages,
#deepseek-chat-history {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

/* --------------------------------------------------------------------------
 * COMPAT-C  移动端（≤800px）：全屏布局、刘海安全区、触控热区、防横向溢出
 * -------------------------------------------------------------------------- */
@media (max-width: 800px) {
    #deepseek-chat-container {
        flex-direction: column-reverse;
        /* 高度优先级：JS 实测可视高度(--ds-chat-vh) > 100vh 兜底 */
        height: 100vh;
        height: calc(var(--ds-chat-vh, 100vh) - var(--ds-chat-viewport-offset, 0px));
        max-height: calc(var(--ds-chat-vh, 100vh) - var(--ds-chat-viewport-offset, 0px));
        /* 全出血：抵消主题内容区左右内边距，避免窄屏出现横向滚动条 */
        width: calc(100vw - var(--ds-scrollbar-w, 0px));
        max-width: calc(100vw - var(--ds-scrollbar-w, 0px));
        margin-left: calc(50% - (100vw - var(--ds-scrollbar-w, 0px)) / 2);
        border-radius: 0;
        border-left: 0;
        border-right: 0;
        box-shadow: none;
    }

    /* 历史侧栏：改为可一键收起的抽屉式区块（默认展示，收起后仅留一行标题） */
    #deepseek-chat-history {
        width: 100%;
        max-width: 100%;
        max-height: 34vh;
        padding: 10px 12px;
        padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
        border-right: 0;
        border-top: 1px solid var(--ds-chat-border-soft);
        overflow-y: auto;
    }
    #deepseek-chat-history.ds-collapsed {
        max-height: none;
        padding: 6px 10px;
        overflow: hidden;
    }
    #deepseek-chat-history.ds-collapsed > *:not(.ds-history-toggle) {
        display: none !important;
    }

    .ds-history-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        width: 100%;
        min-height: 42px;
        margin: 0 0 8px;
        padding: 0 12px;
        border: 1px solid rgba(37, 117, 252, 0.16);
        border-radius: 12px;
        background: rgba(255, 255, 255, 0.72);
        color: #3f4d63;
        font-size: 13px;
        font-weight: 600;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
    }
    .ds-history-toggle::after {
        content: '';
        width: 8px;
        height: 8px;
        border-right: 2px solid currentColor;
        border-bottom: 2px solid currentColor;
        transform: rotate(45deg) translate(-2px, -2px);
        transition: transform 0.2s ease;
    }
    #deepseek-chat-history.ds-collapsed .ds-history-toggle::after {
        transform: rotate(-135deg) translate(-2px, -2px);
    }

    /* 消息区：为底部安全区留白，防止最后一条消息被小黑条遮挡 */
    #deepseek-chat-messages {
        padding: 14px 14px 18px;
        padding-bottom: calc(18px + env(safe-area-inset-bottom, 0px));
        scroll-padding-bottom: 18px;
    }

    /* 气泡：小屏提高可用宽度，长英文/URL 强制换行不撑破布局 */
    .message-bubble {
        max-width: 92%;
        padding: 12px 14px;
        margin-bottom: 14px;
        font-size: 15px;
        border-radius: 16px;
        overflow-wrap: break-word;
        word-break: break-word;
    }
    .message-bubble:last-child {
        margin-bottom: 18px;
    }

    /* 输入区：安全区 + 16px 字号（防 iOS 聚焦自动放大页面）+ 加大热区 */
    #deepseek-chat-input-container {
        padding: 10px 12px;
        padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
        gap: 8px;
        align-items: flex-end;
        min-height: 64px;
    }
    #deepseek-chat-input {
        font-size: 16px;
        line-height: 1.45;
        min-height: 44px;
        max-height: 112px;
        padding: 10px 14px;
        border-radius: 18px;
    }
    #deepseek-chat-send {
        flex: 0 0 auto;
        min-height: 44px;
        min-width: 72px;
        padding: 12px 16px;
        font-size: 15px;
        border-radius: 18px;
    }

    /* 工具栏 / 提示词 / 附件等次级控件 */
    #deepseek-options-bar {
        padding: 8px 12px 10px;
        gap: 8px;
        flex-wrap: wrap;
    }
    .deepseek-option-item,
    .deepseek-interface-select {
        font-size: 13px;
        padding: 7px 10px;
    }
    .deepseek-prompt-library-grid {
        grid-template-columns: 1fr;
    }
    #deepseek-chat-history .deepseek-history-actions button {
        min-height: 34px;
        padding: 6px 12px;
        font-size: 12.5px;
    }

    /* 表格：小屏横向滚动，避免内容被裁切 */
    #deepseek-chat-container .message-bubble table {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* “回到底部”按钮位置：贴在输入区上方 */
    .ds-scroll-bottom-btn {
        right: 14px;
        bottom: calc(var(--ds-input-area-h, 96px) + 12px);
        width: 38px;
        height: 38px;
        font-size: 15px;
    }

    /* 安全区收口（置于段落末尾，靠源码顺序覆盖上方同权重的内边距声明）
       仅在 viewport-fit=cover 生效且设备存在刘海/底部小黑条时，env() 才返回非 0 值 */
    #deepseek-chat-history,
    #deepseek-chat-input-container {
        padding-left: calc(12px + env(safe-area-inset-left, 0px));
        padding-right: calc(12px + env(safe-area-inset-right, 0px));
    }
    #deepseek-chat-messages {
        padding-left: calc(14px + env(safe-area-inset-left, 0px));
        padding-right: calc(14px + env(safe-area-inset-right, 0px));
    }
    #deepseek-chat-history {
        padding-top: calc(10px + env(safe-area-inset-top, 0px));
        padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    }
    #deepseek-chat-messages {
        padding-bottom: calc(18px + env(safe-area-inset-bottom, 0px));
    }
    #deepseek-chat-input-container {
        padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    }
}

/* --------------------------------------------------------------------------
 * COMPAT-D  触控设备：热区不低于 36-44px，去除点击高亮延迟
 * （与宽度断点解耦，可同时命中横屏手机与触屏平板）
 * -------------------------------------------------------------------------- */
@media (hover: none), (pointer: coarse) {
    #deepseek-chat-container button,
    #deepseek-chat-container a,
    #deepseek-chat-container select,
    #deepseek-chat-container .deepseek-prompt-template,
    #deepseek-chat-container .agent-item {
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
    }
    #deepseek-chat-container .deepseek-history-actions button {
        min-height: 36px;
        padding: 8px 12px;
        font-size: 13px;
    }
    #deepseek-chat-container #clear-conversation-button {
        min-height: 36px;
        padding: 8px 14px;
        font-size: 13px;
    }
    #deepseek-chat-container .deepseek-feedback-button {
        min-height: 36px;
        padding: 8px 14px;
        font-size: 13px;
    }
    #deepseek-chat-container .ai-tts-play,
    #deepseek-chat-container .bot-copy-button {
        width: 38px;
        height: 38px;
    }
    #deepseek-chat-container .pre-copy-button {
        min-height: 32px;
        padding: 6px 12px;
    }
    #deepseek-chat-container .deepseek-prompt-template {
        min-height: 48px;
    }
    #deepseek-chat-container .deepseek-prompt {
        padding: 12px 18px;
        font-size: 14px;
    }
    #deepseek-chat-container .deepseek-load-more-history {
        min-height: 40px;
        font-size: 14px;
    }
    #deepseek-chat-container .deepseek-recent-file-item {
        min-height: 44px;
    }
}

/* --------------------------------------------------------------------------
 * COMPAT-E  正文元素隔离 + 暗色主题
 * E-1：主题的 a/table/code/blockquote 往往会污染气泡正文，这里在气泡作用域内重建基线
 * E-2：.ds-dark（由脚本按系统偏好/主题类名添加）下统一转暗色
 * -------------------------------------------------------------------------- */
/* --- E-1 正文元素基线（浅色） --- */
.message-bubble :where(a) {
    color: var(--ds-chat-accent-2);
    text-decoration: underline;
    text-underline-offset: 2px;
}
.message-bubble :where(code) {
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.06);
    font-family: Menlo, Consolas, Monaco, "Courier New", monospace;
    font-size: 0.92em;
    word-break: break-word;
}
.message-bubble :where(pre code) {
    padding: 0;
    background: none;
    font-size: inherit;
}
.message-bubble :where(blockquote) {
    margin: 10px 0;
    padding: 6px 12px;
    border-left: 3px solid var(--ds-chat-accent);
    background: rgba(106, 17, 203, 0.06);
    border-radius: 0 8px 8px 0;
    color: var(--ds-chat-text-muted);
}
.message-bubble :where(hr) {
    height: 0;
    margin: 14px 0;
    border: 0;
    border-top: 1px solid rgba(0, 0, 0, 0.12);
}
/* 正文内列表恢复项目符号（侧栏已单独置空，互不影响） */
.message-bubble :where(ul, ol) {
    margin: 8px 0;
    padding-left: 22px;
}
.message-bubble :where(ul) {
    list-style: disc;
}
.message-bubble :where(ol) {
    list-style: decimal;
}

/* --- E-2 暗色主题核心兜底（不依赖 JS，兼容“跟随系统”主题） --- */
@media (prefers-color-scheme: dark) {
    #deepseek-chat-container {
        --ds-chat-surface: rgba(24, 26, 31, 0.78);
        --ds-chat-surface-solid: #1c1e23;
        --ds-chat-border: rgba(255, 255, 255, 0.08);
        --ds-chat-border-soft: rgba(255, 255, 255, 0.08);
        --ds-chat-text: #e4e7ec;
        --ds-chat-text-muted: #98a2b3;
        --ds-chat-bubble-bot-bg: rgba(38, 41, 48, 0.92);
        --ds-chat-bubble-bot-text: #e4e7ec;
        --ds-chat-input-bg: rgba(30, 33, 39, 0.9);
        --ds-chat-input-text: #e4e7ec;
        --ds-chat-input-area-bg: rgba(20, 22, 26, 0.6);
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.45);
    }
    #deepseek-chat-container .message-bubble.bot,
    #deepseek-chat-container .final-content {
        color: var(--ds-chat-bubble-bot-text);
    }
    #deepseek-chat-container #deepseek-chat-history li {
        color: #d5d9e2;
        background: rgba(255, 255, 255, 0.045);
        border-color: rgba(255, 255, 255, 0.07);
    }
    #deepseek-chat-container #deepseek-chat-history {
        background: rgba(20, 22, 26, 0.6);
    }
}

/* --- E-2 浅色锁定：JS 判定当前站点为浅色主题时，收回上面的系统级暗色兜底 --- */
@media (prefers-color-scheme: dark) {
    #deepseek-chat-container.ds-light {
        --ds-chat-surface: rgba(255, 255, 255, 0.65);
        --ds-chat-surface-solid: #ffffff;
        --ds-chat-border: rgba(255, 255, 255, 0.6);
        --ds-chat-border-soft: rgba(224, 224, 224, 0.5);
        --ds-chat-text: #333333;
        --ds-chat-text-muted: #667085;
        --ds-chat-bubble-bot-bg: rgba(255, 255, 255, 0.85);
        --ds-chat-bubble-bot-border: rgba(255, 255, 255, 0.9);
        --ds-chat-bubble-bot-text: #333333;
        --ds-chat-history-bg: rgba(249, 251, 253, 0.5);
        --ds-chat-history-item-bg: rgba(255, 255, 255, 0.5);
        --ds-chat-history-item-border: rgba(255, 255, 255, 0.6);
        --ds-chat-history-item-text: #444444;
        --ds-chat-input-bg: rgba(255, 255, 255, 0.85);
        --ds-chat-input-border: rgba(200, 200, 200, 0.6);
        --ds-chat-input-text: #333333;
        --ds-chat-input-area-bg: rgba(248, 249, 250, 0.4);
        box-shadow: 0 8px 32px rgba(31, 38, 135, 0.1);
    }
    #deepseek-chat-container.ds-light .message-bubble.bot,
    #deepseek-chat-container.ds-light .final-content {
        color: var(--ds-chat-bubble-bot-text);
    }
    #deepseek-chat-container.ds-light #deepseek-chat-history {
        background: rgba(249, 251, 253, 0.5);
    }
    #deepseek-chat-container.ds-light #deepseek-chat-history li {
        color: #444444;
        background: rgba(255, 255, 255, 0.5);
        border-color: rgba(255, 255, 255, 0.6);
    }
}

/* --- E-2 暗色主题完整覆盖（.ds-dark 由 wpai-responsive.js 添加） --- */
#deepseek-chat-container.ds-dark {
    --ds-chat-surface: rgba(24, 26, 31, 0.78);
    --ds-chat-surface-solid: #1c1e23;
    --ds-chat-border: rgba(255, 255, 255, 0.08);
    --ds-chat-border-soft: rgba(255, 255, 255, 0.08);
    --ds-chat-text: #e4e7ec;
    --ds-chat-text-muted: #98a2b3;
    --ds-chat-bubble-bot-bg: rgba(38, 41, 48, 0.92);
    --ds-chat-bubble-bot-border: rgba(255, 255, 255, 0.08);
    --ds-chat-bubble-bot-text: #e4e7ec;
    --ds-chat-history-bg: rgba(20, 22, 26, 0.6);
    --ds-chat-history-item-bg: rgba(255, 255, 255, 0.05);
    --ds-chat-history-item-border: rgba(255, 255, 255, 0.08);
    --ds-chat-history-item-text: #d0d5dd;
    --ds-chat-input-bg: rgba(30, 33, 39, 0.9);
    --ds-chat-input-border: rgba(255, 255, 255, 0.12);
    --ds-chat-input-text: #e4e7ec;
    --ds-chat-input-area-bg: rgba(20, 22, 26, 0.6);
    border-color: rgba(255, 255, 255, 0.08);
    background: rgba(24, 26, 31, 0.78);
    color: var(--ds-chat-text);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.45);
}
#deepseek-chat-container.ds-dark #deepseek-chat-history {
    background: rgba(20, 22, 26, 0.6);
    border-right-color: rgba(255, 255, 255, 0.08);
    border-top-color: rgba(255, 255, 255, 0.08);
}
#deepseek-chat-container.ds-dark #deepseek-chat-history li {
    color: #d5d9e2;
    background: rgba(255, 255, 255, 0.045);
    border-color: rgba(255, 255, 255, 0.07);
}
#deepseek-chat-container.ds-dark #deepseek-chat-history li:hover {
    background: rgba(255, 255, 255, 0.09);
}
#deepseek-chat-container.ds-dark #deepseek-chat-history li.active {
    color: #ffffff;
}
#deepseek-chat-container.ds-dark #deepseek-chat-history::-webkit-scrollbar-thumb,
#deepseek-chat-container.ds-dark #deepseek-chat-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.18);
}
#deepseek-chat-container.ds-dark .deepseek-history-actions button {
    background: rgba(255, 255, 255, 0.07);
    color: #d5d9e2;
    border-color: rgba(255, 255, 255, 0.12);
}
#deepseek-chat-container.ds-dark .deepseek-history-actions button:hover {
    border-color: rgba(110, 231, 183, 0.45);
    color: #6ee7b7;
}
#deepseek-chat-container.ds-dark .message-bubble.bot {
    background: var(--ds-chat-bubble-bot-bg);
    border-color: rgba(255, 255, 255, 0.08);
    color: var(--ds-chat-bubble-bot-text);
}
#deepseek-chat-container.ds-dark .final-content {
    color: var(--ds-chat-bubble-bot-text);
}
#deepseek-chat-container.ds-dark .reasoning-content {
    background: linear-gradient(135deg, rgba(64, 48, 122, 0.35), rgba(32, 44, 78, 0.35));
    border-left-color: #8b5cf6;
    color: #c3c9d4;
}
#deepseek-chat-container.ds-dark .reasoning-content strong {
    color: #b79bff;
}
#deepseek-chat-container.ds-dark .message-bubble table {
    background: rgba(255, 255, 255, 0.03);
    border-color: rgba(255, 255, 255, 0.1);
}
#deepseek-chat-container.ds-dark .message-bubble table th {
    background: rgba(255, 255, 255, 0.05);
    border-bottom-color: rgba(255, 255, 255, 0.1);
}
#deepseek-chat-container.ds-dark .message-bubble table td {
    border-bottom-color: rgba(255, 255, 255, 0.06);
}
#deepseek-chat-container.ds-dark .message-bubble :where(code) {
    background: rgba(255, 255, 255, 0.1);
}
#deepseek-chat-container.ds-dark .message-bubble :where(blockquote) {
    background: rgba(139, 92, 246, 0.12);
    color: #b6bcc8;
}
#deepseek-chat-container.ds-dark .message-bubble :where(hr) {
    border-top-color: rgba(255, 255, 255, 0.15);
}
#deepseek-chat-container.ds-dark .message-bubble :where(a) {
    color: #7cb0ff;
}
#deepseek-chat-container.ds-dark .deepseek-kb-sources {
    border-top-color: rgba(255, 255, 255, 0.1);
}
#deepseek-chat-container.ds-dark .deepseek-kb-sources-title {
    color: #9aa3b2;
}
#deepseek-chat-container.ds-dark .deepseek-kb-source-item {
    background: rgba(30, 185, 128, 0.18);
    color: #7ee2b8;
}
#deepseek-chat-container.ds-dark #deepseek-chat-input-container {
    background: var(--ds-chat-input-area-bg);
    border-top-color: rgba(255, 255, 255, 0.08);
}
#deepseek-chat-container.ds-dark #deepseek-chat-input {
    background: var(--ds-chat-input-bg);
    color: var(--ds-chat-input-text);
    border-color: rgba(255, 255, 255, 0.12);
}
#deepseek-chat-container.ds-dark #deepseek-chat-input::placeholder {
    color: #8b93a1;
}
#deepseek-chat-container.ds-dark #deepseek-chat-input:focus {
    background: rgba(36, 40, 47, 0.95);
    border-color: #8b5cf6;
}
#deepseek-chat-container.ds-dark #deepseek-prompt-library {
    background: linear-gradient(135deg, rgba(30, 185, 128, 0.1), rgba(37, 117, 252, 0.12));
    border-color: rgba(255, 255, 255, 0.08);
}
#deepseek-chat-container.ds-dark .deepseek-prompt-library-title {
    color: #e4e7ec;
}
#deepseek-chat-container.ds-dark .deepseek-prompt-template {
    background: rgba(255, 255, 255, 0.05);
    color: #dfe3ea;
    border-color: rgba(255, 255, 255, 0.1);
}
#deepseek-chat-container.ds-dark .deepseek-prompt-template-category {
    color: #98a2b3;
}
#deepseek-chat-container.ds-dark .deepseek-feedback {
    color: #98a2b3;
    border-top-color: rgba(255, 255, 255, 0.08);
}
#deepseek-chat-container.ds-dark .deepseek-feedback-button {
    background: rgba(255, 255, 255, 0.06);
    color: #dfe3ea;
    border-color: rgba(255, 255, 255, 0.12);
}
#deepseek-chat-container.ds-dark .deepseek-feedback-status {
    color: #6ee7b7;
}
#deepseek-chat-container.ds-dark #deepseek-custom-prompts .deepseek-prompt {
    background: rgba(139, 92, 246, 0.18);
    color: #cbb6ff;
    border-color: rgba(139, 92, 246, 0.35);
}
#deepseek-chat-container.ds-dark #deepseek-options-bar {
    border-top-color: rgba(255, 255, 255, 0.08);
}
#deepseek-chat-container.ds-dark .deepseek-option-item,
#deepseek-chat-container.ds-dark .deepseek-interface-select {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.08);
    color: #dfe3ea;
}
#deepseek-chat-container.ds-dark .deepseek-option-item:hover,
#deepseek-chat-container.ds-dark .deepseek-interface-select:hover {
    background: rgba(255, 255, 255, 0.09);
}
#deepseek-chat-container.ds-dark .deepseek-interface-select select {
    background: #23262e;
    color: #e4e7ec;
    border-color: rgba(255, 255, 255, 0.14);
}
#deepseek-chat-container.ds-dark .deepseek-search-toggle .slider {
    background-color: rgba(255, 255, 255, 0.2);
}
#deepseek-chat-container.ds-dark .deepseek-search-toggle .slider:before {
    background-color: #cfd6e4;
}
#deepseek-chat-container.ds-dark .deepseek-login-overlay {
    background: rgba(20, 22, 26, 0.85);
    color: #ff8f8f;
}
#deepseek-chat-container.ds-dark .deepseek-tutorial-link a {
    color: #b79bff;
}
#deepseek-chat-container.ds-dark #deepseek-announcement {
    background: rgba(255, 255, 255, 0.05);
    color: #c3c9d4;
    border-color: rgba(255, 255, 255, 0.08);
}
#deepseek-chat-container.ds-dark #uploaded-files-list,
#deepseek-chat-container.ds-dark #agent-uploaded-file {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.08);
}
#deepseek-chat-container.ds-dark #uploaded-files-list div,
#deepseek-chat-container.ds-dark #agent-uploaded-file {
    background: rgba(255, 255, 255, 0.06);
    color: #dfe3ea;
}
#deepseek-chat-container.ds-dark #deepseek-recent-files-panel {
    background: rgba(20, 22, 26, 0.85);
    border-color: rgba(255, 255, 255, 0.1);
}
#deepseek-chat-container.ds-dark .deepseek-recent-file-item {
    background: rgba(255, 255, 255, 0.05);
    color: #dfe3ea;
    border-color: rgba(255, 255, 255, 0.1);
}
#deepseek-chat-container.ds-dark .deepseek-recent-file-meta,
#deepseek-chat-container.ds-dark .deepseek-recent-file-empty {
    color: #98a2b3;
}
#deepseek-chat-container.ds-dark .agent-item {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.08);
}
#deepseek-chat-container.ds-dark .agent-item:hover {
    background: rgba(255, 255, 255, 0.09);
}
#deepseek-chat-container.ds-dark .agent-name {
    color: #e4e7ec;
}
#deepseek-chat-container.ds-dark .agent-description {
    color: #98a2b3;
}
#deepseek-chat-container.ds-dark .opening-question {
    background: linear-gradient(135deg, #3b2f5e 0%, #2b3f63 100%);
    color: #e6e8ec;
}
#deepseek-chat-container.ds-dark .deepseek-load-more-history {
    color: #9ec1e8;
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.12);
}
#deepseek-chat-container.ds-dark .ds-history-toggle {
    background: rgba(255, 255, 255, 0.07);
    color: #dfe3ea;
    border-color: rgba(255, 255, 255, 0.12);
}
#deepseek-chat-container.ds-dark .ds-scroll-bottom-btn {
    background: rgba(38, 41, 48, 0.95);
    color: #9ec1e8;
    border-color: rgba(255, 255, 255, 0.12);
}
/* 品牌渐变按钮（发送 / 上传 / 复制 / 通知）在暗色下保持原样，
   仅给“黑底气泡型”与“浅底提示型”元素补一层可见边界，避免在暗底上糊成一团 */
#deepseek-chat-container.ds-dark .tooltip,
#deepseek-chat-container.ds-dark .deepseek-feedback .tooltip {
    border: 1px solid rgba(255, 255, 255, 0.16);
}
#deepseek-chat-container.ds-dark #deepseek-thinking-message {
    color: #3ddc97;
}
#deepseek-chat-container.ds-dark .message-bubble.user {
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.35);
}


/* ==========================================================================
 * COMPAT-F  首页嵌入布局收敛层（v1.2）
 * --------------------------------------------------------------------------
 * 背景：首页（块主题 / 页面构建器 / 模板部件 / 代码片段）渲染聊天组件时，容器脱离
 *       主题内容列，出现「宽度=整屏、左右无留白、场景按钮横向拉伸、控件比例失衡」等问题。
 * 处理：① 桌面端容器按内容列收敛并居中；② 输入区 / 气泡比例约束；
 *       ③ 移动端场景卡片两列排布并消除末张孤卡；④ 关键尺寸全部变量化，便于主题覆盖。
 * 作用域：仅使用插件自身选择器（#deepseek-chat-* / .deepseek-*）与插件变量，
 *         不新增任何全局选择器，不污染主题样式。
 * 主题可覆盖的变量：
 *         --ds-chat-max-width  桌面端内容列最大宽度，默认 1180px（宽栏主题可改 1340px）
 *         --ds-chat-gutter     桌面端两侧留白，默认 24px
 *         --ds-chat-input-h    桌面端输入框基准高度，默认 92px（约 3 行）
 * ========================================================================== */

#deepseek-chat-container {
    --ds-chat-max-width: 1180px;
    --ds-chat-gutter: 24px;
    --ds-chat-input-h: 92px;
}

/* F1 桌面 / 平板：容器按内容列收敛并居中，不再顶满整屏（配合基础样式的 margin: 40px auto） */
@media (min-width: 801px) {
    #deepseek-chat-container {
        width: 100%;
        max-width: min(var(--ds-chat-max-width), calc(100% - var(--ds-chat-gutter) * 2));
        margin-left: auto;
        margin-right: auto;
    }

    /* F2 输入区比例：发送按钮与输入框底边对齐，输入框高度收敛到约 3 行，避免宽屏下比例失衡 */
    #deepseek-chat-input-container {
        align-items: flex-end;
    }
    #deepseek-chat-input {
        height: var(--ds-chat-input-h);
        min-height: var(--ds-chat-input-h);
        max-height: 220px;
    }

    /* F3 场景按钮：宽屏自适应多列，但每列不小于 180px，不再被拉伸成整行超宽按钮 */
    .deepseek-prompt-library-grid {
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    }

    /* F4 消息气泡：超宽屏下限制行长，保证阅读舒适度 */
    .message-bubble {
        max-width: min(75%, 760px);
    }
}

/* F5 移动端：场景卡片两列排布，末张孤卡跨列占满，消除「孤行卡片」与区块间距失衡 */
@media (max-width: 800px) {
    #deepseek-prompt-library {
        margin: 10px 0 4px;
        padding: 12px;
    }
    .deepseek-prompt-library-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }
    .deepseek-prompt-library-grid > .deepseek-prompt-template:last-child:nth-child(odd) {
        grid-column: 1 / -1;
    }
    .deepseek-prompt-template {
        padding: 10px 12px;
    }
    .deepseek-prompt-template-title {
        font-size: 13.5px;
    }
}
