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

:root {
  --sidebar-width: 280px;
  --sidebar-collapsed-width: 64px;
  --toc-width: 300px;
  
  /* Console 配色 */
  --neutral-50: #fafafa;
  --neutral-100: #f5f5f5;
  --neutral-200: #e5e5e5;
  --neutral-300: #d4d4d4;
  --neutral-400: #a3a3a3;
  --neutral-500: #737373;
  --neutral-600: #525252;
  --neutral-700: #404040;
  --neutral-800: #262626;
  --neutral-900: #171717;
  
  --primary-400: #60a5fa;
  --primary-500: #3b82f6;
  --primary-600: #2563eb;
  --primary-100: #dbeafe;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: var(--neutral-100);
  color: var(--neutral-900);
  height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

#app {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* ==================== 侧边栏 - Console 风格 ==================== */
.sidebar {
  width: fit-content;
  min-width: 220px;
  max-width: 400px;
  background: var(--neutral-900);
  color: var(--neutral-300);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  height: 100%;
}

.sidebar.collapsed {
  width: 64px;
  min-width: 64px;
  max-width: 64px;
}

.sidebar-header {
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  border-bottom: 1px solid var(--neutral-800);
}

.sidebar.collapsed .sidebar-header {
  justify-content: center;
  padding: 0;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-logo svg {
  flex-shrink: 0;
}

.sidebar-logo span {
  font-size: 18px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
}

.sidebar.collapsed .sidebar-logo span {
  display: none;
}

.sidebar.collapsed .toggle-btn-header {
  display: none;
}

.toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 6px;
  background: none;
  border: none;
  border-radius: 4px;
  color: var(--neutral-400);
  cursor: pointer;
  transition: all 0.15s;
}

.toggle-btn:hover {
  background: var(--neutral-800);
  color: var(--neutral-200);
}

.toggle-btn svg {
  width: 18px;
  height: 18px;
}

/* 折叠时的展开按钮 */
.collapsed-toggle {
  display: none;
  width: 100%;
  padding: 12px 0;
  justify-content: center;
  border-bottom: 1px solid var(--neutral-800);
}

.sidebar.collapsed .collapsed-toggle {
  display: flex;
}

/* 新建按钮区域 */
.sidebar-actions {
  padding: 16px;
  border-bottom: 1px solid var(--neutral-800);
}

.sidebar.collapsed .sidebar-actions {
  padding: 8px;
}

/* 新建按钮 - 中性色 */
.new-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 10px 16px;
  background: var(--neutral-800);
  color: var(--neutral-300);
  border: 1px solid var(--neutral-700);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.new-btn:hover {
  background: var(--neutral-700);
  color: #fff;
  border-color: var(--neutral-600);
}

.new-btn svg {
  width: 18px;
  height: 18px;
}

.new-btn span {
  white-space: nowrap;
}

.sidebar.collapsed .new-btn {
  padding: 10px;
}

.sidebar.collapsed .new-btn span {
  display: none;
}

/* 下拉菜单 */
.dropdown {
  position: relative;
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 4px;
  background: var(--neutral-800);
  border: 1px solid var(--neutral-700);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  min-width: 160px;
  z-index: 100;
  display: none;
}

.sidebar.collapsed .dropdown-menu {
  left: 100%;
  top: 0;
  margin-top: 0;
  margin-left: 4px;
}

.dropdown-menu.show {
  display: block;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  font-size: 14px;
  color: var(--neutral-300);
  cursor: pointer;
  transition: background 0.15s;
}

.dropdown-item:first-child {
  border-radius: 7px 7px 0 0;
}

.dropdown-item:last-child {
  border-radius: 0 0 7px 7px;
}

.dropdown-item:hover {
  background: var(--neutral-700);
  color: #fff;
}

.dropdown-item svg {
  width: 16px;
  height: 16px;
  color: var(--neutral-500);
}

/* 文件树 */
.file-tree {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px;
}

.sidebar.collapsed .file-tree {
  display: none;
}

.tree-item {
  display: flex;
  align-items: center;
  padding: 4px 6px 4px 4px;
  margin: 1px 2px;
  border-radius: 4px;
  cursor: pointer;
  user-select: none;
  font-size: 13px;
  color: var(--neutral-400);
  transition: all 0.15s;
}

.tree-item:hover {
  background: var(--neutral-800);
  color: var(--neutral-200);
}

.tree-item.selected {
  background: var(--primary-600);
  color: #fff;
}

.tree-item.drop-target {
  background: var(--primary-500);
  outline: 2px solid var(--primary-400);
}

.tree-item .chevron {
  width: 14px;
  height: 14px;
  margin-right: 4px;
  color: var(--neutral-600);
  flex-shrink: 0;
  transition: transform 0.15s;
}

.tree-item:hover .chevron {
  color: var(--neutral-500);
}

.tree-item .chevron.expanded {
  transform: rotate(90deg);
}

.tree-item .chevron.hidden {
  visibility: hidden;
}

.tree-item .icon {
  width: 14px;
  height: 14px;
  margin-right: 6px;
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  margin-right: 6px;
  flex-shrink: 0;
}

.tree-item .icon.folder {
  color: #fbbf24;
}

.tree-item .icon.file {
  color: var(--neutral-500);
}

.tree-item .icon.file-md {
  color: #60a5fa;
}

.tree-item .name {
  flex: 1;
  white-space: nowrap;
}

.tree-item .name-input {
  flex: 1;
  padding: 2px 6px;
  border: 1px solid var(--primary-500);
  border-radius: 4px;
  font-size: 14px;
  outline: none;
  background: var(--neutral-800);
  color: #fff;
}

.tree-children {
  margin-left: 16px;
}

.tree-children.collapsed {
  display: none;
}

/* ==================== 主内容区 ==================== */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--neutral-50);
}



.welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--neutral-400);
}

.welcome h2 {
  font-size: 20px;
  font-weight: 600;
  color: var(--neutral-600);
  margin-bottom: 8px;
}

