       /* 全局样式 - 针对移动端全面优化 */
        * {
            box-sizing: border-box;
            -webkit-tap-highlight-color: transparent;
        }
        
        body {
            font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
            margin: 0;
            padding: 0;
            background-color: #f5f5f5;
            color: #333;
            width: 100vw;
            height: 100vh;
            height: -webkit-fill-available;
            overflow: hidden;
            position: fixed;
            display: flex;
            justify-content: center;
        }

        .container {
            display: flex;
            width: 100%;
            height: 100%;
            background-color: #fff;
            position: relative;
        }

        /* 左侧栏优化 */
        .sidebar {
            width: 250px;
            height: 100%;
            position: fixed;
            left: 0;
            top: 0;
            background-color: #f9fbff;
            color: #000000;
            padding: 20px;
            box-shadow: 2px 0 5px rgba(0, 0, 0, 0.1);
            transform: translateX(-100%);
            transition: transform 0.3s ease;
            z-index: 100;
            overflow-y: auto;
            -webkit-overflow-scrolling: touch;
        }

        .sidebar.active {
            transform: translateX(0);
        }

        .sidebar h2 {
            margin-top: 0;
            font-size: 1.2rem;
            text-align: center;
            width: 100%;
        }

        .sidebar-buttons {
            display: flex;
            gap: 10px;
            margin-bottom: 15px;
        }

        .sidebar button {
            width: 100%;
            padding: 10px;
            background-color: #3498db;
            color: #fff;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            font-size: 0.9rem;
        }

        #clear-history {
            background-color: #e74c3c;
        }

        #history {
            list-style: none;
            padding: 0;
            margin: 0;
        }

        #history li {
            padding: 12px 10px;
            cursor: pointer;
            border-radius: 5px;
            margin-bottom: 5px;
            background-color: #dbe4ef;
            font-size: 0.9rem;
            transition: background 0.2s;
        }

        /* 主内容区域 */
        .main {
            flex: 1;
            display: flex;
            flex-direction: column;
            height: 100%;
            width: 100%;
            position: relative;
            transition: margin-left 0.3s ease;
        }

        .sidebar.active + .main {
            margin-left: 250px;
        }

        /* 顶部导航栏 */
