:root{
  --bg-primary:#ffffff;
  --bg-secondary:#f5f5f5;
  --bg-tertiary:#e8e8e8;

  --text-primary:#1a1a1a;
  --text-secondary:#666666;
  --text-muted:#999999;

  --border-color:#e0e0e0;

  --accent-color:#2563eb;
  --accent-hover:#1d4ed8;

  --danger-color:#dc2626;
  --success-color:#16a34a;

  --message-user-bg:#2563eb;
  --message-user-text:#ffffff;
  --message-assistant-bg:#f0f0f0;
  --message-assistant-text:#1a1a1a;

  --sidebar-width:280px;
  --header-height:60px;
  --radius:8px;

  --shadow:0 2px 8px rgba(0,0,0,0.1);
}

[data-theme="dark"]{
  --bg-primary:#1a1a1a;
  --bg-secondary:#252525;
  --bg-tertiary:#333333;

  --text-primary:#e8e8e8;
  --text-secondary:#a0a0a0;
  --text-muted:#666666;

  --border-color:#404040;

  --message-assistant-bg:#2a2a2a;
  --message-assistant-text:#e8e8e8;

  --shadow:0 2px 8px rgba(0,0,0,0.3);
}

*{
  margin:0;
  padding:0;
  box-sizing:border-box;
}

body{
  font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,'Helvetica Neue',Arial,sans-serif;
  background-color:var(--bg-primary);
  color:var(--text-primary);
  line-height:1.6;
}

body[data-font="small"]{font-size:14px;}
body[data-font="medium"]{font-size:16px;}
body[data-font="large"]{font-size:18px;}

/* =========================
   Layout
========================= */
.app-container{
  display:flex;
  height:100vh;
  overflow:hidden;
}

/* =========================
   Sidebar
========================= */
.sidebar{
  width:var(--sidebar-width);
  background-color:var(--bg-secondary);
  border-right:1px solid var(--border-color);
  display:flex;
  flex-direction:column;
  flex-shrink:0;
}

.sidebar-header{
  padding:16px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  border-bottom:1px solid var(--border-color);
}

/* 左上角品牌区：logo + 标题 */ 
.sidebar-header .brand { 
  display: flex; 
  align-items: center; 
  gap: 10px; 
  min-width: 0; 
  flex: 1; 
} 

.sidebar-header .brand .logo { 
  width: 32px; 
  height: 32px; 
  object-fit: contain; 
  flex-shrink: 0; 
} 

.sidebar-header .brand h1 { 
  margin: 0; 
  min-width: 0; 
  white-space: nowrap; 
  overflow: hidden; 
  text-overflow: ellipsis; 
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
} 

.search-box{
  padding:12px 16px;
}

.search-box input{
  width:100%;
  padding:8px 12px;
  border:1px solid var(--border-color);
  border-radius:var(--radius);
  background-color:var(--bg-primary);
  color:var(--text-primary);
  font-size:0.875rem;
}

.search-box input:focus{
  outline:none;
  border-color:var(--accent-color);
}

.chat-list{
  flex:1;
  overflow-y:auto;
  padding:8px;
}

.chat-item{
  padding:12px;
  border-radius:var(--radius);
  cursor:pointer;
  margin-bottom:4px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  transition:background-color 0.2s;
}