/* 文档视图 */
.doc-view {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: #fff;
}

.doc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid var(--neutral-200);
  background: #fff;
}

.doc-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--neutral-600);
}

.doc-title .draft-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  background: #fef3c7;
  color: #d97706;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
}

.doc-actions {
  display: flex;
  gap: 8px;
}

.btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  border: none;
}

.btn-primary {
  background: var(--neutral-900);
  color: #fff;
}

.btn-primary:hover {
  background: var(--neutral-700);
}

.btn-secondary {
  background: #fff;
  color: var(--neutral-600);
  border: 1px solid var(--neutral-200);
}

.btn-secondary:hover {
  background: var(--neutral-100);
  border-color: var(--neutral-300);
}

.btn svg {
  width: 14px;
  height: 14px;
}

.doc-body {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* TOC 目录 */
.toc:empty {
  display: none;
}

.toc {
  width: 300px;
  min-width: 300px;
  max-width: 300px;
  background: var(--neutral-50);
  border-left: 1px solid var(--neutral-200);
  order: 1;
  overflow: auto;
  padding: 16px;
  flex-shrink: 0;
}

.toc-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--neutral-500);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.toc-item {
  display: block;
  padding: 5px 0;
  color: var(--neutral-500);
  font-size: 13px;
  cursor: pointer;
  transition: color 0.15s;
  line-height: 1.4;
}

.toc-item:hover {
  color: var(--neutral-900);
}

.toc-item.active {
  color: var(--primary-600);
  font-weight: 500;
}

.toc-item.level-2 { padding-left: 12px; }
.toc-item.level-3 { padding-left: 24px; font-size: 12px; }
.toc-item.level-4 { padding-left: 36px; font-size: 12px; }

/* Markdown 渲染区 */
.markdown-body {
  flex: 1;
  padding: 32px 40px;
  overflow: auto;
  
  background: #fff;
  line-height: 1.5;
  color: #374151;
}

.markdown-body h1, .markdown-body h2, .markdown-body h3,
.markdown-body h4, .markdown-body h5, .markdown-body h6 {
  margin-top: 32px;
  margin-bottom: 16px;
  font-weight: 600;
  color: #111827;
  line-height: 1.3;
}

.markdown-body h1:first-child, .markdown-body h2:first-child {
  margin-top: 0;
}

.markdown-body h1 { font-size: 2em; }
.markdown-body h2 { font-size: 1.5em; padding-bottom: 8px; border-bottom: 1px solid var(--neutral-200); }
.markdown-body h3 { font-size: 1.25em; }

.markdown-body p { margin-bottom: 16px; }

.markdown-body code {
  background: #f3f4f6;
  padding: 0 6px;
  border-radius: 4px;
  font-family: 'SF Mono', Monaco, Consolas, 'Courier New', monospace;
  font-size: 0.9em;
  color: #be185d;
}

.markdown-body pre {
  background: #2b2b2b;
  padding: 16px 20px;
  border-radius: 8px;
  overflow-x: auto;
  position: relative;
  margin: 16px 0;
}

.markdown-body pre code {
  background: none;
  padding: 0;
  color: #a9b7c6;
  font-size: 13px;
}

.markdown-body img {
  max-width: none;
  border-radius: 8px;
  margin: 16px 0;
}

.markdown-body a {
  color: #2563eb;
  text-decoration: none;
}

.markdown-body a:hover {
  text-decoration: underline;
}

.markdown-body blockquote {
  border-left: 4px solid var(--primary-500);
  padding: 12px 20px;
  margin: 16px 0;
  background: #eff6ff;
  color: #1d4ed8;
  border-radius: 0 8px 8px 0;
}

.markdown-body table {
  border-collapse: separate;
  border-spacing: 0;
  width: auto;
  margin: 16px 0;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  border: 1px solid var(--neutral-200);
}

.markdown-body th, .markdown-body td {
  padding: 10px 16px;
  text-align: left;
  border-bottom: 1px solid var(--neutral-200);
  border-right: 1px solid var(--neutral-200);
}

.markdown-body th:last-child,
.markdown-body td:last-child {
  border-right: none;
}

.markdown-body tr:last-child td {
  border-bottom: none;
}

.markdown-body th {
  background: var(--neutral-200);
  font-weight: 600;
  font-size: 13px;
  color: var(--neutral-600);
}

.markdown-body tbody tr:nth-child(odd) td {
  background: #fff;
}

.markdown-body tbody tr:nth-child(even) td {
  background: var(--neutral-50);
}
.markdown-body ul, .markdown-body ol {
  margin: 16px 0;
  padding-left: 24px;
}

.markdown-body li {
  margin: 6px 0;
}

/* 编辑模式 */
.editor-container {
  flex: 1;
  display: flex;
  overflow: hidden;
}

.editor-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--neutral-200);
  overflow: hidden;
}

.preview-pane {
  flex: 1;
  overflow: auto;
}

/* CodeMirror 编辑器样式 */
.CodeMirror {
  flex: 1;
  height: 100% !important;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  font-size: 15px;
  line-height: 1.75;
}

.CodeMirror-gutters {
  background: var(--neutral-50);
  border-right: 1px solid var(--neutral-200);
}

.CodeMirror-linenumber {
  color: var(--neutral-400);
  padding: 0 8px;
}

.CodeMirror-lines {
  padding: 16px 0;
}

.CodeMirror pre.CodeMirror-line {
  padding: 0 20px;
}

/* 右键菜单 */
.context-menu {
  position: fixed;
  background: var(--neutral-800);
  border: 1px solid var(--neutral-700);
  border-radius: 8px;
  padding: 4px 0;
  min-width: 180px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  z-index: 1000;
}

.context-menu.hidden {
  display: none;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  cursor: pointer;
  font-size: 14px;
  color: var(--neutral-300);
  transition: background 0.1s;
}

.menu-item:hover {
  background: var(--neutral-700);
  color: #fff;
}

