/* ======= BASE SIDEBAR ======= */

@media (min-width: 1024px) {
    /* сам сайдбар больше не sticky */
    .custom-sidebar {
        position: relative;
        align-self: flex-start;
    }

    /* sticky-оболочка, которая фиксируется снизу */
    .sgx-sticky-wrap {
        position: sticky;
        bottom: 40px; /* зазор от нижнего края */
        margin-top: 40px;
    }
} /* <- закрываем media */

/* убрать fade-in (по умолчанию показываем) */
.custom-sidebar {
    opacity: 1;
    transform: none;
}

/* отступ между TOC и CTA */
.sgx-toc-card {
    margin-top: 30px;
}

/* ======= GLASS CARD ======= */

.sgx-toc-card {
    background: rgba(255, 255, 255, 0.55);
    backdrop-filter: blur(22px);
    border-radius: 22px;
    border: 1px solid rgba(255,255,255,0.28);
    box-shadow: 0 8px 28px rgba(0,0,0,0.08);
    padding: 20px 18px 22px;
    max-height: calc(100vh - 120px); /* высота карточки в окне */
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: relative; /* для абсолютных :before/:after */
}

/* TITLE BLOCK */
.sgx-toc-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
}

.sgx-toc-title {
    font-size: 20px;
    font-weight: 700;
    margin: 0;
}

.sgx-toc-toggle {
    background: none;
    border: none;
    font-size: 14px;
    cursor: pointer;
    color: #ff176a;
    padding: 4px 8px;
}

/* ======= INNER SCROLL LIST ======= */

.sgx-toc-scroll {
    overflow-y: auto;
    padding-right: 10px;
    flex-grow: 1;
    transition: max-height .3s ease;
    max-height: calc(100vh - 220px); /* внутренняя прокрутка; подправь по высоте header/cta */
}

/* fade top/bottom - реализуем через абсолютные элементы */
.sgx-toc-card::before,
.sgx-toc-card::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    height: 22px;
    pointer-events: none;
    z-index: 5;
}

.sgx-toc-card::before {
    top: 0;
    background: linear-gradient(to bottom, rgba(255,255,255,0.92), rgba(255,255,255,0));
}

.sgx-toc-card::after {
    bottom: 0;
    background: linear-gradient(to top, rgba(255,255,255,0.92), rgba(255,255,255,0));
}

/* ======= LINKS ======= */

.sgx-toc-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 10; /* выше градиентов, но под toggle (если нужно) */
}

.sgx-toc-list a {
    font-size: 15px;
    line-height: 1.4;
    color: #222;
    text-decoration: none;
    border-radius: 10px;
    padding: 7px 10px;
    transition: .18s;
    outline: none;
}

/* keyboard focus */
.sgx-toc-list a:focus {
    box-shadow: 0 0 0 3px rgba(30,158,158,0.12);
    border-radius: 8px;
}

.sgx-toc-list a:hover {
    background: rgba(255,255,255,0.7);
    color: #ff176a;
}

.sgx-toc-list a.active {
    background: #ff176a;
    color: #fff;
}

.toc-h3 {
    margin-left: 12px;
    font-size: 14px;
    opacity: .85;
}

/* ======= COLLAPSED MODE ======= */

.sgx-collapsed .sgx-toc-scroll {
    max-height: 120px !important;
    overflow: hidden;
}

.sgx-collapsed .sgx-toc-toggle::after {
    content: "↓";
}

.sgx-expanded .sgx-toc-toggle::after {
    content: "↑";
}

/* Chrome / Edge */
.sgx-toc-scroll::-webkit-scrollbar {
    width: 6px;
}
.sgx-toc-scroll::-webkit-scrollbar-track {
    background: transparent;
}
.sgx-toc-scroll::-webkit-scrollbar-thumb {
    background: #1e9e9e;
    border-radius: 10px;
}

/* Firefox */
.sgx-toc-scroll {
    scrollbar-width: thin;
    scrollbar-color: #1e9e9e transparent;
}

/* ACCESSIBILITY - toggle focus */
.sgx-toc-toggle:focus {
    outline: 2px solid rgba(30,158,158,0.16);
    border-radius: 8px;
}

/* mobile: скрываем */
@media (max-width: 1023px) {
    .custom-sidebar { display: none; }
}
