/* 全局重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: system-ui, -apple-system, sans-serif;
}
body {
    display: flex;
    height: 100vh;
    overflow: hidden;
    transition: background 0.3s, color 0.3s;
}




/* ========== 亮色主题 ========== */
body.light {
    background: #fff;
    color: #222;
}
body.light .sidebar {
    background: #f7f8fa;
    border-right: 1px solid #e5e7eb;
}
body.light .chat-wrap {
    background: #ffffff;
}
body.light .msg-user {
    background: #1677ff;
    color: white;
}
body.light .msg-ai {
    background: #f0f2f5;
    color: #222;
}
body.light .modal-box {
    background: #fff;
}
body.light pre code {
    background: #f2f3f5;
}
body.light .code-copy-btn {
    background: #e4e6eb;
    color: #333;
}

/* ========== 深色主题 ========== */
body.dark {
    background: #17171a;
    color: #e5e7eb;
}
body.dark .sidebar {
    background: #1e1e24;
    border-right: 1px solid #2d2d34;
}
body.dark .chat-wrap {
    background: #17171a;
}
body.dark .msg-user {
    background: #2563eb;
    color: #fff;
}
body.dark .msg-ai {
    background: #27272f;
    color: #e5e7eb;
}
body.dark .modal-box {
    background: #1e1e24;
}
body.dark pre code {
    background: #111;
}
body.dark .code-copy-btn {
    background: #3a3a48;
    color: #eee;
}


s
/* ========== 滚动条全局统一美化（分离webkit/Firefox，解决冲突） ========== */
/* 1. Webkit内核 Chrome/Edge 专用 单独容器高权重选择器，覆盖原有样式 */
.sidebar-top::-webkit-scrollbar,
.chat-wrap::-webkit-scrollbar,
.sidebar-right-content::-webkit-scrollbar,
.modal-box::-webkit-scrollbar,
.msg-ai pre::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
.sidebar-top::-webkit-scrollbar-track,
.chat-wrap::-webkit-scrollbar-track,
.sidebar-right-content::-webkit-scrollbar-track,
.modal-box::-webkit-scrollbar {
  border-radius: 3px;
}
.sidebar-top::-webkit-scrollbar-thumb,
.chat-wrap::-webkit-scrollbar-thumb,
.sidebar-right-content::-webkit-scrollbar-thumb,
.modal-box::-webkit-scrollbar-thumb {
  border-radius: 3px;
  cursor: pointer;
  transition: background 0.2s ease;
}
/* 代码块横向滚动条单独缩小 */
.msg-ai pre::-webkit-scrollbar {
  height: 4px;
}

/* 亮色主题滚动配色 */
body.light .sidebar-top::-webkit-scrollbar-track,
body.light .chat-wrap::-webkit-scrollbar-track,
body.light .sidebar-right-content::-webkit-scrollbar-track,
body.light .modal-box::-webkit-scrollbar-track {
  background: #eef0f3;
}
body.light .sidebar-top::-webkit-scrollbar-thumb,
body.light .chat-wrap::-webkit-scrollbar-thumb,
body.light .sidebar-right-content::-webkit-scrollbar-thumb,
body.light .modal-box::-webkit-scrollbar-thumb {
  background: #c0c4cc;
}
body.light .sidebar-top::-webkit-scrollbar-thumb:hover,
body.light .chat-wrap::-webkit-scrollbar-thumb:hover,
body.light .sidebar-right-content::-webkit-scrollbar-thumb:hover,
body.light .modal-box::-webkit-scrollbar-thumb:hover {
  background: #909399;
}

/* 深色主题滚动配色 */
body.dark .sidebar-top::-webkit-scrollbar-track,
body.dark .chat-wrap::-webkit-scrollbar-track,
body.dark .sidebar-right-content::-webkit-scrollbar-track,
body.dark .modal-box::-webkit-scrollbar-track {
  background: #24242c;
}
body.dark .sidebar-top::-webkit-scrollbar-thumb,
body.dark .chat-wrap::-webkit-scrollbar-thumb,
body.dark .sidebar-right-content::-webkit-scrollbar-thumb,
body.dark .modal-box::-webkit-scrollbar-thumb {
  background: #444452;
}
body.dark .sidebar-top::-webkit-scrollbar-thumb:hover,
body.dark .chat-wrap::-webkit-scrollbar-thumb:hover,
body.dark .sidebar-right-content::-webkit-scrollbar-thumb:hover,
body.dark .modal-box::-webkit-scrollbar-thumb:hover {
  background: #606072;
}