.chat-item:hover{background-color:var(--bg-tertiary);}
.chat-item.active{background-color:var(--accent-color);color:#fff;}

.chat-item-content{
  flex:1;
  min-width:0;
}

.chat-item-title{
  font-weight:500;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}

.chat-item-date{
  font-size:0.75rem;
  opacity:0.7;
}

.chat-item-delete{
  opacity:0;
  background:none;
  border:none;
  color:inherit;
  cursor:pointer;
  padding:4px;
  border-radius:4px;
}

/* 滑动删除容器 */
.chat-item-swipe-container {
  position: relative;
  width: 100%;
  overflow: hidden;
}

/* 滑动删除按钮 */
.chat-item-delete-swipe {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 80px;
  background: var(--danger-color);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  font-weight: 500;
  transform: translateX(100%);
  transition: transform 0.3s ease;
  z-index: 1;
}

.chat-item.swiped .chat-item-delete-swipe {
  transform: translateX(0);
}

/* 滑动时的聊天项样式 */
.chat-item {
  transition: transform 0.3s ease;
  will-change: transform;
}

.chat-item.swiped {
  transform: translateX(-80px);
}

/* 确保内容不被遮挡 */
.chat-item.swiped .chat-item-content {
  opacity: 0.8;
}

.chat-item:hover .chat-item-delete{opacity:0.7;}
.chat-item-delete:hover{
  opacity:1 !important;
  background-color:rgba(220,38,38,0.2);
}

.sidebar-footer{
  padding: 12px;
  border-top: 1px solid var(--border-color);
  display: flex;
  flex-direction: column; /* 纵向排列两行 */
  gap: 8px; /* 两行之间的间距 */
}

.footer-group {
  display: flex; /* 每行内部横向排列 */
  gap: 8px; /* 按钮之间的间距 */
  width: 100%;
}

/* 让每行内的按钮平分宽度 */
.footer-group .btn-secondary {
  flex: 1; 
  min-width: 0; /* 防止文字溢出挤压 */
  padding: 8px 4px;
  font-size: 0.8rem;
  white-space: nowrap;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

/* 针对带有图标的同步按钮微调 */
#syncBtn svg {
  flex-shrink: 0;
}

/* 知识库链接按钮样式对齐 */
.sidebar-footer a.btn-secondary {
  color: var(--text-primary);
}

.sidebar-footer a.btn-secondary:hover {
  background-color: var(--border-color);
}

/* 知识库未配置时禁用 */
.btn-disabled{
  opacity: 0.5;
  pointer-events: none;
}

/* =========================
   Main Chat
========================= */
.chat-main{
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0; /* 关键：防止被内容撑开或压缩 */
  width: 100%;  /* 强制铺满 */
  background-color: var(--bg-primary);
}

.chat-header{
  height:var(--header-height);
  padding:0 20px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  flex-wrap:wrap;
  gap:12px;
  border-bottom:1px solid var(--border-color);
  background-color:var(--bg-primary);
}

.chat-header-left{
  display:flex;
  align-items:center;
  gap:8px;
  min-width:0;
  flex:1;
}

.chat-header-left h2{
  margin:0;
  font-size:1.125rem;
  font-weight:500;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}

.chat-header-right{
  display:flex;
  align-items:center;
  gap:12px;
  flex-shrink:0;
}

.messages-container{
  flex:1;
  overflow-y:auto;
  padding:20px;
}

.welcome-message{
  text-align:center;
  padding:60px 20px;
  color:var(--text-secondary);
}

.welcome-message h2{
  margin-bottom:12px;
  color:var(--text-primary);
}

/* =========================
   Messages
========================= */
.message{
  max-width:800px;
  margin:0 auto 20px;
  display:flex;
  gap:12px;
}

.message-avatar{
  width:36px;
  height:36px;
  border-radius:50%;
  display:flex;
  align-items:center;
  justify-content:center;
  font-weight:600;
  font-size:0.875rem;
  flex-shrink:0;
}

.message.user .message-avatar{background-color:var(--accent-color);color:#fff;}
.message.assistant .message-avatar{background-color:var(--bg-tertiary);color:var(--text-primary);}

.message-content{flex:1;min-width:0;}

.message-bubble{
  padding:12px 16px;
  border-radius:var(--radius);
  word-wrap:break-word;
  overflow-wrap:break-word;
  overflow:hidden;
  max-width:100%;
  word-break:break-word;
}

/* 确保所有子元素都不会溢出 */
.message-bubble * {
  max-width: 100%;
  overflow-x: auto;
  overflow-wrap: break-word;
}

/* 特殊处理代码块，允许横向滚动 */
.message-bubble pre {
  overflow-x: auto;
  max-width: 100%;
}

.message-bubble pre code {
  white-space: pre;
  overflow-x: auto;
}

/* 确保表格不会溢出 */
.message-bubble table {
  max-width: 100%;
  overflow-x: auto;
  display: block;
}

/* 确保列表不会溢出 */
.message-bubble ul,
.message-bubble ol {
  max-width: 100%;
  overflow-wrap: break-word;
}

/* 确保引用块不会溢出 */
.message-bubble blockquote {
  max-width: 100%;
  overflow-wrap: break-word;
}

/* 确保所有行内元素不会溢出 */
.message-bubble p,
.message-bubble span,
.message-bubble strong,
.message-bubble em {
  max-width: 100%;
  overflow-wrap: break-word;
}

/* 确保链接不会溢出 */
.message-bubble a {
  max-width: 100%;
  overflow-wrap: break-word;
  word-break: break-all;
}

.message.user .message-bubble{background-color:var(--message-user-bg);color:var(--message-user-text);}
.message.assistant .message-bubble{background-color:var(--message-assistant-bg);color:var(--message-assistant-text);}

.message-time{
  font-size:0.75rem;
  color:var(--text-muted);
  margin-top:4px;
}

/* loading dots */
.message-loading{
  display:flex;
  gap:4px;
  padding:8px 0;
}
.message-loading span{
  width:8px;
  height:8px;
  background-color:var(--text-muted);
  border-radius:50%;
  animation:bounce 1.4s ease-in-out infinite;
}
.message-loading span:nth-child(1){animation-delay:0s;}
.message-loading span:nth-child(2){animation-delay:0.2s;}
.message-loading span:nth-child(3){animation-delay:0.4s;}

@keyframes bounce{
  0%,80%,100%{transform:translateY(0);}
  40%{transform:translateY(-8px);}
}

/* attachments in message */
.message-attachments{
  display:flex;
  flex-wrap:wrap;
  gap:10px;
  margin-top:10px;
}
.message-attachments img{
  max-width:260px;
  max-height:260px;
  object-fit:cover;
  border-radius:8px;
  border:1px solid rgba(0,0,0,.08);
  transition: opacity 0.3s ease;
}

/* 图片懒加载样式 */
.message-attachments img.lazy-load {
  opacity: 0.3;
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: loading-shimmer 1.5s infinite;
}

.message-attachments img.lazy-loaded {
  opacity: 1;
  animation: fade-in 0.5s ease;
}

@keyframes loading-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

@keyframes fade-in {
  from { opacity: 0.3; }
  to { opacity: 1; }
}

/* =========================
   Input Area
========================= */
.input-area{
  width: 100%;
  padding: 16px 20px;
  border-top: 1px solid var(--border-color);
  background-color: var(--bg-primary);
  flex-shrink: 0; /* 防止输入区被压缩 */
}

.input-wrapper{
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--bg-secondary);
  padding: 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border-color);
  transition: border-color 0.2s;
}

.input-wrapper textarea{
  width: 100%;
  border: none !important;
  background: transparent !important;
  padding: 8px 4px;
  font-size: 1rem;
  max-height: 200px;
  resize: none;
}

.input-wrapper textarea:focus{
  width: 100%;
  border: none !important;          /* 彻底移除边框 */
  outline: none !important;         /* 彻底移除点击时的蓝色轮廓线 */
  background: transparent !important;
  padding: 8px 4px;
  font-size: 1rem;
  max-height: 200px;
  resize: none;
  box-shadow: none !important;      /* 移除某些浏览器默认的阴影 */
}

/* 当鼠标移入或点击内部时，外层容器变色（模拟输入框聚焦效果） */
.input-wrapper:focus-within {
  border-color: var(--accent-color);
}

.input-hint{
  max-width:800px;
  margin:8px auto 0;
  display:flex;
  justify-content:space-between;
  font-size:0.75rem;
  color:var(--text-muted);
}

/* =========================
   Buttons
========================= */
.btn-primary{
  padding:10px 20px;
  background-color:var(--accent-color);
  color:#fff;
  border:none;
  border-radius:var(--radius);
  cursor:pointer;
  font-size:0.875rem;
  font-weight:500;
  transition:background-color 0.2s;
  display:flex;
  align-items:center;
  justify-content:center;
  gap:6px;
}

.btn-primary:hover{background-color:var(--accent-hover);}
.btn-primary:disabled{opacity:0.5;cursor:not-allowed;}

.btn-secondary{
  padding:8px 12px;
  background-color:var(--bg-tertiary);
  color:var(--text-primary);
  border:1px solid var(--border-color);
  border-radius:var(--radius);
  cursor:pointer;
  font-size:0.8rem;
  transition:background-color 0.2s;
}

.btn-secondary:hover{background-color:var(--border-color);}

.btn-danger{
  padding:8px 16px;
  background-color:var(--danger-color);
  color:#fff;
  border:none;
  border-radius:var(--radius);
  cursor:pointer;
  font-size:0.875rem;
}

.btn-icon{
  padding:8px;
  background:none;
  border:none;
  color:var(--text-secondary);
  cursor:pointer;
  border-radius:var(--radius);
  display:flex;
  align-items:center;
  justify-content:center;
  transition:background-color 0.2s,color 0.2s;
}

.btn-icon:hover{
  background-color:var(--bg-tertiary);
  color:var(--text-primary);
}

/* =========================
   Modal & Overlay
========================= */
.modal{
  display:none;
  position:fixed;
  top:0;left:0;right:0;bottom:0;
  z-index:1000;
  align-items:center;
  justify-content:center;
  padding:20px;
}

.modal.active{display:flex;}

.modal-content{
  background-color:var(--bg-primary);
  border-radius:var(--radius);
  box-shadow:var(--shadow);
  width:100%;
  max-width:560px;
  max-height:90vh;
  display:flex;
  flex-direction:column;
}

.modal-small {
  max-width: 400px;
  width: 90%; /* 移动端适配 */
}

/* 限制标题输入框样式 */
#newChatTitleInput {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  font-size: 1rem;
}

