/* 极简学术风 */
:root {
  --bg: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --brand: #111827;
  --link: #009966;
  --border: #e5e7eb;
  --code-bg: #f8fafc;
  --serif: "Noto Serif SC", "Source Han Serif SC", "Songti SC", STSong, "SimSun", Georgia, "Times New Roman", serif;
  color-scheme: light; /* 强制仅浅色，避免跟随系统切换 */
}
html, body { background: var(--bg); color: var(--text); }
* { 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 #00996633; }
.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: #009966; 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); }
/* 文章大标题、正文标题、目录与列表页标题使用衬线体 */
.post .title,
.post-list h3,
.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6,
.toc-side,
.toc-side .toc,
.toc-side .toc a { font-family: var(--serif); }
/* 正文六级标题统一柔和绿色 */
.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 { color: #009966; }
/* 正文整体行距提升到 1.5 */
.markdown-body { line-height: 1.5; }
a { color: var(--link); }
/* 正文链接：半透明加粗下划线并与文字有间距 */
.markdown-body a { text-decoration-line: underline; text-decoration-color: #009966; text-decoration-thickness: 2px; text-underline-offset: 3px; }
/* 加粗文字添加波浪下划线 */
.markdown-body strong, .markdown-body b { font-weight: 600; text-decoration-line: underline; text-decoration-style: wavy; text-decoration-color: #009966; text-underline-offset: 4px; }
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; }
/* 仅内联代码（非代码块）背景加深为同色系绿色 */
.markdown-body :not(pre) > code { background: #0099661f; color: #1f2937; }
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; }

/* 图片占位（按行加载时的图片位置） */
.img-ph { position: relative; display: block; min-height: 64px; margin: 8px 0; background: #f8fafc; border: 1px dashed var(--border); border-radius: 6px; }
.img-ph .lazy-spinner { position: absolute; inset: 0; }

/* LQIP 渐进加载：在 lazy-wrapper 上应用背景与滤镜淡出 */
.lazy-wrapper.lqip { position: relative; }
.lazy-wrapper.lqip { filter: blur(14px); transition: filter .6s ease; }
.lazy-wrapper.lqip.loaded { filter: blur(0); background-image: none; }
.lazy-wrapper.lqip img { opacity: 0; transition: opacity .6s ease; }
.lazy-wrapper.lqip.loaded img { opacity: 1; }

/* 图片外框与描述（自动包装） */
.markdown-body figure.img-frame { margin: 18px auto; padding: 8px 10px 10px; border: 1px solid #d9e2cc; border-radius: 12px; background: linear-gradient(180deg,#fafcf7,#f2f6ec); box-shadow: 0 2px 6px rgba(0,0,0,.05); max-width: 100%; }
.markdown-body figure.img-frame .lazy-wrapper { display: block; }
.markdown-body figure.img-frame img { border-radius: 8px; display: block; max-width: 100%; height: auto; }
.markdown-body figure.img-frame figcaption.img-caption { margin-top: 8px; font-size: 13px; line-height: 1.4; color: #64748b; font-family: var(--serif); text-align: center; word-break: break-word; }

/* 文本块占位行，避免并发填充时高度瞬时跳动 */
.chunk-loading-line { height: 12px; background: #f1f5f9; border-radius: 6px; margin: 6px 0; }

.loading { color: var(--muted); padding: 32px 0; }

/* 文章底部加载动画（分块流式加载时显示） */
.post-loading-spinner { display: flex; align-items: center; justify-content: center; padding: 24px 0; }
.post-loading-spinner .spinner { width: 40px; height: 40px; border: 4px solid #94a3b8; border-top-color: #009966; border-radius: 50%; animation: spin .9s linear infinite; }

.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: none; border-bottom: 1px dotted var(--muted); 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; }
/* 空状态/错误提示 */
.empty-state { border: 1px dashed #e5e7eb; border-radius: 8px; padding: 16px 18px; margin: 24px 0; background: #f9fafb; }
.empty-state h2 { margin: 0 0 8px; font-size: 18px; color: #111827; }
.empty-state p { margin: 4px 0; color: #4b5563; }
.empty-state details { margin-top: 8px; font-size: 14px; }
.empty-state summary { cursor: pointer; color: #6b7280; }
.empty-state code { background: #1118270d; padding: 1px 4px; border-radius: 3px; }
/* Tags 页样式 */
.tags-page-list { list-style: none; padding-left: 0; margin: 12px 0; display: flex; flex-wrap: wrap; gap: 8px 12px; }
.tags-page-list li { margin: 0; }
.tags-page-list a { display: inline-block; padding: 4px 10px; border-radius: 999px; border: 1px solid #00996666; color: #009966; text-decoration: none; font-size: 14px; background: #f8fffb; }
.tags-page-list a:hover { background: #00996610; }
.tags-page-list a.active { background: #0099661a; border-color: #009966cc; font-weight: 600; }
.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; }

/* 缩写可视化 */
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; display: block; }
.toc-side.hidden { display: none; }
.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(--link); 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: #00996614; }
/* TOC 当前章节高亮 */
.toc-side .toc a.active { background: #0099661a; font-weight: 600; color: #064e3b; box-shadow: inset 0 0 0 1px #00996666; }
/* 移除目录自定义滚动条与滚动容器，目录随页面一同滚动 */
@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; }
