/* ==========================================================================
   编辑器通用样式 + 各类型编辑器
   ========================================================================== */

/* ---------------------------------------------------------------- 编辑器外壳 */

/*
 * 编辑器外壳：纵向 flex。
 *
 * ★ 这里曾经是 `display: grid; grid-template-rows: auto 1fr`。
 *   grid 会按**文档顺序**依次填格：先出现的子元素拿 auto 行，后出现的拿 1fr 行。
 *   而 base.js 构造函数已先把 this.body 挂进 this.node，各编辑器再挂工具栏时
 *   若用 append（排在 body 之后）就会落到第 2 行 → 工具栏视觉上跑到编辑区下方。
 *   改用 flex 后，工具栏只要带 `flex: 0 0 auto`、编辑区带 `flex: 1` 就永远
 *   各归其位，DOM 顺序不再是陷阱。
 *
 *   （工具栏与编辑区的高度分配：.editor-toolbar 是 flex:0 0 auto，
 *     .editor-body 是 flex:1 + min-height:0，两者都在本文件中定义。）
 */
.editor {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    position: relative;
    background: var(--bg);
}

.editor-body {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
}

/* ---------------------------------------------------------------- 编辑器工具栏 */

.editor-toolbar {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 0 8px;
    height: 38px;
    flex: 0 0 auto;
    border-bottom: 1px solid var(--border);
    background: var(--bg-subtle);
    overflow-x: auto;
    scrollbar-width: none;
}
.editor-toolbar::-webkit-scrollbar { display: none; }

.tb-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 26px;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--fg-muted);
    cursor: pointer;
    flex: 0 0 auto;
    transition: background .12s, color .12s;
    position: relative;
}
.tb-btn:hover { background: var(--bg-hover); color: var(--fg); }
.tb-btn:active { background: var(--bg-active); }
.tb-btn.active { background: var(--accent-soft); color: var(--accent); }
.tb-btn:disabled { opacity: .4; cursor: default; background: transparent; }

.tb-sep {
    width: 1px;
    height: 16px;
    margin: 0 5px;
    background: var(--border);
    flex: 0 0 auto;
}

.tb-spacer { flex: 1 1 auto; min-width: 4px; }

.tb-hint { font-size: 11.5px; color: var(--fg-dim); white-space: nowrap; }

.tb-seg {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--fg-dim);
    flex: 0 0 auto;
}

.seg-group {
    display: inline-flex;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}
.seg-btn {
    border: 0;
    background: var(--bg);
    color: var(--fg-muted);
    font-size: 11.5px;
    padding: 3px 9px;
    cursor: pointer;
    font-family: inherit;
    transition: background .12s, color .12s;
}
.seg-btn + .seg-btn { border-left: 1px solid var(--border); }
.seg-btn:hover { background: var(--bg-hover); color: var(--fg); }
.seg-btn.active { background: var(--accent); color: #fff; }

/* 颜色色块（绘图编辑器） */
.color-swatch {
    width: 28px;
    height: 26px;
    padding: 0;
}
.color-swatch::after {
    content: '';
    position: absolute;
    inset: 5px;
    border-radius: 3px;
    background: var(--sw, transparent);
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .14);
}
.color-swatch.stroke::after {
    background: transparent;
    border: 2.5px solid var(--sw, #000);
    inset: 6px;
}

.color-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 7px;
    margin-bottom: 12px;
}
.color-cell {
    aspect-ratio: 1;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    padding: 0;
    transition: transform .1s, box-shadow .1s;
}
.color-cell:hover { transform: scale(1.09); box-shadow: 0 2px 8px rgba(0, 0, 0, .16); }
.color-custom {
    width: 100%;
    height: 34px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    cursor: pointer;
    padding: 2px;
}

/* 状态区（右对齐） */
.editor-lang,
.editor-stats,
.editor-pos {
    font-size: 11.5px;
    color: var(--fg-dim);
    white-space: nowrap;
    flex: 0 0 auto;
    font-variant-numeric: tabular-nums;
}
.editor-lang {
    padding: 2px 7px;
    border-radius: 4px;
    background: var(--bg-hover);
    color: var(--fg-muted);
    margin-right: 4px;
}
.editor-stats { margin-right: 10px; }
.editor-pos { min-width: 62px; }

/* ---------------------------------------------------------------- 加载 / 错误态 */

.editor-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background: var(--bg);
    z-index: 12;
}
.overlay-text { font-size: 12.5px; color: var(--fg-muted); }