#newChatTitleInput:focus {
  border-color: var(--accent-color);
  outline: none;
}

.modal-header{
  padding:16px 20px;
  border-bottom:1px solid var(--border-color);
  display:flex;
  align-items:center;
  justify-content:space-between;
}

.modal-header h3{
  font-size:1.125rem;
  font-weight:600;
}

.modal-body{
  padding:20px;
  overflow-y:auto;
  flex:1;
}

.modal-footer{
  padding:16px 20px;
  border-top:1px solid var(--border-color);
  display:flex;
  justify-content:flex-end;
  gap:12px;
}

/* overlay: 修复输入框被遮罩挡住的问题 */
.overlay{
  display:none;
  position:fixed;
  top:0;left:0;right:0;bottom:0;
  background-color:rgba(0,0,0,0.5);
  z-index:999;
  pointer-events:none; /* 非active时不拦截事件 */
}

.overlay.active{
  display:block;
  pointer-events:auto; /* active 时才拦截 */
}

/* =========================
   Settings Tabs / Forms
========================= */
.settings-tabs{
  display:flex;
  gap:8px;
  margin-bottom:20px;
  border-bottom:1px solid var(--border-color);
  padding-bottom:12px;
}

.tab-btn{
  padding:8px 16px;
  background:none;
  border:none;
  color:var(--text-secondary);
  cursor:pointer;
  font-size:0.875rem;
  border-radius:var(--radius);
  transition:background-color 0.2s,color 0.2s;
}

