/* === toc.css === Table of Contents 样式 === */
.toc-nav {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 20px 24px;
  margin-bottom: 32px;
  font-size: 14px;
  line-height: 1.6;
  position: relative;
}
.toc-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid #e2e8f0;
}
.toc-title {
  font-weight: 700;
  font-size: 16px;
  color: #0f172a;
}
.toc-toggle {
  background: none;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  padding: 2px 10px;
  font-size: 12px;
  color: #64748b;
  cursor: pointer;
  transition: all 0.15s;
}
.toc-toggle:hover {
  background: #e2e8f0;
  color: #334155;
}
.toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.toc-list li {
  margin: 0;
  padding: 0;
}
.toc-list a {
  display: block;
  padding: 4px 0 4px 0;
  color: #475569;
  text-decoration: none;
  border-left: 3px solid transparent;
  padding-left: 12px;
  transition: all 0.15s;
  font-size: 14px;
}
.toc-list a:hover {
  color: #0044BD;
  background: #eff6ff;
  border-left-color: #0044BD;
}
.toc-list a.toc-active {
  color: #0044BD;
  font-weight: 600;
  border-left-color: #0044BD;
  background: #eff6ff;
}
/* h3 缩进 */
.toc-list a.toc-h3 {
  padding-left: 28px;
  font-size: 13px;
}
.toc-nav.toc-collapsed .toc-list {
  display: none;
}
.toc-nav.toc-collapsed {
  padding-bottom: 16px;
}

/* 内容+侧边目录通用布局 */
.content-with-sidebar {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  gap: 40px;
  align-items: flex-start;
}
.content-main {
  flex: 1;
  min-width: 0;
}

/* 桌面端：目录脱离文档流，绝对定位在主体右侧 */
@media (min-width: 1024px) {
  .content-with-sidebar {
    position: relative; /* 为绝对定位的子元素提供参考容器 */
  }
  .content-main {
    width: 100%; /* 主体模块充满整个板块区域 */
  }
  .toc-sidebar {
    position: absolute;
    right: calc(-260px - 40px); /* 定位在容器右侧 40px 处 */
    top: 0; /* 与主体模块顶部持平对齐 */
    width: 260px;
    max-height: calc(100vh - 140px);
    overflow-y: auto;
    flex-shrink: 0;
    margin-left: 0;
    margin-bottom: 0;
  }
  .toc-sidebar .toc-nav {
    margin-bottom: 0;
  }
}

/* 目录吸顶固定态 */
.toc-sidebar--fixed {
  z-index: 900;
  /* 在桌面端切换到 fixed 定位后，确保目录内容可正常滚动 */
}

/* 移动端：侧边目录吸顶（使用原生 sticky） */
@media (max-width: 1023px) {
  .content-with-sidebar {
    flex-direction: column;
  }
  .toc-sidebar {
    width: 100%;
    margin-left: 0;
    position: sticky;
    top: 72px; /* 顶部导航栏高度 */
    z-index: 900;
  }
}
