.toc-heading {
  scroll-margin-top: 6.5rem;
}

.article-toc {
  margin: 0 0 1.25rem;
  overflow: hidden;
  border: 1px solid rgba(99, 102, 241, 0.2);
  border-radius: 0.9rem;
  background:
    linear-gradient(145deg, rgba(99, 102, 241, 0.08), rgba(20, 184, 166, 0.04)),
    var(--q2-surface, #fff);
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.07);
}

.article-toc summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1rem;
  color: var(--q2-text-strong);
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.article-toc summary::-webkit-details-marker {
  display: none;
}

.article-toc summary::after {
  content: '＋';
  color: #6366f1;
  font-size: 1rem;
  transition: transform 0.2s ease;
}

.article-toc[open] summary::after {
  content: '−';
}

.article-toc nav {
  max-height: min(66vh, 38rem);
  padding: 0.1rem 0.65rem 0.8rem;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(99, 102, 241, 0.55) transparent;
}

.article-toc ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

.article-toc li {
  margin: 0;
  list-style: none;
}

.article-toc a {
  display: block;
  margin: 0.08rem 0;
  padding: 0.42rem 0.55rem;
  border-left: 2px solid transparent;
  border-radius: 0.35rem;
  color: var(--q2-text-muted, #64748b);
  font-size: 0.8rem;
  line-height: 1.35;
  text-decoration: none;
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.article-toc .toc-level-3 a {
  padding-left: 1.2rem;
  font-size: 0.76rem;
  opacity: 0.88;
}

.article-toc a:hover {
  color: #4f46e5;
  background: rgba(99, 102, 241, 0.08);
}

.article-toc a.is-active {
  border-left-color: #14b8a6;
  color: #4338ca;
  background: linear-gradient(90deg, rgba(99, 102, 241, 0.13), rgba(20, 184, 166, 0.05));
  font-weight: 650;
}

@media (min-width: 1024px) {
  #sidebar .article-toc {
    position: sticky;
    top: 5.5rem;
  }
}

@media (max-width: 1023px) {
  #item .article-toc {
    margin: 0.5rem 0 1.5rem;
  }
}

:root[data-theme='dark'] .article-toc {
  border-color: rgba(129, 140, 248, 0.25);
  background:
    linear-gradient(145deg, rgba(99, 102, 241, 0.14), rgba(20, 184, 166, 0.06)),
    #171b24;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.24);
}

:root[data-theme='dark'] .article-toc a.is-active {
  color: #c7d2fe;
  background: linear-gradient(90deg, rgba(129, 140, 248, 0.2), rgba(45, 212, 191, 0.06));
}
