/* ========== CSS Variables ========== */
:root {
  --bg: #151517;
  --bg-sidebar: #1b1b1b;
  --bg-main: #151517;
  --surface-1: #2d2e2f;
  --surface-2: #3b3b3b;
  --surface-3: #43474b;
  --border: #3e434b;
  --primary: #7c5cfc;
  --primary-hover: #8b6ffd;
  --primary-active: #6b4ce0;
  --text-primary: #dbdbdb;
  --text-secondary: #b3b3b3;
  --text-muted: #838383;
  --text-dim: #707070;
  --input-bg: #2b2d30;
  --input-border: #3e434b;
  --hover-bg: rgba(255,255,255,0.06);
  --active-bg: rgba(255,255,255,0.1);
  --border-subtle: rgba(255,255,255,0.06);
  --message-user-bg: #414158;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 4096px;
  --sidebar-width: 260px;
  --font: system-ui, -apple-system, "Segoe UI", "Roboto", "Ubuntu", "Cantarell", "Noto Sans", sans-serif;
  --transition: 0.2s ease;
}

/* ========== Light Theme ========== */
html.theme-light {
  --bg: #faf9fd;
  --bg-sidebar: #f4f0fb;
  --bg-main: #faf9fd;
  --surface-1: #efeaf8;
  --surface-2: #e5def4;
  --surface-3: #d9d0ec;
  --border: #e2dcf1;
  --primary: #7c5cfc;
  --primary-hover: #6d4ff5;
  --primary-active: #5f42e8;
  --text-primary: #2a2438;
  --text-secondary: #5a5470;
  --text-muted: #8a84a0;
  --text-dim: #a29bb8;
  --input-bg: #ffffff;
  --input-border: #e2dcf1;
  --hover-bg: rgba(124, 92, 252, 0.08);
  --active-bg: rgba(124, 92, 252, 0.14);
  --border-subtle: rgba(0, 0, 0, 0.06);
  --message-user-bg: #ece7f9;
}

/* ========== Reset ========== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; }
body { font-family: var(--font); font-size: 15px; line-height: 1.5; color: var(--text-primary); background: var(--bg); height: 100%; overflow: hidden; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea { font-family: inherit; color: inherit; }
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface-2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--surface-3); }

/* 主题切换过渡动画（仅切换期间由 JS 临时加类） */
html.theme-transition,
html.theme-transition *,
html.theme-transition *::before,
html.theme-transition *::after {
  transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease, fill 0.3s ease, stroke 0.3s ease !important;
}

/* ========== App Layout ========== */
.app {
  display: flex;
  height: 100vh;
  width: 100%;
}

/* ========== Sidebar ========== */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border-subtle);
  transition: width var(--transition), min-width var(--transition), opacity var(--transition);
  overflow: hidden;
  z-index: 100;
}
.sidebar.collapsed {
  width: 0;
  min-width: 0;
  border-right: none;
  opacity: 0;
  pointer-events: none;
}

.sidebar-expand {
  display: none;
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 50;
  align-items: center;
  gap: 8px;
  padding: 8px 4px;
  cursor: pointer;
  transition: color var(--transition);
  color: var(--text-primary);
  font-size: 16px;
  font-weight: 600;
}
.sidebar-expand:hover { color: var(--primary); }
.sidebar-expand svg { flex-shrink: 0; }
.sidebar.collapsed ~ .main .sidebar-expand { display: flex; }

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  gap: 12px;
}
.logo-area {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.logo-icon { flex-shrink: 0; }
.logo-text {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
}

.btn-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  transition: background var(--transition), color var(--transition);
  flex-shrink: 0;
}
.btn-icon:hover { background: var(--hover-bg); color: var(--text-primary); }

.sidebar-toggle { display: none; }
.sidebar:not(.collapsed) .sidebar-toggle { display: flex; }