.menu-item svg {
  width: 15px;
  height: 15px;
  color: var(--neutral-500);
}

.menu-item.danger {
  color: #f87171;
}

.menu-item.danger svg {
  color: #f87171;
}

.menu-separator {
  height: 1px;
  background: var(--neutral-700);
  margin: 4px 0;
}

/* 历史面板 */
.history-panel {
  position: fixed;
  right: 0;
  top: 0;
  bottom: 0;
  width: 320px;
  background: #fff;
  border-left: 1px solid var(--neutral-200);
  z-index: 100;
  display: flex;
  flex-direction: column;
  box-shadow: -4px 0 12px rgba(0,0,0,0.05);
}

.history-panel.hidden {
  display: none;
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid var(--neutral-200);
}

.history-header h3 {
  font-size: 14px;
  font-weight: 600;
}

.history-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: none;
  border: none;
  border-radius: 6px;
  color: var(--neutral-500);
  cursor: pointer;
}

.history-close:hover {
  background: var(--neutral-100);
  color: var(--neutral-900);
}

.history-list {
  flex: 1;
  overflow: auto;
  padding: 8px;
}

.history-item {
  padding: 12px;
  border-radius: 6px;
  cursor: pointer;
  margin-bottom: 4px;
  font-size: 13px;
  color: var(--neutral-600);
}

.history-item:hover {
  background: var(--neutral-100);
}

/* 文件预览 */
.file-preview {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.pdf-container, .office-preview {
  flex: 1;
  overflow: auto;
  padding: 24px;
  background: var(--neutral-50);
}

.pdf-container canvas {
  display: block;
  margin: 0 auto 24px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.1);
  border-radius: 4px;
}

.excel-table {
  border-collapse: collapse;
  font-size: 13px;
  background: #fff;
}

.excel-table th, .excel-table td {
  border: 1px solid var(--neutral-200);
  padding: 4px 8px;
  text-align: left;
}

.excel-table th {
  background: var(--neutral-50);
  font-weight: 600;
}

/* 滚动条 */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--neutral-300);
  border-radius: 3px;
}

.sidebar ::-webkit-scrollbar-thumb {
  background: var(--neutral-700);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--neutral-400);
}

.sidebar ::-webkit-scrollbar-thumb:hover {
  background: var(--neutral-600);
}

/* 空状态 */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--neutral-400);
  padding: 40px;
  text-align: center;
}

.empty-state svg {
  width: 48px;
  height: 48px;
  margin-bottom: 16px;
  color: var(--neutral-300);
}

.empty-state p {
  font-size: 14px;
}

/* ==================== 图片查看器 ==================== */
.image-viewer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.9);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.image-viewer-close {
  position: absolute;
  top: 16px;
  right: 16px;
  padding: 8px;
  background: rgba(255,255,255,0.1);
  border: none;
  border-radius: 50%;
  color: #fff;
  cursor: pointer;
  transition: background 0.15s;
}

.image-viewer-close:hover {
  background: rgba(255,255,255,0.2);
}

.image-viewer-info {
  position: absolute;
  top: 16px;
  left: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: rgba(255,255,255,0.7);
  font-size: 13px;
}

.image-viewer-hint {
  color: rgba(255,255,255,0.5);
  margin-left: 8px;
}

.image-viewer-img {
  max-width: none;
  cursor: grab;
  user-select: none;
  transition: transform 0.1s;
}

/* 可点击的图片 */
.markdown-body img.clickable-image {
  cursor: pointer;
  transition: opacity 0.15s;
}

.markdown-body img.clickable-image:hover {
  opacity: 0.9;
}

/* 编辑器中选中的图片 */
.preview-pane img.selected-image {
  outline: 2px solid var(--primary-500);
  outline-offset: 2px;
}

/* 图片尺寸调整工具栏 */
.image-resize-toolbar {
  position: absolute;
  background: var(--neutral-800);
  border: 1px solid var(--neutral-700);
  border-radius: 8px;
  padding: 4px 8px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  z-index: 100;
}

.image-resize-toolbar label {
  color: var(--neutral-400);
  font-size: 12px;
}

.image-resize-toolbar input[type="number"] {
  width: 60px;
  padding: 4px 8px;
  background: var(--neutral-900);
  border: 1px solid var(--neutral-700);
  border-radius: 4px;
  color: #fff;
  font-size: 13px;
}

.image-resize-toolbar input[type="number"]:focus {
  outline: none;
  border-color: var(--primary-500);
}

.image-resize-toolbar button {
  padding: 4px 12px;
  background: var(--primary-500);
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
}

.image-resize-toolbar button:hover {
  background: var(--primary-600);
}

.image-resize-toolbar .preset-btn {
  padding: 4px 8px;
  background: var(--neutral-700);
  color: var(--neutral-300);
}

.image-resize-toolbar .preset-btn:hover {
  background: var(--neutral-600);
}

/* ==================== 编辑器工具栏 ==================== */
.editor-toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  background: var(--neutral-50);
  border-bottom: 1px solid var(--neutral-200);
  flex-wrap: wrap;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 2px;
}

.toolbar-divider {
  width: 1px;
  height: 24px;
  background: var(--neutral-200);
  margin: 0 8px;
}

.toolbar-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  background: none;
  border: none;
  border-radius: 6px;
  color: var(--neutral-600);
  cursor: pointer;
  transition: all 0.15s;
}

.toolbar-btn:hover {
  background: var(--neutral-200);
  color: var(--neutral-900);
}

.toolbar-btn:active {
  background: var(--neutral-300);
}

.toolbar-btn svg {
  width: 18px;
  height: 18px;
}

.toolbar-btn.active {
  background: var(--primary-100);
  color: var(--primary-600);
}

/* 下拉菜单式按钮 */
.toolbar-dropdown {
  position: relative;
}

.toolbar-dropdown-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 8px;
  height: 32px;
  background: none;
  border: none;
  border-radius: 6px;
  color: var(--neutral-600);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}

