/* Eliy v0.3.2-test Chat-first Visual Design System (Flat Dark Edition) */

:root {
  --color-base: #080a10;           /* 右侧主聊天区大背景 */
  --color-sidebar: #0d111e;        /* 左侧边栏底色 */
  --color-surface: #141a2d;        /* 输入框、卡片基础色 */
  --color-surface-hover: #1e263f;  /* 悬停时的卡片色 */
  --color-border: #222b45;         /* 通用细边框线 */
  
  --color-eliy: #9b8cff;           /* Eliy 紫色系 (智能体专属) */
  --color-eliy-bubble: rgba(155, 140, 255, 0.04);
  
  --color-user: #ffb26b;           /* 用户 橙色系 (用户专属) */
  --color-user-bubble: rgba(255, 178, 107, 0.04);
  
  --color-gold: #f5c518;           /* 成果卡 金色系 */
  --color-gold-surface: rgba(245, 197, 24, 0.04);

  --color-success: #10b981;
  --color-danger: #ef4444;
  --color-warning: #f59e0b;
  
  --color-text: #fdfbff;
  --color-text-muted: #8f97a6;
  
  --font-family: 'Outfit', 'Noto Sans SC', -apple-system, sans-serif;
  --radius-lg: 12px;
  --radius-md: 8px;
  --radius-sm: 6px;
  --transition: all 0.2s ease;
  --shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

/* === 基础重置 === */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  width: 100%;
  font-family: var(--font-family);
  background: var(--color-base);
  color: var(--color-text);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

#app {
  display: flex;
  height: 100vh;
  height: 100dvh;
  width: 100%;
  position: relative;
  overflow: hidden;
}

/* === 左侧边栏 (Sidebar) === */
#sidebar {
  width: 280px;
  background: var(--color-sidebar);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: var(--transition);
  z-index: 10;
}

.sidebar-overlay {
  display: none;
}

/* 侧边栏头部 */
.sidebar-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}
.brand-logo {
  font-size: 1.6rem;
  color: var(--color-eliy);
  font-weight: bold;
}
.brand-text h2 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.5px;
}
.brand-text span {
  font-size: 0.72rem;
  color: var(--color-text-muted);
  display: block;
  margin-top: 0.1rem;
}
.sidebar-close-btn {
  display: none;
  background: transparent;
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 1.35rem;
  line-height: 1;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: var(--transition);
}
.sidebar-close-btn:hover {
  color: var(--color-text);
  background: var(--color-surface);
}

/* 对话与搜索操作 */
.sidebar-actions {
  padding: 1.2rem 1.2rem 0.5rem 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}
.new-chat-btn {
  width: 100%;
  padding: 0.75rem;
  background: rgba(155, 140, 255, 0.08);
  border: 1px solid rgba(155, 140, 255, 0.2);
  color: var(--color-text);
  border-radius: var(--radius-md);
  font-family: var(--font-family);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: var(--transition);
}
.new-chat-btn:hover {
  background: rgba(155, 140, 255, 0.15);
  border-color: var(--color-eliy);
}
.new-chat-btn .btn-icon {
  font-size: 1.05rem;
  font-weight: 600;
}
.search-box {
  position: relative;
  width: 100%;
}
.search-icon {
  position: absolute;
  left: 0.8rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.85rem;
  color: var(--color-text-muted);
}
.search-box input {
  width: 100%;
  padding: 0.65rem 0.8rem 0.65rem 2.2rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text);
  font-size: 0.82rem;
  outline: none;
  cursor: not-allowed;
}

/* Skills 区域 */
.skills-section {
  padding: 1.2rem 1.2rem 0.5rem 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.skills-section h3, .history-section h3 {
  font-size: 0.72rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
  padding-left: 0.3rem;
}
/* Skills 列表 */
.skills-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
/* 最近对话历史 */
.history-section {
  flex: 1;
  padding: 0.5rem 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  overflow: hidden;
}
.history-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  overflow-y: auto;
  padding-right: 2px;
}
.history-empty {
  padding: 0.75rem 0.8rem;
  color: var(--color-text-muted);
  font-size: 0.78rem;
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-md);
}

