html, body { height: 100%; }
* { box-sizing: border-box; }
body {
  margin: 0;
  background: #f5f7fa;
  color: #333;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif;
}

.assistant-app { display: flex; flex-direction: column; width: 100%; height: 100vh; overflow: hidden; padding-top: 65px; }

.assistant-app.intro-mode {
  overflow-y: auto;
  align-items: center;
}

.assistant-app.chat-active {
  flex-direction: row;
}

/* 侧边栏样式 */
.chat-sidebar {
  width: 260px;
  background: #f8fafc;
  border-right: 1px solid #e2e8f0;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: transform 0.3s ease;
}

.sidebar-header {
  padding: 20px;
}

.new-chat-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  color: #334155;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.new-chat-btn:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

.history-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 10px 20px;
}

.history-item {
  padding: 10px 12px;
  margin-bottom: 4px;
  border-radius: 8px;
  color: #475569;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background 0.2s;
}

.history-item:hover {
  background: #e2e8f0;
}

.history-item.active {
  background: #dbeafe;
  color: #0080ff;
}

.sidebar-footer {
  padding: 20px;
  border-top: 1px solid #e2e8f0;
}

.clear-history-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px;
  background: transparent;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  color: #64748b;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
}

.clear-history-btn:hover {
  background: #fee2e2;
  border-color: #fecaca;
  color: #ef4444;
}

/* 主内容区样式 */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: calc(100vh - 65px); /* 减去头部高度 */
  overflow: hidden; /* 隐藏溢出内容 */
  position: relative;
  min-width: 0;
  box-sizing: border-box;
}