.toolbar-dropdown-btn:hover {
  background: var(--neutral-200);
  color: var(--neutral-900);
}

.toolbar-dropdown-btn svg {
  width: 14px;
  height: 14px;
}

.toolbar-dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 4px;
  background: #fff;
  border: 1px solid var(--neutral-200);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  min-width: 120px;
  z-index: 100;
  display: none;
}

.toolbar-dropdown-menu.show {
  display: block;
}

.toolbar-dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  font-size: 14px;
  color: var(--neutral-700);
  cursor: pointer;
  transition: background 0.1s;
}

.toolbar-dropdown-item:first-child {
  border-radius: 7px 7px 0 0;
}

.toolbar-dropdown-item:last-child {
  border-radius: 0 0 7px 7px;
}

.toolbar-dropdown-item:hover {
  background: var(--neutral-100);
}

.toolbar-dropdown-item span {
  font-weight: 600;
}

.toolbar-dropdown-item .h1 { font-size: 18px; }
.toolbar-dropdown-item .h2 { font-size: 16px; }
.toolbar-dropdown-item .h3 { font-size: 14px; }

/* CodeMirror 字体强制覆盖 */
.CodeMirror,
.CodeMirror pre,
.CodeMirror pre.CodeMirror-line,
.CodeMirror pre.CodeMirror-line-like,
.CodeMirror-code,
.CodeMirror-line,
.CodeMirror span {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'PingFang SC', 'Microsoft YaHei', 'Hiragino Sans GB', sans-serif !important;
  font-size: 15px !important;
  line-height: 1.75 !important;
}

.CodeMirror-cursor {
  border-left-width: 2px !important;
}

/* 代码块匹配高亮 */
.cm-matchingblock {
  background: rgba(59, 130, 246, 0.15) !important;
  border-bottom: 2px solid var(--primary-500) !important;
}

.cm-matchingblock-current {
  background: rgba(59, 130, 246, 0.25) !important;
}

/* 括号匹配高亮 */
.CodeMirror-matchingbracket {
  color: var(--primary-600) !important;
  font-weight: 600 !important;
  background: rgba(59, 130, 246, 0.15) !important;
  border-bottom: 2px solid var(--primary-500) !important;
}

/* 代码块匹配高亮 */
.cm-matchhighlight {
  background: rgba(59, 130, 246, 0.15) !important;
}

.cm-matching-fence {
  background: rgba(59, 130, 246, 0.2) !important;
  border-radius: 2px;
  outline: 1px solid rgba(59, 130, 246, 0.4);
}

.CodeMirror-matchingbracket {
  color: #2563eb !important;
  font-weight: 600;
  background: rgba(59, 130, 246, 0.15);
  border-radius: 2px;
}

.CodeMirror-nonmatchingbracket {
  color: #dc2626 !important;
}

/* 代码块```匹配高亮 - 修正类名 */
.cm-matchingblock {
  background: rgba(59, 130, 246, 0.12) !important;
  display: inline-block;
  width: 100%;
}

.cm-matchingblock-current {
  background: rgba(59, 130, 246, 0.2) !important;
}

/* 确保整行高亮 */
.CodeMirror-line .cm-matchingblock {
  padding: 2px 0;
}

/* 代码块匹配 - 行高亮 */
.cm-line-highlight-current {
  background: rgba(59, 130, 246, 0.18) !important;
}

.cm-line-highlight-match {
  background: rgba(59, 130, 246, 0.12) !important;
}

/* 配对符号高亮 */
.cm-matching-pair {
  background: rgba(59, 130, 246, 0.25) !important;
  border-radius: 2px;
  padding: 1px 0;
}

/* 预览区内容 */
#preview-body {
  padding: 24px 32px;
  min-height: 100%;
}

/* ==================== 导入弹窗 ==================== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal.hidden {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
}

.modal-content {
  position: relative;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

.import-modal-content {
  width: 480px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--neutral-200);
}

.modal-header h3 {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
}

.modal-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: none;
  border: none;
  border-radius: 6px;
  color: var(--neutral-500);
  cursor: pointer;
}

.modal-close:hover {
  background: var(--neutral-100);
  color: var(--neutral-900);
}

.modal-close svg {
  width: 18px;
  height: 18px;
}

.modal-body {
  flex: 1;
  overflow: auto;
  padding: 0;
  max-height: 400px;
}

.modal-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--neutral-200);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.import-target {
  display: flex;
  align-items: center;
  gap: 8px;
}

.import-target label {
  font-size: 13px;
  color: var(--neutral-600);
}

.import-target select {
  flex: 1;
  padding: 6px 10px;
  border: 1px solid var(--neutral-200);
  border-radius: 6px;
  font-size: 13px;
  background: #fff;
}

.import-stats {
  font-size: 13px;
  color: var(--neutral-500);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* 导入文件树 */
.import-tree {
  padding: 8px;
}

.import-tree .tree-item {
  margin: 1px 4px;
}

.import-tree .tree-item.unsupported {
  color: #ef4444;
  opacity: 0.7;
}

.import-tree .tree-item.unsupported .icon {
  color: #ef4444;
}

.import-tree .tree-item.excluded {
  opacity: 0.4;
  text-decoration: line-through;
}

/* 加载状态 */
.import-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--neutral-500);
}

.import-loading .spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--neutral-200);
  border-top-color: var(--primary-500);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 12px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* 导入结果 */
.import-result {
  padding: 20px;
}

.import-result h4 {
  margin: 0 0 12px;
  font-size: 14px;
}

.import-result ul {
  margin: 0;
  padding-left: 20px;
  font-size: 13px;
}

.import-result .success {
  color: #22c55e;
}

.import-result .failed {
  color: #ef4444;
}

/* 上传进度条 */
.upload-progress {
  margin-top: 12px;
}

.progress-bar {
  height: 6px;
  background: var(--neutral-200);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--primary-500);
  border-radius: 3px;
  transition: width 0.1s;
  width: 0%;
}