.chat-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    padding: 10px 20px;
    background-color: #f9fbff;
    border-bottom: 1px solid #ddd;
    gap: 10px;
    position: sticky;
    top: 0;
    z-index: 99;
}

        .chat-header .essential {
            display: flex;
            align-items: center;
        }
        .chat-header p {
            margin: 0;
            display: flex;
            align-items: center;
        }
        .chat-header select {
            margin-left: 5px;
            padding: 5px 8px;
            border: 1px solid #ddd;
            border-radius: 5px;
            max-width: 150px;
            font-size: 0.9rem;
        }

        #connection-status {
            display: flex;
            align-items: center;
        }

        .status-dot {
            width: 10px;
            height: 10px;
            border-radius: 50%;
            margin-right: 5px;
        }

        .status-dot.online {
            background-color: #2ecc71;
        }
        
        .status-dot.offline {
            background-color: #e74c3c;
        }

        #refresh-models {
            padding: 5px 10px;
            background-color: #3498db;
            color: #fff;
            border: none;
            border-radius: 5px;
            cursor: pointer;
        }

        #refresh-models:hover {
            background-color: #2980b9;
        }
        /* 聊天内容区域 */
        #chat-output {
            flex: 1;
            overflow-y: auto;
            width: 960px;
            margin: 0 auto;
            -webkit-overflow-scrolling: touch;
            padding: 20px;
            padding-bottom: 80px;
        }
        .tips, .xtip {
          position: relative;
          text-align: center; /* 水平居中 */
          margin: 0 auto; /* 水平居中 */
          width: fit-content; /* 根据内容宽度自适应 */
                  max-width: 80%; /* 防止过宽 */
          padding: 10px 20px; /* 内边距 */
        }

        .tips {
          font-size: 18px; /* 大字体 */
          margin-top: 20vh; /* 从视口顶部20%开始 */
          margin-bottom: 10px; /* 与xtip的间距 */
          font-weight: bold;
        }

        .xtip {
          font-size: 14px; /* 较小字体 */
          color: #666; /* 次级文本颜色 */
        }
         .user-message, .assistant-message {
            margin-bottom: 15px;
            padding: 10px;
            border-radius: 5px;
            max-width: 80%;
        }

        /* 用户消息样式 */
        .user-message {
            max-width: 80%;
            width: fit-content;
            margin-left: auto;
            padding: 10px 15px;
            background: #e3f2fd;
            border-radius: 18px;
            word-break: break-word;
            white-space: pre-wrap;
        }

        /* 助手消息样式 */
        .assistant-message {
            max-width: 100%;
            /*width: fit-content;*/
            margin-right: auto;
            padding: 10px 15px;
            border-radius: 18px;
            word-break: break-word;
            margin-bottom: 10px;
            white-space: pre-wrap;
        }

        .model-name {
            font-size: 0.8em;
            color: #777;
            margin-bottom: 5px;
        }

        /* 思考内容样式 */
        think {
            display: block;
            background-color: #f8f9fa;
            border-left: 4px solid #34a853;
            padding: 1em;
            margin: 1em 0;
            color: #5f6368;
            font-size: 0.9em;
        }

        .thinking {
            font-size: 0.8em;
            color: #777;
            margin-bottom: 5px;
        }

        /* 代码头部 */
        .code-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 4px 10px;
            background-color: #50505a;
            color: #e0e0e0;
            font-family: Consolas, monospace;
            font-size: 14px;
            border-bottom: 1px solid #333;
            margin: 0 !important;
        }

        /* 代码块容器 */
        .code-block {
            background-color: #181d28;
            border-radius: 10px;
            margin: 10px 0;
            overflow: hidden;
            border: 1px solid #333;
            display: flex;
            flex-direction: column;
        }
        /* 代码块安全防护 */
        .code-block[data-safe-render] pre {
          background: #f5f5f5;
          padding: 1em;
          border-radius: 4px;
          overflow-x: auto;
        }

        /* 关键安全规则：禁用代码内HTML解析 */
        .code-block[data-safe-render] code * {
          all: unset !important;
          display: inline !important;
          pointer-events: none !important;
        }

        /* 代码内容区域 */
        .code-block pre {
            margin: 0 !important;
            padding: 2px;
            background-color: #181d28 !important;
            overflow-x: auto;
            line-height: 1.4;
            border-top: none;
        }
         
        /* Highlight.js 基础样式 */
        .hljs {
            display: block;
            overflow-x: auto;
            background: #181d28 !important;
            color: #e0e0e0 !important;
        }

        /* 语法高亮颜色配置 */
        .hljs-keyword,
        .hljs-literal,
        .hljs-name,
        .hljs-selector-tag { 
            color: #569cd6 !important;
        }

        .hljs-string { 
            color: #ce9178 !important;
        }

        .hljs-title,
        .hljs-section,
        .hljs-attribute { 
            color: #dcdcaa !important;
        }

        .hljs-number { 
            color: #b5cea8 !important;
        }

        .hljs-comment { 
            color: #7e817c !important;
        }

        .hljs-meta { 
            color: #9cdcfe !important;
        }

        .hljs-variable,
        .hljs-template-variable { 
            color: #9cdcfe !important;
        }

        .hljs-built_in,
        .hljs-builtin-name { 
            color: #4ec9b0 !important;
        }

        .hljs-subst { 
            color: #9cdcfe !important;
        }

        .hljs-regexp { 
            color: #509bf1 !important;
        }

        /* PHP专用样式 */
        .language-php .hljs-meta {
            color: #569cd6 !important;
        }

        /* 复制按钮样式 */
        .copy-btn {
            background-color: #3498db;
            color: #fff;
            border: none;
            border-radius: 3px;
            padding: 5px 10px;
            cursor: pointer;
            font-size: 12px;
            transition: background 0.2s;
        }

        .copy-btn:hover {
            background-color: #2980b9;
        }

        /* 保证代码字体和间距 */
        pre code {
            font-family: Consolas, Monaco, 'Andale Mono', monospace;
            font-size: 14px;
            white-space: pre;
            word-spacing: normal;
            word-break: normal;
            line-height: 1.5;
            tab-size: 4;
            hyphens: none;
        }
        /* 输入区域 - 固定在底部 */