.tab-btn:hover{background-color:var(--bg-tertiary);}
.tab-btn.active{background-color:var(--accent-color);color:#fff;}

.tab-content{display:none;}
.tab-content.active{display:block;}

.form-group{margin-bottom:16px;}

.form-group label{
  display:block;
  margin-bottom:6px;
  font-weight:500;
  font-size:0.875rem;
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group textarea,
.form-group select{
  width:100%;
  padding:10px 12px;
  border:1px solid var(--border-color);
  border-radius:var(--radius);
  background-color:var(--bg-secondary);
  color:var(--text-primary);
  font-size:0.875rem;
  font-family:inherit;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus{
  outline:none;
  border-color:var(--accent-color);
}

.form-group small{
  display:block;
  margin-top:4px;
  color:var(--text-muted);
  font-size:0.75rem;
}

.form-group input[type="checkbox"]{margin-right:8px;}
.form-group input[type="range"]{width:100%;}

.input-with-btn{
  display:flex;
  gap:8px;
}
.input-with-btn input{flex:1;}

.btn-group{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
}

.danger-zone{
  margin-top:24px;
  padding-top:16px;
  border-top:1px solid var(--danger-color);
}

/* WebDAV status */
.sync-status{
  margin-top:12px;
  padding:8px 12px;
  border-radius:var(--radius);
  font-size:0.875rem;
}
.sync-status.success{
  background-color:rgba(22,163,74,0.1);
  color:var(--success-color);
}
.sync-status.error{
  background-color:rgba(220,38,38,0.1);
  color:var(--danger-color);
}

/* =========================
   Toast
========================= */
.toast-container{
  position:fixed;
  bottom:20px;
  right:20px;
  z-index:2000;
  display:flex;
  flex-direction:column;
  gap:8px;
}

.toast{
  padding:12px 20px;
  background-color:var(--bg-tertiary);
  color:var(--text-primary);
  border-radius:var(--radius);
  box-shadow:var(--shadow);
  animation:slideIn 0.3s ease;
  border: 1px solid var(--border-color);
  opacity: 1 !important;
}

.toast.success{background-color:var(--success-color);color:#fff;}
.toast.error{background-color:var(--danger-color);color:#fff;}
.toast.loading{background-color:var(--accent-color);color:#fff;}

@keyframes slideIn{
  from{transform:translateX(100%);opacity:0;}
  to{transform:translateX(0);opacity:1;}
}

/* =========================
   Mobile menu button
========================= */
.mobile-menu-btn{
  display:none;
  position:fixed;
  top:12px;
  left:12px;
  z-index:2000;
  padding:8px;
  background-color:var(--bg-secondary);
  border:1px solid var(--border-color);
  border-radius:var(--radius);
  color:var(--text-primary);
  cursor:pointer;
}

/* =========================
   Model selector
========================= */
.model-selector{
  display:flex;
  align-items:center;
  gap:8px;
}

.model-selector label{
  font-size:0.875rem;
  color:var(--text-muted);
  white-space:nowrap;
}

.model-selector select{
  padding:6px 28px 6px 12px;
  font-size:0.875rem;
  color:var(--text-primary);
  background-color:var(--bg-secondary);
  border:1px solid var(--border-color);
  border-radius:var(--radius);
  cursor:pointer;
  appearance:none;
  background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat:no-repeat;
  background-position:right 8px center;
  min-width:140px;
  max-width:200px;
}

.model-selector select:hover{border-color:var(--accent-color);}
.model-selector select:focus{
  outline:none;
  border-color:var(--accent-color);
  box-shadow:0 0 0 2px rgba(37,99,235,0.2);
}

[data-theme="dark"] .model-selector select{
  background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
}

/* =========================
   Attachment bar (input)
========================= */
.attach-bar{
  max-width:800px;
  margin:0 auto 10px;
  padding:10px 12px;
  background:var(--bg-secondary);
  border:1px solid var(--border-color);
  border-radius:var(--radius);
}

.attach-bar-left,
.attach-bar-right{
  display:inline-flex;
  align-items:center;
  gap:10px;
}

.attach-bar-right{float:right;}

.attach-count{
  color:var(--text-secondary);
  font-size:0.85rem;
}

.attach-clear-btn{font-size:0.8rem;}

.attach-list{
  margin-top:10px;
  display:flex;
  flex-wrap:wrap;
  gap:8px;
  clear:both;
}

/* 附件卡片样式 - 类似腾讯元宝 */
.attach-card {
  position: relative;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
}

.attach-card:hover {
  border-color: var(--accent-color);
  transform: translateY(-2px);
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* 图片卡片 */
.attach-image-card {
  width: 60px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}

.attach-image-card .attach-thumb {
  width: 100%;
  height: 100%;
  border-radius: 6px;
  object-fit: cover;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

/* 文件卡片 */
.attach-file-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  min-width: 120px;
  max-width: 200px;
  flex-shrink: 0;
}

.attach-file-card .attach-icon-placeholder {
  width: 36px;
  height: 36px;
  min-width: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  border-radius: 6px;
  font-size: 20px;
}

.attach-file-name {
  font-size: 0.85rem;
  color: var(--text-primary);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

/* 卡片删除按钮 */
.attach-card-remove {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: none;
  background: var(--danger-color);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  opacity: 0;
  transition: all 0.2s ease;
  z-index: 10;
}

.attach-card:hover .attach-card-remove {
  opacity: 1;
}

.attach-card-remove:hover {
  transform: scale(1.1);
  background: #b91c1c;
}

.attach-card-remove svg {
  width: 12px;
  height: 12px;
}

.attach-item {
  display: flex;
  align-items: center;
  background: var(--bg-secondary);
  padding: 6px 10px;
  border-radius: 6px;
  margin-bottom: 6px;
  gap: 10px;
  height: 44px; /* 固定高度确保整齐 */
  min-width: 0;
}

.attach-thumb {
  width: 32px !important;
  height: 32px !important;
  min-width: 32px; /* 防止压缩 */
  border-radius: 4px;
  border: 1px solid var(--border-color);
  object-fit: cover;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  flex-shrink: 0;
}

.attach-icon-placeholder {
  width: 32px !important;
  height: 32px !important;
  min-width: 32px; /* 防止压缩 */
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-tertiary);
  border-radius: 4px;
  font-size: 18px;
  flex-shrink: 0;
}

.attach-item-clickable {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
  cursor: pointer;
}

.attach-item-name {
  font-size: 0.85rem;
  color: var(--text-primary);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.2;
}

.attach-item-remove {
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s ease;
}

.attach-item-remove:hover {
  color: var(--danger-color);
  background: rgba(220,38,38,0.08);
}

/* Attach preview modal content */
.attach-preview-image{
  max-width: 100%;
  max-height: 70vh; /* 限制高度，防止超出屏幕 */
  display: block;
  margin: 0 auto;
  object-fit: contain;
  border-radius: 4px;
}

/* 附件项布局微调 */
.attach-item-clickable {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    cursor: pointer;
}

.attach-item-clickable:hover .attach-item-name {
    text-decoration: underline;
    color: var(--primary-color);
}

.attach-preview-text{
  width:100%;
  min-height:55vh;
  white-space:pre-wrap;
  font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono",monospace;
  font-size:13px;
  line-height:1.5;
  background:var(--bg-secondary);
  border:1px solid var(--border-color);
  border-radius:10px;
  padding:12px;
  overflow:auto;
}

/* =========================
   Message actions / edit
========================= */
.message-actions{
  display:flex;
  gap:4px;
  margin-top:8px;
  opacity:0;
  transition:opacity 0.2s;
}

.message:hover .message-actions{opacity:1;}

.message-actions button{
  display:flex;
  align-items:center;
  gap:4px;
  padding:4px 8px;
  font-size:0.75rem;
  color:var(--text-muted);
  background:var(--bg-tertiary);
  border:1px solid var(--border-color);
  border-radius:4px;
  cursor:pointer;
  transition:all 0.2s;
}

.message-actions button:hover{
  color:var(--text-primary);
  background:var(--bg-secondary);
  border-color:var(--text-muted);
}

.message-actions button.danger:hover{
  color:var(--danger-color);
  border-color:var(--danger-color);
  background:rgba(220,38,38,0.1);
}

.message-actions button.regenerate:hover{
  color:var(--accent-color);
  border-color:var(--accent-color);
}

.message-edit-area{
  width:100%;
  margin-top:8px;
}

.message-edit-area textarea{
  width:100%;
  min-height:80px;
  padding:10px 12px;
  font-size:inherit;
  font-family:inherit;
  line-height:1.6;
  color:var(--text-primary);
  background:var(--bg-primary);
  border:1px solid var(--accent-color);
  border-radius:var(--radius);
  resize:vertical;
}

.message-edit-area textarea:focus{
  outline:none;
  box-shadow:0 0 0 2px rgba(37,99,235,0.2);
}

.message-edit-buttons{
  display:flex;
  gap:8px;
  margin-top:8px;
}

.message-edit-buttons button{
  padding:6px 14px;
  font-size:0.8rem;
  border-radius:4px;
  cursor:pointer;
  transition:all 0.2s;
}

.message-edit-buttons .save-btn{
  color:#fff;
  background:var(--accent-color);
  border:none;
}

.message-edit-buttons .save-btn:hover{background:var(--accent-hover);}

.message-edit-buttons .cancel-btn{
  color:var(--text-primary);
  background:var(--bg-tertiary);
  border:1px solid var(--border-color);
}

.message-edit-buttons .cancel-btn:hover{background:var(--border-color);}

/* =========================
   Code copy button
========================= */
.code-block-wrapper{position:relative;}

.code-copy-btn{
  position:absolute;
  top:8px;
  right:8px;
  padding:4px 8px;
  background-color:var(--bg-tertiary);
  border:1px solid var(--border-color);
  border-radius:4px;
  color:var(--text-secondary);
  font-size:0.75rem;
  cursor:pointer;
  opacity:0;
  transition:opacity 0.2s;
}

.code-block-wrapper:hover .code-copy-btn{opacity:1;}
.code-copy-btn:hover{background-color:var(--border-color);}

/* =========================
   Markdown render
========================= */

/* Markdown高亮样式 */
.message-bubble mark {
  background-color: #fef08a;
  color: #000;
  padding: 2px 4px;
  border-radius: 2px;
}

[data-theme="dark"] .message-bubble mark {
  background-color: #854d0e;
  color: #fef08a;
}

.message-bubble h1,
.message-bubble h2,
.message-bubble h3,
.message-bubble h4,
.message-bubble h5,
.message-bubble h6{
  margin:16px 0 8px 0;
  font-weight:600;
  line-height:1.4;
}

.message-bubble h1{font-size:1.5em;}
.message-bubble h2{font-size:1.3em;}
.message-bubble h3{font-size:1.15em;}
.message-bubble h4{font-size:1.05em;}
.message-bubble h5,
.message-bubble h6{font-size:1em;}

.message-bubble h1:first-child,
.message-bubble h2:first-child,
.message-bubble h3:first-child{margin-top:0;}

.message-bubble p{
  margin:0 0 12px 0;
  line-height:1.7;
}
.message-bubble p:last-child{margin-bottom:0;}

.message-bubble ul,
.message-bubble ol{
  margin:12px 0;
  padding-left:24px;
}

.message-bubble li{
  margin:6px 0;
  line-height:1.6;
}

.message-bubble li > ul,
.message-bubble li > ol{margin:4px 0;}

.message-bubble blockquote{
  margin:12px 0;
  padding:8px 16px;
  border-left:4px solid var(--accent-color);
  background-color:rgba(0,0,0,0.03);
  border-radius:0 var(--radius) var(--radius) 0;
}
[data-theme="dark"] .message-bubble blockquote{background-color:rgba(255,255,255,0.05);}
.message-bubble blockquote p{margin:0;}

.message-bubble hr{
  margin:16px 0;
  border:none;
  border-top:1px solid var(--border-color);
}

.message-bubble a{
  color:var(--accent-color);
  text-decoration:none;
}
.message-bubble a:hover{text-decoration:underline;}

.message-bubble code{
  font-family:'SF Mono',Monaco,'Courier New',monospace;
  font-size:0.9em;
  padding:2px 6px;
  background-color:rgba(0,0,0,0.06);
  border-radius:4px;
}
[data-theme="dark"] .message-bubble code{background-color:rgba(255,255,255,0.1);}

.message-bubble pre{
  margin:12px 0;
  padding:0;
  background:none;
  overflow:visible;
}

.message-bubble pre code{
  display:block;
  padding:16px;
  background-color:#1e1e1e;
  color:#d4d4d4;
  border-radius:var(--radius);
  overflow-x:auto;
  line-height:1.5;
  font-size:0.875em;
}

.message-bubble .code-block-wrapper{
  position:relative;
  margin:12px 0;
}

.message-bubble .code-block-header{
  display:flex;
  justify-content:space-between;
  align-items:center;
  padding:8px 12px;
  background-color:#2d2d2d;
  border-radius:var(--radius) var(--radius) 0 0;
  font-size:0.75em;
  color:#999;
}

.message-bubble .code-block-header + pre code{
  border-radius:0 0 var(--radius) var(--radius);
}

.message-bubble table{
  width:100%;
  margin:12px 0;
  border-collapse:collapse;
  font-size:0.9em;
}

.message-bubble th,
.message-bubble td{
  padding:8px 12px;
  border:1px solid var(--border-color);
  text-align:left;
}

.message-bubble th{
  background-color:var(--bg-tertiary);
  font-weight:600;
}

.message-bubble tr:nth-child(even){background-color:rgba(0,0,0,0.02);}
[data-theme="dark"] .message-bubble tr:nth-child(even){background-color:rgba(255,255,255,0.02);}

.message-bubble strong{font-weight:600;}
.message-bubble em{font-style:italic;}
.message-bubble del{text-decoration:line-through;opacity:0.7;}

/* user bubble tweaks */
.message.user .message-bubble code{background-color:rgba(255,255,255,0.2);}
.message.user .message-bubble pre code{background-color:rgba(0,0,0,0.3);color:#fff;}
.message.user .message-bubble a{color:#fff;text-decoration:underline;}

/* =========================
   Scrollbar
========================= */
::-webkit-scrollbar{width:6px;height:6px;}
::-webkit-scrollbar-track{background:transparent;}
::-webkit-scrollbar-thumb{background-color:var(--border-color);border-radius:3px;}
::-webkit-scrollbar-thumb:hover{background-color:var(--text-muted);}

/* =========================
   Responsive
========================= */
@media (max-width:768px){
  .sidebar{
    position:fixed;
    top:0;left:0;bottom:0;
    z-index:200;
    transform:translateX(-100%);
    transition:transform 0.3s ease;
  }
  .sidebar.open{transform:translateX(0);}

  .mobile-menu-btn{display:flex;}

  .chat-header{padding-left:60px;}
  .messages-container{padding:16px;}

  .message{gap:8px;}
  .message-avatar{width:32px;height:32px;font-size:0.75rem;}

  .input-area{padding:12px;}
  
  /* 优化移动端输入区域 */
  .input-wrapper{
    padding:8px;
    border-radius:12px;
    margin-bottom:8px;
  }
  
  .input-wrapper textarea{
    font-size:16px; /* 防止iOS缩放 */
    padding:12px;
    min-height:44px; /* 符合触摸最小尺寸 */
  }
  
  .input-toolbar{
    padding:8px 0 0;
    gap:12px;
  }
  
  .toolbar-left button{
    width:44px !important;
    height:44px !important;
    min-width:44px !important;
  }
  
  #sendBtn{
    min-width:44px;
    height:44px;
    padding:0 16px;
  }

  .modal-content{
    max-height:100vh;
    border-radius:0;
  }

  .settings-tabs{flex-wrap:wrap;}
  .tab-btn{padding:6px 12px;font-size:0.8rem;}

  /* 移动端始终显示操作按钮 */
  .message-actions{opacity:1;}

  /* 模型选择 label 隐藏 */
  .model-selector label{display:none;}
  .model-selector select{
    min-width:100px;
    max-width:140px;
    font-size:0.8rem;
    padding:5px 24px 5px 8px;
  }
}

@media (max-width:520px){
  .history-bar{
    grid-template-columns:1fr;
    align-items:start;
  }
  .history-tip{margin-top:2px;}
}

@media (max-width:480px){
  .chat-header{
    flex-direction:column;
    align-items:flex-start;
    height:auto;
    padding:12px 16px;
  }
  .chat-header-right{width:100%;}
  .model-selector{width:100%;}
  .model-selector label{display:block;}
  .model-selector select{flex:1;max-width:none;}
}

.compress-enable{
  display:inline-flex;
  align-items:center;
  gap:8px;
  color:var(--text-primary);
  font-size:0.9rem;
  white-space:nowrap;
}

.compress-input{
  display:inline-flex;
  align-items:center;
  gap:6px;
  white-space:nowrap;
}

.compress-input input{
  width:120px;
  padding:6px 8px;
  border-radius:10px;
  border:1px solid var(--border-color);
  background:var(--bg-primary);
  color:var(--text-primary);
}

.compress-input input:disabled{ opacity:0.6; }

.compress-prefix,
.compress-suffix{
  color:var(--text-secondary);
  font-size:0.9rem;
}

.compress-tip{
  color:var(--text-muted);
  font-size:0.8rem;
  line-height:1.3;
}

@media (max-width:520px){
  .compress-bar{
    grid-template-columns:1fr;
    align-items:start;
  }
  .compress-tip{ margin-top:2px; }
}
.compress-sep{
  color: var(--text-muted);
  margin: 0 6px;
}
/* 背景材料指示器样式 */
.background-indicator {
  font-size: 0.8rem;
  color: var(--text-secondary);
  background: var(--bg-tertiary);
  padding: 2px 8px;
  border-radius: 4px;
  margin-left: 4px;
  vertical-align: middle;
  white-space: nowrap;
}

.background-indicator span {
  margin-left: 4px;
}

@media (max-width: 768px) {
  .background-indicator span {
    display: none; /* 移动端隐藏文字 */
  }
  .background-indicator {
    padding: 2px 4px;
    background: transparent; /* 移动端去掉背景色，只留图标更清爽 */
    font-size: 1rem;
  }
}

/* =========================
   ICP Footer (fixed)
========================= */
:root{
  --icp-footer-height: 36px;
}

.site-footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 3000;

  height: var(--icp-footer-height);
  display: flex;
  align-items: center;
  justify-content: center;
  
  /* 核心修改：增加内容之间的间距 */
  gap: 15px; 

  padding: 0 12px;
  font-size: 12px;
  color: var(--text-muted);
  background-color: color-mix(in srgb, var(--bg-primary) 88%, transparent);
  border-top: 1px solid var(--border-color);
  backdrop-filter: blur(6px);
}

/* 针对版权文字的微调 */
.site-footer .copyright {
  user-select: none; /* 禁止选中版权文字，防止误触 */
}

/* 移动端适配：如果屏幕太窄，将两行文字上下排列 */
@media (max-width: 600px) {
  .site-footer {
    flex-direction: column; /* 纵向排列 */
    height: auto; /* 高度自适应 */
    padding: 8px 12px;
    gap: 4px; /* 缩减间距 */
  }
  
  /* 相应调整主体内容的底部内边距，防止被加高的页脚遮挡 */
  :root {
    --icp-footer-height: 50px; 
  }
}

/* 兼容不支持 color-mix 的浏览器（会用这条覆盖） */
@supports not (background-color: color-mix(in srgb, white 50%, transparent)){
  .site-footer{
    background-color: var(--bg-primary);
  }
}

.site-footer a{
  color: inherit;
  text-decoration: none;
}

.site-footer a:hover{
  text-decoration: underline;
}

/* 给主体让出底部空间，避免备案栏遮挡输入框/内容 */
.app-container{
  padding-bottom: var(--icp-footer-height);
}
/* 流式代码块样式 */
.code-block-wrapper.streaming {
  border: 1px dashed var(--border-color);
  opacity: 0.9;
}

.code-block-wrapper.streaming .typing-indicator {
  margin-left: 8px;
  animation: blink 1s infinite;
  font-size: 12px;
}

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

/* 确保代码块内容正确换行 */
.code-block-wrapper pre {
  margin: 0;
  overflow-x: auto;
}

.code-block-wrapper code {
  white-space: pre;
  word-break: normal;
  overflow-wrap: normal;
}

/* 表格样式修复 */
.message-bubble table {
  border-collapse: collapse;
  width: 100%;
  margin: 1em 0;
}

.message-bubble th,
.message-bubble td {
  border: 1px solid var(--border-color);
  padding: 8px 12px;
  text-align: left;
}

.message-bubble th {
  background: var(--bg-secondary);
  font-weight: 600;
}

/* 列表样式 - 移除缩进，以序号层级区分 */
.message-bubble ul,
.message-bubble ol {
  margin: 0.5em 0;
  padding-left: 0.5em; /* 最小缩进，仅让序号符号稍微突出 */
}

.message-bubble li {
  margin: 0.25em 0;
  padding-left: 1.5em; /* 通过padding让内容对齐 */
  position: relative;
}

/* 调整列表序号位置 */
.message-bubble ul {
  list-style-position: inside;
}

.message-bubble ol {
  list-style-position: inside;
}

/* 引用块 */
.message-bubble blockquote {
  margin: 1em 0;
  padding: 0.5em 1em;
  border-left: 4px solid var(--primary-color);
  background: var(--bg-secondary);
}
/* =========================
   打字机光标效果
========================= */
.typewriter-cursor {
    display: inline;
    margin-left: 2px;
}

.typewriter-cursor::after {
    content: '▋';
    animation: blink 0.8s infinite;
    color: var(--accent-color);
    font-weight: normal;
}

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

/* 新字符淡入效果 */
.char-new {
    animation: charFadeIn 0.1s ease-out;
}

@keyframes charFadeIn {
    from { opacity: 0.3; }
    to { opacity: 1; }
}
	/* 代码块复制按钮在 streaming 时隐藏，因为代码还没写完 */
	.streaming .code-copy-btn {
	  display: none;
	}
		/* 消息统计信息（耗时 + Token） */
	.message-stats {
	  font-size: 0.75rem;
	  color: var(--text-secondary, #888);
	  margin-top: 4px;
	  text-align: right;
	  opacity: 0.8;
	  user-select: none;
	}
		/* =========================================
	   最新版：移动端适配 + 标题自动换行 + 隐藏摘要模型
	   ========================================= */
	/* -----------------------
	   第一步：修正层级顺序
	   ----------------------- */
	.site-footer { z-index: 10 !important; }
	.overlay { z-index: 1000 !important; background-color: rgba(0, 0, 0, 0.5) !important; }
	.sidebar { z-index: 1050 !important; }
	.modal { z-index: 1100 !important; }
	/* -----------------------
	   第二步：移动端整体适配
	   ----------------------- */
	@media (max-width: 768px) {
	    /* 1. 侧边栏抽屉效果 */
	    .sidebar {
	        position: fixed !important;
	        top: 0; left: 0; bottom: 0;
	        width: 280px !important;
	        max-width: 85vw !important;
	        transform: translateX(-100%) !important;
	        transition: transform 0.3s ease-in-out !important;
	        box-shadow: 2px 0 15px rgba(0,0,0,0.5) !important;
	    }
	    .sidebar.open { transform: translateX(0) !important; }
	    .mobile-menu-btn { display: flex !important; }
	    /* 2. 聊天头部左移 */
	    .chat-header-left { padding-left: 40px; }
	    /* 3. 【新增】移动端标题自动换行 */
	    /* 强制取消单行限制，允许文字换行显示 */
	    #chatTitle,
	    .chat-header-left h2 {
	        white-space: normal !important;
	        overflow: visible !important;
	        text-overflow: clip !important; /* 移除省略号 */
	        word-wrap: break-word !important; /* 允许长单词断行 */
	        line-height: 1.4 !important; /* 增加行高，多行时更易读 */
	    }
	    /* 调整头部左侧对齐方式，防止标题变多行后错位 */
	    .chat-header-left {
	        align-items: flex-start !important; /* 顶部对齐 */
	        min-width: 0 !important; /* 允许 flex 容器收缩 */
	    }
	    /* 4. 隐藏“摘要模型”选择器 */
	    .model-selector:has(#compressModelSelect) {
	        display: none !important;
	    }
	}
	/* -----------------------
	   第三步：移动端界面净化 (隐藏复杂配置栏)
	   ----------------------- */
	@media (max-width: 768px) {
	    /* 隐藏历史条数栏和自动压缩栏 */
	    .history-bar,
	    .compress-bar {
	        display: none !important;
	    }
	}
/* 厂商配置那一行的按钮组合 */
.input-with-btn {
  display: flex;
  gap: 8px;
  align-items: center;
}

.input-with-btn select {
  flex: 1;
}

/* 统一 + 和 - 按钮的尺寸，使其看起来完全对称 */
.input-with-btn #addProviderBtn, 
.input-with-btn #deleteProviderBtn {
  width: 38px;         /* 固定宽度 */
  height: 38px;        /* 固定高度 */
  padding: 0;          /* 清除内边距，靠 flex 居中 */
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;   /* 放大符号 */
  font-weight: bold;   /* 加粗符号 */
  flex-shrink: 0;      /* 防止被挤压 */
  line-height: 1;
}

.input-with-btn #deleteProviderBtn {
  padding-bottom: 2px; 
}
/* 模型分组显示 */
optgroup {
  background: var(--bg-secondary);
  color: var(--accent-color);
  font-weight: bold;
  font-style: normal;
}
/* 打字机光标样式 */
.typing-cursor {
  display: inline-block;
  width: 2px;
  height: 1.2em;
  background-color: var(--accent-color);
  margin-left: 2px;
  vertical-align: middle;
  animation: blink 0.8s step-end infinite;
}

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

/* Markdown渲染器样式优化 */
.message-bubble strong {
  font-weight: 700;
  color: inherit;
}

.message-bubble ul, 
.message-bubble ol {
  padding-left: 1.5em !important;
  margin: 10px 0 !important;
  list-style-position: outside !important;
}

.message-bubble li {
  margin-bottom: 6px;
  line-height: 1.7;
}

.message-bubble p {
  margin-bottom: 12px;
  line-height: 1.7;
}

.message-bubble p:last-child {
  margin-bottom: 0;
}

/* 确保代码块与文字有足够间距 */
.code-block-wrapper {
  margin: 16px 0 !important;
}

/* 消息泡泡渐入效果 */
.message {
  animation: fadeIn 0.3s ease-out forwards;
}

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

/* 正在生成的泡泡特殊效果 */
.message.generating .message-bubble {
  border-left: 3px solid var(--accent-color);
  transition: all 0.2s ease;
}
/* 思考中的小点动画 */
.message-loading {
  display: flex;
  gap: 4px;
  padding: 8px 0;
}
.message-loading span {
  width: 8px;
  height: 8px;
  background-color: var(--text-muted);
  border-radius: 50%;
  animation: bounce 1.4s ease-in-out infinite;
}
.message-loading span:nth-child(1) { animation-delay: 0s; }
.message-loading span:nth-child(2) { animation-delay: 0.2s; }
.message-loading span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-8px); }
}
/* =========================
   简洁一行式配置栏样式 (修复版)
========================= */
.chat-config-bar {
  width: 100%;          /* 必须：强制铺满父容器宽度 */
  max-width: 800px;     /* 与消息列表和输入框宽度保持一致 */
  margin: 0 auto 12px;  /* 居中并保持底部间距 */
  padding: 8px 0;       /* 移除左右内边距，靠 margin 居中 */
  
  display: flex;
  align-items: center;
  justify-content: flex-start; /* 靠左排列 */
  gap: 12px;            /* 适当缩减间距防止溢出 */
  
  font-size: 0.85rem;
  color: var(--text-secondary);
  flex-wrap: nowrap;    /* 电脑端禁止换行，保持一行 */
  overflow-x: auto;     /* 万一屏幕太窄，允许横向滚动而不是挤压布局 */
}

.config-item {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;       /* 防止文字被挤压换行 */
}

/* 复选框与文字组合 */
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  color: var(--text-primary);
  font-weight: 500;
  white-space: nowrap;
}

/* 下划线输入框 */
.inline-input {
  border: none;
  border-bottom: 1px solid var(--border-color);
  background: transparent !important;
  text-align: center;
  padding: 0 2px;
  height: 22px;
  font-size: 0.85rem;
  color: var(--accent-color);
  transition: border-color 0.2s;
  font-family: inherit;
}

.inline-input:focus {
  outline: none;
  border-bottom-color: var(--accent-color);
}

.inline-input:disabled {
  color: var(--text-muted);
  border-bottom-style: dashed;
  cursor: not-allowed;
}

/* 分割竖线 */
.config-divider {
  width: 1px;
  height: 14px;
  background-color: var(--border-color);
  margin: 0 4px;
  flex-shrink: 0;
}

/* 移动端适配：仅在小屏幕允许换行 */
@media (max-width: 768px) {
  .chat-config-bar {
    max-width: 100%;
    padding: 8px 15px;
    flex-wrap: wrap; /* 手机端允许换行 */
    gap: 10px;
  }
  .config-divider {
    display: none; /* 手机端隐藏分割线 */
  }
}

/* 移动端隐藏会话配置栏*/
@media (max-width: 768px) {
  .chat-config-bar {
    display: none !important; /* 在屏幕宽度小于 768px 时彻底隐藏 */
  }
}

/* 设置页面：删除厂商按钮红色样式 */
#deleteProviderBtn {
  background-color: var(--danger-color) !important; /* 使用全局定义的红色变量 */
  color: #ffffff !important; /* 文字（减号）设为白色 */
  border: none !important;
  transition: opacity 0.2s;
}

#deleteProviderBtn:hover {
  background-color: #b91c1c !important; /* 悬停时颜色稍微加深 */
  opacity: 0.9;
}

