/* ========== 全局重置 ========== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
                 "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue",
                 Helvetica, Arial, sans-serif;
    background: #1a1a2e;
    color: #e0e0e0;
    min-height: 100vh;
}

/* ========== 顶部导航栏 ========== */
.ai-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 200;
    background: rgba(15, 15, 30, 0.92);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    height: 52px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.ai-nav-inner {
    max-width: 1100px;
    margin: 0 auto;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
}

.ai-nav-brand {
    color: #fff;
    font-size: 18px;
    font-weight: 700;
    text-decoration: none;
    letter-spacing: 1px;
}

.ai-nav-links {
    display: flex;
    gap: 28px;
}

.ai-nav-links a {
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    font-size: 14px;
    transition: color 0.2s;
}

.ai-nav-links a:hover,
.ai-nav-links a.active {
    color: #fff;
}

.ai-nav-links a.active {
    font-weight: 600;
}

/* ========== 整体布局 ========== */
.ai-layout {
    display: flex;
    padding-top: 52px;
    min-height: 100vh;
    background: #1a1a2e;
}

/* ========== 侧边栏 — 深色 DeepSeek 风格 ========== */
.ai-sidebar {
    width: 260px;
    min-width: 260px;
    height: calc(100vh - 52px);
    position: sticky;
    top: 52px;
    background: #151525;
    display: flex;
    flex-direction: column;
    transition: width 0.25s ease, min-width 0.25s ease;
    overflow: hidden;
    z-index: 50;
    border-right: 1px solid rgba(255, 255, 255, 0.04);
}

.ai-sidebar.collapsed {
    width: 60px;
    min-width: 60px;
}

/* ---- 侧边栏顶部 ---- */
.sidebar-top {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 10px;
    flex-shrink: 0;
}

.sidebar-collapse-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: rgba(255, 255, 255, 0.55);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s;
}

.sidebar-collapse-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.85);
}

.sidebar-new-chat-btn {
    flex: 1;
    height: 36px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: transparent;
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 13px;
    font-family: inherit;
    transition: all 0.2s;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-new-chat-btn:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.25);
    color: #fff;
}

.sidebar-new-icon {
    flex-shrink: 0;
}

/* 收起后只显示图标 */
.ai-sidebar.collapsed .sidebar-new-chat-btn {
    flex: 0;
    width: 40px;
    height: 36px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    justify-content: center;
    padding: 0;
}

.ai-sidebar.collapsed .sidebar-label {
    display: none;
}

.ai-sidebar.collapsed .sidebar-top {
    flex-direction: column;
    gap: 8px;
    align-items: center;
    padding: 12px 10px;
}

/* ---- 对话列表 ---- */
.sidebar-list {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

.sidebar-list::-webkit-scrollbar {
    width: 4px;
}

.sidebar-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
}

.sidebar-empty {
    text-align: center;
    color: rgba(255, 255, 255, 0.3);
    font-size: 13px;
    padding: 32px 0;
}

/* 收起后隐藏列表 */
.ai-sidebar.collapsed .sidebar-list {
    display: none;
}

/* 对话项 */
.sidebar-item {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s;
    position: relative;
    white-space: nowrap;
}

.sidebar-item:hover {
    background: rgba(255, 255, 255, 0.06);
}

.sidebar-item.active {
    background: rgba(255, 255, 255, 0.1);
}

.sidebar-item.active .sidebar-item-title {
    color: #fff;
    font-weight: 500;
}

.sidebar-item-body {
    flex: 1;
    overflow: hidden;
    min-width: 0;
}

.sidebar-item-title {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.7);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-item-time {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.3);
    margin-top: 2px;
}

