/* ===== 博客前端共享样式（所有主题通用） ===== */
.nb-topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;   /* 三栏均分：左/中/右 */
  align-items: center;
  gap: 8px;
  max-width: 1080px;
  margin: 0 auto;
  padding: 12px 16px;
  font-size: 14px;
}
.nb-topbar a { text-decoration: none; }
.nb-topbar-left {
  justify-self: start; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  opacity: .8;
}
.nb-topbar-center {
  justify-self: center;
  padding: 4px 16px; border-radius: 999px;
  border: 1px solid currentColor; opacity: .85;
  white-space: nowrap;
}
.nb-topbar-right {
  justify-self: end;
  padding: 4px 16px; border-radius: 999px;
  font-weight: 600; white-space: nowrap;
}
.nb-topbar a:hover { opacity: 1; }
@media (max-width: 640px) {
  .nb-topbar { padding: 10px 12px; font-size: 13px; gap: 6px; }
  .nb-topbar-left { font-size: 12px; }
  .nb-topbar-center, .nb-topbar-right { padding: 3px 12px; }
}
/* 页脚沉底兜底（主题自定义样式可覆盖） */
body { display: flex; flex-direction: column; min-height: 100vh; }
body > main { flex: 1 0 auto; }
body > footer { margin-top: auto; }

/* ===== 平滑动效（全主题通用） ===== */
html { scroll-behavior: smooth; }
body { animation: nb-page-in .3s ease; }
@keyframes nb-page-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes nb-fade-up { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
a, button, .btn, input, select, textarea, label {
  transition: color .16s ease, background-color .16s ease, border-color .16s ease,
              box-shadow .16s ease, opacity .16s ease, transform .16s ease;
}
button:active, .btn:active { transform: scale(.97); }
main article, main .blog-item, main .paper-item, main .md-item,
main .fk-card, main .il-card, main .post-list-item, main .post-item {
  animation: nb-fade-up .35s ease both;
}
main .blog-item, main .paper-item, main .md-item,
main .fk-card, main .il-card, main .post-list-item, main .post-item {
  transition: transform .18s ease, box-shadow .18s ease;
}
main .blog-item:hover, main .paper-item:hover, main .md-item:hover,
main .fk-card:hover, main .il-card:hover, main .post-list-item:hover, main .post-item:hover {
  transform: translateY(-2px);
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ===== 博客前端分页 ===== */
.nb-pager {
  display: flex; align-items: center; justify-content: center;
  gap: 14px; padding: 30px 0 42px; flex-wrap: wrap;
}
.nb-pager-link {
  color: inherit; text-decoration: none; cursor: pointer;
  padding: 8px 18px; border: 1px solid rgba(128,128,128,.35); border-radius: 999px;
}
.nb-pager-link:hover { opacity: .7; }
.nb-pager-info { color: #888; font-size: 14px; }

/* ===== 博客前端分类筛选栏 ===== */
.nb-cats {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 0 18px; flex-wrap: wrap;
}
.nb-cat {
  display: inline-flex; align-items: center; gap: 6px;
  color: inherit; text-decoration: none; cursor: pointer;
  padding: 5px 14px; border: 1px solid rgba(128,128,128,.3);
  border-radius: 999px; font-size: 14px; line-height: 1.4;
}
.nb-cat:hover { opacity: .7; }
.nb-cat-active {
  border-color: currentColor; box-shadow: inset 0 0 0 1px currentColor;
  font-weight: 600;
}
.nb-cat-n {
  font-size: 12px; opacity: .65;
  background: rgba(128,128,128,.12); border-radius: 999px; padding: 0 7px;
}
@media (max-width: 640px) {
  .nb-cats { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 12px;
             -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .nb-cats::-webkit-scrollbar { display: none; }
  .nb-cat { flex-shrink: 0; padding: 4px 12px; font-size: 13px; }
}

/* ===== nb-md-overflow-fix：Markdown 文章内容防横向溢出（全主题） ===== */
/* 容器允许收缩：防止 flex/grid 子项把页面撑宽 */
main, main > *, article, .post-body, .fk-post, .md-post, .il-post, .mg-post,
.post-body > * { min-width: 0; }
/* 正文内长词断行：行内代码、链接、长路径不再撑破容器 */
.post-body { overflow-wrap: break-word; word-break: break-word; }
/* nb-md-overflow-fix-2：溢出元素不只在 .post-body 内（H1/目录/meta 也有行内代码），
   断行规则覆盖整个 main，代码块（pre）除外——保持横向滚动而非折行 */
main * { overflow-wrap: anywhere; word-break: break-word; }
main pre, main pre *, main .nb-code, main .nb-code * {
  overflow-wrap: normal;
  word-break: normal;
}
main .nb-code, main pre { white-space: pre; }
.post-body a, .post-body .nb-link-title, .post-body .nb-link-url {
  overflow-wrap: anywhere;
  word-break: break-word;
}
/* 块级元素不越界：代码块/图片/引用 */
.post-body pre, .post-body .nb-code {
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.post-body img {
  max-width: 100%;
  height: auto;
}
.post-body blockquote, .post-body .nb-quote, .post-body ul, .post-body ol {
  max-width: 100%;
}
.post-body ul, .post-body ol { padding-left: 1.4em; }
/* nb-md-overflow-fix-3：body 是 flex 列容器，主题的 main 用 margin:auto 居中，
   flex 下宽度会退化为 fit-content，被 pre 等不折行内容的最小宽度撑破。
   显式让 main 占满容器宽度（max-width 仍由主题控制，桌面端 1080px 上限不受影响） */
body > main { width: 100%; box-sizing: border-box; }

/* 兜底：页面本身不出现横向滚动（内容层已可各自滚动） */
html { overflow-x: hidden; }
body { overflow-x: clip; }

/* ===== Markdown 表格 + 行内代码（全主题通用） ===== */
.nb-table-wrap { overflow-x: auto; margin: 1.2rem 0; -webkit-overflow-scrolling: touch; }
.nb-table { border-collapse: collapse; width: 100%; font-size: .93em; }
.nb-table th, .nb-table td {
  border: 1px solid rgba(128, 128, 128, .35);
  padding: .45em .8em; text-align: left; vertical-align: top;
}
.nb-table th { background: rgba(128, 128, 128, .08); font-weight: 600; }
.post-body code, .nb-quote code, .nb-list code {
  background: rgba(128, 128, 128, .14);
  border-radius: .35em; padding: .08em .4em;
  font-family: ui-monospace, "SF Mono", Consolas, Menlo, monospace;
  font-size: .88em;
}
.post-body pre code, .nb-code code { background: none; padding: 0; border-radius: 0; }