/* 保持加号按钮为原色，但确保它们高度一致 */
#addProviderBtn {
  background-color: var(--accent-color);
  color: #ffffff;
  border: none;
}

#addProviderBtn:hover {
  background-color: var(--accent-hover);
}
/*搜索按钮*/
.search-toggle-btn {
  flex: 0 0 auto;
  padding: 10px;
  border-radius: 8px;
  min-width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.search-toggle-btn.active {
  background-color: var(--accent-color) !important;
  color: white !important;
  border-color: var(--accent-color) !important;
}

.search-toggle-btn:hover {
  background-color: var(--bg-tertiary);
}
/* 工具栏布局 */
.input-toolbar {
  display: flex;
  justify-content: space-between; /* 左右分布 */
  align-items: center;
  padding-top: 4px;
}

.toolbar-left button {
  width: 38px !important;           /* 强制固定宽度 */
  height: 38px !important;          /* 强制固定高度 */
  min-width: 38px !important;       /* 防止被挤压 */
  padding: 0 !important;            /* 移除内边距干扰 */
  
  display: inline-flex !important;  /* 使用 flex 居中图标 */
  align-items: center;
  justify-content: center;
  
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text-secondary);
}
.toolbar-left button svg {
  width: 20px;
  height: 20px;
  display: block;
}