.assistant-hero { margin-top: 120px; text-align: center; transition: all 0.3s ease; width: 100%; }
.assistant-logo { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 10px; background: #dbeafe; color: #0080ff; margin-bottom: 12px; } /* 蓝色 Logo 背景和图标 */
.assistant-title { font-size: 36px; font-weight: 800; color: #007aff; margin: 8px 0 10px; letter-spacing: .5px; } /* 深蓝标题 */
.hero-subtitle { font-size: 16px; color: #475569; margin: 20px auto; max-width: 760px; } /* 蓝灰副标题 */
.hero-gradient { position: relative; padding: 40px 20px; }
.hero-content { max-width: 1200px; margin: 0 auto; }
.hero-bullets { list-style: none; padding: 0; margin: 16px auto 18px; display: grid; gap: 10px; max-width: 860px; }
.hero-bullets li { background: #ffffff; border: 1px solid #bfdbfe; border-radius: 12px; padding: 10px 14px; font-size: 14px; box-shadow: 0 6px 18px rgba(0, 128, 255, 0.06); } /* 蓝色边框和阴影 */
.hero-tags { display: inline-flex; gap: 10px; margin-top: 10px; }
.tag { display: inline-flex; align-items: center; padding: 8px 12px; border-radius: 999px; border: 1px solid #bfdbfe; background: #fff; color: #1e40af; font-size: 13px; }
.tag-primary { background: #dbeafe; border-color: #93c5fd; color: #1d4ed8; }

.assistant-input-area { width: 100%; max-width: 800px; margin-top: 35px; transition: all 0.3s ease; }
.input-bar { position: relative; display: flex; align-items: flex-start; flex-wrap: wrap; gap: 12px; background: #fff; border: 1px solid #bfdbfe; box-shadow: 0 12px 28px rgba(0, 128, 255, 0.06); border-radius: 24px; padding: 20px; min-height: 100px; } /* 蓝色边框和阴影 */

.input-chips { order: 2; width: auto; display: flex; gap: 10px; margin-top: 8px; margin-right: 0; flex-shrink: 0; }
.chip-btn { appearance: none; -webkit-appearance: none; padding: 10px 14px; border-radius: 999px; border: 1px solid #cccccc; background: #ffffff; color: #000; font-size: 14px; display: inline-flex; align-items: center; gap: 6px; cursor: pointer; } /* 蓝色 chip */
.chip-btn .chip-icon { width: 18px; height: 18px; stroke: #000; fill: none; }
/*.chip-btn.active { background: #dbeafe; border-color: #93c5fd; color: #1d4ed8; }*/
.chip-btn.active { background: #eff6ff; border-color: #dbeafe; color: #0080ff; }
/*.chip-btn.active .chip-icon { stroke: #1d4ed8; }*/
.chip-btn.active .chip-icon { stroke: #0080ff; }

.input-textarea { flex: 1 1 100%; width: 100%; border: none; outline: none; font-size: 18px; line-height: 26px; padding: 10px 0; resize: none; max-height: 220px;}
.input-textarea::placeholder { color: #94a3b8; }

.input-actions { order: 2; position: relative; right: auto; top: auto; bottom: auto; transform: none; margin-left: auto; display: inline-flex; align-items: center; gap: 10px; margin-top: 8px;}
.icon-btn { width: 32px; height: 32px; border: none; background: transparent; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.icon-btn:hover { background: #eff6ff; }

.send-circle { width: 40px; height: 40px; border-radius: 999px; border: none; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; background: #0080ff; box-shadow: 0 10px 20px rgba(0, 128, 255, 0.25); } /* 蓝色发送按钮 */
.send-circle:disabled { opacity: 0.6; cursor: not-allowed; }

/* 消息区 */
.messages-section { width: 100%; padding: 0 24px 40px; }
.hidden { display: none; }

.chat-messages { 
  margin-top: 8px; 
  background: #fff; 
  border: 1px solid #bfdbfe; 
  border-radius: 16px; 
  padding: 20px; 
  min-height: 100%;
  overflow: visible;
  /* 移除可能引起问题的transform */
  will-change: scroll-position;
}
.message { display: flex; gap: 12px; margin-bottom: 24px; opacity: 0; animation: fadeIn 0.3s forwards; }
@keyframes fadeIn { to { opacity: 1; } }

.message .avatar { width: 36px; height: 36px; border-radius: 50%; background: #0080ff; color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 600; flex-shrink: 0; } /* 蓝色 AI 头像 */
.message.sent { flex-direction: row-reverse; }
.message.sent .avatar { background: #3b82f6; }

.message .content { display: flex; flex-direction: column; max-width: 80%; }
.message.sent .content { align-items: flex-end; }

.message .text { 
  padding: 12px 16px; 
  border-radius: 12px; 
  line-height: 1.6; 
  font-size: 16px; 
  word-break: break-word;
  /* 优化渲染性能 */
  will-change: contents;
  transform: translateZ(0);
  backface-visibility: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
.message.received .text { background: #eff6ff; border: 1px solid #bfdbfe; border-top-left-radius: 2px; }
.message.sent .text { background: #0080ff; color: #fff; border-top-right-radius: 2px; }
.message .time { font-size: 12px; color: #94a3b8; margin-top: 4px; }

/* 复制功能样式 */
.message-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

.copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  background: transparent;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  color: #64748b;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.copy-btn:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: #0080FF;
}

.copy-btn.copied {
  background: #dcfce7;
  border-color: #86efac;
  color: #16a34a;
}

.copy-icon {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.5;
}

/* 滚动条优化 */
.chat-messages::-webkit-scrollbar { width: 8px; }
.chat-messages::-webkit-scrollbar-thumb { background-color: #cbd5e1; border-radius: 8px; }
.chat-messages::-webkit-scrollbar-track { background-color: transparent; }

/* --- 交互模式样式 --- */
.assistant-app.chat-active .chat-main {
  justify-content: stretch;
  padding-top: 0;
}

.assistant-app.chat-active .assistant-hero {
  display: none;
}
.assistant-app.chat-active .features-section {
  display: none;
}

.assistant-app.chat-active .assistant-input-area {
  flex-shrink: 0;
  width: 100%;
  min-width: 1000px;
  margin: 0 auto;
  /*background: #f0f5ff;*/
  padding: 24px;
  box-sizing: border-box;
  /*border-top: 1px solid #dbeafe;*/
}

.assistant-app.chat-active .messages-section {
  display: block !important;
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  height: auto;
  width: 100%;
  box-sizing: border-box;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
  /* 防抖动优化 */
  will-change: transform;
  transform: translateZ(0);
  contain: layout style paint;
  perspective: 1000px;
}

.assistant-app.chat-active .chat-messages {
  border: none;
  background: transparent;
  padding: 0;
  min-height: 100%;
  overflow: visible;
}

.assistant-app.chat-active .message.received .text {
  background: #fff;
  box-shadow: 0 2px 6px rgba(0, 128, 255, 0.04);
}

/* 优化的光标闪烁动画 */
.cursor-blink::after {
  content: '|';
  animation: blink 1s step-end infinite;
  /* 性能优化 */
  will-change: opacity;
  transform: translateZ(0);
}
@keyframes blink { 
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* 减少重绘的通用优化 */
.message {
  will-change: transform;
  transform: translateZ(0);
  contain: layout style paint;
}

/* --- 功能亮点 --- */
.features-section { width: 100%; max-width: 1200px; padding: 0 20px; margin-top: 40px; margin-bottom: 40px; }
.features-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.feature-card { background: #0080ff; color: #ffffff; border-radius: 12px; padding: 16px; box-shadow: 0 10px 24px rgba(0, 128, 255, 0.25); border: 1px solid #0080ff; } /* 蓝色背景卡片 */
.feature-icon { font-size: 20px; line-height: 1; margin-bottom: 8px; }
.feature-title { font-weight: 700; font-size: 14px; margin-bottom: 6px; color: #ffffff; } /* 白色标题 */
.feature-desc { font-size: 13px; color: rgba(255, 255, 255, 0.9); }

.assistant-input-area {
  will-change: transform;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

/* 滚动条初始隐藏 */
.assistant-app.chat-active .messages-section {
  /* 默认隐藏滚动条 */
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE 10+ */
}

.assistant-app.chat-active .messages-section::-webkit-scrollbar {
  display: none; /* Chrome Safari */
  width: 0;
  height: 0;
}

/* 当内容超出时显示滚动条 */
.assistant-app.chat-active .messages-section.has-content {
  scrollbar-width: thin;
  -ms-overflow-style: auto;
}

.assistant-app.chat-active .messages-section.has-content::-webkit-scrollbar {
  display: block;
  width: 8px;
  height: 8px;
}

.assistant-app.chat-active .messages-section.has-content::-webkit-scrollbar-thumb {
  background-color: #cbd5e1;
  border-radius: 8px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

.assistant-app.chat-active .messages-section.has-content::-webkit-scrollbar-track {
  background-color: transparent;
  border-radius: 8px;
}

/* Markdown渲染样式 */
.message .text h1,
.message .text h2,
.message .text h3,
.message .text h4,
.message .text h5,
.message .text h6 {
  margin: 16px 0 12px 0;
  font-weight: 600;
  line-height: 1.4;
  color: #1e293b;
}

.message .text h1 { font-size: 24px; border-bottom: 2px solid #e2e8f0; padding-bottom: 8px; }
.message .text h2 { font-size: 20px; border-bottom: 1px solid #e2e8f0; padding-bottom: 6px; }
.message .text h3 { font-size: 18px; }
.message .text h4 { font-size: 16px; }
.message .text h5 { font-size: 14px; }
.message .text h6 { font-size: 12px; color: #64748b; }

.message .text p {
  margin: 0 0 12px 0;
  line-height: 1.6;
}

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

.message .text li {
  margin: 4px 0;
  line-height: 1.5;
}

.message .text ul li { list-style-type: disc; }
.message .text ol li { list-style-type: decimal; }

.message .text code {
  background-color: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  padding: 2px 6px;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  font-size: 14px;
  color: #e11d48;
}

.message .text pre {
  background-color: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 16px;
  margin: 16px 0;
  overflow-x: auto;
}

.message .text pre code {
  background: none;
  border: none;
  padding: 0;
  color: #334155;
  font-size: 14px;
}

.message .text blockquote {
  border-left: 4px solid #0080ff;
  background-color: #f0f9ff;
  margin: 16px 0;
  padding: 12px 16px;
  color: #334155;
}

.message .text blockquote p { margin: 0; }

.message .text a {
  color: #0080ff;
  text-decoration: none;
  border-bottom: 1px dotted #0080ff;
}

.message .text a:hover {
  color: #0066cc;
  border-bottom: 1px solid #0066cc;
}

.message .text table {
  border-collapse: collapse;
  width: 100%;
  margin: 16px 0;
  background: white;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.message .text th,
.message .text td {
  border: 1px solid #e2e8f0;
  padding: 12px;
  text-align: left;
}

.message .text th {
  background-color: #f1f5f9;
  font-weight: 600;
  color: #1e293b;
}

.message .text tr:nth-child(even) {
  background-color: #f8fafc;
}

.message .text hr {
  border: none;
  border-top: 1px solid #e2e8f0;
  margin: 24px 0;
}

.message .text strong,
.message .text b {
  font-weight: 600;
  color: #1e293b;
}

.message .text em,
.message .text i {
  font-style: italic;
  color: #64748b;
}

@media (max-width: 768px) {
  .message .text pre {
    padding: 12px;
    font-size: 13px;
  }
  
  .message .text code {
    font-size: 12px;
    padding: 1px 4px;
  }
  
  .message .text h1 { font-size: 20px; }
  .message .text h2 { font-size: 18px; }
  .message .text h3 { font-size: 16px; }
  .message .text h4 { font-size: 15px; }
}

/* 移动端特殊处理 */
@media (max-width: 768px) {
  .assistant-app.chat-active .messages-section {
    scrollbar-width: none;
    -ms-overflow-style: none;
  }
  
  .assistant-app.chat-active .messages-section::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
  }
  
  .assistant-app.chat-active .messages-section.has-content {
    scrollbar-width: thin;
    -ms-overflow-style: auto;
  }
  
  .assistant-app.chat-active .messages-section.has-content::-webkit-scrollbar {
    display: block;
    width: 6px;
    height: 6px;
  }
  
  .assistant-app.chat-active .messages-section.has-content::-webkit-scrollbar-thumb {
    background-color: #cbd5e1;
    border-radius: 6px;
    border: 1px solid transparent;
    background-clip: padding-box;
  }
}
