/* Premium Light UI System for Doubao AI Pro */
:root {
  --bg-primary: #f8f9fa;
  --bg-secondary: #ffffff;
  --sidebar-bg: #ffffff;
  --text-main: #1d1d1f;
  --text-muted: #86868b;
  --accent-color: #33D685; /* 豆包绿色 */
  --accent-hover: #2bbd74;
  --border-color: rgba(0, 0, 0, 0.08);
  --glass-bg: rgba(255, 255, 255, 0.85);
  --bubble-ai: #ffffff;
  --bubble-user: #33D685;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.08);
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --sidebar-width: 260px;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-main);
  height: 100vh;
  margin: 0;
  display: flex;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Sidebar Styling */
.sidebar {
  width: var(--sidebar-width);
  background-color: var(--sidebar-bg);
  height: 100%;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border-color);
  z-index: 100;
  transition: var(--transition);
}

.new-chat-btn {
  margin: 20px;
  padding: 12px 16px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  color: var(--text-main);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: var(--transition);
  font-weight: 600;
  font-size: 14px;
}

.new-chat-btn:hover {
  background: #f0f0f0;
  transform: translateY(-1px);
}

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

.history-item {
  padding: 12px 14px;
  margin-bottom: 4px;
  border-radius: 10px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 14px;
  color: var(--text-muted);
  transition: var(--transition);
}

.history-item:hover {
  background: #f5f5f7;
  color: var(--text-main);
}

.history-item.active {
  background: #e8fbf2;
  color: var(--accent-hover);
  font-weight: 500;
}

/* Main Chat Area */
.main-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  background-color: var(--bg-primary);
}

.chat-header {
  height: 64px;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  background: var(--glass-bg);
  position: sticky;
  top: 0;
  z-index: 50;
}

.chat-window {
  flex: 1;
  overflow-y: auto;
  padding: 30px 0;
  display: flex;
  flex-direction: column;
  scroll-behavior: smooth;
}

.message-container {
  max-width: 800px;
  width: 92%;
  margin: 0 auto 20px;
  display: flex;
  gap: 12px;
  animation: messageSlide 0.4s ease-out;
  contain: content; /* 开启渲染优化：告诉浏览器此容器独立，减少回流重绘 */
}

#stopBtn:hover {
  background: #f8f9fa !important;
  color: #cf1322;
  border-color: #ffa39e !important;
}

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

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
}

.ai-avatar {
  background: var(--accent-color);
  color: white;
}

.user-avatar {
  background: #e5e5ea;
  color: #1d1d1f;
}

.message-body {
  flex: 1;
  background: var(--bubble-ai);
  padding: 12px 16px;
  border-radius: 14px;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  color: var(--text-main);
  line-height: 1.6;
  font-size: 15px;
  max-width: fit-content;
}

.message-container:has(.user-avatar) {
  flex-direction: row-reverse;
}

.message-container:has(.user-avatar) .message-body {
  background: var(--accent-color);
  color: white;
  border: none;
  max-width: 80%;
}

/* Code Styling in Light Mode */
pre {
  background: #f1f3f5;
  padding: 16px;
  border-radius: 12px;
  margin: 12px 0;
  position: relative;
  border: 1px solid #e9ecef;
}

code {
  font-family: 'Fira Code', monospace;
  font-size: 13.5px;
  color: #d63384;
}

.copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 4px 10px;
  background: white;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 11px;
  cursor: pointer;
}

/* Input Area - CAPSULE DESIGN */
.input-area {
  max-width: 800px;
  width: 100%;
  margin: 0 auto 24px;
  padding: 0 20px;
  position: relative;
}

.input-wrapper {
  background: var(--bg-secondary);
  border: 1.5px solid var(--border-color);
  border-radius: 20px;
  padding: 8px 12px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  box-shadow: var(--shadow-lg);
  transition: var(--transition);
}

.input-wrapper:focus-within {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 4px rgba(51, 214, 133, 0.1);
}

textarea {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  resize: none;
  color: var(--text-main);
  font-size: 15px;
  padding: 10px 4px;
  max-height: 180px;
  line-height: 1.4;
}

.send-btn {
  background: var(--accent-color);
  color: white;
  border: none;
  width: 44px; /* 增大按钮以提升点击体验 */
  height: 44px;
  border-radius: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  opacity: 0.4;
  flex-shrink: 0;
  margin-bottom: 2px;
}

.send-btn.active {
  opacity: 1;
  box-shadow: 0 4px 12px rgba(51, 214, 133, 0.3);
}

.send-btn:hover.active {
  background: var(--accent-hover);
  transform: translateY(-2px);
}

/* 极速追加模式样式 */
.streaming-text {
  white-space: pre-wrap;
  word-wrap: break-word;
}

.typing-cursor {
  display: inline-block;
  width: 8px;
  height: 16px;
  background: var(--accent-color);
  margin-left: 4px;
  animation: cursorBlink 0.8s infinite;
  vertical-align: middle;
}

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

/* --- WATCH & TINY SCREEN ADAPTATION (326x326) --- */
@media (max-width: 350px) {
  :root {
    --sidebar-width: 0px;
  }
  
  /* 完全隐藏非核心 UI，争取每一像素 */
  .sidebar, .mobile-header, .chat-header, .avatar {
    display: none !important;
  }

  .main-container {
    height: 100vh;
  }

  .chat-window {
    padding: 10px 4px;
  }

  .message-container {
    width: 100%;
    margin-bottom: 10px;
    gap: 0;
  }

  .message-body {
    font-size: 16px; /* 加大字号 */
    font-weight: 500;
    line-height: 1.4;
    padding: 10px 14px;
    border-radius: 12px;
    max-width: 95% !important;
    box-shadow: none;
    border: 1px solid rgba(0,0,0,0.05);
  }

  /* 手表端输入框优化：更紧凑，更大按钮 */
  .input-area {
    margin: 0;
    padding: 6px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
  }

  .input-wrapper {
    padding: 2px 6px;
    border: none;
    box-shadow: none;
    border-radius: 0;
  }

  textarea {
    font-size: 16px;
    padding: 8px 0;
  }

  .send-btn {
    width: 54px; 
    height: 48px;
    border-radius: 14px;
  }
}

/* Mobile Drawer */
.mobile-header {
  display: none;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  justify-content: space-between;
  align-items: center;
}

@media (max-width: 768px) and (min-width: 351px) {
  .sidebar {
    position: absolute;
    left: -100%;
  }
  .sidebar.open {
    left: 0;
    box-shadow: var(--shadow-lg);
  }
  .mobile-header {
    display: flex;
    height: 56px;
  }
}

/* Loading Dots */
.loading-dots { display: flex; gap: 4px; padding: 4px 0; }
.dot { width: 6px; height: 6px; background: #ccd0d5; border-radius: 50%; animation: bounce 1.4s infinite ease-in-out both; }
.dot:nth-child(1) { animation-delay: -0.32s; }
.dot:nth-child(2) { animation-delay: -0.16s; }
@keyframes bounce { 0%, 80%, 100% { transform: scale(0); } 40% { transform: scale(1.0); } }