.input-area {
    bottom: 0;
    left: 0;
    right: 0;
    background: #f5f5f5;
    padding: 10px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
    border: 1px solid #ddd;
    z-index: 100;
    display: flex;
   /* align-items: flex-end;*/
    border-radius: 20px;
    width: 960px;
    flex-direction: column;
    margin: 0 auto;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.05); /* 添加上方阴影作为边界 */
}

.btnmg {
  display: flex;
  justify-content: space-between; /* 关键：左右两端对齐 */
  width: 100%; /* 确保占满父容器 */
}

.left-group, .right-group {
  display: flex;
}
   
.aitips {
    margin: 0 auto;
    text-align: center;
    color: #cacdcd;
    margin-top: 6px;
    margin-bottom: 6px;
    width: fit-content;
    line-height: 16px;
    font-size: 12px;  
}

        #user-input {
            flex: 1;
            min-height: 80px;
            max-height: 200px;
            padding: 10px 15px;
            background-color: #f5f5f5;
            border: none;
            outline: none;
            resize: none;
            font-size: 1rem;
            line-height: 1.5;
        }
        
        /* 空状态样式 */
        #user-input[data-empty="true"] {
          color: transparent; 
        }
        
        #user-input[data-empty="true"]::placeholder {
          color: #999; 
        }
        
        #send-btn {
            margin-left: 5px;
            padding: 4px 20px;
            background-color: #f9fbff;
            color: #6790e3;
            border: 1px solid #95b4f1;
            border-radius: 22px;
            cursor: pointer;
            flex-shrink: 0;
        }
        
        .gray { filter: grayscale(100%); }
        #search-btn,#sd-btn { box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05); }   

        #send-btn.stop {
            background-color: #fff;
        }

        #send-btn.stop:hover {
            background-color: #6790e3;
        }

        /* 确保有以下样式 */
        #search-btn.active {
            background-color: #f9fbff !important;
            color: #6790e3 !important;
            border-color: #95b4f1 !important;
        }

        #search-btn[data-active="true"] {
            box-shadow: 0 0 8px #f9fbff;;
        }
        
        #sd-btn.active {
            background-color: #f9fbff !important;
            color: #6790e3 !important;
            border-color: #95b4f1 !important;
        }

        #sd-btn[data-active="true"] {
            box-shadow: 0 0 8px #f9fbff;;
        }

        #search-btn, #sd-btn {
            margin-left: 5px;
            padding: 4px 8px;
            background-color: #fff;
            color: #000;
            border: 1px solid #ddd;
            border-radius: 22px;
            cursor: pointer;
            white-space: nowrap;
        }
        
        #file-btn {
            margin-left: 10px;
            padding: 4px 8px;
            background-color: #f9fbff;
            color: #6790e3;
            border: 1px solid #95b4f1;
            border-radius: 22px;
            cursor: pointer;
            white-space: nowrap;
        }

      
       /* 内容行基础样式 */
        .content-line {
          line-height: 1.6;
          color: #777575;
         /* font-size: .9em;*/
        }

        /* 列表项特殊样式 */
        .content-line.is-list {
          position: relative;
          padding-left: 2em;
          text-indent: -1em;
        }

        /* 行内代码 */
        .inline-code {
          font-family: SFMono-Regular, Menlo, Monaco, Consolas, monospace;
          background: rgba(31, 32, 33, 0.2);
          padding: 0.2em 0.4em;
          border-radius: 3px;
          font-size: 1em;
          font-weight: 600;
          color: #24292e;
        }

        /* 标题样式 */
        h3 { font-size: 1.4em; margin: 1.8em 0 1em; }
        h4 { font-size: 1.2em; margin: 1.5em 0 0.8em; }
        h5 { font-size: 1.1em; margin: 1.2em 0 0.6em; }

        /* 加粗文本样式 */
        strong {
            font-weight: bold;
        }

        pre {
            margin: 1em 0;
            padding: 1em;
            background: #f5f5f5;
        }