/* 2. Firefox 兼容单独写，不与webkit伪类混写，避免解析报错 */
@supports (scrollbar-width: thin) {
  .sidebar-top,
  .chat-wrap,
  .sidebar-right-content,
  .modal,
  .modal-box,
  .msg-ai pre {
    scrollbar-width: thin;
  }
  body.light .sidebar-top,
  body.light .chat-wrap,
  body.light .sidebar-right-content,
  body.light .modal-box {
    scrollbar-color: #c0c4cc #eef0f3;
  }
  body.dark .sidebar-top,
  body.dark .chat-wrap,
  body.dark .sidebar-right-content,
  body.dark .modal-box {
    scrollbar-color: #444452 #242c;
  }
}

/* ========== 侧边栏 ========== 
.sidebar {
    width: 280px;
    display: fixed;
    flex-direction: column;
    padding: 12px;
}
*/
/* 侧边栏宽度变量，默认280，限制最小/最大宽度 */
.sidebar {
    width: 280px;
    min-width: 220px;
    max-width: 850px;
    display: flex;
    flex-direction: column;
    padding: 12px;
	position: fixed;
	will-change: width;
	height: 100vh;
}

.sidebar-top {
    flex: 1;
 overflow-y: auto !important;
  scrollbar-gutter: stable !important;
}
.sidebar-bottom {
    margin-top: auto;
    padding-top: 10px;
    border-top: 1px solid #eee;
    display: flex;
    flex-direction: column;
    gap:6px;
}
.sidebar-title {
    font-size: 12px;
    color: #888;
    margin: 12px 0 6px;
    padding-left: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.new-chat-btn {
    font-size:12px;
    padding:2px 6px;
    cursor:pointer;
    background:#1677ff22;
    color:#1677ff;
    border-radius:4px;
}
.sidebar-item {
    padding: 8px 10px;
    border-radius: 6px;
    cursor: pointer;
    margin: 4px 0;
    font-size: 14px;
    display:flex;
    justify-content: space-between;
    align-items: center;
}
.sidebar-item:hover {
    background: rgba(130,130,130,0.12);
}
.sidebar-item.active {
    background: #1677ff22;
    color: #1677ff;
}
.chat-op-btn-group {
    display:none;
    gap:4px;
}
.sidebar-item:hover .chat-op-btn-group {
    display:flex;
}
.chat-rename,.chat-del {
    font-size:12px;
    padding:1px 4px;
    border-radius:3px;
    border:none;
    cursor:pointer;
}
.chat-rename {
    background:#52c41a22;
    color:#389e0d;
}
.chat-del {
    background:#ff4d4f22;
    color:#ff4d4f;
}
/* 侧边底部图标工具栏 */
.sidebar-bottom {
    margin-top: auto;
    padding-top: 10px;
    border-top: 1px solid rgba(120,120,120,0.12);
}
.sidebar-tool-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
.tool-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap:4px;
    padding: 10px 4px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
}
body.light .tool-btn:hover {
    background: rgba(0,0,0,0.06);
}
body.dark .tool-btn:hover {
    background: rgba(255,255,255,0.08);
}

/* 聊天气泡内有序/无序列表统一修复 */
.msg-box ol,
.msg-box ul {
    margin: 8px 0;
    /* 关键：用内边距把序号收进气泡内部 */
    padding-left: 1.8rem;
    /* 序号放在文本区域内部，不会跑出盒子 */
    list-style-position: inside;
}
.msg-box li {
    line-height: 1.7;
    margin: 4px 0;
    word-wrap: break-word;
}
/* 多级嵌套列表缩进 */
.msg-box ol ol,
.msg-box ul ul,
.msg-box ol ul,
.msg-box ul ol {
    padding-left: 1.2rem;
    margin: 4px 0;
}

/* 亮色主题文字 */
body.light .msg-box ol li,
body.light .msg-box ul li {
    color: #1f2937;
}
/* 深色主题文字，保证序号清晰 */
body.dark .msg-box ol li,
body.dark .msg-box ul li {
    color: #e5e7eb;
}

