/* 全局重置 */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* 主题色彩变量 —— 深色 GitHub 风格配色方案
   bg/surface/surface2: 三层深色背景，由深到浅
   accent: 蓝色强调色，用于链接、选中态、主按钮
   danger/success: 语义色，用于删除操作和免费/无审核标记 */
:root {
  --bg: #0d1117;
  --surface: #161b22;
  --surface2: #1c2129;
  --border: #30363d;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --accent: #58a6ff;
  --accent-hover: #79b8ff;
  --danger: #f85149;
  --success: #3fb950;
  --radius: 8px;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

/* ── Header · 顶部导航栏 ─────────────────────────────── */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
header h1 {
  font-size: 18px;
  font-weight: 600;
  color: var(--accent);
}
.header-actions button {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 6px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  transition: all 0.15s;
}
.header-actions button:hover {
  color: var(--text);
  border-color: var(--accent);
}
.header-actions button:last-child:hover {
  color: var(--danger);
  border-color: var(--danger);
}

/* ── Layout · 页面主体：侧栏 + 聊天区的 flex 横向布局 ── */
.layout {
  display: flex;
  height: calc(100vh - 53px);
  overflow: hidden;
}

/* ── Sidebar · 左侧配置面板（固定宽度，纵向滚动） ──── */
.sidebar {
  width: 340px;
  min-width: 340px;
  border-right: 1px solid var(--border);
  background: var(--surface);
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.panel h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}
.panel textarea,
.panel input[type="text"],
.panel input[type="number"],
.panel select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius);
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
  transition: border-color 0.15s;
}
.panel textarea:focus,
.panel input:focus,
.panel select:focus {
  outline: none;
  border-color: var(--accent);
}

/* ── Character Card · 角色卡选择栏、信息展示、标签与操作按钮 ── */
.char-bar {
  display: flex;
  gap: 6px;
}
.char-bar select { flex: 1; }
.char-bar button {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 5px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  transition: border-color 0.15s;
}
.char-bar button:hover { border-color: var(--accent); color: var(--accent); }

.char-info {
  margin-top: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 10px;
}
.kol-version-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}
.char-info-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.char-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  font-size: 10px;
}
.char-tag {
  background: var(--surface2);
  color: var(--text-muted);
  padding: 1px 6px;
  border-radius: 3px;
}
.char-info-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.char-info-actions button {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13px;
  padding: 0 3px;
  transition: color 0.15s;
}
.char-info-actions button:hover { color: var(--accent); }
.char-info-actions button.danger:hover { color: var(--danger); }
.btn-greeting {
  margin-top: 6px;
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 5px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 12px;
  transition: all 0.15s;
}
.btn-greeting:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* 角色编辑器弹窗：多字段表单，纵向可滚动 */
.dialog.char-editor {
  min-width: 580px;
  max-width: 720px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}