.menu-toggle {
  /* 基础样式 */
  position: fixed;
  left: 12px;
  top: 12px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #3498db;
  border: none;
  cursor: pointer;
  z-index: 101;
  padding: 8px; /* 控制SVG周围空间 */
  
  /* 弹性布局确保SVG居中 */
  display: flex;
  align-items: center;
  justify-content: center;
  
  /* 交互效果 */
  transition: all 0.3s ease;
}

/* 鼠标悬停效果 */
.menu-toggle:hover {
  background: #2980b9;
  transform: scale(1.05);
}

/* 点击效果 */
.menu-toggle:active {
  transform: scale(0.95);
}

/* SVG样式控制 */
.menu-toggle svg {
  width: 24px;  /* 与viewBox保持一致 */
  height: 24px;
  display: block;
}

/* Safari特殊优化 */
@supports (-webkit-touch-callout: none) {
  .menu-toggle {
    -webkit-tap-highlight-color: transparent; /* 移除点击高光 */
  }
  .menu-toggle svg {
    margin-top: 1px; /* Safari微调 */
  }
}

/* 深色模式适配 */
@media (prefers-color-scheme: dark) {
  .menu-toggle {
    background: #1e88e5;
  }
  .menu-toggle svg path {
    fill: #f5f5f5;
  }
}
.menu-toggle svg {
  width: 24px;
  height: 24px;
}
.menu-toggle svg path {
  stroke: white;
  stroke-width: 8;
  stroke-linecap: round;
  transition: all 0.3s;
}
/* 动画效果 */
.menu-toggle.active .top {
  transform: translateY(12px) rotate(45deg);
}
.menu-toggle.active .bottom {
  transform: translateY(-12px) rotate(-45deg);
}
.menu-toggle.active .middle {
  opacity: 0;
}

        /* 响应式设计 */
@media (min-width: 992px) {
    .sidebar {
        position: relative;
        transform: translateX(0) !important; /* 强制显示 */
        display: block !important;
    }
    
    .main {
        width: calc(100% - 250px);
        /*margin-left: 250px !important;*/
    }
    
    /* 确保菜单按钮在PC端隐藏 */
    .menu-toggle {
        display: none !important;
    }
}

@media (max-width: 991px) {
    .menu-toggle {
        display: flex; /* 只在移动端显示 */
    }
    
    /* 移动端默认隐藏侧边栏 */
    .sidebar {
        transform: translateX(-100%);
    }
    
    /* 移动端展开时显示侧边栏 */
    .sidebar.active {
        transform: translateX(0);
    }
    
    .chat-header {
        overflow-x: auto;
        padding: 18px 60px;
    }

    /* 模型信息容器 */
    .chat-header .essential {
        flex: 0 0 auto; /* 禁止伸缩 */
        margin-right: 15px;
    }

    /* 隐藏非必要元素 */
    .chat-header .non-essential {
        display: none;
    }

    /* 选择框样式调整 */
    .chat-header select {
        max-width: 120px;
        font-size: 0.9rem;
    }
    
}

        @media (max-width: 576px) {
            .sidebar {
                width: 85%;
            }
            
            .sidebar.active ~ .main {
                margin-left: 85%;
            }
            
            .sidebar.active ~ .main .menu-toggle {
                left: calc(85% + 12px);
            }
            
.chat-header {
  display: flex;               /* 保持flex布局 */
  justify-content: flex-start; /* 左对齐 */
  align-items: center; /* 新增：垂直居中对齐所有子项 */
  padding: 18px 60px;         /* 保持原有内边距 */
  overflow-x: auto;           /* 允许横向滚动 */
  white-space: nowrap;        /* 禁止换行 */
  width: 100%;               /* 确保宽度撑满 */
  min-width: max-content;    /* 关键修复：让容器最小宽度适应内容 */
  flex-wrap: nowrap;         /* 禁止flex项换行 */
  align-items: center;       /* 垂直居中 */
}

.chat-header .essential {
   display: flex; 
  margin-right: 10px;
  flex-shrink: 0;           /* 禁止flex项收缩 */
  align-items: center; /* 新增：垂直居中对齐所有子项 */
}

.chat-header select {
  max-width: 100px;
  flex-shrink: 0;           /* 禁止select收缩 */
  align-items: center; /* 新增：垂直居中对齐所有子项 */
}
            
    #user-input {
                width: 100%;
                min-height: 80px;
     }
     
    #chat-output {
            flex: 1;
            overflow-y: auto;
            width: 100%;
            -webkit-overflow-scrolling: touch;
            padding: 20px;
            padding-bottom: 80px;
    }  
    
