﻿/* ================ CSS 变量与主题 ================ */
:root {
  --bg-primary: #0d0c0b;
  --bg-secondary: #121110;
  --bg-tertiary: #181715;
  --bg-hover: #1e1c1a;
  --bg-active: #252320;
  --text-primary: #d9d4cc;
  --text-secondary: #9a948c;
  --text-tertiary: #6b6560;
  --border-color: #1e1c1a;
  --border-hover: #2a2825;
  --accent: #c9a66b;
  --accent-hover: #d8b97e;
  --accent-soft: rgba(201, 166, 107, 0.12);
  --danger: #d46b6b;
  --danger-soft: rgba(212, 107, 107, 0.12);
  --success: #7ba67a;
  --warning: #c9a66b;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.5);
  --editor-font: 'JetBrains Mono', 'Consolas', 'Monaco', monospace;
  --ui-font: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --serif-font: 'Noto Serif SC', 'Songti SC', serif;
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --sidebar-left-width: 240px;
  --sidebar-right-width: 280px;
  --editor-font-size: 14px;
  --topbar-height: 44px;
}

[data-theme="light"] {
  --bg-primary: #f5f5f5;
  --bg-secondary: #eeeeee;
  --bg-tertiary: #e0e0e0;
  --bg-hover: #d5d5d5;
  --bg-active: #c9c9c9;
  --text-primary: #212121;
  --text-secondary: #555555;
  --text-tertiary: #888888;
  --border-color: #d0d0d0;
  --border-hover: #bdbdbd;
  --accent: #555555;
  --accent-hover: #444444;
  --accent-soft: rgba(85, 85, 85, 0.1);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.12);
}

/* 亮色主题下笔按钮单独配色 */
[data-theme="light"] .edit-toggle-toolbar {
  background: #2E8B57;
  color: #ffffff;
  border-color: #2E8B57;
  box-shadow: 0 0 12px rgba(46, 139, 87, 0.4), 0 0 4px rgba(46, 139, 87, 0.2);
  animation: penPulseLight 2.5s ease-in-out infinite;
}
[data-theme="light"] .edit-toggle-toolbar:hover {
  background: #256e45;
  color: #ffffff;
  box-shadow: 0 0 18px rgba(46, 139, 87, 0.55);
}
[data-theme="light"] .edit-toggle-toolbar.edit-active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
  box-shadow: none;
  animation: none;
}
[data-theme="light"] .edit-toggle-toolbar.edit-active:hover {
  background: var(--accent-soft);
  color: var(--accent);
  box-shadow: none;
}
@keyframes penPulseLight {
  0%, 100% { box-shadow: 0 0 12px rgba(46, 139, 87, 0.4), 0 0 4px rgba(46, 139, 87, 0.2); }
  50% { box-shadow: 0 0 20px rgba(46, 139, 87, 0.6), 0 0 8px rgba(46, 139, 87, 0.3); }
}

/* 亮色主题下分支下拉框 */
[data-theme="light"] .branch-btn {
  background: #2E8B57;
  color: #ffffff;
  border-color: #2E8B57;
}
[data-theme="light"] .branch-btn:hover {
  background: #256e45;
  color: #ffffff;
  border-color: #256e45;
}

/* 亮色主题下保存按钮有修改时 */
[data-theme="light"] .save-group.has-changes .save-btn {
  background: #2E8B57;
  color: #ffffff;
  border-color: #2E8B57;
  box-shadow: 0 0 12px rgba(46, 139, 87, 0.4), 0 0 4px rgba(46, 139, 87, 0.2);
  animation: savePulseLight 2s ease-in-out infinite;
}
[data-theme="light"] .save-group.has-changes .save-btn:hover {
  background: #256e45;
  color: #ffffff;
}
@keyframes savePulseLight {
  0%, 100% { box-shadow: 0 0 12px rgba(46, 139, 87, 0.4), 0 0 4px rgba(46, 139, 87, 0.2); }
  50% { box-shadow: 0 0 18px rgba(46, 139, 87, 0.6), 0 0 8px rgba(46, 139, 87, 0.3); }
}

/* ================ 基础样式 ================ */
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body {
  height: 100%; overflow: hidden;
  font-family: var(--ui-font); font-size: 13px;
  color: var(--text-primary); background: var(--bg-primary);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
button { font-family: inherit; font-size: inherit; color: inherit; background: none; border: none; cursor: pointer; outline: none; }
input, textarea { font-family: inherit; font-size: inherit; color: inherit; outline: none; border: none; background: none; }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-hover); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-tertiary); }