.char-editor-fields {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 65vh;
  padding-right: 4px;
}
.char-field label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 3px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.char-field input,
.char-field textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
  margin-bottom: 0;
}
.char-field input:focus,
.char-field textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.char-field .hint {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* 预设栏：下拉选择 + 保存/删除按钮 */
.preset-bar {
  display: flex;
  gap: 6px;
}
.preset-bar select { flex: 1; }
.preset-bar button {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
  transition: border-color 0.15s;
}
.preset-bar button:hover { border-color: var(--accent); }

/* RP 输出格式切换（RP格式/纯对话/无格式） */
.rp-format-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

/* ── World Books · 世界书列表与条目卡片 ──────────────── */
.wb-toolbar {
  display: flex;
  gap: 6px;
}
.wb-toolbar button {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 5px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 12px;
  transition: border-color 0.15s;
}
.wb-toolbar button:hover { border-color: var(--accent); color: var(--accent); }

.wb-list {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 280px;
  overflow-y: auto;
}

.wb-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 10px;
  transition: border-color 0.15s;
}
.wb-card.disabled { opacity: 0.5; }
.wb-card-header {
  display: flex;
  align-items: center;
  gap: 6px;
}
.wb-card-header input[type="checkbox"] {
  accent-color: var(--accent);
  width: 14px;
  height: 14px;
  cursor: pointer;
  flex-shrink: 0;
}
.wb-card-header .wb-name {
  flex: 1;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wb-card-header .wb-count {
  font-size: 10px;
  color: var(--text-muted);
  flex-shrink: 0;
}
.wb-card-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.wb-card-actions button {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13px;
  padding: 0 3px;
  line-height: 1;
  transition: color 0.15s;
}
.wb-card-actions button:hover { color: var(--accent); }
.wb-card-actions button.danger:hover { color: var(--danger); }

/* 世界书编辑器弹窗：条目列表的增删改 */
.dialog.wb-editor {
  min-width: 520px;
  max-width: 680px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}
.dialog.wb-editor h3 { flex-shrink: 0; }
.wb-editor-name {
  margin-bottom: 12px;
}
.wb-entries {
  flex: 1;
  overflow-y: auto;
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 100px;
  max-height: 50vh;
}
.wb-entry {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px;
}
.wb-entry-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.wb-entry-header label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-muted);
  cursor: pointer;
}
.wb-entry-header label input[type="checkbox"] {
  accent-color: var(--accent);
  width: 13px;
  height: 13px;
}
.wb-entry-header button {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  padding: 0 4px;
}
.wb-entry-header button:hover { color: var(--danger); }
.wb-entry input[type="text"] {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 4px;
  padding: 5px 8px;
  font-size: 12px;
  margin-bottom: 4px;
}
.wb-entry input:focus { outline: none; border-color: var(--accent); }
.wb-entry textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 4px;
  padding: 5px 8px;
  font-size: 12px;
  font-family: inherit;
  resize: vertical;
  min-height: 50px;
}
.wb-entry textarea:focus { outline: none; border-color: var(--accent); }
.wb-add-entry {
  background: var(--surface);
  border: 1px dashed var(--border);
  color: var(--text-muted);
  border-radius: 6px;
  padding: 8px;
  text-align: center;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.15s;
}
.wb-add-entry:hover { border-color: var(--accent); color: var(--accent); }

/* 模型过滤栏：无审核筛选复选框 + 模型计数 */
.filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 6px;
  margin-bottom: 2px;
}
.toggle-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}
.toggle-label input[type="checkbox"] {
  accent-color: var(--accent);
  width: 14px;
  height: 14px;
  cursor: pointer;
}
.model-count {
  font-size: 11px;
  color: var(--text-muted);
}

/* 模型列表：可滚动的多选列表，含名称、元信息和状态徽章 */
.model-list {
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-top: 4px;
  background: var(--bg);
}
.model-list .model-item {
  padding: 7px 10px;
  cursor: pointer;
  font-size: 12px;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
  display: flex;
  align-items: center;
  gap: 6px;
}
.model-list .model-item:last-child { border-bottom: none; }
.model-list .model-item:hover { background: var(--surface2); }
.model-list .model-item.selected { background: var(--surface2); color: var(--accent); }
.model-list .model-item .check {
  width: 16px;
  height: 16px;
  border: 1px solid var(--border);
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 11px;
}
.model-list .model-item.selected .check {
  background: var(--accent);
  border-color: var(--accent);
  color: #000;
}
.model-list .model-item .model-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.model-list .model-item .model-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.model-list .model-item .model-meta {
  display: flex;
  gap: 6px;
  font-size: 10px;
  color: var(--text-muted);
}
.badge {
  display: inline-block;
  padding: 0 5px;
  border-radius: 3px;
  font-size: 9px;
  font-weight: 600;
  line-height: 16px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.badge-free {
  background: var(--success);
  color: #000;
}
.badge-moderated {
  background: #da3633;
  color: #fff;
}
.badge-unmoderated {
  background: var(--success);
  color: #000;
}

.selected-models {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}
.selected-models .label {
  font-size: 12px;
  color: var(--text-muted);
}
.model-tag {
  background: var(--accent);
  color: #000;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: default;
}
.model-tag .remove {
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  opacity: 0.7;
}
.model-tag .remove:hover { opacity: 1; }

/* 参数调节面板：滑块和数字输入 */
.param-group {
  margin-bottom: 10px;
}
.param-group label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.param-group label span {
  color: var(--accent);
  font-weight: 600;
}
.param-group input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

/* ── Chat Area · 聊天主区域：多模型并列对话列 ────────── */
.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-columns {
  flex: 1;
  display: flex;
  gap: 0;
  overflow: hidden;
}

.placeholder-msg {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  color: var(--text-muted);
  font-size: 16px;
}

.chat-column {
  flex: 1;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  overflow: hidden;
}
.chat-column:last-child { border-right: none; }

.chat-column-header {
  padding: 8px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  text-align: center;
  flex-shrink: 0;
}

.chat-char-desc {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  max-height: 220px;
  overflow-y: auto;
}
.chat-char-desc summary {
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
}
.chat-char-desc summary:hover {
  color: var(--accent);
}
.chat-char-desc-body {
  padding: 4px 12px 10px 12px;
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-muted);
  white-space: pre-wrap;
  word-wrap: break-word;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.message {
  max-width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  line-height: 1.6;
  word-wrap: break-word;
  overflow-wrap: break-word;
}
.message.user {
  background: #1a3a5c;
  align-self: flex-end;
  border-bottom-right-radius: 2px;
}
.message.assistant {
  background: var(--surface2);
  align-self: flex-start;
  border-bottom-left-radius: 2px;
}
.message.assistant .content p { margin-bottom: 0.5em; }
.message.assistant .content p:last-child { margin-bottom: 0; }
.message.assistant .content pre {
  background: var(--bg);
  padding: 10px;
  border-radius: 6px;
  overflow-x: auto;
  margin: 8px 0;
}
.message.assistant .content code {
  background: var(--bg);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 12px;
}
.message.assistant .content pre code {
  background: none;
  padding: 0;
}

/* RP 格式化颜色：*动作* 用紫色斜体，「对话」用橙色 */
.rp-action {
  color: #d2a8ff;
  font-style: italic;
}
.rp-dialogue {
  color: #ffa657;
}

.message .streaming-cursor {
  display: inline-block;
  width: 6px;
  height: 14px;
  background: var(--accent);
  margin-left: 2px;
  animation: blink 0.8s infinite;
  vertical-align: text-bottom;
}
@keyframes blink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}