.sidebar-item-del {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    border-radius: 6px;
    border: none;
    background: transparent;
    color: rgba(255, 255, 255, 0.2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: all 0.15s;
    margin-left: 4px;
}

.sidebar-item:hover .sidebar-item-del {
    opacity: 1;
}

.sidebar-item-del:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

/* ---- 侧边栏底部 ---- */
.sidebar-bottom {
    padding: 12px 10px;
    flex-shrink: 0;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.ai-sidebar.collapsed .sidebar-bottom {
    align-items: center;
}

.sidebar-action-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    height: 40px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    font-size: 13px;
    font-family: inherit;
    padding: 0 12px;
    transition: all 0.15s;
    white-space: nowrap;
}

.sidebar-action-btn:hover {
    background: rgba(255, 255, 255, 0.06);
    color: rgba(255, 255, 255, 0.85);
}

.ai-sidebar.collapsed .sidebar-action-btn {
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
}

/* ---- 全局工具提示 ---- */
.sidebar-tooltip {
    position: fixed;
    z-index: 9999;
    background: rgba(30, 30, 30, 0.95);
    color: #fff;
    font-size: 12px;
    padding: 6px 10px;
    border-radius: 6px;
    pointer-events: none;
    opacity: 0;
    transform: translateY(-50%);
    transition: opacity 0.15s;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.sidebar-tooltip.show {
    opacity: 1;
}

/* ========== 主内容区 ========== */
.ai-page {
    flex: 1;
    max-width: 900px;
    margin: 0 auto;
    padding: 20px 40px 130px;
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 52px);
}

/* ========== 消息列表 ========== */
.ai-messages {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.ai-msg {
    display: flex;
    flex-direction: column;
    animation: fadeUp 0.3s ease;
}

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

.ai-msg.user {
    align-items: flex-end;
}

.ai-msg.assistant {
    align-items: flex-start;
}

/* ========== 消息气泡 ========== */
.ai-bubble {
    max-width: 85%;
    padding: 12px 18px;
    border-radius: 18px;
    font-size: 15px;
    line-height: 1.7;
    word-break: break-word;
}

.ai-msg.user .ai-bubble {
    background: #4f6fbf;
    color: #fff;
    border-bottom-right-radius: 18px;
}

.ai-msg.assistant .ai-bubble {
    background: #2a2a3a;
    color: #e0e0e0;
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-bottom-left-radius: 18px;
}

/* ========== 气泡内 Markdown ========== */
.ai-bubble p { margin: 0 0 10px 0; }
.ai-bubble p:last-child { margin-bottom: 0; }

.ai-bubble pre {
    background: #1e1e1e;
    border-radius: 8px;
    padding: 14px;
    overflow-x: auto;
    font-size: 13px;
    line-height: 1.6;
    margin: 10px 0;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.code-block-wrapper {
    position: relative;
    margin: 10px 0;
}

.code-block-wrapper pre {
    margin: 0;
    padding-top: 38px;
}

.code-copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 5px 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.08);
    color: #9ca3af;
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.code-copy-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #e0e0e0;
    border-color: rgba(255, 255, 255, 0.2);
}

.code-copy-btn.copied {
    color: #34d399;
    border-color: rgba(52, 211, 153, 0.3);
    background: rgba(52, 211, 153, 0.1);
}

.ai-msg.user .ai-bubble .code-copy-btn {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.18);
    color: rgba(255, 255, 255, 0.8);
}

.ai-msg.user .ai-bubble .code-copy-btn:hover {
    background: rgba(255, 255, 255, 0.22);
    color: #fff;
}

.ai-msg.user .ai-bubble .code-copy-btn.copied {
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.3);
}

.hljs-ln-numbers { display: none; }

.ai-bubble code {
    font-family: "SF Mono", "Fira Code", "Consolas", "Monaco", monospace;
    font-size: 13px;
}

.ai-bubble :not(pre) > code {
    background: rgba(255, 255, 255, 0.08);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
    color: #e0e0e0;
}

