/* ===== 基础变量与重置 ===== */
:root {
  color-scheme: light;

  --bg: #f4f5f7;
  --panel: #ffffff;
  --panel-soft: #fafafa;
  --border: #e5e7eb;
  --border-strong: #c7cbd1;
  --text: #1f2328;
  --text-weak: #6b7280;
  --text-mute: #9ca3af;

  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-text: #2563eb;
  --primary-weak: #eff6ff;
  --primary-weak-border: #bfdbfe;

  --danger: #dc2626;
  --danger-weak: #fef2f2;

  --editor-bg: #ffffff;
  --hover: #f3f4f6;
  --hover-soft: #f9fafb;
  --input-bg: #f3f4f6;
  --scrollbar: #d1d5db;
  --scrollbar-hover: #9ca3af;

  --overlay: rgba(17, 24, 39, .45);
  --shadow-panel: 0 16px 48px rgba(0, 0, 0, .18);

  --mark-bg: #fde68a;
  --mark-text: #92400e;
  --warn-text: #b45309;
  --storage-bar: #e5e7eb;
  --storage-fill: linear-gradient(90deg, #3b82f6, #6366f1);

  /* Markdown 正文 */
  --md-text: #24292f;
  --md-weak: #57606a;
  --md-line: #d8dee4;
  --md-quote-line: #d0d7de;
  --md-table-line: #d0d7de;
  --md-soft: #f6f8fa;
  --md-code-bg: rgba(175, 184, 193, .2);
  --md-link: #0969da;
  --md-code-block-bg: #f6f8fa;
  --md-ok: #1a7f37;
  --md-copy-bg: #ffffff;
  --md-copy-border: #d0d7de;
  --md-copy-text: #57606a;
  --md-diagram-bg: #fbfcfe;
  --md-diagram-line: #e5e7eb;

  /* front matter */
  --fm-bg: #fafbfc;
  --fm-line: #eef0f3;
  --fm-head-bg: #f3f4f6;
  --fm-head-text: #8c959f;
  --fm-key: #57606a;

  --radius: 8px;
  --mono: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
}

/* ===== 暗黑模式（取色参考 VS Code Dark+） ===== */
[data-theme="dark"] {
  color-scheme: dark;

  --bg: #181818;
  --panel: #252526;
  --panel-soft: #1f1f1f;
  --border: #3c3c3c;
  --border-strong: #4b4b4b;
  --text: #d4d4d4;
  --text-weak: #a9a9a9;
  --text-mute: #858585;

  --primary: #0e639c;
  --primary-hover: #1177bb;
  --primary-text: #3794ff;
  --primary-weak: #04395e;
  --primary-weak-border: #0e639c;

  --danger: #f14c4c;
  --danger-weak: rgba(241, 76, 76, .14);

  --editor-bg: #1e1e1e;
  --hover: #2a2d2e;
  --hover-soft: #2d2d2d;
  --input-bg: #3c3c3c;
  --scrollbar: #4b4b4b;
  --scrollbar-hover: #5f5f5f;

  --overlay: rgba(0, 0, 0, .6);
  --shadow-panel: 0 16px 48px rgba(0, 0, 0, .55);

  --mark-bg: #613214;
  --mark-text: #e2c08d;
  --warn-text: #d7ba7d;
  --storage-bar: #3c3c3c;
  --storage-fill: linear-gradient(90deg, #007acc, #4daafc);

  --md-text: #d4d4d4;
  --md-weak: #9d9d9d;
  --md-line: #3c3c3c;
  --md-quote-line: #4b4b4b;
  --md-table-line: #3c3c3c;
  --md-soft: #2d2d2d;
  --md-code-bg: rgba(255, 255, 255, .1);
  --md-link: #3794ff;
  --md-code-block-bg: #252526;
  --md-ok: #3fb950;
  --md-copy-bg: #2d2d2d;
  --md-copy-border: #4b4b4b;
  --md-copy-text: #c8c8c8;
  --md-diagram-bg: #1e1e1e;
  --md-diagram-line: #3c3c3c;

  --fm-bg: #1e1e1e;
  --fm-line: #2d2d2d;
  --fm-head-bg: #2d2d2d;
  --fm-head-text: #9d9d9d;
  --fm-key: #9cdcfe;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Helvetica, Arial, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  overflow: hidden;
}

button {
  font-family: inherit;
}

/* ===== 整体布局 ===== */
.app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ===== 左侧栏 ===== */
.sidebar {
  display: flex;
  flex-direction: column;
  width: 280px;
  min-width: 280px;
  height: 100%;
  overflow: hidden;
  background: var(--panel);
  border-right: 1px solid var(--border);
  transition: width .2s ease, min-width .2s ease;
}

/* 收起后宽度归零，右侧编辑器自动占满剩余空间 */
.omd-sidebar-collapsed .sidebar {
  width: 0;
  min-width: 0;
  border-right-width: 0;
}

.sidebar__header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

/* 收起动画期间保持内部区块原始高度，避免内容被挤压重排 */
.sidebar__header,
.sidebar__tools,
.sidebar__footer {
  flex: none;
}

.logo {
  flex: none;
}

/* 侧边栏收起按钮 */
.sidebar__collapse {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  margin-left: auto;
  padding: 0;
  color: var(--text-weak);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  transition: color .15s ease, background .15s ease, border-color .15s ease;
}

.sidebar__collapse:hover {
  color: var(--primary-text);
  background: var(--hover);
  border-color: var(--border);
}

.brand {
  min-width: 0;
}

.brand__name {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: .3px;
  white-space: nowrap;
}

.brand__desc {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--text-mute);
}

/* 搜索区 */
.sidebar__tools {
  padding: 12px 12px 8px;
  border-bottom: 1px solid var(--border);
}

.search {
  position: relative;
  display: flex;
  align-items: center;
}

.search__icon {
  position: absolute;
  left: 9px;
  color: var(--text-mute);
  pointer-events: none;
}

.search__input {
  width: 100%;
  height: 32px;
  padding: 0 28px 0 30px;
  font-size: 13px;
  color: var(--text);
  background: var(--input-bg);
  border: 1px solid transparent;
  border-radius: var(--radius);
  outline: none;
}

.search__input:focus {
  background: var(--panel);
  border-color: var(--primary);
}

.search__clear {
  position: absolute;
  right: 6px;
  width: 20px;
  height: 20px;
  padding: 0;
  font-size: 16px;
  line-height: 1;
  color: var(--text-mute);
  background: none;
  border: none;
  border-radius: 50%;
  cursor: pointer;
}

.search__clear:hover {
  color: var(--text);
  background: var(--border);
}

.sidebar__tools-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
}