.tool-icon {
    font-size: 20px;
}
.tool-label {
    display: none !important;
}
.sidebar-tool-row {
    display: grid;
    grid-template-columns: repeat(5, 1fr); /* 5个按钮均分 */
    gap: 8px;
}
.tool-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    padding: 12px 4px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
}
/* 会话操作小按钮缩小 */
.chat-op-btn-group button {
    width: 22px;
    height: 22;
    font-size: 13px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
/* 危险按钮区分颜色 */
#clear-current-session .tool-icon {
    color: #ff4d4f;
}
#export-json .tool-icon {
    color: #1677ff;
}
#export-txt .tool-icon {
    color: #52c41a;
}
#open-setting .tool-icon {
    color: #722ed1;
}
#export-lora .tool-icon {
    color: #722ed1;
}

#current-username {
    cursor: pointer !important; /* !important覆盖默认text光标 */
    text-decoration: underline;
    transition: color 0.2s;
}
#current-username:hover {
    color: #1677ff;
}
/* ========== 聊天主区域 ========== */


.msg-box {
    margin-bottom: 10px;
    max-width: 75%;
    position:relative;
}

/* AI对话内表格全局边框样式，浅色/深色自适应 */
.msg-box table {
    width: 100%;
    border-collapse: collapse; /* 合并边框，无双线 */
    margin: 12px 0;
    overflow-x: auto;
    display: block;
}
.msg-box th,
.msg-box td {
    border: 1px solid #d1d5db; /* 灰色网格线 */
    padding: 8px 10px;
    text-align: left;
    vertical-align: middle;
}
.msg-box th {
    background-color: #f3f4f6;
    font-weight: bold;
    color: #111827; /* 浅色表头深色文字 */
}
.msg-box td {
    color: #1f2937;
}
/* 超长表格横向滚动 */
.table-wrap {
    overflow-x: auto;
    margin: 10px 0;
}

/* 深色主题适配 */
body.dark .msg-box th,
body.dark .msg-box td {
    border: 1px solid #4b5563;
}
body.dark .msg-box th {
    background-color: #374151;
    color: #f9fafb; /* 深色表头纯白文字，清晰可见 */
}
body.dark .msg-box td {
    color: #e5e7eb; /* 单元格浅灰文字 */
}

.msg-user {
    margin-left: auto;
    padding: 10px 14px;
    border-radius: 12px 2px 12px 12px;
}
.msg-ai {
    margin-right: auto;
    padding: 10px 14px;
    border-radius: 2px 12px 12px 12px;
}
/* AI消息复制按钮 */
.ai-copy-all {
    position:absolute;
    top:4px;
    right:4px;
    font-size:12px;
    padding:2px 6px;
    border:none;
    border-radius:4px;
    cursor:pointer;
    opacity:0;
}
.msg-ai:hover .ai-copy-all {
    opacity:1;
}
/* Markdown 基础样式 */
.msg-ai h1,.msg-ai h2,.msg-ai h3 {
    margin:8px 0;
}
.msg-ai p {
    margin:6px 0;
    line-height:1.6;
}
.msg-ai pre {
    border-radius:6px;
    padding:10px;
    overflow-x:auto;
    margin:8px 0;
    position:relative;
	scrollbar-height: 4px;
	overflow-x: auto;
}
.msg-ai pre::-webkit-scrollbar {
  height: 4px;
}

.msg-ai code {
    padding:2px 6px;
    border-radius:4px;
}
.code-copy-btn {
    position:absolute;
    top:6px;
    right:6px;
    font-size:12px;
    padding:2px 6px;
    border:none;
    border-radius:4px;
    cursor:pointer;
}
/* 上传图片预览 */
.upload-img-preview {
    max-width:240px;
    border-radius:6px;
    margin:6px 0;
}
/* 底部输入栏 */

.input-left-tool {
    display:flex;
    flex-direction:column;
    gap:6px;
}
.upload-file-btn {
    width:36px;
    height:36px;
    border-radius:6px;
    border:1px solid #ccc;
    display:flex;
    align-items:center;
    justify-content:center;
    cursor:pointer;
}

