.findbar .rep-group { display: none; }
.findbar.replace-mode .rep-group { display: inline-flex; }
/* 极简学术风 */
:root {
  --bg: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --brand: #111827;
  --link: #0f766e;
  --border: #e5e7eb;
  --code-bg: #f8fafc;
  color-scheme: light; /* 强制仅浅色，避免跟随系统切换 */
}
html, body { background: var(--bg); color: var(--text); }
body { margin: 0; }
* { box-sizing: border-box; }
/* 移动端点击时的蓝色透明高亮（tap highlight）处理 */
* { -webkit-tap-highlight-color: transparent; }
/* 可按需仅作用于可点击元素：
a, button { -webkit-tap-highlight-color: transparent; }
*/
/* 字体策略：拉丁字符与数字优先使用无衬线；中文优先使用衬线（宋体系） */

.container { max-width: 920px; margin: 0 auto; padding: 0 16px; }

.site-header { border-bottom: 1px solid var(--border); position: sticky; top: 0; background: rgba(255,255,255,.92); backdrop-filter: saturate(180%) blur(8px); z-index: 10; }
.site-header .container { display: flex; align-items: center; justify-content: space-between; height: 52px; }
.brand { font-weight: 700; color: var(--brand); text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.brand img { height: 22px; width: auto; margin: 0; border-radius: 0; }
.nav { display: flex; align-items: center; gap: 12px; }
.nav a { color: var(--link); text-decoration: none; display: inline-flex; align-items: center; line-height: 1; }
.nav a img { height: 20px; width: auto; display: block; margin-right: 4px; }
/* 确保图标类链接的包裹器也参与居中对齐 */
.nav a .lazy-wrapper { display: inline-flex; align-items: center; }
.search { margin-left: 12px; }
.search-input { width: 220px; max-width: 36vw; padding: 6px 10px; border: 1px solid var(--border); border-radius: 6px; }
.lang-switch { margin-left: 8px; display: flex; align-items: center; }
.lang-switch select { padding: 6px 8px; border: 1px solid var(--border); background: #fff; border-radius: 6px; font-size: 14px; color: #334155; }
.lang-switch select:focus { outline: 2px solid #0f766e33; }
.sidebar .lang-switch { margin-top: 12px; margin-left: 0; }
.sidebar .lang-switch select { width: 100%; }

/* 移动端导航：汉堡菜单与侧边栏 */
.menu-btn { display: none; background: transparent; border: 0; width: 36px; height: 36px; border-radius: 6px; cursor: pointer; align-items: center; justify-content: center; }
.menu-btn .bar { display: block; width: 20px; height: 2px; background: #334155; margin: 3px 0; }
.sidebar-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.35); opacity: 0; visibility: hidden; transition: opacity .2s ease, visibility .2s ease; z-index: 40; }
.sidebar-backdrop.show { opacity: 1; visibility: visible; }
.sidebar { position: fixed; top: 0; right: 0; width: 80vw; max-width: 360px; height: 100vh; background: #fff; box-shadow: -2px 0 12px rgba(0,0,0,.08); transform: translateX(100%); transition: transform .2s ease; z-index: 41; padding: 16px; display: flex; flex-direction: column; }
.sidebar.open { transform: translateX(0); }
.sidebar .title { font-weight: 700; color: var(--brand); margin: 4px 0 12px; }
.sidebar .links { display: flex; flex-direction: column; gap: 10px; margin: 12px 0; }
.sidebar .links a { color: var(--link); text-decoration: none; }
.sidebar .links a img { height: 20px; width: auto; vertical-align: middle; margin-right: 6px; }
.sidebar .search-input { width: 100%; max-width: none; margin-top: 8px; }
/* 移动端侧边栏：优化链接分组样式（文本链接 + 图标链接） */
.sidebar .links-main { display: flex; flex-direction: column; gap: 10px; margin: 12px 0; }
.sidebar .links-main a { display: block; color: var(--link); text-decoration: none; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
.sidebar .links-main a:hover { background: #f8fafc; }
.sidebar .links-icons { display: flex; align-items: center; gap: 12px; margin: 8px 0 4px; }
.sidebar .links-icons a { width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--border); border-radius: 50%; background: #fff; }
.sidebar .links-icons a img { height: 20px; width: 20px; margin: 0; }
@media (max-width: 720px) {
  .nav { display: none; }
  .menu-btn { display: flex; }
}

/* 禁止双击缩放触发（在支持的浏览器上进一步减少缩放手势） */
html { touch-action: manipulation; }

.site-footer { margin-top: 40px; padding: 24px 0; border-top: 1px solid var(--border); color: var(--muted); font-size: 14px; }

/* 轮播图样式 */
.carousel { position: relative; width: min(886px, 100%); aspect-ratio: 886 / 300; margin: 20px auto 8px; border-radius: 12px; overflow: hidden; background: #f1f5f9; border: 1px solid var(--border); }
.carousel-track { display: flex; transition: transform .6s ease; width: 100%; height: 100%; }
.carousel-item { position: relative; min-width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; background: #e2e8f0; color: #334155; font-size: 28px; font-weight: 600; }
.carousel-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.carousel-caption { position: absolute; left: 0; bottom: 0; right: 0; padding: 12px 18px; background: linear-gradient(to top, rgba(0,0,0,.55), rgba(0,0,0,.15)); color: #fff; font-size: 16px; font-weight: 500; }
.carousel-nav { position: absolute; inset: 0; display: flex; align-items: center; justify-content: space-between; pointer-events: none; }
.carousel-btn { pointer-events: auto; background: rgba(0,0,0,.45); color: #fff; border: none; width: 40px; height: 40px; border-radius: 50%; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 18px; backdrop-filter: blur(4px); }
.carousel-btn:hover { background: rgba(0,0,0,.65); }
.carousel-dots { position: absolute; left: 0; right: 0; bottom: 10px; display: flex; align-items: center; justify-content: center; gap: 6px; }
.carousel-dots button { width: 10px; height: 10px; border-radius: 50%; border: none; background: rgba(255,255,255,.55); cursor: pointer; padding: 0; }
.carousel-dots button.active { background: #fff; box-shadow: 0 0 0 2px rgba(0,0,0,.25); }
@media (max-width: 720px) { .carousel-item { font-size: 20px; } }

/* 图片懒加载包装与加载中动画 */
.lazy-wrapper { position: relative; display: inline-block; }
.lazy-wrapper img { display: block; }
.lazy-spinner { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: radial-gradient(circle at center, rgba(255,255,255,.85), rgba(255,255,255,.55)); }
.lazy-spinner::after { content: ""; width: 34px; height: 34px; border: 4px solid #94a3b8; border-top-color: #0f766e; border-radius: 50%; animation: spin 0.9s linear infinite; }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* 确保轮播内懒加载包装占满容器，避免高度塌陷 */
.carousel .lazy-wrapper { display: block; width: 100%; height: 100%; }
.carousel .lazy-wrapper img { width: 100%; height: 100%; object-fit: cover; display: block; }

h1, h2, h3, h4 { color: var(--brand); }
a { color: var(--link); }
blockquote { margin: 1em 0; padding: .5em 1em; border-left: 3px solid var(--border); background: #fafafa; }
pre { background: var(--code-bg); padding: 12px; overflow: auto; border-radius: 6px; font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; }
code { background: var(--code-bg); padding: 2px 4px; border-radius: 4px; font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; }
hr { border: none; border-top: 1px solid var(--border); margin: 24px 0; }

.post-list { list-style: none; padding: 0; margin: 24px 0; }
.post-list li { padding: 16px 0; border-bottom: 1px solid var(--border); }
.post-list a { text-decoration: none; color: inherit; }
.post-meta { color: var(--muted); font-size: 14px; }

/* 分页 */
.pager { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; margin: 16px 0 8px; }
.pager .left { justify-self: start; }
.pager .center { justify-self: center; color: var(--muted); font-size: 14px; }
.pager .right { justify-self: end; }
.pager button { padding: 6px 10px; border: 1px solid var(--border); border-radius: 6px; background: #fff; cursor: pointer; }
.pager button:disabled { opacity: .5; cursor: not-allowed; }

.post { margin: 24px 0; }
.post .title { margin: 0 0 8px; }
.post .meta { color: var(--muted); font-size: 14px; margin-bottom: 16px; }
.post .content :is(img, video) { max-width: 100%; height: auto; }

.loading { color: var(--muted); padding: 32px 0; }

.katex-display { overflow-x: auto; }

/* Markdown 细节样式增强 */
/* 无序列表：统一用“·”作为项目符号，更清晰 */
.markdown-body ul { list-style: none; margin: 0.6em 0 0.6em 1.2em; padding-left: 0; }
.markdown-body ul ul { margin-left: 1.2em; }
/* 仅普通无序列表项使用自定义点，不影响任务清单 */
.markdown-body ul:not(.task-list) > li { position: relative; margin: 6px 0; padding-left: 1.1em; }
.markdown-body ul:not(.task-list) > li::before { content: '·'; position: absolute; left: 0; top: 0.15em; color: #334155; font-weight: 700; line-height: 1; }
/* 任务清单项不显示点或序号 */
.markdown-body .task-list li::before { content: none !important; }

/* 有序列表：使用 data-ol-index 控制序号显示，配合后端重写，不受段落打断影响 */
.markdown-body ol { list-style: none !important; margin: 0.6em 0 0.6em 1.6em; padding-left: 0; }
.markdown-body ol > li { position: relative; margin: 6px 0; padding-left: 1.6em; }
.markdown-body ol > li::before {
  content: attr(data-ol-index) '. ';
  position: absolute; left: 0; top: 0; color: #475569; font-weight: 600;
}
/* 嵌套的有序列表仍使用浏览器默认序号（不叠加自定义 ::before）*/
.markdown-body ol ol { list-style: decimal !important; margin-left: 1.2em; }
.markdown-body ol ol > li::before { content: none; }

.markdown-body li { margin: 4px 0; }

/* 任务列表（Task List）美化 */
.markdown-body ul.task-list,
.markdown-body .task-list { list-style: none; margin: 0.6em 0; padding-left: 0; }
.markdown-body .task-list-item { display: flex; align-items: flex-start; gap: 8px; margin: 6px 0; }
.markdown-body .task-list-item input[type="checkbox"] {
  margin-top: 3px; /* 与文本顶部对齐 */
  accent-color: var(--link);
  transform: scale(1.05);
}
.markdown-body .task-list-item p { margin: 0; }

/* 缩写（abbr）提示更明显 */
abbr[title] { text-decoration: underline dotted; cursor: help; }

/* 定义列表（Definition List）优化 */
.markdown-body dl { margin: 1em 0; }
.markdown-body dt { font-weight: 600; color: var(--brand); }
.markdown-body dd { margin: .25em 0 .9em 1.2em; padding-left: .75em; border-left: 2px solid var(--border); color: #374151; }
.markdown-body dd > :first-child { margin-top: 0; }
.markdown-body dd > :last-child { margin-bottom: 0; }

/* 表格样式 */
.markdown-body table { border-collapse: collapse; width: 100%; margin: 1em 0; }
.markdown-body th, .markdown-body td { border: 1px solid var(--border); padding: 8px 10px; }
.markdown-body thead th { background: #f5f7fa; color: var(--brand); }
.markdown-body tbody tr:nth-child(even) { background: #fafafa; }

/* 代码块工具条 */
.code-block { position: relative; margin: 16px 0; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.code-toolbar { display: flex; align-items: center; justify-content: space-between; height: var(--toolbar-h, 36px); padding: 0 10px; background: #f3f4f6; border-bottom: 1px solid var(--border); font-size: 12px; color: var(--muted); }
.code-lang { font-weight: 600; color: #475569; }
.copy-btn { appearance: none; border: 1px solid var(--border); background: #fff; color: #334155; padding: 2px 8px; border-radius: 4px; cursor: pointer; }
.copy-btn:hover { background: #f8fafc; }
.code-block pre { background: var(--code-bg); margin: 0; border-radius: 0; }
/* 代码块（无行号）保持正常内边距 */
.code-block pre code { line-height: 1.5; display: block; }

/* 提示块（admonition）与 details */
.admonition { border-left: 4px solid #64748b; background: #f8fafc; padding: 10px 12px; margin: 16px 0; border-radius: 4px; }
.admonition .admonition-title { font-weight: 600; margin-bottom: 6px; color: #334155; }
.admonition.note { border-left-color: #3b82f6; background: #eff6ff; }
.admonition.warning { border-left-color: #f59e0b; background: #fffbeb; }
details.admonition { padding: 0; }
details.admonition > summary { list-style: none; cursor: pointer; padding: 10px 12px; background: #f3f4f6; border-radius: 4px; }
details.admonition[open] > summary { border-bottom: 1px solid var(--border); border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
details.admonition > .admonition-content { padding: 10px 12px; }
/* 暗色模式下的提示块对比度与背景 */
body[data-theme="dark"] .admonition { background: #0f172a; border-left-color: #475569; }
body[data-theme="dark"] .admonition.note { border-left-color: #3b82f6; }
body[data-theme="dark"] .admonition.warning { border-left-color: #f59e0b; }
body[data-theme="dark"] details.admonition > summary { background: #0f172a; }

/* 缩写可视化 */
abbr[title] { text-decoration: underline dotted; cursor: help; }

/* 右侧目录布局（桌面显示，移动隐藏） */
.post-layout { display: flex; align-items: flex-start; gap: 24px; }
/* 正文允许换行压缩，但目录保持固定宽度不被挤压 */
.post-layout .markdown-body { flex: 1 1 auto; min-width: 0; }
.toc-side { flex: 0 0 260px; width: 260px; position: sticky; top: 72px; max-height: calc(100vh - 90px); overflow: auto; display: block; }
.toc-side .toc { font-size: 14px; line-height: 1.65; border: 1px solid var(--border); border-radius: 8px; padding: 12px; background: #fff; }
.toc-side .toc::before { content: "目录"; display: block; font-weight: 700; color: var(--brand); margin-bottom: 8px; font-size: 15px; }
.toc-side .toc ul { list-style: none; padding-left: 0; margin: 0; }
.toc-side .toc li { margin: 6px 0; }
.toc-side .toc li li { margin: 4px 0; }
.toc-side .toc ul ul { padding-left: 12px; border-left: 1px dotted var(--border); }
.toc-side .toc a { display: block; color: #334155; text-decoration: none; padding: 4px 8px; border-radius: 6px; }
.toc-side .toc a:hover { background: #f1f5f9; }
@media (max-width: 980px) { .toc-side { display: none; } }

/* 锚点高亮 */
.anchor-highlight { background: #fff3bf; box-shadow: inset 0 0 0 9999px rgba(255,243,191,0.4); transition: background .6s ease; }

/* —— MD 编辑器布局（极简） —— */
.editor-shell { display: grid; grid-template-rows: auto 1fr auto; min-height: 100vh; }
.toolbar { display: flex; align-items: center; gap: 12px; padding: 8px 18px; border-bottom: 1px solid var(--border); background: #fff; position: sticky; top: 0; z-index: 6; width: 100%; }
.tb-sep { width: 1px; height: 20px; background: var(--border); margin: 0 2px; }
.tb-spacer { flex: 1; }
.toolbar .tb-btn { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border: 1px solid transparent; border-radius: 4px; background: transparent; color: #1f2937; cursor: pointer; }
.toolbar .tb-btn:hover { background: #e5e7eb; border-color: #d1d5db; }
.toolbar .tb-btn:active { background: #dbe0e6; border-color: #cbd5e1; }
.toolbar .tb-btn .codicon { font-size: 16px; line-height: 1; }
.toolbar .tb-btn .label { font-size: 13px; }
@media (max-width: 720px) { .toolbar .tb-btn .label { display: none; } }
.tb-metrics { font-size: 12px; color: #475569; padding: 0 8px; line-height: 1; display: inline-flex; align-items: center; height: 28px; border: 1px solid var(--border); border-radius: 4px; background: #f8fafc; }
@media (max-width: 720px) { .tb-metrics { display: none; } }
.toolbar .brand { font-weight: 700; color: var(--brand); }
.toolbar button { padding: 6px 10px; border: 1px solid var(--border); border-radius: 6px; background: transparent; color: #1f2937; cursor: pointer; }
.toolbar button:hover { background: #f1f5f9; }

.workspace { display: grid; grid-template-columns: 1fr 1fr; min-height: 0; overflow: hidden; }
.pane { min-width: 0; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.editor { flex: 1; width: 100%; border: none; outline: none; padding: 16px; resize: none; font: var(--editor-font-size,14px)/var(--editor-line-height,1.6) var(--editor-font, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace); background: var(--bg); color: var(--text); overflow: auto; }
.preview { padding: 16px; overflow: auto; flex: 1; overflow-anchor: none; }
/* 整体不滚动，使用内部面板滚动，避免整页出现滚动条 */
body, html { height: 100%; overflow: hidden; }

/* 为标题锚点跳转预留顶部空间，避免被 sticky 工具栏遮挡 */
.markdown-body h1, .markdown-body h2, .markdown-body h3,
.markdown-body h4, .markdown-body h5, .markdown-body h6 { scroll-margin-top: 60px; }
/* 关闭全局平滑滚动，避免输入时浏览器做滚动锚定动画引起错觉“自动上翻” */
/* html { scroll-behavior: smooth; } */

@media (max-width: 960px) {
  .workspace { grid-template-columns: 1fr; grid-template-rows: 1fr 1fr; }
}

/* 让预览区图片、视频自适应 */
.markdown-body :is(img, video) { max-width: 100%; height: auto; }

.editor-footer { display:flex; align-items:center; justify-content:space-between; gap:12px; font-size: 12px; padding: 6px 10px; color: var(--muted); border-top: 1px solid var(--border); background: #fff; }
.footer-hotkeys { color: #64748b; }
.kbd { display:inline-block; min-width:1.6em; text-align:center; padding: 0 6px; line-height: 1.6; font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; font-size: 11px; color: #334155; background: #f1f5f9; border: 1px solid var(--border); border-bottom-color:#cbd5e1; border-radius: 4px; box-shadow: inset 0 -1px 0 #e2e8f0; }

/* Base64 省略提示样式（用于预览覆盖标记） */
.img-base64-note { display: inline-block; font-size: 11px; color: #64748b; background: #f1f5f9; border: 1px solid var(--border); padding: 2px 6px; margin-left: 6px; border-radius: 4px; vertical-align: middle; }

/* 编辑区顶部提示条 */
.pane-hint { padding: 6px 10px; font-size: 12px; color: #475569; background: #f1f5f9; border-bottom: 1px solid var(--border); }

/* 恢复有序列表默认编号（覆盖站点自定义 data-ol-index 方案） */
/* 有序列表：保持默认 decimal，避免与前面旧的 data-ol-index 方案冲突 */
.markdown-body ol { list-style: decimal; margin: 0.6em 0 0.6em 1.2em; padding-left: 1.2em; }
.markdown-body ol > li { padding-left: 0; }
.markdown-body ol > li::before { content: none; }

/* mark 高亮 */
mark, .markdown-body mark { background: #fff3bf; padding: 0 2px; border-radius: 2px; }

/* 自定义模态框 */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: grid; place-items: center; z-index: 1000; }
.modal-backdrop[hidden] { display: none; }
.modal-dialog { width: min(92vw, 440px); background: #fff; border-radius: 10px; border: 1px solid var(--border); box-shadow: 0 6px 24px rgba(0,0,0,.12); overflow: hidden; }
.modal-title { padding: 12px 14px; font-weight: 700; color: var(--brand); border-bottom: 1px solid var(--border); }
.modal-body { padding: 14px; color: #334155; line-height: 1.6; max-height: 64vh; overflow: auto; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--border); }
.modal-actions .btn-ok, .modal-actions .btn-cancel { padding: 6px 12px; border: 1px solid var(--border); background: #fff; border-radius: 6px; cursor: pointer; }
.modal-actions .btn-ok { background: #111827; color: #fff; border-color: #111827; }
.modal-actions .btn-ok:hover { filter: brightness(1.05); }
.modal-actions .btn-cancel:hover { background: #f8fafc; }

/* 任务清单（与脚本增强匹配） */
.markdown-body ul.task-list, .markdown-body .task-list { list-style: none; margin: .6em 0; padding-left: 0; }
.markdown-body .task-list-item { display: flex; align-items: flex-start; gap: 8px; margin: 6px 0; }

/* —— 深色主题 —— */
body[data-theme="dark"] {
  --bg: #0b1220;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --brand: #e5e7eb;
  --link: #22d3ee;
  --border: #253045;
  --code-bg: #0f172a;
  color-scheme: dark;
}
body[data-theme="dark"] .toolbar,
body[data-theme="dark"] .editor-footer,
body[data-theme="dark"] .pane-hint { background: #0f172a; border-color: var(--border); }
body[data-theme="dark"] .tb-metrics { background: #0b1220; border-color: var(--border); color: var(--muted); }
body[data-theme="dark"] .toolbar .tb-btn { color: var(--text); }
body[data-theme="dark"] .toolbar .tb-btn:hover { background: #111827; border-color: #222b3d; }
body[data-theme="dark"] .toolbar button { background: transparent; color: var(--text); border-color: var(--border); }
body[data-theme="dark"] .toolbar button:hover { background: #111827; }
body[data-theme="dark"] .preview { background: var(--bg); color: var(--text); }
body[data-theme="dark"] .markdown-body thead th { background: #0f172a; }
body[data-theme="dark"] .markdown-body tbody tr:nth-child(even) { background: #0b1220; }
body[data-theme="dark"] .modal-dialog { background: #0f172a; color: var(--text); border-color: var(--border); }
body[data-theme="dark"] .modal-title { border-bottom-color: var(--border); }
body[data-theme="dark"] .modal-actions { border-top-color: var(--border); }
body[data-theme="dark"] .modal-actions .btn-ok { background: #22d3ee; border-color: #22d3ee; color: #0b1220; }
body[data-theme="dark"] .modal-actions .btn-cancel { background: #0b1220; color: var(--text); border-color: var(--border); }

/* —— 查找/替换条 —— */
.findbar { display: none; align-items: center; gap: 6px; padding: 6px; border-bottom: 1px solid var(--border); background: var(--bg); }
.findbar.show { display: flex; }
.findbar input[type="text"] { height: 28px; padding: 4px 8px; border: 1px solid var(--border); border-radius: 4px; background: transparent; color: var(--text); }
.findbar .btn { height: 28px; padding: 0 8px; border: 1px solid var(--border); border-radius: 4px; background: transparent; color: var(--text); cursor: pointer; }
.findbar .btn:hover { background: #f8fafc; }
body[data-theme="dark"] .findbar .btn:hover { background: #111827; }
.findbar .chk { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-size: 12px; }
.findbar .sp { width: 1px; height: 20px; background: var(--border); margin: 0 4px; }