.progress-text {
  font-size: 12px;
  color: var(--neutral-500);
  margin-top: 6px;
  text-align: center;
}

/* ============== 右侧面板 & 顶部工具栏 ============== */
.right-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100%;
}

.top-bar {
  height: 40px;
  min-height: 40px;
  background: #fff;
  border-bottom: 1px solid var(--neutral-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  flex-shrink: 0;
}

.top-bar-left {
  flex: 1;
}

.top-bar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.top-bar-btn {
  padding: 6px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--neutral-500);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.top-bar-btn:hover {
  background: var(--neutral-100);
  color: var(--neutral-700);
}

.top-bar-divider {
  width: 1px;
  height: 20px;
  background: var(--neutral-200);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 8px;
  font-size: 13px;
  color: var(--neutral-600);
}

/* App Switcher */
.app-switcher {
  position: relative;
}

.app-switcher-menu {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 4px;
  width: 180px;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  border: 1px solid var(--neutral-200);
  padding: 4px 0;
  z-index: 200;
}

.app-switcher-menu.hidden {
  display: none;
}

.app-menu-title {
  padding: 8px 12px;
  font-size: 11px;
  color: var(--neutral-400);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.app-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--neutral-700);
  text-decoration: none;
  transition: background 0.15s;
}

.app-menu-item:hover {
  background: var(--neutral-50);
}

.app-menu-item.active {
  background: rgba(6, 182, 212, 0.1);
  color: var(--primary);
}

.app-menu-item .check-icon {
  margin-left: 0;
}

/* 调整 main-content 填满剩余空间 */
.right-panel .main-content {
  flex: 1;
  overflow: hidden;
}


/* ==================== 图片编辑器 ==================== */
.img-editor-container {
  position: relative;
  display: inline-block;
  margin: 16px 0;
}

.img-editor-container img {
  display: block;
  border-radius: 8px;
  outline: 2px solid var(--primary-500);
  outline-offset: 2px;
}

/* 工具栏 */
.img-editor-toolbar {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: -44px;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 8px;
  background: var(--neutral-800);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  z-index: 100;
}

.img-tool-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  background: none;
  border: none;
  border-radius: 6px;
  color: var(--neutral-400);
  cursor: pointer;
  transition: all 0.15s;
}

.img-tool-btn:hover {
  background: var(--neutral-700);
  color: #fff;
}

.img-tool-btn.active {
  background: var(--primary-600);
  color: #fff;
}

.img-tool-btn svg {
  width: 18px;
  height: 18px;
}

.img-tool-divider {
  width: 1px;
  height: 20px;
  background: var(--neutral-600);
  margin: 0 4px;
}

.img-tool-save {
  color: #22c55e;
}

.img-tool-save:hover {
  background: #22c55e;
  color: #fff;
}

/* 缩放手柄 */
.img-handle {
  position: absolute;
  width: 10px;
  height: 10px;
  background: #fff;
  border: 2px solid var(--primary-500);
  border-radius: 2px;
  z-index: 10;
}

.img-handle-nw { top: -5px; left: -5px; }
.img-handle-n { top: -5px; left: 50%; transform: translateX(-50%); }
.img-handle-ne { top: -5px; right: -5px; }
.img-handle-w { top: 50%; left: -5px; transform: translateY(-50%); }
.img-handle-e { top: 50%; right: -5px; transform: translateY(-50%); }
.img-handle-sw { bottom: -5px; left: -5px; }
.img-handle-s { bottom: -5px; left: 50%; transform: translateX(-50%); }
.img-handle-se { bottom: -5px; right: -5px; }

/* 裁剪遮罩 */
.img-crop-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
}

.crop-mask {
  position: absolute;
  background: rgba(0, 0, 0, 0.5);
}

.crop-mask-top {
  top: 0;
  left: 0;
  right: 0;
}

.crop-mask-bottom {
  bottom: 0;
  left: 0;
  right: 0;
}

.crop-mask-left {
  left: 0;
  position: absolute;
}

.crop-mask-right {
  right: 0;
  position: absolute;
}

/* 裁剪手柄 */
.img-crop-handle {
  position: absolute;
  background: var(--primary-500);
  z-index: 10;
}

.img-crop-handle-top {
  height: 4px;
  cursor: ns-resize;
  transform: translateY(-50%);
}

.img-crop-handle-bottom {
  height: 4px;
  cursor: ns-resize;
  transform: translateY(50%);
}

.img-crop-handle-left {
  width: 4px;
  cursor: ew-resize;
  transform: translateX(-50%);
}

.img-crop-handle-right {
  width: 4px;
  cursor: ew-resize;
  transform: translateX(50%);
}

.img-crop-handle:hover {
  background: var(--primary-400);
}

/* 可编辑图片 hover 效果 */
.editable-img {
  cursor: pointer;
  transition: opacity 0.15s;
}

.editable-img:hover {
  opacity: 0.9;
}

/* ==================== 自定义组件样式 ==================== */

/* Callout 提示框 */
.callout {
  display: flex;
  gap: 12px;
  padding: 16px;
  margin: 16px 0;
  border-radius: 8px;
  border-left: 4px solid;
}

.callout-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
}

.callout-icon svg {
  width: 20px;
  height: 20px;
}

.callout-content {
  flex: 1;
  min-width: 0;
}

.callout-title {
  font-weight: 600;
  margin-bottom: 4px;
}

.callout-body p:last-child {
  margin-bottom: 0;
}

