/* Full-screen sidebar overlay */
#kb-mob-overlay {
    top: var(--header-h, 56px);
}

/* ── Mobile bar divider ── */
#kb-mob-divider {
    background: rgba(0, 0, 0, 0.15);
}
.dark #kb-mob-divider {
    background: rgba(255, 255, 255, 0.15);
}
:root {
    --kb-sidebar-w: 15.5rem; /* 248px */
    --header-h: 56px;
}

/* Strip default <main> padding injected by header.php */
body > main { padding: 0 !important; }

/* ── Sidebar scrollbar ── */
#kb-sidebar {
    scrollbar-width: thin;
    scrollbar-color: #e5e7eb transparent;
}
#kb-sidebar::-webkit-scrollbar { width: 3px; }
#kb-sidebar::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 2px; }
.dark #kb-sidebar::-webkit-scrollbar-thumb { background: #374151; }

/* ── Right panel scrollbar ── */
#kb-right {
    scrollbar-width: thin;
    scrollbar-color: #e5e7eb transparent;
}
#kb-right::-webkit-scrollbar { width: 4px; }
#kb-right::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 2px; }
.dark #kb-right::-webkit-scrollbar-thumb { background: #374151; }

/* ── TOC col scrollbar ── */
#kb-toc-col { scrollbar-width: none; }
#kb-toc-col::-webkit-scrollbar { display: none; }

/* ── Mobile TOC scrollbar ── */
#kb-mob-toc { scrollbar-width: thin; }

/* ── Folder icon swap ── */
.kb-group-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1rem;
    height: 1rem;
    flex-shrink: 0;
    position: relative;
}
.kb-group-icon i { position: absolute; font-size: 0.875rem; transition: opacity 0.15s; }
.kb-group-icon .ri-folder-open-line { opacity: 0; }
.kb-group-header.is-open .kb-group-icon .ri-folder-3-line { opacity: 0; }
.kb-group-header.is-open .kb-group-icon .ri-folder-open-line { opacity: 1; }

/* ── Sidebar group chevron ── */
.kb-group-header.is-open .kb-chevron { transform: rotate(90deg); }

/* ── Group items accordion ── */
.kb-group-items {
    overflow: hidden;
    max-height: 0;
    transition: max-height 0.25s ease;
}
.kb-group-items.is-open { max-height: 2000px; }