.ai-msg.user .ai-bubble :not(pre) > code {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

.ai-msg.user .ai-bubble pre {
    background: rgba(0, 0, 0, 0.3);
    color: rgba(255, 255, 255, 0.9);
}

.ai-msg.assistant .ai-bubble pre {
    background: #16162a;
}

.ai-bubble ul, .ai-bubble ol {
    padding-left: 22px;
    margin: 8px 0;
}

.ai-bubble li { margin-bottom: 4px; }

.ai-bubble blockquote {
    border-left: 3px solid rgba(255, 255, 255, 0.15);
    padding-left: 14px;
    margin: 10px 0;
    color: #9ca3af;
}

.ai-msg.user .ai-bubble blockquote {
    border-left-color: rgba(255, 255, 255, 0.4);
    color: rgba(255, 255, 255, 0.8);
}

.ai-bubble table {
    border-collapse: collapse;
    width: 100%;
    margin: 10px 0;
    font-size: 14px;
}

.ai-bubble th, .ai-bubble td {
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 8px 12px;
    text-align: left;
}

.ai-bubble th {
    background: rgba(255, 255, 255, 0.05);
    font-weight: 600;
}

.ai-bubble h1, .ai-bubble h2, .ai-bubble h3,
.ai-bubble h4, .ai-bubble h5, .ai-bubble h6 {
    margin: 14px 0 8px;
    font-weight: 600;
}

.ai-bubble h1 { font-size: 1.4em; }
.ai-bubble h2 { font-size: 1.25em; }
.ai-bubble h3 { font-size: 1.1em; }

/* ========== 打字指示器 ========== */
.typing-cursor {
    display: inline-block;
    width: 2px;
    height: 1em;
    background: #4f6fbf;
    margin-left: 2px;
    vertical-align: text-bottom;
    animation: blink 0.8s infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* ========== 底部输入栏 — 透明化深色 ========== */
.ai-input-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: transparent;
    padding: 12px 20px 14px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.ai-input-inner {
    overflow: hidden;
    width: 100%;
    max-width: 900px;
    display: flex;
    gap: 10px;
    align-items: center;
    background: #2a2a3a;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 18px;
    padding: 10px 14px;
    transition: border-color 0.2s, background 0.2s;
}

.ai-input-inner:focus-within {
    border-color: #4f6fbf;
    background: #2f2f42;
}

#ai-input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-size: 15px;
    font-family: inherit;
    line-height: 1.5;
    color: #e0e0e0;
    resize: none !important; overflow: hidden !important;
    max-height: 150px;
}

#ai-input::placeholder {
    color: #6b7280;
}

#ai-send-btn {
    flex-shrink: 0;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    border: none;
    background: #4f6fbf;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

#ai-send-btn:hover {
    background: #5b7fd4;
}

#ai-stop-btn {
    flex-shrink: 0;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: #2a2a3a;
    color: #9ca3af;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

#ai-stop-btn:hover {
    background: #33334a;
    color: #e0e0e0;
}

#ai-send-btn:disabled {
    background: #3a3a4a;
    cursor: not-allowed;
}

.ai-bubble.error {
    background: rgba(220, 38, 38, 0.12);
    border: 1px solid rgba(220, 38, 38, 0.25);
    color: #fca5a5;
    font-size: 14px;
}

/* ========== 响应式 ========== */
@media (max-width: 900px) {
    .ai-sidebar {
        position: fixed;
        left: 0;
        top: 52px;
        height: calc(100vh - 52px);
        z-index: 70;
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.3);
        transform: translateX(0);
        transition: transform 0.25s ease;
    }

    .ai-sidebar.collapsed {
        transform: translateX(-100%);
        width: 260px;
        min-width: 260px;
    }

    .ai-nav-inner {
        padding-left: 16px;
    }

    .ai-nav-links {
        gap: 16px;
    }

    .ai-nav-links a {
        font-size: 13px;
    }

    .ai-page {
        padding: 20px 28px 120px;
    }

    .ai-bubble {
        max-width: 92%;
        font-size: 14px;
    }

    .ai-input-bar {
        padding: 10px 12px;
    }
}

