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

:root {
  --bg-primary: #0f0f0f;
  --bg-secondary: #1a1a1a;
  --bg-tertiary: #242424;
  --bg-hover: #2a2a2a;
  --text-primary: #e8e8e8;
  --text-secondary: #999;
  --text-muted: #666;
  --accent: #d4af37;
  --accent-hover: #e5c158;
  --border: #333;
  --user-bubble: #2d5a87;
  --ai-bubble: #2a2a2a;
  --success: #4caf50;
  --error: #f44336;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
}

.app {
  display: flex;
  height: 100vh;
}

/* 侧边栏 */
.sidebar {
  width: 280px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: transform 0.3s ease;
  z-index: 100;
}

.logo {
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border);
}

.logo-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--accent), #b8941f);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.logo-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.logo-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.new-chat-btn {
  margin: 16px;
  padding: 12px;
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

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

.plus {
  font-size: 18px;
  font-weight: 700;
}

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

.chat-list-title {
  font-size: 12px;
  color: var(--text-muted);
  padding: 8px 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.chat-item {
  padding: 10px 12px;
  border-radius: 6px;
  cursor: pointer;
  margin-bottom: 4px;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  gap: 8px;
}

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

.chat-item.active {
  background: var(--bg-tertiary);
  border-left: 2px solid var(--accent);
}

.chat-item-title {
  flex: 1;
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-item-delete {
  opacity: 0;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: all 0.2s;
}

.chat-item:hover .chat-item-delete {
  opacity: 1;
}

.chat-item-delete:hover {
  color: var(--error);
  background: rgba(244, 67, 54, 0.1);
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
}

.model-selector label {
  font-size: 11px;
  color: var(--text-muted);
  display: block;
  margin-bottom: 6px;
}

.model-selector select {
  width: 100%;
  padding: 8px 10px;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
}

.model-selector select:focus {
  outline: none;
  border-color: var(--accent);
}

.footer-link {
  margin-top: 12px;
  display: flex;
  gap: 8px;
}

.footer-link a {
  flex: 1;
  text-align: center;
  padding: 8px;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: 6px;
  font-size: 12px;
  transition: all 0.2s;
}

.footer-link a:hover {
  background: var(--bg-hover);
  color: var(--accent);
}

/* 主内容区 */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.header {
  height: 56px;
  padding: 0 20px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
}

.menu-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 20px;
  cursor: pointer;
  padding: 8px;
  margin-right: 12px;
  border-radius: 6px;
}

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

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

.header-actions {
  display: flex;
  gap: 8px;
}

.icon-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 18px;
  cursor: pointer;
  padding: 8px;
  border-radius: 6px;
  transition: all 0.2s;
}

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

/* 欢迎页 */
.welcome {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  overflow-y: auto;
}

.welcome-icon {
  font-size: 64px;
  margin-bottom: 20px;
}

.welcome h1 {
  font-size: 28px;
  font-weight: 600;
  margin-bottom: 12px;
  background: linear-gradient(135deg, var(--accent), #fff);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.welcome p {
  font-size: 15px;
  color: var(--text-secondary);
  margin-bottom: 40px;
  text-align: center;
  max-width: 500px;
}

.quick-prompts {
  width: 100%;
  max-width: 800px;
}

.quick-title {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 16px;
  text-align: center;
}

.quick-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.quick-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}

.quick-card:hover {
  border-color: var(--accent);
  background: var(--bg-tertiary);
  transform: translateY(-2px);
}

.quick-icon {
  font-size: 28px;
  margin-bottom: 10px;
}

.quick-text {
  font-size: 13px;
  color: var(--text-secondary);
}

/* 对话区域 */
.chat-area {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

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

.message.user {
  flex-direction: row-reverse;
}

.message-avatar {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.message.user .message-avatar {
  background: var(--user-bubble);
}

.message.ai .message-avatar {
  background: linear-gradient(135deg, var(--accent), #b8941f);
}

.message-bubble {
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.7;
  max-width: 70%;
  word-wrap: break-word;
}

.message.user .message-bubble {
  background: var(--user-bubble);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.message.ai .message-bubble {
  background: var(--ai-bubble);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
}

.message-bubble pre {
  background: #000;
  padding: 12px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 8px 0;
  font-size: 13px;
}

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

.message-bubble pre code {
  background: none;
  padding: 0;
}

.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 4px 0;
}

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

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

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

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

.input-wrapper {
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  gap: 12px;
  align-items: flex-end;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px 8px 8px 16px;
  transition: border-color 0.2s;
}

.input-wrapper:focus-within {
  border-color: var(--accent);
}

#chatInput {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  resize: none;
  outline: none;
  max-height: 200px;
  line-height: 1.5;
  padding: 8px 0;
}

#chatInput::placeholder {
  color: var(--text-muted);
}

.send-btn {
  padding: 10px 24px;
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.send-btn:hover:not(:disabled) {
  background: var(--accent-hover);
}

.send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.input-tip {
  max-width: 800px;
  margin: 8px auto 0;
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
}

.tip-divider {
  margin: 0 8px;
}

/* 遮罩层 */
.overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 99;
}

/* 响应式 */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    transform: translateX(-100%);
  }

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

  .overlay.show {
    display: block;
  }

  .menu-btn {
    display: block;
  }

  .quick-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .welcome h1 {
    font-size: 22px;
  }

  .message-bubble {
    max-width: 85%;
  }
}

@media (max-width: 480px) {
  .quick-grid {
    grid-template-columns: 1fr;
  }
}

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

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

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

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