.skill-item, .history-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.7rem 0.8rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid transparent;
  border-left: 3px solid transparent;
}
.skill-item:hover, .history-item:hover {
  background: rgba(20, 26, 45, 0.4);
  border-color: var(--color-border);
  border-left-color: transparent;
}
.skill-item.active {
  background: transparent;
  border-color: transparent;
  border-left-color: var(--color-eliy);
  box-shadow: none;
}
.skill-item.active .history-title {
  color: var(--color-eliy);
}
.history-item.active {
  background: var(--color-surface);
  border-color: var(--color-border);
  border-left-color: transparent;
}
.skill-icon, .history-icon {
  font-size: 0.95rem;
  color: var(--color-text-muted);
  opacity: 0.6;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
}
.skill-icon {
  color: var(--color-eliy);
}
.skill-item.active .skill-icon {
  opacity: 1;
}
.skill-details, .history-details {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  overflow: hidden;
}
.history-title {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.history-time {
  font-size: 0.68rem;
  color: var(--color-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.skill-item .history-title,
.skill-item .history-time {
  font-family: 'Noto Sans SC', -apple-system, sans-serif;
}

/* 侧边栏底部 */
.sidebar-footer {
  padding: 1.2rem;
  border-top: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.settings-btn {
  background: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--color-text-muted);
  transition: var(--transition);
}
.settings-btn:hover {
  color: var(--color-text);
  background: var(--color-surface);
}

/* 主题切换按鈕 */
.theme-toggle-btn {
  background: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.9rem;
  transition: var(--transition);
  flex-shrink: 0;
}
.theme-toggle-btn:hover {
  background: var(--color-surface);
}
.user-profile {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  padding: 0.4rem 0.6rem;
  border-radius: var(--radius-md);
  overflow: hidden;
}
.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-user), #f97316);
  color: #000;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
}
.user-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.user-name {
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-role {
  font-size: 0.62rem;
  color: var(--color-text-muted);
}
.logout-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.85rem;
  opacity: 0.6;
  transition: var(--transition);
  padding: 0.2rem;
}
.logout-btn:hover {
  opacity: 1;
}

/* === 右侧主聊天区 === */
#chatMain {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--color-base);
  position: relative;
  overflow: hidden;
}

/* 顶部导航栏 */
.chat-header {
  height: 64px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-base);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 5;
}
.header-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.menu-toggle {
  display: none;
  background: none;
  border: 1px solid var(--color-border);
  color: var(--color-text);
  font-size: 1.2rem;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}
.menu-toggle:hover {
  background: var(--color-surface);
}

/* 下拉菜单 */
.model-dropdown {
  position: relative;
}
.dropdown-trigger {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  padding: 0.45rem 0.8rem;
  border-radius: var(--radius-md);
  color: var(--color-text);
  font-family: var(--font-family);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: var(--transition);
}
.dropdown-trigger:hover {
  border-color: var(--color-eliy);
}
.model-badge {
  font-size: 0.65rem;
  background: rgba(155, 140, 255, 0.15);
  color: var(--color-eliy);
  padding: 0.05rem 0.35rem;
  border-radius: 4px;
  font-weight: 600;
}
.dropdown-arrow {
  font-size: 0.6rem;
  color: var(--color-text-muted);
}
.dropdown-menu {
  position: absolute;
  left: 0;
  top: calc(100% + 6px);
  width: 240px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 0.4rem;
  box-shadow: var(--shadow);
  display: none;
  flex-direction: column;
  gap: 0.2rem;
  z-index: 20;
}
.dropdown-menu.show {
  display: flex;
}
.dropdown-item {
  padding: 0.6rem 0.8rem;
  font-size: 0.82rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
}
.dropdown-item:hover {
  background: var(--color-surface-hover);
}
.dropdown-item.active {
  background: rgba(155, 140, 255, 0.08);
  color: var(--color-eliy);
  font-weight: 500;
}
.dropdown-item.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1.2rem;
}
.skill-observer {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
  max-width: min(52vw, 560px);
  padding: 0.35rem 0.55rem;
  border: 1px solid rgba(155, 140, 255, 0.22);
  border-radius: var(--radius-sm);
  background: rgba(20, 26, 45, 0.55);
  color: var(--color-text-muted);
  font-size: 0.7rem;
  line-height: 1.35;
}
.skill-observer strong {
  color: var(--color-eliy);
  font-weight: 600;
}
.status-indicator {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
  color: var(--color-text-muted);
}
.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--color-success);
}

