    :root {
      --bg: #f4f5f7;
      --surface: #ffffff;
      --border: #e2e5eb;
      --text: #1a1d24;
      --muted: #5c6370;
      --accent: #2563eb;
      --accent-hover: #1d4ed8;
      --editor-font: "JetBrains Mono", "Fira Code", "SF Mono", Consolas, monospace;
      --preview-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans SC", sans-serif;
      --header-h: 52px;
      --radius: 10px;
      --shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    }

    * {
      box-sizing: border-box;
    }

    html, body {
      height: 100%;
      margin: 0;
      font-family: var(--preview-font);
      color: var(--text);
      background: var(--bg);
    }

    .app {
      display: flex;
      flex-direction: column;
      height: 100%;
      min-height: 0;
    }

    header {
      flex-shrink: 0;
      height: var(--header-h);
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 0 16px;
      background: var(--surface);
      border-bottom: 1px solid var(--border);
      box-shadow: var(--shadow);
      gap: 12px;
    }

    .brand {
      margin: 0;
      font-size: 15px;
      font-weight: 600;
      letter-spacing: -0.02em;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    .site-foot {
      flex-shrink: 0;
      padding: 10px 16px 14px;
      font-size: 12px;
      line-height: 1.55;
      color: var(--muted);
      text-align: center;
      border-top: 1px solid var(--border);
      background: var(--surface);
    }

    .site-foot a {
      color: var(--muted);
      text-decoration: underline;
    }

    .site-foot a:hover {
      color: var(--accent);
    }

    .toolbar {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      gap: 8px;
      justify-content: flex-end;
    }

    button, .file-btn {
      font-family: inherit;
      font-size: 13px;
      padding: 7px 14px;
      border-radius: 8px;
      border: 1px solid var(--border);
      background: var(--surface);
      color: var(--text);
      cursor: pointer;
      transition: background 0.15s, border-color 0.15s, color 0.15s;
    }

    button:hover, .file-btn:hover {
      background: var(--bg);
      border-color: var(--hover-border);
    }

    button.primary {
      background: var(--accent);
      border-color: var(--accent);
      color: var(--on-accent);
    }

    button.primary:hover {
      background: var(--accent-hover);
      border-color: var(--accent-hover);
    }

    .file-btn {
      display: inline-block;
      text-decoration: none;
    }

    input[type="file"] {
      position: absolute;
      width: 0;
      height: 0;
      opacity: 0;
      pointer-events: none;
    }

    .export-dropdown {
      position: relative;
      display: inline-block;
    }

    .export-dropdown-toggle::after {
      content: "▾";
      margin-left: 4px;
      font-size: 11px;
      opacity: 0.85;
    }

    .export-dropdown-menu {
      position: absolute;
      top: calc(100% + 6px);
      right: 0;
      min-width: 132px;
      padding: 6px;
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 10px;
      box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
      z-index: 120;
    }

    .export-dropdown-menu[hidden] {
      display: none !important;
    }

    .export-dropdown-menu button {
      display: block;
      width: 100%;
      text-align: left;
      border: none;
      background: transparent;
      padding: 8px 12px;
      border-radius: 6px;
    }

    .export-dropdown-menu button:hover {
      background: var(--bg);
    }

    main {
      flex: 1;
      min-height: 0;
      padding: 12px;
    }

    /* 仅编辑：两侧留白，中间「大纲 | 编辑器」两列紧挨成一组 */
    main.mode-focus {
      display: grid;
      grid-template-columns: 1fr minmax(150px, 200px) minmax(0, 1000px) 1fr;
      gap: 12px;
      align-items: stretch;
    }

    main.outline-collapsed.mode-focus {
      grid-template-columns: 1fr minmax(0, 1000px) 1fr;
    }

    main.outline-collapsed.mode-focus .panel-outline {
      display: none;
    }

    main.outline-collapsed.mode-focus .panel-editor {
      grid-column: 2;
    }

    main.mode-focus .panel-preview {
      display: none;
    }

    main.mode-focus .panel-outline {
      grid-column: 2;
      display: flex;
      flex-direction: column;
      width: 100%;
      min-width: 0;
      min-height: 0;
    }

    main.mode-focus .panel-editor {
      grid-column: 3;
      width: 100%;
      max-width: 1000px;
      min-width: 0;
    }

    /* 预览分栏：大纲 | 编辑 | 预览（三列占满） */
    main.mode-split {
      display: grid;
      grid-template-columns: minmax(160px, 200px) 1fr 1fr;
      gap: 12px;
      align-items: stretch;
    }

    main.outline-collapsed.mode-split {
      grid-template-columns: 1fr 1fr;
    }

    main.outline-collapsed.mode-split .panel-outline {
      display: none;
    }

    main.mode-split .panel-outline {
      display: flex;
      flex-direction: column;
      min-height: 0;
      min-width: 0;
    }

    main.mode-split .panel-preview {
      display: flex;
    }

    .panel {
      display: flex;
      flex-direction: column;
      min-width: 0;
      min-height: 0;
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: var(--radius);
      box-shadow: var(--shadow);
      overflow: hidden;
    }

    .panel-label-row {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
    }

    .panel-label-row .btn-clear,
    .panel-label-row .btn-mode-toggle {
      flex-shrink: 0;
      font-family: inherit;
      font-size: 14px;
      font-weight: 600;
      padding: 4px 12px;
      border-radius: 6px;
      border: 1px solid var(--border);
      background: var(--surface);
      color: var(--muted);
      cursor: pointer;
      letter-spacing: 0.02em;
      text-transform: none;
      line-height: 1.25;
    }

    .panel-label-row .btn-clear:hover,
    .panel-label-row .btn-mode-toggle:hover {
      background: var(--bg);
      color: var(--text);
      border-color: var(--hover-border);
    }

    .panel-outline-hd .btn-outline-toggle {
      flex-shrink: 0;
      font-family: inherit;
      font-size: 14px;
      font-weight: 600;
      padding: 4px 10px;
      border-radius: 6px;
      border: 1px solid var(--border);
      background: var(--surface);
      color: var(--muted);
      cursor: pointer;
      line-height: 1.25;
      letter-spacing: 0.02em;
      text-transform: none;
    }

    .panel-outline-hd .btn-outline-toggle:hover {
      background: var(--bg);
      color: var(--text);
      border-color: var(--hover-border);
    }

    .editor-hd-actions {
      display: flex;
      align-items: center;
      gap: 8px;
      flex-shrink: 0;
      margin-left: auto;
    }

    .panel-label-row .btn-outline-expand {
      flex-shrink: 0;
      font-family: inherit;
      font-size: 14px;
      font-weight: 600;
      padding: 4px 12px;
      border-radius: 6px;
      border: 1px solid var(--border);
      background: var(--surface);
      color: var(--muted);
      cursor: pointer;
      letter-spacing: 0.02em;
      text-transform: none;
      line-height: 1.25;
    }

    .panel-label-row .btn-outline-expand:hover {
      background: var(--bg);
      color: var(--text);
      border-color: var(--hover-border);
    }

    /* 三栏标题栏等高：与含「清空」的编辑行对齐 */
    .panel > .panel-label {
      flex-shrink: 0;
      display: flex;
      align-items: center;
      box-sizing: border-box;
      min-height: 46px;
      padding: 8px 12px;
      font-size: 14px;
      font-weight: 600;
      color: var(--muted);
      text-transform: uppercase;
      letter-spacing: 0.06em;
      border-bottom: 1px solid var(--border);
      background: linear-gradient(to bottom, var(--table-stripe), var(--surface));
      line-height: 1.25;
    }

    .editor-shell {
      flex: 1;
      display: flex;
      flex-direction: column;
      min-height: 0;
      min-width: 0;
    }

    #editor {
      flex: 1;
      width: 100%;
      min-height: 0;
      padding: 16px;
      border: none;
      resize: none;
      font-family: var(--editor-font);
      font-size: 14px;
      line-height: 1.65;
      color: var(--text);
      background: var(--surface);
      outline: none;
      tab-size: 2;
    }

    .panel-editor.mode-wysiwyg #editor {
      display: none;
    }

    #vditor-root.vditor-mount .bn-container {
      width: 100%;
      min-height: 100%;
    }

    #vditor-root.vditor-mount .bn-editor {
      width: 100%;
      min-height: 100%;
      /* 左侧留白给块级拖拽手柄（BlockNote 默认 54px） */
      padding-inline: 54px 20px;
    }

    #vditor-root.vditor-mount .bn-side-menu .mantine-UnstyledButton-root:not(.mantine-Menu-item) svg {
      color: var(--muted);
    }

    #vditor-root.vditor-mount .bn-side-menu .mantine-UnstyledButton-root:hover {
      background: var(--bg);
    }

    /* BlockNote 基础主题（浅色/暗黑共用，依赖 CSS 变量） */
    #vditor-root.vditor-mount .bn-container,
    #vditor-root.vditor-mount .bn-editor {
      background: var(--surface);
      color: var(--text);
    }

    #vditor-root.vditor-mount .bn-editor .ProseMirror {
      color: var(--text);
      caret-color: var(--text);
    }

    #vditor-root.vditor-mount .bn-editor .ProseMirror p,
    #vditor-root.vditor-mount .bn-editor .ProseMirror li,
    #vditor-root.vditor-mount .bn-editor .ProseMirror h1,
    #vditor-root.vditor-mount .bn-editor .ProseMirror h2,
    #vditor-root.vditor-mount .bn-editor .ProseMirror h3,
    #vditor-root.vditor-mount .bn-editor .ProseMirror h4,
    #vditor-root.vditor-mount .bn-editor .ProseMirror h5,
    #vditor-root.vditor-mount .bn-editor .ProseMirror h6 {
      color: var(--text);
    }

    #vditor-root.vditor-mount .bn-editor .ProseMirror blockquote {
      border-left-color: var(--border);
      background: var(--surface-2, var(--bg));
      color: var(--muted);
    }

    #vditor-root.vditor-mount .bn-editor .ProseMirror table th,
    #vditor-root.vditor-mount .bn-editor .ProseMirror table td {
      border-color: var(--border);
      color: var(--text);
    }

    #vditor-root.vditor-mount .bn-editor .ProseMirror table th {
      background: var(--table-stripe);
    }

    #vditor-root.vditor-mount .bn-editor .ProseMirror code:not(pre code) {
      background: var(--surface-2, var(--bg));
      color: var(--text);
    }

    [data-theme="dark"] #vditor-root.vditor-mount .bn-container,
    [data-theme="dark"] #vditor-root.vditor-mount .bn-editor {
      background: var(--surface);
      color: var(--text);
    }

    [data-theme="dark"] #vditor-root.vditor-mount .bn-editor .ProseMirror {
      color: var(--text);
      caret-color: var(--text);
    }

    [data-theme="dark"] #vditor-root.vditor-mount .bn-editor .ProseMirror p,
    [data-theme="dark"] #vditor-root.vditor-mount .bn-editor .ProseMirror li,
    [data-theme="dark"] #vditor-root.vditor-mount .bn-editor .ProseMirror h1,
    [data-theme="dark"] #vditor-root.vditor-mount .bn-editor .ProseMirror h2,
    [data-theme="dark"] #vditor-root.vditor-mount .bn-editor .ProseMirror h3,
    [data-theme="dark"] #vditor-root.vditor-mount .bn-editor .ProseMirror h4,
    [data-theme="dark"] #vditor-root.vditor-mount .bn-editor .ProseMirror h5,
    [data-theme="dark"] #vditor-root.vditor-mount .bn-editor .ProseMirror h6 {
      color: var(--text);
    }

    [data-theme="dark"] #vditor-root.vditor-mount .bn-editor .ProseMirror blockquote {
      border-left-color: var(--border);
      background: var(--surface-2);
      color: var(--muted);
    }

    [data-theme="dark"] #vditor-root.vditor-mount .bn-editor .ProseMirror table th,
    [data-theme="dark"] #vditor-root.vditor-mount .bn-editor .ProseMirror table td {
      border-color: var(--border);
      color: var(--text);
    }

    [data-theme="dark"] #vditor-root.vditor-mount .bn-editor .ProseMirror table th {
      background: var(--surface-2);
    }

    [data-theme="dark"] #vditor-root.vditor-mount .bn-editor .ProseMirror code:not(pre code) {
      background: var(--surface-2);
      color: var(--code-block-text);
    }

    /* BlockNote 飞书风格代码块 */
    #vditor-root.vditor-mount .bn-block-content[data-content-type="codeBlock"].oyyi-code-block,
    #vditor-root.vditor-mount .bn-block-content[data-content-type="codeBlock"] {
      display: flex;
      flex-direction: column;
      align-items: stretch;
      position: relative;
      background: #f4f5f5 !important;
      color: #1f2329;
      border: 1px solid transparent;
      border-radius: 8px;
      overflow: hidden;
      padding: 0;
      transition: border-color 0.18s ease, box-shadow 0.18s ease;
    }

    /* 取消 BlockNote 默认对子元素的蓝色 outline，避免选中态出现双重描边 */
    #vditor-root.vditor-mount .bn-block-content[data-content-type="codeBlock"].ProseMirror-selectednode > *,
    #vditor-root.vditor-mount .ProseMirror-selectednode > .bn-block-content[data-content-type="codeBlock"] > * {
      outline: none !important;
      box-shadow: none !important;
    }

    #vditor-root.vditor-mount .bn-block-content[data-content-type="codeBlock"]:hover,
    #vditor-root.vditor-mount .bn-block-content[data-content-type="codeBlock"]:focus-within,
    #vditor-root.vditor-mount .bn-block-content[data-content-type="codeBlock"].ProseMirror-selectednode,
    #vditor-root.vditor-mount .bn-block-content[data-content-type="codeBlock"].oyyi-code-active,
    #vditor-root.vditor-mount .ProseMirror-selectednode > .bn-block-content[data-content-type="codeBlock"],
    #vditor-root.vditor-mount .bn-block-outer.ProseMirror-selectednode .bn-block-content[data-content-type="codeBlock"],
    #vditor-root.vditor-mount .bn-block.ProseMirror-selectednode .bn-block-content[data-content-type="codeBlock"] {
      border-color: #b4cbf0;
      box-shadow: 0 0 0 1px rgba(51, 112, 255, 0.18);
    }

    #vditor-root.vditor-mount .oyyi-code-toolbar,
    #vditor-root.vditor-mount .bn-block-content[data-content-type="codeBlock"] > div[contenteditable="false"] {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      flex: 0 0 auto;
      width: 100%;
      min-height: 36px;
      padding: 6px 10px;
      border-bottom: 1px solid transparent;
      box-sizing: border-box;
      background: transparent;
      transition: border-color 0.18s ease;
    }

    #vditor-root.vditor-mount .oyyi-code-toolbar-inner {
      display: flex;
      align-items: center;
      gap: 8px;
      flex: 1 1 auto;
      min-width: 0;
    }

    #vditor-root.vditor-mount .oyyi-code-label {
      flex: 0 0 auto;
      font-size: 13px;
      line-height: 20px;
      color: #646a73;
      user-select: none;
      white-space: nowrap;
    }

    #vditor-root.vditor-mount .bn-block-content[data-content-type="codeBlock"]:hover .oyyi-code-toolbar,
    #vditor-root.vditor-mount .bn-block-content[data-content-type="codeBlock"]:focus-within .oyyi-code-toolbar,
    #vditor-root.vditor-mount .bn-block-content[data-content-type="codeBlock"].ProseMirror-selectednode .oyyi-code-toolbar,
    #vditor-root.vditor-mount .bn-block-content[data-content-type="codeBlock"].oyyi-code-active .oyyi-code-toolbar,
    #vditor-root.vditor-mount .ProseMirror-selectednode > .bn-block-content[data-content-type="codeBlock"] .oyyi-code-toolbar,
    #vditor-root.vditor-mount .bn-block-content[data-content-type="codeBlock"]:hover > div[contenteditable="false"],
    #vditor-root.vditor-mount .bn-block-content[data-content-type="codeBlock"]:focus-within > div[contenteditable="false"],
    #vditor-root.vditor-mount .bn-block-content[data-content-type="codeBlock"].ProseMirror-selectednode > div[contenteditable="false"],
    #vditor-root.vditor-mount .bn-block-content[data-content-type="codeBlock"].oyyi-code-active > div[contenteditable="false"],
    #vditor-root.vditor-mount .ProseMirror-selectednode > .bn-block-content[data-content-type="codeBlock"] > div[contenteditable="false"] {
      border-bottom-color: #e5e6eb;
    }

    #vditor-root.vditor-mount .oyyi-code-toolbar-left {
      display: flex;
      align-items: center;
      gap: 8px;
      min-width: 0;
      flex: 1 1 auto;
    }

    #vditor-root.vditor-mount .bn-block-content[data-content-type="codeBlock"] > div[contenteditable="false"]::before {
      content: "代码块";
      flex: 0 0 auto;
      font-size: 13px;
      line-height: 20px;
      color: #646a73;
      user-select: none;
      white-space: nowrap;
      margin-right: 8px;
    }

    #vditor-root.vditor-mount .bn-block-content[data-content-type="codeBlock"] > div[contenteditable="false"] select {
      position: static !important;
      top: auto !important;
      left: auto !important;
      flex: 0 0 auto;
      margin-left: auto;
      min-width: 96px;
      max-width: 50%;
      padding: 2px 22px 2px 8px;
      font-size: 13px;
      line-height: 20px;
      border: none;
      border-radius: 4px;
      background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238f959e' d='M3 4.5 6 7.5 9 4.5'/%3E%3C/svg%3E") no-repeat right 4px center;
      color: #1f2329 !important;
      cursor: pointer;
      appearance: none;
      pointer-events: auto !important;
    }

    #vditor-root.vditor-mount .bn-block-content[data-content-type="codeBlock"] > div[contenteditable="false"] select:hover {
      background-color: rgba(31, 35, 41, 0.06);
    }

    #vditor-root.vditor-mount .bn-block-content[data-content-type="codeBlock"] > div[contenteditable="false"] select {
      border: 1px solid #cad5e2;
      background-color: #fff;
      box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
    }

    #vditor-root.vditor-mount .bn-block-content[data-content-type="codeBlock"] > div[contenteditable="false"] select:focus {
      outline: none;
      border-color: #7aa2e3;
      box-shadow: 0 0 0 2px rgba(51, 112, 255, 0.16);
    }

    #vditor-root.vditor-mount .oyyi-code-inline-tools {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      margin-left: 6px;
      flex: 0 0 auto;
      pointer-events: auto;
    }

    #vditor-root.vditor-mount .oyyi-code-copy-btn {
      height: 24px;
      border: 1px solid #cad5e2;
      border-radius: 6px;
      background: #fff;
      color: #4b5563;
      font-size: 12px;
      line-height: 18px;
      padding: 2px 10px;
      cursor: pointer;
      white-space: nowrap;
    }

    #vditor-root.vditor-mount .oyyi-code-copy-btn:hover {
      background: rgba(31, 35, 41, 0.05);
      color: #111827;
    }

    #vditor-root.vditor-mount .oyyi-code-pre,
    #vditor-root.vditor-mount .bn-block-content[data-content-type="codeBlock"] > pre {
      display: block;
      flex: 1 1 auto;
      width: 100%;
      margin: 0;
      padding: 10px 12px 12px !important;
      border: none;
      border-radius: 0;
      background: transparent !important;
      color: inherit !important;
      white-space: pre;
      overflow-x: auto;
      tab-size: 2;
      box-sizing: border-box;
    }

    #vditor-root.vditor-mount .oyyi-code-pre.oyyi-code-wrap,
    #vditor-root.vditor-mount .bn-block-content[data-content-type="codeBlock"] > pre.oyyi-code-wrap {
      white-space: pre-wrap;
      word-break: break-word;
    }

    #vditor-root.vditor-mount .oyyi-code-pre.oyyi-code-wrap code,
    #vditor-root.vditor-mount .bn-block-content[data-content-type="codeBlock"] > pre.oyyi-code-wrap code {
      white-space: pre-wrap;
      word-break: break-word;
    }

    #vditor-root.vditor-mount .oyyi-code-pre code,
    #vditor-root.vditor-mount .bn-block-content[data-content-type="codeBlock"] pre code {
      flex: 1 1 auto;
      min-width: 0;
      background: transparent !important;
      color: inherit !important;
      font-family: "JetBrains Mono", "Fira Code", "SF Mono", Consolas, monospace;
      font-size: 13px;
      line-height: 1.65;
      cursor: text;
      caret-color: #1f2329;
    }

    /* 覆盖 BlockNote 默认深色代码块（#161616） */
    #vditor-root.vditor-mount .bn-block-content[data-content-type="codeBlock"],
    #vditor-root.vditor-mount .bn-block-content[data-content-type="codeBlock"] > pre,
    #vditor-root.vditor-mount .bn-block-content[data-content-type="codeBlock"] pre code,
    #vditor-root.vditor-mount .bn-block-content[data-content-type="codeBlock"] pre code span {
      background-color: #f4f5f5 !important;
      color: #1f2329 !important;
    }

    [data-theme="dark"] #vditor-root.vditor-mount .bn-block-content[data-content-type="codeBlock"],
    [data-theme="dark"] #vditor-root.vditor-mount .bn-block-content[data-content-type="codeBlock"].oyyi-code-block {
      background: var(--code-block-bg) !important;
      color: var(--code-block-text);
      border-color: transparent;
    }

    [data-theme="dark"] #vditor-root.vditor-mount .bn-block-content[data-content-type="codeBlock"]:hover,
    [data-theme="dark"] #vditor-root.vditor-mount .bn-block-content[data-content-type="codeBlock"]:focus-within,
    [data-theme="dark"] #vditor-root.vditor-mount .bn-block-content[data-content-type="codeBlock"].ProseMirror-selectednode,
    [data-theme="dark"] #vditor-root.vditor-mount .bn-block-content[data-content-type="codeBlock"].oyyi-code-active,
    [data-theme="dark"] #vditor-root.vditor-mount .ProseMirror-selectednode > .bn-block-content[data-content-type="codeBlock"] {
      border-color: rgba(100, 149, 237, 0.45);
      box-shadow: 0 0 0 1px rgba(100, 149, 237, 0.2);
    }

    [data-theme="dark"] #vditor-root.vditor-mount .bn-block-content[data-content-type="codeBlock"],
    [data-theme="dark"] #vditor-root.vditor-mount .bn-block-content[data-content-type="codeBlock"] > pre,
    [data-theme="dark"] #vditor-root.vditor-mount .bn-block-content[data-content-type="codeBlock"] pre code,
    [data-theme="dark"] #vditor-root.vditor-mount .bn-block-content[data-content-type="codeBlock"] pre code span {
      background-color: var(--code-block-bg) !important;
      color: var(--code-block-text) !important;
    }
    [data-theme="dark"] #vditor-root.vditor-mount .bn-block-content[data-content-type="codeBlock"] pre code {
      caret-color: var(--code-block-text);
    }

    [data-theme="dark"] #vditor-root.vditor-mount .oyyi-code-label {
      color: var(--muted);
    }

    [data-theme="dark"] #vditor-root.vditor-mount .oyyi-code-gutter {
      border-right-color: var(--border);
      color: rgba(255, 255, 255, 0.28);
    }

    [data-theme="dark"] #vditor-root.vditor-mount .oyyi-code-toolbar-left select,
    [data-theme="dark"] #vditor-root.vditor-mount .bn-block-content[data-content-type="codeBlock"] > div[contenteditable="false"] select {
      background-color: var(--surface-2);
      border-color: var(--border);
      color: var(--text);
    }

    [data-theme="dark"] #vditor-root.vditor-mount .oyyi-code-copy-btn {
      background-color: var(--surface-2);
      border-color: var(--border);
      color: var(--text);
    }

    [data-theme="dark"] #vditor-root.vditor-mount .oyyi-code-copy-btn:hover {
      color: var(--text);
      background: rgba(255, 255, 255, 0.08);
    }

    #vditor-root.vditor-mount .bn-block-content[data-content-type="codeBlock"] > pre {
      position: relative;
      z-index: 0;
    }

    #vditor-root.vditor-mount {
      display: none;
      flex: 1;
      flex-direction: column;
      min-height: 0;
      min-width: 0;
      width: 100%;
      position: relative;
      overflow-y: auto;
      overflow-x: hidden;
      -webkit-overflow-scrolling: touch;
    }

    .panel-editor.mode-wysiwyg #vditor-root.vditor-mount {
      display: flex;
    }

    #vditor-root.vditor-mount .vditor {
      flex: 1;
      min-height: 0;
      width: 100%;
      border: none;
      border-radius: 0;
    }

    #vditor-root.vditor-mount .vditor-toolbar {
      display: none !important;
      height: 0 !important;
      min-height: 0 !important;
      padding: 0 !important;
      border: none !important;
      overflow: hidden !important;
    }

    #vditor-root.vditor-mount .vditor-content {
      flex: 1;
      min-height: 0;
    }

    /* 代码块编辑时隐藏预览层，避免与源码区重复显示 */
    #vditor-root .vditor-wysiwyg__block[data-type="code-block"] pre:not([style*="display:none"]):not([style*="display: none"]) + .vditor-wysiwyg__preview {
      display: none !important;
    }

    /* 图片尺寸元数据注释块，不在所见即所得中展示 */
    #vditor-root .vditor-wysiwyg__block.oyyi-img-meta-hidden {
      display: none !important;
      height: 0 !important;
      margin: 0 !important;
      padding: 0 !important;
      overflow: hidden !important;
    }

    #vditor-root .vditor-wysiwyg img:not(.emoji),
    #vditor-root .vditor-ir img:not(.emoji) {
      max-width: 100%;
      height: auto;
      object-fit: contain;
      border-radius: 6px;
      cursor: pointer;
    }

    #vditor-root .vditor-wysiwyg img.editor-img-selected {
      outline: 2px solid var(--accent, #2563eb);
      outline-offset: 2px;
    }

    .editor-img-resize-handle {
      position: absolute;
      width: 12px;
      height: 12px;
      background: var(--accent, #2563eb);
      border: 2px solid var(--handle-border);
      border-radius: 2px;
      cursor: nwse-resize;
      z-index: 20;
      box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
    }

    /* 编辑器主区域：点击聚焦时不改变背景色（覆盖 Vditor 默认 focus 样式） */
    #vditor-root .vditor-wysiwyg > pre.vditor-reset,
    #vditor-root .vditor-wysiwyg > pre.vditor-reset:focus {
      background-color: var(--surface) !important;
    }

    [data-theme="dark"] #vditor-root .vditor-wysiwyg > pre.vditor-reset,
    [data-theme="dark"] #vditor-root .vditor-wysiwyg > pre.vditor-reset:focus {
      background-color: var(--input-bg) !important;
    }

    /* 暗黑模式：所见即所得内代码块、表格黑底 */
    [data-theme="dark"] #vditor-root .vditor-wysiwyg__block[data-type="code-block"] {
      background: var(--code-block-bg);
      border-radius: 8px;
    }

    [data-theme="dark"] #vditor-root .vditor-wysiwyg__block[data-type="code-block"] pre,
    [data-theme="dark"] #vditor-root .vditor-wysiwyg__block[data-type="code-block"] pre code,
    [data-theme="dark"] #vditor-root .vditor-wysiwyg .vditor-wysiwyg__preview pre,
    [data-theme="dark"] #vditor-root .vditor-wysiwyg .vditor-wysiwyg__preview pre code,
    [data-theme="dark"] #vditor-root .vditor-wysiwyg .vditor-wysiwyg__preview .hljs,
    [data-theme="dark"] #vditor-root .vditor-wysiwyg .vditor-wysiwyg__preview .highlight-chroma {
      background-color: var(--code-block-bg) !important;
      background-image: none !important;
      color: var(--code-block-text) !important;
    }

    [data-theme="dark"] #vditor-root .vditor-wysiwyg .vditor-reset code:not(.hljs):not(.highlight-chroma) {
      background-color: var(--surface-2) !important;
      color: var(--code-block-text) !important;
    }

    [data-theme="dark"] #vditor-root .vditor-wysiwyg .vditor-reset table tr {
      background-color: var(--code-block-bg) !important;
      border-top-color: var(--border) !important;
    }

    [data-theme="dark"] #vditor-root .vditor-wysiwyg .vditor-reset table tbody tr:nth-child(2n) {
      background-color: var(--surface-2) !important;
    }

    [data-theme="dark"] #vditor-root .vditor-wysiwyg .vditor-reset table td,
    [data-theme="dark"] #vditor-root .vditor-wysiwyg .vditor-reset table th {
      border-color: var(--border) !important;
      color: var(--text) !important;
    }

    [data-theme="dark"] #vditor-root .vditor-wysiwyg .vditor-reset table th {
      background-color: var(--surface-2) !important;
      font-weight: 600;
    }

    #preview {
      flex: 1;
      min-height: 0;
      overflow: auto;
      padding: 16px 20px;
      font-size: 15px;
      line-height: 1.7;
      color: var(--text);
    }

    .md-prose h1, .md-prose h2, .md-prose h3 {
      margin-top: 1.2em;
      margin-bottom: 0.5em;
      line-height: 1.3;
      font-weight: 600;
    }

    .md-prose h1 { font-size: 1.75em; border-bottom: 1px solid var(--border); padding-bottom: 0.3em; }
    .md-prose h2 { font-size: 1.4em; }
    .md-prose h3 { font-size: 1.15em; }

    .md-prose p { margin: 0.75em 0; }
    .md-prose ul, .md-prose ol { margin: 0.75em 0; padding-left: 1.5em; }
    .md-prose li { margin: 0.25em 0; }
    .md-prose blockquote {
      margin: 1em 0;
      padding: 0.25em 0 0.25em 1em;
      border-left: 4px solid var(--accent);
      color: var(--muted);
      background: var(--bg);
      border-radius: 0 6px 6px 0;
    }
    .md-prose code {
      font-family: var(--editor-font);
      font-size: 0.88em;
      padding: 0.15em 0.45em;
      background: var(--bg);
      border-radius: 4px;
      border: 1px solid var(--border);
    }
    .md-prose pre {
      margin: 1em 0;
      padding: 14px 16px;
      overflow: auto;
      background: var(--code-block-bg);
      color: var(--code-block-text);
      border-radius: 8px;
      font-size: 15px;
      line-height: 1.6;
    }
    .md-prose pre code {
      background: none;
      border: none;
      padding: 0;
      color: inherit;
      font-size: inherit;
    }
    .md-prose a { color: var(--accent); }
    .md-prose table {
      border-collapse: collapse;
      width: 100%;
      margin: 1em 0;
      font-size: 14px;
    }
    .md-prose th, .md-prose td {
      border: 1px solid var(--border);
      padding: 8px 12px;
    }
    .md-prose th { background: var(--table-stripe); font-weight: 600; }
    .md-prose tbody tr {
      background: var(--surface);
    }
    .md-prose tbody tr:nth-child(even) {
      background: var(--table-stripe);
    }

    [data-theme="dark"] .md-prose tbody tr {
      background: var(--code-block-bg);
    }

    [data-theme="dark"] .md-prose tbody tr:nth-child(even) {
      background: var(--surface-2);
    }

    [data-theme="dark"] .md-prose th {
      background: var(--surface-2);
    }
    .md-prose img {
      max-width: 100%;
      height: auto;
      object-fit: contain;
      border-radius: 6px;
    }

    .app.is-fullscreen {
      position: fixed;
      inset: 0;
      z-index: 9999;
      background: var(--bg);
    }

    .app.is-fullscreen main {
      padding: 8px;
    }

    @media (max-width: 900px) {
      main.mode-split {
        grid-template-columns: 1fr;
        grid-template-rows: minmax(200px, 1fr) minmax(200px, 1fr);
      }

      main.mode-split .panel-outline {
        display: none;
      }

      main.help-open.mode-split {
        grid-template-columns: 1fr;
        grid-template-rows: minmax(160px, 1fr) minmax(160px, 1fr) minmax(120px, 28vh);
      }

      main.help-open.mode-split .panel-editor {
        grid-column: 1;
        grid-row: 1;
      }

      main.help-open.mode-split .panel-preview {
        grid-column: 1;
        grid-row: 2;
      }

      main.help-open.mode-split .panel-help {
        grid-column: 1;
        grid-row: 3;
      }
    }

    @media (max-width: 720px) {
      main.mode-focus {
        grid-template-columns: 1fr;
      }

      main.mode-focus .panel-outline {
        display: none;
      }

      main.mode-focus .panel-editor {
        grid-column: 1;
        max-width: none;
      }
    }

    .panel-outline .outline-nav {
      flex: 1;
      min-height: 0;
      overflow: auto;
      padding: 8px 10px 12px;
      font-size: 15px;
    }

    .outline-empty {
      margin: 8px 0 0;
      padding: 0 4px;
    }

    .outline-item {
      margin: 2px 0;
    }

    .outline-link {
      display: block;
      width: 100%;
      text-align: left;
      padding: 5px 8px;
      border: none;
      border-radius: 6px;
      background: transparent;
      color: var(--text);
      font-size: 15px;
      line-height: 1.45;
      cursor: pointer;
      word-break: break-word;
    }

    .outline-link:hover {
      background: var(--bg);
    }

    .outline-link:focus-visible {
      outline: 2px solid var(--accent);
      outline-offset: 1px;
    }

    .vditor-wysiwyg .outline-flash {
      animation: outline-flash 1s ease-out;
    }

    #vditor-root.vditor-mount .bn-editor .outline-flash {
      animation: outline-flash 1s ease-out;
    }

    @keyframes outline-flash {
      0% {
        background-color: rgba(37, 99, 235, 0.22);
      }
      100% {
        background-color: transparent;
      }
    }

    .auth-area {
      display: inline-flex;
      align-items: center;
      gap: 8px;
    }

    .auth-area #btn-history,
    .auth-area #btn-logout {
      display: none !important;
    }

    .auth-area.is-logged-in #btn-history,
    .auth-area.is-logged-in #btn-logout {
      display: inline-block !important;
    }

    .auth-area.is-logged-in #btn-auth-open {
      display: none !important;
    }

    .modal-overlay {
      position: fixed;
      inset: 0;
      background: var(--overlay);
      z-index: 10000;
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 20px;
    }

    .modal-overlay.modal-app-msg {
      z-index: 10050;
    }

    .modal-overlay[hidden] {
      display: none !important;
    }

    .modal {
      background: var(--surface);
      border-radius: var(--radius);
      box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
      border: 1px solid var(--border);
      width: 100%;
      max-width: 400px;
      max-height: 90vh;
      overflow: auto;
    }

    .modal-wide {
      max-width: 520px;
    }

    .modal-hd {
      padding: 14px 18px;
      border-bottom: 1px solid var(--border);
      font-weight: 600;
      font-size: 15px;
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: 12px;
    }

    .modal-close {
      border: none;
      background: none;
      font-size: 22px;
      line-height: 1;
      cursor: pointer;
      color: var(--muted);
      padding: 0 4px;
    }

    .modal-close:hover {
      color: var(--text);
    }

    .modal-bd {
      padding: 18px;
    }

    .app-msg-body {
      margin: 0;
      font-size: 14px;
      line-height: 1.6;
      color: var(--text);
      white-space: pre-wrap;
      word-break: break-word;
    }

    .app-msg-row-single {
      margin-top: 16px;
    }

    .app-msg-row-dual {
      margin-top: 16px;
      gap: 10px;
    }

    .app-msg-row-dual:not([hidden]) {
      display: flex;
    }

    .app-msg-row-single[hidden],
    .app-msg-row-dual[hidden] {
      display: none !important;
    }

    .toast-save-success {
      position: fixed;
      top: 18%;
      left: 50%;
      transform: translateX(-50%);
      z-index: 10100;
      padding: 12px 22px;
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 10px;
      box-shadow: 0 8px 28px rgba(0, 0, 0, 0.12);
      font-size: 15px;
      font-weight: 600;
      color: var(--text);
      letter-spacing: 0.02em;
      pointer-events: none;
      opacity: 0;
      transition: opacity 0.2s ease;
    }

    .toast-save-success.toast-save-success--show {
      opacity: 1;
    }

    .toast-save-success[hidden] {
      display: none !important;
    }

    .modal-tabs {
      display: flex;
      gap: 0;
      margin-bottom: 16px;
      border-radius: 8px;
      overflow: hidden;
      border: 1px solid var(--border);
    }

    .modal-tabs button {
      flex: 1;
      border: none;
      border-radius: 0;
      padding: 10px;
      font-size: 14px;
      background: var(--bg);
      color: var(--muted);
    }

    .modal-tabs button.active {
      background: var(--surface);
      color: var(--text);
      font-weight: 600;
    }

    .form-row {
      margin-bottom: 14px;
    }

    .form-row label {
      display: block;
      font-size: 13px;
      font-weight: 600;
      color: var(--muted);
      margin-bottom: 6px;
    }

    .form-row input,
    .form-row textarea {
      width: 100%;
      padding: 9px 11px;
      border: 1px solid var(--border);
      border-radius: 8px;
      font-size: 14px;
      font-family: inherit;
      box-sizing: border-box;
      background: var(--input-bg);
      color: var(--text);
    }

    .form-row textarea {
      resize: vertical;
      min-height: 100px;
      line-height: 1.55;
    }

    .form-hint {
      font-size: 12px;
      color: var(--muted);
      margin-top: 4px;
    }

    .form-err {
      font-size: 13px;
      color: var(--danger);
      margin-top: 8px;
    }

    .form-hp {
      position: absolute;
      left: -9999px;
      width: 1px;
      height: 1px;
      overflow: hidden;
      opacity: 0;
      pointer-events: none;
    }

    .history-list {
      list-style: none;
      margin: 0;
      padding: 0;
      max-height: 360px;
      overflow: auto;
    }

    .history-list li {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 10px;
      padding: 10px 0;
      border-bottom: 1px solid var(--border);
      font-size: 14px;
    }

    .history-list .history-actions {
      display: flex;
      flex-shrink: 0;
      gap: 8px;
      align-items: center;
    }

    .history-list .btn-history-delete {
      color: var(--danger);
      border-color: var(--danger-border);
      background: var(--danger-bg);
    }

    .history-list .btn-history-delete:hover {
      background: var(--danger-hover-bg);
      border-color: var(--danger-hover-border);
    }

    .history-list li:last-child {
      border-bottom: none;
    }

    .history-list button {
      flex-shrink: 0;
      font-size: 13px;
      padding: 6px 12px;
      border-radius: 8px;
      border: 1px solid var(--border);
      background: var(--surface);
      cursor: pointer;
    }

    .history-list button:hover {
      background: var(--bg);
    }

    .history-meta {
      font-size: 12px;
      color: var(--muted);
    }

    /* 嵌入右侧的语法帮助面板（与大纲、编辑、预览同一 main 网格） */
    main .panel-help {
      display: none;
      flex-direction: column;
      min-height: 0;
      min-width: 0;
    }

    main.help-open .panel-help {
      display: flex;
    }

    main.help-open.mode-focus {
      /* 与未打开时相同仍为 4 列：帮助只占最右一列，铺满原右侧留白，不挤压大纲与编辑 */
      grid-template-columns: 1fr minmax(160px, 220px) minmax(0, 900px) minmax(260px, 1fr);
    }

    main.help-open.mode-focus .panel-outline {
      grid-column: 2;
    }

    main.help-open.mode-focus .panel-editor {
      grid-column: 3;
    }

    main.help-open.mode-focus .panel-help {
      grid-column: 4;
    }

    main.help-open.outline-collapsed.mode-focus {
      grid-template-columns: 1fr minmax(0, 900px) minmax(260px, 1fr);
    }

    main.help-open.outline-collapsed.mode-focus .panel-editor {
      grid-column: 2;
    }

    main.help-open.outline-collapsed.mode-focus .panel-help {
      grid-column: 3;
    }

    main.help-open.mode-split {
      grid-template-columns: minmax(160px, 200px) 1fr 1fr minmax(260px, 1fr);
    }

    main.help-open.outline-collapsed.mode-split {
      grid-template-columns: 1fr 1fr minmax(260px, 1fr);
    }

    main.help-open.outline-collapsed.mode-split .panel-editor {
      grid-column: 1;
    }

    main.help-open.outline-collapsed.mode-split .panel-preview {
      grid-column: 2;
    }

    main.help-open.outline-collapsed.mode-split .panel-help {
      grid-column: 3;
    }

    .panel-help .help-panel-bd {
      flex: 1;
      min-height: 0;
      overflow: auto;
      padding: 12px 14px 18px;
      font-size: 15px;
      line-height: 1.6;
    }

    .panel-help .help-panel-bd h3 {
      margin: 1.1em 0 0.45em;
      font-size: 1.02em;
      font-weight: 600;
      color: var(--text);
    }

    .panel-help .help-panel-bd h3:first-child {
      margin-top: 0;
    }

    .panel-help .help-panel-bd h4 {
      margin: 0.95em 0 0.35em;
      font-size: 0.95em;
      font-weight: 600;
      color: var(--muted);
    }

    .panel-help .help-panel-bd p {
      margin: 0.45em 0;
      color: var(--text);
    }

    .panel-help .help-panel-bd ul {
      margin: 0.35em 0 0.55em;
      padding-left: 1.25em;
    }

    .panel-help .help-panel-bd li {
      margin: 0.2em 0;
    }

    .panel-help .help-panel-bd .help-snippet {
      margin: 0.45em 0 0.65em;
      padding: 8px 10px;
      border-radius: 8px;
      border: 1px solid var(--border);
      background: var(--snippet-bg);
      font-family: var(--editor-font);
      font-size: 14px;
      line-height: 1.5;
      overflow-x: auto;
      white-space: pre-wrap;
      word-break: break-word;
    }

    .panel-help .help-panel-bd kbd {
      font-family: var(--editor-font);
      font-size: 0.88em;
      padding: 1px 4px;
      border-radius: 4px;
      border: 1px solid var(--border);
      background: var(--bg);
    }

    .panel-help-hd .btn-help-close,
    .panel-help-hd .btn-help-action {
      flex-shrink: 0;
      font-family: inherit;
      font-size: 14px;
      font-weight: 600;
      padding: 4px 10px;
      border-radius: 6px;
      border: 1px solid var(--border);
      background: var(--surface);
      color: var(--muted);
      cursor: pointer;
      line-height: 1.25;
      letter-spacing: 0.02em;
      text-transform: none;
    }

    .help-hd-actions {
      display: flex;
      align-items: center;
      gap: 8px;
      flex-shrink: 0;
      margin-left: auto;
    }

    .panel-help-hd .btn-help-close:hover,
    .panel-help-hd .btn-help-action:hover {
      background: var(--bg);
      color: var(--text);
      border-color: var(--hover-border);
    }

    .modal-tip {
      max-width: 360px;
    }

    .tip-modal-bd {
      text-align: center;
    }

    .tip-qr {
      display: block;
      max-width: 100%;
      height: auto;
      margin: 0 auto;
      border-radius: 8px;
      border: 1px solid var(--border);
    }

    @media (max-width: 720px) {
      main.help-open.mode-focus {
        grid-template-columns: 1fr;
        grid-template-rows: minmax(0, 1fr) minmax(160px, 38vh);
      }

      main.help-open.mode-focus .panel-outline {
        display: none;
      }

      main.help-open.mode-focus .panel-editor {
        grid-column: 1;
        grid-row: 1;
        max-width: none;
      }

      main.help-open.mode-focus .panel-help {
        grid-column: 1;
        grid-row: 2;
      }

      main.help-open.outline-collapsed.mode-focus {
        grid-template-columns: 1fr;
        grid-template-rows: minmax(0, 1fr) minmax(160px, 38vh);
      }

      main.help-open.outline-collapsed.mode-focus .panel-editor {
        grid-column: 1;
        grid-row: 1;
      }

      main.help-open.outline-collapsed.mode-focus .panel-help {
        grid-column: 1;
        grid-row: 2;
      }
    }

    .help-loading {
      margin: 0.35em 0;
      font-size: 13px;
      color: var(--muted);
    }
