:root {
    --novatoc-accent: #0f766e;
    --novatoc-accent-hover: #115e59;
    --novatoc-bg: #ffffff;
    --novatoc-text: #172033;
    --novatoc-muted: #667085;
    --novatoc-border: #d9e2e7;
    --novatoc-shadow: 0 18px 50px rgba(15, 23, 42, 0.2);
    --novatoc-radius: 14px;
    --novatoc-scroll-offset: 96px;
}

.novatoc[hidden] {
    display: none !important;
}

.novatoc,
.novatoc * {
    box-sizing: border-box;
}

.novatoc {
    --novatoc-trigger-left: 16px;
    --novatoc-panel-left: 76px;
    width: 0;
    height: 0;
    margin: 0;
    padding: 0;
    color: var(--novatoc-text);
    font: inherit;
}

.novatoc__trigger {
    position: fixed;
    z-index: 9998;
    top: 50%;
    right: auto;
    left: var(--novatoc-trigger-left);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    min-width: 48px;
    height: 48px;
    min-height: 48px;
    margin: 0;
    padding: 0;
    color: #ffffff;
    appearance: none;
    background: var(--novatoc-accent);
    border: 0;
    border-radius: 12px;
    box-shadow: 0 10px 28px rgba(15, 118, 110, 0.32);
    cursor: pointer;
    opacity: 1;
    visibility: visible;
    transform: translateY(-50%);
    transition: background-color 160ms ease, opacity 180ms ease, visibility 180ms ease;
}

.novatoc__trigger:hover,
.novatoc__trigger:focus-visible {
    color: #ffffff;
    background: var(--novatoc-accent-hover);
    outline: 3px solid rgba(15, 118, 110, 0.22);
    outline-offset: 3px;
}

.novatoc__trigger-icon {
    display: grid;
    width: 23px;
    gap: 4px;
}

.novatoc__trigger-icon span {
    display: block;
    width: 100%;
    height: 2px;
    background: currentColor;
    border-radius: 99px;
}

.novatoc__panel {
    position: fixed;
    z-index: 9999;
    top: clamp(84px, 14vh, 132px);
    right: auto;
    left: var(--novatoc-panel-left);
    width: min(370px, calc(100vw - 110px));
    max-height: min(72vh, 680px);
    margin: 0;
    overflow: hidden;
    color: var(--novatoc-text);
    font: inherit;
    background: var(--novatoc-bg);
    border: 1px solid var(--novatoc-border);
    border-radius: var(--novatoc-radius);
    box-shadow: var(--novatoc-shadow);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateX(-14px) scale(0.985);
    transform-origin: top left;
    transition: opacity 180ms ease, transform 180ms ease, visibility 180ms ease;
}

.novatoc.is-open .novatoc__panel {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateX(0) scale(1);
}

.novatoc.is-past-content .novatoc__trigger,
.novatoc.is-past-content .novatoc__panel {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.novatoc__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    min-height: 58px;
    padding: 0.75rem 0.85rem 0.75rem 1rem;
    border-bottom: 1px solid var(--novatoc-border);
}

.novatoc__title {
    margin: 0;
    color: var(--novatoc-text);
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.35;
}

.novatoc__close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    min-width: 36px;
    height: 36px;
    min-height: 36px;
    margin: 0;
    padding: 0;
    color: var(--novatoc-muted);
    font: inherit;
    font-size: 1.75rem;
    line-height: 1;
    appearance: none;
    background: transparent;
    border: 0;
    border-radius: 50%;
    cursor: pointer;
}

.novatoc__close:hover,
.novatoc__close:focus-visible {
    color: var(--novatoc-text);
    background: #f2f6f7;
    outline: 0;
}

.novatoc__list {
    max-height: calc(min(72vh, 680px) - 59px);
    margin: 0;
    padding: 0.65rem 0.75rem 0.85rem;
    overflow: auto;
    list-style: none;
    scrollbar-width: thin;
}

.novatoc__item {
    margin: 0;
    padding: 0;
    list-style: none;
}

.novatoc__link {
    display: grid;
    grid-template-columns: 2rem minmax(0, 1fr);
    gap: 0.35rem;
    align-items: start;
    margin: 0;
    padding: 0.5rem 0.55rem;
    color: var(--novatoc-text);
    font-size: 0.94rem;
    font-weight: 500;
    line-height: 1.45;
    text-decoration: none;
    border-left: 3px solid transparent;
    border-radius: 7px;
    overflow-wrap: anywhere;
}

.novatoc__number {
    color: var(--novatoc-accent);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.novatoc__link-text {
    min-width: 0;
}

.novatoc__link:hover,
.novatoc__link:focus-visible,
.novatoc__link[aria-current="location"] {
    color: var(--novatoc-accent-hover);
    text-decoration: none;
    background: #edf8f6;
    border-left-color: var(--novatoc-accent);
    outline: 0;
}

.novatoc-heading {
    scroll-margin-top: var(--novatoc-scroll-offset);
}

.novatoc__sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

@media (max-width: 782px) {
    :root {
        --novatoc-scroll-offset: 80px;
    }

    .novatoc__trigger {
        top: auto;
        right: auto;
        left: 16px;
        bottom: 18px;
        transform: none;
    }

    .novatoc__panel {
        top: auto;
        right: 12px;
        bottom: 78px;
        left: 12px;
        width: auto;
        max-height: min(68vh, 580px);
        transform: translateY(14px) scale(0.99);
        transform-origin: bottom center;
    }

    .novatoc.is-open .novatoc__panel {
        transform: translateY(0) scale(1);
    }

    .novatoc__list {
        max-height: calc(min(68vh, 580px) - 59px);
    }
}

@media (prefers-reduced-motion: reduce) {
    .novatoc__trigger,
    .novatoc__panel {
        transition: none;
    }
}

@media print {
    .novatoc {
        display: none !important;
    }
}
