.toc {
  position: sticky;
  top: 5rem;
  align-self: flex-start;
  max-height: calc(100vh - 6rem);
  overflow-y: auto;
  padding-left: 2rem;
  font-size: 0.85rem;
  min-width: 200px;
  max-width: 280px;
}

.tocHeader {
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--foreground-muted);
  margin-bottom: 1rem;
}

.tocNav {
  position: relative;
}

.tocList {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.tocItem {
  position: relative;
}

.tocLink {
  display: block;
  color: var(--foreground-muted);
  text-decoration: none;
  transition: color 0.15s ease;
  padding: 0.25rem 0;
  line-height: 1.5;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.tocLink:hover {
  color: var(--foreground);
}

.tocItemActive .tocLink {
  color: var(--foreground);
  font-weight: 500;
}

/* Level-specific indentation */
.tocLevel1 {
  padding-left: 0;
}

.tocLevel2 {
  padding-left: 0;
}

.tocLevel3 {
  padding-left: 0.75rem;
}

.tocLevel4 {
  padding-left: 1.5rem;
}

.tocLevel5 {
  padding-left: 2.25rem;
}

.tocLevel6 {
  padding-left: 3rem;
}

/* Active indicator */
.tocItemActive::before {
  content: '';
  position: absolute;
  left: -1rem;
  top: 50%;
  transform: translateY(-50%);
  width: 2px;
  height: 1.2rem;
  background: var(--foreground);
  border-radius: 1px;
}

/* Scrollbar styling */
.toc::-webkit-scrollbar {
  width: 6px;
}

.toc::-webkit-scrollbar-track {
  background: transparent;
}

.toc::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.toc::-webkit-scrollbar-thumb:hover {
  background: var(--foreground-muted);
}

/* Mobile responsive */
@media (max-width: 1024px) {
  .toc {
    display: none;
  }
}