/* === 消息流区 === */
.messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 2rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  -webkit-overflow-scrolling: touch;
}

.message {
  display: flex;
  gap: 1rem;
  max-width: 1040px;
  width: calc(100% - 96px);
  margin: 0 auto;
  animation: message-fade-in 0.2s ease-out;
}
@keyframes message-fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

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

.message .avatar {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.88rem;
  flex-shrink: 0;
}
.message.assistant .avatar {
  background: var(--color-eliy);
  color: #000;
}
.message.user .avatar {
  background: var(--color-user);
  color: #000;
}

.bubble {
  padding: 0.85rem 1.2rem;
  border-radius: var(--radius-lg);
  line-height: 1.6;
  font-size: 0.92rem;
  max-width: calc(100% - 80px);
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.message.assistant .bubble {
  background: var(--color-eliy-bubble);
  border: 1px solid rgba(155, 140, 255, 0.2);
}
.message.user .bubble {
  background: var(--color-user-bubble);
  border: 1px solid rgba(255, 178, 107, 0.2);
}

.bubble p {
  margin-bottom: 0.5rem;
}
.bubble p:last-child {
  margin-bottom: 0;
}
.bubble strong {
  font-weight: 600;
  color: var(--color-text);
}

/* === 成果卡 (Artifact Card) === */
.artifact-card {
  margin-top: 0.8rem;
  border: 1px solid rgba(155, 140, 255, 0.3);
  background: rgba(20, 26, 45, 0.7);
  border-radius: var(--radius-md);
  padding: 1.1rem;
  box-shadow: var(--shadow);
  animation: card-appear 0.2s ease-out;
  max-width: 100%;
  overflow: hidden;
}
@keyframes card-appear {
  from { opacity: 0; transform: scale(0.98); }
  to { opacity: 1; transform: none; }
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.7rem;
  border-bottom: 1px solid rgba(155, 140, 255, 0.15);
  padding-bottom: 0.4rem;
}
.card-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--color-text);
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-width: 0;
  overflow-wrap: anywhere;
}
.card-status {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.1rem 0.45rem;
  border-radius: 4px;
}
.card-status.pending {
  background: rgba(155, 140, 255, 0.1);
  color: var(--color-eliy);
  border: 1px solid rgba(155, 140, 255, 0.25);
}
.card-status.accepted {
  background: rgba(16, 185, 129, 0.1);
  color: var(--color-success);
  border: 1px solid rgba(16, 185, 129, 0.2);
}
.card-status.converted {
  background: rgba(155, 140, 255, 0.1);
  color: var(--color-eliy);
  border: 1px solid rgba(155, 140, 255, 0.2);
}

.card-body {
  font-size: 0.88rem;
  line-height: 1.55;
  color: #e2e8f0;
  margin-bottom: 0.9rem;
  background: rgba(0,0,0,0.15);
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--color-eliy);
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* 成果卡 action 按钮 */
.card-actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}
.card-btn {
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-family);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: var(--transition);
}
.card-btn.approve {
  background: var(--color-eliy);
  color: #000;
}
.card-btn.approve:hover {
  background: #8574f5;
}
.card-btn.modify {
  background: transparent;
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
}
.card-btn.modify:hover {
  color: var(--color-text);
  border-color: var(--color-text-muted);
}
.card-btn.freeze {
  background: transparent;
  color: var(--color-eliy);
  border: 1px solid rgba(155, 140, 255, 0.3);
}
.card-btn.freeze:hover {
  background: rgba(155, 140, 255, 0.1);
}

/* === Gate 2 Adapter Panels === */
.gate2-panel,
.gate2-error-banner,
.gate2-legacy-fallback {
  margin-top: 0.8rem;
  border-radius: var(--radius-md);
  border: 1px solid rgba(155, 140, 255, 0.24);
  background: rgba(10, 14, 26, 0.72);
  padding: 0.9rem 1rem;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.gate2-error-banner {
  border-color: rgba(248, 113, 113, 0.35);
  background: rgba(37, 15, 18, 0.88);
}

.gate2-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.6rem;
  flex-wrap: wrap;
}

.gate2-panel-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--color-text);
  letter-spacing: 0.2px;
}

.gate2-panel-pill,
.gate2-trace-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  border-radius: 999px;
  padding: 0.18rem 0.5rem;
  font-size: 0.7rem;
  font-weight: 600;
  border: 1px solid rgba(155, 140, 255, 0.25);
  background: rgba(155, 140, 255, 0.08);
  color: var(--color-eliy);
}

