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

:root {
  --bg-primary: #ffffff;
  --bg-secondary: #f9f9f9;
  --bg-tertiary: #ececf1;
  --sidebar-bg: #fafafa;
  --text-primary: #000000;
  --text-secondary: #6e6e80;
  --text-tertiary: #acacbe;
  --border-light: #e5e5e5;
  --border-medium: #d1d1d6;
  --accent: #4b5563;
  --accent-hover: #3b4451;
  --accent-dark: #1f2933;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
  --shadow-md: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;
}

@font-face {
  font-family: 'MaokenZhuyuanTi';
  src: url('MaokenZhuyuanTi.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
}

body {
  font-family: 'MaokenZhuyuanTi', 'Söhne', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  height: 100vh;
  display: flex;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* 侧边栏 */
.sidebar {
  width: 260px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  z-index: 100;
  flex-shrink: 0;
}

/* 折叠窄条侧边栏 */
.sidebar-mini {
  width: 52px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border-light);
  display: none;
  flex-direction: column;
  position: relative;
  z-index: 100;
  flex-shrink: 0;
  padding: 6px 0;
}

.sidebar-mini-header {
  display: flex;
  justify-content: center;
  padding: 6px;
  margin-bottom: 8px;
}

.sidebar-mini-logo {
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  color: var(--text-primary);
  cursor: pointer;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  position: relative;
}

.sidebar-mini-logo .logo-default {
  display: block;
}

.sidebar-mini-logo .logo-hover {
  display: none;
}

.sidebar-mini-logo:hover {
  background: var(--bg-secondary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.sidebar-mini-logo:hover .logo-default {
  display: none;
}

.sidebar-mini-logo:hover .logo-hover {
  display: block;
}

.sidebar-mini-logo::after {
  content: attr(aria-label);
  position: absolute;
  left: 52px;
  background: var(--text-primary);
  color: white;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 1000;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.sidebar-mini-logo:hover::after {
  opacity: 1;
}

.sidebar-mini-actions {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0 6px;
}

.sidebar-mini-btn {
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  position: relative;
}

.sidebar-mini-btn:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.sidebar-mini-btn::after {
  content: attr(title);
  position: absolute;
  left: 52px;
  background: var(--text-primary);
  color: white;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 1000;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.sidebar-mini-btn:hover::after {
  opacity: 1;
}

.sidebar-mini-spacer {
  flex: 1;
}

.sidebar-mini-bottom {
  padding: 6px;
  border-top: 1px solid var(--border-light);
  margin-top: 8px;
}

/* 桌面端切换显示 */
@media (min-width: 769px) {
  .sidebar {
    margin-left: 0;
  }

  .sidebar.collapsed {
    display: none;
  }

  .sidebar-mini.active {
    display: flex;
  }
}

.sidebar-header {
  padding: 12px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.sidebar-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.home-logo {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
  position: relative;
}

.home-logo:hover {
  background: var(--bg-secondary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.home-logo::after {
  content: attr(aria-label);
  position: absolute;
  left: 46px;
  background: var(--text-primary);
  color: white;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 1000;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.home-logo:hover::after {
  opacity: 1;
}

.sidebar-close {
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
  position: relative;
}

.sidebar-close:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.sidebar-close::after {
  content: attr(title);
  position: absolute;
  right: 46px;
  background: var(--text-primary);
  color: white;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 1000;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.sidebar-close:hover::after {
  opacity: 1;
}

.new-chat-btn,
.search-chat-btn {
  height: 40px;
  padding: 0 12px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  transition: all 0.2s;
  width: 100%;
  position: relative;
}

.new-chat-btn:hover,
.search-chat-btn:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.new-chat-btn span,
.search-chat-btn span {
  font-size: 14px;
  font-weight: 500;
}

/* 搜索容器 */
.search-container {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-light);
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
}

.search-box svg {
  color: var(--text-secondary);
  flex-shrink: 0;
}

.search-box input {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  font-size: 14px;
  color: var(--text-primary);
}

.search-box input::placeholder {
  color: var(--text-tertiary);
}

.search-close {
  width: 20px;
  height: 20px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

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

/* 聊天列表 */
.chat-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-medium) transparent;
}

.chat-list::-webkit-scrollbar {
  width: 6px;
}

.chat-list::-webkit-scrollbar-thumb {
  background: var(--border-medium);
  border-radius: 3px;
}

.chat-list::-webkit-scrollbar-track {
  background: transparent;
}

.chat-item {
  padding: 10px 12px;
  margin: 2px 0;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  position: relative;
  background: transparent;
}

.chat-item:hover {
  background: var(--bg-secondary);
  padding-left: 16px;
}

.chat-item.active {
  background: var(--bg-secondary);
  font-weight: 600;
  color: var(--text-primary);
  box-shadow: inset 0 0 0 1px var(--border-medium), 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* 侧边栏底部 */
.sidebar-bottom {
  padding: 12px;
  border-top: 1px solid var(--border-light);
}

.sidebar-item {
  width: 100%;
  padding: 10px 12px;
  background: transparent;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: all 0.2s ease;
}

.sidebar-item:hover {
  background: var(--bg-secondary);
  border-color: var(--border-medium);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.sidebar-item:active {
  transform: scale(0.98);
}

.sidebar-item.upgrade {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
}

.sidebar-item.upgrade:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

/* 主容器 */
.main-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
  position: relative;
}

/* 顶部导航 */
.top-nav {
  height: 52px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: var(--bg-primary);
}

.nav-left,
.nav-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-center {
  flex: 1;
  display: flex;
  justify-content: center;
}

.menu-btn,
.new-chat-mobile,
.nav-icon {
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.menu-btn:hover,
.new-chat-mobile:hover,
.nav-icon:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.nav-right {
  display: flex;
  gap: 8px;
}

.new-chat-mobile {
  display: none;
}

.model-selector {
  padding: 6px 12px;
  background: var(--bg-secondary);
  border: none;
  border-radius: var(--radius-lg);
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s;
  position: relative;
}

.model-selector:hover {
  background: var(--bg-tertiary);
  box-shadow: var(--shadow-sm);
}

.model-name {
  font-weight: 600;
}

.image-gen-toggle {
  padding: 8px;
  background: transparent;
  border: none;
  border-radius: var(--radius-lg);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  margin-right: 4px;
}

.image-gen-toggle:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.image-gen-toggle.active {
  background: var(--accent);
  color: white;
}

.image-gen-toggle svg {
  width: 20px;
  height: 20px;
}

.deep-thinking-toggle {
  padding: 8px;
  background: transparent;
  border: none;
  border-radius: var(--radius-lg);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  margin-right: 4px;
}

.deep-thinking-toggle:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.deep-thinking-toggle.active {
  background: var(--accent);
  color: white;
}

.deep-thinking-toggle svg {
  width: 20px;
  height: 20px;
}

/* 选项菜单样式 - Radix UI 风格 */
.options-menu-wrapper {
  position: relative;
  display: inline-block;
}

.options-menu-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 50%;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
  margin-right: 4px;
}

.options-menu-btn:hover {
  background: var(--bg-secondary);
}

.options-menu-btn.active {
  background: rgba(2, 133, 255, 0.1);
  color: #0285ff;
}

.options-menu-btn.active svg {
  color: #0285ff;
}

.options-dropdown {
  position: fixed;
  background: var(--bg-primary);
  border: 1px solid var(--border-light);
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1),
              0 2px 8px rgba(0, 0, 0, 0.05),
              0 0 0 1px rgba(0, 0, 0, 0.02);
  min-width: 220px;
  max-width: 320px;
  padding: 6px;
  z-index: 1000;
  overflow-y: auto;
  max-height: 400px;
}

.options-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  cursor: pointer;
  transition: background 0.12s ease;
  color: var(--text-primary);
  font-size: 14px;
  border-radius: 8px;
  margin: 1px 0;
  min-height: 40px;
  position: relative;
}

.options-item:hover {
  background: var(--bg-secondary);
}

.options-item:active {
  background: var(--bg-tertiary);
}

.options-item svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  color: var(--text-secondary);
  transition: color 0.15s;
}

.options-item:hover svg {
  color: var(--text-primary);
}

.options-item span {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 400;
  line-height: 1.4;
}

.options-item.selected {
  background: var(--bg-secondary);
}

.options-item.selected svg {
  color: #0285ff;
}

/* 思考过程样式 - 使用details元素 */
.thinking-section {
  margin-bottom: 16px;
  border: 1px solid var(--border-medium);
  background: var(--bg-secondary);
  border-radius: 12px;
  overflow: hidden;
}

.thinking-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  cursor: pointer;
  user-select: none;
  list-style: none;
  transition: background 0.2s;
  pointer-events: auto;
  position: relative;
  z-index: 1;
}

.thinking-summary::-webkit-details-marker {
  display: none;
}

.thinking-summary::marker {
  display: none;
}

.thinking-summary:hover {
  background: var(--bg-tertiary);
}

.thinking-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--text-secondary);
}

.thinking-title {
  flex: 1;
  font-size: 14px;
  color: var(--text-primary);
  font-weight: 500;
}

.chevron-icon {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
  color: var(--text-tertiary);
  transition: transform 0.2s;
}

.thinking-section[open] .chevron-icon {
  transform: rotate(0deg);
}

.thinking-section:not([open]) .chevron-icon {
  transform: rotate(-90deg);
}

.thinking-content {
  padding: 16px;
  padding-top: 0;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.6;
  border-top: 1px solid var(--border-light);
}

.thinking-content p {
  margin: 8px 0;
}

.thinking-content p:first-child {
  margin-top: 0;
}

.thinking-content p:last-child {
  margin-bottom: 0;
}

/* 聊天区域 */
.chat-wrapper {
  flex: 1;
  overflow-y: auto;
  position: relative;
  scrollbar-width: thin;
  scrollbar-color: var(--border-medium) transparent;
}

.chat-wrapper::-webkit-scrollbar {
  width: 8px;
}

.chat-wrapper::-webkit-scrollbar-thumb {
  background: var(--border-medium);
  border-radius: 4px;
  transition: background 0.2s;
}

.chat-wrapper::-webkit-scrollbar-thumb:hover {
  background: var(--text-tertiary);
}

.chat-wrapper::-webkit-scrollbar-track {
  background: transparent;
}

.chat-container {
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* 欢迎界面 */
.welcome-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
}

.logo-container {
  margin-bottom: 24px;
}

.logo {
  width: 48px;
  height: 48px;
  color: var(--text-primary);
}

.logo svg {
  width: 100%;
  height: 100%;
}

.welcome-title {
  font-size: 32px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 40px;
  text-align: center;
  overflow: hidden;
  white-space: nowrap;
}

.welcome-title.typing {
  display: inline-block;
}

.welcome-title.typing span {
  display: inline-block;
  opacity: 0;
  animation: fadeInChar 0.1s ease forwards;
}

@keyframes fadeInChar {
  to {
    opacity: 1;
  }
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  width: 100%;
  max-width: 720px;
}

.quick-action-card {
  padding: 18px;
  background: var(--bg-primary);
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  gap: 14px;
  text-align: left;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.quick-action-card:hover {
  background: var(--bg-secondary);
  border-color: var(--accent);
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
}

.quick-action-card:active {
  transform: translateY(-1px);
}

.card-icon {
  font-size: 24px;
  flex-shrink: 0;
}

.card-text {
  flex: 1;
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.card-desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* 消息区域 - 气泡样式 */
.messages-container {
  padding: 20px;
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
}

.message-group {
  display: flex;
  margin-bottom: 20px;
  animation: fadeIn 0.3s ease-in;
}

.message-group.user {
  justify-content: flex-end;
}

.message-group.assistant {
  justify-content: flex-start;
}

.message-wrapper {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  position: relative;
}

.message-group.user .message-wrapper {
  max-width: 70%;
  flex-direction: row-reverse;
}

.message-group.assistant .message-wrapper {
  max-width: 100%;
}

.message-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 13px;
  transition: transform 0.2s ease;
}

.message-group:hover .message-avatar {
  transform: scale(1.05);
}

.user-avatar {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1.5px solid var(--border-light);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.assistant-avatar {
  background: var(--bg-secondary);
  border: 1.5px solid var(--border-light);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  color: var(--text-primary);
}

.assistant-avatar svg {
  width: 20px;
  height: 20px;
  display: block;
}

.message-bubble {
  padding: 14px 18px;
  border-radius: var(--radius-lg);
  font-size: 15px;
  line-height: 1.75;
  position: relative;
  transition: all 0.2s ease;
  word-wrap: break-word;
}

.message-group.user .message-bubble {
  background: var(--bg-secondary);
  color: var(--text-primary);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  border: 1px solid rgba(0, 0, 0, 0.05);
}

.message-group.user .message-bubble:hover {
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

.message-group.assistant .message-bubble {
  background: transparent;
  color: var(--text-primary);
  padding: 0;
  box-shadow: none;
  border: none;
}

.message-group.assistant .message-bubble:hover {
  background: transparent;
}

.message-actions {
  display: flex;
  gap: 4px;
  padding: 4px 0;
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
  transform: translateY(-4px);
}

.message-wrapper:hover .message-actions {
  opacity: 1;
  transform: translateY(0);
}

/* 用户消息的操作按钮在左下角 */
.message-group.user .message-actions {
  justify-content: flex-end;
}

/* 助手消息的操作按钮在右下角 */
.message-group.assistant .message-actions {
  justify-content: flex-start;
}

.message-action-btn {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  font-size: 15px;
}

.message-action-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  transform: scale(1.1);
}

.message-action-btn:active {
  transform: scale(0.95);
}

.message-bubble p {
  margin: 0;
}

.message-bubble p + p {
  margin-top: 8px;
}

.message-bubble pre {
  background: rgba(0, 0, 0, 0.1);
  border-radius: 8px;
  padding: 0;
  margin: 8px 0;
  overflow: hidden;
  position: relative;
}

.code-copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 4px 8px;
  background: rgba(0, 0, 0, 0.3);
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  opacity: 0;
  transition: all 0.2s;
}

.message-bubble pre:hover .code-copy-btn {
  opacity: 1;
}

.code-copy-btn:hover {
  background: rgba(0, 0, 0, 0.5);
}

.message-group.user .message-bubble pre {
  background: rgba(255, 255, 255, 0.2);
}

.message-bubble pre code {
  display: block;
  padding: 12px;
  overflow-x: auto;
  font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Consolas', monospace;
  font-size: 13px;
  line-height: 1.5;
}

.message-bubble code {
  font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Consolas', monospace;
  font-size: 13px;
}

.message-bubble :not(pre) > code {
  background: rgba(0, 0, 0, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
}

.message-group.user .message-bubble :not(pre) > code {
  background: rgba(255, 255, 255, 0.2);
}

/* Markdown样式 */
.message-bubble h1,
.message-bubble h2,
.message-bubble h3,
.message-bubble h4,
.message-bubble h5,
.message-bubble h6 {
  margin: 16px 0 8px;
  font-weight: 600;
}

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

.message-bubble h1 { font-size: 24px; }
.message-bubble h2 { font-size: 20px; }
.message-bubble h3 { font-size: 18px; }
.message-bubble h4 { font-size: 16px; }
.message-bubble h5 { font-size: 14px; }
.message-bubble h6 { font-size: 13px; }

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

.message-bubble li {
  margin: 4px 0;
}

.message-bubble blockquote {
  margin: 8px 0;
  padding-left: 12px;
  border-left: 3px solid rgba(0, 0, 0, 0.2);
  color: rgba(0, 0, 0, 0.7);
}

.message-group.user .message-bubble blockquote {
  border-left-color: rgba(255, 255, 255, 0.5);
  color: rgba(255, 255, 255, 0.9);
}

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

.message-bubble table th,
.message-bubble table td {
  border: 1px solid rgba(0, 0, 0, 0.2);
  padding: 8px 12px;
  text-align: left;
}

.message-bubble table th {
  background: rgba(0, 0, 0, 0.05);
  font-weight: 600;
}

.message-group.user .message-bubble table th,
.message-group.user .message-bubble table td {
  border-color: rgba(255, 255, 255, 0.3);
}

.message-group.user .message-bubble table th {
  background: rgba(255, 255, 255, 0.15);
}

.message-bubble a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: rgba(0, 0, 0, 0.3);
}

.message-bubble a:hover {
  text-decoration-color: currentColor;
}

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

.message-group.user .message-bubble hr {
  border-top-color: rgba(255, 255, 255, 0.3);
}

.message-bubble strong {
  font-weight: 600;
}

.message-bubble em {
  font-style: italic;
}

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


/* 输入区域 */
.input-section {
  border-top: 1px solid var(--border-light);
  background: var(--bg-primary);
  padding: 16px 20px 20px;
}

.input-container {
  max-width: 768px;
  margin: 0 auto;
}

.input-box {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: var(--bg-primary);
  border: 2px solid var(--border-light);
  border-radius: var(--radius-xl);
  padding: 10px 10px 10px 18px;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

.input-box:hover {
  border-color: var(--border-medium);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.input-box:focus-within {
  border-color: var(--border-medium);
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.05), 0 4px 12px rgba(0, 0, 0, 0.1);
}

.attach-btn {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

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

.message-input {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 15px;
  line-height: 1.5;
  resize: none;
  outline: none;
  max-height: 200px;
  padding: 4px 0;
  font-family: inherit;
}

.message-input::placeholder {
  color: var(--text-tertiary);
}

.send-btn {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: var(--text-primary);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.send-btn:disabled {
  background: var(--bg-tertiary);
  color: var(--text-tertiary);
  cursor: not-allowed;
  box-shadow: none;
  opacity: 0.5;
}

.send-btn:not(:disabled):hover {
  background: var(--accent);
  transform: scale(1.08);
  box-shadow: 0 2px 8px rgba(25, 195, 125, 0.3);
}

.send-btn:not(:disabled):active {
  transform: scale(0.98);
}

.attached-files {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
  padding: 0 4px;
}

.attached-file {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-primary);
  max-width: 200px;
}

.attached-file-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attached-file-remove {
  width: 18px;
  height: 18px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s;
}

.attached-file-remove:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.input-info {
  text-align: center;
  margin-top: 12px;
  font-size: 12px;
  color: var(--text-tertiary);
}

/* 模型下拉菜单 */
.model-dropdown {
  position: absolute;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-primary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 8px;
  min-width: 280px;
  max-height: 400px;
  overflow-y: auto;
  z-index: 1000;
  scrollbar-width: thin;
  scrollbar-color: var(--border-medium) transparent;
}

.model-dropdown::-webkit-scrollbar {
  width: 6px;
}

.model-dropdown::-webkit-scrollbar-thumb {
  background: var(--border-medium);
  border-radius: 3px;
}

.model-dropdown::-webkit-scrollbar-track {
  background: transparent;
}

.dropdown-item {
  padding: 12px;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: background 0.2s;
}

.dropdown-item:hover {
  background: var(--bg-secondary);
}

.dropdown-item.active {
  background: var(--bg-secondary);
}

.model-icon {
  font-size: 20px;
  width: 32px;
  text-align: center;
}

.model-info {
  flex: 1;
}

.model-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.model-desc {
  font-size: 12px;
  color: var(--text-secondary);
}

/* 加载动画 */
.typing-indicator {
  display: inline-flex;
  gap: 4px;
  padding: 8px 0;
}

.typing-dot {
  width: 8px;
  height: 8px;
  background: var(--text-tertiary);
  border-radius: 50%;
  animation: typing 1.4s infinite;
}

.typing-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typing {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.5;
  }
  30% {
    transform: translateY(-10px);
    opacity: 1;
  }
}

/* 响应式设计 */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100%;
    transform: translateX(-100%);
    z-index: 1000;
    box-shadow: var(--shadow-lg);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-close {
    display: flex;
  }

  .new-chat-mobile {
    display: flex;
  }

  .quick-actions {
    grid-template-columns: 1fr;
  }

  .nav-center {
    flex: initial;
  }

  .model-selector {
    font-size: 13px;
    padding: 6px 10px;
  }
}

/* 滚动条 */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-medium);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-tertiary);
}

/* 暗色模式 */
@media (prefers-color-scheme: dark) {
  :root {
    --bg-primary: #212121;
    --bg-secondary: #2a2a2a;
    --bg-tertiary: #333333;
    --sidebar-bg: #1a1a1a;
    --text-primary: #e3e3e3;
    --text-secondary: #ababab;
    --text-tertiary: #6e6e6e;
    --border-light: #424242;
    --border-medium: #565656;
  }

  .logo svg {
    filter: invert(1);
  }
}

/* API设置弹窗 */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content {
  position: relative;
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 500px;
  max-height: 80vh;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  z-index: 10000;
}

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

.modal-header h2 {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
}

.modal-close {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 24px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close:hover {
  background: var(--bg-secondary);
}

.modal-body {
  padding: 20px;
  max-height: calc(80vh - 140px);
  overflow-y: auto;
}

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

.form-group {
  margin-bottom: 20px;
  position: relative;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}

.form-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 14px;
  transition: border-color 0.2s;
}

.form-input:focus {
  outline: none;
  border-color: var(--border-medium);
}

.toggle-password {
  position: absolute;
  right: 12px;
  bottom: 10px;
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 16px;
}

.btn-primary,
.btn-secondary {
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-primary {
  background: var(--text-primary);
  color: white;
  border: none;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.btn-primary:hover {
  background: var(--text-secondary);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.btn-primary:active {
  transform: scale(0.98);
}

.btn-secondary {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-light);
}

.btn-secondary:hover {
  background: var(--bg-tertiary);
  border-color: var(--border-medium);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.btn-secondary:active {
  transform: scale(0.98);
}

.btn-danger {
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
  background: #ef4444;
  color: white;
}

.btn-danger:hover {
  background: #dc2626;
}

.models-list {
  margin-top: 20px;
  padding: 12px;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
}

.models-list label {
  display: block;
  margin-bottom: 12px;
  font-weight: 600;
  color: var(--text-primary);
}

#available-models {
  max-height: 200px;
  overflow-y: auto;
}

.model-item {
  padding: 8px 12px;
  margin: 4px 0;
  background: var(--bg-primary);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text-primary);
  cursor: pointer;
  transition: background 0.2s;
}

.model-item:hover {
  background: var(--bg-tertiary);
}

.model-item.selected {
  background: var(--accent);
  color: white;
}

/* Toggle Switch 开关样式 */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  transition: 0.3s;
  border-radius: 24px;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.3s;
  border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
  background-color: var(--accent);
}

.toggle-switch input:checked + .toggle-slider:before {
  transform: translateX(20px);
}

.toggle-switch input:focus + .toggle-slider {
  box-shadow: 0 0 1px var(--accent);
}

/* 强度滑块样式 */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  transition: transform 0.15s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.1);
}

