/* ================= DataWeaver Notebook 样式 ================= */

/* ================= 1. 全局变量与基础设置 ================= */
:root {
    /* 配色方案 */
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --secondary: #64748b;
    --text-dark: #1e293b;
    --bg-canvas: #f1f5f9;
    --bg-sidebar: rgba(255, 255, 255, 0.75);
    --border-color: rgba(226, 232, 240, 0.6);
    --success-bg: #dcfce7;
    --success-text: #166534;
    --process-bg: #dbeafe;
    --process-text: #1e40af;
    --error-bg: #fee2e2;
    --error-text: #991b1b;
    --glass-bg: rgba(255, 255, 255, 0.75);
    --glass-border: rgba(255, 255, 255, 0.5);
    --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.05);
    /* Viewport adjustments */
    --vh: 1vh;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--text-dark);
    background-color: #fff;
    margin: 0;
    padding: 0;
    overflow: hidden;
    /* 防止 body 滚动 */
}

/* 滚动条美化 */
.custom-scroll::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.custom-scroll::-webkit-scrollbar-track {
    background: transparent;
}

.custom-scroll::-webkit-scrollbar-thumb {
    background-color: #cbd5e1;
    border-radius: 3px;
}

.custom-scroll::-webkit-scrollbar-thumb:hover {
    background-color: #94a3b8;
}

/* ================= 2. 核心布局 ================= */
.layout-container {
    display: flex;
    width: 100vw;
    height: calc(var(--vh, 1vh) * 100);
    padding-top: var(--safe-top);
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    overflow: hidden;
}

/* 左侧侧边栏 */
.sidebar-panel {
    width: 280px;
    min-width: 280px;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-sidebar);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-right: 1px solid var(--border-color);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.02);
    z-index: 20;
    height: 100%;
    overflow: hidden;
    transition: width 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.sidebar-panel.collapsed .sidebar-content {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    flex: 0;
    height: 0;
}

.sidebar-panel.collapsed .sidebar-header {
    padding: 12px 0;
    justify-content: center;
    border-bottom: none;
    gap: 0;
}

.sidebar-panel.collapsed .sidebar-header .sidebar-tabs-nav {
    display: none;
}

/* Allow popover to be visible when collapsed */
.sidebar-panel.collapsed {
    width: 60px;
    min-width: 60px;
    overflow: visible;
}

.sidebar-footer {
    display: flex;
    justify-content: flex-end;
    padding: 10px;
    border-top: 1px solid var(--border-color);
    background: transparent;
}

.sidebar-panel.collapsed .sidebar-footer {
    justify-content: center;
}

.btn-collapse {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 1.25rem;
    color: var(--secondary);
    padding: 6px;
    border-radius: 8px;
    transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-collapse:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--primary);
}

.sidebar-tabs-wrapper {
    flex-shrink: 0;
}

