:root {
  --bg-primary: #0f0f1a;
  --bg-secondary: #1a1a2e;
  --bg-card: #16213e;
  --bg-input: #1e2a4a;
  --accent: #6c5ce7;
  --accent-light: #a29bfe;
  --accent-glow: rgba(108, 92, 231, 0.3);
  --text-primary: #e8e8f0;
  --text-secondary: #8888aa;
  --text-muted: #555577;
  --success: #00cec9;
  --warning: #fdcb6e;
  --danger: #ff6b6b;
  --border: rgba(255,255,255,0.06);
  --radius: 16px;
  --radius-sm: 10px;
}

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

body {
  font-family: -apple-system, 'PingFang SC', 'SF Pro Display', 'Helvetica Neue', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow: hidden;
}

/* ============ 布局 ============ */
.app {
  display: flex;
  height: 100vh;
  max-width: 1400px;
  margin: 0 auto;
}

/* ============ 左侧游戏选择栏 ============ */
.sidebar {
  width: 280px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar-header {
  padding: 24px 20px 16px;
  border-bottom: 1px solid var(--border);
}

.sidebar-header h1 {
  font-size: 18px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent-light), var(--success));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.sidebar-header p {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

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

.game-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: 6px;
  border: 1px solid transparent;
}

.game-card:hover {
  background: rgba(108, 92, 231, 0.08);
  border-color: rgba(108, 92, 231, 0.15);
}

.game-card.active {
  background: rgba(108, 92, 231, 0.15);
  border-color: var(--accent);
  box-shadow: 0 0 20px var(--accent-glow);
}

.game-icon {
  font-size: 28px;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.05);
  border-radius: 12px;
  flex-shrink: 0;
}

.game-info h3 {
  font-size: 14px;
  font-weight: 600;
}

.game-info p {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.game-badge {
  display: inline-block;
  background: var(--danger);
  color: white;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 8px;
  margin-left: 4px;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
}

.mode-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 600;
  background: rgba(0, 206, 201, 0.15);
  color: var(--success);
}

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

/* 顶部信息栏 */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-left h2 {
  font-size: 16px;
  font-weight: 600;
}

.topbar-left .persona-name {
  font-size: 12px;
  color: var(--accent-light);
  background: rgba(108, 92, 231, 0.12);
  padding: 3px 10px;
  border-radius: 12px;
}

.topbar-stats {
  display: flex;
  gap: 16px;
}

.stat-item {
  text-align: center;
}

.stat-value {
  font-size: 16px;
  font-weight: 700;
  color: var(--accent-light);
}

.stat-label {
  font-size: 10px;
  color: var(--text-muted);
}

/* 对话区域 */
.chat-area {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}

.chat-area::-webkit-scrollbar { width: 4px; }
.chat-area::-webkit-scrollbar-track { background: transparent; }
.chat-area::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 4px; }

/* 消息气泡 */
.message {
  display: flex;
  gap: 12px;
  max-width: 85%;
  animation: fadeInUp 0.3s ease;
}

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

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

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

.message.assistant .message-avatar {
  background: linear-gradient(135deg, var(--accent), #4834d4);
}

.message.user .message-avatar {
  background: linear-gradient(135deg, #00b894, #00cec9);
}

.message-content {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 14px 18px;
  font-size: 14px;
  line-height: 1.7;
  border: 1px solid var(--border);
}

.message.user .message-content {
  background: rgba(108, 92, 231, 0.2);
  border-color: rgba(108, 92, 231, 0.3);
}

.message-content pre {
  white-space: pre-wrap;
  word-break: break-word;
  font-family: inherit;
}

/* Agent 标签 */
.agent-tags {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.agent-tag {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 6px;
  background: rgba(108, 92, 231, 0.12);
  color: var(--accent-light);
  border: 1px solid rgba(108, 92, 231, 0.2);
}

/* 进度指示 */
.thinking-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  background: rgba(108, 92, 231, 0.08);
  font-size: 12px;
  color: var(--accent-light);
  animation: pulse 1.5s ease infinite;
}

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

.thinking-dots span {
  animation: dotBounce 1.4s ease infinite;
  display: inline-block;
}
.thinking-dots span:nth-child(2) { animation-delay: 0.2s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dotBounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-4px); }
}

/* 快捷指令 */
.quick-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 0 24px 12px;
}

.quick-btn {
  padding: 8px 16px;
  border-radius: 20px;
  border: 1px solid rgba(108, 92, 231, 0.25);
  background: rgba(108, 92, 231, 0.08);
  color: var(--accent-light);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.quick-btn:hover {
  background: rgba(108, 92, 231, 0.2);
  border-color: var(--accent);
  transform: translateY(-1px);
}

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

.input-wrapper {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.input-wrapper textarea {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid rgba(108, 92, 231, 0.2);
  border-radius: 14px;
  padding: 12px 18px;
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  resize: none;
  outline: none;
  min-height: 44px;
  max-height: 120px;
  transition: border-color 0.2s;
  line-height: 1.5;
}

.input-wrapper textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.input-wrapper textarea::placeholder {
  color: var(--text-muted);
}

.send-btn {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  border: none;
  background: linear-gradient(135deg, var(--accent), #4834d4);
  color: white;
  font-size: 18px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.send-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 15px var(--accent-glow);
}

.send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

/* ============ 欢迎页 ============ */
.welcome-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px;
}

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

.welcome-screen h2 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 8px;
  background: linear-gradient(135deg, var(--accent-light), var(--success));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.welcome-screen p {
  color: var(--text-secondary);
  font-size: 14px;
  max-width: 400px;
  line-height: 1.6;
}

/* ============ 架构图弹窗 ============ */
.arch-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(4px);
}

.arch-overlay.active { display: flex; }

.arch-panel {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  max-width: 700px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  position: relative;
}

.arch-panel h3 {
  font-size: 18px;
  margin-bottom: 16px;
  color: var(--accent-light);
}

.arch-panel pre {
  background: var(--bg-primary);
  border-radius: var(--radius-sm);
  padding: 16px;
  font-size: 12px;
  line-height: 1.6;
  overflow-x: auto;
  color: var(--text-secondary);
}

.arch-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 20px;
  cursor: pointer;
}

.arch-btn {
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.arch-btn:hover {
  border-color: var(--accent);
  color: var(--accent-light);
}

/* ============ 响应式 ============ */
@media (max-width: 768px) {
  .sidebar { width: 70px; }
  .sidebar-header h1, .sidebar-header p, .game-info, .sidebar-footer { display: none; }
  .game-card { justify-content: center; padding: 12px; }
  .game-icon { width: 40px; height: 40px; font-size: 24px; }
  .topbar-stats { display: none; }
  .message { max-width: 95%; }
}