input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: none;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  transition: transform 0.15s ease;
}

input[type="range"]::-moz-range-thumb:hover {
  transform: scale(1.1);
}

/* 加载动画 */
.loading-dots {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.loading-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-secondary);
  display: inline-block;
  animation: bounce 1.4s infinite ease-in-out both;
}

.loading-dots span:nth-child(1) {
  animation-delay: -0.32s;
}

.loading-dots span:nth-child(2) {
  animation-delay: -0.16s;
}

@keyframes bounce {
  0%, 80%, 100% {
    transform: scale(0);
    opacity: 0.5;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* 图片预览 */
.image-preview-overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(10, 14, 23, 0.78);
  backdrop-filter: blur(12px);
  z-index: 2600;
  padding: 48px 24px;
}

.image-preview-overlay.visible {
  display: flex;
}

.image-preview-inner {
  position: relative;
  max-width: min(90vw, 1200px);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.image-preview-img {
  max-width: 100%;
  max-height: calc(90vh - 72px);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.35);
  object-fit: contain;
  background: rgba(255, 255, 255, 0.04);
}

.image-preview-caption {
  color: rgba(255, 255, 255, 0.85);
  font-size: 14px;
  line-height: 1.6;
  text-align: center;
  max-width: 80vw;
  word-break: break-word;
}

.image-preview-close {
  position: absolute;
  top: -40px;
  right: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(10px);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.image-preview-close::before {
  content: '×';
  font-size: 20px;
  line-height: 1;
}

.image-preview-close:hover {
  background: rgba(255, 255, 255, 0.28);
}

/* 系统弹窗 */
.system-dialog-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(13, 17, 28, 0.35);
  backdrop-filter: blur(14px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 2700;
}

.system-dialog-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.system-dialog {
  width: min(340px, 90vw);
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  transform: translateY(12px);
  transition: transform 0.2s ease;
}

.system-dialog-overlay.visible .system-dialog {
  transform: translateY(0);
}

.system-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 12px;
}

.system-dialog-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.system-dialog-close {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.system-dialog-close::before {
  content: '×';
  font-size: 22px;
  line-height: 1;
}

.system-dialog-close:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.system-dialog-body {
  padding: 0 24px 16px;
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.system-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 0 24px 24px;
}

.system-dialog-btn {
  min-width: 84px;
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.system-dialog-btn:hover {
  background: var(--bg-tertiary);
}

.system-dialog-btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.system-dialog-btn.primary:hover {
  background: var(--accent-hover);
}