.sidebar-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Chat List */
.chat-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 8px;
}
.chat-list-label {
  font-size: 12px;
  color: var(--text-dim);
  padding: 4px 8px 8px;
}
.chat-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition);
  user-select: none;
}
.chat-item:hover { background: var(--hover-bg); }
.chat-item.active { background: var(--active-bg); }
.chat-item-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  color: var(--text-secondary);
}
.chat-item.active .chat-item-name { color: var(--text-primary); }
.chat-item-menu {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  color: var(--text-dim);
  opacity: 0;
  transition: opacity var(--transition), background var(--transition);
  flex-shrink: 0;
}
.chat-item:hover .chat-item-menu { opacity: 1; }
.chat-item-menu:hover { background: var(--active-bg); color: var(--text-primary); }

/* Sidebar Footer */
.sidebar-footer {
  padding: 12px;
}
.sidebar-footer-actions {
  display: flex;
  justify-content: flex-end;
  gap: 4px;
}
.btn-settings,
.btn-theme {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  transition: background var(--transition), color var(--transition);
}
.btn-settings:hover,
.btn-theme:hover { background: var(--hover-bg); color: var(--text-primary); }

/* ========== Main Area ========== */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-main);
  min-width: 0;
}

/* Mobile Header */
.mobile-header {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-main);
}
.mobile-title { font-size: 16px; font-weight: 600; }

/* Welcome Screen */
.welcome-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
}
.welcome-screen h1 { font-size: 24px; font-weight: 600; color: var(--text-primary); }
.welcome-sub { font-size: 14px; color: var(--text-muted); }

/* Messages Area */
.messages-area {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.messages-container {
  width: 100%;
  max-width: 768px;
  margin: 0 auto;
  padding: 80px 24px 24px;
}

/* Message Bubble */
.message {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
  width: 100%;
}
.message.user { justify-content: flex-end; }
.message.assistant { justify-content: flex-start; }

.message-body {
  max-width: 85%;
  min-width: 0;
  width: fit-content;
}

.message-content {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 15px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}
.message.user .message-content {
  background: var(--message-user-bg);
  color: var(--text-primary);
  border-bottom-right-radius: 4px;
}
.message.assistant .message-content {
  background: transparent;
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
  white-space: normal;
}

/* Markdown 渲染内容 */
.message.assistant .message-content > *:first-child { margin-top: 0; }
.message.assistant .message-content > *:last-child { margin-bottom: 0; }
.message.assistant .message-content p { margin: 0 0 8px; }
.message.assistant .message-content h1,
.message.assistant .message-content h2,
.message.assistant .message-content h3,
.message.assistant .message-content h4,
.message.assistant .message-content h5,
.message.assistant .message-content h6 {
  margin: 16px 0 8px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text-primary);
}
.message.assistant .message-content h1 { font-size: 1.4em; }
.message.assistant .message-content h2 { font-size: 1.25em; }
.message.assistant .message-content h3 { font-size: 1.1em; }
.message.assistant .message-content ul,
.message.assistant .message-content ol {
  margin: 0 0 8px;
  padding-left: 20px;
}
.message.assistant .message-content li { margin: 2px 0; }
.message.assistant .message-content a {
  color: var(--primary);
  text-decoration: underline;
  word-break: break-all;
}
.message.assistant .message-content code {
  background: var(--surface-1);
  padding: 2px 5px;
  border-radius: 4px;
  font-family: "Cascadia Code", Consolas, "DejaVu Sans Mono", "SF Mono", Menlo, "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", sans-serif;
  font-size: 0.9em;
}
.message.assistant .message-content pre {
  position: relative;
  background: var(--surface-1);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  margin: 0 0 8px;
  white-space: pre;
}
.code-copy-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  color: var(--text-dim);
  background: var(--surface-2);
  opacity: 0.9;
  transition: background var(--transition), color var(--transition), opacity var(--transition);
}
.code-copy-btn:hover { background: var(--surface-3); color: var(--text-primary); opacity: 1; }
.code-lang {
  position: absolute;
  bottom: 4px;
  right: 8px;
  font-size: 11px;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--text-dim);
  background: var(--surface-2);
  opacity: 0.9;
  font-family: "Cascadia Code", Consolas, "DejaVu Sans Mono", "SF Mono", Menlo, "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", sans-serif;
  user-select: none;
  pointer-events: none;
}
.message.assistant .message-content pre code {
  background: none;
  padding: 0;
  font-size: 13px;
}
.message.assistant .message-content blockquote {
  border-left: 3px solid var(--primary);
  padding-left: 12px;
  color: var(--text-secondary);
  margin: 0 0 8px;
}
.message.assistant .message-content table {
  border-collapse: collapse;
  margin: 0 0 8px;
  width: 100%;
  display: block;
  overflow-x: auto;
}
.message.assistant .message-content th,
.message.assistant .message-content td {
  border: 1px solid var(--border);
  padding: 6px 10px;
  text-align: left;
}
.message.assistant .message-content th { background: var(--surface-1); font-weight: 600; }
.message.assistant .message-content img {
  max-width: 100%;
  border-radius: var(--radius-sm);
}
.message.assistant .message-content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 12px 0;
}