.gate2-trace-chip {
  cursor: pointer;
  white-space: nowrap;
}

.gate2-panel-body {
  display: grid;
  gap: 0.4rem;
  line-height: 1.55;
  color: var(--color-text-muted);
  font-size: 0.86rem;
}

.gate2-panel-body code,
.gate2-error-list code {
  font-size: 0.76rem;
}

.gate2-summary {
  margin: 0;
  color: var(--color-text);
}

.gate2-meta,
.gate2-muted {
  margin: 0;
  color: var(--color-text-muted);
}

.gate2-actions {
  display: flex;
  gap: 0.55rem;
  flex-wrap: wrap;
}

.gate2-action-btn,
.gate2-inline-btn {
  padding: 0.42rem 0.8rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(155, 140, 255, 0.22);
  background: rgba(155, 140, 255, 0.08);
  color: var(--color-text);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}

.gate2-action-btn.confirm {
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.25);
}

.gate2-action-btn.reject {
  background: rgba(248, 113, 113, 0.12);
  border-color: rgba(248, 113, 113, 0.25);
}

.gate2-action-btn.defer {
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.25);
}

.gate2-panel-status {
  margin-top: 0.6rem;
  font-size: 0.78rem;
  color: var(--color-success);
  font-weight: 600;
}

.gate2-error-list {
  margin: 0 0 0.65rem 1rem;
  padding: 0;
  color: #fda4af;
  font-size: 0.84rem;
  line-height: 1.5;
}

.gate2-legacy-fallback {
  border-style: dashed;
  color: var(--color-text-muted);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* 打字动画 */
.typing-indicator {
  display: flex;
  gap: 5px;
  padding: 0.4rem 0.2rem;
  align-items: center;
}
.typing-indicator span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-text-muted);
  animation: typing-wave 1.2s infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing-wave {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.3; }
  30% { transform: translateY(-3px); opacity: 1; }
}

/* === 底部输入框区域 === */
.chat-footer {
  padding: 1rem 1.5rem 1.5rem 1.5rem;
  background: linear-gradient(180deg, transparent, var(--color-base) 40%);
  position: relative;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
}
.input-container {
  max-width: 800px;
  width: 100%;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: flex-end;
  padding: 0.6rem 0.8rem;
  gap: 0.8rem;
  box-shadow: var(--shadow);
  transition: border-color 0.2s;
}
.input-container:focus-within {
  border-color: var(--color-eliy);
}

/* 附件容器 */
.attach-container {
  display: flex;
  align-items: center;
  margin-bottom: 2px;
}
.attach-btn {
  background: var(--color-border);
  border: none;
  color: var(--color-text);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}
.attach-btn:hover {
  background: var(--color-surface-hover);
}
.attach-icon {
  font-size: 1.1rem;
  font-weight: 500;
}

/* 附件缩略图预览栏 */
.file-preview-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.6rem;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  margin-bottom: 0.5rem;
  width: 100%;
  font-size: 0.78rem;
  animation: fadeIn 0.2s;
}
.file-preview-name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.file-preview-remove {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-danger);
  font-size: 0.85rem;
}

/* 输入框 */
#userInput {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  color: var(--color-text);
  font-family: var(--font-family);
  font-size: 0.92rem;
  line-height: 1.5;
  outline: none;
  resize: none;
  max-height: 140px;
  min-height: 24px;
  padding: 0.3rem 0;
  margin-bottom: 2px;
}
#userInput::placeholder {
  color: var(--color-text-muted);
}

/* 输入框操作按钮区 */
.input-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 2px;
}

.send-btn {
  background: var(--color-eliy);
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}
.send-btn:hover {
  transform: scale(1.05);
}
.send-icon {
  width: 14px;
  height: 14px;
  fill: #000;
  transform: rotate(-45deg) translate(-1px, -1px);
}

.footer-tip {
  font-size: 0.68rem;
  color: var(--color-text-muted);
  text-align: center;
}