.send-btn-group {
    display:flex;
    flex-direction:column;
    gap:6px;
}
#send-btn {
    padding: 0 20px;
    background: #1677ff;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    height:36px;
}
#stop-stream-btn {
    padding: 0 20px;
    background: #ff4d4f;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    height:36px;
    display:none;
}
/* 弹窗通用 */
.modal-mask {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.modal-box {
    width: 600px;
    max-height:85vh;
    padding: 24px;
    border-radius: 10px;
    overflow-y: auto !important;
    scrollbar-gutter: stable !important;
	border: 1px solid #b8d8fe !important;; /* 柔和淡蓝色边线 */
	position: relative;
}


.msg-info {
    padding:8px 12px;background:#e6f7ff;border:1px #91caff solid;border-radius:4px;color:#2f5496;font-size:12px;
}
.table-compact th {background:#2f5496;color:#fff;}


.modal-sm {
    width:360px;
}
.modal-title {
    font-size: 18px;
    margin-bottom: 16px;
    display: flex;
    justify-content: space-between;
    cursor: move;
    user-select: none;
    /* 新增淡蓝色底边线 */
    padding-bottom: 10px;
    border-bottom: 1px solid #b8d8fe;
}
.close-modal {
    cursor: pointer;
    font-size: 22px;
}
.form-item {
    margin-bottom: 14px;
}
.form-item label {
    display: block;
    margin-bottom: 6px;
    font-size: 14px;
}
.form-item input,
.form-item select,
.form-item textarea {
    width: 100%;
    padding: 9px 12px;
    border-radius: 6px;
    border: 1px solid #ccc;
}
.form-item textarea {
    min-height:80px;
    resize:vertical;
}
.row-two {
    display:flex;
    gap:10px;
}
.row-two .form-item {
    flex:1;
}
.save-config {
    margin-top: 10px;
    width: 100%;
    padding: 10px;
    background: #1677ff;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
}
.loading-text {
    opacity:0.6;
}
/* 隐藏原生文件input */
#file-input {
    display:none;
}

/* 侧边栏顶部Logo MantisAI */
.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 10px 16px;
    border-bottom: 1px solid rgba(120,120,0.12);
    margin-bottom: 10px;
    /* 取消两端对齐，改为左靠，登录区自动挤到右侧 */
    justify-content: flex-start;
}
.login-area {
    margin-left: auto; /* 登录区域自动推到最右边 */
    display: flex;
    align-items: center;
    gap: 10px;
}
.login-btn {
    padding: 4px 10px;
    border-radius: 6px;
    border: none;
    background: #1677ff;
    color: #fff;
    cursor: pointer;
}
.logout-btn {
    padding: 3px 8px;
    border-radius: 6px;
    border: 1px solid #ff4d4f;
    color: #ff4d4f;
    background: transparent;
    cursor: pointer;
}
body.dark .logout-btn {
    border-color: #ff7875;
    color: #ff7875;
}
.logo-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: #1677ff;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}
.logo-text {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: 0.5px;
}
/* 深色主题logo适配 */
body.dark .logo-icon {
    background: #2563eb;
}

/* 设置弹窗标签页 */
.setting-tabs {
    display: flex;
    border-bottom: 1px solid #ccc;
    margin-bottom: 16px;
}
.tab-item {
    padding: 8px 16px;
    cursor: pointer;
    font-size: 14px;
    border-bottom: 2px solid transparent;
}
.tab-item.active {
    border-bottom-color: #1677ff;
    color: #1677ff;
}
body.dark .setting-tabs {
    border-bottom-color: #333;
}
body.dark .tab-item.active {
    color: #69b1ff;
    border-bottom-color: #69b1ff;
}
.tab-panel {
    padding: 4px 0;
}

/* 侧边栏列表前置图标 */
.sidebar-item {
    padding: 8px 10px;
    border-radius: 6px;
    cursor: pointer;
    margin: 4px 0;
    font-size: 14px;
    display: flex;
    align-items: center;
    /* 左右两端对齐：图标文字靠左，操作按钮靠右 */
    justify-content: space-between;
    gap: 8px;
}
/* 左侧图标+文字容器，强制靠左不撑开 */
.item-left-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 1;
}
.item-icon {
    font-size: 16px;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}
