/* === Editor === */

/* ==================== 编辑器工具栏 ==================== */
.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%;
}

/* 编辑器工具栏下拉菜单 */
.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);
}

/* ==================== 编辑器分栏拖拽 ==================== */
.editor-resize-handle {
  width: 4px;
  cursor: col-resize;
  background: var(--neutral-300);
  flex-shrink: 0;
  transition: background 0.2s;
}
.editor-resize-handle:hover { background: var(--primary-500); }

/* ==================== 未保存指示 ==================== */
.dirty-indicator {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #f59e0b;
  margin-left: 6px;
  vertical-align: middle;
}
.auto-save-indicator {
  font-size: 12px;
  color: var(--neutral-500);
  margin-right: 8px;
}

/* 代码编辑器 */
.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;
}

.code-editor-wrapper .CodeMirror {
  height: 100%;
  font-size: 13px;
}