/* === 响应式设计 === */
@media (max-width: 900px) {
  #app {
    height: 100vh;
    height: 100dvh;
    width: 100%;
  }
  .sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.48);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 30;
  }
  .sidebar-overlay.open {
    opacity: 1;
    pointer-events: auto;
  }
  #sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: min(84vw, 320px);
    max-width: calc(100vw - 44px);
    height: 100vh;
    height: 100dvh;
    transform: translateX(-100%);
    box-shadow: var(--shadow);
    z-index: 40;
    overflow: hidden;
  }
  #sidebar.open {
    transform: translateX(0);
  }
  .sidebar-close-btn {
    display: flex;
  }
  .menu-toggle {
    display: flex;
    flex-shrink: 0;
  }
  #chatMain {
    width: 100%;
    height: 100%;
    min-height: 0;
  }
  .chat-header {
    height: 56px;
    padding: 0 0.75rem;
    gap: 0.6rem;
  }
  .header-left {
    min-width: 0;
    gap: 0.6rem;
  }
  .header-right {
    display: flex;
    margin-left: auto;
    min-width: 0;
  }
  .status-indicator {
    display: none;
  }
  .skill-observer {
    max-width: 42vw;
    justify-content: flex-end;
    gap: 0.2rem 0.4rem;
    padding: 0.25rem 0.4rem;
    font-size: 0.62rem;
  }
  .skill-observer span {
    white-space: nowrap;
  }
  .model-dropdown {
    min-width: 0;
  }
  .dropdown-trigger {
    max-width: calc(100vw - 72px);
    padding: 0.42rem 0.55rem;
    gap: 0.35rem;
  }
  .model-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .dropdown-menu {
    width: min(260px, calc(100vw - 1.5rem));
  }
  .messages {
    padding: 1rem 0.75rem;
    gap: 1rem;
  }
  .message {
    width: 100%;
    max-width: 100%;
    padding: 0;
    gap: 0.6rem;
  }
  .message .avatar {
    width: 30px;
    height: 30px;
    border-radius: 7px;
    font-size: 0.78rem;
  }
  .bubble {
    max-width: calc(100% - 42px);
    padding: 0.75rem 0.85rem;
    font-size: 0.9rem;
  }
  .chat-footer {
    padding: 0.75rem 0.75rem calc(0.75rem + env(safe-area-inset-bottom));
  }
  .input-container {
    max-width: none;
    gap: 0.5rem;
    padding: 0.55rem 0.65rem;
  }
  .attach-btn,
  .send-btn {
    width: 34px;
    height: 34px;
  }
  #userInput {
    font-size: 16px;
    max-height: 112px;
  }
  .footer-tip {
    display: none;
  }
  .artifact-card {
    padding: 0.85rem;
  }
  .card-header {
    align-items: flex-start;
    gap: 0.6rem;
  }
  .card-title {
    flex: 1;
    font-size: 0.84rem;
    line-height: 1.35;
  }
  .card-status {
    flex-shrink: 0;
    margin-top: 0.05rem;
  }
  .card-body {
    padding: 0.65rem;
    font-size: 0.84rem;
    max-height: 42dvh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .card-actions {
    gap: 0.5rem;
  }
  .card-btn {
    flex: 1 1 100%;
    min-height: 38px;
  }
}

/* === 优雅的自定义滚动条 === */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(155, 140, 255, 0.2);
}

/* === 亮色主题覆盖 (Light Theme) === */
body[data-theme="light"] {
  --color-base: #f7f7f8;
  --color-sidebar: #ffffff;
  --color-surface: #f3f4f6;
  --color-surface-hover: #e9eaf0;
  --color-border: #e5e7eb;
  --color-text: #111827;
  --color-text-muted: #6b7280;
  --color-eliy-bubble: rgba(155, 140, 255, 0.06);
  --color-user-bubble: rgba(255, 178, 107, 0.08);
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  background: var(--color-base);
  color: var(--color-text);
}

