/* 全站顶部导航条：只作用于 .sitebar，避免与各页原有样式冲突 */
:root { --sb-h: 48px; }          /* 导航条高度，供各页二级吸顶栏让位 */
.sitebar {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: var(--max, 1200px);
  margin: 0 auto;
  padding: 11px 0 10px;
  border-bottom: 1px solid var(--line, #e0dfd4);
  background: var(--paper, #f5f4ee);
  box-shadow: -50vw 0 0 var(--paper, #f5f4ee), 50vw 0 0 var(--paper, #f5f4ee);
  font-family: var(--sans, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif);
  font-size: 13px;
  line-height: 1.4;
}
.sitebar a { color: inherit; text-decoration: none; }
.sb-brand {
  font-family: var(--serif, "Noto Serif SC", "Songti SC", serif);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: .08em;
  color: var(--ink, #1b211d);
  white-space: nowrap;
}
.sb-brand::before {
  content: "";
  display: inline-block;
  width: 6px; height: 6px;
  margin-right: 7px;
  border-radius: 50%;
  background: var(--gold, #b5842f);
  vertical-align: 2px;
}
.sb-links {
  display: flex;
  align-items: center;
  gap: 18px;
}
.sb-links a {
  color: var(--muted, #6d746c);
  padding: 3px 0;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: color .15s, border-color .15s;
}
.sb-links a:hover { color: var(--ink, #1b211d); }
.sb-links a.on {
  color: var(--accent, #2f5d8a);
  border-bottom-color: currentColor;
  font-weight: 600;
}
/* 站名右边的 GitHub 入口（全站统一，插在 .sb-brand / .brand 之后） */
.sb-gh, .sitebar .ghbtn, .topbar .ghbtn { flex: none; }
.sitebar .ghbtn, .topbar .ghbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 24px;
  padding: 0 9px;
  border: 1px solid var(--line, #e0dfd4);
  border-radius: 999px;
  background: var(--surface, #fffdf8);
  color: var(--muted, #6d746c);
  font-size: 11px;
  line-height: 1;
  letter-spacing: .02em;
  white-space: nowrap;
  text-decoration: none;
  /* 紧挨站名，同时把右侧导航挤到最右 */
  margin-left: -5px;
  margin-right: auto;
  align-self: center;
  transition: color .15s, border-color .15s, background .15s;
}
.sitebar .ghbtn svg, .topbar .ghbtn svg { width: 13px; height: 13px; display: block; }
.sitebar .ghbtn:hover, .topbar .ghbtn:hover {
  color: var(--ink, #1b211d);
  border-color: var(--ink, #1b211d);
}
@media (max-width: 620px) {
  .sitebar .ghbtn, .topbar .ghbtn { width: 24px; padding: 0; gap: 0; }
  .sitebar .ghbtn span, .topbar .ghbtn span { display: none; }
}

/* 窄屏：单行不换行，链接区可横向滑动，高度恒定（--sb-h 才能对得上） */
@media (max-width: 720px) {
  :root { --sb-h: 44px; }
  .sitebar {
    box-sizing: border-box;
    flex-wrap: nowrap;
    height: var(--sb-h);
    padding: 0 15px;
    gap: 10px;
  }
  .sb-brand { font-size: 12.5px; letter-spacing: .02em; }
  .sb-links {
    flex: 0 1 auto;
    min-width: 0;
    margin-left: auto;
    gap: 12px;
    font-size: 12px;
    justify-content: flex-start;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    /* 尾部留白 + 右缘渐隐：提示可横向滑动，滚到底时最后一项不被渐隐 */
    padding-right: 18px;
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 18px), transparent 100%);
    mask-image: linear-gradient(to right, #000 calc(100% - 18px), transparent 100%);
  }
  .sb-links::-webkit-scrollbar { display: none; }
  .sb-links a { flex: none; padding: 2px 0; }
}