.callout-info {
  background: #eff6ff;
  border-color: #3b82f6;
  color: #1e40af;
}
.callout-info .callout-icon { color: #3b82f6; }

.callout-tip {
  background: #f0fdf4;
  border-color: #22c55e;
  color: #166534;
}
.callout-tip .callout-icon { color: #22c55e; }

.callout-warning {
  background: #fffbeb;
  border-color: #f59e0b;
  color: #92400e;
}
.callout-warning .callout-icon { color: #f59e0b; }

.callout-danger {
  background: #fef2f2;
  border-color: #ef4444;
  color: #991b1b;
}
.callout-danger .callout-icon { color: #ef4444; }

/* 折叠块 */
.custom-details {
  margin: 16px 0;
  border: 1px solid var(--neutral-200);
  border-radius: 8px;
  overflow: hidden;
}

.custom-details summary {
  padding: 12px 16px;
  background: var(--neutral-50);
  cursor: pointer;
  font-weight: 500;
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

.custom-details summary::-webkit-details-marker {
  display: none;
}

.custom-details summary::before {
  content: '';
  width: 0;
  height: 0;
  border-left: 6px solid var(--neutral-500);
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  transition: transform 0.2s;
}

.custom-details[open] summary::before {
  transform: rotate(90deg);
}

.custom-details summary:hover {
  background: var(--neutral-100);
}

.details-content {
  padding: 16px;
  border-top: 1px solid var(--neutral-200);
}

.details-content p:last-child {
  margin-bottom: 0;
}

/* 标签页 */
.custom-tabs {
  margin: 16px 0;
  border: 1px solid var(--neutral-200);
  border-radius: 8px;
  overflow: hidden;
}

.tabs-header {
  display: flex;
  background: var(--neutral-50);
  border-bottom: 1px solid var(--neutral-200);
  overflow-x: auto;
}

.tab-btn {
  padding: 10px 20px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  font-size: 14px;
  font-weight: 500;
  color: var(--neutral-500);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}

.tab-btn:hover {
  color: var(--neutral-700);
  background: var(--neutral-100);
}

.tab-btn.active {
  color: var(--primary-600);
  border-bottom-color: var(--primary-500);
  background: #fff;
}

.tabs-body {
  padding: 16px;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.tab-panel p:last-child {
  margin-bottom: 0;
}

/* 快捷键 */
.kbd-group {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

kbd {
  display: inline-block;
  padding: 3px 8px;
  font-family: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, monospace;
  font-size: 12px;
  line-height: 1.4;
  color: var(--neutral-700);
  background: linear-gradient(180deg, #fff 0%, #f5f5f5 100%);
  border: 1px solid var(--neutral-300);
  border-radius: 5px;
  box-shadow: 0 2px 0 var(--neutral-200), inset 0 -1px 0 var(--neutral-200);
}

.kbd-plus {
  font-size: 11px;
  color: var(--neutral-400);
}

/* 编辑器工具栏下拉菜单 */
.editor-dropdown-menu {
  background: #fff;
  border: 1px solid var(--neutral-200);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  min-width: 160px;
  z-index: 1000;
  padding: 4px 0;
}

.editor-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  font-size: 14px;
  color: var(--neutral-700);
  cursor: pointer;
  transition: background 0.1s;
}

.editor-dropdown-item:hover {
  background: var(--neutral-100);
}

.callout-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.callout-dot.info { background: #3b82f6; }
.callout-dot.tip { background: #22c55e; }
.callout-dot.warning { background: #f59e0b; }
.callout-dot.danger { background: #ef4444; }

/* 编辑器布局调整 */
.editor-pane {
  display: flex;
  flex-direction: column;
}

.editor-pane .editor-toolbar {
  flex-shrink: 0;
}

.editor-pane .CodeMirror {
  flex: 1;
}

/* 拖拽排序指示器 */
.tree-item.dragging {
  opacity: 0.5;
}

.tree-item.drop-before {
  box-shadow: inset 0 2px 0 var(--primary-500);
}

.tree-item.drop-after {
  box-shadow: inset 0 -2px 0 var(--primary-500);
}

.tree-item.drop-inside {
  background: var(--primary-50);
  box-shadow: inset 0 0 0 2px var(--primary-500);
}



  color: #6a8759;
  background: rgba(106, 135, 89, 0.1);
}

/* ==================== 代码高亮 - JetBrains Darcula 官方配色 ==================== */
.markdown-body pre {
  position: relative;
  background: #2B2B2B;
}

.markdown-body pre code {
  font-family: 'JetBrains Mono', 'Fira Code', 'SF Mono', Monaco, Consolas, monospace;
  line-height: 1.5;
  color: #A9B7C6;
}

/* 语言标签 */
.markdown-body pre[data-lang]::before {
  content: attr(data-lang);
  position: absolute;
  top: 0;
  right: 0;
  padding: 4px 10px;
  font-size: 11px;
  color: #606366;
  background: rgba(255,255,255,0.03);
  border-radius: 0 8px 0 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Darcula 官方配色 */
.hljs {
  background: #2B2B2B;
  color: #A9B7C6;
}

/* 关键字 - 橙色 */
.hljs-keyword,
.hljs-selector-tag,
.hljs-built_in {
  color: #CC7832;
}

/* 字符串 - 绿色 */
.hljs-string,
.hljs-attr {
  color: #6A8759;
}

/* 数字 - 蓝色 */
.hljs-number,
.hljs-literal {
  color: #6897BB;
}

/* 注释 - 灰色斜体 */
.hljs-comment,
.hljs-quote {
  color: #808080;
  font-style: italic;
}

/* 函数名 - 黄色 */
.hljs-function,
.hljs-title,
.hljs-title.function_ {
  color: #FFC66D;
}

/* 类型/类名 - 浅蓝 */
.hljs-type,
.hljs-class .hljs-title,
.hljs-title.class_ {
  color: #A9B7C6;
}

/* 变量/参数 - 紫色 */
.hljs-variable,
.hljs-template-variable,
.hljs-params {
  color: #A9B7C6;
}

/* 属性名 */
.hljs-attribute,
.hljs-property {
  color: #9876AA;
}

/* 标签 - 黄色 */
.hljs-tag {
  color: #E8BF6A;
}

.hljs-name {
  color: #E8BF6A;
}

/* 元信息/注解 - 黄绿色 */
.hljs-meta,
.hljs-meta .hljs-keyword {
  color: #BBB529;
}

/* 正则表达式 */
.hljs-regexp {
  color: #6A8759;
}

/* 符号 */
.hljs-symbol,
.hljs-bullet {
  color: #6897BB;
}

/* 内置 - 紫色 */
.hljs-built_in {
  color: #8888C6;
}

/* 选择器 - 黄色 */
.hljs-selector-id,
.hljs-selector-class {
  color: #FFC66D;
}

/* 删除/新增 */
.hljs-deletion {
  color: #CC7832;
  background: rgba(204, 120, 50, 0.1);
}

.hljs-addition {
  color: #6A8759;
  background: rgba(106, 135, 89, 0.1);
}

/* 强调 */
.hljs-emphasis {
  font-style: italic;
}

.hljs-strong {
  font-weight: bold;
}

/* ==================== 图片预览器 ==================== */
.image-viewer-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.9);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: default;
}

.image-viewer-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  border: none;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.image-viewer-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

.image-viewer-close svg {
  width: 24px;
  height: 24px;
  color: #fff;
}

.image-viewer-info {
  position: absolute;
  top: 16px;
  left: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: rgba(255, 255, 255, 0.7);
  font-size: 14px;
}

.image-viewer-info svg {
  color: rgba(255, 255, 255, 0.7);
}

.image-viewer-scale {
  font-weight: 500;
  color: #fff;
}

.image-viewer-hint {
  color: rgba(255, 255, 255, 0.5);
  margin-left: 8px;
}

.image-viewer-img {
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
  cursor: grab;
  user-select: none;
}

.image-viewer-img:active {
  cursor: grabbing;
}

/* 阅读模式图片可点击 */
.doc-body .markdown-body img {
  cursor: zoom-in;
}

/* ==================== 摘要弹窗 ==================== */
.summary-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.summary-modal {
  background: #fff;
  border-radius: 12px;
  width: 500px;
  max-width: 90vw;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
}

.summary-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--neutral-200);
}

.summary-modal-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--neutral-800);
}

.summary-modal-close {
  width: 32px;
  height: 32px;
  border: none;
  background: none;
  cursor: pointer;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--neutral-500);
  transition: all 0.15s;
}

.summary-modal-close:hover {
  background: var(--neutral-100);
  color: var(--neutral-700);
}

.summary-modal-close svg {
  width: 18px;
  height: 18px;
}

.summary-modal-body {
  padding: 20px;
}

.summary-text {
  margin: 0;
  font-size: 14px;
  line-height: 1.6;
  color: var(--neutral-700);
}

.summary-date {
  margin: 12px 0 0 0;
  font-size: 12px;
  color: var(--neutral-400);
}

.summary-empty {
  margin: 0;
  font-size: 14px;
  color: var(--neutral-400);
  text-align: center;
  padding: 20px 0;
}

/* ==================== Wiki 链接卡片 ==================== */
.wiki-link-card {
  display: flex;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.15s ease;
}

.wiki-link-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.wiki-link-body {
  display: flex;
  align-items: center;
  gap: 8px;
}

.wiki-link-body svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.6;
}

.wiki-link-name {
  color: var(--neutral-700);
  font-weight: 500;
}

.wiki-link-card:hover .wiki-link-name {
  color: var(--primary-600);
}


/* ==================== ASCII 图表卡片 ==================== */
.ascii-diagram {
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  border: 1px solid var(--neutral-200);
  border-radius: 12px;
  padding: 24px 32px;
  margin: 20px 0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  overflow-x: auto;
  display: inline-block;
  max-width: 100%;
}

.markdown-body .ascii-diagram {
  display: block;
  width: fit-content;
  margin-left: 0;
  margin-right: 0;
}

.ascii-diagram code {
  font-family: "JetBrains Mono", "Fira Code", "SF Mono", "Monaco", "Consolas", monospace;
  font-size: 13px;
  line-height: 1.6;
  color: var(--neutral-600);
  background: none;
  white-space: pre;
  display: block;
  text-align: left;
}

.ascii-diagram:hover {
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
  border-color: var(--neutral-300);
}

/* ==================== HTML 嵌入块 ==================== */
.html-embed {
  margin: 16px 0;
  border: 1px solid var(--neutral-200);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.html-embed-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--neutral-100);
  border-bottom: 1px solid var(--neutral-200);
}

.html-embed-header-mini {
  justify-content: flex-end;
  padding: 4px 8px;
  background: transparent;
  border-bottom: none;
  position: absolute;
  top: 0;
  right: 0;
  z-index: 1;
}

.html-embed-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--neutral-700);
}