/* 亮色：聊天区背景 */
body[data-theme="light"] #chatMain {
  background: #ffffff;
}
body[data-theme="light"] .chat-header {
  background: #ffffff;
}
body[data-theme="light"] .chat-footer {
  background: linear-gradient(180deg, transparent, #ffffff 40%);
}

/* 亮色：输入框与发送按钮 */
body[data-theme="light"] .input-container {
  background: #ffffff;
  box-shadow: 0 0 0 1px var(--color-border);
}
body[data-theme="light"] .send-btn {
  background: var(--color-eliy);
}
body[data-theme="light"] .send-btn .send-icon {
  fill: #ffffff;
}

/* 亮色：新建对话按钮 */
body[data-theme="light"] .new-chat-btn {
  background: var(--color-eliy);
  border-color: var(--color-eliy);
  color: #ffffff;
}
body[data-theme="light"] .new-chat-btn:hover {
  background: #8574f5;
  border-color: #8574f5;
}

/* 亮色：搜索框 */
body[data-theme="light"] .search-box input {
  background: #f3f4f6;
  border-color: var(--color-border);
  color: var(--color-text);
}

/* 亮色：Skill 与对话列表项 */
body[data-theme="light"] .skill-item,
body[data-theme="light"] .history-item {
  background: transparent;
  border-color: transparent;
  border-left-color: transparent;
}
body[data-theme="light"] .skill-item:hover,
body[data-theme="light"] .history-item:hover {
  background: #f3f4f6;
  border-color: var(--color-border);
  border-left-color: transparent;
}
body[data-theme="light"] .skill-item.active {
  background: transparent;
  border-color: transparent;
  border-left-color: var(--color-eliy);
  box-shadow: none;
}
body[data-theme="light"] .skill-item.active .history-title {
  color: var(--color-eliy);
}

/* 亮色：S'FOCUS Skill 按钮专属样式 */
body[data-theme="light"] #sfocusSkillBtn {
  background: rgba(155, 140, 255, 0.08);
  border: 1px solid rgba(155, 140, 255, 0.3);
}
body[data-theme="light"] #sfocusSkillBtn:hover {
  background: rgba(155, 140, 255, 0.15);
}
body[data-theme="light"] #sfocusSkillBtn.active {
  background: rgba(155, 140, 255, 0.15);
  border-color: var(--color-eliy);
  border-left-color: var(--color-eliy);
}

/* 亮色：成果卡与行动卡 */
body[data-theme="light"] .artifact-card {
  background: #ffffff;
  border-color: #e5e7eb;
}
body[data-theme="light"] .card-header {
  border-bottom-color: #e5e7eb;
}
body[data-theme="light"] .card-title {
  color: #111827; /* 标题主色 */
}
body[data-theme="light"] .card-body {
  color: #374151; /* 正文主色 */
  background: #f9fafb; /* 内容块背景 */
  border-left-color: var(--color-eliy); /* 淡紫强调线 */
}
body[data-theme="light"] .card-body strong {
  color: #111827; /* 粗体主色 */
}
body[data-theme="light"] .card-status.pending {
  background: rgba(155, 140, 255, 0.12);
  color: #6366f1; /* 亮色模式选用稍深紫色以保证良好对比度 */
  border-color: rgba(155, 140, 255, 0.3);
}
body[data-theme="light"] .card-actions {
  color: #4b5563;
}
body[data-theme="light"] .card-actions .card-action-tip {
  color: #4b5563 !important;
}

body[data-theme="light"] .gate2-panel,
body[data-theme="light"] .gate2-error-banner,
body[data-theme="light"] .gate2-legacy-fallback {
  background: #ffffff;
  border-color: #e5e7eb;
}

body[data-theme="light"] .gate2-error-banner {
  background: #fff1f2;
  border-color: #fecdd3;
}

body[data-theme="light"] .gate2-panel-title,
body[data-theme="light"] .gate2-meta,
body[data-theme="light"] .gate2-muted,
body[data-theme="light"] .gate2-legacy-fallback {
  color: #374151;
}

body[data-theme="light"] .gate2-panel-pill,
body[data-theme="light"] .gate2-trace-chip {
  background: rgba(155, 140, 255, 0.12);
  border-color: rgba(155, 140, 255, 0.25);
}

/* 亮色：下拉菜单 */
body[data-theme="light"] .dropdown-trigger,
body[data-theme="light"] .dropdown-menu {
  background: #ffffff;
  border-color: var(--color-border);
}
body[data-theme="light"] .dropdown-item:hover {
  background: #f3f4f6;
}

/* 亮色：用户信息栏 */
body[data-theme="light"] .user-profile {
  background: #f3f4f6;
  border-color: var(--color-border);
}

/* 亮色：滚动条 */
body[data-theme="light"] ::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.12);
}
body[data-theme="light"] ::-webkit-scrollbar-thumb:hover {
  background: rgba(155, 140, 255, 0.4);
}
