*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: #1f2937;
  background: #fff;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}
a { color: #2563eb; text-decoration: none; }
a:hover { text-decoration: underline; }

.docs-layout { display: flex; min-height: 100vh; }

/* ---------- Sidebar ---------- */
:root { --sidebar-w: 260px; }

.docs-sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  border-right: 1px solid #e5e7eb;
  height: 100vh;
  overflow: hidden;
  position: sticky;
  top: 0;
  background: #ffffff;
  display: flex;
  flex-direction: column;
  transition: width 0.2s ease;
}
body.sidebar-collapsed .docs-sidebar { border-right-width: 0; }
body.sidebar-collapsed .sidebar-resizer { display: none; }

/* 折叠/展开按钮: 水平压在分隔线上 (translateX -50%), 默认隐藏 */
.sidebar-collapse-btn {
  position: fixed;
  top: 80px;
  left: var(--sidebar-w, 260px);
  transform: translateX(-50%);
  width: 20px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  color: #9aa0a6;
  cursor: pointer;
  z-index: 60;
  padding: 0;
  box-shadow: 0 2px 6px rgba(0,0,0,0.08);
  opacity: 0;
  pointer-events: none;
  transition: left 0.2s ease, opacity 0.2s ease, color 0.15s, background 0.15s;
}
/* 默认隐藏, 由 JS 控制 .visible 显示 */
.sidebar-collapse-btn.visible {
  opacity: 1;
  pointer-events: auto;
}
/* 折叠态时按钮贴左边缘, 去掉 translateX 否则会被裁掉一半 */
body.sidebar-collapsed .sidebar-collapse-btn {
  transform: none;
  left: 0;
}
.sidebar-collapse-btn:hover {
  color: #374151;
  background: #f5f6f8;
  border-color: #d1d5db;
}
.sidebar-collapse-btn svg {
  width: 14px;
  height: 14px;
  transition: transform 0.2s ease;
}
body.sidebar-collapsed .sidebar-collapse-btn svg {
  transform: rotate(180deg);
}

