/* Rawnaq Scroll Progress + Smart TOC */
.rawnaq-spt {
    --spt-accent: #fbbf24;
    --spt-accent-deep: #4338ca;
    --spt-ink: #1e1b2e;
    --spt-muted: #6b6478;
    --spt-line: #e6e2f0;
    --spt-panel: #ffffff;
    --spt-bar-h: 4px;
    --spt-offset: 80px;
    font-family: inherit;
    color: var(--spt-ink);
}

/* Top progress bar */
.rawnaq-spt-bar {
    position: fixed;
    left: 0;
    right: 0;
    top: 0;
    height: var(--spt-bar-h);
    background: rgba(230, 226, 240, 0.65);
    z-index: 100000;
    pointer-events: none;
}

.rawnaq-spt-bar.is-bottom {
    top: auto;
    bottom: 0;
}

.rawnaq-spt-bar-fill {
    display: block;
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--spt-accent-deep), var(--spt-accent));
    transition: width 0.05s linear;
    will-change: width;
}

/* Circular ring */
.rawnaq-spt-ring {
    position: fixed;
    right: 20px;
    bottom: 24px;
    z-index: 100000;
    width: 56px;
    height: 56px;
}

.rawnaq-spt-ring svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.rawnaq-spt-ring-bg {
    fill: none;
    stroke: var(--spt-line);
    stroke-width: 4;
}

.rawnaq-spt-ring-fg {
    fill: none;
    stroke: var(--spt-accent-deep);
    stroke-width: 4;
    stroke-linecap: round;
    stroke-dasharray: 126;
    stroke-dashoffset: 126;
    transition: stroke-dashoffset 0.08s linear;
}

.rawnaq-spt-ring-label {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    font-size: 11px;
    font-weight: 800;
    color: var(--spt-ink);
    pointer-events: none;
}

/* TOC shell */
.rawnaq-spt-toc {
    background: var(--spt-panel);
    border: 1px solid var(--spt-line);
    border-radius: 16px;
    padding: 18px 16px;
    box-sizing: border-box;
}

.rawnaq-spt-toc.is-sticky {
    position: sticky;
    top: var(--spt-offset);
}

.rawnaq-spt-toc.is-floating {
    position: fixed;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    width: min(260px, calc(100vw - 40px));
    z-index: 99990;
    max-height: 70vh;
    overflow: auto;
    box-shadow: 0 16px 40px rgba(30, 27, 46, 0.12);
}

.rawnaq-spt-toc.is-inline {
    margin: 0 0 24px;
}

.rawnaq-spt-reading {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--spt-muted);
    margin: 0 0 10px;
}

.rawnaq-spt-title {
    font-size: 14px;
    font-weight: 800;
    margin: 0 0 12px;
    color: var(--spt-ink);
}

.rawnaq-spt-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.rawnaq-spt-list a {
    display: block;
    text-decoration: none;
    color: var(--spt-muted);
    font-size: 13px;
    font-weight: 600;
    padding: 7px 10px;
    border-left: 3px solid transparent;
    border-radius: 0 8px 8px 0;
    transition: color 0.15s, background 0.15s, border-color 0.15s;
    line-height: 1.35;
}

.rawnaq-spt-list a:hover,
.rawnaq-spt-list a:focus-visible {
    color: var(--spt-ink);
    background: #f5f3ff;
    outline: none;
}

.rawnaq-spt-list a.is-active {
    color: var(--spt-accent-deep);
    border-left-color: var(--spt-accent);
    background: #f5f3ff;
    font-weight: 700;
}

.rawnaq-spt-list .lvl-3 { padding-left: 18px; font-size: 12.5px; }
.rawnaq-spt-list .lvl-4 { padding-left: 28px; font-size: 12px; }

.rawnaq-spt-list .is-child { display: none; }
.rawnaq-spt-toc.is-expanded .is-child,
.rawnaq-spt-list li.is-open > .is-child {
    display: block;
}

/* Mobile fab */
.rawnaq-spt-fab {
    display: none;
    position: fixed;
    right: 16px;
    bottom: 88px;
    z-index: 100001;
    width: 48px;
    height: 48px;
    border-radius: 14px;
    border: none;
    background: linear-gradient(135deg, var(--spt-accent-deep), #7c3aed);
    color: #fff;
    font-size: 18px;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 10px 24px rgba(67, 56, 202, 0.3);
}

.rawnaq-spt.is-hidden {
    display: none !important;
}

.rawnaq-spt-bar.is-hidden-progress,
.rawnaq-spt-ring.is-hidden-progress {
    display: none !important;
}

@media (max-width: 767px) {
    .rawnaq-spt-toc.is-floating,
    .rawnaq-spt-toc.is-sticky.collapse-mobile {
        display: none;
    }

    .rawnaq-spt-toc.is-sticky.collapse-mobile.is-sheet-open,
    .rawnaq-spt-toc.is-floating.is-sheet-open {
        display: block;
        position: fixed;
        left: 12px;
        right: 12px;
        top: auto;
        bottom: 72px;
        transform: none;
        width: auto;
        max-height: 55vh;
        z-index: 100002;
    }

    .rawnaq-spt.has-mobile-fab .rawnaq-spt-fab {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
}

[dir="rtl"] .rawnaq-spt-list a {
    border-left: none;
    border-right: 3px solid transparent;
    border-radius: 8px 0 0 8px;
}

[dir="rtl"] .rawnaq-spt-list a.is-active {
    border-right-color: var(--spt-accent);
}

[dir="rtl"] .rawnaq-spt-ring {
    right: auto;
    left: 20px;
}

@media (prefers-reduced-motion: reduce) {
    .rawnaq-spt-bar-fill,
    .rawnaq-spt-ring-fg,
    .rawnaq-spt-list a {
        transition: none !important;
    }
    html {
        scroll-behavior: auto !important;
    }
}