/* 文字自动靠左，剩余空间留给右侧按钮 */
.chat-name, .sidebar-item > span:nth-child(2) {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
/* 亮色主题图标微调 */
body.light .item-icon {
    opacity: 0.8;
}
/* 深色主题图标提亮 */
body.dark .item-icon {
    opacity: 0.9;
}
.sidebar-item:hover .item-icon {
    opacity: 1;
}
.sidebar-item.active .item-icon {
    color: #1677ff;
}
body.dark .sidebar-item.active .item-icon {
    color: #69b1ff;
}

/* 页面横向布局支持拉伸 */
body {
    display: flex;
    height: 100vh;
    overflow: hidden;
    transition: background 0.3s, color 0.3s;
}



/* 拖拽分割条样式 */
.resize-handle {
	position: fixed;
    top: 0;
    margin-left: 280px; /* 与右侧栏宽度一致 */
    width: 4px;
    height: 100vh;
    background: transparent;
    cursor: col-resize;
    z-index: 99;
    transition:  background 0.15s;
}
.resize-handle:hover,
.resize-handle.active {
    background: #1677ff;
}
body.dark .resize-handle:hover,
body.dark .resize-handle.active {
    background: #69b1ff;
}

/* 右侧聊天自动占满剩余宽度 */


#chat-input {
    flex: 1;
    padding: 12px 14px;
    border-radius: 8px;
    border: 1px solid #ddd;
    resize: vertical; /* 只允许上下拖拽 */
    min-height: 60px;
    max-height: 220px;
    height: 60px;
    overflow-y: auto;
	width: 100%;
    box-sizing: border-box;
}


body.dark #chat-input {
    background: #27272f;
    color: #e5e7eb;
    border-color: #3a3a48;
}





body.dark .chat-input-area {
    border-color: #2d2d34;
}

/* 输入框外层容器 */
.textarea-wrap {
    position: relative;
    width: 100%;
}



/* 右上角拖拽手柄 */
.resize-handle-input {
    position: absolute;
    right: 6px;
    top: 6px;
    width: 18px;
    height: 18px;
    cursor: ns-resize !important;
    opacity: 0.6;
    border-top: 2px solid #999;
    border-right: 2px solid #999;
    z-index: 99 !important; /* 层级最高，不会被遮挡 */
    pointer-events: auto !important; /* 允许接收鼠标点击 */
}
.resize-handle-input:hover {
    opacity: 1;
}
body.dark .resize-handle-input {
    border-color: #ccc;
}

/* 调整输入框工具栏布局，适配水平预览 */
.input-inner-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px;
}

/* 上传按钮样式优化 */
.upload-file-btn {
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  background: #f0f2f5;
  font-size: 16px;
}
.upload-file-btn:hover {
  background: #e5e6eb;
}

#file-input {
    display: none;
}

/* 发送停止按钮组横向排列 */




/* 只读昵称输入框置灰 */
#login-nick {
    background: #f5f5f5 !important;
    color: #666 !important;
    cursor: default;
}
body.dark #login-nick {
    background: #333 !important;
    color: #aaa !important;
}

body.dark #login-nick[readonly] {
    background: #333 !important;
    color: #aaa !important;
}
body.dark #login-nick:not([readonly]) {
    background: #27272f !important;
    color: #eee !important;
}

