/* === Floating TOC + Progress Bar === */
#floating-toc {
  position: fixed;
  right: 12px;
  top: 60px;
  z-index: 200;
  font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
  max-width: 260px;
}

#toc-toggle {
  position: absolute;
  right: 0;
  top: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #1a5276;
  color: #fff;
  font-size: 18px;
  text-align: center;
  line-height: 36px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  transition: all 0.2s;
  user-select: none;
}
#toc-toggle:hover {
  background: #2980b9;
  transform: scale(1.1);
}

#toc-list-wrap {
  margin-top: 44px;
  background: #fff;
  border: 1px solid #d5d5d5;
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.12);
  padding: 0;
  overflow: hidden;
}

#toc-title {
  padding: 10px 14px 8px;
  font-size: 13px;
  font-weight: bold;
  color: #1a5276;
  border-bottom: 1px solid #eee;
  background: #f8f9fa;
}

#toc-list {
  list-style: none;
  margin: 0;
  padding: 6px 0;
  max-height: calc(100vh - 200px);
  overflow-y: auto;
  scrollbar-width: thin;
}
#toc-list::-webkit-scrollbar {
  width: 4px;
}
#toc-list::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 2px;
}

#toc-list li {
  margin: 0;
  padding: 0;
}

#toc-list a {
  display: block;
  padding: 5px 14px;
  font-size: 12px;
  color: #555;
  text-decoration: none;
  border-left: 3px solid transparent;
  transition: all 0.15s;
  line-height: 1.5;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#toc-list a.toc-h3 {
  padding-left: 26px;
  font-size: 11.5px;
  color: #888;
}
#toc-list a:hover {
  background: #f0f4ff;
  color: #1a5276;
  border-left-color: #2980b9;
}
#toc-list a.toc-active {
  background: #e8f0fe;
  color: #1a5276;
  font-weight: bold;
  border-left-color: #c0392b;
}

/* Progress bar */
#toc-progress-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
  padding-right: 44px;
}
#toc-progress-bar {
  height: 4px;
  background: linear-gradient(90deg, #1a5276, #2980b9);
  border-radius: 2px;
  width: 0%;
  transition: width 0.1s;
  flex: 1;
  min-width: 0;
}
#toc-progress-text {
  font-size: 11px;
  color: #888;
  min-width: 30px;
  text-align: right;
}

/* Top reading progress bar (full width) */
#reading-progress-top {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  background: linear-gradient(90deg, #1a5276, #c0392b);
  z-index: 9999;
  width: 0%;
  transition: width 0.1s;
}

/* Responsive: hide sidebar on narrow screens, show toggle */
@media (max-width: 1100px) {
  #floating-toc {
    right: 8px;
    top: 88px;
    max-width: 240px;
  }
  #toc-progress-wrap {
    display: none;
  }
}

@media (max-width: 768px) {
  #floating-toc {
    right: 6px;
    top: 83px;
    max-width: 220px;
  }
  #toc-list {
    max-height: 60vh;
  }
}

/* Performance: promote fixed elements to own layer */
#floating-toc { will-change: transform; }
#reading-progress-top { will-change: width; }

/* TOC floats over content, no body shift */