.spinner {
    width: 22px;
    height: 22px;
    border: 2px solid var(--border-strong);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .68s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.editor-error {
    margin: auto;
    padding: 40px 24px;
    max-width: 480px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}
.editor-error .error-icon { color: var(--warn, #ff9500); opacity: .85; }
.editor-error .error-title { font-size: 14px; font-weight: 500; color: var(--fg); }
.editor-error .error-desc { font-size: 12.5px; color: var(--fg-muted); line-height: 1.65; }
.editor-error .error-desc > div + div { margin-top: 4px; }
.error-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 8px;
}

/* 状态点（未保存） */
.editor.dirty .editor-status-text { color: var(--warn, #ff9500); }

/* ==========================================================================
   CodeMirror 6
   ========================================================================== */

.cm-wrap {
    flex: 1 1 auto;
    min-height: 0;
    position: relative;
    overflow: hidden;
}
.cm-wrap .cm-editor {
    height: 100%;
    /*
     * ★ 字号走 CSS 变量，不要写死数值。
     *
     * 踩坑（2026-09-17）：这里原本写死 `font-size: 13.5px`。
     *   该选择器 `.cm-wrap .cm-editor` 特异性是 (0,2,0)，
     *   而 CodeMirror 通过 `EditorView.theme()` 注入的样式形如
     *   `.cm-editor.ͼxxx { font-size: …px }`，特异性只有 (0,1,1) ——
     *   **被这里的规则稳定压制**。
     *   于是「更多 → 字号」和「设置 → 字号」两处改了设置、
     *   compartment 也确实重配置了、DOM 类名也换了，
     *   但最终渲染字号永远是 13.5px → 表现为「字号没反应」。
     *
     * 修法：变量兜底。CSS 只提供初始默认值，
     *   JS 侧改 `--cm-font-size` 即可覆盖（见 code.js 的 applyFontSize()）。
     *   用变量而非删掉这条规则，是为了保留 (0,2,0) 的稳定兜底 ——
     *   万一 theme 扩展加载失败，字号仍是可读的 13.5px。
     */
    font-size: var(--cm-font-size, 13.5px);
}
.cm-wrap .cm-scroller {
    font-family: var(--font-mono);
    line-height: 1.65;
}
.cm-wrap .cm-editor.cm-focused { outline: none; }
.cm-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    font-size: 12.5px;
    color: var(--fg-muted);
}

.cm-fold-marker {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    color: var(--fg-dim);
    cursor: pointer;
    border-radius: 3px;
}
.cm-fold-marker:hover { background: var(--bg-hover); color: var(--fg); }

/* CodeMirror 面板（查找替换） */
.cm-wrap .cm-panels {
    background: var(--bg-subtle);
    border-top: 1px solid var(--border);
    font-family: var(--font-sans);
    font-size: 12.5px;
}
.cm-wrap .cm-panels.cm-panels-top { border-bottom: 1px solid var(--border); border-top: 0; }
.cm-wrap .cm-panel.cm-search { padding: 8px 10px; }
.cm-wrap .cm-panel input,
.cm-wrap .cm-panel button {
    font-family: inherit;
    font-size: 12.5px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    color: var(--fg);
    padding: 3px 7px;
    margin: 0 3px 4px 0;
}
.cm-wrap .cm-panel button { cursor: pointer; }
.cm-wrap .cm-panel button:hover { background: var(--bg-hover); }
.cm-wrap .cm-panel button[name="close"] {
    position: absolute;
    top: 6px;
    right: 8px;
    border: 0;
    background: transparent;
    font-size: 16px;
}
.cm-wrap .cm-searchMatch { background: rgba(255, 204, 0, .35); }
.cm-wrap .cm-searchMatch-selected { background: rgba(255, 149, 0, .5); }

.cm-wrap .cm-tooltip {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    font-family: var(--font-sans);
}
.cm-wrap .cm-tooltip-autocomplete ul li[aria-selected] {
    background: var(--accent);
    color: #fff;
}

/* ==========================================================================
   Markdown 编辑器
   ========================================================================== */

.md-split {
    flex: 1 1 auto;
    min-height: 0;
    display: grid;
    grid-template-columns: 1fr 5px 1fr;
}
.md-split.mode-edit { grid-template-columns: 1fr 0 0; }
.md-split.mode-edit .md-preview,
.md-split.mode-edit .md-splitter { display: none; }
/* mode-preview 下 .md-edit/.md-splitter 是 display:none，不产生 grid item，
   实际只剩 .md-preview 一个 item → 列定义也必须是 1 列，否则它落进 0 宽的首列 */
.md-split.mode-preview { grid-template-columns: 1fr; }
.md-split.mode-preview .md-edit,
.md-split.mode-preview .md-splitter { display: none; }

.md-pane { min-width: 0; overflow: auto; }
.md-edit { overflow: hidden; }
.md-edit .cm-editor { height: 100%; }

.md-splitter {
    background: var(--border);
    cursor: col-resize;
    position: relative;
    transition: background .12s;
}
.md-splitter::after {
    content: '';
    position: absolute;
    inset: 0 -3px;
}
.md-splitter:hover,
.md-splitter.dragging { background: var(--accent); }

.md-preview {
    padding: 22px 26px 60px;
    background: var(--bg);
    border-left: 1px solid var(--border);
}

/* ---------------------------------------------------------------- Markdown 正文 */

.markdown-body {
    font-size: 14px;
    line-height: 1.78;
    color: var(--fg);
    word-wrap: break-word;
}
.markdown-body > *:first-child { margin-top: 0; }
.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
    margin: 1.5em 0 .6em;
    font-weight: 600;
    line-height: 1.35;
}
.markdown-body h1 { font-size: 1.72em; padding-bottom: .3em; border-bottom: 1px solid var(--border); }
.markdown-body h2 { font-size: 1.42em; padding-bottom: .28em; border-bottom: 1px solid var(--border); }
.markdown-body h3 { font-size: 1.2em; }
.markdown-body h4 { font-size: 1.05em; }
.markdown-body h5,
.markdown-body h6 { font-size: .95em; color: var(--fg-muted); }

.markdown-body p { margin: .85em 0; }
.markdown-body ul,
.markdown-body ol { margin: .85em 0; padding-left: 1.7em; }
.markdown-body li { margin: .3em 0; }
.markdown-body li > ul,
.markdown-body li > ol { margin: .25em 0; }

.markdown-body blockquote {
    margin: 1em 0;
    padding: .5em 1.1em;
    border-left: 3px solid var(--accent);
    background: var(--bg-subtle);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    color: var(--fg-muted);
}
.markdown-body blockquote p { margin: .35em 0; }

.markdown-body code {
    font-family: var(--font-mono);
    font-size: .88em;
    padding: .17em .42em;
    border-radius: 4px;
    background: var(--code-bg);
    color: var(--code-fg);
}
.markdown-body pre {
    margin: 1em 0;
    padding: 13px 15px;
    overflow: auto;
    border-radius: var(--radius-md);
    background: var(--code-bg);
    border: 1px solid var(--border);
    line-height: 1.6;
}
.markdown-body pre code {
    padding: 0;
    background: transparent;
    font-size: .86em;
    color: var(--code-fg);
}
.markdown-body .copy-code {
    position: absolute;
    top: 7px;
    right: 7px;
    font-family: var(--font-sans);
    font-size: 11px;
    padding: 2.5px 8px;
    border: 1px solid var(--border);
    border-radius: 5px;
    background: var(--bg-elevated);
    color: var(--fg-muted);
    cursor: pointer;
    opacity: 0;
    transition: opacity .15s;
}
.markdown-body pre:hover .copy-code { opacity: 1; }
.markdown-body .copy-code:hover { color: var(--fg); background: var(--bg-hover); }

.markdown-body a { color: var(--accent); text-decoration: none; }
.markdown-body a:hover { text-decoration: underline; }

.markdown-body img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-sm);
    cursor: zoom-in;
    vertical-align: top;
}