.html-embed-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  background: none;
  border: none;
  border-radius: 4px;
  color: var(--neutral-500);
  cursor: pointer;
  transition: all 0.15s;
}

.html-embed-toggle:hover {
  background: var(--neutral-200);
  color: var(--neutral-700);
}

.html-embed-code {
  display: none;
  max-height: 300px;
  overflow: auto;
  background: var(--neutral-900);
  border-bottom: 1px solid var(--neutral-200);
}

.html-embed-code pre {
  margin: 0;
  padding: 12px;
  background: transparent;
}

.html-embed-code code {
  font-size: 12px;
  line-height: 1.5;
  color: var(--neutral-300);
}

.html-embed.show-code .html-embed-code {
  display: block;
}

.html-embed-frame {
  display: block;
  width: 100%;
  border: none;
  background: #fff;
}

/* 无标题时的相对定位 */
.html-embed:not(:has(.html-embed-title)) {
  position: relative;
}

.html-embed:not(:has(.html-embed-title)) .html-embed-header-mini {
  opacity: 0;
  transition: opacity 0.15s;
}

.html-embed:not(:has(.html-embed-title)):hover .html-embed-header-mini {
  opacity: 1;
}

/* ==================== Sigil 预览 ==================== */
.sigil-icon svg {
  color: #f59e0b !important;
}

.doc-content-area {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.sigil-preview {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--neutral-200);
  border-radius: 8px;
  margin-bottom: 16px;
  background: #fff;
  overflow: hidden;
}

.sigil-preview.fullscreen {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  margin: 0;
  border-radius: 0;
  border: none;
}

