/* 文章目录样式（重写） */
.article-toc {
    position: fixed;
    top: 0;      /* 由 JS 实时设置 */
    left: 0;     /* 由 JS 实时设置 */
    width: 280px;
    opacity: 0;
    visibility: hidden;
    transform: translateX(20px);
    /* 加上 top 的过渡，配合 JS 惯性更顺滑 */
    transition: top .25s ease-out, opacity .3s ease, transform .3s ease, visibility .3s ease;
    will-change: top, left, transform;
    z-index: 100;
  }
  /* 小屏兜底隐藏可保留；移除响应式 left 的兜底，避免视觉错觉 */
  @media (max-width: 1400px) { .article-toc { display: none !important; } }
  
  .article-toc.show {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
  }
  
  /* 评论区淡出状态（不抢事件） */
  .article-toc.fade-out {
    opacity: 0;
    pointer-events: none;
  }
  
  /* 强制隐藏（空间不足/无目录项时） */
  .article-toc.is-hidden {
    display: none !important;
  }
  
  /* 目录卡片 */
  .toc-container {
    background: var(--color-background);
    border-radius: 8px;
    padding: 0.8rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    border: 1px solid var(--color-border);
  }
  
  .toc-title {
    font-size: 1rem;
    font-weight: 540;
    color: var(--color-text);
    margin: 0 0 0.55rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    gap: 0.5rem;
  }
  
  .toc-title i {
    color: var(--color-primary);
    font-size: 1.1rem;
  }
  
  .toc-list {
    max-height: calc(100vh - 200px);
    overflow-y: auto;
    padding-right: 0.5rem;
  }
  
  .toc-item { margin: 0.25rem 0; line-height: 1.4; }
  .toc-item.level-2 { padding-left: 0; }
  .toc-item.level-3 { padding-left: 1.2em; }
  .toc-item.level-4 { padding-left: 2.4em; }
  .toc-item.level-5 { padding-left: 3.6em; }
  .toc-item.level-6 { padding-left: 4.8em; }
  
  .toc-link {
    display: block;
    padding: 0.2rem 0.3rem;
    color: var(--color-text);
    text-decoration: none;
    border-radius: 4px;
    font-size: 0.85rem;
    transition: all 0.2s ease;
    opacity: 0.85;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .toc-link:hover {
    color: var(--color-primary);
    background: rgba(var(--color-primary-rgb), 0.08);
    opacity: 1;
  }
  .toc-link.active {
    color: var(--color-primary);
    background: rgba(var(--color-primary-rgb), 0.1);
    font-weight: 500;
    opacity: 1;
  }
  
  /* 目录不同层级字号区分，避免占满宽度 */
  .toc-item.level-2 > .toc-link { font-size: 0.95rem; font-weight: 400; }
  .toc-item.level-3 > .toc-link { font-size: 0.85rem; }
  .toc-item.level-4 > .toc-link { font-size: 0.75rem; }
  .toc-item.level-5 > .toc-link { font-size: 0.65rem; }
  .toc-item.level-6 > .toc-link { font-size: 0.60rem; }
  
  /* 滚动条美化 */
  .toc-list::-webkit-scrollbar { width: 4px; }
  .toc-list::-webkit-scrollbar-track { background: transparent; }
  .toc-list::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: 2px; }
  .toc-list:hover::-webkit-scrollbar-thumb { background: var(--color-text-light); }
  
  /* 修复锚点被固定头部遮挡（JS 会设置 --fixed-header-offset） */
  .entry-content h1,
  .entry-content h2,
  .entry-content h3,
  .entry-content h4,
  .entry-content h5,
  .entry-content h6 {
    scroll-margin-top: var(--fixed-header-offset, 100px);
  }
  
  /* 深色模式 */
  [data-theme="dark"] .toc-container {
    background: var(--color-background);
    border-color: var(--color-border);
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
  }
  
  /* 响应式兜底（JS 会优先计算定位） */
  @media (max-width: 1400px) {
    .article-toc { display: none !important; }
  }