/* ── Hint Bar · AI 输入提示条 ───────────────────────── */
.hint-bar {
  display: flex;
  gap: 8px;
  padding: 8px 16px 0;
  background: var(--surface);
  flex-wrap: wrap;
}
.hint-chip {
  flex: 1;
  min-width: 0;
  background: var(--bg);
  border: 1px solid var(--accent);
  color: var(--text);
  border-radius: var(--radius);
  padding: 7px 14px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  line-height: 1.4;
  transition: background 0.15s, border-color 0.15s;
  white-space: normal;
  word-break: break-all;
}
.hint-chip:hover {
  background: color-mix(in srgb, var(--accent) 15%, var(--bg));
  border-color: var(--accent-hover);
}
.hint-chip:empty { display: none; }
.hint-chip.loading {
  opacity: 0.5;
  cursor: wait;
  animation: pulse 1s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 0.85; }
}

/* ── Input Bar · 底部消息输入栏 ─────────────────────── */
.input-bar {
  display: flex;
  gap: 8px;
  padding: 10px 16px 12px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.input-bar textarea {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  resize: none;
  line-height: 1.4;
}
.input-bar textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.input-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.input-actions button {
  background: var(--accent);
  color: #000;
  border: none;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}
.input-actions button:hover { background: var(--accent-hover); }
.input-actions button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
#btn-hint {
  background: var(--surface) !important;
  color: var(--text) !important;
  border: 1px solid var(--border) !important;
  font-weight: 500 !important;
}
#btn-hint:hover {
  border-color: var(--accent) !important;
  color: var(--accent) !important;
  background: var(--bg) !important;
}
#btn-hint:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── Scrollbar · 全局滚动条样式（细窄暗色） ──────────── */
::-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); }

/* ── Dialog · 模态弹窗系统：半透明遮罩 + 居中面板 ──── */
.dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.dialog {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  min-width: 360px;
  max-width: 480px;
}
.dialog h3 {
  margin-bottom: 12px;
  font-size: 16px;
}
.dialog input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 10px;
  border-radius: var(--radius);
  font-size: 14px;
  margin-bottom: 16px;
}
.dialog input:focus { outline: none; border-color: var(--accent); }
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.dialog-actions button {
  padding: 8px 18px;
  border-radius: var(--radius);
  font-size: 13px;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  transition: all 0.15s;
}
.dialog-actions button:hover { border-color: var(--accent); }
.dialog-actions button.primary {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
  font-weight: 600;
}
.dialog-actions button.primary:hover { background: var(--accent-hover); }

