:root {
    --bg: #0b1220;
    --surface: rgba(22, 28, 41, 0.86);
    --text-primary: #e8edf7;
    --text-secondary: #b4bed1;
    --text-tertiary: #91a0b8;
    --primary: #8ab4ff;
    --primary-dark: #5a86ff;
    --border: rgba(140, 155, 185, 0.22);
    --border-strong: rgba(180, 195, 225, 0.45);
    --shadow: rgba(5, 8, 19, 0.5);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.18);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.24);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.32);
    --glass: rgba(22, 28, 41, 0.6);
    --glass-deep: rgba(16, 21, 33, 0.65);
    --glass-border: rgba(189, 200, 226, 0.14);
    --ring: #6da2ff;
    --ring-soft: rgba(109, 162, 255, 0.25);
    --accent-gradient: linear-gradient(135deg, #6da2ff 0%, #9e7bff 100%);
    --on-accent: #0e1220;
    --radius-xl: 14px;
    --radius-2xl: 18px;
    --radius-3xl: 22px;
    --space-1: 6px;
    --space-2: 10px;
    --space-3: 16px;
    --space-4: 22px;
    --space-5: 28px;
    --logo-size: 44px;
}

* { box-sizing: border-box; }

html {
    font-size: clamp(14px, 14px + 0.25vw, 18px);
    scroll-behavior: smooth;
}

body {
    margin: 0;
    background:
        radial-gradient(1200px 800px at 10% -10%, rgba(64, 87, 255, 0.16), transparent 50%),
        radial-gradient(1000px 700px at 110% 10%, rgba(156, 86, 255, 0.16), transparent 50%),
        var(--bg);
    color: var(--text-primary);
    font-family: "IBM Plex Sans", "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    line-height: 1.65;
    min-height: 100vh;
}

.container {
    max-width: 1140px;
    margin: 0 auto;
    padding: 0 24px 64px;
}

.hero { padding: 64px 0 18px; }

.hero h1 {
    margin: 0 0 8px;
    font-size: clamp(28px, 3.3vw, 46px);
    line-height: 1.15;
    letter-spacing: 0.2px;
    font-weight: 700;
}

.muted { color: var(--text-secondary); }

.layout {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 24px;
    align-items: start;
}

.toc {
    position: sticky;
    top: 18px;
    align-self: start;
    background: var(--surface);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-2xl);
    box-shadow: var(--shadow-sm);
    padding: 16px;
}

.toc-title {
    margin: 0 0 10px;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
}

.toc-list {
    counter-reset: toc;
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 4px;
}

.toc-list > li {
    counter-increment: toc;
    display: grid;
    grid-template-columns: min-content 1fr;
    column-gap: 8px;
    align-items: start;
}

.toc-list > li::before {
    content: counter(toc) ".";
    color: var(--primary);
    font-weight: 700;
    line-height: 1.4;
    padding-top: 6px;
}

.toc a {
    grid-column: 2;
    display: block;
    padding: 6px 8px;
    border-radius: 10px;
    color: var(--text-secondary);
    text-decoration: none;
    line-height: 1.4;
    overflow-wrap: anywhere;
}

.toc a:hover,
.toc a.active {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.doc {
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-2xl);
    background: linear-gradient(180deg, rgba(22, 28, 41, 0.9), rgba(22, 28, 41, 0.76));
    box-shadow: var(--shadow-sm);
    padding: 24px;
}

.section { scroll-margin-top: 18px; }

.section + .section {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px dashed var(--glass-border);
}

h2 {
    margin: 0 0 8px;
    font-size: clamp(20px, 2.4vw, 28px);
    font-weight: 700;
    letter-spacing: 0.15px;
    color: var(--text-primary);
}

.num-list,
.num-list ol {
    list-style: none;
    margin: 0;
    padding-left: 0;
}

.num-list[data-sec] { counter-reset: item; }
.num-list[data-sec] > li { counter-increment: item; }
.num-list[data-sec] > li + li { margin-top: 8px; }

.num-list[data-sec] > li::before {
    content: attr(data-sec) "." counters(item, ".") ". ";
    color: var(--primary);
    font-weight: 700;
    margin-right: 6px;
}

.num-list[data-sec] > li > ol[data-sec] {
    counter-reset: item;
    margin-top: 8px;
    padding-left: 22px;
}

.num-list[data-sec] > li > ol[data-sec] > li { counter-increment: item; }

.num-list[data-sec] > li > ol[data-sec] > li::before {
    content: attr(data-sec) "." counters(item, ".") ". ";
    color: var(--primary);
    font-weight: 700;
    margin-right: 6px;
}

.num-list[data-sec] ol[data-sec] ol[data-sec] {
    counter-reset: item;
    margin-top: 8px;
    padding-left: 22px;
}

.num-list[data-sec] ol[data-sec] ol[data-sec] > li { counter-increment: item; }

.num-list[data-sec] ol[data-sec] ol[data-sec] > li::before {
    content: attr(data-sec) "." counters(item, ".") ". ";
    color: var(--primary);
    font-weight: 700;
    margin-right: 6px;
}

a {
    color: var(--primary);
    text-decoration: underline;
    text-underline-offset: 3px;
}

a:focus-visible {
    outline: 2px solid var(--ring);
    outline-offset: 2px;
    border-radius: 6px;
}

.scroll-top {
    position: fixed;
    right: 20px;
    bottom: 24px;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transform: translateY(10px);
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 50;
}

.scroll-top i {
    font-size: 28px;
    line-height: 1;
}

.scroll-top.show {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.scroll-top:active { transform: translateY(1px); }

@media (max-width: 1220px) {
    .container { max-width: 1000px; }
    .layout { grid-template-columns: 340px 1fr; }
}

@media (max-width: 1020px) {
    .layout { grid-template-columns: 1fr; }
    .toc { position: static; border-radius: var(--radius-xl); }
}

@media (max-width: 560px) {
    .container { padding: 0 16px 56px; }
    .doc { padding: 16px; border-radius: var(--radius-xl); }
    .scroll-top { width: 46px; height: 46px; right: 16px; bottom: 18px; }
    .scroll-top i { font-size: 24px; }
}