/* 单条消息容器 */
/* 消息外层容器，控制左右对齐 */
.msg-wrap {
    width: 100%;
    padding: 14px 14px;
    box-sizing: border-box;
}
.msg-user-wrap {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}
.msg-ai-wrap {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

/* 头部小字：作者+时间 */
.msg-header {
    font-size: 11px;
    opacity: 0.75;
    margin-bottom: 5px;
    display: flex;
    gap: 10px;
}
.user-header {
    flex-direction: row-reverse; /* 用户信息靠右 */
}
.ai-header {
    flex-direction: row; /* AI模型信息靠左 */
}
.msg-author {
    font-weight: 500;
}
.msg-time {}

/* 原有气泡样式不变，这里只补充间距 */
.msg-box {
    max-width: 72%;
}

/* AI等待加载三点动画 */
.loading-dot {
    display: flex;
    gap: 4px;
    font-size: 22px;
    line-height: 1.6;
    padding: 6px 0;
}
.loading-dot span {
    animation: dotAnim 1.4s infinite ease-in-out;
}
.loading-dot span:nth-child(1) { animation-delay: 0s; }
.loading-dot span:nth-child(2) { animation-delay: 0.2s; }
.loading-dot span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dotAnim {
    0%, 100% { opacity: 0.2; transform: translateY(0); }
    50% { opacity: 1; transform: translateY(-4px); }
}

/* 深色主题适配 */
body.dark .loading-dot span {
    color: #ccc;
}
body.light .loading-dot span {
    color: #555;
}

/* 文件预览容器 */
.file-preview-container {
  display: flex;
  gap: 8px;
  padding: 4px;
  flex-wrap: wrap;
  align-items: center;
}

/* 单个文件预览项 */
.file-preview-item {
  position: relative;
  width: 60px;
  height: 60px;
  border: 1px solid #e5e7eb;
  border-radius: 4px;
  overflow: hidden;
  background: #f9fafb;
}

/* 图片缩略图 */
.file-preview-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* 非图片文件图标容器 */
.file-icon-wrap {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  font-size: 12px;
  color: #6b7280;
}

.file-icon {
  font-size: 24px;
  margin-bottom: 4px;
}

/* 预览项删除按钮 */
.file-preview-remove {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ef4444;
  color: white;
  border: none;
  cursor: pointer;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

/* 聊天消息中的附件样式 */
.chat-attach-file {
  display: inline-block;
  margin-top: 8px;
  margin-left: 8px;
}

.chat-attach-file .file-preview-item {
  width: 40px;
  height: 40px;
}

 /* 上传文件预览样式 */
/* 上传预览容器 - 水平排列核心样式 */
.upload-preview-container {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
    height: 40px;
    overflow-x: auto;
    flex-shrink: 1; /* 允许自身收缩，优先挤压预览区，不会挤按钮 */
    max-width: calc(100% - 120px); /* 预留足够宽度给上传+发送按钮，根据按钮总宽度微调 */
}
/* 滚动条美化（深色模式适配） */
.upload-preview-container::-webkit-scrollbar {
    height: 3px;
}
.upload-preview-container::-webkit-scrollbar-thumb {
    background: #555;
    border-radius: 2px;
}

/* 按钮组禁止收缩，固定占位 */
.chat-btn-group {
    flex-shrink: 0;
    display: flex;
    gap: 8px;
}

.chat-input-wrap {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 12px;
    border-top: 1px solid #333;
    flex-wrap: nowrap; /* 禁止整行换行，保证预览横向滚动 */
}

/* 单个文件预览项 */
.upload-preview-item {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  background: #f0f2f5;
  border-radius: 4px;
  height: 28px;
  white-space: nowrap;
}
/* 文件名称样式优化 */
.upload-file-name {
  font-size: 13px;
  color: #333;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.chat-files {
    margin-top: 0px;
    padding-top: 0px;
	border-bottom: 1px dashed #cccccc;
    font-size: 10px;
}
.chat-files a {
    color: #1677ff;
    text-decoration: none;
    margin-right: 6px;
}
.chat-files a:hover {
    text-decoration: underline;
}

/* 文件图标 */
.upload-file-icon {
  font-size: 14px;
}
/* 关闭按钮 */
.upload-close-btn {
  cursor: pointer;
  font-size: 12px;
  color: #999;
  margin-left: 4px;
}
.upload-close-btn:hover {
  color: #ff4d4f;
}

.upload-preview-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.upload-preview-file-icon {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f9fafb;
    font-size: 18px;
}
.upload-preview-remove {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #ff4d4f;
    color: white;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: 1px solid white;
}
/* 聊天消息附件样式 */
.chat-attachments {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    flex-wrap: wrap;
}
.chat-attachment-item {
    position: relative;
    width: 60px;
    height: 60px;
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid #e5e7eb;
}
.chat-attachment-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.chat-attachment-file-icon {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f9fafb;
    font-size: 24px;
}

/* 顶部标题栏 */
.chat-header {
    height: auto;
    min-height: 45px;
    max-height: 70%;
    padding: 0 14px;
    display: flex;
    align-items: flex-start;
    background: #f3f3f3;
    /* 必须加relative，拖拽条才能以它为基准 */
    position: relative;
    box-sizing: border-box;
    /* 底部留8px空间给拖拽条，不被chat-wrap盖住 */
    padding-bottom:4px;
	padding-top:4px;
}


/* 聊天内容自动占剩余空间 */
/* 聊天内容区域 不能贴紧顶部，避开拖拽条 */
.chat-wrap {
    flex: 1;
    overflow-y: auto !important;
    padding: 0 0px;
    scrollbar-gutter: stable;
    box-sizing: border-box; /* padding不会撑宽容器 */
}


.dark .chat-header{
    background:#242424;
}
.chat-header-title{
    font-size:14px;
    z-index:2;
    position:top;
	width:100%;
	Vertical-align: top;
}
/* 加粗拖拽分割线，一眼可见 */
/* 拖拽分割线 提升层级，不会被遮挡 */
.chat-header-resize-handle {
    position:fixed;
    left:0;
    bottom:0;
    width:100%;
    height:1px;
    background:transparent;
    cursor:ns-resize;
    transition: background 0.15s;
    z-index:99; /* 层级最高，不会被聊天内容盖住 */
}
.chat-header-resize-handle:hover{
    background:#4096ff !important;
	height:4px;
}
.chat-header-resize-handle:active{
    background:#1677ff !important;
	height:4px;
}


/* 聊天外层容器必须占满高度 */
.chat-main {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    overflow: hidden;
	margin-right:380px;
	margin-left:280px;
}



.chat-input-area{
    flex-shrink:0;
	width:98%;
}



/* 拖拽时禁止页面文字选中 */
body.drag-modal {
    user-select: none;
}

.modal-mask .modal-box {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
	border: 1px solid #b8d8fe; /* 柔和淡蓝色边线 */
}

/* 右侧栏核心样式 */
.sidebar-right {
    position: fixed;
    top: 0;
    right: 0;
    width: 380px; /* 默认宽度 */

    height: 100vh;
    background: 8;
    border-left: 1px solid #e5e7eb;
    box-shadow: -2px 0 8px rgba(0,0,0,0.05);
    z-index: 100;
    transition: width 0.2s ease;
    overflow-y: none;
}

.sidebar-right-header {
    padding: 16px;
    border-bottom: 1px solid #e5e7eb;
    font-weight: 600;
    font-size: 14px;
}

.sidebar-right-content {
	 flex: 1;
    padding: 4px;
	min-height: 100px; /* 最小高度限制 */
    overflow-y: auto !important;
    scrollbar-gutter: stable !important;
	margin-bottom:20px;
}


.right-item {
    padding: 12px 8px;
    border-radius: 6px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: background 0.2s;
}

.right-item:hover {
    background: #f5f7fa;
}
/*position: fixed;top: 0;right: 80px;  width: 2px; height: 100vh; background: gray;cursor: ew-resize; z-index: 99; transition: background 0.15s
 右侧拖拽手柄样式 */
 

	
.resize-handle-right {
    position: fixed;
    top: 0;
    right: 380px; /* 与右侧栏宽度一致 */
    width: 4px;
    height: 100vh;
    background: transparent;
    cursor: col-resize;
    z-index: 99;
    transition:  background 0.15s;
}

.resize-handle-right:hover {
  background: #4096ff !important;
}

.resize-handle-right:active {
  background: #4096ff !important;
} 

/* 适配深色主题 */
body.dark .sidebar-right {
    background: #1f2937;
    border-left-color: #374151;
    color: #fff;
}

body.dark .right-item:hover {
    background: #374151 !important;
}

.share-toggle-btn {
    border: 0;
    background: transparent;
    cursor: pointer;
    font-size:14px;
    padding: 2px 5px;
}
.public-agent-item .item-icon {
    color:#1677ff;
}

/* 右侧栏整体布局 */
.sidebar-right {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}



/* 拖拽手柄样式 */
.sidebar-right-resize-handle {
    height: 1px;
    background-color: #e5e7eb;
    cursor: ns-resize; /* 上下拖拽光标 */
    border-radius: 3px;
    margin-bottom: 20px;
    transition: background-color 0.2s;
}

.sidebar-right-resize-handle:hover {
    background: #69b1ff;
	 height: 4px;
}

sidebar-right-resize-handle:active{
    background:#1677ff !important;
	height:4px;
}
/* 第二个内容区 */
.sidebar-right-content-secondary {
    height: 20px; /* 初始高度 */
    min-height: 20px; /* 最小高度限制 */
    overflow-y: auto;
    padding: 4px;
    /*border-top: 1px solid #e2e8f0;*/
}

/* 消息附件展开容器样式，和知识库统一 */
.file-wrap {
  margin-bottom: 5px;
  padding-bottom: 5px;
  border-bottom: 1px solid #e2e8f0;
  color: white;
}
.file-toggle {
  cursor: pointer;
}
.file-list {
  padding-left: 18px;
  margin: 4px 0;
}
.file-list li a {
 
}

/* 下拉菜单容器 */
.setting-dropdown-wrap {
    position: relative;
    cursor: pointer;
}

/* 下拉菜单样式 */
.setting-dropdown-menu {
    position: absolute;
    bottom: 100%; /* 上拉显示 */
    left: 0;
    z-index: 999;
    width: 160px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    display: none; /* 默认隐藏 */
}

/* 深色模式适配 */
.dark .setting-dropdown-menu {
    background: #333;
    border-color: #444;
}

/* 菜单项样式 */
.dropdown-item {
    padding: 8px 12px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s;
}

/* 深色模式菜单项 */
.dark .dropdown-item {
    color: #e5e7eb;
}

/* 菜单项hover效果 */
.dropdown-item:hover {
    background: #f5f5f5;
}

.dark .dropdown-item:hover {
    background: #444;
}

/* 点击按钮时的激活态（可选） */
.setting-dropdown-wrap.active .tool-icon {
    color: #1677ff;
}

.meta-table-wrap {
    border: 1px solid #eee;
    max-height: 300px;
    overflow-y: auto;
    margin: 14px 0;
}
body.dark .meta-table-wrap {
    border-color: #333;
}

/* 表格铺满modal-body完整宽度，清除form-item宽度限制 */
.table-full-width {
    width: 100%;
    margin-top: 12px;
    border: 1px solid #eee;
    max-height: 300px;
    overflow-y: auto;
    box-sizing: border-box;
	 border-collapse: collapse; /* 合并边框，无双线 */
}
body.dark .table-full-width {
    border-color: #333;
}
/* table-layout:fixed强制按th百分比分配列宽 */
.table-compact {
    table-layout: fixed;
    width: 100%;
}

input[readonly],
select[disabled] {
    background: #eee !important;
    cursor: not-allowed;
    opacity: 0.7;
}
body.dark input[readonly],
body.dark select[disabled] {
    background: #333 !important;
}

/* 知识库三态按钮样式，基于原有 rag-switch-btn */
.rag-switch-btn.state-false {
    background: #999;
    color: #fff;
}
.rag-switch-btn.state-true {
    background: #1677ff;
    color: #fff;
}
.rag-switch-btn.state-global {
    background: #722ed1;
    color: #fff;
}
body.dark .rag-switch-btn.state-global {
    background: #9254de;
}

.switch-box {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 22px;
}
.switch-box input {
  opacity: 0;
  width: 0;
  height: 0;
}
.switch-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  border-radius: 22px;
  transition: .3s;
}
.switch-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 2px;
  bottom: 2px;
  background-color: white;
  border-radius: 50%;
  transition: .3s;
}
input:checked + .switch-slider {
  background-color: #4096ff;
}
input:checked + .switch-slider:before {
  transform: translateX(22px);
}