.attach-btn-secondary, .search-toggle-btn, .markdown-toggle-btn {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  width: 38px;
  height: 38px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
}

.markdown-toggle-btn.active {
  background-color: var(--accent-color) !important;
  color: white !important;
  border-color: var(--accent-color) !important;
}

/* 知识库按钮激活样式 */
.kb-toggle-btn.active {
  background-color: var(--accent-color) !important;
  color: white !important;
  border-color: var(--accent-color) !important;
}

/* 知识库多选面板 */
.kb-selector-wrapper {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.kb-dropdown-panel {
  display: none;
  position: absolute;
  bottom: 100%;
  left: 0;
  width: 220px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: 0 -4px 12px rgba(0,0,0,0.15); /* 向上投影 */
  z-index: 10000; /* 确保在最顶层 */
  margin-bottom: 10px;
  padding: 8px;
  max-height: 300px;
  overflow-y: auto;
}

/* 关键修复：当面板激活时，允许父容器溢出显示 */
.chat-config-bar:has(.kb-dropdown-panel.active) {
  overflow: visible !important;
}

.kb-dropdown-panel.active {
  display: block;
}

.kb-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  cursor: pointer;
  border-radius: 4px;
}

.kb-option:hover {
  background: var(--bg-secondary);
}

.kb-option input {
  cursor: pointer;
}