.input-area {
    bottom: 0;
    left: 0;
    right: 0;
    background: #f5f5f5;
    padding: 10px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
    border: 1px solid #ddd;
    z-index: 100;
    display: flex;
    align-items: flex-end;
    border-radius: 20px;
    max-width: 95%;
    margin: 0 auto;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.05); /* 添加上方阴影作为边界 */
    } 
            
            
     }

        /* Safari专属优化 */
        @supports (-webkit-touch-callout: none) {
            .menu-toggle {
                top: 15px;
                font-size: 26px;
            }
            
            #user-input {
                border-radius: 22px;
            }
        }
        

/* ===== 模型名称 ===== */
.assistant-message .model-name {
    display: block !important;
    color: #666;
    font-size: 0.9em;
    margin: 0 0 6px 0;
    padding: 0;
    opacity: 1 !important;
    visibility: visible !important;
    line-height: 1.3;
}

/* ===== 消息内容容器 ===== */
.assistant-message .message-content {
    line-height: 1.6;
    padding-bottom: 0; /* 由父容器统一控制间距 */
}

/* ===== 操作按钮 ===== */
.assistant-message {
    position: relative;
    padding-bottom: 32px; /* 预留按钮空间 */
}

.message-actions {
    position: absolute;
    bottom: -10px;
    left: 10px;
    display: flex;
    gap: 8px;
    opacity: 1 !important;
    visibility: visible !important;
}

/* 按钮样式增强 */
.message-actions .action-btn {
    display: inline-flex !important;
    align-items: center;
    padding: 4px 10px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s;
}

.message-actions .action-btn:hover {
    background: rgba(0, 0, 0, 0.1);
}

/* ===== 流式状态处理 ===== */
.assistant-message.streaming {
    padding-bottom: 0; /* 流式时不需要按钮空间 */
}

.assistant-message.streaming .message-actions {
    display: none !important;
}
/* 按钮样式 */
.action-btn {
    padding: 5px 12px;
    border: 1px solid #e0e0e0;
    border-radius: 16px;
    background: white;
    font-size: 13px;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    transition: all 0.2s;
}

.action-btn:hover {
    background: #f5f5f5;
    transform: translateY(-1px);
}

/* 移动端适配 */
@media (max-width: 768px) {
    .message-actions {
        margin-top: 8px;
        padding: 8px 0;
    }
    
    .action-btn {
        flex: 1;
        text-align: center;
    }
}

/* 提示消息 */
.toast-message {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.8);
    color: white;
    padding: 8px 16px;
    border-radius: 4px;
    z-index: 1000;
    animation: fadeInOut 2s forwards;
}

@keyframes fadeInOut {
    0%,100% { opacity: 0; }
    20%,80% { opacity: 1; }
}


.assistant-message .message-actions {
    display: flex !important;
    opacity: 1 !important;
}

/* 文件预览区 */
#file-previews {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
  padding: 10px;
  background: #f8f9fa;
  border-radius: 8px;
}

.file-preview {
  display: flex;
  align-items: center;
  padding: 6px 10px;
  background: white;
  border-radius: 16px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.file-preview img {
  width: 16px;
  height: 16px;
  object-fit: cover;
  margin-right: 6px;
}

.remove-btn {
  margin-left: 6px;
  background: none;
  border: none;
  color: #999;
  cursor: pointer;
}

/* 消息中的文件标记 */
.message-file-ref {
  display: inline-block;
  margin-left: 6px;
  color: #666;
  font-size: 0.9em;
}