/*移动端*/

/* 全局移动端基础 */
/* ============ 移动端适配修复 ============ */
@media (max-width: 1200px) {
  /* 拖拽条全部隐藏 */
  .resize-handle, .resize-handle-right, .sidebar-right-resize-handle, .chat-header-resize-handle {
    display: none !important;
  }

  /* 左侧侧边默认移出屏幕 */
  .sidebar {
    position: fixed;
    z-index: 9999 !important; /* 提高层级，不会被聊天区盖住 */
    left: 0;
    top: 0;
    bottom: 0;
    width: 280px;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }
  .sidebar.show-left {
    transform: translateX(0);
  }

  /* 右侧知识库侧边 */
  .sidebar-right {
    position: fixed;
    z-index: 9999 !important;
    right: 0;
    top: 0;
    bottom: 0;
    width: 380px;
    transform: translateX(100%);
    transition: transform 0.25s ease;
  }
  .sidebar-right.show-right {
    transform: translateX(0);
  }

  /* 聊天窗口全屏，清除左右边距 */
  .chat-main {
    margin-left: 0 !important;
    margin-right: 0 !important;
    width: 100%;
  }

  /* 遮罩样式 */
  .mask-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 9998 !important;
  }
  .mask-overlay.active {
    display: block;
  }

  /* 移动端按钮强制可见，提升层级不被遮挡 */
  .mobile-bar-btn {
    flex-shrink: 0;
    padding: 5px 8px !important;
    font-size: 17px !important;
    border-radius: 6px;
    border: 1px solid #555;
    background: #333;
    color: #fff;
    cursor: pointer;
  }
  /* 侧边打开时，隐藏顶部按钮 */
  .sidebar.show-left ~ .chat-main .mobile-bar-btn,
  .sidebar-right.show-right ~ .chat-main .mobile-bar-btn {
    display: none !important;
  }
}

@media (prefers-color-scheme: dark) {
    .mobile-bar-btn {
        background:#2a2a2a;
        color:#fff;
        border-color:#444;
    }
}

/* PC大屏：清除移动端样式 */
@media (min-width: 1201px) {
  .mask-overlay {
    display: none !important;
  }
  .sidebar.show-left, .sidebar-right.show-right {
    transform: none !important;
  }
  .mobile-bar-btn {
    display: none !important;
  }
}