.sigil-preview.fullscreen .sigil-body {
  height: calc(100vh - 48px) !important;
}

.sigil-preview.fullscreen .sigil-resizer {
  display: none;
}

.sigil-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: linear-gradient(135deg, #1e1b4b 0%, #312e81 100%);
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sigil-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  color: #fbbf24;
}

.sigil-title svg {
  color: #fbbf24;
}

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

.sigil-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  background: rgba(255,255,255,0.1);
  border: none;
  border-radius: 4px;
  color: rgba(255,255,255,0.8);
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
}

.sigil-btn:hover {
  background: rgba(255,255,255,0.2);
  color: #fff;
}

.sigil-btn svg {
  width: 16px;
  height: 16px;
}

.sigil-body {
  height: 400px;
  overflow: hidden;
}

.sigil-body iframe {
  width: 100%;
  height: 100%;
  border: none;
}

.sigil-resizer {
  height: 6px;
  background: var(--neutral-100);
  cursor: ns-resize;
  transition: background 0.15s;
}

.sigil-resizer:hover {
  background: var(--neutral-200);
}

/* 让 markdown-body 在有 sigil 时可滚动 */
.doc-content-area .markdown-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

/* ==================== Sigil 视图 ==================== */
.sigil-view,
.sigil-editor {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--neutral-100);
}

.sigil-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--neutral-900);
  border-bottom: 1px solid var(--neutral-800);
}

.sigil-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sigil-info svg {
  color: #f59e0b;
}

.sigil-name {
  font-size: 15px;
  font-weight: 600;
  color: #fff;
}

.sigil-mode-badge {
  font-size: 11px;
  padding: 3px 8px;
  background: var(--primary-500);
  color: #fff;
  border-radius: 4px;
}

.sigil-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sigil-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--neutral-800);
  border: none;
  border-radius: 6px;
  color: var(--neutral-300);
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s;
}

.sigil-btn:hover {
  background: var(--neutral-700);
  color: #fff;
}

.sigil-btn svg {
  width: 16px;
  height: 16px;
}

.sigil-btn-primary {
  background: var(--primary-500);
  color: #fff;
}

.sigil-btn-primary:hover {
  background: var(--primary-600);
}

/* 预览模式 iframe */
.sigil-frame-container {
  flex: 1;
  position: relative;
  overflow: hidden;
}

.sigil-frame-container iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
}

/* 编辑模式布局 */
.sigil-editor-body {
  flex: 1;
  display: flex;
  overflow: hidden;
}

.sigil-file-list {
  width: 200px;
  background: var(--neutral-900);
  border-right: 1px solid var(--neutral-800);
  display: flex;
  flex-direction: column;
}

.sigil-file-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--neutral-800);
  color: var(--neutral-400);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.sigil-file-add {
  width: 20px;
  height: 20px;
  background: var(--neutral-800);
  border: none;
  border-radius: 4px;
  color: var(--neutral-400);
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sigil-file-add:hover {
  background: var(--neutral-700);
  color: #fff;
}

.sigil-files {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.sigil-file-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
  color: var(--neutral-300);
  font-size: 13px;
  transition: background 0.15s;
}

.sigil-file-item:hover {
  background: var(--neutral-800);
}

.sigil-file-item.active {
  background: var(--neutral-800);
  color: #fff;
  border-left: 2px solid var(--primary-500);
}

.sigil-file-icon {
  font-size: 14px;
}

.sigil-code-area {
  flex: 1;
  position: relative;
  overflow: hidden;
}

#sigil-monaco {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

#sigil-monaco textarea {
  width: 100%;
  height: 100%;
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: 13px;
  padding: 12px;
  border: none;
  resize: none;
  background: #1e1e1e;
  color: #d4d4d4;
  outline: none;
}

/* Tree sigil 图标 */
.sigil-icon svg {
  color: #f59e0b !important;
}

/* ==================== Sigil 简化样式 ==================== */
.sigil-frame-wrapper {
  flex: 1;
  position: relative;
}

.sigil-frame-wrapper iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
  background: #fff;
}

/* 编辑模式 */
.sigil-editor-body {
  display: flex !important;
  flex-direction: row !important;
}

.sigil-file-panel {
  width: 180px;
  background: var(--neutral-800);
  border-right: 1px solid var(--neutral-700);
  display: flex;
  flex-direction: column;
}

.sigil-file-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  border-bottom: 1px solid var(--neutral-700);
  font-size: 11px;
  color: var(--neutral-400);
  text-transform: uppercase;
}

.sigil-file-header button {
  width: 20px;
  height: 20px;
  background: var(--neutral-700);
  border: none;
  border-radius: 4px;
  color: var(--neutral-300);
  cursor: pointer;
}

.sigil-file-header button:hover {
  background: var(--neutral-600);
  color: #fff;
}

.sigil-file-list {
  flex: 1;
  overflow-y: auto;
}

.sigil-file-item {
  padding: 8px 12px;
  font-size: 13px;
  color: var(--neutral-300);
  cursor: pointer;
  border-left: 2px solid transparent;
}

.sigil-file-item:hover {
  background: var(--neutral-700);
}

.sigil-file-item.active {
  background: var(--neutral-700);
  color: #fff;
  border-left-color: var(--primary-500);
}

.sigil-code-panel {
  flex: 1;
  display: flex;
}

.sigil-code-panel textarea {
  flex: 1;
  padding: 12px;
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: 13px;
  line-height: 1.5;
  background: #1e1e1e;
  color: #d4d4d4;
  border: none;
  resize: none;
  outline: none;
}

/* 代码编辑器 */
.code-editor-wrapper {
  flex: 1;
  display: flex;
}

.code-editor-wrapper textarea {
  flex: 1;
  padding: 16px;
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  font-size: 13px;
  line-height: 1.6;
  background: #1e1e1e;
  color: #d4d4d4;
  border: none;
  resize: none;
  outline: none;
  tab-size: 2;
}