.sidebar-content {
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* 右侧主区域 */
.main-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    /* 点状背景纹理 */
    background-image: radial-gradient(#e2e8f0 1px, transparent 1px);
    background-size: 24px 24px;
    min-width: 0;
}

/* ================= 3. Sidebar 组件样式 ================= */
.badge-btn {
    font-size: 0.75rem;
    padding: 4px 10px;
    border-radius: 20px;
    background-color: #fff;
    color: #64748b;
    border: 1px solid #e2e8f0;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 5px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
}

.badge-btn:hover {
    background-color: #f1f5f9;
    border-color: #cbd5e1;
    color: var(--text-dark);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.border-bottom-dashed {
    border-bottom: 1px dashed #f1f5f9;
}

.small-text {
    font-size: 0.85rem;
}

.hover-bg:hover {
    background-color: #f8fafc;
}

.cursor-pointer {
    cursor: pointer;
}

/* ================= 3.1 文件列表布局 ================= */
.file-list-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.file-list-menu {
    flex-shrink: 0;
}

.file-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    border-bottom: 1px solid var(--border-color);
}

.file-section:last-child {
    border-bottom: none;
}

.file-section-header {
    flex-shrink: 0;
    padding: 6px 8px;
    background: #f8fafc;
    color: #64748b;
    font-size: 0.8rem;
    font-weight: 600;
    border-bottom: 1px solid var(--border-color);
}

.file-section-list {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

/* ================= 3.2 历史记录列表布局 ================= */
.history-list-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.history-list-menu {
    flex-shrink: 0;
    padding: 8px;
    background: #fff;
    border-bottom: 1px solid var(--border-color);
}

.history-list-content {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    background: #fafafa;
}

/* 历史记录项样式 */
.history-item {
    cursor: pointer;
    transition: all 0.15s ease;
    background: transparent;
}

.history-item:hover {
    background-color: #f1f5f9;
}

.history-item.active {
    background-color: #fff;
    border-left: 3px solid var(--primary) !important;
}

/* 标题容器 - 渐变淡出效果 */
.history-title-wrapper {
    position: relative;
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.history-title-text {
    display: flex;
    align-items: center;
    white-space: nowrap;
    font-weight: 600;
    font-size: 0.85rem;
    /* 使用 mask 实现右侧渐变淡出 */
    -webkit-mask-image: linear-gradient(to right, black 70%, transparent 100%);
    mask-image: linear-gradient(to right, black 70%, transparent 100%);
    padding-right: 20px;
}

/* 悬停时调整渐变，给按钮留更多空间 */
.history-item:hover .history-title-text {
    -webkit-mask-image: linear-gradient(to right, black 50%, transparent 85%);
    mask-image: linear-gradient(to right, black 50%, transparent 85%);
}

/* 操作按钮默认隐藏，悬停时显示 */
.history-item-actions {
    opacity: 0;
    transition: opacity 0.15s ease;
    flex-shrink: 0;
    position: relative;
    z-index: 1;
}

.history-item:hover .history-item-actions {
    opacity: 1;
}

.history-item-actions .btn {
    min-width: 20px;
    min-height: 20px;
}

.history-item-actions .btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* 编辑模式下输入框样式 */
.history-item input.form-control {
    font-size: 0.85rem;
    padding: 2px 8px;
    height: 26px;
}

/* ================= 4. 聊天区域 (Chat History) ================= */
.chat-history {
    flex: 1;
    overflow-y: auto;
    padding: 2rem 3rem;
    /* 两侧留白更多 */
    padding-bottom: 160px;
    /* 给底部悬浮输入框留空间 */
    scroll-behavior: smooth;
}

/* 消息行 */
.msg-row {
    display: flex;
    gap: 16px;
    margin-bottom: 2rem;
    opacity: 0;
    animation: slideUp 0.3s ease-out forwards;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.msg-user-row {
    flex-direction: row-reverse;
}

/* 头像 */
.msg-avatar .avatar {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.user-avatar {
    background-color: var(--text-dark);
    color: white;
    border-radius: 50%;
}

.ai-avatar {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
}

/* 消息内容容器 */
.msg-content-wrapper {
    max-width: 80%;
    min-width: 300px;
    display: flex;
    flex-direction: column;
}

/* AI 回复区域宽度最大化 */
.msg-ai-row .msg-content-wrapper {
    max-width: calc(100% - 60px);
    /* 减去头像和间距 */
    flex: 1;
}

.msg-user-row .msg-content-wrapper {
    align-items: flex-end;
}

/* 用户气泡 */
.user-bubble {
    background-color: var(--text-dark);
    color: #fff;
    padding: 12px 20px;
    border-radius: 20px 20px 4px 20px;
    /* 左下角尖角 */
    font-size: 0.95rem;
    line-height: 1.6;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    /* white-space: pre-wrap; 移除此行，由内部 pre 标签处理 */
    word-break: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
}

/* 用户输入内容 pre 样式 */
.cell-pre-wrap {
    max-width: 100%;
    overflow: hidden;
}

.cell-pre {
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: break-word;
    margin: 0;
    font-family: inherit;
    font-size: inherit;
    background: transparent;
    color: inherit;
}

.cell-pre code {
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: break-word;
    font-family: inherit;
    background: transparent;
}

.msg-meta {
    font-size: 0.75rem;
    color: #94a3b8;
    margin-top: 6px;
    margin-right: 4px;
}

/* AI 气泡 (Notebook Style) */
.ai-bubble {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    width: 100%;
    overflow: hidden;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.ai-toolbar {
    background: #fafafa;
    padding: 8px 16px;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.btn-xs {
    padding: 2px 8px;
    font-size: 0.75rem;
    border-radius: 4px;
    border: none;
    cursor: pointer;
}

.btn-ghost {
    background: transparent;
    color: var(--secondary);
}

.btn-ghost:hover {
    background: #eff6ff;
    color: var(--primary);
}

/* ================= 5. 时间轴与代码块 (Timeline) ================= */
.timeline-box {
    padding: 16px;
    width: 100%;
}

.timeline-list {
    display: flex;
    flex-direction: column;
    width: 100%;
}

.timeline-item {
    position: relative;
    padding-left: 32px;
    padding-bottom: 24px;
    width: 100%;
}

.timeline-item details {
    width: 100%;
}

/* 连接线 */
.timeline-item::before {
    content: '';
    position: absolute;
    left: 10px;
    top: 26px;
    bottom: 0;
    width: 2px;
    background-color: #f1f5f9;
}

.timeline-item:last-child {
    padding-bottom: 0;
}

.timeline-item:last-child::before {
    display: none;
}

/* 图标圆点 */
.timeline-icon {
    position: absolute;
    left: 0;
    top: 2px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    z-index: 2;
    box-shadow: 0 0 0 1px #e2e8f0;
}

/* 状态颜色适配 */
.status-done .timeline-icon {
    background: var(--success-bg);
    color: var(--success-text);
    box-shadow: none;
}

.status-process .timeline-icon {
    background: var(--process-bg);
    color: var(--process-text);
    box-shadow: none;
}

.status-error .timeline-icon {
    background: var(--error-bg);
    color: var(--error-text);
    box-shadow: none;
}

/* 折叠组件 Details/Summary */
summary {
    list-style: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    user-select: none;
}

.tl-title {
    font-weight: 600;
    font-size: 0.9rem;
    color: #334155;
}

.tl-time {
    font-size: 0.75rem;
    color: #94a3b8;
    font-family: monospace;
}

.toggle-icon {
    font-size: 12px;
    color: #cbd5e1;
    transition: transform 0.2s;
}

details[open] .toggle-icon {
    transform: rotate(180deg);
}

/* 内容面板 */
.detail-panel {
    margin-top: 10px;
    width: 100%;
}

/* 代码块美化 */
.code-block-wrapper {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 12px;
}

.code-header {
    background: #f8fafc;
    padding: 6px 12px;
    font-size: 0.75rem;
    color: #64748b;
    font-family: monospace;
    font-weight: bold;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
}

.code-body {
    background: #1e1e1e;
    color: #d4d4d4;
    padding: 12px;
    font-family: 'Menlo', 'Consolas', monospace;
    font-size: 0.85rem;
    overflow-x: auto;
    white-space: pre-wrap;
}

.markdown-body {
    font-size: 0.95rem;
    line-height: 1.6;
    color: #334155;
    width: 100%;
}

/* Markdown 表格响应式 */
.markdown-body table {
    width: 100%;
    max-width: 100%;
    border-collapse: collapse;
    margin: 15px 0;
    table-layout: auto;
}

.markdown-body th,
.markdown-body td {
    padding: 10px 14px;
    border: 1px solid #e2e8f0;
    text-align: left;
    white-space: normal;
    word-break: break-word;
}

.markdown-body th {
    background: #f8fafc;
    font-weight: 600;
}

.markdown-body tr:nth-child(even) {
    background: #fafafa;
}

/* 表格容器，支持横向滚动 */
.markdown-body .table-wrapper {
    width: 100%;
    overflow-x: auto;
}

.echart-box {
    width: 100%;
    min-height: 350px;
    height: auto;
    aspect-ratio: 16 / 9;
    /* 保持宽高比 */
    max-height: 500px;
}

/* 思考中动画点 */
.spinner-dot {
    width: 8px;
    height: 8px;
    background-color: currentColor;
    border-radius: 50%;
    animation: pulse 1s infinite ease-in-out;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 0.5;
        transform: scale(0.9);
    }

    50% {
        opacity: 1;
        transform: scale(1.1);
    }
}

.thinking-text {
    font-size: 0.85rem;
    color: var(--secondary);
    font-style: italic;
    margin-top: 2px;
}

/* 思考中指示器样式 */
.thinking-indicator {
    display: flex;
    align-items: center;
}

.thinking-content {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-radius: 20px;
    border: 1px solid #e2e8f0;
}

.thinking-dots {
    display: flex;
    gap: 4px;
}

.thinking-dots span {
    width: 6px;
    height: 6px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border-radius: 50%;
    animation: thinkingBounce 1.4s ease-in-out infinite;
}

.thinking-dots span:nth-child(1) {
    animation-delay: 0s;
}

.thinking-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.thinking-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes thinkingBounce {

    0%,
    60%,
    100% {
        transform: translateY(0);
        opacity: 0.5;
    }

    30% {
        transform: translateY(-6px);
        opacity: 1;
    }
}

.thinking-content .thinking-text {
    font-size: 0.85rem;
    color: #64748b;
    font-style: normal;
    font-weight: 500;
    margin-top: 0;
}

/* 思考中带中断按钮的容器 */
.thinking-content-with-stop {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* 内联中断按钮 */
.btn-stop-inline {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 16px;
    border: none;
    background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
    color: #dc2626;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(220, 38, 38, 0.1);
}

.btn-stop-inline:hover {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    box-shadow: 0 4px 8px rgba(220, 38, 38, 0.2);
    transform: translateY(-1px);
}

.btn-stop-inline:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(220, 38, 38, 0.1);
}

.btn-stop-inline i {
    font-size: 12px;
}

/* 中断状态样式 */
.status-cancelled .timeline-icon {
    background: #fef2f2;
    color: #dc2626;
    box-shadow: none;
}

.cancelled-content {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
    border-radius: 20px;
    border: 1px solid #fecaca;
    color: #dc2626;
}

.cancelled-content i {
    font-size: 14px;
}

.cancelled-text {
    font-size: 0.85rem;
    font-weight: 500;
}

/* ================= 6. 底部悬浮输入框 (Glassmorphism) ================= */
.input-container-float {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 50;
    padding: 24px 40px;
    /* 背景渐变，让聊天内容在底部逐渐淡出 */
    background: linear-gradient(to top, rgba(248, 250, 252, 1) 40%, rgba(248, 250, 252, 0) 100%);
    pointer-events: none;
    /* 让渐变层不阻挡点击，子元素单独开启 pointer-events */
}

.input-box-glass {
    pointer-events: auto;
    /* 恢复交互 */
    position: relative;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: 24px;
    /* 更圆润 */
    box-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.08), 0 4px 10px -5px rgba(0, 0, 0, 0.04);
    padding: 10px;
    display: flex;
    align-items: flex-end;
    gap: 10px;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    max-width: 900px;
    margin: 0 auto;
    /* 居中 */
}

.input-box-glass:focus-within {
    box-shadow: 0 20px 40px -5px rgba(79, 70, 229, 0.15);
    /* 聚焦时淡淡的蓝紫色阴影 */
    border-color: rgba(79, 70, 229, 0.3);
    transform: translateY(-2px);
}

/* ================= 8. 用户账号头像圆点模式 ================= */
.account-panel {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--bg-sidebar);
}

.account-avatar-container {
    position: relative;
    width: 42px;
    height: 42px;
}

.avatar-circle {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.avatar-circle:hover {
    transform: scale(1.1);
}

.avatar-circle.guest {
    background: #e2e8f0;
    color: #64748b;
}

/* 悬浮弹窗 */
.account-popover {
    position: absolute;
    top: 50px;
    /* 头像下方 + 间距 */
    left: 0;
    width: 240px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: 16px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    padding: 16px;
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px) scale(0.95);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
    /* 默认不接受点击，防止误触 */
}

/* 透明桥接区域，连接头像和弹窗，防止hover时鼠标经过间隙导致弹窗消失 */
.account-popover::before {
    content: '';
    position: absolute;
    top: -15px;
    /* 向上延伸覆盖间隙 */
    left: 0;
    width: 100%;
    height: 20px;
    /* 覆盖头像和弹窗之间的间隙 */
    background: transparent;
}

/* 悬停在容器上时显示弹窗 */
.account-avatar-container:hover .account-popover {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.popover-header {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 12px;
}

.popover-name {
    font-weight: 700;
    font-size: 1rem;
    color: var(--text-dark);
}

.popover-role {
    font-size: 0.75rem;
    color: var(--secondary);
    background: #f1f5f9;
    padding: 2px 8px;
    border-radius: 10px;
    align-self: flex-start;
}

.popover-usage {
    margin-bottom: 16px;
}

.popover-usage-text {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--secondary);
    margin-bottom: 6px;
}

.popover-usage-bar {
    height: 6px;
    background: #e2e8f0;
    border-radius: 3px;
    overflow: hidden;
}

.popover-usage-progress {
    height: 100%;
    background: var(--primary);
    border-radius: 3px;
    transition: width 0.3s ease;
}

.popover-usage-progress.warning {
    background: #f59e0b;
}

.popover-usage-progress.danger {
    background: #ef4444;
}

.popover-lang {
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid #e2e8f0;
}

.popover-lang-label {
    font-size: 0.8rem;
    color: #64748b;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
}

.popover-lang-options {
    display: flex;
    gap: 6px;
}

.lang-btn {
    flex: 1;
    padding: 4px 8px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    background: #f8fafc;
    color: #475569;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.lang-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(99, 102, 241, 0.05);
}

.lang-btn.active {
    border-color: var(--primary);
    background: var(--primary);
    color: white;
}

.popover-actions .btn-login,
.popover-actions .btn-logout {
    width: 100%;
    padding: 8px 0;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
}

.popover-actions .btn-login {
    background: var(--primary);
    color: white;
}

.popover-actions .btn-login:hover {
    background: var(--primary-hover);
}

.popover-actions .btn-logout {
    background: #fee2e2;
    color: #991b1b;
}

.popover-actions .btn-logout:hover {
    background: #fecaca;
}

.rich-input {
    flex: 1;
    min-height: 44px;
    max-height: 180px;
    padding: 10px 14px;
    outline: none;
    font-size: 1rem;
    color: var(--text-dark);
    line-height: 1.5;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: break-word;
}

.rich-input:empty:before {
    content: attr(placeholder);
    color: #94a3b8;
}

.btn-send {
    width: 40px;
    height: 40px;
    border-radius: 14px;
    border: none;
    background: var(--text-dark);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 2px;
    flex-shrink: 0;
}

.btn-send:hover {
    background: var(--primary);
    transform: scale(1.05);
}

.btn-send:active {
    transform: scale(0.95);
}

.input-footer {
    display: flex;
    justify-content: center;
    align-items: center;
    color: #94a3b8;
    font-size: 0.75rem;
    margin-top: 8px;
    pointer-events: auto;
    position: relative;
}

.input-footer .version-info {
    color: #b0b8c4;
    font-size: 0.7rem;
    margin-left: 10px;
    opacity: 0.8;
}

/* 空状态提示 */
.empty-state {
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
    opacity: 0.6;
}

.empty-state .icon-box {
    font-size: 4rem;
    margin-bottom: 1rem;
    color: #cbd5e1;
}

/* ================= 7. 文件拖放上传 ================= */
.file-list-container {
    position: relative;
}

.file-list-container.drag-over {
    background-color: rgba(79, 70, 229, 0.05);
}

/* 拖放遮罩层 */
.drop-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(79, 70, 229, 0.15);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 3px dashed var(--primary);
    border-radius: 8px;
    margin: 8px;
    animation: dropPulse 1.5s ease-in-out infinite;
}

@keyframes dropPulse {

    0%,
    100% {
        background: rgba(79, 70, 229, 0.1);
        border-color: rgba(79, 70, 229, 0.6);
    }

    50% {
        background: rgba(79, 70, 229, 0.2);
        border-color: var(--primary);
    }
}

.drop-overlay-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    color: var(--primary);
    text-align: center;
}

.drop-overlay-content i {
    font-size: 3rem;
    animation: bounceUp 0.6s ease-in-out infinite alternate;
}

@keyframes bounceUp {
    from {
        transform: translateY(0);
    }

    to {
        transform: translateY(-8px);
    }
}

.drop-overlay-content span {
    font-size: 1rem;
    font-weight: 600;
}

.drop-overlay-content small {
    font-size: 0.75rem;
    opacity: 0.8;
}

/* 拖放提示区域 */
.drop-hint {
    background: #fafafa;
}

.drop-hint-box {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 12px;
    background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
    border: 2px dashed #cbd5e1;
    border-radius: 8px;
    color: #64748b;
    font-size: 0.8rem;
    transition: all 0.2s ease;
    cursor: pointer;
}

.drop-hint-box:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
}

.drop-hint-box i {
    font-size: 1rem;
}

/* ================= 8. 文件列表项和删除按钮 ================= */
.file-item {
    transition: all 0.15s ease;
}

.file-item:hover {
    background-color: #f8fafc;
}

.file-item-content {
    min-width: 0;
}

/* 删除按钮 - 默认隐藏 */
.file-delete-btn {
    opacity: 0;
    padding: 2px 6px;
    color: #94a3b8;
    background: transparent;
    border: none;
    border-radius: 4px;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.file-item:hover .file-delete-btn {
    opacity: 1;
}

.file-delete-btn:hover {
    color: #ef4444;
    background: #fee2e2;
    transform: scale(1.1);
}

.file-delete-btn:active {
    transform: scale(0.95);
}


/* ================= 8. 图表工具栏 ================= */
.chart-wrapper {
    position: relative;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
}

.chart-toolbar {
    display: flex;
    justify-content: flex-end;
    padding: 8px 12px;
    background: #f8fafc;
    border-bottom: 1px solid var(--border-color);
    gap: 8px;
}

.chart-toolbar .btn {
    font-size: 0.8rem;
    padding: 4px 12px;
    border-radius: 6px;
    transition: all 0.2s;
}

.chart-toolbar .btn:hover:not(:disabled) {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.chart-toolbar .btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ================= 9. PPT 预览样式（轮播图模式） ================= */
.ppt-wrapper {
    position: relative;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    background: #f8fafc;
    margin-top: 10px;
}

.ppt-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: #fff;
    border-bottom: 1px solid var(--border-color);
}

.ppt-title {
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--text-color);
}

.ppt-preview-box {
    padding: 20px;
    background: #e5e7eb;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 300px;
}

.ppt-carousel {
    position: relative;
    width: 100%;
    max-width: 800px;
    /* 限制最大宽度 */
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.ppt-slide-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    /* 保持 16:9 比例 */
    background: #fff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border-radius: 4px;
    overflow: hidden;
}

.ppt-slide {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
}

.ppt-slide-inner {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
}

.ppt-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(0, 0, 0, 0.1);
    color: #333;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    transition: all 0.2s;
    outline: none;
}