/* ========== Light Theme 代码高亮（github light 配色） ========== */
html.theme-light .hljs {
  color: #24292e;
}
html.theme-light .hljs-comment,
html.theme-light .hljs-quote { color: #6a737d; }
html.theme-light .hljs-keyword,
html.theme-light .hljs-selector-tag,
html.theme-light .hljs-subst { color: #d73a49; }
html.theme-light .hljs-number,
html.theme-light .hljs-literal,
html.theme-light .hljs-variable,
html.theme-light .hljs-template-variable,
html.theme-light .hljs-tag .hljs-attr { color: #005cc5; }
html.theme-light .hljs-string,
html.theme-light .hljs-doctag { color: #032f62; }
html.theme-light .hljs-title,
html.theme-light .hljs-section,
html.theme-light .hljs-selector-id { color: #6f42c1; }
html.theme-light .hljs-type,
html.theme-light .hljs-class .hljs-title { color: #005cc5; }
html.theme-light .hljs-tag,
html.theme-light .hljs-name,
html.theme-light .hljs-attribute { color: #22863a; }
html.theme-light .hljs-regexp,
html.theme-light .hljs-link { color: #032f62; }
html.theme-light .hljs-symbol,
html.theme-light .hljs-bullet { color: #e36209; }
html.theme-light .hljs-built_in,
html.theme-light .hljs-builtin-name { color: #005cc5; }
html.theme-light .hljs-meta { color: #032f62; }
html.theme-light .hljs-deletion { color: #b31d28; }
html.theme-light .hljs-addition { color: #22863a; }
html.theme-light .hljs-emphasis { font-style: italic; }
html.theme-light .hljs-strong { font-weight: bold; }

/* Thinking Block */
.thinking-block {
  margin-bottom: 8px;
  border-left: 3px solid var(--primary);
  padding: 8px 12px;
  background: rgba(124, 92, 252, 0.06);
  border-radius: 0;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  max-height: 207px;
  overflow-y: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  cursor: pointer;
  transition: max-height 0.3s ease;
}
.thinking-block::-webkit-scrollbar {
  display: none;
}
.thinking-content {
  white-space: pre-line;
}
.thinking-block.collapsed {
  max-height: 32px;
  overflow: hidden;
}
.thinking-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}
.thinking-label svg { width: 12px; height: 12px; flex-shrink: 0; }

.message-actions {
  display: flex;
  gap: 4px;
  margin-top: 8px;
  opacity: 0;
  transition: opacity var(--transition);
}
.message.user .message-actions { justify-content: flex-end; }
.message:hover .message-actions { opacity: 1; }
.msg-action-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  color: var(--text-dim);
  transition: background var(--transition), color var(--transition);
}
.msg-action-btn:hover { background: var(--hover-bg); color: var(--text-secondary); }

/* Token 用量 */
.msg-usage {
  display: flex;
  align-items: center;
  font-size: 11px;
  color: var(--text-dim);
  padding: 0 4px;
  user-select: none;
  white-space: nowrap;
}

/* 编辑指示条 */
.edit-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  margin-bottom: 6px;
  border-radius: var(--radius-sm);
  background: var(--surface-1);
  font-size: 12px;
  color: var(--text-secondary);
}
.edit-bar-cancel {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--text-dim);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
}
.edit-bar-cancel:hover { background: var(--hover-bg); color: var(--text-primary); }

/* ========== Input Area ========== */
.input-area {
  padding: 0 24px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.input-wrapper {
  width: 100%;
  max-width: 768px;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--radius-lg);
  padding: 12px 16px;
  transition: border-color var(--transition);
}
.input-wrapper:focus-within { border-color: var(--primary); }
.input-area.drag-over .input-wrapper {
  border-color: var(--primary);
  border-style: dashed;
  background: var(--hover-bg);
}

#promptInput {
  width: 100%;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 15px;
  line-height: 1.5;
  resize: none;
  min-height: 24px;
  max-height: 200px;
}
#promptInput::placeholder { color: var(--text-dim); }

.input-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
}

/* Feature Buttons */
.feature-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.feature-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border: 1px solid var(--surface-2);
  border-radius: var(--radius-full);
  font-size: 12px;
  color: var(--text-dim);
  transition: all var(--transition);
  white-space: nowrap;
}
.feature-btn:hover { border-color: var(--text-dim); color: var(--text-secondary); }
.feature-btn.active {
  border-color: var(--primary);
  background: rgba(124, 92, 252, 0.15);
  color: var(--primary);
}

/* Send / Stop Buttons */
.send-area { display: flex; align-items: center; gap: 8px; }
.btn-send {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--text-dim);
  color: var(--bg);
  transition: background var(--transition);
}
.btn-send:not(:disabled) { background: var(--primary); cursor: pointer; }
.btn-send:not(:disabled):hover { background: var(--primary-hover); }
.btn-send:disabled { cursor: not-allowed; }

.btn-stop {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #ef4444;
  color: #fff;
  cursor: pointer;
  transition: background var(--transition);
}
.btn-stop:hover { background: #dc2626; }

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

/* Image Preview（待发送图片） */
.image-preview {
  display: none;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 4px 4px;
}
.image-preview-item {
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.image-preview-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.image-preview-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(0,0,0,0.6);
  color: #fff;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
}
.image-preview-remove:hover { background: rgba(0,0,0,0.8); }

/* 上传中占位（转圈） */
.image-preview-item.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-1);
}
.image-preview-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--surface-3);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: image-spin 0.8s linear infinite;
}
@keyframes image-spin {
  to { transform: rotate(360deg); }
}

/* 上传失败占位 */
.image-preview-item.error {
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
  font-size: 16px;
  font-weight: 600;
}

/* 文件预览（待发送文件，长方形显示文件名） */
.file-preview-item {
  position: relative;
  width: 128px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: var(--surface-1);
  overflow: hidden;
  padding: 0 20px;
}
.file-preview-item.loading {
  background: var(--surface-1);
}
.file-preview-name {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* 用户消息中的图片 */
.message-images {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}
.message-images img {
  max-width: 240px;
  max-height: 240px;
  border-radius: var(--radius-sm);
  display: block;
}

/* 用户消息中的文件 */
.message-files {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}
.file-card {
  display: flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-1);
  border: 1px solid var(--border);
  max-width: 240px;
}
.file-card-name {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 图片按钮（发送按钮左侧） */
.btn-image {
  width: 36px;
  height: 36px;
}

/* 文件按钮（发送按钮左侧） */
.btn-file {
  width: 36px;
  height: 36px;
}

/* ========== Settings Modal ========== */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
}
.modal {
  background: var(--surface-1);
  border: 1px solid var(--surface-2);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 420px;
  margin: 0 16px;
  box-shadow: 0 24px 48px rgba(0,0,0,0.4);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 0;
}
.modal-header h2 { font-size: 18px; font-weight: 600; }
.modal-close {
  width: 32px;
  height: 32px;
  font-size: 20px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}
.modal-close:hover { background: var(--hover-bg); color: var(--text-primary); }

.modal-body { padding: 20px 24px; }
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.form-group input {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--surface-2);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text-primary);
  outline: none;
  transition: border-color var(--transition);
}
.form-group input:focus { border-color: var(--primary); }
.form-group input::placeholder { color: var(--text-dim); }
.form-group textarea {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--surface-2);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text-primary);
  outline: none;
  resize: vertical;
  min-height: 60px;
  transition: border-color var(--transition);
}
.form-group textarea:focus { border-color: var(--primary); }
.form-group textarea::placeholder { color: var(--text-dim); }
.form-row { display: flex; gap: 12px; }
.form-row .form-group { flex: 1; }