#messagePreview {
  width: 100%;
  border: none !important;
  background: transparent !important;
  padding: 8px 4px;
  font-size: 1rem;
  max-height: 200px;
  overflow-y: auto;
}

/* 发送按钮美化 */
#sendBtn {
  padding: 8px 16px;
  height: 38px;
  cursor: pointer !important;
  display: flex;
  align-items: center;
  justify-content: center;
}

#sendBtn span {
  margin-right: 6px;
}

#sendBtn svg {
  display: block;
  width: 18px;
  height: 18px;
}

/* 停止按钮样式 */
.btn-stop {
  background-color: #dc2626 !important;
  color: #fff !important;
  border-color: #dc2626 !important;
  cursor: pointer !important;
}

.btn-stop:hover {
  background-color: #b91c1c !important;
  border-color: #b91c1c !important;
}

/* 停止按钮圆圈旋转动画 */
.btn-stop .stop-circle {
  animation: rotate 2s linear infinite;
  transform-origin: 12px 12px; /* 确保围绕圆心旋转 */
}

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

/* =========================
   移动端适配优化
========================= */
@media (max-width: 768px) {
  .input-area {
    padding: 10px; /* 减小外边距 */
  }
  
  .input-wrapper {
    padding: 8px;
    border-radius: 12px; /* 手机端圆角大一点更好看 */
  }

  #sendBtn span {
    display: none; /* 手机端隐藏“发送”文字，只留图标，节省空间 */
  }
  
  #sendBtn {
    width: 42px; /* 手机端发送按钮变方 */
    padding: 0;
  }

  /* 移动端隐藏知识库切换按钮 */
  #kbToggleBtn {
    display: none !important;
  }
}
/* =========================
   右上角帮助下拉菜单
========================= */
.info-dropdown {
  position: relative;
  display: inline-block;
  margin-left: 8px;
}