.ppt-nav-btn:hover:not(:disabled) {
    background: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    color: var(--primary);
}

.ppt-nav-btn:disabled {
    opacity: 0.3;
    cursor: default;
}

.ppt-prev {
    left: -50px;
}

.ppt-next {
    right: -50px;
}

/* 当屏幕较窄时，导航按钮放到图片内部 */
@media (max-width: 900px) {
    .ppt-prev {
        left: 10px;
        background: rgba(255, 255, 255, 0.5);
    }

    .ppt-next {
        right: 10px;
        background: rgba(255, 255, 255, 0.5);
    }
}

.ppt-pagination {
    display: flex;
    gap: 6px;
    justify-content: center;
    margin-top: 10px;
    flex-wrap: wrap;
}

.ppt-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #cbd5e1;
    cursor: pointer;
    transition: all 0.2s;
}

.ppt-dot.active {
    background: var(--primary);
    transform: scale(1.2);
}

.ppt-info {
    font-size: 0.85rem;
    color: #64748b;
    margin-top: 4px;
}

.ppt-empty {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
}

/* ================= 10. 账号面板样式 ================= */
.account-panel {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
}

.account-user {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.account-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.account-avatar.guest {
    background: linear-gradient(135deg, #94a3b8, #64748b);
}

.account-info {
    flex: 1;
    min-width: 0;
}

.account-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.account-role {
    font-size: 0.75rem;
    color: #64748b;
}

.usage-bar {
    margin-bottom: 12px;
}

.usage-text {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: #64748b;
    margin-bottom: 6px;
}

.usage-count {
    font-weight: 600;
    color: var(--primary);
}

.usage-count.warning {
    color: #f59e0b;
}

.usage-count.danger {
    color: #ef4444;
}

.usage-progress {
    height: 6px;
    background: #e2e8f0;
    border-radius: 3px;
    overflow: hidden;
}

.usage-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), #8b5cf6);
    transition: width 0.3s ease;
    border-radius: 3px;
}