@media (max-width: 640px) {
    .ai-nav-inner {
        padding: 0 12px;
    }

    .ai-nav-links {
        gap: 12px;
    }

    .ai-nav-links a {
        font-size: 12px;
    }

    .ai-page {
        padding: 16px 20px 110px;
    }
}

/* ========== 上传按钮 ========== */
.ai-upload-btn {
    flex-shrink: 0;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    border: none;
    background: transparent;
    color: #6b7280;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.ai-upload-btn:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #9ca3af;
}

.ai-upload-btn.loading {
    opacity: 0.5;
    pointer-events: none;
}

/* ========== 多文件标签容器（DeepSeek 风格 — 输入框上方内联） ========== */
.ai-files-container {
    width: 100%;
    max-width: 900px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    padding: 4px 0;
    /* 空时不占空间 */
    min-height: 0;
}

/* ========== 单个文件标签（Chip 风格） ========== */
.ai-file-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    background: #2a2a3a;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    font-size: 13px;
    color: #d1d5db;
    transition: all 0.15s;
    line-height: 1.2;
    user-select: none;
}

.ai-file-tag:hover {
    background: #33334d;
    border-color: rgba(255, 255, 255, 0.15);
}

/* 文件图标 */
.ai-file-tag-icon {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    color: #6b7280;
}

/* 文件名 — 过长时中间截断 */
.ai-file-tag-name {
    max-width: 160px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    /* 中间截断由 JS 处理 */
    color: #d1d5db;
}

/* 删除按钮 */
.ai-file-tag-remove {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    border-radius: 4px;
    border: none;
    background: transparent;
    color: #6b7280;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    line-height: 1;
    padding: 0;
    transition: all 0.15s;
    margin-left: 2px;
}

.ai-file-tag-remove:hover {
    background: rgba(239, 68, 68, 0.25);
    color: #f87171;
}

/* ========== 消息气泡内文件缩略图 ========== */
.ai-msg-files {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-bottom: 6px;
    text-decoration: none !important;
}

.ai-msg-file-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 6px;
    font-size: 12px;
    color: #9ca3af;
    line-height: 1.3;
    user-select: none;
    transition: background 0.15s;
    text-decoration: none !important;
}

.ai-msg-file-tag:hover {
    background: rgba(255, 255, 255, 0.1);
}

.ai-msg-file-tag-name {
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #9ca3af;
    text-decoration: none !important;
}

/* assistant 消息不显示文件行，所有文件标签彻底禁止划字线 */
.ai-msg.assistant .ai-msg-files {
    display: none;
}

.ai-msg-files,
.ai-msg-files *,
.ai-msg-file-tag,
.ai-msg-file-tag *,
.ai-msg-file-tag-name {
    text-decoration: none !important;
}

/* ========== 上传进度指示器（内联） ========== */
.ai-upload-progress {
    width: 100%;
    max-width: 900px;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 2px 0;
    font-size: 12px;
    color: #a5b4fc;
    opacity: 0.85;
}

/* ========== 联网搜索按钮 ========== */
.ai-websearch-btn {
    flex-shrink: 0;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    border: none;
    background: transparent;
    color: #6b7280;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    position: relative;
}

.ai-websearch-btn:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #9ca3af;
}

.ai-websearch-btn.active {
    background: rgba(79, 111, 191, 0.25);
    color: #4f6fbf;
}

.ai-websearch-btn.active:hover {
    background: rgba(79, 111, 191, 0.35);
    color: #7b93d9;
}

.ai-websearch-btn:disabled {
    opacity: 0.5;
    pointer-events: none;
}

