.sidebar-wrapper {
    position: sticky;
    top: 100px;
    float: right;
    width: 175px;
    margin-right: -24px;
    z-index: 10;
    border: 0px solid #dadce0;

}

.toc-container {
    margin-bottom: 20px;
    display: none;
    /* Hidden by default, shown by JS if headings are found */
    max-height: calc(100vh - 180px);
    /* Reserving space for footer/header but allowing full view */
    padding: 0px;
    background-color: transparent;
    position: relative;
    overflow: visible;
    /* Changed to allow indicators to position correctly */
}

/* Adjust TOC height when a promo card is also present in the sidebar */
.sidebar-wrapper.has-promo .toc-container {
    max-height: calc(100vh - 450px);
}

.toc-scroll-wrapper {
    position: relative;
    max-height: inherit;
    display: flex;
    flex-direction: column;
}

#toc-nav {
    overflow-y: auto;
    max-height: inherit;
    scrollbar-width: none;
    /* Hide scrollbar for cleaner look */
}

#toc-nav::-webkit-scrollbar {
    display: none;
}

.toc-indicator {
    position: absolute;
    left: 0;
    right: 0;
    height: 30px;
    z-index: 5;
    pointer-events: none;
    transition: opacity 0.3s ease;
    opacity: 0;
}

.toc-indicator.top {
    top: 0;
    background: linear-gradient(to bottom, rgba(255, 255, 255, 1) 0%, rgba(255, 255, 255, 0) 100%);
}

.toc-indicator.bottom {
    bottom: 0;
    background: linear-gradient(to top, rgba(255, 255, 255, 1) 0%, rgba(255, 255, 255, 0) 100%);
}

.toc-indicator.visible {
    opacity: 1;
}

/* On large screens, align with the content boundaries */
@media (min-width: 1400px) {
    .toc-container {
        display: block;
    }
}

/* Hide on mobile and smaller tablets */
@media (max-width: 1199px) {
    .toc-container {
        display: none !important;
    }
}

.toc-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    color: var(--google-grey-text);
    font-weight: 500;
    font-size: 0.9rem;
    letter-spacing: 0.05em;
}

.toc-icon {
    font-size: 1.2rem;
}

.toc-list {
    list-style: none;
    padding: 0;
    margin: 0;
    border-left: 0px solid #eee;
}

.toc-item {
    margin: 8px 0;
}

.toc-link {
    display: block;
    padding: 6px 8px;
    /* Slightly more padding for touch/click */
    color: #5f6368;
    font-size: 0.75rem;
    text-decoration: none;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    border-left: 2px solid transparent;
    margin-left: -2px;
    white-space: normal;
    max-width: 100%;
    margin-bottom: 8px;
    position: relative;
    overflow: hidden;
}

.toc-link:hover {
    color: var(--google-blue);
    background-color: var(--google-hover-grey);
    transform: translateX(4px);
    /* Premium micro-animation */
}

/* Add a subtle indicator for hover */
.toc-link:hover::after {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 2px;
    height: 60%;
    background: var(--google-blue-faded, #e8f0fe);
    border-radius: 4px;
}

.toc-link.active {
    color: var(--google-blue);
    font-weight: 500;
    border-left: 2px solid var(--google-blue);
}

.toc-link.h3 {
    padding-left: 24px;
    font-size: 0.8rem;
}

/* Make the TOC scrollbar subtle and professional */
.toc-container::-webkit-scrollbar {
    width: 4px;
}

.toc-container::-webkit-scrollbar-thumb {
    background: #dadce0;
    border-radius: 10px;
}

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