/* ── Skeleton shimmer ── */
@keyframes sk-shimmer {
    0%   { background-position: -600px 0; }
    100% { background-position:  600px 0; }
}
.sk-shimmer {
    background: linear-gradient(90deg, #f0f0f0 25%, #e4e4e4 50%, #f0f0f0 75%);
    background-size: 600px 100%;
    animation: sk-shimmer 1.3s infinite linear;
    border-radius: 5px;
}
.dark .sk-shimmer {
    background: linear-gradient(90deg, #1a1f2e 25%, #252d3d 50%, #1a1f2e 75%);
    background-size: 600px 100%;
}

/* ── Skeleton overlay ── */
#kb-skeleton {
    position: absolute;
    inset: 0;
    padding: 2rem 2.25rem;
    background: #fff;
    z-index: 5;
    pointer-events: none;
}
.dark #kb-skeleton { background: #000; }

/* ── Footnote references ── */
.footnote-ref {
    font-size: 0.75em;
    vertical-align: super;
    color: #9ca3af;
    text-decoration: none;
    padding: 0 0.1em;
}
.footnote-ref:hover { color: #6b7280; text-decoration: underline; }
.dark .footnote-ref { color: #6b7280; }
.dark .footnote-ref:hover { color: #9ca3af; }

/* Reference list anchor — inline <a> with id, offset for sticky bars */
a.footnote-anchor {
    display: inline-block;
    font-weight: 600;
    color: #374151;
    margin-right: 0.4em;
    text-decoration: none;
    /* Scroll offset: push the anchor target below sticky header + mobile bar */
    scroll-margin-top: calc(var(--header-h, 56px) + var(--mob-bar-h, 0px) + 16px);
}
.dark a.footnote-anchor { color: #d1d5db; }

/* ── Heading anchor links ── */
.heading-with-anchor {
    position: relative;
}
.heading-anchor {
    display: inline-flex;
    align-items: center;
    margin-left: 0.4em;
    opacity: 0;
    color: #9ca3af;
    text-decoration: none;
    font-size: 0.85em;
    transition: opacity 0.15s;
    vertical-align: middle;
}
.heading-with-anchor:hover .heading-anchor,
.heading-anchor:focus { opacity: 1; }
.heading-anchor:hover { color: #6366f1; }
.dark .heading-anchor { color: #6b7280; }
.dark .heading-anchor:hover { color: #818cf8; }

/* ── Prose styles ── */
.prose-blog { color: #374151; font-size: 0.9375rem; line-height: 1.8; }
.dark .prose-blog { color: #d1d5db; }

.prose-blog h2 {
    font-size: 1.2rem; font-weight: 700; color: #111827;
    margin: 2.5rem 0 0.875rem;
    padding-bottom: 0.375rem;
    border-bottom: 1px solid #e5e7eb;
    scroll-margin-top: calc(var(--header-h) + 1rem);
}
.dark .prose-blog h2 { color: #f9fafb; border-color: #374151; }

.prose-blog h3 {
    font-size: 1rem; font-weight: 600; color: #1f2937;
    margin: 1.75rem 0 0.625rem;
    scroll-margin-top: calc(var(--header-h) + 1rem);
}
.dark .prose-blog h3 { color: #e5e7eb; }

@media (max-width: 768px) {
    .prose-blog h2, .prose-blog h3 {
        scroll-margin-top: calc(var(--header-h) + var(--mob-bar-h, 44px) + 12px);
    }
}

.prose-blog p { margin: 0 0 1.125rem; }
.prose-blog ul, .prose-blog ol { margin: 0 0 1.125rem 1.5rem; }
.prose-blog li { margin-bottom: 0.3rem; }
.prose-blog strong { font-weight: 600; color: #111827; }
.dark .prose-blog strong { color: #f3f4f6; }
.prose-blog code { background: #f3f4f6; color: #1f2937; padding: 0.15em 0.4em; border-radius: 4px; font-size: 0.84em; }
.dark .prose-blog code { background: #1f2937; color: #e5e7eb; }
.prose-blog hr { border: none; border-top: 1px solid #e5e7eb; margin: 2.25rem 0; }
.dark .prose-blog hr { border-color: #374151; }
.prose-blog table { width: 100%; border-collapse: collapse; margin: 1.25rem 0; font-size: 0.85rem; }
.prose-blog th { background: #f9fafb; font-weight: 600; text-align: left; padding: 0.55rem 0.8rem; border: 1px solid #e5e7eb; color: #374151; }
.dark .prose-blog th { background: #1f2937; border-color: #374151; color: #d1d5db; }
.prose-blog td { padding: 0.5rem 0.8rem; border: 1px solid #e5e7eb; vertical-align: top; }
.dark .prose-blog td { border-color: #374151; }
.prose-blog tr:nth-child(even) td { background: #f9fafb; }
.dark .prose-blog tr:nth-child(even) td { background: #111827; }
.prose-blog blockquote {
    border-left: 3px solid #6366f1; padding: 0.7rem 1rem; margin: 1.25rem 0;
    background: #f5f3ff; border-radius: 0 8px 8px 0; color: #4b5563; font-style: italic;
}
.dark .prose-blog blockquote { background: #1e1b4b; color: #c4b5fd; border-color: #818cf8; }

/* ── TOC link blur effect ── */
.toc-link {
    opacity: 0.5;
    filter: blur(0.4px);
    transition: color 0.15s, opacity 0.15s, filter 0.15s;
}
.toc-link:hover { color: #374151; opacity: 0.85; filter: none; }
.dark .toc-link { color: #9ca3af; }
.dark .toc-link:hover { color: #e5e7eb; }
.toc-link.is-active { color: #111827; opacity: 1; font-weight: 500; filter: none; }
.dark .toc-link.is-active { color: #f3f4f6; }

/* ── Mobile TOC active ── */
#kb-mob-toc-list a.is-active {
    color: #111827;
    font-weight: 500;
}
.dark #kb-mob-toc-list a.is-active {
    color: #f3f4f6;
}

/* ── Mobile: skeleton padding ── */
@media (max-width: 768px) {
    #kb-skeleton { padding: 1.25rem 1rem; }
}