/* ========== 搜索状态指示器 ========== */
.ai-search-indicator {
    position: fixed;
    bottom: 88px;
    left: 50%;
    transform: translateX(-50%);
    max-width: 900px;
    width: calc(100% - 40px);
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: #2a2a3a;
    border: 1px solid rgba(79, 111, 191, 0.3);
    border-radius: 12px;
    z-index: 101;
    font-size: 13px;
    color: #9ca3af;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ========== 深度思考样式 ========== */
/* 分隔线：思考过程与正式回答之间的 hr */
.ai-bubble hr {
    border: none;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    margin: 14px 0;
}

/* 思考段落：紧邻 <hr> 之前的段落（深度思考的最后一段） */
.ai-bubble p:has(+ hr) {
    color: #a0a0b0;
    font-size: 0.9em;
    border-left: 3px solid #555;
    padding-left: 14px;
}

/* 思考段落内的加粗文字 */
.ai-bubble p:has(+ hr) strong {
    color: #b0b0c0;
}

/* 用户气泡（蓝色背景）中的 hr 和思考样式 */
.ai-msg.user .ai-bubble hr {
    border-top-color: rgba(255, 255, 255, 0.25);
}

.ai-msg.user .ai-bubble p:has(+ hr) {
    color: rgba(255, 255, 255, 0.75);
    border-left-color: rgba(255, 255, 255, 0.4);
}
/* ========== 侧边栏模式选择器 ========== */
.sidebar-mode {
    padding: 8px 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex-shrink: 0;
}

.sidebar-mode-label {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.3);
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 0 6px;
    margin-bottom: 2px;
}

.sidebar-mode-btn {
    width: 100%;
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid transparent;
    background: transparent;
    color: rgba(255, 255, 255, 0.45);
    cursor: pointer;
    font-size: 13px;
    font-family: inherit;
    text-align: left;
    transition: all 0.15s;
    white-space: nowrap;
}

.sidebar-mode-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: rgba(255, 255, 255, 0.7);
}

.sidebar-mode-btn.active {
    background: rgba(255, 255, 255, 0.08);
    color: #e0e0e0;
    border-color: rgba(255, 255, 255, 0.15);
    font-weight: 500;
}

/* 收起侧边栏后隐藏模式区 */
.ai-sidebar.collapsed .sidebar-mode {
    display: none;
}

/* ========== 深度思考开关区域 ========== */
.sidebar-deepthink {
    padding: 10px 16px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.ai-sidebar.collapsed .sidebar-deepthink {
    display: none;
}

/* Toggle Switch */
.toggle-switch {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
    position: relative;
}

.toggle-switch input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: relative;
    width: 40px;
    height: 22px;
    background: #3a3a4a;
    border-radius: 22px;
    transition: background 0.25s ease;
    flex-shrink: 0;
}

.toggle-slider::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    background: #6b7280;
    border-radius: 50%;
    transition: all 0.25s ease;
}

.toggle-switch input:checked + .toggle-slider {
    background: #4f6fbf;
}

.toggle-switch input:checked + .toggle-slider::after {
    background: #fff;
    transform: translateX(18px);
}

.toggle-label {
    font-size: 13px;
    color: #9ca3af;
    transition: color 0.2s;
}

.toggle-switch input:checked ~ .toggle-label {
    color: #a5b4fc;
}

/* ========== 消息气泡内思考过程区域 ========== */
.ai-thinking-block {
    margin-bottom: 12px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    overflow: hidden;
}

.ai-thinking-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.03);
    cursor: pointer;
    user-select: none;
    font-size: 13px;
    color: #9ca3af;
    transition: background 0.15s;
}

.ai-thinking-header:hover {
    background: rgba(255, 255, 255, 0.05);
}

.ai-thinking-header .toggle-arrow {
    transition: transform 0.2s;
    font-size: 10px;
    color: #6b7280;
}

.ai-thinking-block.collapsed .toggle-arrow {
    transform: rotate(-90deg);
}

.ai-thinking-body {
    padding: 10px 14px;
    font-size: 13px;
    color: #9ca3af;
    font-style: italic;
    line-height: 1.7;
    border-top: 1px solid rgba(255, 255, 255, 0.04);
    max-height: 400px;
    overflow-y: auto;
    display: block;
}

.ai-thinking-block.collapsed .ai-thinking-body {
    display: none;
}