.list-count {
  font-size: 12px;
  color: var(--text-mute);
}

/* 文件列表（可滚动） */
.sidebar__list {
  flex: 1;
  min-height: 0;
  padding: 8px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.sidebar__list::-webkit-scrollbar {
  width: 8px;
}

.sidebar__list::-webkit-scrollbar-thumb {
  background: var(--scrollbar);
  border: 2px solid var(--panel);
  border-radius: 8px;
}

.sidebar__list::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-hover);
}

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

.file-item {
  position: relative;
  padding: 9px 28px 9px 10px;
  margin-bottom: 4px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
}

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

.file-item.is-active {
  background: var(--primary-weak);
  border-color: var(--primary-weak-border);
}

.file-item__title {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-item.is-active .file-item__title {
  color: var(--primary-text);
}

.file-item__snippet {
  margin-top: 3px;
  font-size: 12px;
  color: var(--text-weak);
  line-height: 1.5;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-item__time {
  margin-top: 4px;
  font-size: 11px;
  color: var(--text-mute);
}

.file-item__del {
  position: absolute;
  top: 8px;
  right: 6px;
  display: none;
  width: 20px;
  height: 20px;
  padding: 0;
  color: var(--text-mute);
  background: none;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

.file-item:hover .file-item__del {
  display: block;
}

.file-item__del:hover {
  color: var(--danger);
  background: var(--danger-weak);
}

.list-empty {
  padding: 32px 8px;
  font-size: 13px;
  color: var(--text-mute);
  text-align: center;
}

mark {
  padding: 0 1px;
  color: var(--mark-text);
  background: var(--mark-bg);
  border-radius: 2px;
}

/* 底部：占用信息 */
.sidebar__footer {
  flex: none;
  padding: 10px 14px 12px;
  border-top: 1px solid var(--border);
  background: var(--panel-soft);
}

.storage__bar {
  height: 6px;
  overflow: hidden;
  background: var(--storage-bar);
  border-radius: 999px;
}

.storage__used {
  display: block;
  width: 0;
  height: 100%;
  background: var(--storage-fill);
  border-radius: 999px;
  transition: width .25s ease;
}

.storage__text {
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-weak);
}

.warning {
  margin: 8px 0 0;
  font-size: 11px;
  line-height: 1.6;
  color: var(--text-mute);
}

.warning b {
  color: var(--warn-text);
}

/* ===== 右侧主区域 ===== */
.main {
  position: relative;
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
  height: 100%;
}

.editor-bar {
  display: flex;
  flex: none;
  align-items: center;
  gap: 12px;
  height: 48px;
  padding: 0 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.doc-title {
  flex: 1;
  min-width: 0;
  height: 32px;
  padding: 0 8px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  outline: none;
}

/* 侧边栏收起后显示在标题栏左侧的展开按钮 */
.sidebar-expand {
  display: none;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  color: var(--text-weak);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: color .15s ease, background .15s ease, border-color .15s ease;
}

.sidebar-expand:hover {
  color: var(--primary-text);
  background: var(--primary-weak);
  border-color: var(--primary-weak-border);
}

.omd-sidebar-collapsed .sidebar-expand {
  display: inline-flex;
}

.doc-title:hover {
  background: var(--hover);
}

.doc-title:focus {
  background: var(--editor-bg);
  border-color: var(--primary);
}

.editor-bar__right {
  display: flex;
  flex: none;
  align-items: center;
  gap: 8px;
}

/* 未打开文档时只保留「更多工具」入口，其余控件连同标题一起隐藏 */
.editor-bar.is-empty .doc-title,
.editor-bar.is-empty .save-status,
.editor-bar.is-empty #btn-export,
.editor-bar.is-empty #btn-delete {
  display: none;
}

/* 返回「更多工具」快捷入口 */
.editor-bar__back {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 4px;
  height: 26px;
  padding: 0 10px;
  color: var(--text-weak);
  background: var(--hover-soft);
  border: 1px solid var(--border);
  border-radius: 13px;
  font-size: 12px;
  white-space: nowrap;
  text-decoration: none;
  transition: color .15s ease, background .15s ease, border-color .15s ease;
}

.editor-bar__back:hover {
  color: var(--primary);
  background: var(--primary-weak);
  border-color: var(--primary-weak-border);
}

.save-status {
  font-size: 12px;
  color: var(--text-mute);
}

.save-status.is-dirty {
  color: var(--warn-text);
}

.editor-host {
  flex: 1;
  min-height: 0;
  padding: 0;
  overflow: hidden;
}

.editor-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.editor-empty__title {
  margin: 12px 0 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-weak);
}

.editor-empty__desc {
  margin: 0;
  font-size: 13px;
  color: var(--text-mute);
}

/* ===== bytemd 容器适配 ===== */
.editor-host .bytemd {
  height: 100%;
  color: var(--text);
  background: var(--editor-bg);
  border: none;
  border-radius: 0;
}

.editor-host .bytemd-toolbar {
  background: var(--panel);
  border-bottom-color: var(--border);
}

.editor-host .bytemd-toolbar-icon:hover {
  background: var(--hover);
}

.editor-host .bytemd-toolbar-tab-active,
.editor-host .bytemd-toolbar-icon-active {
  color: var(--primary-text);
}

.editor-host .bytemd-split .bytemd-preview {
  border-left-color: var(--border);
}

.editor-host .bytemd-status {
  position: relative;
  background: var(--panel);
  border-top-color: var(--border);
}

/* 状态栏正中的站点署名，与「字数 / 行数」「暗黑模式」同一行 */
.editor-host .omd-status-brand {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  /* 备案信息比原来的“核心编程 - www.hxstrive.com”长得多，放宽居中区宽度；
     上限取 55%，左右各留约 22% 给 bytemd 状态栏两侧的浮动内容，避免文字压到“暗黑模式”开关上 */
  max-width: 55%;
  overflow: hidden;
  font-size: 12px;
  line-height: 24px;
  color: var(--text-mute);
  white-space: nowrap;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 备案信息来自后台参数，自带内联白色（原本给深色页脚用），这里统一跟随状态栏配色，保证浅色主题下可见 */
.editor-host .omd-status-brand,
.editor-host .omd-status-brand span {
  color: var(--text-mute) !important;
}

.editor-host .omd-status-brand a {
  color: var(--text-mute) !important;
  text-decoration: none !important;
}

.editor-host .omd-status-brand a:hover {
  color: var(--primary-text) !important;
  text-decoration: underline !important;
}

/* 备案图标（公安备案带底座图）与文字居中对齐 */
.editor-host .omd-status-brand img {
  vertical-align: middle;
}

.editor-host .bytemd-status-right span:hover {
  color: var(--primary-text);
}

.editor-host .bytemd-sidebar {
  background: var(--panel);
  border-left-color: var(--border);
}

.editor-host .bytemd-toc-active {
  color: var(--primary-text);
  background: var(--md-soft);
}

/* 状态栏里的「暗黑模式」开关，与「滚动同步」并排 */
.editor-host .omd-theme-toggle {
  margin-right: 16px;
  cursor: pointer;
}

.editor-host .omd-theme-toggle input {
  margin-right: 3px;
  vertical-align: middle;
  accent-color: var(--primary-text);
  cursor: pointer;
}

/* CodeMirror（编辑区）跟随主题 */
.editor-host .CodeMirror {
  color: var(--md-text);
  background: var(--editor-bg);
}

.editor-host .CodeMirror-cursor {
  border-left-color: var(--md-text);
}

.editor-host .CodeMirror-gutters {
  background: var(--editor-bg);
  border-right-color: var(--border);
}

.editor-host .CodeMirror-gutter-filler,
.editor-host .CodeMirror-scrollbar-filler {
  background: var(--editor-bg);
}

[data-theme="dark"] .editor-host .CodeMirror-selected,
[data-theme="dark"] .editor-host .CodeMirror-line::selection,
[data-theme="dark"] .editor-host .CodeMirror-line > span::selection,
[data-theme="dark"] .editor-host .CodeMirror-line > span > span::selection {
  background: rgba(38, 79, 120, .99);
}

/* 隐藏右上角“查看源码”按钮（内置按钮，点击跳转到 GitHub） */
.editor-host .bytemd-toolbar-right .bytemd-toolbar-icon[bytemd-tippy-path="5"] {
  display: none;
}

/* ===== 按钮 ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 32px;
  padding: 0 12px;
  font-size: 13px;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: all .15s ease;
}

.btn:hover {
  border-color: var(--border-strong);
  background: var(--hover-soft);
}

.btn--sm {
  height: 28px;
  padding: 0 10px;
  font-size: 12px;
}

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

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

.btn--danger {
  color: var(--danger);
}

.btn--danger:hover {
  color: #fff;
  background: var(--danger);
  border-color: var(--danger);
}

/* ===== 弹窗 ===== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--overlay);
}

.modal[hidden] {
  display: none;
}

.modal__panel {
  width: 360px;
  max-width: calc(100vw - 32px);
  padding: 20px;
  background: var(--panel);
  border-radius: 12px;
  box-shadow: var(--shadow-panel);
}

.modal__title {
  margin: 0 0 8px;
  font-size: 15px;
  font-weight: 600;
}

.modal__text {
  margin: 0 0 18px;
  font-size: 13px;
  line-height: 1.7;
  color: var(--text-weak);
}

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

/* ===== Markdown 预览排版（bytemd 未内置 markdown-body 样式） ===== */
.markdown-body {
  font-size: 15px;
  line-height: 1.7;
  color: var(--md-text);
  word-wrap: break-word;
}

.markdown-body>*:first-child {
  margin-top: 0 !important;
}

.markdown-body>*:last-child {
  margin-bottom: 0 !important;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
  margin: 24px 0 16px;
  font-weight: 600;
  line-height: 1.3;
}

.markdown-body h1 {
  padding-bottom: .3em;
  font-size: 1.9em;
  border-bottom: 1px solid var(--md-line);
}

.markdown-body h2 {
  padding-bottom: .3em;
  font-size: 1.45em;
  border-bottom: 1px solid var(--md-line);
}

.markdown-body h3 {
  font-size: 1.2em;
}

.markdown-body h4 {
  font-size: 1em;
}

.markdown-body h5 {
  font-size: .9em;
}

.markdown-body h6 {
  font-size: .85em;
  color: var(--md-weak);
}

.markdown-body p,
.markdown-body ul,
.markdown-body ol,
.markdown-body blockquote,
.markdown-body table,
.markdown-body pre {
  margin-top: 0;
  margin-bottom: 16px;
}

.markdown-body ul,
.markdown-body ol {
  padding-left: 2em;
}

.markdown-body li+li {
  margin-top: .25em;
}

.markdown-body li>ul,
.markdown-body li>ol {
  margin: .25em 0 0;
}

.markdown-body blockquote {
  /* 浏览器默认给 blockquote 一个 40px 的左右外边距，需要清掉，否则会显得整块居中 */
  margin: 0 0 16px;
  padding: 2px 0 2px 1em;
  color: var(--md-weak);
  border-left: .25em solid var(--md-quote-line);
}

/* 数学公式（KaTeX，与 playground 一致） */
.markdown-body .katex {
  font-size: 1.05em;
}

.markdown-body .katex-display {
  margin: 14px 0 16px;
  overflow-x: auto;
  overflow-y: hidden;
}

.markdown-body .math-inline,
.markdown-body .math-display {
  overflow-x: auto;
}

/* Mermaid 图表（与 playground 一致：容器 class 为 bytemd-mermaid） */
.bytemd-mermaid {
  margin: 0 0 16px;
  padding: 10px;
  overflow-x: auto;
  text-align: center;
  line-height: initial;
  background: var(--md-diagram-bg);
  border: 1px solid var(--md-diagram-line);
  border-radius: 10px;
}

.bytemd-mermaid svg {
  max-width: 100%;
  height: auto;
}

/* 数学公式（LaTeX → MathML，官方插件不可用时的兜底渲染） */
.markdown-body math {
  font-size: 1.05em;
}

.math-inline {
  display: inline-block;
  vertical-align: baseline;
}

.math-block {
  margin: 14px 0 16px;
  overflow-x: auto;
  text-align: center;
}

.math-block math {
  max-width: 100%;
}

/* 图表（mermaid 精简实现） */
.diagram {
  margin: 0 0 16px;
  padding: 10px;
  overflow-x: auto;
  text-align: center;
  background: var(--md-diagram-bg);
  border: 1px solid var(--md-diagram-line);
  border-radius: 10px;
}

.diagram svg {
  max-width: 100%;
  height: auto;
}

.markdown-body blockquote> :last-child {
  margin-bottom: 0;
}

.markdown-body a {
  color: var(--md-link);
  text-decoration: none;
}

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

.markdown-body hr {
  height: .25em;
  margin: 24px 0;
  background: var(--md-line);
  border: 0;
}

.markdown-body img {
  max-width: 100%;
  border-radius: 6px;
}

.markdown-body code {
  padding: .2em .4em;
  font-family: var(--mono);
  font-size: 85%;
  background: var(--md-code-bg);
  border-radius: 6px;
}

.markdown-body pre {
  position: relative;
  padding: 16px;
  overflow: auto;
  font-size: 85%;
  line-height: 1.6;
  background: var(--md-code-block-bg);
  border-radius: 8px;
}

.markdown-body pre code {
  padding: 0;
  font-size: 100%;
  background: transparent;
  border-radius: 0;
}

.markdown-body table {
  display: block;
  width: max-content;
  max-width: 100%;
  overflow: auto;
  border-collapse: collapse;
  border-spacing: 0;
}

.markdown-body th,
.markdown-body td {
  padding: 6px 13px;
  border: 1px solid var(--md-table-line);
}

.markdown-body th {
  font-weight: 600;
  background: var(--md-soft);
}

.markdown-body tr:nth-child(2n) td {
  background: var(--md-soft);
}

/* 顶部 YAML front matter：渲染成一张低调的键值表 */
.markdown-body .omd-frontmatter {
  display: table;
  width: 100%;
  max-width: 100%;
  margin: 0 0 20px;
  font-size: 13px;
  line-height: 1.55;
  background: var(--fm-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
}

.markdown-body .omd-frontmatter th,
.markdown-body .omd-frontmatter td {
  padding: 5px 12px;
  text-align: left;
  vertical-align: top;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--fm-line);
}

.markdown-body .omd-frontmatter thead th {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .04em;
  color: var(--fm-head-text);
  background: var(--fm-head-bg);
}

.markdown-body .omd-frontmatter tbody td:first-child {
  width: 1%;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--fm-key);
  white-space: nowrap;
}

.markdown-body .omd-frontmatter tbody td:last-child {
  word-break: break-word;
}

.markdown-body .omd-frontmatter tr:last-child td {
  border-bottom: 0;
}

.markdown-body .omd-frontmatter tr:nth-child(2n) td {
  background: transparent;
}

.markdown-body input[type="checkbox"] {
  margin-right: .35em;
  vertical-align: middle;
}

.markdown-body .contains-task-list,
.markdown-body li.task-list-item {
  list-style: none;
}

.markdown-body li.task-list-item {
  margin-left: -1.4em;
}

.markdown-body li.task-list-item input[type="checkbox"] {
  margin-right: .4em;
}

/* 代码块增强（复制按钮 / 语言标签） */
.code-block {
  position: relative;
  margin-bottom: 16px;
}

.code-block pre {
  margin-bottom: 0;
}

.code-block__lang {
  position: absolute;
  top: 6px;
  right: 62px;
  font-size: 11px;
  color: var(--fm-head-text);
  pointer-events: none;
}

.code-block__copy {
  position: absolute;
  top: 6px;
  right: 8px;
  height: 22px;
  padding: 0 8px;
  font-size: 11px;
  color: var(--md-copy-text);
  background: var(--md-copy-bg);
  border: 1px solid var(--md-copy-border);
  border-radius: 5px;
  cursor: pointer;
  opacity: 0;
  transition: opacity .15s ease;
}

.code-block:hover .code-block__copy {
  opacity: 1;
}

.code-block__copy:hover {
  color: var(--md-link);
  border-color: var(--md-link);
}

.code-block__copy.is-done {
  color: var(--md-ok);
  border-color: var(--md-ok);
  opacity: 1;
}

/* 代码高亮：着色由官方 @bytemd/plugin-highlight（highlight.js）完成，
   配色来自 highlight.js 主题（浅色 github / 暗色 vs2015），随主题切换 <link> 的 href。
   这里只兜住主题自带的内边距，避免和 preview 的 pre 样式打架。 */
.markdown-body pre code.hljs {
  padding: 0;
  background: transparent;
}

/* ===== 暗黑模式：CodeMirror 语法着色（对齐 VS Code Dark+） ===== */
[data-theme="dark"] .editor-host .cm-s-default .cm-header,
[data-theme="dark"] .editor-host .cm-s-default .cm-keyword,
[data-theme="dark"] .editor-host .cm-s-default .cm-operator,
[data-theme="dark"] .editor-host .cm-s-default .cm-word {
  color: #569cd6;
}

[data-theme="dark"] .editor-host .cm-s-default .cm-atom,
[data-theme="dark"] .editor-host .cm-s-default .cm-number {
  color: #b5cea8;
}

[data-theme="dark"] .editor-host .cm-s-default .cm-comment {
  color: #6a9955;
}

[data-theme="dark"] .editor-host .cm-s-default .cm-string,
[data-theme="dark"] .editor-host .cm-s-default .cm-string-2 {
  color: #ce9178;
}

[data-theme="dark"] .editor-host .cm-s-default .cm-def,
[data-theme="dark"] .editor-host .cm-s-default .cm-variable,
[data-theme="dark"] .editor-host .cm-s-default .cm-variable-2,
[data-theme="dark"] .editor-host .cm-s-default .cm-variable-3,
[data-theme="dark"] .editor-host .cm-s-default .cm-property,
[data-theme="dark"] .editor-host .cm-s-default .cm-attribute,
[data-theme="dark"] .editor-host .cm-s-default .cm-qualifier {
  color: #9cdcfe;
}

[data-theme="dark"] .editor-host .cm-s-default .cm-builtin,
[data-theme="dark"] .editor-host .cm-s-default .cm-tag {
  color: #4ec9b0;
}

[data-theme="dark"] .editor-host .cm-s-default .cm-link,
[data-theme="dark"] .editor-host .cm-s-default .cm-url {
  color: #3794ff;
}

[data-theme="dark"] .editor-host .cm-s-default .cm-quote {
  color: #6a9955;
}

[data-theme="dark"] .editor-host .cm-s-default .cm-meta,
[data-theme="dark"] .editor-host .cm-s-default .cm-bracket {
  color: #d4d4d4;
}

[data-theme="dark"] .editor-host .cm-s-default .cm-hr {
  color: #808080;
}

[data-theme="dark"] .editor-host .cm-s-default .cm-error {
  color: #f14c4c;
}

/* ===== 窄屏适配 ===== */
@media (max-width: 820px) {
  .sidebar {
    width: 220px;
    min-width: 220px;
  }

  .brand__desc {
    display: none;
  }
}

/* 窗口不够宽时收起状态栏中间的署名，避免压到右侧开关 */
@media (max-width: 940px) {
  .editor-host .omd-status-brand {
    display: none;
  }
}