/* ================ 顶部导航栏 ================ */
.topbar {
  height: var(--topbar-height); background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; position: relative; z-index: 100; user-select: none;
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.app-logo { width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; color: var(--accent); font-size: 18px; }
.app-name { font-size: 14px; font-weight: 600; letter-spacing: 0.5px; color: var(--text-primary); }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.topbar-btn {
  height: 28px; padding: 0 10px; border-radius: var(--radius-sm);
  display: flex; align-items: center; gap: 6px; font-size: 12px;
  color: var(--text-secondary); transition: all 0.15s ease; position: relative;
}
.topbar-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.topbar-btn.primary { background: var(--accent); color: #1a1510; font-weight: 500; }
.topbar-btn.primary:hover { background: var(--accent-hover); }
.avatar-btn {
  width: 28px; height: 28px; border-radius: 50%; background: var(--accent-soft);
  color: var(--accent); display: flex; align-items: center; justify-content: center;
  font-size: 14px; transition: all 0.15s ease;
}
.avatar-btn:hover { background: var(--accent); color: #1a1510; }
.theme-toggle { font-size: 14px; padding: 0 8px; }

.dropdown { position: relative; }
.dropdown-menu {
  position: absolute; top: calc(100% + 6px); right: 0; min-width: 180px;
  background: var(--bg-secondary); border: 1px solid var(--border-color);
  border-radius: var(--radius-md); box-shadow: var(--shadow-md);
  padding: 4px; display: none; z-index: 200;
}
.dropdown.open .dropdown-menu { display: block; }
.dropdown-item {
  display: block; width: 100%; text-align: left; padding: 8px 12px;
  border-radius: var(--radius-sm); font-size: 12px; color: var(--text-secondary);
  transition: all 0.12s ease; text-decoration: none;
}
.dropdown-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.dropdown-divider { height: 1px; background: var(--border-color); margin: 4px 8px; }
.dropdown-checkbox { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.dropdown-checkbox input[type="checkbox"] { width: 14px; height: 14px; cursor: pointer; accent-color: var(--accent); }
.dropdown-checkbox span { flex: 1; }

/* ================ 主体布局 ================ */
.main { display: flex; height: calc(100vh - var(--topbar-height)); overflow: hidden; }
.sidebar {
  background: var(--bg-secondary); border-right: 1px solid var(--border-color);
  display: flex; flex-direction: column; overflow: hidden;
  transition: width 0.25s ease; flex-shrink: 0;
}
.sidebar.right { border-right: none; border-left: 1px solid var(--border-color); }
.sidebar.collapsed { width: 0 !important; border: none; }
.sidebar-header {
  height: 36px; padding: 0 12px; display: flex; align-items: center;
  justify-content: space-between; border-bottom: 1px solid var(--border-color); flex-shrink: 0;
}
.sidebar-title { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 1px; color: var(--text-tertiary); }
.sidebar-actions { display: flex; align-items: center; gap: 2px; flex-shrink: 0; }
.icon-btn {
  width: 26px; height: 26px; display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm); color: var(--text-tertiary); font-size: 15px; transition: all 0.12s ease;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.sidebar-content { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 4px 0; }
.sidebar-toggle { width: 4px; background: transparent; cursor: col-resize; flex-shrink: 0; transition: background 0.2s ease; }
.sidebar-toggle:hover { background: var(--accent); }

/* ================ 左栏 - 文件树 ================ */
#left-sidebar { width: var(--sidebar-left-width); }
.file-tree { padding: 2px 0; font-size: 12.5px; }
.tree-node { user-select: none; }

/* 文件夹行 */
.tree-node.folder .node-row {
  display: flex; align-items: center; padding: 3px 8px 3px 6px; cursor: pointer;
  border-radius: var(--radius-sm); margin: 0 2px; transition: background 0.1s ease; gap: 5px;
}
.tree-node.folder .node-row:hover { background: var(--bg-hover); }
.tree-node.folder .node-row .twisty {
  width: 14px; height: 14px; display: flex; align-items: center; justify-content: center;
  color: var(--text-tertiary); transition: transform 0.15s ease; flex-shrink: 0; font-size: 10px;
}
.tree-node.folder .node-row.open .twisty { transform: rotate(90deg); }

.tree-node .node-icon { font-size: 12px; flex-shrink: 0; display: flex; align-items: center; }
.tree-node .node-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-primary); }
.tree-node.file .node-name { color: var(--text-secondary); }
.tree-node.file.active > .node-row { background: var(--accent-soft); }
.tree-node.file.active > .node-row .node-name { color: var(--accent); font-weight: 500; }

/* 文件节点行 */
.tree-node.file .node-row {
  display: flex; align-items: center; padding: 3px 8px 3px 26px; cursor: pointer;
  border-radius: var(--radius-sm); margin: 0 2px; transition: background 0.1s ease; gap: 5px;
}
.tree-node.file .node-row:hover { background: var(--bg-hover); }

.project-thumb {
  width: 20px; height: 20px; border-radius: 4px; object-fit: cover; flex-shrink: 0;
  background: var(--bg-tertiary); border: 1px solid var(--border-color);
}

/* 操作按钮 - 所有节点行通用，hover 时显示 */
.tree-node .node-row .node-actions { display: none; gap: 2px; margin-left: auto; }
.tree-node .node-row:hover .node-actions { display: flex; }
.sidebar-empty { padding: 24px 16px; text-align: center; color: var(--text-tertiary); font-size: 12px; line-height: 1.6; }
.sidebar-empty .empty-icon { font-size: 28px; margin-bottom: 8px; opacity: 0.5; }
.new-project-btn {
  width: calc(100% - 16px); margin: 8px; padding: 8px; border-radius: var(--radius-md);
  background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 500;
  display: flex; align-items: center; justify-content: center; gap: 6px; transition: all 0.15s ease;
}
.new-project-btn:hover { background: var(--accent); color: #1a1510; }
.open-folder-btn {
  width: calc(100% - 16px); margin: 8px; padding: 8px; border-radius: var(--radius-md);
  border: 1px dashed var(--border-hover); color: var(--text-secondary); font-size: 12px;
  display: flex; align-items: center; justify-content: center; gap: 6px; transition: all 0.15s ease;
}
.open-folder-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ================ 中栏 - 编辑器 ================ */
.editor-pane { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--bg-primary); }
.editor-toolbar {
  height: 38px; padding: 0 12px; border-bottom: 1px solid var(--border-color);
  display: flex; align-items: center; gap: 8px; flex-shrink: 0; background: var(--bg-secondary);
}
.toolbar-group { display: flex; align-items: center; gap: 4px; }
.toolbar-divider { width: 1px; height: 16px; background: var(--border-color); margin: 0 4px; }
.toolbar-btn {
  width: 32px; height: 32px; border-radius: var(--radius-sm); display: flex; align-items: center;
  justify-content: center; color: var(--text-secondary); transition: all 0.12s ease; font-size: 16px; position: relative;
}
.toolbar-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.toolbar-btn.active { color: var(--accent); background: var(--accent-soft); }

/* 工具栏文字按钮 */
.toolbar-text-btn {
  height: 30px; padding: 0 14px; border-radius: var(--radius-sm);
  font-size: 12px; font-weight: 500; transition: all 0.15s ease;
  display: flex; align-items: center; justify-content: center;
  opacity: 0.4; pointer-events: none;
}
.save-group.has-changes .toolbar-text-btn,
.save-group.edit-mode .toolbar-text-btn { opacity: 1; pointer-events: auto; }
.save-btn { background: var(--accent); color: #1a1510; }
.save-btn:hover { background: var(--accent-hover); }
.discard-btn { background: var(--bg-tertiary); color: var(--text-secondary); border: 1px solid var(--border-color); margin-right: 6px; }
.discard-btn:hover { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }

/* 编辑切换按钮 - 浏览模式蓝色泛光，编辑模式金色不泛光 */
.edit-toggle-toolbar {
  opacity: 1 !important; pointer-events: auto !important;
  width: auto; min-width: 44px; padding: 0 14px;
  background: rgba(100, 160, 200, 0.12);
  color: #7db8da;
  border: 1.5px solid #7db8da;
  border-radius: var(--radius-md);
  font-size: 13px; font-weight: 600;
  box-shadow: 0 0 12px rgba(125, 184, 218, 0.35), 0 0 4px rgba(125, 184, 218, 0.2);
  animation: penPulse 2.5s ease-in-out infinite;
}
.edit-toggle-toolbar:hover { background: #7db8da; color: #1a1510; box-shadow: 0 0 18px rgba(125, 184, 218, 0.5); }
.edit-toggle-toolbar.edit-active {
  background: var(--accent-soft);
  color: var(--accent);
  border: 1.5px solid var(--accent);
  box-shadow: none;
  animation: none;
  cursor: default;
}
.edit-toggle-toolbar.edit-active:hover { background: var(--accent-soft); color: var(--accent); box-shadow: none; }
@keyframes penPulse {
  0%, 100% { box-shadow: 0 0 12px rgba(125, 184, 218, 0.35), 0 0 4px rgba(125, 184, 218, 0.2); }
  50% { box-shadow: 0 0 20px rgba(125, 184, 218, 0.55), 0 0 8px rgba(125, 184, 218, 0.3); }
}

/* 保存按钮 - 有改动时蓝色泛光 */
.save-group.has-changes .save-btn {
  background: rgba(100, 160, 200, 0.15);
  color: #7db8da;
  border: 1.5px solid #7db8da;
  box-shadow: 0 0 12px rgba(125, 184, 218, 0.4), 0 0 4px rgba(125, 184, 218, 0.2);
  animation: savePulse 2s ease-in-out infinite;
}
.save-group.has-changes .save-btn:hover { background: #7db8da; color: #1a1510; }
@keyframes savePulse {
  0%, 100% { box-shadow: 0 0 12px rgba(125, 184, 218, 0.4), 0 0 4px rgba(125, 184, 218, 0.2); }
  50% { box-shadow: 0 0 18px rgba(125, 184, 218, 0.6), 0 0 8px rgba(125, 184, 218, 0.3); }
}

.branch-selector { position: relative; }
.branch-btn {
  height: 28px; padding: 0 14px; border-radius: var(--radius-sm); background: var(--accent-soft);
  border: 1px solid var(--accent); display: flex; align-items: center; gap: 8px;
  font-size: 12.5px; color: var(--accent); transition: all 0.15s ease; font-weight: 500;
}
.branch-btn:hover { border-color: var(--accent-hover); background: rgba(201, 166, 107, 0.2); color: var(--accent-hover); }
.branch-btn .branch-name { font-weight: 600; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.branch-dropdown {
  position: absolute; top: calc(100% + 4px); left: 0; min-width: 200px;
  background: var(--bg-secondary); border: 1px solid var(--border-color); border-radius: var(--radius-md);
  box-shadow: var(--shadow-md); padding: 4px; display: none; z-index: 150;
}
.branch-dropdown.open { display: block; }
.branch-item { display: flex; align-items: center; padding: 6px 10px; border-radius: var(--radius-sm); font-size: 12px; cursor: pointer; gap: 8px; transition: background 0.1s ease; }
.branch-item:hover { background: var(--bg-hover); }
.branch-item.current { color: var(--accent); background: var(--accent-soft); }
.branch-item .branch-icon { font-size: 12px; opacity: 0.7; }
.branch-footer { padding: 6px; border-top: 1px solid var(--border-color); margin-top: 4px; padding-top: 8px; }
.branch-new-input {
  width: 100%; padding: 5px 8px; border-radius: var(--radius-sm); background: var(--bg-tertiary);
  border: 1px solid var(--border-color); font-size: 12px; color: var(--text-primary); transition: border-color 0.15s ease;
}
.branch-new-input:focus { border-color: var(--accent); }

.editor-title-bar {
  padding: 8px 20px; border-bottom: 1px solid var(--border-color); display: flex;
  align-items: center; gap: 12px; font-size: 13px; flex-shrink: 0; background: var(--bg-primary);
}
.editor-filename { font-weight: 500; color: var(--text-primary); font-family: var(--editor-font); font-size: 12.5px; }
.editor-save-status { font-size: 11px; color: var(--text-tertiary); display: flex; align-items: center; gap: 4px; }
.editor-save-status.dirty { color: var(--warning); }
.editor-save-status.saved { color: var(--success); }
.save-status-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.editor-body { flex: 1; overflow: hidden; position: relative; display: flex; background: var(--bg-primary); min-height: 0; }
.editor-with-lines {
  position: relative; flex: 1; display: flex; overflow: hidden; background: var(--bg-primary); min-height: 0; }
.line-numbers {
  width: 48px; flex-shrink: 0; padding: 24px 8px 24px 0;
  font-family: var(--editor-font); font-size: 12px; line-height: 1.7;
  color: var(--text-tertiary); text-align: right; user-select: none;
  overflow: hidden; background: var(--bg-primary); border-right: 1px solid var(--border-color);
}
.line-number {
  display: block; height: calc(14px * 1.7); white-space: nowrap;
  transition: color 0.15s ease, background 0.15s ease;
  padding-right: 6px;
}
.line-number.error {
  color: #ff6b9d;
  background: rgba(255, 107, 157, 0.12);
  font-weight: 600;
  cursor: help;
}
.editor-textarea {
  flex: 1; height: 100%; padding: 24px 32px 24px 16px; font-family: var(--editor-font);
  font-size: 14px; line-height: 1.7; color: var(--text-primary); background: var(--bg-primary);
  border: none; outline: none; resize: none; caret-color: var(--accent); tab-size: 2;
  overflow-y: auto; overflow-x: hidden;
}
.editor-textarea::selection { background: var(--accent-soft); color: var(--accent); }
.preview-mode .editor-textarea { display: none; }
.preview-mode .editor-with-lines { display: none; }
.edit-mode .markdown-preview { display: none; }
.markdown-preview {
  width: 100%; height: 100%; padding: 28px 40px; overflow-y: auto;
  font-family: var(--serif-font); font-size: 15px; line-height: 1.8; color: var(--text-primary);
}
.markdown-preview h1,.markdown-preview h2,.markdown-preview h3,.markdown-preview h4,.markdown-preview h5,.markdown-preview h6 {
  font-weight: 600; margin: 1.6em 0 0.8em; line-height: 1.3; color: var(--text-primary);
}
.markdown-preview h1 { font-size: 1.8em; border-bottom: 1px solid var(--border-color); padding-bottom: 0.4em; }
.markdown-preview h2 { font-size: 1.5em; border-bottom: 1px solid var(--border-color); padding-bottom: 0.3em; }
.markdown-preview h3 { font-size: 1.25em; }
.markdown-preview h4 { font-size: 1.1em; }
.markdown-preview p { margin: 0.8em 0; }
.markdown-preview blockquote {
  margin: 1em 0; padding: 0.4em 1em; border-left: 3px solid var(--accent);
  color: var(--text-secondary); background: var(--accent-soft); border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.markdown-preview code { font-family: var(--editor-font); font-size: 0.85em; padding: 2px 6px; background: var(--bg-tertiary); border-radius: var(--radius-sm); color: var(--accent); }
.markdown-preview pre { margin: 1em 0; padding: 12px 16px; background: var(--bg-tertiary); border-radius: var(--radius-md); overflow-x: auto; border: 1px solid var(--border-color); }
.markdown-preview pre code { padding: 0; background: none; color: var(--text-primary); font-size: 0.9em; }
.markdown-preview ul,.markdown-preview ol { margin: 0.8em 0; padding-left: 1.6em; }
.markdown-preview li { margin: 0.3em 0; }
.markdown-preview a { color: var(--accent); text-decoration: none; border-bottom: 1px solid transparent; transition: border-color 0.15s ease; }
.markdown-preview a:hover { border-bottom-color: var(--accent); }
.markdown-preview table { width: 100%; border-collapse: collapse; margin: 1em 0; font-size: 0.9em; }
.markdown-preview th,.markdown-preview td { padding: 8px 12px; border: 1px solid var(--border-color); text-align: left; }
.markdown-preview th { background: var(--bg-tertiary); font-weight: 600; }
.markdown-preview hr { border: none; height: 1px; background: var(--border-color); margin: 2em 0; }
.markdown-preview img { max-width: 100%; border-radius: var(--radius-md); }

.editor-empty { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--text-tertiary); gap: 12px; position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: var(--bg-primary); z-index: 10; }
.editor-empty-icon { font-size: 48px; opacity: 0.3; }
.editor-empty-text { font-size: 14px; }
.editor-empty-sub { font-size: 12px; color: var(--text-tertiary); opacity: 0.7; }

.editor-statusbar {
  min-height: 32px;
  height: 24px; padding: 0 12px; border-top: 1px solid var(--border-color);
  display: flex; align-items: center; justify-content: space-between; font-size: 11px;
  color: var(--text-tertiary); flex-shrink: 0; background: var(--bg-secondary);
}
.status-left, .status-right {
  display: flex;
  align-items: center;
  gap: 16px;
}
.status-item { display: flex; align-items: center; gap: 4px; }

/* ================ 右栏 ================ */
#right-sidebar { width: var(--sidebar-right-width); }
.panel { padding: 12px; border-bottom: 1px solid var(--border-color); }
.panel-title { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 1px; color: var(--text-tertiary); margin-bottom: 10px; display: flex; align-items: center; gap: 6px; }
.meta-item { display: flex; justify-content: space-between; align-items: center; padding: 5px 0; font-size: 12px; }
.meta-label { color: var(--text-tertiary); flex-shrink: 0; }
.meta-value { color: var(--text-primary); font-weight: 500; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 60%; font-family: var(--editor-font); font-size: 11.5px; }

.commits-list { display: flex; flex-direction: column; gap: 6px; max-height: 200px; overflow-y: auto; }
.commit-item { padding: 6px 8px; border-radius: var(--radius-sm); background: var(--bg-tertiary); font-size: 11px; border-left: 2px solid var(--accent); }
.commit-time { color: var(--text-tertiary); font-size: 10.5px; margin-bottom: 2px; }
.commit-branch { display: inline-block; padding: 1px 5px; border-radius: 3px; background: var(--accent-soft); color: var(--accent); font-size: 10px; margin-bottom: 2px; }
.commit-file { color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--editor-font); }

/* 实时预览面板 */
.preview-panel { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.preview-body { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 8px 12px 12px; min-height: 0; }
.preview-content { font-size: 14px; line-height: 1.6; color: var(--text-primary); word-wrap: break-word; min-height: 100%; padding-bottom: 20px; box-sizing: border-box; }
.preview-content h1,.preview-content h2,.preview-content h3,.preview-content h4,.preview-content h5,.preview-content h6 { font-weight: 600; margin: 1em 0 0.5em; line-height: 1.3; color: var(--text-primary); }
.preview-content h1 { font-size: 1.4em; border-bottom: 1px solid var(--border-color); padding-bottom: 0.3em; }
.preview-content h2 { font-size: 1.25em; border-bottom: 1px solid var(--border-color); padding-bottom: 0.2em; }
.preview-content h3 { font-size: 1.1em; }
.preview-content h4 { font-size: 1em; }
.preview-content p { margin: 0.5em 0; }
.preview-content blockquote { margin: 0.6em 0; padding: 4px 8px; border-left: 2px solid var(--accent); color: var(--text-secondary); background: var(--accent-soft); font-size: 0.95em; border-radius: 0 3px 3px 0; }
.preview-content code { font-family: var(--editor-font); font-size: 0.85em; padding: 1px 4px; background: var(--bg-tertiary); border-radius: 3px; color: var(--accent); }
.preview-content pre { margin: 0.6em 0; padding: 8px 10px; background: var(--bg-tertiary); border-radius: var(--radius-sm); overflow-x: auto; border: 1px solid var(--border-color); }
.preview-content pre code { padding: 0; background: none; color: var(--text-primary); font-size: 0.9em; }
.preview-content ul,.preview-content ol { margin: 0.5em 0; padding-left: 1.4em; }
.preview-content li { margin: 0.2em 0; }
.preview-content a { color: var(--accent); text-decoration: none; border-bottom: 1px solid transparent; }
.preview-content a:hover { border-bottom-color: var(--accent); }
.preview-content table { width: 100%; border-collapse: collapse; margin: 0.6em 0; font-size: 0.9em; }
.preview-content th,.preview-content td { padding: 5px 8px; border: 1px solid var(--border-color); text-align: left; }
.preview-content th { background: var(--bg-tertiary); font-weight: 600; }
.preview-content hr { border: none; height: 1px; background: var(--border-color); margin: 1em 0; }
.preview-content img { max-width: 100%; border-radius: var(--radius-sm); }
.preview-empty { padding: 20px 0; text-align: center; color: var(--text-tertiary); font-size: 11px; opacity: 0.6; }
.preview-empty-icon { font-size: 24px; margin-bottom: 6px; opacity: 0.5; }

/* ================ 模态对话框 ================ */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.5);
  display: flex; align-items: center; justify-content: center; z-index: 1000;
  opacity: 0; visibility: hidden; transition: all 0.2s ease;
}
.modal-overlay.active { opacity: 1; visibility: visible; }
.modal {
  background: var(--bg-secondary); border: 1px solid var(--border-color); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); min-width: 360px; max-width: 480px;
  transform: translateY(10px) scale(0.97); transition: all 0.2s ease;
}
.modal-overlay.active .modal { transform: translateY(0) scale(1); }
.modal-header { padding: 16px 20px; border-bottom: 1px solid var(--border-color); font-size: 14px; font-weight: 600; }
.modal-body { padding: 20px; font-size: 13px; line-height: 1.6; color: var(--text-secondary); }
.modal-footer { padding: 12px 20px; border-top: 1px solid var(--border-color); display: flex; justify-content: flex-end; gap: 8px; }
.modal-btn { padding: 7px 16px; border-radius: var(--radius-sm); font-size: 12px; font-weight: 500; transition: all 0.12s ease; }
.modal-btn.secondary { background: var(--bg-tertiary); color: var(--text-secondary); border: 1px solid var(--border-color); }
.modal-btn.secondary:hover { background: var(--bg-hover); color: var(--text-primary); }
.modal-btn.primary { background: var(--accent); color: #1a1510; }
.modal-btn.primary:hover { background: var(--accent-hover); }
.modal-btn.blue { background: #7db8da; color: #1a1510; }
.modal-btn.blue:hover { background: #8fc4e0; }
.modal-btn.danger { background: var(--danger); color: white; }
.modal-btn.danger:hover { background: #e07a7a; }
.modal-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.confirm-checkbox { display: flex; align-items: center; gap: 8px; margin-top: 12px; cursor: pointer; font-size: 12px; color: var(--text-secondary); }
.confirm-checkbox input[type=checkbox] { width: 15px; height: 15px; accent-color: var(--accent); }
.modal-input {
  width: 100%; padding: 8px 12px; border-radius: var(--radius-sm); background: var(--bg-tertiary);
  border: 1px solid var(--border-color); font-size: 13px; color: var(--text-primary); margin-top: 8px; transition: border-color 0.15s ease;
}
.modal-input:focus { border-color: var(--accent); }

/* 公众号弹窗 */
.qrcode-modal .modal { text-align: center; min-width: 320px; }
.qrcode-img-wrap {
  width: 180px; height: 180px; margin: 16px auto; background: white; border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center; padding: 10px;
}
.qrcode-img-wrap img { width: 100%; height: 100%; object-fit: contain; }
.qrcode-placeholder { width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; color: #666; font-size: 11px; gap: 4px; }
.wechat-name { font-size: 14px; font-weight: 600; color: var(--text-primary); margin-bottom: 4px; }
.copy-btn { padding: 6px 14px; border-radius: var(--radius-sm); background: var(--accent-soft); color: var(--accent); font-size: 11.5px; font-weight: 500; transition: all 0.15s ease; margin-top: 8px; }
.copy-btn:hover { background: var(--accent); color: #1a1510; }

/* 猫咪弹窗 */
.cat-modal .modal { text-align: center; min-width: 380px; overflow: hidden; }
.cat-face { font-size: 72px; margin: 20px 0 10px; animation: catCry 3s ease-in-out infinite; position: relative; }
@keyframes catCry { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
.cat-tear {
  position: absolute; width: 6px; height: 10px;
  background: linear-gradient(180deg, #7db8da, #4a90b8);
  border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  animation: tearFall 2.5s ease-in infinite; opacity: 0;
}
@keyframes tearFall {
  0% { transform: translateY(0); opacity: 0; }
  20% { opacity: 1; }
  100% { transform: translateY(30px); opacity: 0; }
}
.cat-modal-body { padding: 0 24px 20px; font-size: 13px; line-height: 1.7; color: var(--text-secondary); }
.cat-modal-footer { padding: 14px 24px 20px; }
.cat-close-btn {
  width: 100%; padding: 10px; border-radius: var(--radius-md); font-size: 13px; font-weight: 500;
  background: var(--bg-tertiary); color: var(--text-tertiary); border: 1px solid var(--border-color); transition: all 0.2s ease;
}
.cat-close-btn.ready { background: var(--accent); color: #1a1510; border-color: var(--accent); }
.cat-close-btn.ready:hover { background: var(--accent-hover); }
.cat-qrcode { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--border-color); }
.cat-qrcode .qrcode-img-wrap { width: 120px; height: 120px; margin: 8px auto; }

/* ================ Toast 通知 ================ */
.toast-container { position: fixed; bottom: 90px; left: 20px; z-index: 2000; display: flex; flex-direction: column; gap: 8px; }
.toast {
  padding: 10px 16px; background: var(--bg-secondary); border: 1px solid var(--border-color);
  border-radius: var(--radius-md); box-shadow: var(--shadow-md); font-size: 12.5px;
  color: var(--text-primary); min-width: 240px; max-width: 360px;
  animation: toastIn 0.25s ease; display: flex; align-items: center; gap: 8px;
}
.toast.fade-out { animation: toastOut 0.25s ease forwards; }
.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.warning { border-left: 3px solid var(--warning); }
.toast.info { border-left: 3px solid var(--accent); }
@keyframes toastIn { from { opacity: 0; transform: translateX(-20px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toastOut { from { opacity: 1; transform: translateX(0); } to { opacity: 0; transform: translateX(-20px); } }

/* ================ 权限续约横幅 ================ */
.banner {
  position: fixed; top: 200px; left: 50%; transform: translateX(-50%);
  padding: 10px 20px; background: var(--bg-secondary); border: 1px solid var(--accent);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  display: flex; align-items: center; gap: 16px; z-index: 500; font-size: 13px; animation: bannerIn 0.3s ease;
}
@keyframes bannerIn { from { opacity: 0; transform: translateX(-50%) translateY(-10px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }
.banner-text { color: var(--text-primary); }
.banner-text span { color: var(--accent); font-weight: 500; }
.banner-btn { padding: 5px 14px; border-radius: var(--radius-sm); background: var(--accent); color: #1a1510; font-size: 12px; font-weight: 500; transition: background 0.15s ease; }
.banner-btn:hover { background: var(--accent-hover); }
.banner-dismiss { color: var(--text-tertiary); font-size: 14px; padding: 2px; transition: color 0.15s ease; }
.banner-dismiss:hover { color: var(--text-primary); }

/* ================ 浏览器不支持提示 ================ */
.unsupported-banner {
  padding: 12px 20px; background: var(--danger-soft); border-bottom: 1px solid var(--danger);
  color: var(--danger); font-size: 12.5px; display: flex; align-items: center; gap: 10px;
}
.unsupported-banner strong { font-weight: 600; }

/* ================ 右键上下文菜单 ================ */
.context-menu {
  position: fixed; background: var(--bg-secondary); border: 1px solid var(--border-color);
  border-radius: var(--radius-md); box-shadow: var(--shadow-lg); padding: 4px; min-width: 160px; z-index: 900; display: none;
}
.context-menu.open { display: block; }
.context-menu-item { display: flex; align-items: center; gap: 8px; padding: 7px 12px; border-radius: var(--radius-sm); font-size: 12px; color: var(--text-secondary); cursor: pointer; transition: all 0.1s ease; }
.context-menu-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.context-menu-item.danger { color: var(--danger); }
.context-menu-item.danger:hover { background: var(--danger-soft); }
.context-menu-divider { height: 1px; background: var(--border-color); margin: 4px 0; }

/* 项目结构树弹窗 */
.tree-text {
  font-family: var(--editor-font);
  font-size: 13px;
  line-height: 1.7;
  color: var(--text-primary);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 16px;
  max-height: 400px;
  overflow: auto;
  white-space: pre;
  margin: 0;
}

.tree-node.hidden-node > .node-row { opacity: 0.4; }
.rename-input { flex: 1; padding: 1px 4px; background: var(--bg-tertiary); border: 1px solid var(--accent); border-radius: 3px; font-size: 12.5px; color: var(--text-primary); font-family: inherit; min-width: 0; }


/* ================ 展开层级下拉框 ================ */
.tree-level-select {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 2px 6px;
  font-size: 11px;
  cursor: pointer;
  font-family: var(--ui-font);
  outline: none;
}
.tree-level-select:hover {
  border-color: var(--border-hover);
  color: var(--text-primary);
}
.tree-level-select:focus {
  border-color: var(--accent);
}

/* ================ 文档信息紧凑布局 ================ */
.meta-row {
  display: flex;
  gap: 8px;
}
.meta-half {
  flex: 1;
  min-width: 0;
}
.meta-half .meta-item {
  width: 100%;
  display: flex;
  justify-content: space-between;
}
.meta-half .meta-value {
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-left: auto;
  text-align: right;
}

/* 提交历史两栏 */
.commit-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border-color);
  font-size: 11px;
}
.commit-item:last-child {
  border-bottom: none;
}
.commit-time {
  color: var(--text-tertiary);
  white-space: nowrap;
  flex-shrink: 0;
}
.commit-summary {
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-left: 8px;
  text-align: right;
}

/* 状态值样式 */
.status-value {
  font-weight: 500;
  font-size: 12px;
}

/* 压缩提交历史区域 */
#commits-list {
  max-height: 120px;
  overflow-y: auto;
}
.commit-item {
  padding: 4px 8px;
  font-size: 10.5px;
}
.commit-time {
  font-size: 10px;
}
.commit-summary {
  font-size: 10.5px;
}

/* ================ 命令面板 ================ */
@keyframes cursor-blink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}
.command-palette {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  padding: 8px 16px;
  background: rgba(26, 21, 16, 0.95);
  border-top: 1px solid #7db8da;
  box-shadow: 0 -4px 20px rgba(125, 184, 218, 0.4), 0 -1px 8px rgba(125, 184, 218, 0.6);
  backdrop-filter: blur(8px);
  z-index: 100;
  gap: 10px;
}
.command-prompt {
  color: #7db8da;
  font-size: 16px;
  font-weight: bold;
  flex-shrink: 0;
  text-shadow: 0 0 8px rgba(125, 184, 218, 0.8);
}
#command-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: #e0f0fa;
  font-family: var(--editor-font);
  font-size: 13px;
  padding: 4px 0;
}
#command-input::placeholder {
  color: rgba(125, 184, 218, 0.5);
  font-size: 11px;
}
/* ================ 标题栏右侧按钮 ================ */
.title-bar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}
.ratio-group {
  display: flex;
  align-items: center;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  padding: 2px;
  gap: 2px;
}
.ratio-btn {
  padding: 3px 8px;
  border: none;
  background: transparent;
  color: var(--text-tertiary);
  font-size: 10.5px;
  font-weight: 500;
  border-radius: 3px;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: var(--editor-font);
}
.ratio-btn:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}
.ratio-btn.active {
  background: var(--accent);
  color: #1a1510;
}
.mode-btn {
  width: 28px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-color);
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  transition: all 0.15s ease;
}
.mode-btn:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.mode-btn.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

/* ================ 比例布局 ================ */
.main.ratio-6-4 .editor-pane { flex: 6; }
.main.ratio-6-4 #right-sidebar { flex: 4; width: auto !important; }
.main.ratio-1-1 .editor-pane { flex: 1; }
.main.ratio-1-1 #right-sidebar { flex: 1; width: auto !important; }
.main.ratio-4-6 .editor-pane { flex: 4; }
.main.ratio-4-6 #right-sidebar { flex: 6; width: auto !important; }
.main.ratio-3-7 .editor-pane { flex: 3; }
.main.ratio-3-7 #right-sidebar { flex: 7; width: auto !important; }
.main.ratio-2-8 .editor-pane { flex: 2; }
.main.ratio-2-8 #right-sidebar { flex: 8; width: auto !important; }

/* 专注模式 */
.main.focus-mode #left-sidebar,
.main.focus-mode #right-sidebar {
  width: 0 !important;
  border: none !important;
  overflow: hidden;
}
.main.focus-mode .editor-pane { flex: 1; }

/* 展示模式 */
.main.display-mode #left-sidebar {
  width: 0 !important;
  border: none !important;
  overflow: hidden;
}
/* 标题栏右侧模式按钮 */
.editor-title-bar {
  display: flex;
  align-items: center;
}
.title-bar-modes {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
}
.title-bar-modes .mode-btn {
  width: 26px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-color);
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 12px;
  transition: all 0.15s ease;
}
.title-bar-modes .mode-btn:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.title-bar-modes .mode-btn.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}
/* ================ 响应式按钮适配 ================ */
.btn-icon { margin-right: 4px; }
.btn-text { display: inline; }

/* 1:1 和 4:6 比例下只显示图标 */
.main.ratio-1-1 .btn-text,
.main.ratio-4-6 .btn-text {
  display: none;
}
.main.ratio-1-1 .btn-icon,
.main.ratio-4-6 .btn-icon {
  margin-right: 0;
}
.main.ratio-1-1 .toolbar-text-btn,
.main.ratio-4-6 .toolbar-text-btn {
  padding: 4px 8px;
  min-width: 32px;
}

/* 缩小 main 分支选择器 */
.main.ratio-1-1 .branch-btn,
.main.ratio-4-6 .branch-btn {
  padding: 4px 8px;
}
.main.ratio-1-1 .branch-name,
.main.ratio-4-6 .branch-name {
  max-width: 50px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 展示模式：只显示跳转按钮，隐藏其他 */
.main.display-mode .toolbar-group:not(:nth-child(7)) {
  display: none;
}
.main.display-mode .toolbar-divider {
  display: none;
}
.main.display-mode .save-group {
  display: flex !important;
}

/* 保存状态颜色 */
.status-value.saved { color: var(--success); }
.status-value.dirty { color: var(--warning); }


/* ================ 预览区烟花粒子动画 ================ */
.preview-particles {
  position: absolute;
  inset: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary);
}
.preview-particles .particles-container {
  position: absolute;
  inset: 0;
}
.preview-particles .particle {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--color, var(--accent));
  opacity: 0;
  transform: translate(-50%, -50%);
  animation: particle-explode ease-out infinite;
  box-shadow: 0 0 6px var(--color, var(--accent));
}

.preview-particles .p1 { --tx: -213.4px; --ty: 17.2px; --color: #ffd700; animation-duration: 2.74s; animation-delay: 0.99s; width: 2.2px; height: 2.2px; }
.preview-particles .p2 { --tx: -260.2px; --ty: 111.2px; --color: #7dd87d; animation-duration: 2.62s; animation-delay: 0.93s; width: 1.7px; height: 1.7px; }
.preview-particles .p3 { --tx: -305.8px; --ty: 29.9px; --color: #7db8da; animation-duration: 2.20s; animation-delay: 0.39s; width: 2.3px; height: 2.3px; }
.preview-particles .p4 { --tx: -95.4px; --ty: 344.1px; --color: #5ce1e6; animation-duration: 2.60s; animation-delay: 0.73s; width: 2.3px; height: 2.3px; }
.preview-particles .p5 { --tx: 261.1px; --ty: -8.0px; --color: #5ce1e6; animation-duration: 2.04s; animation-delay: 0.11s; width: 2.6px; height: 2.6px; }
.preview-particles .p6 { --tx: -264.8px; --ty: -169.1px; --color: #ffd700; animation-duration: 2.20s; animation-delay: 1.18s; width: 1.2px; height: 1.2px; }
.preview-particles .p7 { --tx: -89.4px; --ty: -352.8px; --color: #5ce1e6; animation-duration: 2.70s; animation-delay: 0.97s; width: 2.5px; height: 2.5px; }
.preview-particles .p8 { --tx: 27.2px; --ty: 342.5px; --color: #7dd87d; animation-duration: 2.71s; animation-delay: 1.16s; width: 1.6px; height: 1.6px; }
.preview-particles .p9 { --tx: 266.7px; --ty: 62.5px; --color: #c9a0ff; animation-duration: 2.57s; animation-delay: 0.36s; width: 2.6px; height: 2.6px; }
.preview-particles .p10 { --tx: 78.7px; --ty: 279.1px; --color: #c9a0ff; animation-duration: 2.36s; animation-delay: 1.15s; width: 1.6px; height: 1.6px; }
.preview-particles .p11 { --tx: 43.5px; --ty: -214.5px; --color: #ff6b9d; animation-duration: 2.09s; animation-delay: 1.25s; width: 2.3px; height: 2.3px; }
.preview-particles .p12 { --tx: -306.8px; --ty: 212.0px; --color: #7dd87d; animation-duration: 2.77s; animation-delay: 1.25s; width: 2.1px; height: 2.1px; }
.preview-particles .p13 { --tx: -110.5px; --ty: 205.3px; --color: #ff6b9d; animation-duration: 2.44s; animation-delay: 1.15s; width: 2.6px; height: 2.6px; }
.preview-particles .p14 { --tx: 28.2px; --ty: -211.5px; --color: #ff6b9d; animation-duration: 2.52s; animation-delay: 1.41s; width: 1.7px; height: 1.7px; }
.preview-particles .p15 { --tx: 156.9px; --ty: -227.1px; --color: #ff6b9d; animation-duration: 2.80s; animation-delay: 1.20s; width: 2.5px; height: 2.5px; }
.preview-particles .p16 { --tx: 65.1px; --ty: 234.0px; --color: #ff6b9d; animation-duration: 2.50s; animation-delay: 0.77s; width: 2.9px; height: 2.9px; }
.preview-particles .p17 { --tx: 61.8px; --ty: 298.5px; --color: #5ce1e6; animation-duration: 2.79s; animation-delay: 0.86s; width: 3.0px; height: 3.0px; }
.preview-particles .p18 { --tx: -259.8px; --ty: -272.5px; --color: var(--accent); animation-duration: 2.06s; animation-delay: 1.31s; width: 2.1px; height: 2.1px; }
.preview-particles .p19 { --tx: 195.3px; --ty: -97.3px; --color: #7dd87d; animation-duration: 2.74s; animation-delay: 1.12s; width: 2.3px; height: 2.3px; }
.preview-particles .p20 { --tx: 73.0px; --ty: -201.2px; --color: #7db8da; animation-duration: 2.92s; animation-delay: 0.54s; width: 1.5px; height: 1.5px; }
.preview-particles .p21 { --tx: -234.1px; --ty: 40.6px; --color: #5ce1e6; animation-duration: 2.70s; animation-delay: 1.18s; width: 1.4px; height: 1.4px; }
.preview-particles .p22 { --tx: 138.9px; --ty: 278.7px; --color: var(--accent); animation-duration: 2.71s; animation-delay: 1.45s; width: 2.9px; height: 2.9px; }
.preview-particles .p23 { --tx: -42.8px; --ty: 287.4px; --color: var(--accent); animation-duration: 2.63s; animation-delay: 0.07s; width: 1.6px; height: 1.6px; }
.preview-particles .p24 { --tx: -172.7px; --ty: -190.6px; --color: #ffd700; animation-duration: 2.82s; animation-delay: 1.13s; width: 2.2px; height: 2.2px; }
.preview-particles .p25 { --tx: -102.1px; --ty: -238.8px; --color: #7db8da; animation-duration: 3.19s; animation-delay: 1.34s; width: 4.6px; height: 4.6px; }
.preview-particles .p26 { --tx: -174.4px; --ty: 107.2px; --color: var(--accent); animation-duration: 2.77s; animation-delay: 1.07s; width: 1.9px; height: 1.9px; }
.preview-particles .p27 { --tx: -272.7px; --ty: 225.9px; --color: #ff6b9d; animation-duration: 2.70s; animation-delay: 1.19s; width: 2.5px; height: 2.5px; }
.preview-particles .p28 { --tx: -179.7px; --ty: 239.3px; --color: #7db8da; animation-duration: 2.99s; animation-delay: 0.41s; width: 1.6px; height: 1.6px; }
.preview-particles .p29 { --tx: -41.4px; --ty: -247.9px; --color: var(--accent); animation-duration: 2.18s; animation-delay: 0.46s; width: 2.0px; height: 2.0px; }
.preview-particles .p30 { --tx: 45.4px; --ty: -335.5px; --color: var(--accent); animation-duration: 3.53s; animation-delay: 1.80s; width: 5.1px; height: 5.1px; }
.preview-particles .p31 { --tx: 37.9px; --ty: 324.6px; --color: #7dd87d; animation-duration: 2.78s; animation-delay: 0.13s; width: 2.5px; height: 2.5px; }
.preview-particles .p32 { --tx: 166.4px; --ty: 228.0px; --color: #ffd700; animation-duration: 2.75s; animation-delay: 0.96s; width: 1.4px; height: 1.4px; }
.preview-particles .p33 { --tx: 281.4px; --ty: 239.1px; --color: #c9a0ff; animation-duration: 2.16s; animation-delay: 0.96s; width: 2.6px; height: 2.6px; }
.preview-particles .p34 { --tx: 295.0px; --ty: -29.7px; --color: #7dd87d; animation-duration: 3.55s; animation-delay: 2.41s; width: 5.3px; height: 5.3px; }
.preview-particles .p35 { --tx: 227.0px; --ty: 124.8px; --color: #ff6b9d; animation-duration: 2.39s; animation-delay: 0.03s; width: 2.1px; height: 2.1px; }
.preview-particles .p36 { --tx: 7.7px; --ty: -225.7px; --color: #c9a0ff; animation-duration: 2.17s; animation-delay: 0.31s; width: 2.4px; height: 2.4px; }
.preview-particles .p37 { --tx: -146.4px; --ty: 247.1px; --color: #7dd87d; animation-duration: 2.55s; animation-delay: 1.45s; width: 2.5px; height: 2.5px; }
.preview-particles .p38 { --tx: -98.7px; --ty: -246.1px; --color: #ffd700; animation-duration: 2.19s; animation-delay: 0.07s; width: 2.0px; height: 2.0px; }
.preview-particles .p39 { --tx: 300.2px; --ty: 151.8px; --color: #ff6b9d; animation-duration: 2.19s; animation-delay: 1.48s; width: 2.7px; height: 2.7px; }
.preview-particles .p40 { --tx: -99.4px; --ty: -309.4px; --color: #7db8da; animation-duration: 2.16s; animation-delay: 0.62s; width: 2.6px; height: 2.6px; }
.preview-particles .p41 { --tx: -269.1px; --ty: -95.8px; --color: #5ce1e6; animation-duration: 2.94s; animation-delay: 1.09s; width: 1.6px; height: 1.6px; }
.preview-particles .p42 { --tx: -185.7px; --ty: -96.7px; --color: #c9a0ff; animation-duration: 2.20s; animation-delay: 0.02s; width: 2.2px; height: 2.2px; }
.preview-particles .p43 { --tx: -202.3px; --ty: -64.1px; --color: #ff6b9d; animation-duration: 2.49s; animation-delay: 0.11s; width: 2.2px; height: 2.2px; }
.preview-particles .p44 { --tx: 287.4px; --ty: 3.1px; --color: #ffaa5c; animation-duration: 3.13s; animation-delay: 1.74s; width: 6.8px; height: 6.8px; }
.preview-particles .p45 { --tx: 132.0px; --ty: -152.7px; --color: #ff6b9d; animation-duration: 2.54s; animation-delay: 1.47s; width: 1.1px; height: 1.1px; }
.preview-particles .p46 { --tx: -359.5px; --ty: -19.9px; --color: #c9a0ff; animation-duration: 2.32s; animation-delay: 1.42s; width: 2.0px; height: 2.0px; }
.preview-particles .p47 { --tx: -241.2px; --ty: -38.6px; --color: #ff6b9d; animation-duration: 2.70s; animation-delay: 0.06s; width: 2.4px; height: 2.4px; }
.preview-particles .p48 { --tx: -257.0px; --ty: 238.6px; --color: #ff6b9d; animation-duration: 2.83s; animation-delay: 1.49s; width: 2.8px; height: 2.8px; }
.preview-particles .p49 { --tx: -192.2px; --ty: -172.3px; --color: #c9a0ff; animation-duration: 2.94s; animation-delay: 0.31s; width: 1.3px; height: 1.3px; }
.preview-particles .p50 { --tx: 163.9px; --ty: 282.1px; --color: #ff6b9d; animation-duration: 2.98s; animation-delay: 1.23s; width: 2.1px; height: 2.1px; }
.preview-particles .p51 { --tx: -143.1px; --ty: -302.2px; --color: var(--accent); animation-duration: 2.29s; animation-delay: 0.10s; width: 1.1px; height: 1.1px; }
.preview-particles .p52 { --tx: 185.2px; --ty: 220.9px; --color: #5ce1e6; animation-duration: 2.60s; animation-delay: 0.04s; width: 2.5px; height: 2.5px; }
.preview-particles .p53 { --tx: -248.8px; --ty: 71.3px; --color: #7dd87d; animation-duration: 2.86s; animation-delay: 0.67s; width: 2.8px; height: 2.8px; }
.preview-particles .p54 { --tx: -176.9px; --ty: 317.2px; --color: #7db8da; animation-duration: 3.46s; animation-delay: 1.27s; width: 6.0px; height: 6.0px; }
.preview-particles .p55 { --tx: -291.2px; --ty: 139.1px; --color: var(--accent); animation-duration: 3.06s; animation-delay: 1.08s; width: 5.6px; height: 5.6px; }
.preview-particles .p56 { --tx: 272.9px; --ty: 227.7px; --color: #7dd87d; animation-duration: 2.59s; animation-delay: 1.25s; width: 1.6px; height: 1.6px; }
.preview-particles .p57 { --tx: 279.6px; --ty: -87.7px; --color: #7dd87d; animation-duration: 2.35s; animation-delay: 1.37s; width: 1.9px; height: 1.9px; }
.preview-particles .p58 { --tx: 41.1px; --ty: 247.4px; --color: var(--accent); animation-duration: 3.55s; animation-delay: 1.55s; width: 6.7px; height: 6.7px; }
.preview-particles .p59 { --tx: 207.9px; --ty: -21.4px; --color: #5ce1e6; animation-duration: 2.79s; animation-delay: 0.13s; width: 1.3px; height: 1.3px; }
.preview-particles .p60 { --tx: 29.9px; --ty: -349.0px; --color: #7dd87d; animation-duration: 2.16s; animation-delay: 1.14s; width: 2.3px; height: 2.3px; }
.preview-particles .p61 { --tx: 344.9px; --ty: 153.6px; --color: #c9a0ff; animation-duration: 2.42s; animation-delay: 0.65s; width: 2.6px; height: 2.6px; }
.preview-particles .p62 { --tx: -7.4px; --ty: 316.9px; --color: #c9a0ff; animation-duration: 2.02s; animation-delay: 0.23s; width: 2.3px; height: 2.3px; }
.preview-particles .p63 { --tx: 264.0px; --ty: 168.3px; --color: var(--accent); animation-duration: 3.89s; animation-delay: 0.61s; width: 4.2px; height: 4.2px; }
.preview-particles .p64 { --tx: -324.6px; --ty: -96.9px; --color: #c9a0ff; animation-duration: 3.87s; animation-delay: 1.37s; width: 6.5px; height: 6.5px; }
.preview-particles .p65 { --tx: -163.0px; --ty: -125.2px; --color: #7db8da; animation-duration: 2.84s; animation-delay: 0.27s; width: 2.6px; height: 2.6px; }
.preview-particles .p66 { --tx: -24.6px; --ty: 238.8px; --color: #ffd700; animation-duration: 2.51s; animation-delay: 0.73s; width: 2.6px; height: 2.6px; }
.preview-particles .p67 { --tx: -189.2px; --ty: 269.9px; --color: #ffaa5c; animation-duration: 2.40s; animation-delay: 0.66s; width: 2.6px; height: 2.6px; }
.preview-particles .p68 { --tx: 192.6px; --ty: -175.7px; --color: #7dd87d; animation-duration: 3.85s; animation-delay: 0.82s; width: 6.9px; height: 6.9px; }
.preview-particles .p69 { --tx: 327.0px; --ty: 93.8px; --color: #c9a0ff; animation-duration: 2.53s; animation-delay: 0.99s; width: 2.8px; height: 2.8px; }
.preview-particles .p70 { --tx: 356.0px; --ty: 67.1px; --color: #5ce1e6; animation-duration: 2.19s; animation-delay: 1.15s; width: 2.6px; height: 2.6px; }
.preview-particles .p71 { --tx: -230.9px; --ty: -35.1px; --color: #ffd700; animation-duration: 2.59s; animation-delay: 0.11s; width: 2.4px; height: 2.4px; }
.preview-particles .p72 { --tx: 257.3px; --ty: -224.0px; --color: #7db8da; animation-duration: 2.22s; animation-delay: 0.23s; width: 1.3px; height: 1.3px; }
.preview-particles .p73 { --tx: -132.8px; --ty: -210.1px; --color: #ffd700; animation-duration: 2.55s; animation-delay: 1.22s; width: 2.2px; height: 2.2px; }
.preview-particles .p74 { --tx: -86.5px; --ty: 280.8px; --color: #ff6b9d; animation-duration: 2.27s; animation-delay: 0.71s; width: 2.8px; height: 2.8px; }
.preview-particles .p75 { --tx: 332.7px; --ty: 26.2px; --color: #ffd700; animation-duration: 2.93s; animation-delay: 1.27s; width: 1.2px; height: 1.2px; }

@keyframes particle-explode {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.1);
  }
  5% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(2);
  }
  20% {
    opacity: 0.95;
  }
  100% {
    opacity: 0;
    transform: translate(calc(-50% + var(--tx)), calc(-50% + var(--ty))) scale(0.05);
  }
}

.preview-particles .particles-text {
  position: relative;
  z-index: 1;
  font-size: 14px;
  color: var(--text-tertiary);
  opacity: 0.7;
  letter-spacing: 2px;
  animation: text-glow 3s ease-in-out infinite;
}

@keyframes text-glow {
  0%, 100% { opacity: 0.5; text-shadow: 0 0 5px var(--accent); }
  50% { opacity: 0.9; text-shadow: 0 0 15px var(--accent), 0 0 30px var(--accent); }
}

/* 预览区需要相对定位 */
.preview-body { position: relative; }



.hl-heading { color: #ffd700; font-weight: 600; }
.hl-bold { color: #ff6b9d; font-weight: 600; }
.hl-italic { color: #c9a0ff; font-style: italic; }
.hl-code { color: #5ce1e6; background: rgba(92, 225, 230, 0.1); padding: 1px 4px; border-radius: 3px; }
.hl-codeblock { color: #7dd87d; }
.hl-link { color: #7db8da; text-decoration: underline; }
.hl-list { color: #ffaa5c; }
.hl-quote { color: #a0a0a0; font-style: italic; }
.hl-hr { color: #666; }
.hl-table { color: #ffd700; }
.hl-checkbox { color: #7dd87d; }
.hl-marker { color: #ff6b9d; }




/* ================ 1:1 比例下按钮适配：只显示图标 ================ */
.main.ratio-1-1 .toolbar-text-btn .btn-text {
  display: none;
}
.main.ratio-1-1 .toolbar-text-btn {
  min-width: 36px;
  padding: 0 8px;
  font-size: 14px;
}
.main.ratio-1-1 .edit-toggle-toolbar {
  min-width: 36px;
  padding: 0 8px;
}
.main.ratio-1-1 .discard-btn {
  margin-right: 4px;
}
/* 1:1 比例下分支选择框缩小 */
.main.ratio-1-1 .branch-selector {
  max-width: 80px;
}
.main.ratio-1-1 .branch-selector select {
  font-size: 11px;
  padding: 4px 6px;
}

/* ================ 展示模式下按钮适配 ================ */
.main.display-mode .save-group .btn-text {
  display: none;
}
.main.display-mode .save-group .toolbar-text-btn {
  min-width: 36px;
  padding: 0 8px;
}
.main.display-mode .edit-toggle-toolbar {
  min-width: 36px;
  padding: 0 8px;
}


/* ================ 底部状态栏字体控制 ================ */
.status-font-controls {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-right: 12px;
}
.status-font-btn {
  width: 26px;
  height: 24px;
  border: 1px solid var(--accent);
  border-radius: 4px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}
.status-font-btn:hover {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
}
.status-font-size {
  font-size: 11px;
  color: var(--text-tertiary);
  min-width: 24px;
  text-align: center;
}


/* ================ 顶部保存组右对齐 ================ */
.save-group {
  margin-left: auto !important;
}

/* ================ 底部状态栏调整 ================ */
.editor-statusbar {
  min-height: 32px;
  display: flex;
  align-items: center;
}
.status-right {
  display: flex !important;
  align-items: center !important;
  gap: 12px;
}
.status-font-controls {
  display: flex !important;
  align-items: center !important;
  gap: 4px;
  margin-right: 12px;
}
.status-font-btn {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}


/* ================ 强制显示底部字体控件（调试用） ================ */
.editor-statusbar {
  height: 40px !important;
  min-height: 40px !important;
  padding: 4px 12px !important;
  overflow: visible !important;
}
.status-right {
  display: flex !important;
  align-items: center !important;
  gap: 12px !important;
  overflow: visible !important;
}
.status-font-controls {
  display: flex !important;
  align-items: center !important;
  gap: 6px !important;
  margin-right: 12px !important;
  padding: 2px 6px !important;
  background: rgba(255, 0, 0, 0.2) !important;
  border: 1px solid red !important;
  border-radius: 4px !important;
}
.status-font-btn {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 28px !important;
  height: 26px !important;
  background: #ff4444 !important;
  color: #ffffff !important;
  border: 1px solid #ff0000 !important;
  border-radius: 4px !important;
  font-size: 12px !important;
  font-weight: 700 !important;
  cursor: pointer !important;
  opacity: 1 !important;
  visibility: visible !important;
}
.status-font-size {
  display: inline-block !important;
  min-width: 28px !important;
  text-align: center !important;
  font-size: 12px !important;
  font-weight: 700 !important;
  color: #ff4444 !important;
  opacity: 1 !important;
  visibility: visible !important;
}


/* ================ 标题栏字体控制（在 📺 按钮旁边） ================ */
.title-font-controls {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-right: 8px;
}
.title-font-btn {
  width: 26px;
  height: 24px;
  border: 1px solid var(--border-hover);
  border-radius: 4px;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}
.title-font-btn:hover {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
}
.title-font-size {
  font-size: 11px;
  color: var(--text-tertiary);
  min-width: 24px;
  text-align: center;
  font-weight: 500;
}

/* 已移除：之前为 Monaco 隐藏行号的样式，现在恢复自定义行号 */


/* ================ 确保 Monaco Editor 行号显示 ================ */
.monaco-editor .margin {
  display: block !important;
  width: auto !important;
  min-width: 40px !important;
  max-width: 50px !important;
  background: #1e1e1e !important;
  border-right: 1px solid #2a2825 !important;
  overflow: visible !important;
}
.monaco-editor .line-numbers {
  display: block !important;
  color: #6a9955 !important;
  font-size: 12px !important;
  text-align: right !important;
  padding-right: 8px !important;
  padding-left: 4px !important;
  line-height: 24px !important;
  overflow: visible !important;
}
.monaco-editor .current-line ~ .line-numbers {
  color: #c6c6c6 !important;
}
.monaco-editor .view-overlays .current-line {
  border: none !important;
}


/* ================ 自定义语法高亮层（修复版） ================ */
.editor-highlight {
  position: absolute;
  top: 0;
  left: 48px;
  right: 0;
  bottom: 0;
  padding: 24px 32px 24px 16px;
  margin: 0;
  font-family: var(--editor-font);
  font-size: var(--editor-font-size, 14px);
  line-height: 1.7;
  color: var(--text-primary);
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow: hidden;
  pointer-events: none;
  z-index: 1;
  box-sizing: border-box;
  background: transparent;
}

/* textarea 透明，只显示光标 */
.editor-textarea {
  position: relative;
  z-index: 2;
  background: transparent !important;
  color: transparent !important;
  caret-color: var(--text-primary) !important;
  flex: 1;
  min-width: 0;
  min-height: 0;
  padding: 24px 32px 24px 16px;
  font-family: var(--editor-font);
  font-size: var(--editor-font-size, 14px);
  line-height: 1.7;
  border: none;
  outline: none;
  resize: none;
  overflow-y: auto;
  overflow-x: hidden;
  tab-size: 2;
  box-sizing: border-box;
  display: block;
}

.editor-textarea::selection {
  background: rgba(125, 184, 218, 0.3);
}


/* ================ 编辑区绝对定位布局（修复版） ================ */
.editor-with-lines {
  position: relative !important;
  flex: 1 !important;
  display: block !important;
  overflow: hidden !important;
  background: var(--bg-primary) !important;
  min-height: 0 !important;
}

.line-numbers {
  display: block !important;
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  width: 48px !important;
  height: 100% !important;
  padding: 24px 8px 24px 0 !important;
  margin: 0 !important;
  box-sizing: border-box !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  z-index: 3 !important;
  background: var(--bg-primary) !important;
  border-right: 1px solid var(--border-color) !important;
}

.editor-highlight {
  position: absolute !important;
  top: 0 !important;
  left: 48px !important;
  right: 0 !important;
  bottom: 0 !important;
  width: auto !important;
  height: auto !important;
  padding: 24px 32px 24px 16px !important;
  margin: 0 !important;
  box-sizing: border-box !important;
  overflow: hidden !important;
  pointer-events: none !important;
  z-index: 1 !important;
  background: transparent !important;
}

.editor-textarea {
  position: absolute !important;
  top: 0 !important;
  left: 48px !important;
  right: 0 !important;
  bottom: 0 !important;
  width: auto !important;
  height: auto !important;
  padding: 24px 32px 24px 16px !important;
  margin: 0 !important;
  box-sizing: border-box !important;
  background: transparent !important;
  color: transparent !important;
  caret-color: var(--text-primary) !important;
  font-family: var(--editor-font) !important;
  font-size: var(--editor-font-size, 14px) !important;
  line-height: 1.7 !important;
  border: none !important;
  outline: none !important;
  resize: none !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  tab-size: 2 !important;
  z-index: 2 !important;
  display: block !important;
  white-space: pre-wrap !important;
  word-wrap: break-word !important;
}

.monaco-container {
  display: none !important;
}


/* ================ 行号样式（修复版） ================ */
.line-numbers {
  color: #6a9955 !important;
  font-family: var(--editor-font) !important;
  font-size: 12px !important;
  text-align: right !important;
  user-select: none !important;
}
.line-number {
  display: block !important;
  width: 100% !important;
  text-align: right !important;
  padding-right: 8px !important;
  color: #6a9955 !important;
  font-size: 12px !important;
  line-height: inherit !important;
  box-sizing: border-box !important;
}
.line-number.error {
  color: #f44747 !important;
  background: rgba(244, 71, 71, 0.15) !important;
  font-weight: bold !important;
  cursor: help !important;
}


/* ================ 确保高亮层文字颜色正确 ================ */
.editor-highlight {
  color: #d4d4d4 !important; /* VS Code Dark+ 普通文字颜色 */
}
.editor-highlight .hl-bold {
  color: #ff6b9d !important;
  font-weight: 600;
}
.editor-highlight .hl-italic {
  color: #c586c0 !important;
  font-style: italic;
}
.editor-highlight .hl-code {
  color: #ce9178 !important;
  background: rgba(206, 145, 120, 0.1) !important;
  padding: 1px 4px !important;
  border-radius: 3px !important;
}
.editor-highlight .hl-codeblock {
  color: #ce9178 !important;
}
.editor-highlight .hl-heading {
  color: #569cd6 !important;
  font-weight: 600 !important;
}
.editor-highlight .hl-link {
  color: #4fc1ff !important;
  text-decoration: underline !important;
}
.editor-highlight .hl-quote {
  color: #6a9955 !important;
  font-style: italic !important;
}
.editor-highlight .hl-list {
  color: #dcdcaa !important;
}
.editor-highlight .hl-checkbox {
  color: #dcdcaa !important;
}
.editor-highlight .hl-hr {
  color: #808080 !important;
}
.editor-highlight .hl-table {
  color: #dcdcaa !important;
}


/* ==========================================
   极客暗黑预览主题 (Modern Dark Preview)
   ========================================== */
.style-modern-dark.markdown-preview,
.style-modern-dark.preview-content {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background-color: #181825;
  color: #cdd6f4;
  line-height: 1.7;
}
.style-modern-dark.markdown-preview strong,
.style-modern-dark.markdown-preview b,
.style-modern-dark.preview-content strong,
.style-modern-dark.preview-content b {
  color: #cba6f7;
  font-weight: 600;
}
.style-modern-dark.markdown-preview code,
.style-modern-dark.preview-content code {
  font-family: "Fira Code", "Source Code Pro", Consolas, Monaco, monospace;
  background-color: #313244;
  color: #f38ba8;
  padding: 2px 6px;
  border-radius: 4px;
}
.style-modern-dark.markdown-preview pre code,
.style-modern-dark.preview-content pre code {
  background: none;
  color: #cdd6f4;
  padding: 0;
}
.style-modern-dark.markdown-preview blockquote,
.style-modern-dark.preview-content blockquote {
  background-color: #1e1e2e;
  border-left: 4px solid #89b4fa;
  color: #a6adc8;
  border-radius: 0 4px 4px 0;
}
.style-modern-dark.markdown-preview h1,
.style-modern-dark.markdown-preview h2,
.style-modern-dark.markdown-preview h3,
.style-modern-dark.markdown-preview h4,
.style-modern-dark.markdown-preview h5,
.style-modern-dark.markdown-preview h6,
.style-modern-dark.preview-content h1,
.style-modern-dark.preview-content h2,
.style-modern-dark.preview-content h3,
.style-modern-dark.preview-content h4,
.style-modern-dark.preview-content h5,
.style-modern-dark.preview-content h6 {
  color: #cba6f7;
}
.style-modern-dark.markdown-preview a,
.style-modern-dark.preview-content a {
  color: #89b4fa;
}
.style-modern-dark.markdown-preview ul li::marker,
.style-modern-dark.markdown-preview ol li::marker,
.style-modern-dark.preview-content ul li::marker,
.style-modern-dark.preview-content ol li::marker {
  color: #a6e3a1;
}
.style-modern-dark.markdown-preview hr,
.style-modern-dark.preview-content hr {
  background: #313244;
}
.style-modern-dark.markdown-preview pre,
.style-modern-dark.preview-content pre {
  background-color: #11111b;
  border-color: #313244;
  color: #cdd6f4;
}
.style-modern-dark.markdown-preview th,
.style-modern-dark.preview-content th {
  background-color: #1e1e2e;
}
.style-modern-dark.markdown-preview th,
.style-modern-dark.markdown-preview td,
.style-modern-dark.preview-content th,
.style-modern-dark.preview-content td {
  border-color: #313244;
}

/* ================ 预览风格切换器 ================ */
.preview-title-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.preview-style-dropdown {
  position: relative;
  display: inline-block;
}
.preview-style-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  padding: 2px 4px;
  border-radius: 4px;
  transition: background 0.15s ease;
  line-height: 1;
  margin-right: 8px;
}
.preview-style-btn:hover {
  background: var(--bg-hover);
}
.preview-style-menu {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 4px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  min-width: 140px;
  z-index: 100;
  display: none;
  overflow: hidden;
}
.preview-style-menu.open {
  display: block;
}
.preview-style-item {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text-primary);
  transition: background 0.15s ease;
  white-space: nowrap;
}
.preview-style-item:hover {
  background: var(--bg-hover);
}
.preview-style-item.active {
  background: var(--accent-soft);
  color: var(--accent);
}

/* ===== 森林晨雾 (Nordic Forest) ===== */
.style-nordic-forest.markdown-preview,
.style-nordic-forest.preview-content {
  font-family: "Source Han Sans SC", "Hiragino Sans GB", "Heiti SC", sans-serif;
  background-color: #121e17;
  color: #e0e8e3;
  line-height: 1.75;
}
.style-nordic-forest.markdown-preview strong,
.style-nordic-forest.markdown-preview b,
.style-nordic-forest.preview-content strong,
.style-nordic-forest.preview-content b {
  color: #78ab80;
  font-weight: 600;
}
.style-nordic-forest.markdown-preview code,
.style-nordic-forest.preview-content code {
  font-family: "JetBrains Mono", Consolas, monospace;
  background-color: #1e2a35;
  color: #8fb8d8;
  padding: 2px 6px;
  border-radius: 4px;
}
.style-nordic-forest.markdown-preview pre code,
.style-nordic-forest.preview-content pre code {
  background: none;
  color: #c8d8e8;
  padding: 0;
}
.style-nordic-forest.markdown-preview blockquote,
.style-nordic-forest.preview-content blockquote {
  background-color: #1a2e22;
  border-left: 4px solid #78ab80;
  color: #b8c8be;
  border-radius: 0 4px 4px 0;
}
.style-nordic-forest.markdown-preview h1,
.style-nordic-forest.markdown-preview h2,
.style-nordic-forest.markdown-preview h3,
.style-nordic-forest.markdown-preview h4,
.style-nordic-forest.markdown-preview h5,
.style-nordic-forest.markdown-preview h6,
.style-nordic-forest.preview-content h1,
.style-nordic-forest.preview-content h2,
.style-nordic-forest.preview-content h3,
.style-nordic-forest.preview-content h4,
.style-nordic-forest.preview-content h5,
.style-nordic-forest.preview-content h6 {
  color: #78ab80;
}
.style-nordic-forest.markdown-preview a,
.style-nordic-forest.preview-content a {
  color: #8fc49a;
}
.style-nordic-forest.markdown-preview ul li::marker,
.style-nordic-forest.markdown-preview ol li::marker,
.style-nordic-forest.preview-content ul li::marker,
.style-nordic-forest.preview-content ol li::marker {
  color: #78ab80;
}
.style-nordic-forest.markdown-preview hr,
.style-nordic-forest.preview-content hr {
  background: #2a4030;
}
.style-nordic-forest.markdown-preview pre,
.style-nordic-forest.preview-content pre {
  background-color: #1a2530;
  border-color: #2a3a48;
  color: #c8d8e8;
}
.style-nordic-forest.markdown-preview th,
.style-nordic-forest.preview-content th {
  background-color: #16281d;
  color: #e0e8e3;
}
.style-nordic-forest.markdown-preview td,
.style-nordic-forest.preview-content th,
.style-nordic-forest.preview-content td {
  border-color: #1f3528;
}
/* ===== 烟雨江南 (Jiangnan Fog) ===== */
.style-jiangnan-fog.markdown-preview,
.style-jiangnan-fog.preview-content {
  font-family: "LXGW WenKai", "STKaiti", "KaiTi", serif;
  color: #2c3e50;
  background-color: #eef2f3;
  line-height: 1.8;
}
.style-jiangnan-fog.markdown-preview strong,
.style-jiangnan-fog.markdown-preview b,
.style-jiangnan-fog.preview-content strong,
.style-jiangnan-fog.preview-content b {
  color: #2980b9;
  font-weight: 600;
}
.style-jiangnan-fog.markdown-preview code,
.style-jiangnan-fog.preview-content code {
  font-family: "Fira Code", monospace;
  background-color: #d5e8e4;
  color: #16a085;
  padding: 2px 6px;
  border-radius: 4px;
}
.style-jiangnan-fog.markdown-preview pre code,
.style-jiangnan-fog.preview-content pre code {
  background: none;
  color: #2c3e50;
  padding: 0;
}
.style-jiangnan-fog.markdown-preview blockquote,
.style-jiangnan-fog.preview-content blockquote {
  background-color: #e4e9ed;
  border-left: 4px solid #7f8c8d;
  color: #4a6572;
  border-radius: 0 4px 4px 0;
}
.style-jiangnan-fog.markdown-preview h1,
.style-jiangnan-fog.markdown-preview h2,
.style-jiangnan-fog.markdown-preview h3,
.style-jiangnan-fog.markdown-preview h4,
.style-jiangnan-fog.markdown-preview h5,
.style-jiangnan-fog.markdown-preview h6,
.style-jiangnan-fog.preview-content h1,
.style-jiangnan-fog.preview-content h2,
.style-jiangnan-fog.preview-content h3,
.style-jiangnan-fog.preview-content h4,
.style-jiangnan-fog.preview-content h5,
.style-jiangnan-fog.preview-content h6 {
  color: #2980b9;
}
.style-jiangnan-fog.markdown-preview a,
.style-jiangnan-fog.preview-content a {
  color: #16a085;
}
.style-jiangnan-fog.markdown-preview ul li::marker,
.style-jiangnan-fog.markdown-preview ol li::marker,
.style-jiangnan-fog.preview-content ul li::marker,
.style-jiangnan-fog.preview-content ol li::marker {
  color: #7f8c8d;
}
.style-jiangnan-fog.markdown-preview hr,
.style-jiangnan-fog.preview-content hr {
  background: #bdc3c7;
}


/* ===== 朱砂古卷 (Vermilion Scroll) ===== */
.style-vermilion-scroll.markdown-preview,
.style-vermilion-scroll.preview-content {
  font-family: "Noto Serif SC", "Songti SC", "SimSun", serif;
  color: #2b2b2b;
  background-color: #f7f4ed;
  line-height: 1.8;
}
.style-vermilion-scroll.markdown-preview strong,
.style-vermilion-scroll.markdown-preview b,
.style-vermilion-scroll.preview-content strong,
.style-vermilion-scroll.preview-content b {
  color: #b83227;
  font-weight: 700;
}
.style-vermilion-scroll.markdown-preview code,
.style-vermilion-scroll.preview-content code {
  font-family: "Courier New", Courier, monospace;
  background-color: #eae3d2;
  color: #a63a50;
  padding: 2px 6px;
  border-radius: 3px;
}
.style-vermilion-scroll.markdown-preview pre code,
.style-vermilion-scroll.preview-content pre code {
  background: none;
  color: #2b2b2b;
  padding: 0;
}
.style-vermilion-scroll.markdown-preview blockquote,
.style-vermilion-scroll.preview-content blockquote {
  background-color: #f0eae1;
  border-left: 4px solid #8c6d46;
  color: #594a38;
  border-radius: 0 4px 4px 0;
}
.style-vermilion-scroll.markdown-preview h1,
.style-vermilion-scroll.markdown-preview h2,
.style-vermilion-scroll.markdown-preview h3,
.style-vermilion-scroll.markdown-preview h4,
.style-vermilion-scroll.markdown-preview h5,
.style-vermilion-scroll.markdown-preview h6,
.style-vermilion-scroll.preview-content h1,
.style-vermilion-scroll.preview-content h2,
.style-vermilion-scroll.preview-content h3,
.style-vermilion-scroll.preview-content h4,
.style-vermilion-scroll.preview-content h5,
.style-vermilion-scroll.preview-content h6 {
  color: #b83227;
}
.style-vermilion-scroll.markdown-preview a,
.style-vermilion-scroll.preview-content a {
  color: #a63a50;
}
.style-vermilion-scroll.markdown-preview ul li::marker,
.style-vermilion-scroll.markdown-preview ol li::marker,
.style-vermilion-scroll.preview-content ul li::marker,
.style-vermilion-scroll.preview-content ol li::marker {
  color: #8c6d46;
}
.style-vermilion-scroll.markdown-preview hr,
.style-vermilion-scroll.preview-content hr {
  background: #d4c5a9;
}


/* 预览区容器背景色同步 */
.preview-panel:has(.style-modern-dark) .preview-body {
  background-color: #1e1e2e;
}
.preview-panel:has(.style-neon-aurora) .preview-body {
  background-color: #181a1b;
}
.preview-panel:has(.style-nordic-forest) .preview-body {
  background-color: #f4f7f6;
}
.preview-panel:has(.style-jiangnan-fog) .preview-body {
  background-color: #eef2f3;
}
.preview-panel:has(.style-vermilion-scroll) .preview-body {
  background-color: #f7f4ed;
}


/* ===== 各风格代码块/表格补充样式 ===== */

/* modern-dark */
.style-modern-dark.markdown-preview pre,
.style-modern-dark.preview-content pre {
  background-color: #313244;
  border-color: #45475a;
  color: #cdd6f4;
}
.style-modern-dark.markdown-preview pre code,
.style-modern-dark.preview-content pre code {
  background: none;
  color: #cdd6f4;
}
.style-modern-dark.markdown-preview th,
.style-modern-dark.preview-content th {
  background-color: #45475a;
}
.style-modern-dark.markdown-preview th,
.style-modern-dark.markdown-preview td,
.style-modern-dark.preview-content th,
.style-modern-dark.preview-content td {
  border-color: #45475a;
}

/* ===== 暗夜极光 (Neon Aurora) ===== */
.style-neon-aurora.markdown-preview,
.style-neon-aurora.preview-content {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background-color: #121212;
  color: #f8f8f2;
  line-height: 1.7;
}
.style-neon-aurora.markdown-preview strong,
.style-neon-aurora.markdown-preview b,
.style-neon-aurora.preview-content strong,
.style-neon-aurora.preview-content b {
  color: #50fa7b;
  font-weight: 600;
}
.style-neon-aurora.markdown-preview code,
.style-neon-aurora.preview-content code {
  font-family: "JetBrains Mono", monospace;
  background-color: #282a36;
  color: #50fa7b;
  padding: 2px 6px;
  border-radius: 4px;
}
.style-neon-aurora.markdown-preview pre code,
.style-neon-aurora.preview-content pre code {
  background: none;
  color: #f8f8f2;
  padding: 0;
}
.style-neon-aurora.markdown-preview blockquote,
.style-neon-aurora.preview-content blockquote {
  background-color: #1e1f29;
  border-left: 4px solid #50fa7b;
  color: #bdbdbd;
  border-radius: 0 4px 4px 0;
}
.style-neon-aurora.markdown-preview h1,
.style-neon-aurora.markdown-preview h2,
.style-neon-aurora.markdown-preview h3,
.style-neon-aurora.markdown-preview h4,
.style-neon-aurora.markdown-preview h5,
.style-neon-aurora.markdown-preview h6,
.style-neon-aurora.preview-content h1,
.style-neon-aurora.preview-content h2,
.style-neon-aurora.preview-content h3,
.style-neon-aurora.preview-content h4,
.style-neon-aurora.preview-content h5,
.style-neon-aurora.preview-content h6 {
  color: #50fa7b;
}
.style-neon-aurora.markdown-preview a,
.style-neon-aurora.preview-content a {
  color: #8be9fd;
}
.style-neon-aurora.markdown-preview ul li::marker,
.style-neon-aurora.markdown-preview ol li::marker,
.style-neon-aurora.preview-content ul li::marker,
.style-neon-aurora.preview-content ol li::marker {
  color: #50fa7b;
}
.style-neon-aurora.markdown-preview hr,
.style-neon-aurora.preview-content hr {
  background: #282a36;
}

/* neon-aurora */
.style-neon-aurora.markdown-preview pre,
.style-neon-aurora.preview-content pre {
  background-color: #282a36;
  border-color: #44475a;
  color: #e8e6e3;
}
.style-neon-aurora.markdown-preview pre code,
.style-neon-aurora.preview-content pre code {
  background: none;
  color: #e8e6e3;
}
.style-neon-aurora.markdown-preview th,
.style-neon-aurora.preview-content th {
  background-color: #44475a;
}
.style-neon-aurora.markdown-preview th,
.style-neon-aurora.markdown-preview td,
.style-neon-aurora.preview-content th,
.style-neon-aurora.preview-content td {
  border-color: #44475a;
}

/* nordic-forest */
.style-nordic-forest.markdown-preview pre,
.style-nordic-forest.preview-content pre {
  background-color: #1a2530;
  border-color: #2a3a48;
  color: #c8d8e8;
}
.style-nordic-forest.markdown-preview pre code,
.style-nordic-forest.preview-content pre code {
  background: none;
  color: #c8d8e8;
}
.style-nordic-forest.markdown-preview th,
.style-nordic-forest.preview-content th {
  background-color: #16281d;
  color: #e0e8e3;
}
.style-nordic-forest.markdown-preview td,
.style-nordic-forest.preview-content th,
.style-nordic-forest.preview-content td {
  border-color: #1f3528;
}

/* jiangnan-fog */
.style-jiangnan-fog.markdown-preview pre,
.style-jiangnan-fog.preview-content pre {
  background-color: #d5e8e4;
  border-color: #a3c4bc;
  color: #2c3e50;
}
.style-jiangnan-fog.markdown-preview pre code,
.style-jiangnan-fog.preview-content pre code {
  background: none;
  color: #2c3e50;
}
.style-jiangnan-fog.markdown-preview th,
.style-jiangnan-fog.preview-content th {
  background-color: #c5d8d4;
}
.style-jiangnan-fog.markdown-preview th,
.style-jiangnan-fog.markdown-preview td,
.style-jiangnan-fog.preview-content th,
.style-jiangnan-fog.preview-content td {
  border-color: #a3c4bc;
}

/* vermilion-scroll */
.style-vermilion-scroll.markdown-preview pre,
.style-vermilion-scroll.preview-content pre {
  background-color: #eae3d2;
  border-color: #d4c5a9;
  color: #2b2b2b;
}
.style-vermilion-scroll.markdown-preview pre code,
.style-vermilion-scroll.preview-content pre code {
  background: none;
  color: #2b2b2b;
}
.style-vermilion-scroll.markdown-preview th,
.style-vermilion-scroll.preview-content th {
  background-color: #e0d7c0;
}
.style-vermilion-scroll.markdown-preview th,
.style-vermilion-scroll.markdown-preview td,
.style-vermilion-scroll.preview-content th,
.style-vermilion-scroll.preview-content td {
  border-color: #d4c5a9;
}


/* 预览区外层容器背景色同步 */
.preview-body.style-modern-dark {
  background-color: #1e1e2e;
}
.preview-body.style-neon-aurora {
  background-color: #181a1b;
}
.preview-body.style-nordic-forest {
  background-color: #121e17;
}
.preview-body.style-jiangnan-fog {
  background-color: #eef2f3;
}
.preview-body.style-vermilion-scroll {
  background-color: #f7f4ed;
}

/* ================ 手机预览模式 ================ */
#right-sidebar.phone-mode .sidebar-content {
  display: flex !important;
  flex-direction: row !important;
  gap: 12px;
  padding: 12px !important;
  align-items: stretch;
  height: 100%;
  box-sizing: border-box;
}
#right-sidebar.phone-mode .panel:not(.preview-panel) {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  margin: 0;
}
#right-sidebar.phone-mode .preview-panel {
  display: none;
}
#right-sidebar.phone-mode .preview-panel .preview-particles {
  display: none;
}
.phone-preview-wrapper {
  flex: 0 0 auto;
  display: flex;
  justify-content: center;
  align-items: center;
  max-height: 100%;
}
.iphone-frame {
  width: 312px;
  height: 624px;
  max-height: 100%;
  background: #1a1a1a;
  border-radius: 43px;
  padding: 12px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.5), inset 0 0 2px rgba(255,255,255,0.1);
  position: relative;
  flex-shrink: 0;
}
.iphone-screen {
  width: 100%;
  height: 100%;
  background: transparent;
  border-radius: 30px;
  overflow: hidden;
  position: relative;
}
.iphone-notch {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  width: 120px;
  height: 24px;
  background: #1a1a1a;
  border-radius: 0 0 16px 16px;
  z-index: 10;
}
.iphone-home-indicator {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  width: 100px;
  height: 4px;
  background: rgba(0,0,0,0.3);
  border-radius: 2px;
  z-index: 10;
}
.iphone-content {
  width: 100%;
  height: 100%;
  overflow-y: auto;
  padding: 40px 16px 24px;
  box-sizing: border-box;
  font-size: 13px;
  line-height: 1.6;
}
.iphone-content::-webkit-scrollbar {
  width: 0;
}
.phone-doc-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px;
  background: var(--bg-secondary);
  border-radius: 12px;
  border: 1px solid var(--border-color);
  overflow-y: auto;
}
.phone-doc-info .info-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}
.phone-doc-info .info-item {
  font-size: 12px;
  color: var(--text-secondary);
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid var(--border-color);
}
.phone-doc-info .info-item .label {
  color: var(--text-tertiary);
}
.phone-doc-info .info-item .value {
  color: var(--text-primary);
  font-weight: 500;
}

/* 预览控制按钮移到右边栏头部 */
.sidebar-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  position: relative;
}
.sidebar-actions .preview-style-dropdown {
  display: flex;
  align-items: center;
  gap: 2px;
}
.sidebar-actions .preview-phone-btn,
.sidebar-actions .preview-style-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  line-height: 1;
  transition: background 0.15s ease;
}
.sidebar-actions .preview-phone-btn:hover,
.sidebar-actions .preview-style-btn:hover {
  background: var(--bg-hover);
}
.sidebar-actions .preview-phone-btn.active {
  background: var(--accent-soft);
}
.sidebar-actions .preview-style-menu {
  top: 100%;
  right: 0;
  margin-top: 4px;
}
/* 手机模式下文档信息竖向排列 */
#right-sidebar.phone-mode .meta-row {
  flex-direction: column;
  gap: 8px;
}
#right-sidebar.phone-mode .meta-half {
  width: 100%;
}

/* ================ 模块系统 ================ */
.module-list-item {
  display: flex;
  align-items: center;
  padding: 10px 14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
  gap: 10px;
}
.module-list-item:hover {
  border-color: var(--accent);
  background: var(--bg-secondary);
}
.module-list-item .module-icon {
  font-size: 18px;
  flex-shrink: 0;
}
.module-list-item .module-info {
  flex: 1;
  min-width: 0;
}
.module-list-item .module-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 2px;
}
.module-list-item .module-desc {
  font-size: 11px;
  color: var(--text-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.module-list-item .module-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.module-list-item .module-actions button {
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: 4px;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.module-list-item .module-actions button:hover {
  background: var(--bg-primary);
}

/* / 联想列表 */
#module-suggestions .suggestion-item {
  padding: 8px 14px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background 0.1s;
}
#module-suggestions .suggestion-item:hover,
#module-suggestions .suggestion-item.active {
  background: var(--accent-soft);
}
#module-suggestions .suggestion-item .s-icon {
  font-size: 14px;
}
#module-suggestions .suggestion-item .s-name {
  flex: 1;
}
#module-suggestions .suggestion-item .s-hint {
  font-size: 11px;
  color: var(--text-tertiary);
}

/* 模块系统文件夹特殊样式 */
.tree-node.module-system-folder > .node-row {
  opacity: 0.7;
}
.tree-node.module-system-folder > .node-row .node-name {
  color: var(--text-tertiary);
  font-style: italic;
}
.tree-node.module-system-folder > .node-row .node-name::after {
  content: " (模块系统，请勿删除)";
  font-size: 10px;
  color: var(--text-tertiary);
  opacity: 0.7;
}