/* ── Generator Tabs · AI生成器的选项卡切换 ── */
.gen-tab {
  flex: 1; padding: 8px 0; font-size: 13px; cursor: pointer;
  background: none; border: none; border-bottom: 2px solid transparent;
  color: var(--text-muted); transition: all 0.15s;
}
.gen-tab:hover { color: var(--text); }
.gen-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.gen-tab:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Message Actions · 消息悬浮操作按钮（重生成/TTS等） ── */
.msg-actions {
  display: flex; gap: 4px; margin-top: 4px; opacity: 0; transition: opacity 0.15s;
}
.message:hover .msg-actions { opacity: 1; }
.msg-action-btn {
  background: none; border: 1px solid var(--border); border-radius: 4px;
  padding: 2px 6px; font-size: 12px; cursor: pointer; color: var(--text-muted);
  transition: all 0.15s;
}
.msg-action-btn:hover { border-color: var(--accent); color: var(--text); }
.msg-action-btn:disabled { opacity: 0.5; cursor: wait; }

/* ── Visual Scene Hint · 场景图像生成提示按钮（延迟淡入） ── */
.visual-scene-hint {
  margin-top: 6px; opacity: 0; animation: hint-fade-in 0.6s ease 0.8s forwards;
}
@keyframes hint-fade-in { to { opacity: 1; } }
.visual-hint-btn {
  background: none; border: 1px dashed var(--border); border-radius: 6px;
  padding: 5px 14px; font-size: 12px; color: var(--text-muted); cursor: pointer;
  transition: all 0.2s; width: 100%; text-align: center;
}
.visual-hint-btn:hover {
  border-color: var(--accent); color: var(--accent); border-style: solid;
  background: rgba(88, 166, 255, 0.05);
}

/* ── Image Prompt Popup · 图像提示词弹出面板（可复制的等宽文本） ── */
.img-prompt-popup {
  margin-top: 8px; background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; font-size: 13px;
}
.img-prompt-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 10px; background: var(--bg-card); border-bottom: 1px solid var(--border);
  font-size: 11px; color: var(--text-muted);
}
.img-prompt-close {
  background: none; border: none; color: var(--text-muted); cursor: pointer;
  font-size: 16px; line-height: 1; padding: 0;
}
.img-prompt-close:hover { color: var(--text); }
.img-prompt-text {
  padding: 10px; line-height: 1.5; color: var(--text);
  font-family: 'Consolas', 'Monaco', monospace; font-size: 12px;
  user-select: all; word-break: break-word;
}
.img-prompt-footer {
  padding: 6px 10px; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end;
}
.img-prompt-copy {
  padding: 3px 12px; font-size: 11px; border-radius: 4px; cursor: pointer;
  background: var(--accent); color: #000; border: none; font-weight: 500;
}
.img-prompt-copy:hover { background: var(--accent-hover); }

/* ── Chat History List · 对话记录列表：加载/删除已保存的对话 ── */
.chat-history-item {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius);
  margin-bottom: 8px; background: var(--surface); transition: border-color 0.15s;
}
.chat-history-item:hover { border-color: var(--accent); }
.chat-history-main {
  flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px;
}
.chat-history-name {
  font-size: 14px; font-weight: 500; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chat-history-meta {
  font-size: 11px; color: var(--text-muted);
}
.chat-history-sub {
  width: 100%; display: flex; gap: 12px; font-size: 11px; color: var(--text-muted);
}
.chat-history-char, .chat-history-models {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 240px;
}
.chat-history-actions {
  display: flex; gap: 6px; flex-shrink: 0;
}
.chat-load-btn {
  padding: 4px 14px; font-size: 12px; border-radius: 4px; cursor: pointer;
  background: var(--accent); color: #000; border: none; font-weight: 500;
  transition: background 0.15s;
}
.chat-load-btn:hover { background: var(--accent-hover); }
.chat-delete-btn {
  padding: 4px 8px; font-size: 12px; border-radius: 4px; cursor: pointer;
  background: none; border: 1px solid var(--border); color: var(--text-muted);
  transition: all 0.15s;
}
.chat-delete-btn:hover { border-color: var(--danger); color: var(--danger); }

/* ── TTS · 语音朗读控件与播放中脉冲动画 ── */
.tts-controls {
  display: flex; align-items: center; gap: 8px;
}
.tts-playing {
  animation: tts-pulse 1s ease-in-out infinite;
  border-color: var(--accent) !important; color: var(--accent) !important;
}
@keyframes tts-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ── Remix Card Preview · AI改造角色卡的预览卡片 ── */
.remix-card-preview {
  display: flex; flex-direction: column; gap: 4px;
  padding: 10px 12px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); margin-top: 8px;
}
.remix-card-name { font-size: 15px; font-weight: 600; color: var(--text); }
.remix-card-tags { display: flex; flex-wrap: wrap; gap: 4px; }