.toggle-label {
  display: flex !important;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
}
.toggle-label input[type="checkbox"][role="switch"] {
  appearance: none;
  -webkit-appearance: none;
  width: 40px;
  height: 22px;
  border-radius: 11px;
  background: var(--surface-2);
  position: relative;
  cursor: pointer;
  transition: background var(--transition);
  border: none;
  outline: none;
  flex-shrink: 0;
}
.toggle-label input[type="checkbox"][role="switch"]::before {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: transform var(--transition);
}
.toggle-label input[type="checkbox"][role="switch"]:checked {
  background: var(--primary);
}
.toggle-label input[type="checkbox"][role="switch"]:checked::before {
  transform: translateX(18px);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 0 24px 20px;
}
.btn-secondary {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text-secondary);
  transition: background var(--transition), color var(--transition);
}
.btn-secondary:hover { background: var(--hover-bg); color: var(--text-primary); }
.btn-primary {
  padding: 8px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  background: var(--primary);
  color: #fff;
  transition: background var(--transition);
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger {
  width: 100%;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  background: transparent;
  color: #ef4444;
  border: 1px solid #ef4444;
  transition: background var(--transition), color var(--transition);
}
.btn-danger:hover { background: #ef4444; color: #fff; }

/* ========== Context Menu ========== */
.context-menu {
  position: fixed;
  z-index: 2000;
  background: var(--surface-1);
  border: 1px solid var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 4px;
  min-width: 140px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.context-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.context-menu-item:hover { background: var(--hover-bg); color: var(--text-primary); }
.context-menu-item[data-action="delete"]:hover { color: #ef4444; }

/* ========== Mobile ========== */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100%;
    z-index: 200;
    transform: translateX(-100%);
    transition: transform var(--transition);
  }
  .sidebar.mobile-open {
    transform: translateX(0);
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    opacity: 1;
    pointer-events: auto;
  }
  /* 手机端侧边栏由 transform 控制显隐，忽略 collapsed 的宽度/透明效果 */
  .sidebar.collapsed {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    border-right: 1px solid var(--border-subtle);
    opacity: 1;
    pointer-events: auto;
  }
  /* 手机端侧边栏打开时始终显示收起按钮 */
  .sidebar.mobile-open .sidebar-toggle { display: flex; }
  .mobile-header { display: flex; }
  .sidebar-expand { display: none !important; }
  .messages-container { padding: 16px; }
  .message-body { max-width: 100%; }
  .input-area { padding: 0 12px 12px; }
  .feature-buttons { gap: 4px; }
  .feature-btn { padding: 4px 8px; font-size: 11px; }
}