.markdown-body hr {
    margin: 1.8em 0;
    border: 0;
    border-top: 1px solid var(--border);
}

.markdown-body table {
    margin: 1em 0;
    border-collapse: collapse;
    width: 100%;
    font-size: .94em;
    display: block;
    overflow-x: auto;
}
.markdown-body th,
.markdown-body td {
    border: 1px solid var(--border);
    padding: 7px 11px;
    text-align: left;
}
.markdown-body th { background: var(--bg-subtle); font-weight: 600; }
.markdown-body tr:nth-child(even) td { background: var(--bg-subtle); }

.markdown-body input[type="checkbox"] { margin-right: 5px; }

.markdown-body mark {
    background: rgba(255, 204, 0, .38);
    color: inherit;
    padding: 0 2px;
    border-radius: 2px;
}

/* ---- 扩展语法：标签页（::: tabs / ::: tab-item） ---- */
.markdown-body .md-tabs {
    margin: 1em 0;
    border: 1px solid var(--c-border);
    border-radius: var(--r-md);
    overflow: hidden;
}
.markdown-body .md-tab-head {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    padding: 4px;
    background: var(--c-bg-sunken);
    border-bottom: 1px solid var(--c-border);
}
.markdown-body .md-tab-btn {
    padding: 5px 14px;
    font-size: 13px;
    line-height: 1.5;
    border: 0;
    border-radius: var(--r-sm);
    background: transparent;
    color: var(--c-text-2);
    cursor: pointer;
    transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.markdown-body .md-tab-btn:hover { background: var(--c-bg-hover); color: var(--c-text); }
.markdown-body .md-tab-btn.active { background: var(--c-bg-elev); color: var(--c-text); font-weight: 600; }
.markdown-body .md-tab-panel { display: none; padding: 12px 16px; }
.markdown-body .md-tab-panel.active { display: block; }
.markdown-body .md-tab-panel > :first-child { margin-top: 0; }
.markdown-body .md-tab-panel > :last-child { margin-bottom: 0; }

/* ---- 扩展语法：GFM 警告框（> [!NOTE/TIP/IMPORTANT/WARNING/CAUTION]） ---- */
.markdown-body .md-alert {
    margin: 1em 0;
    padding: .65em 1em;
    border-left: 4px solid var(--c-accent);
    border-radius: 0 var(--r-sm) var(--r-sm) 0;
    background: var(--c-bg-sunken);
}
.markdown-body .md-alert-title {
    margin: 0 0 .35em;
    font-weight: 600;
    font-size: .95em;
}
.markdown-body .md-alert-body > :first-child { margin-top: 0; }
.markdown-body .md-alert-body > :last-child { margin-bottom: 0; }
.markdown-body .md-alert-note { border-left-color: var(--c-accent); }
.markdown-body .md-alert-note .md-alert-title { color: var(--c-accent); }
.markdown-body .md-alert-tip { border-left-color: var(--c-success); }
.markdown-body .md-alert-tip .md-alert-title { color: var(--c-success); }
.markdown-body .md-alert-important { border-left-color: #8957e5; }
.markdown-body .md-alert-important .md-alert-title { color: #8957e5; }
.markdown-body .md-alert-warning { border-left-color: var(--c-warning); }
.markdown-body .md-alert-warning .md-alert-title { color: var(--c-warning); }
.markdown-body .md-alert-caution { border-left-color: var(--c-danger); }
.markdown-body .md-alert-caution .md-alert-title { color: var(--c-danger); }

.md-empty,
.md-error { color: var(--fg-dim); font-size: 13px; }

/* 通用文档正文（帮助/关于/统计弹窗） */
.doc-body { font-size: 13.5px; line-height: 1.75; color: var(--fg); }
.doc-body h3 {
    margin: 1.3em 0 .5em;
    font-size: 1.08em;
    font-weight: 600;
}
.doc-body h3:first-child { margin-top: 0; }
.doc-body ul { margin: .5em 0; padding-left: 1.5em; }
.doc-body li { margin: .28em 0; }
.doc-body code {
    font-family: var(--font-mono);
    font-size: .88em;
    padding: .15em .4em;
    border-radius: 4px;
    background: var(--code-bg);
    color: var(--code-fg);
}
.doc-body p { margin: .6em 0; }
.doc-body .dim { color: var(--fg-dim); font-size: .94em; }

/* ==========================================================================
   图片查看器
   ========================================================================== */

.img-container {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    background:
        linear-gradient(45deg, var(--checker) 25%, transparent 25%) 0 0 / 18px 18px,
        linear-gradient(-45deg, var(--checker) 25%, transparent 25%) 0 9px / 18px 18px,
        linear-gradient(45deg, transparent 75%, var(--checker) 75%) 9px -9px / 18px 18px,
        linear-gradient(-45deg, transparent 75%, var(--checker) 75%) -9px 0 / 18px 18px;
    background-color: var(--bg-subtle);
}
.img-stage {
    min-height: 100%;
    min-width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.img-stage.grabbing { cursor: grabbing; }
.img-target {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transform-origin: center center;
    transition: transform .16s ease;
    box-shadow: 0 3px 20px rgba(0, 0, 0, .16);
    border-radius: 3px;
    user-select: none;
}

/* ==========================================================================
   媒体查看器
   ========================================================================== */

.media-stage {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 26px;
    background: var(--bg-subtle);
}
.media-video {
    max-width: 100%;
    max-height: 100%;
    border-radius: var(--radius-md);
    box-shadow: 0 4px 24px rgba(0, 0, 0, .2);
    background: #000;
}
.media-audio { width: min(560px, 100%); }
.media-unsupported {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    text-align: center;
    color: var(--fg-muted);
    font-size: 13px;
    padding: 32px;
}

/* ==========================================================================
   PDF 查看器
   ========================================================================== */

.pdf-container {
    flex: 1 1 auto;
    min-height: 0;
    background: var(--bg-sunken);
}
.pdf-frame {
    width: 100%;
    height: 100%;
    border: 0;
    display: block;
}

/* ==========================================================================
   docx 预览
   ========================================================================== */

.docx-container {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    background: var(--bg-sunken);
    padding: 24px 16px 60px;
}
.docx-body {
    max-width: 820px;
    margin: 0 auto;
    padding: 44px 52px;
    background: var(--bg-elevated);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    font-size: 14px;
    line-height: 1.8;
}
.docx-body img { max-width: 100%; }
.docx-body table { width: 100%; border-collapse: collapse; margin: 1em 0; }
.docx-body td,
.docx-body th { border: 1px solid var(--border); padding: 6px 10px; }

/* ==========================================================================
   sdoc 富文本（Summernote）
   ========================================================================== */

.sdoc-container {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    background: var(--bg);
}
.sdoc-holder { min-height: 100%; }

.sdoc-container .note-editor.note-frame {
    border: 0;
    border-radius: 0;
    background: transparent;
}
/* 注：Summernote 自带工具栏已通过 toolbar:false 关闭，
   .note-toolbar / .note-btn 相关样式随之失效，故不再保留。
   工具栏改由 .editor-toolbar.sn-toolbar 提供（见文件末尾）。 */

/*
 * ★ 隐藏 Summernote 的拖拽调整高度状态栏（旧项目 default.css:956 逐字迁移）。
 *
 * 为什么必须靠 CSS，而不能只靠配置：
 *   旧项目传了 `statusbar: false`，本项目也传了，但 **0.9.1 里这个选项根本无效** ——
 *   `statusbar` 不是 option key，而是 modules 注册名（`modules: { ..., statusbar: Yo, ... }`）。
 *   Statusbar 模块的初始化逻辑只有这一个开关（源码 @170102）：
 *       this.options.airMode || this.options.disableResizeEditor
 *           ? this.destroy()                                  // destroy = off() + addClass('locked')
 *           : this.$statusbar.on('mousedown touchstart', ...)  // 绑定拖拽
 *   而 `disableResizeEditor` 全库仅出现这一次、且不在默认值表里 → 默认 undefined
 *   → 永远走 else 分支 → 拖拽手柄必然可拖。
 *   所以 .note-statusbar 节点总会渲染，只能由 CSS 隐藏
 *   （旧项目就是这么做的，迁移时漏了这一条，导致拖拽条外露）。
 */
.sdoc-container .note-editor > .note-statusbar { display: none; }

.sdoc-container .note-editable {
    padding: 28px 34px 80px;
    font-size: 14px;
    line-height: 1.8;
    background: var(--bg);
    color: var(--fg);
    min-height: 320px;
    font-family: var(--font-sans);
}
.sdoc-container .note-editable:focus { outline: none; }
.sdoc-container .note-placeholder { color: var(--fg-dim); }
.sdoc-container .note-editable table {
    width: 100%;
    border-collapse: collapse;
}
.sdoc-container .note-editable td,
.sdoc-container .note-editable th {
    border: 1px solid var(--border);
    padding: 6px 10px;
    min-width: 32px;
}
.sdoc-container .note-editable img { max-width: 100%; }
.sdoc-container .note-editable blockquote {
    border-left: 3px solid var(--accent);
    padding-left: 14px;
    color: var(--fg-muted);
    margin: 1em 0;
}
.sdoc-container .note-editable pre {
    background: var(--code-bg);
    color: var(--code-fg);
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 12.5px;
    overflow-x: auto;
}
/* 下拉面板 */
.note-modal .note-modal-content,
.note-popover .popover-content,
.note-dropdown-menu {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    color: var(--fg);
}
.note-dropdown-menu .note-btn {
    color: var(--fg);
    background: transparent;
}
.note-dropdown-menu .note-btn:hover { background: var(--bg-hover); }
.note-modal-backdrop { background: rgba(0, 0, 0, .42); }

.source-textarea {
    width: 100%;
    min-height: 380px;
    font-family: var(--font-mono);
    font-size: 12.5px;
    line-height: 1.6;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--code-bg);
    color: var(--code-fg);
    resize: vertical;
}

/* ==========================================================================
   hxls 表格（Handsontable）
   ========================================================================== */

.hxls-container {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    padding: 8px;
    background: var(--bg);
}
.hxls-grid { width: 100%; height: 100%; }

.hxls-container .handsontable {
    font-family: var(--font-sans);
    font-size: 12.5px;
    color: var(--fg);
}
.hxls-container .handsontable td,
.hxls-container .handsontable th {
    background: var(--bg-elevated);
    border-color: var(--border);
    color: var(--fg);
}
.hxls-container .handsontable th {
    background: var(--bg-subtle);
    color: var(--fg-muted);
    font-weight: 500;
}
.hxls-container .handsontable .wtBorder { background-color: var(--accent) !important; }
.hxls-container .handsontable td.area,
.hxls-container .handsontable td.area-1,
.hxls-container .handsontable td.area-2,
.hxls-container .handsontable td.area-3 { background: var(--accent-soft); }
.hxls-container .handsontable tr > th.ht__highlight,
.hxls-container .handsontable tr > td.ht__highlight { background: var(--bg-hover); }
.hxls-container .handsontable .currentRow,
.hxls-container .handsontable .currentCol { background: var(--bg-hover); }
.hxls-container .htContextMenu table tbody tr td {
    background: var(--bg-elevated);
    color: var(--fg);
    font-size: 12.5px;
}
.hxls-container .htContextMenu table tbody tr td.htDimmed { color: var(--fg-dim); }
.hxls-container .htContextMenu table tbody tr td.current,
.hxls-container .htContextMenu table tbody tr td.zeroclipboard-is-hover { background: var(--accent); color: #fff; }
.hxls-container .htDropdownMenu { background: var(--bg-elevated); }
.hxls-container .htCommentsContainer .htComments { background: var(--bg-elevated); color: var(--fg); }
.hxls-container .handsontable .htAutocompleteArrow { color: var(--fg-dim); }

/* ==========================================================================
   zsvg 绘图（ZRender）
   ========================================================================== */

.zsvg-container {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    background:
        linear-gradient(var(--grid-line) 1px, transparent 1px) 0 0 / 20px 20px,
        linear-gradient(90deg, var(--grid-line) 1px, transparent 1px) 0 0 / 20px 20px,
        var(--bg);
}
.zsvg-canvas {
    width: 100%;
    height: 100%;
    outline: none;
}

/* ==========================================================================
   文件列表 / 搜索结果 / 快速打开
   ========================================================================== */

.file-list { display: flex; flex-direction: column; gap: 1px; }

.search-bar {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg);
    margin-bottom: 12px;
    color: var(--fg-dim);
    flex: 0 0 auto;
}
.search-input {
    flex: 1 1 auto;
    border: 0;
    outline: none;
    background: transparent;
    font-size: 13.5px;
    color: var(--fg);
    font-family: inherit;
    min-width: 0;
}
.search-input::placeholder { color: var(--fg-dim); }

.search-results,
.quick-list {
    max-height: min(54vh, 460px);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.search-hint,
.search-loading,
.search-count {
    padding: 14px 4px;
    font-size: 12.5px;
    color: var(--fg-dim);
    text-align: center;
}
.search-count { text-align: left; font-weight: 500; color: var(--fg-muted); padding: 6px 4px 8px; }

.search-item,
.quick-item {
    display: grid;
    grid-template-columns: 20px 1fr auto;
    align-items: center;
    gap: 9px;
    padding: 7px 9px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background .1s;
}
.search-item:hover,
.quick-item:hover,
.quick-item.active { background: var(--bg-hover); }
.quick-item.active { box-shadow: inset 2px 0 0 var(--accent); }

.search-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--fg-dim);
}
.search-icon.sdoc { color: #ff9500; }
.search-icon.hxls { color: #34c759; }
.search-icon.zsvg { color: #af52de; }
.search-icon.md { color: #0a84ff; }
.search-icon.code { color: #5ac8fa; }
.search-icon.image { color: #ff2d55; }
.search-icon.pdf { color: #ff3b30; }

.search-name {
    font-size: 13px;
    color: var(--fg);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.search-path {
    font-size: 11.5px;
    color: var(--fg-dim);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 46%;
}
.search-snippet {
    grid-column: 2 / -1;
    font-size: 11.5px;
    color: var(--fg-muted);
    font-family: var(--font-mono);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-top: 1px;
}

/* ==========================================================================
   版本历史
   ========================================================================== */

.history-layout {
    display: grid;
    grid-template-columns: 306px 1fr;
    gap: 0;
    height: min(66vh, 580px);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.history-side {
    display: flex;
    flex-direction: column;
    min-height: 0;
    border-right: 1px solid var(--border);
    background: var(--bg-subtle);
}
.history-head {
    padding: 9px 12px;
    border-bottom: 1px solid var(--border);
    flex: 0 0 auto;
}
.history-path {
    display: block;
    font-size: 11.5px;
    color: var(--fg-muted);
    font-family: var(--font-mono);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    direction: rtl;
    text-align: left;
}

.commit-list { flex: 1 1 auto; overflow-y: auto; padding: 5px; }
.commit-list.mini { max-height: 180px; flex: none; padding: 0; }

.commit-row {
    display: grid;
    grid-template-columns: 12px 1fr auto;
    gap: 9px;
    align-items: flex-start;
    padding: 8px 9px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background .1s;
}
.commit-row:hover { background: var(--bg-hover); }
.commit-row.active { background: var(--accent-soft); }

.commit-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--border-strong);
    margin-top: 5px;
}
.commit-row.active .commit-dot { background: var(--accent); }

.commit-main { min-width: 0; }
.commit-msg {
    font-size: 12.5px;
    color: var(--fg);
    line-height: 1.42;
    word-break: break-word;
}
.commit-meta {
    display: flex;
    gap: 8px;
    margin-top: 3px;
    font-size: 11px;
    color: var(--fg-dim);
}
.commit-sha {
    font-family: var(--font-mono);
    font-size: 10.5px;
    color: var(--fg-dim);
    padding-top: 2px;
}

.commit-empty,
.commit-loading {
    padding: 26px 12px;
    text-align: center;
    font-size: 12.5px;
    color: var(--fg-dim);
}

.diff-view {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    background: var(--bg);
}
.diff-empty {
    margin: auto;
    padding: 30px;
    font-size: 12.5px;
    color: var(--fg-dim);
    text-align: center;
}
.diff-head {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-subtle);
    flex: 0 0 auto;
}
.diff-msg {
    font-size: 12.5px;
    color: var(--fg);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.diff-sha {
    font-family: var(--font-mono);
    font-size: 10.5px;
    color: var(--fg-dim);
    padding: 1px 6px;
    background: var(--bg-hover);
    border-radius: 4px;
}
.diff-spacer { flex: 1 1 auto; }

.diff-body {
    flex: 1 1 auto;
    overflow: auto;
    font-family: var(--font-mono);
    font-size: 12px;
    line-height: 1.62;
    padding: 8px 0 20px;
}
.diff-line {
    display: grid;
    grid-template-columns: 44px 44px 15px 1fr;
    white-space: pre;
    min-width: max-content;
}
.diff-line .dl-old,
.diff-line .dl-new {
    text-align: right;
    padding-right: 9px;
    color: var(--fg-dim);
    user-select: none;
    font-size: 11px;
}
.diff-line .dl-sign { text-align: center; color: var(--fg-dim); user-select: none; }
.diff-line .dl-text { padding-right: 18px; }

.diff-line.add { background: rgba(52, 199, 89, .13); }
.diff-line.add .dl-sign { color: #34c759; }
.diff-line.del { background: rgba(255, 59, 48, .11); }
.diff-line.del .dl-sign { color: #ff3b30; }
.diff-line.hunk {
    background: var(--bg-subtle);
    color: var(--accent);
    padding: 3px 0;
    margin: 5px 0;
}
.diff-line.hunk .dl-text { color: var(--accent); }
.diff-line.ctx { color: var(--fg-muted); }

.diff-truncated {
    padding: 10px 14px;
    font-family: var(--font-sans);
    font-size: 11.5px;
    color: var(--fg-dim);
    text-align: center;
    border-top: 1px solid var(--border);
    margin-top: 8px;
}

/* ==========================================================================
   文件信息
   ========================================================================== */

.info-table {
    display: grid;
    grid-template-columns: 88px 1fr;
    gap: 7px 14px;
    font-size: 13px;
    align-items: baseline;
}
.info-key { color: var(--fg-dim); font-size: 12.5px; }
.info-val {
    color: var(--fg);
    word-break: break-all;
    font-family: var(--font-mono);
    font-size: 12.5px;
}

.info-history { margin-top: 16px; }
.info-history-title {
    font-size: 12.5px;
    font-weight: 500;
    color: var(--fg-muted);
    margin-bottom: 7px;
    padding-bottom: 5px;
    border-bottom: 1px solid var(--border);
}
.info-history .commit-row { grid-template-columns: 1fr auto; cursor: default; }
.info-history .commit-row:hover { background: transparent; }

/* ==========================================================================
   文件统计
   ========================================================================== */

.stat-list {
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 7px;
    max-height: 300px;
    overflow-y: auto;
}
.stat-row {
    display: grid;
    grid-template-columns: 62px 1fr 42px;
    align-items: center;
    gap: 10px;
    font-size: 12px;
}
.stat-ext {
    color: var(--fg-muted);
    font-family: var(--font-mono);
    font-size: 11.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.stat-bar {
    height: 6px;
    border-radius: 3px;
    background: var(--bg-hover);
    overflow: hidden;
}
.stat-fill {
    display: block;
    height: 100%;
    background: var(--accent);
    border-radius: 3px;
    min-width: 2px;
    transition: width .3s;
}
.stat-count {
    text-align: right;
    color: var(--fg-dim);
    font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   文本预览（打开本地文件）
   ========================================================================== */

.text-preview {
    margin: 0;
    padding: 15px;
    font-family: var(--font-mono);
    font-size: 12.5px;
    line-height: 1.62;
    background: var(--code-bg);
    color: var(--code-fg);
    border-radius: var(--radius-sm);
    max-height: min(62vh, 520px);
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-word;
}

/* ==========================================================================
   快捷键网格
   ========================================================================== */

.shortcut-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(228px, 1fr));
    gap: 22px 28px;
}
.shortcut-group { min-width: 0; }
.shortcut-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: .05em;
    margin-bottom: 9px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}
.shortcut-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 5px 0;
    font-size: 12.5px;
    color: var(--fg-muted);
}

/* ==========================================================================
   sdoc 自绘工具栏（对齐旧项目 my-notes 的 .toolbar + .extendbar）
   --------------------------------------------------------------------------
   旧项目 app/css/default.css:22-47 / 759-826 / 702-736 定义了
   .toolbar / .color-picker / .table-picker / .header-list / .source-code / .combobox。
   新项目没有 Bootstrap，故用等价的视觉语言重写：
     - 保持 9×9 网格、格子 15px、.selected 蓝框 #9cc9f0 底 #eff5fa
     - 保持下拉面板的分组标题、分隔线、悬停底色
   ========================================================================== */

/* ---- 工具栏内的下拉触发器（带文字或双图标） ---- */
.sn-toolbar .sn-combo {
    gap: 3px;
    padding-right: 3px;
}
.sn-toolbar .sn-combo-text {
    font-size: 12px;
    color: var(--fg-muted);
    min-width: 34px;
    text-align: left;
    font-variant-numeric: tabular-nums;
}
.sn-toolbar .sn-combo.active .sn-combo-text { color: var(--accent); }

/* ---- 字体颜色按钮下方的当前色条 ---- */
.sn-toolbar .tb-color { position: relative; }
.sn-toolbar .sn-color-bar {
    position: absolute;
    left: 6px;
    right: 6px;
    bottom: 3px;
    height: 2.5px;
    border-radius: 2px;
    background: var(--fg);
    pointer-events: none;
}

/* ---- 通用下拉面板（挂在 body 上，absolute 定位） ---- */
.sn-panel {
    z-index: 3000;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    padding: 5px;
    animation: snPanelIn .12s var(--ease);
}
@keyframes snPanelIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: none; }
}

/* ---- 颜色选择面板 ---- */
.sn-colorpicker { width: 232px; }
.sn-color-section + .sn-color-section {
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid var(--border);
}
.sn-color-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 11px;
    color: var(--fg-dim);
    padding: 2px 4px 5px;
}
.sn-color-reset {
    font-size: 11px;
    color: var(--accent);
    padding: 1px 5px;
    border-radius: var(--radius-sm);
}
.sn-color-reset:hover { background: var(--accent-soft); }

.sn-colorgrid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 3px;
    padding: 0 2px;
}
.sn-colorcell {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 4px;
    border: 1px solid var(--border);
    transition: transform .1s var(--ease), box-shadow .1s var(--ease);
}
.sn-colorcell:hover {
    transform: scale(1.18);
    box-shadow: 0 0 0 2px var(--accent-ring);
    z-index: 1;
}
.sn-colorcell.is-transparent {
    background-image:
        linear-gradient(45deg, var(--checker) 25%, transparent 25%),
        linear-gradient(-45deg, var(--checker) 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, var(--checker) 75%),
        linear-gradient(-45deg, transparent 75%, var(--checker) 75%);
    background-size: 8px 8px;
    background-position: 0 0, 0 4px, 4px -4px, -4px 0;
}

/* ---- 下拉列表框（字体大小 / 标题） ---- */
.sn-combobox { min-width: 132px; padding: 0; }
.sn-combolist {
    display: flex;
    flex-direction: column;
    max-height: 320px;
    overflow-y: auto;
    padding: 3px;
}
.sn-comboitem {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 5px 9px;
    border-radius: var(--radius-sm);
    text-align: left;
    color: var(--fg);
    line-height: 1.35;
    white-space: nowrap;
}
.sn-comboitem:hover { background: var(--bg-hover); }
.sn-comboitem.selected {
    background: var(--accent-soft);
    color: var(--accent);
}
.sn-comboitem svg { flex: 0 0 auto; color: var(--accent); }

/* ---- 表格选择器（9×9 网格，对齐旧项目 .table-picker） ---- */
.sn-tablepicker-wrap { padding: 6px; }
.sn-tablepicker {
    border-collapse: separate;
    border-spacing: 1px;
    margin: 0 auto;
}
.sn-tablepicker td {
    width: 15px;
    height: 15px;
    border: 1px solid var(--border);
    border-radius: 2px;
    cursor: pointer;
    background: var(--bg-elevated);
    transition: background .08s, border-color .08s;
}
.sn-tablepicker td:hover { border-color: var(--border-strong); }
.sn-tablepicker td.selected {
    border-color: #9cc9f0;
    background-color: #eff5fa;
}
:root[data-theme="dark"] .sn-tablepicker td.selected {
    border-color: #0a84ff;
    background-color: rgba(10, 132, 255, .28);
}
.sn-tablepicker-status {
    text-align: center;
    font-size: 11.5px;
    color: var(--fg-dim);
    padding-top: 5px;
    font-variant-numeric: tabular-nums;
}

/* ---- 代码 / 源码面板（对齐旧项目 .source-code） ---- */
.sn-sourcecode { min-width: 158px; padding: 0; }
.sn-srcitem {
    display: flex;
    align-items: center;
    gap: 9px;
    width: 100%;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    color: var(--fg);
    font-size: 12.5px;
    text-align: left;
}
.sn-srcitem:hover { background: var(--bg-hover); }
.sn-srcitem svg { flex: 0 0 auto; color: var(--fg-dim); }
.sn-srcitem:hover svg { color: var(--accent); }
.sn-srcdivider {
    height: 1px;
    background: var(--border);
    margin: 4px 6px;
}

/* ---- 代码块弹窗 ---- */
.sn-lang-select {
    width: 100%;
    height: 32px;
    padding: 0 9px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
    color: var(--fg);
    font-size: 12.5px;
}
.sn-lang-select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-ring);
}

.sn-code-tabs {
    display: flex;
    gap: 2px;
    margin: 14px 0 0;
    border-bottom: 1px solid var(--border);
}
.sn-code-tab {
    padding: 6px 13px;
    font-size: 12.5px;
    color: var(--fg-dim);
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: color .12s, border-color .12s;
}
.sn-code-tab:hover { color: var(--fg); }
.sn-code-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    font-weight: 500;
}

.sn-code-pane { padding-top: 10px; }
.sn-code-pane.hidden { display: none; }

.sn-code-area {
    width: 100%;
    min-height: 300px;
    max-height: 52vh;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--code-bg);
    color: var(--code-fg);
    font-family: var(--font-mono);
    font-size: 12.5px;
    line-height: 1.6;
    tab-size: 4;
    resize: vertical;
    white-space: pre;
    overflow: auto;
}
.sn-code-area:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-ring);
}

