:root {
    color-scheme: dark;
    --page: #0f1318;
    --page-elevated: #131920;
    --sidebar: #0b0f14;
    --panel: #151b22;
    --panel-soft: #1a212a;
    --line: #27313d;
    --line-strong: #334050;
    --text: #e7edf5;
    --muted: #9ba8b7;
    --muted-soft: #778292;
    --link: #8fb7ff;
    --link-hover: #b3ccff;
    --accent: #6da4ff;
    --accent-soft: rgba(109, 164, 255, 0.12);
    --success: #7ad6b2;
    --code-bg: #0d1218;
    --code-line: #222c37;
    --shadow: 0 18px 36px rgba(0, 0, 0, 0.22);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --content-width: 880px;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.025), transparent 180px),
        var(--page);
    color: var(--text);
    font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
}

a {
    color: var(--link);
    text-decoration: none;
}

a:hover {
    color: var(--link-hover);
    text-decoration: underline;
}

code,
pre {
    font-family: "IBM Plex Mono", "Cascadia Code", Consolas, monospace;
}

::selection {
    background: rgba(109, 164, 255, 0.28);
}

.app-shell {
    display: grid;
    grid-template-columns: 292px minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    height: 100vh;
    padding: 1.1rem 1rem 1rem;
    background: var(--sidebar);
    border-right: 1px solid var(--line);
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0 0.2rem;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 2.4rem;
    height: 2.4rem;
    border: 1px solid var(--line-strong);
    border-radius: 10px;
    background: #121821;
    color: var(--text);
    font-size: 0.92rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.eyebrow {
    margin: 0 0 0.14rem;
    color: var(--muted-soft);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.brand h1 {
    margin: 0;
    color: var(--text);
    font-size: 1.06rem;
    font-weight: 700;
}

.search-wrap {
    position: relative;
}

.search-label {
    display: block;
    margin: 0 0 0.42rem 0.2rem;
    color: var(--muted);
    font-size: 0.77rem;
    font-weight: 600;
}

.search-input {
    width: 100%;
    padding: 0.82rem 0.9rem;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-md);
    background: #121821;
    color: var(--text);
    outline: none;
    transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.search-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(109, 164, 255, 0.14);
    background: #151d27;
}

.search-input::placeholder {
    color: var(--muted-soft);
}

.search-results {
    position: absolute;
    inset: calc(100% + 0.5rem) 0 auto;
    max-height: 25rem;
    overflow: auto;
    padding: 0.45rem;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-md);
    background: #0f141b;
    box-shadow: var(--shadow);
    z-index: 20;
}

.search-empty,
.search-item {
    display: block;
    width: 100%;
    padding: 0.72rem 0.78rem;
    border-radius: 10px;
}

.search-item:hover {
    background: rgba(255, 255, 255, 0.04);
    text-decoration: none;
}

.search-item-title {
    margin: 0;
    color: var(--text);
    font-size: 0.93rem;
    font-weight: 600;
}

.search-item-excerpt {
    margin: 0.24rem 0 0;
    color: var(--muted);
    font-size: 0.82rem;
    line-height: 1.45;
}

.sidebar-nav {
    flex: 1;
    overflow: auto;
    padding-right: 0.15rem;
}

.nav-group {
    margin-bottom: 0.95rem;
}

.nav-group-title {
    margin: 0 0 0.42rem;
    padding: 0 0.22rem;
    color: var(--muted-soft);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

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

.nav-link {
    display: block;
    padding: 0.54rem 0.68rem 0.54rem 0.88rem;
    border-left: 2px solid transparent;
    border-radius: 0 10px 10px 0;
    color: #c1cad6;
    font-size: 0.91rem;
    line-height: 1.42;
    transition: background 0.16s ease, color 0.16s ease, border-color 0.16s ease;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.035);
    color: var(--text);
    text-decoration: none;
}

.nav-link.active {
    border-left-color: var(--accent);
    background: var(--accent-soft);
    color: #d7e4ff;
    font-weight: 600;
}

.nav-children {
    margin: 0.2rem 0 0.58rem 0.86rem;
    padding: 0 0 0 0.7rem;
    border-left: 1px solid rgba(255, 255, 255, 0.08);
    list-style: none;
}

.sidebar-footer {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    padding: 0.85rem 0.2rem 0;
    border-top: 1px solid var(--line);
}

.sidebar-footer a {
    color: var(--muted);
    font-size: 0.82rem;
}

.main-column {
    min-width: 0;
    padding: 0 1.5rem 1.5rem;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 12;
    display: flex;
    align-items: center;
    gap: 0.9rem;
    padding: 0.95rem 0 0.8rem;
    background: linear-gradient(180deg, rgba(15, 19, 24, 0.98), rgba(15, 19, 24, 0.92), rgba(15, 19, 24, 0.65), transparent);
    backdrop-filter: blur(8px);
}

.menu-toggle {
    display: none;
    width: 2.7rem;
    height: 2.7rem;
    border: 1px solid var(--line-strong);
    border-radius: 10px;
    background: #121821;
}

.menu-toggle span {
    display: block;
    width: 1.1rem;
    height: 2px;
    margin: 0.22rem auto;
    background: var(--text);
    border-radius: 999px;
}

.topbar-meta {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.82rem 0 0.92rem;
    border-bottom: 1px solid var(--line);
}

.breadcrumbs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.46rem;
    min-width: 0;
    color: var(--muted);
    font-size: 0.85rem;
}

.breadcrumbs a,
.breadcrumbs strong {
    color: inherit;
}

.breadcrumbs span {
    color: #677180;
}

.meta-chips {
    display: flex;
    gap: 0.48rem;
    flex-wrap: wrap;
}