/* ── Character Avatar · 角色头像展示与图生提示词面板 ── */
.char-avatar-area { margin-bottom: 8px; }
.char-avatar-img {
  width: 100%; max-height: 260px; object-fit: cover;
  border-radius: var(--radius); border: 1px solid var(--border);
  cursor: pointer; transition: opacity 0.15s;
}
.char-avatar-img:hover { opacity: 0.85; }
.char-avatar-prompt {
  border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; background: var(--bg);
}
.char-avatar-prompt-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 5px 10px; background: var(--surface); border-bottom: 1px solid var(--border);
  font-size: 11px; color: var(--text-muted);
}
.char-avatar-copy {
  padding: 2px 10px; font-size: 10px; border-radius: 4px; cursor: pointer;
  background: var(--accent); color: #000; border: none; font-weight: 500;
}
.char-avatar-copy:hover { background: var(--accent-hover); }
.char-avatar-prompt-text {
  padding: 8px 10px; font-size: 11px; line-height: 1.5;
  color: var(--text-muted); font-family: 'Consolas', 'Monaco', monospace;
  word-break: break-word; max-height: 150px; overflow-y: auto;
  user-select: all;
}

/* 编辑器头像上传区域 */
#ce-avatar-preview img {
  max-width: 128px; max-height: 128px; border-radius: 8px;
  object-fit: cover; display: block;
}
.ce-avatar-placeholder {
  width: 128px; height: 128px; border: 2px dashed var(--border);
  border-radius: 8px; display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); font-size: 11px;
}
.small-btn {
  padding: 3px 10px; font-size: 11px; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--surface); color: var(--text);
  cursor: pointer;
}
.small-btn:hover { background: var(--surface2); }

/* 消息内差分图 */
.matched-image { margin-top: 8px; text-align: center; }
.matched-image img {
  max-width: 320px; max-height: 400px; border-radius: 8px;
  cursor: pointer; transition: all 0.3s ease;
  animation: fadeInUp 0.4s ease;
}
.matched-image img.expanded {
  max-width: 90vw; max-height: 80vh; position: relative; z-index: 100;
}
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* 图库管理对话框 */
.gallery-dialog { max-width: 720px; width: 95vw; }
.gallery-toolbar { display: flex; gap: 6px; margin-bottom: 8px; flex-wrap: wrap; }
.gallery-progress { font-size: 12px; color: var(--accent); margin-bottom: 6px; }
.gallery-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px; max-height: 50vh; overflow-y: auto; padding: 4px;
}
.gallery-item {
  border: 1px solid var(--border); border-radius: 6px; overflow: hidden;
  background: var(--surface);
}
.gallery-item img {
  width: 100%; aspect-ratio: 1; object-fit: cover; display: block;
}
.gallery-desc {
  width: 100%; padding: 4px 6px; font-size: 11px; border: none;
  border-top: 1px solid var(--border); background: var(--bg); color: var(--text);
  outline: none;
}
.gallery-item-actions {
  display: flex; justify-content: space-between; align-items: center;
  padding: 2px 6px; font-size: 10px; color: var(--text-muted);
}
.gallery-id { font-family: monospace; overflow: hidden; text-overflow: ellipsis; }
.gallery-del-btn { font-size: 14px; line-height: 1; }

/* ── Toast 提示 ── */
.app-toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: rgba(20, 20, 20, 0.95);
  color: #e4e4e7;
  border: 1px solid #3f3f46;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 13px;
  font-family: 'Segoe UI', system-ui, sans-serif;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
  z-index: 9999;
  max-width: 90vw;
}
.app-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