.ai-thinking-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.06);
    margin: 8px 0 12px;
}


/* ========== Toast 提示 ========== */
.ai-toast {
    position: fixed;
    top: 68px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    background: rgba(79, 111, 191, 0.9);
    color: #fff;
    padding: 10px 24px;
    border-radius: 10px;
    font-size: 14px;
    font-family: inherit;
    z-index: 300;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s, transform 0.3s;
    white-space: nowrap;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.ai-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* 响应式：小屏模式按钮缩小 */
@media (max-width: 640px) {
    .ai-mode-bar {
        gap: 4px;
        padding: 8px 0 4px;
    }

    .ai-mode-btn {
        padding: 6px 14px;
        font-size: 13px;
    }
}
/* ========== 侧边栏对话项操作按钮组 ========== */
.sidebar-item-actions {
    display: flex;
    gap: 2px;
    flex-shrink: 0;
    margin-left: 4px;
}

.sidebar-item-edit,
.sidebar-item-del {
    width: 26px;
    height: 26px;
    border-radius: 6px;
    border: none;
    background: transparent;
    color: rgba(255, 255, 255, 0.18);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: all 0.15s;
}

.sidebar-item:hover .sidebar-item-edit,
.sidebar-item:hover .sidebar-item-del {
    opacity: 1;
}

.sidebar-item-edit:hover {
    background: rgba(79, 111, 191, 0.2);
    color: #4f6fbf;
}

.sidebar-item-del:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

/* ========== AI 消息底部操作按钮 ========== */
.ai-msg-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 8px;
    padding-top: 4px;
}

.ai-msg-action-btn {
    padding: 4px 12px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.04);
    color: rgba(255, 255, 255, 0.4);
    cursor: pointer;
    font-size: 0.75rem;
    font-family: inherit;
    transition: all 0.15s;
    white-space: nowrap;
}

.ai-msg-action-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.7);
    border-color: rgba(255, 255, 255, 0.15);
}

.ai-msg-action-btn.copied {
    color: #34d399;
    border-color: rgba(52, 211, 153, 0.25);
    background: rgba(52, 211, 153, 0.08);
}

/* 用户气泡中的操作按钮不需要（用户消息不显示） */
/* 只对 assistant 消息显示 */

/* 导出/清空按钮在收起侧边栏时的适配 */
.ai-sidebar.collapsed .sidebar-bottom .sidebar-action-btn {
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
}

/* ========== 侧边栏原地编辑输入框 ========== */
.sidebar-item-input {
    width: 100%;
    padding: 4px 8px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    background: #2a2a3a;
    color: #e0e0e0;
    font-size: 13px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s;
}

.sidebar-item-input:focus {
    border-color: #4f6fbf;
}

/* ========== 自定义确认弹窗 ========== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(3px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    animation: modalFadeIn 0.2s ease;
}

@keyframes modalFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes modalSlideIn {
    from { opacity: 0; transform: translateY(-20px) scale(0.95); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-card {
    background: #1e1e2e;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 24px 28px;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.4);
    animation: modalSlideIn 0.25s ease;
}

.modal-title {
    font-size: 16px;
    font-weight: 600;
    color: #e0e0e0;
    margin-bottom: 10px;
}

.modal-body {
    font-size: 14px;
    color: #9ca3af;
    line-height: 1.6;
    margin-bottom: 22px;
}

.modal-buttons {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.modal-btn {
    padding: 8px 20px;
    border-radius: 8px;
    border: none;
    font-size: 14px;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s;
    font-weight: 500;
}

.modal-btn-cancel {
    background: rgba(255, 255, 255, 0.08);
    color: #9ca3af;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.modal-btn-cancel:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #d1d5db;
}

.modal-btn-confirm {
    background: #dc2626;
    color: #fff;
}

.modal-btn-confirm:hover {
    background: #ef4444;
}

body.modal-open {
    overflow: hidden;
}