.chip {
    display: inline-flex;
    align-items: center;
    padding: 0.3rem 0.6rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #141a21;
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 600;
}

.chip-accent {
    color: #d6e4ff;
    border-color: rgba(109, 164, 255, 0.26);
    background: rgba(109, 164, 255, 0.1);
}

.content-shell {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 220px;
    gap: 2rem;
    align-items: start;
}

.article-panel {
    max-width: var(--content-width);
    padding: 0;
}

.article-header {
    margin-bottom: 1.9rem;
    padding: 1.2rem 0 1.25rem;
    border-bottom: 1px solid var(--line);
}

.page-kicker {
    margin: 0 0 0.42rem;
    color: var(--muted-soft);
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.page-title {
    margin: 0;
    color: var(--text);
    font-size: clamp(2rem, 4vw, 3rem);
    font-weight: 700;
    line-height: 1.03;
    letter-spacing: -0.02em;
}

.page-excerpt {
    max-width: 48rem;
    margin: 0.82rem 0 0;
    color: var(--muted);
    font-size: 1rem;
    line-height: 1.68;
}

.article-content {
    color: var(--text);
    font-size: 0.99rem;
    line-height: 1.78;
}

.article-content h1,
.article-content h2,
.article-content h3,
.article-content h4,
.article-content h5,
.article-content h6 {
    margin: 2.1rem 0 0.82rem;
    color: var(--text);
    font-weight: 700;
    line-height: 1.14;
    scroll-margin-top: 6rem;
}

.article-content h2 {
    font-size: 1.52rem;
}

.article-content h3 {
    font-size: 1.18rem;
}

.article-content h4,
.article-content h5,
.article-content h6 {
    font-size: 1rem;
}

.article-content p {
    margin: 0 0 1rem;
}

.article-content > p:first-of-type {
    color: #b6c0cc;
    font-size: 1.03rem;
}

.article-content ul,
.article-content ol {
    margin: 0 0 1rem;
    padding-left: 1.3rem;
}

.article-content li {
    margin: 0.34rem 0;
}

.article-content hr {
    margin: 2rem 0;
    border: 0;
    border-top: 1px solid var(--line);
}

.article-content blockquote {
    margin: 1.4rem 0;
    padding: 0.95rem 1.05rem;
    border-left: 3px solid var(--accent);
    background: rgba(255, 255, 255, 0.03);
    color: #c5d0dc;
}

.article-content blockquote p {
    margin: 0;
}

.article-content code {
    padding: 0.12rem 0.38rem;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.04);
    color: #d7e5ff;
    font-size: 0.92em;
}

.code-block {
    position: relative;
    margin: 1.3rem 0;
    padding: 1.1rem 1.1rem 0.98rem;
    border: 1px solid var(--code-line);
    border-radius: 12px;
    background: var(--code-bg);
    color: #e7edf5;
    overflow: auto;
}

.code-block code {
    display: block;
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    white-space: pre-wrap;
    line-height: 1.72;
}

.copy-code {
    position: absolute;
    top: 0.72rem;
    right: 0.72rem;
    padding: 0.32rem 0.6rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
    font-size: 0.76rem;
    font-weight: 600;
    cursor: pointer;
}

.copy-code:hover {
    background: rgba(255, 255, 255, 0.08);
}

.article-footer {
    margin-top: 2.25rem;
    padding-top: 1.2rem;
    border-top: 1px solid var(--line);
}

.prev-next {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.85rem;
}

.prev-next-card {
    display: block;
    padding: 0.88rem 0.95rem;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--panel);
}

.prev-next-card:hover {
    border-color: var(--line-strong);
    text-decoration: none;
}

.prev-next-card small {
    display: block;
    margin-bottom: 0.2rem;
    color: var(--muted-soft);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.prev-next-card strong {
    color: var(--text);
    font-size: 0.98rem;
    font-weight: 600;
}

.toc-panel {
    position: sticky;
    top: 5.8rem;
}

.toc-inner {
    padding-top: 0.15rem;
}

.toc-label {
    margin: 0 0 0.8rem;
    color: var(--muted-soft);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.toc-nav {
    display: flex;
    flex-direction: column;
    gap: 0.18rem;
}

.toc-link {
    display: block;
    padding: 0.34rem 0.42rem 0.34rem 0.7rem;
    border-left: 2px solid transparent;
    color: var(--muted);
    font-size: 0.84rem;
    line-height: 1.42;
}

.toc-link.level-3,
.toc-link.level-4 {
    margin-left: 0.78rem;
    font-size: 0.8rem;
}

.toc-link.active,
.toc-link:hover {
    border-left-color: var(--accent);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text);
    text-decoration: none;
}

body.sidebar-open .sidebar {
    transform: translateX(0);
}

@media (max-width: 1220px) {
    .content-shell {
        grid-template-columns: minmax(0, 1fr);
    }

    .toc-panel {
        position: static;
        margin-top: 2rem;
        padding-top: 1rem;
        border-top: 1px solid var(--line);
    }
}

@media (max-width: 980px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        z-index: 50;
        width: min(22rem, 88vw);
        transform: translateX(-105%);
        transition: transform 0.22s ease;
        box-shadow: 12px 0 32px rgba(0, 0, 0, 0.34);
    }

    .menu-toggle {
        display: inline-block;
    }

    .main-column {
        padding: 0 1rem 1.35rem;
    }
}

@media (max-width: 680px) {
    .page-title {
        font-size: 2rem;
    }

    .article-header {
        margin-bottom: 1.45rem;
        padding-top: 0.95rem;
    }

    .prev-next {
        grid-template-columns: 1fr;
    }

    .meta-chips {
        display: none;
    }
}