.sidebar-header {
  padding: 16px;
  border-bottom: 1px solid #e5e7eb;
  flex-shrink: 0;
}
.sidebar-header a {
  font-size: 16px;
  font-weight: 600;
  color: #1a1a1a;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: color 0.15s;
}
.sidebar-header a:hover { text-decoration: none; color: #3b82f6; }

.sidebar-nav-wrap {
  flex: 1;
  position: relative;
  display: flex;
  overflow: hidden;
  min-height: 0;
}
.sidebar-nav {
  flex: 1;
  padding: 8px 0;
  overflow-y: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.sidebar-nav::-webkit-scrollbar { display: none; width: 0; height: 0; }

/* 自定义滚动条: 固定 40px thumb, 滚动时显示, 停止后淡出 */
.sidebar-scrollbar {
  position: absolute;
  top: 4px;
  right: 2px;
  bottom: 4px;
  width: 4px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.sidebar-scrollbar.visible {
  opacity: 1;
  pointer-events: auto;
}
.sidebar-thumb {
  position: absolute;
  top: 0;
  right: 0;
  width: 4px;
  height: 40px;
  background: rgba(0, 0, 0, 0.18);
  border-radius: 4px;
  transition: background 0.15s ease;
}
.sidebar-thumb:hover { background: rgba(0, 0, 0, 0.32); }

.nav-item {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 7px 12px;
  color: #1a1a1a;
  font-size: 15px;
  line-height: 1.5;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  user-select: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nav-item > .nav-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 占位: 对齐 summary 里的箭头列, 叶子节点没有箭头 */
.nav-arrow-placeholder {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* 前置图标: 文件 / 文件夹 */
.nav-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  line-height: 1;
}
.nav-icon-file::before { content: "📄"; }
.nav-icon-folder::before { content: "📁"; }
.nav-group[open] > summary .nav-icon-folder::before { content: "📂"; }
.nav-item:hover {
  background: #e5e7eb;
  color: #111827;
  text-decoration: none;
}
.nav-item.active {
  background: #fde68a;
  color: #78350f;
  font-weight: 500;
}
.nav-item.active:hover {
  background: #fcd34d;
  color: #78350f;
}

.nav-group { margin: 0; }
.nav-group > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 7px 12px;
  font-size: 15px;
  font-weight: 500;
  color: #1a1a1a;
  user-select: none;
  transition: background 0.15s;
}
.nav-group > summary:hover { background: #e5e7eb; color: #111827; }
.nav-group > summary::-webkit-details-marker,
.nav-group > summary::marker { display: none; content: ""; }

.nav-arrow {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #9aa0a6;
  transform: rotate(0deg);
  transition: transform 0.15s, color 0.15s;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%239aa0a6' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><path d='M9 18l6-6-6-6'/></svg>");
  background-repeat: no-repeat;
  background-position: center;
}
.nav-group[open] > summary .nav-arrow { transform: rotate(90deg); }

/* 递归树的深度缩进通过内联 style="padding-left:Npx" 注入, CSS 里不再硬编码 */

/* 拖拽调宽把手: 6px 宽的不可见命中区, 居中压在 1px 边框上;
   hover/拖动时显示 3px 深灰圆角线, 参考 pageindex 配色 */
.sidebar-resizer {
  position: absolute;
  top: 0;
  right: -3px;
  width: 6px;
  height: 100%;
  cursor: col-resize;
  z-index: 10;
  background: transparent;
}
.sidebar-resizer::after {
  content: '';
  position: absolute;
  top: 0;
  left: 3px;
  width: 0;
  height: 100%;
  background: #d1d5db;
  border-radius: 2px;
  transition: width 0.15s ease, left 0.15s ease;
}
.sidebar-resizer:hover::after {
  width: 3px;
  left: 2px;
  background: #9ca3af;
}
.sidebar-resizer.dragging::after {
  width: 4px;
  left: 1px;
  background: #6b7280;
}
body.sidebar-resizing,
body.sidebar-resizing * {
  cursor: col-resize !important;
  user-select: none !important;
}
/* 拖拽过程中关掉宽度/位置的过渡, 避免追帧产生的卡顿感 */
body.sidebar-resizing .docs-sidebar,
body.sidebar-resizing .sidebar-collapse-btn {
  transition: none !important;
}

.sidebar-footer {
  padding: 12px 20px;
  border-top: 1px solid #e5e7eb;
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 12px;
  color: #6b7280;
}
.sidebar-footer a { color: #6b7280; }

/* ---------- Mobile toggle ---------- */
.sidebar-toggle {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 60;
  background: #fff;
  border: 1px solid #e5e7eb;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 18px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.06);
}
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 49;
}
.sidebar-backdrop.show { display: block; }

/* ---------- Main ---------- */
.docs-main {
  flex: 1;
  min-width: 0;
  padding: 40px 60px 80px;
}
.docs-main.with-toc {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 240px;
  gap: 56px;
}
.docs-main.with-toc .docs-article { max-width: none; }
.docs-article { max-width: 1040px; width: 100%; }

/* 面包屑导航 */
.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #6b7280;
  margin-bottom: 16px;
}
.breadcrumb .breadcrumb-link {
  color: #6b7280;
  text-decoration: none;
}
.breadcrumb .breadcrumb-link:hover {
  color: #2563eb;
  text-decoration: underline;
}
.breadcrumb .breadcrumb-sep {
  color: #9ca3af;
}
.breadcrumb .breadcrumb-current {
  color: #374151;
}

.docs-article h1 { font-size: 32px; margin: 0 0 8px; color: #111827; line-height: 1.3; }
/* Markdown 内容首行若为 h1 (与文章标题重复), 隐藏避免双标题 */
.docs-article .content > h1:first-child { display: none; }
.docs-article h2 { font-size: 22px; margin: 36px 0 12px; border-bottom: 1px solid #e5e7eb; padding-bottom: 8px; }
.docs-article h3 { font-size: 17px; margin: 24px 0 8px; color: #111827; }
.docs-article p { margin: 12px 0; }
.docs-article ul, .docs-article ol { padding-left: 28px; }
.docs-article li { margin: 4px 0; }
.docs-article code {
  background: #f3f4f6;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 0.9em;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}
.docs-article pre {
  position: relative;
  background: #f2f3f3;
  color: #16191f;
  padding: 16px 18px;
  padding-right: 56px;
  border: 1px solid #d5dbdb;
  border-radius: 4px;
  overflow-x: auto;
  line-height: 1.6;
  font-size: 16px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}
.docs-article pre code {
  background: transparent;
  padding: 0;
  color: inherit;
  font-family: inherit;
}
/* copy 按钮 - AWS 风格: 右上角, hover 浮现 */
.docs-article pre .copy-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  font-size: 12px;
  padding: 3px 10px;
  border: 1px solid #d5dbdb;
  background: #fff;
  color: #16191f;
  border-radius: 4px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease, border-color 0.15s, color 0.15s;
  font-family: inherit;
}
.docs-article pre:hover .copy-btn,
.docs-article pre:focus-within .copy-btn {
  opacity: 1;
}
.docs-article pre .copy-btn:hover {
  background: #f2f3f3;
  border-color: #8c8c8c;
}
.docs-article pre .copy-btn.copied {
  color: #1a7f37;
  border-color: #1a7f37;
  opacity: 1;
}
.docs-article blockquote {
  border-left: 4px solid #93c5fd;
  padding: 4px 16px;
  color: #4b5563;
  margin: 16px 0;
  background: #f0f9ff;
  border-radius: 0 6px 6px 0;
}
.docs-article img { max-width: 100%; height: auto; border-radius: 6px; }
.docs-article table { border-collapse: collapse; width: 100%; margin: 16px 0; }
.docs-article th, .docs-article td { border: 1px solid #e5e7eb; padding: 8px 12px; text-align: left; }
.docs-article th { background: #f9fafb; font-weight: 600; }
.docs-article hr { border: none; border-top: 1px solid #e5e7eb; margin: 32px 0; }

.docs-article .meta {
  color: #6b7280;
  font-size: 13px;
  margin-bottom: 20px;
}
/* 面包屑最后一项点击复制短链: hover 时变蓝提示可点击, 配合页面底部 toast 反馈 */
.docs-article .breadcrumb-share {
  cursor: pointer;
  transition: color 0.15s, text-decoration-color 0.15s;
  text-decoration: underline dotted transparent;
  text-underline-offset: 3px;
}
.docs-article .breadcrumb-share:hover {
  color: #2563eb;
  text-decoration-color: #2563eb;
}
.copy-toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(31, 41, 55, 0.92);
  color: #fff;
  padding: 8px 18px;
  border-radius: 6px;
  font-size: 13px;
  letter-spacing: 0.3px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 9999;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}
.copy-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
/* 标题区底部分隔线, 宽度与 .post-list 的 hover 卡片对齐 (820px) */
.docs-article > .meta {
  max-width: 1040px;
  padding-bottom: 20px;
  border-bottom: 1px solid #eee;
  margin-bottom: 16px;
}

/* ---------- TOC ---------- */
.docs-toc {
  position: sticky;
  top: 32px;
  height: max-content;
  max-height: calc(100vh - 64px);
  overflow: hidden;
  font-size: 15px;
  border-left: 1px solid #e5e7eb;
  padding-left: 16px;
}
.docs-toc-title {
  font-weight: 600;
  color: #111827;
  margin-bottom: 12px;
  font-size: 16px;
}
.docs-toc .toc-item {
  display: block;
  padding: 5px 0;
  color: #4b5563;
  line-height: 1.5;
  border-left: 2px solid transparent;
  padding-left: 10px;
  margin-left: -12px;
}
.docs-toc .toc-item:hover { color: #2563eb; text-decoration: none; }
.docs-toc .toc-item.toc-h3 { padding-left: 24px; font-size: 14px; color: #6b7280; }
.docs-toc .toc-item.active {
  color: #2563eb;
  border-left-color: #2563eb;
  font-weight: 500;
}

/* ---------- Post list (index/archive/tag) ---------- */
/* 首页/标签文章列表 - 左右边界与 h1/分页线对齐, 只保留垂直 padding */
/* 注意: 用 .docs-article .post-list 提高特异性, 覆盖上面 .docs-article ul 的 padding-left:28px */
.docs-article .post-list {
  list-style: none;
  padding: 0;
  margin: 0;
  max-width: 1040px;
}
.post-list > li {
  padding: 18px 16px;
  margin-bottom: 10px;
  border-radius: 8px;
  background: #f3f4f6;
  transition: background 0.2s ease;
}
.post-list > li:last-child { margin-bottom: 0; }
.post-list > li:hover { background: #e5e7eb; }

.post-list h2 {
  margin: 0 0 10px;
  font-size: 22px;
  font-weight: 600;
  line-height: 1.4;
  /* 覆盖 .docs-article h2 从正文样式继承来的 #e5e7eb 下划线,
     换成更深的 #d1d5db, hover (#e5e7eb) 时仍可见 */
  border-bottom-color: #d1d5db;
  padding-bottom: 10px;
}
.post-list h2 a {
  color: #2c3e50;
  transition: color 0.2s;
}
.post-list h2 a:hover { color: #3498db; text-decoration: none; }

.post-list .meta {
  color: #666;
  font-size: 14px;
  margin-bottom: 10px;
}
.post-list .meta a { color: #666; }
.post-list .meta a:hover { color: #3498db; text-decoration: none; }

.post-list .excerpt {
  color: #555;
  font-size: 15px;
  line-height: 1.65;
  margin: 10px 0 0;
}

/* Pagination - 数字按钮 + 省略号 */
.pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  max-width: 1040px;
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px solid #eee;
  font-size: 14px;
}
.pagination .pg-nav,
.pagination .pg-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 12px;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  color: #374151;
  background: #fff;
  transition: all 0.15s ease;
  text-decoration: none;
}
.pagination a.pg-nav:hover,
.pagination a.pg-num:hover {
  border-color: #3498db;
  color: #3498db;
  background: #f0f9ff;
  text-decoration: none;
}
.pagination .pg-num.current {
  background: #3498db;
  border-color: #3498db;
  color: #fff;
  font-weight: 500;
  cursor: default;
}
.pagination .disabled {
  color: #d1d5db;
  background: #f9fafb;
  cursor: not-allowed;
  pointer-events: none;
}
.pagination .pg-ellipsis {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 36px;
  color: #9ca3af;
  user-select: none;
}

/* Tag tags - 彩色胶囊按钮, 按 :nth-child 循环 6 色 */
.tag-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  max-width: 1040px;
  margin: 0;
  padding: 0;
}
.tag-tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid transparent;
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}
.tag-tag:hover {
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.08);
  filter: brightness(0.96);
  text-decoration: none;
}
.tag-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  padding: 1px 6px;
  background: rgba(255, 255, 255, 0.7);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}

/* 6 色循环 */
.tag-tag:nth-child(6n+1) { background: #fee2e2; color: #991b1b; border-color: #fecaca; }
.tag-tag:nth-child(6n+2) { background: #ffedd5; color: #9a3412; border-color: #fed7aa; }
.tag-tag:nth-child(6n+3) { background: #fef3c7; color: #854d0e; border-color: #fde68a; }
.tag-tag:nth-child(6n+4) { background: #d1fae5; color: #065f46; border-color: #a7f3d0; }
.tag-tag:nth-child(6n+5) { background: #dbeafe; color: #1e40af; border-color: #bfdbfe; }
.tag-tag:nth-child(6n)   { background: #ede9fe; color: #5b21b6; border-color: #ddd6fe; }

/* Archive - 紧凑单行列表 */
.archive-page h1 { margin-bottom: 4px; }
.archive-total { color: #9ca3af; font-size: 13px; margin: 0 0 20px; }

.archive-year {
  margin: 28px 0 4px;
  font-size: 20px;
  font-weight: 700;
  color: #111827;
  border-bottom: none;
  padding-bottom: 0;
}
.archive-year .count { color: #9ca3af; font-size: 14px; font-weight: 400; margin-left: 4px; }

.archive-month {
  margin: 16px 0 6px;
  font-size: 14px;
  font-weight: 600;
  color: #6b7280;
}
.archive-month .count { color: #9ca3af; font-weight: 400; margin-left: 2px; }

.archive-list {
  list-style: none;
  padding: 0;
  margin: 0 0 8px;
}
.archive-list li {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 3px 0;
  font-size: 14px;
  line-height: 1.6;
  border: none;
}
.archive-list .date {
  color: #9ca3af;
  font-size: 12px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  flex-shrink: 0;
  width: 42px;
}
.archive-list a {
  color: #374151;
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.archive-list a:hover { color: #2563eb; text-decoration: none; }

/* ---------- Mobile ---------- */
@media (max-width: 900px) {
  .docs-main.with-toc { grid-template-columns: 1fr; }
  .docs-toc {
    position: static;
    border-left: none;
    padding-left: 0;
    margin-top: 32px;
    border-top: 1px solid #e5e7eb;
    padding-top: 16px;
  }
}
@media (max-width: 768px) {
  .sidebar-toggle { display: block; }
  .docs-sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    height: 100vh;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: 2px 0 12px rgba(0,0,0,0.15);
  }
  .docs-sidebar.open { transform: translateX(0); }
  .docs-main { padding: 56px 20px 40px; }
  .docs-article h1 { font-size: 26px; }
  .post-nav {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .post-nav-next {
    grid-column: 1;
    text-align: left;
  }
}
.post-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid #e5e7eb;
}
.post-nav-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 18px 16px;
  border-radius: 8px;
  background: #f3f4f6;
  color: #24292f;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.2s ease;
}
.post-nav-item:hover {
  background: #e5e7eb;
  text-decoration: none;
}
.post-nav-prev {
  grid-column: 1;
}
.post-nav-next {
  grid-column: 2;
  text-align: right;
}
.post-nav-label {
  font-size: 13px;
  color: #6b7280;
}
.post-nav-title {
  font-size: 16px;
  color: #24292f;
  font-weight: 600;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.post-nav-item:hover .post-nav-title {
  color: #0969da;
}