.info-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 38px; 
  padding: 0 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px; /* 与附件按钮圆角一致 */
  color: var(--text-primary);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}

/* 确保图标颜色和粗细感一致 */
.info-btn svg {
  flex-shrink: 0;
  color: var(--text-secondary);
}

.info-btn:hover svg {
  color: var(--accent-color);
}

.info-btn:hover {
  background: var(--bg-tertiary);
  border-color: var(--accent-color);
}

/* 下拉面板 */
.dropdown-panel {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  width: 220px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 12px;
  z-index: 5000;
  margin-top: 8px;
}

/* 悬停显示逻辑 */
.info-dropdown:hover .dropdown-panel {
  display: block;
}

/* 补齐悬停间隙，防止鼠标滑向面板时消失 */
.info-dropdown::after {
  content: "";
  position: absolute;
  top: 100%;
  right: 0;
  width: 100%;
  height: 10px;
}

/* 指南超链接样式 */
.guide-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px;
  background: var(--bg-secondary);
  border-radius: 8px;
  color: var(--accent-color);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 12px;
  transition: background 0.2s;
}

.guide-link:hover {
  background: var(--bg-tertiary);
  text-decoration: underline;
}

/* 二维码样式 */
.qr-section {
  text-align: center;
  padding-top: 8px;
  border-top: 1px dashed var(--border-color);
}

.qr-section img {
  width: 140px;
  height: 140px;
  border-radius: 6px;
  margin-bottom: 8px;
}

.qr-section p {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin: 2px 0;
}

/* 移动端适配 */
@media (max-width: 768px) {
  .info-btn span { display: none; }
  .dropdown-panel { width: 180px; }
}
/* =========================================
   关于/帮助按钮的跨端适配逻辑
   ========================================= */

/* 1. 默认样式：隐藏侧边栏里的“关于”横栏（PC端不显示） */
.about-row {
  display: none !important;
}

/* 2. 移动端适配 (宽度小于 768px) */
@media (max-width: 768px) {
  
  /* 隐藏右上角的“帮助”下拉菜单 */
  .info-dropdown {
    display: none !important;
  }

  /* 显示侧边栏底部的“关于”横栏 */
  .about-row {
    display: flex !important;
    width: 100%;
    margin-bottom: 4px;
  }

  /* 美化侧边栏“关于”横栏 */
  .about-link-bar {
    width: 100%;
    flex: 1;
    background-color: var(--bg-tertiary) !important;
    color: var(--accent-color) !important; /* 使用主题色突出 */
    font-weight: 500;
    border: 1px solid var(--border-color);
    padding: 10px 0 !important;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
  }

  .about-link-bar:hover {
    background-color: var(--border-color) !important;
  }
/*Markdown格式调整*/
  /* 确保列表有缩进和正确的符号 */
.message-bubble ul.markdown-list, 
.message-bubble ol.markdown-list {
    margin: 10px 0 10px 0 !important;
    padding-left: 1.2em !important; /* 减少缩进，主要由序号/符号决定层级 */
    list-style-position: outside !important; /* 序号显示在列表外部 */
    text-indent: 0 !important; /* 确保文本不缩进 */
}

.message-bubble ul.markdown-list {
    list-style-type: disc !important; /* 显示圆点 */
}

.message-bubble ol.markdown-list {
    list-style-type: decimal !important; /* 显示数字 1. 2. 3. */
    padding-left: 2.5em !important; /* 有序列表需要更多空间来显示多位数序号 */
    /* 移除 counter-reset，让浏览器自动处理有序列表编号 */
}

.message-bubble ol.markdown-list li {
    margin-bottom: 5px;
    line-height: 1.6;
    display: list-item !important; /* 确保它是列表项模式 */
    padding-left: 0 !important; /* 有序列表项不需要额外的左边距 */
}

.message-bubble ul.markdown-list li {
    margin-bottom: 5px;
    line-height: 1.6;
    display: list-item !important; /* 确保它是列表项模式 */
    padding-left: 0 !important; /* 无序列表项不需要额外的左边距 */
}
/* 聊天气泡内的分割线 */
.message-bubble hr {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 15px 0;
    opacity: 0.5;
}
.message-bubble {
    /* 允许通过 CSS 稍微美化引用标注，但不改变其内容 */
}
.message-bubble p {
    /* 这里保持默认，由 AI 生成内容 */
}


/* 暗色模式适配 */
[data-theme="dark"] .message-bubble hr {
    border-top: 1px solid #444;
}

#backgroundContent {
  width: 100%;
  min-height: 200px;
  padding: 12px;
  font-size: 0.95rem;
  line-height: 1.6;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-family: inherit;
  resize: vertical;
}

#backgroundContent:focus {
  outline: none;
  border-color: var(--accent-color);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}
/* 数学公式容器样式 */
.katex-block-wrapper {
  overflow-x: auto;
  overflow-y: hidden;
  padding: 10px 0;
  margin: 10px 0;
  text-align: center;
}

.katex-display {
  margin: 0 !important;
  display: inline-block;
  min-width: 100%;
}

/* 错误公式显示样式 */
.katex-error {
  color: var(--danger-color);
  background: rgba(220, 38, 38, 0.1);
  padding: 2px 4px;
  border-radius: 4px;
  font-family: monospace;
}