.usage-progress-bar.warning {
    background: linear-gradient(90deg, #f59e0b, #fbbf24);
}

.usage-progress-bar.danger {
    background: linear-gradient(90deg, #ef4444, #f87171);
}

.account-actions {
    display: flex;
    gap: 8px;
}

.btn-account {
    flex: 1;
    padding: 8px 12px;
    border: none;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-login {
    background: var(--primary);
    color: white;
}

.btn-login:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.btn-logout {
    background: #f1f5f9;
    color: #64748b;
    border: 1px solid #e2e8f0;
}

.btn-logout:hover {
    background: #e2e8f0;
    color: var(--text-dark);
}

/* ================= 11. 登录弹窗样式 ================= */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.modal-content {
    background: white;
    border-radius: 16px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease;
    overflow: hidden;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-dark);
}

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: #f1f5f9;
    border-radius: 8px;
    color: #64748b;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.modal-close:hover {
    background: #e2e8f0;
    color: var(--text-dark);
}

.modal-body {
    padding: 24px;
}

.modal-body .form-group {
    margin-bottom: 16px;
}

.modal-body .form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    color: #334155;
}

.modal-body .form-control {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    font-size: 0.95rem;
    transition: all 0.2s;
    background: #f8fafc;
}

.modal-body .form-control:focus {
    outline: none;
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.modal-body .alert {
    padding: 12px 14px;
    border-radius: 10px;
    margin-bottom: 16px;
    font-size: 0.875rem;
}

.modal-body .alert-danger {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #dc2626;
}

.modal-footer {
    padding: 0 24px 24px;
}

.modal-footer .btn {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.modal-footer .btn-primary {
    background: linear-gradient(135deg, var(--primary), #8b5cf6);
    color: white;
}

.modal-footer .btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.modal-footer .btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.modal-footer .btn-secondary {
    background: #f1f5f9;
    color: #64748b;
    margin-top: 8px;
}

.modal-footer .btn-secondary:hover {
    background: #e2e8f0;
    color: var(--text-dark);
}

.modal-switch {
    text-align: center;
    margin-top: 16px;
    font-size: 0.875rem;
    color: #64748b;
}

.modal-switch a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.modal-switch a:hover {
    text-decoration: underline;
}

/* ================= 12. 使用限制弹窗 ================= */
.limit-modal {
    max-width: 360px;
}

.limit-info {
    background: #f8fafc;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
}

.limit-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px dashed #e2e8f0;
}

.limit-row:last-child {
    border-bottom: none;
}

.limit-row.highlight {
    background: linear-gradient(90deg, rgba(99, 102, 241, 0.1), rgba(139, 92, 246, 0.1));
    border-radius: 8px;
    padding: 12px;
    margin: 0 -8px;
}

.limit-label {
    color: #64748b;
    font-size: 0.9rem;
}

.limit-value {
    font-weight: 600;
    color: var(--text-dark);
}

.limit-row.highlight .limit-value {
    color: var(--primary);
}

.limit-tip {
    text-align: center;
    color: #64748b;
    font-size: 0.875rem;
    margin: 0;
}

/* ================= 13. 聊天项删除按钮样式 ================= */

/* 超小按钮 */
.btn-xs {
    padding: 2px 6px;
    font-size: 0.75rem;
    line-height: 1.4;
    border-radius: 4px;
}

/* 幽灵按钮（透明背景） */
.btn-ghost {
    background: transparent;
    border: none;
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-ghost:hover {
    background: rgba(0, 0, 0, 0.05);
}

.btn-ghost.text-danger:hover {
    background: #fee2e2;
    color: #dc2626 !important;
}

.btn-ghost.text-primary:hover {
    background: #eff6ff;
    color: #4338ca !important;
}

/* 用户气泡 - 更紧凑与现代风格 */
.user-bubble {
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    color: #fff;
    padding: 10px 16px;
    border-radius: 18px 18px 4px 18px;
    font-size: 0.95rem;
    line-height: 1.5;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.25);
    word-break: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
    position: relative;
    transition: transform 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.user-bubble:hover {
    transform: translateY(-1px);
}

/* AI 气泡 - 玻璃拟态风格 */
.ai-bubble {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(226, 232, 240, 0.6);
    padding: 12px 16px;
    border-radius: 4px 18px 18px 18px;
    font-size: 0.95rem;
    line-height: 1.5;
    box-shadow: 0 4px 20px -5px rgba(0, 0, 0, 0.05);
    word-break: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
    position: relative;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.ai-bubble:hover {
    box-shadow: 0 8px 30px -5px rgba(0, 0, 0, 0.08);
    transform: translateY(-1px);
}

/* 用户气泡工具栏 - 悬浮在右上角 */
.user-bubble .bubble-toolbar {
    position: absolute;
    top: -8px;
    right: -8px;
    opacity: 0;
    transition: all 0.2s ease;
    z-index: 10;
    transform: scale(0.8);
}

.user-bubble:hover .bubble-toolbar {
    opacity: 1;
    transform: scale(1);
}

.user-bubble .bubble-toolbar .btn {
    width: 20px;
    height: 20px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #fff;
    color: #ef4444;
    /* 红色图标 */
    border: 1px solid #e2e8f0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    cursor: pointer;
}

.user-bubble .bubble-toolbar .btn:hover {
    background: #fee2e2;
    transform: scale(1.1);
}

/* AI 气泡工具栏增强 */
.ai-toolbar {
    display: flex;
    align-items: center;
}

.ai-toolbar .toolbar-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* 时间轴项的 header-actions */
.timeline-item summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.timeline-item .header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.timeline-item .header-actions .delete-btn {
    opacity: 0;
    transition: opacity 0.15s ease;
}

.timeline-item:hover .header-actions .delete-btn {
    opacity: 1;
}

.timeline-item .header-actions .delete-btn:hover {
    background: #fee2e2;
    color: #dc2626;
}

/* 删除按钮通用样式 */
.delete-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 8px;
    font-size: 0.8rem;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.delete-btn i {
    font-size: 0.85rem;
}



/* ================= 9. 侧边栏头部重构 (Avatar + Tabs) ================= */
.sidebar-header {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--bg-sidebar);
    gap: 16px;
    flex-shrink: 0;
}

/* 重置 AccountPanel 内边距，因为它现在在 sidebar-header 内部 */
.sidebar-header .account-panel {
    padding: 0;
    border-bottom: none;
    background: transparent;
    flex-shrink: 0;
}

/* 导航 Tab 样式 */
.sidebar-tabs-nav {
    display: flex;
    align-items: center;
    flex: 1;
    background: #f1f5f9;
    border-radius: 8px;
    padding: 3px;
    gap: 2px;
}

.tab-item {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 34px;
    cursor: pointer;
    border-radius: 6px;
    color: #64748b;
    transition: all 0.2s ease;
    font-size: 1.1rem;
}

.tab-item:hover {
    color: var(--text-dark);
    background: rgba(255, 255, 255, 0.5);
}

.tab-item.active {
    background: #fff;
    color: var(--primary);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* ================= 删除确认弹窗 ================= */
.delete-confirm-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

.delete-confirm-dialog {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 16px;
    padding: 24px 28px;
    min-width: 280px;
    max-width: 320px;
    text-align: center;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
    animation: slideUp 0.25s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.delete-confirm-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 16px;
    background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.delete-confirm-icon i {
    font-size: 24px;
    color: #dc2626;
}

.delete-confirm-title {
    margin: 0 0 8px 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-dark);
}

.delete-confirm-text {
    margin: 0 0 20px 0;
    font-size: 0.9rem;
    color: var(--secondary);
    line-height: 1.5;
}

.delete-confirm-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.btn-confirm-cancel,
.btn-confirm-delete {
    flex: 1;
    padding: 10px 16px;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-confirm-cancel {
    background: #f1f5f9;
    color: var(--secondary);
}

.btn-confirm-cancel:hover {
    background: #e2e8f0;
    color: var(--text-dark);
}

.btn-confirm-delete {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(220, 38, 38, 0.3);
}

.btn-confirm-delete:hover {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.4);
    transform: translateY(-1px);
}

.btn-confirm-delete:active {
    transform: translateY(0);
}

/* ================= 10. 移动端自适应 (Max Width 768px) ================= */
@media (max-width: 768px) {

    /* 主布局不再是左右平级，而是叠放 */
    .layout-container {
        flex-direction: column;
        height: calc(var(--vh, 1vh) * 100);
        width: 100vw;
        overflow: hidden;
    }

    /* 移动端隐藏侧边栏的桌面 Tab区域及整个占位头部 */
    .sidebar-header {
        display: none !important;
    }

    /* 默认隐藏侧边栏的桌面 Tab (作预防性收底) */
    .sidebar-tabs-nav {
        display: none !important;
    }

    /* 移动端隐藏数据板块的无关操作钮 */
    .file-list-menu .dir-shortcuts,
    .file-list-menu .drop-hint {
        display: none !important;
    }

    /* 根据当前视图模式显示或隐藏区域 */
    .mobile-view-chat .sidebar-panel {
        display: none;
    }

    .mobile-view-sidebar .main-panel {
        display: none;
    }

    /* 调整在移动端显示的面板铺满剩余空间 */
    .mobile-view-chat .main-panel,
    .mobile-view-sidebar .sidebar-panel {
        flex: 1;
        width: 100%;
        min-width: 100%;
        height: calc((var(--vh, 1vh) * 100) - 60px - var(--safe-bottom) - var(--safe-top));
        /* 留出底部导航栏的空间 并考虑刘海和底部按键 */
    }

    /* 缩小左右 padding 留出空间 */
    .chat-history {
        padding: 1rem 0.5rem 120px 0.5rem;
    }

    /* 底部悬浮输入框提升高度，避免被底部导航栏遮挡 */
    .input-container-float {
        bottom: calc(80px + var(--safe-bottom));
        /* 导航栏高度之上加上底部安全区 */
        padding: 10px;
        transition: bottom 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    }

    /* 键盘弹起时的处理 (通过JS赋予body.keyboard-open类) */
    body.keyboard-open .mobile-bottom-nav {
        display: none !important;
    }

    body.keyboard-open .input-container-float {
        bottom: 10px !important;
    }

    body.keyboard-open .chat-history {
        padding-bottom: 80px !important;
    }

    /* 移动端底部导航栏显示 - 悬浮胶囊风 */
    .mobile-bottom-nav {
        display: flex;
        flex-shrink: 0;
        height: 60px;
        background: rgba(255, 255, 255, 0.85);
        backdrop-filter: blur(16px);
        -webkit-backdrop-filter: blur(16px);
        border: 1px solid rgba(226, 232, 240, 0.6);
        box-shadow: 0 8px 32px rgba(31, 38, 135, 0.1);
        z-index: 100;
        position: fixed;
        bottom: calc(16px + var(--safe-bottom));
        left: 16px;
        right: 16px;
        border-radius: 30px;
        padding: 0 10px;
    }

    .mob-nav-item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        color: #94a3b8;
        cursor: pointer;
        transition: all 0.25s cubic-bezier(0.25, 0.8, 0.25, 1);
        gap: 4px;
        user-select: none;
        position: relative;
    }

    .mob-nav-item i {
        font-size: 1.25rem;
        transition: transform 0.2s;
    }

    .mob-nav-item span {
        font-size: 0.7rem;
        font-weight: 500;
    }

    .mob-nav-item.active {
        color: var(--primary);
    }

    .mob-nav-item.active i {
        transform: translateY(-2px);
    }

    /* 隐藏侧边栏的头像面板，放入底栏中间 */
    .sidebar-panel .account-panel {
        display: none !important;
    }

    /* 底部居中头像样式 */
    .mob-nav-account {
        flex: 1.2;
        /* 稍微给一点多余宽度 */
    }

    .mob-nav-account .account-panel {
        padding: 0;
        border: none;
        background: transparent;
        display: flex;
        justify-content: center;
        align-items: center;
    }

    .mob-nav-account .account-avatar-container {
        width: 50px;
        height: 50px;
        margin-top: -30px;
        /* 让头像浮出导航栏 */
        border-radius: 50%;
        box-shadow: 0 8px 16px rgba(99, 102, 241, 0.3) !important;
        background: white;
        z-index: 105;
        border: 3px solid white;
    }

    .mob-nav-account .avatar-circle {
        box-shadow: none !important;
    }

    .mob-nav-account .account-popover {
        top: auto !important;
        bottom: 65px !important;
        left: 50% !important;
        transform: translateX(-50%) translateY(15px) scale(0.95) !important;
        transform-origin: bottom center;
    }

    .mob-nav-account .account-avatar-container:hover .account-popover {
        transform: translateX(-50%) translateY(0) scale(1) !important;
    }


    /* 移动端全屏账号页面 */
    .mobile-account-page {
        display: flex;
        flex-direction: column;
        gap: 24px;
        height: 100%;
        padding: 20px !important;
    }

    .mobile-account-page .popover-header {
        margin-bottom: 0;
        padding-bottom: 16px;
        border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    }

    .mobile-account-page .popover-actions {
        margin-top: auto;
        padding-bottom: 30px;
    }

    /* 对话气泡占据更多宽度 */
    .msg-content-wrapper {
        max-width: 90%;
        min-width: 0;
    }
}

/* 桌面端隐藏底部导航栏 */
@media (min-width: 769px) {
    .mobile-bottom-nav {
        display: none;
    }
}

/* ================= 11. 聊天输入框 @ 文件提及菜单 ================= */
.mention-popover-container {
    position: absolute;
    display: none;
    z-index: 9999;
    max-height: 250px;
    overflow-y: auto;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1), 0 1px 10px rgba(0, 0, 0, 0.05);
    border-radius: 12px;
    padding: 8px 0;
    min-width: 240px;
    line-height: 1.5;
    /* transition element when appearing */
    animation: popIn 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.mention-item {
    display: flex;
    align-items: center;
    padding: 8px 16px;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
    text-decoration: none;
    color: var(--text-dark);
    font-size: 0.95rem;
}

.mention-item:hover,
.mention-item.active {
    background-color: rgba(99, 102, 241, 0.1);
    /* Primary color low opacity */
    color: var(--primary);
}

.mention-item-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    margin-right: 12px;
    font-size: 1.1rem;
}

.mention-item-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-grow: 1;
}

@keyframes popIn {
    0% {
        opacity: 0;
        transform: translateY(10px) scale(0.95);
    }

    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* @ 菜单移动端特殊适配 */
.mention-popover-container.mobile-mode {
    position: fixed !important;
    width: auto !important;
    min-width: 0 !important;
    max-height: 35vh !important;
    /* Limit height to 35% of view height to leave room for content */
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 -5px 25px rgba(0, 0, 0, 0.15);
    animation: slideUp 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.mention-popover-container.mobile-mode .mention-item {
    padding: 12px 16px;
    /* 更大的触控区域 */
    font-size: 1rem;
}

@keyframes slideUp {
    0% {
        opacity: 0;
        transform: translateY(20px);
    }

    100% {
        opacity: 1;
        transform: translateY(0);
    }
}