/* 基础重置 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* 悬浮按钮样式 */
#toc-button {
  position: fixed;
  right: 30px;
  bottom: 150px;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: #3498db;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: none !important;
}

.menu-icon {
  width: 24px;
  height: 24px;
  fill: #fff;
}

/* 目录容器 */
#toc-container {
  position: fixed;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px);
  transition: opacity 0.25s ease-out,
    visibility 0.25s ease-out,
    transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  background: white;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  padding: 12px;
  z-index: 10;
  min-width: 160px;
}

#toc-container.active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* 目录列表项 */
.toc-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  /* gap: 8px; */
}

.toc-item {
  margin-bottom: 0px;
  padding: 10px;
  border-radius: 8px;
  transition: background 0.15s ease-out;
}

.toc-item:hover {
  background: rgba(245, 245, 245, 0.8);
}

.toc-link {
  color: #2c3e50;
  text-decoration: none;
  font-size: 14px;
  line-height: 1.4;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}

h2 {
  scroll-margin-top: 80px;
  /* 根据实际header高度调整 */
  position: relative;
  z-index: 1;
}

/* 兼容Firefox */
@supports (scroll-margin-top: 0) {
  h2 {
    scroll-snap-margin-top: 80px;
    /* 旧属性兼容 */
  }
}