.sn-code-preview {
    min-height: 300px;
    max-height: 52vh;
    margin: 0;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--code-bg);
    color: var(--code-fg);
    font-family: var(--font-mono);
    font-size: 12.5px;
    line-height: 1.6;
    overflow: auto;
    white-space: pre;
}

/* ---- 编辑区内的代码块样式（插入后的渲染效果） ---- */
.sdoc-container .note-editable pre {
    background: var(--code-bg);
    color: var(--code-fg);
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 12.5px;
    line-height: 1.6;
    overflow-x: auto;
    white-space: pre;
    margin: 10px 0;
}
.sdoc-container .note-editable pre code {
    background: none;
    padding: 0;
    font-size: inherit;
    color: inherit;
}
.sdoc-container .note-editable code {
    background: var(--bg-sunken);
    padding: 2px 5px;
    border-radius: 3px;
    font-family: var(--font-mono);
    font-size: .92em;
    color: var(--c-danger);
}
.sdoc-container .note-editable blockquote {
    margin: 10px 0;
    padding: 6px 0 6px 14px;
    border-left: 3px solid var(--border-strong);
    color: var(--fg-muted);
}
.sdoc-container .note-editable hr {
    border: 0;
    border-top: 1px solid var(--border);
    margin: 18px 0;
}

/* ---- 表格样式（对齐旧项目 .table.table-bordered） ---- */
.sdoc-container .note-editable table {
    border-collapse: collapse;
    width: 100%;
    margin: 10px 0;
    table-layout: fixed;
}
.sdoc-container .note-editable table td,
.sdoc-container .note-editable table th {
    border: 1px solid var(--border);
    padding: 6px 10px;
    min-width: 28px;
    word-break: break-word;
}
.sdoc-container .note-editable table th {
    background: var(--bg-subtle);
    font-weight: 600;
    text-align: left;
}
.sdoc-container .note-editable table td:hover,
.sdoc-container .note-editable table th:hover {
    box-shadow: inset 0 0 0 1px var(--accent-ring);
}
.sdoc-container .note-editable table .selectedCell::after {
    content: "";
    position: absolute;
    inset: 0;
    background: var(--accent-soft);
    pointer-events: none;
}

/* ---- 链接 ---- */
.sdoc-container .note-editable a {
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 2px;
}
