:root{

    --bg:#0b1020;
    --bg2:#11182e;
    --panel:#131c35;
    --panel2:#182344;

    --text:#edf2ff;
    --muted:#9fb0d7;

    --line:rgba(255,255,255,.08);

    --accent:#7cc7ff;
    --accent2:#c18cff;
    --accent3:#7be0b1;

    --warning:#ffb86b;
    --danger:#ff8b8b;
    --good:#89f0b7;

    --shadow:
        0 12px 40px rgba(0,0,0,.35);

    --radius:18px;
}

*{
    box-sizing:border-box;
}

html{
    scroll-behavior:smooth;
}

body{

    margin:0;

    color:var(--text);

    background:
        radial-gradient(
            circle at 15% 20%,
            rgba(124,199,255,.08),
            transparent 35%
        ),

        radial-gradient(
            circle at 85% 10%,
            rgba(176,140,255,.08),
            transparent 35%
        ),

        radial-gradient(
            circle at 50% 80%,
            rgba(123,224,177,.05),
            transparent 40%
        ),

        var(--bg);

    background-attachment:fixed;

    font-family:
        Inter,
        Segoe UI,
        Roboto,
        Arial,
        sans-serif;

    line-height:1.75;

    min-height:100vh;
}

/* =================================
   HEADER
   ================================= */

.site-header{

    position:relative;

    padding:
        80px
        24px
        60px;

    text-align:center;
}

.site-header__inner{

    max-width:1200px;

    margin:0 auto;
}

.eyebrow{

    text-transform:none;

    letter-spacing:.25em;

    font-size:1rem;

    color:var(--accent);

    margin-bottom:18px;
}

.site-header h1{

    margin:0;

    font-size:clamp(3rem,6vw,5rem);

    font-weight:900;

    letter-spacing:-0.02em;

    line-height:1.15;

    padding:10px 0;

    overflow:visible;

    background:
        linear-gradient(
            135deg,
            #ffffff 0%,
            #7cc7ff 25%,
            #b08cff 60%,
            #ffffff 100%
        );

    -webkit-background-clip:text;
    background-clip:text;

    -webkit-text-fill-color:transparent;

    text-shadow:
        0 0 40px rgba(124,199,255,.15);

    display:inline-block;
}

.subtitle{

    max-width:860px;

    margin:
        24px auto 0;

    color:var(--muted);

    font-size:1.1rem;

    line-height:1.8;
}

.toc-mobile-header{
    display:none;
}

/* =================================
   LAYOUT
   ================================= */

.page-shell{

    max-width:1400px;

    margin:0 auto;

    padding:
        0
        24px
        80px;

    display:grid;

    grid-template-columns:
        320px
        minmax(0,1fr);

    gap:32px;
}

/* =================================
   TOC
   ================================= */

.toc-panel{

    position:sticky;

    top:20px;

    max-height:calc(100vh - 40px);

    display:flex;
    flex-direction:column;

    border:1px solid var(--line);

    background:
        rgba(19,28,53,.82);

    backdrop-filter:blur(12px);

    border-radius:var(--radius);

    box-shadow:var(--shadow);

    overflow:hidden;
}

.toc-panel__head{

    flex-shrink:0;

    padding:20px;

    border-bottom:
        1px solid var(--line);
}

.toc-panel__head h2{

    margin:0;
}

.load-status{

    display:none;
}

.toc{

    flex:1;

    min-height:0;

    overflow-y:auto;

    padding:12px;
}

/* Скроллбар */

.toc::-webkit-scrollbar{

    width:8px;
}

.toc::-webkit-scrollbar-track{

    background:transparent;
}

.toc::-webkit-scrollbar-thumb{

    background:
        rgba(255,255,255,.15);

    border-radius:999px;
}

.toc::-webkit-scrollbar-thumb:hover{

    background:
        rgba(255,255,255,.25);
}

.toc a{

    display:block;

    text-decoration:none;

    transition:.2s;

    border-radius:10px;
}

.toc a:hover{

    background:
        rgba(255,255,255,.05);
}

.toc-chapter{

    padding:10px 12px;

    color:var(--text);

    font-weight:700;
}

.toc-section{

    padding:8px 12px 8px 26px;

    color:var(--muted);

    font-size:.95rem;
}

/* =================================
   BOOK
   ================================= */

.book-shell{

    min-width:0;
}

.book{

    border:1px solid var(--line);

    background:
        rgba(19,28,53,.78);

    backdrop-filter:blur(14px);

    border-radius:24px;

    box-shadow:var(--shadow);

    padding:
        40px
        50px;
}

/* =================================
   CHAPTER
   ================================= */

.chapter{

    margin:0;
}

.chapter > h2{

    margin:
        0
        0
        28px;

    font-size:2.2rem;

    line-height:1.15;
}

.chapter:first-child > h2{

    margin-top:0;
}

.chapter > h2::after{

    content:"";

    display:block;

    width:220px;
    height:3px;

    margin-top:16px;

    border-radius:999px;

    background:
        linear-gradient(
            90deg,
            var(--accent),
            transparent
        );
}

/* =================================
   SECTION
   ================================= */

.section{

    margin-top:45px;
}

.section > h3{

    margin:
        0
        0
        22px;

    font-size:1.55rem;
}

.section > h3::after{

    content:"";

    display:block;

    width:110px;
    height:2px;

    margin-top:12px;

    border-radius:999px;

    background:
        linear-gradient(
            90deg,
            var(--accent3),
            transparent
        );
}

/* =================================
   SUBSECTION
   ================================= */

.subsection{

    margin-top:30px;
}

.subsection > h4{

    margin:
        0
        0
        16px;

    font-size:1.18rem;

    font-weight:700;

    color:var(--accent);
}

/* =================================
   PARAGRAPHS
   ================================= */

.paragraph{

    margin:
        0
        0
        18px;

    color:#e8eefc;
}

/* =================================
   QUOTE
   ================================= */

.quote{

    margin:28px 0;

    padding:
        18px
        22px;

    border-left:
        4px solid var(--accent);

    background:
        rgba(124,199,255,.08);

    border-radius:
        0
        14px
        14px
        0;

    white-space:pre-wrap;

    color:#eaf4ff;
}

/* =================================
   INFO / WARNING
   ================================= */

.callout{

    margin:24px 0;

    border-radius:16px;

    overflow:hidden;

    border:
        1px solid var(--line);
}

.callout--info{

    background:
        rgba(124,199,255,.08);

    padding:18px;
}

.callout--warning{

    background:
        rgba(255,139,139,.08);

    border-color:
        rgba(255,139,139,.18);

    padding:18px;
}

/* =================================
   THEOREM
   ================================= */

.callout--theorem{

    background:
        rgba(123,224,177,.05);

    border-color:
        rgba(123,224,177,.18);
}

.callout__title{

    padding:
        14px
        18px;

    font-weight:700;

    color:var(--good);

    border-bottom:
        1px solid var(--line);

    background:
        rgba(123,224,177,.08);
}

.callout__body{

    padding:18px;
}

.callout__body p{

    margin:0;
}

/* =================================
   PROOF
   ================================= */

.proof{

    border-top:
        1px solid var(--line);

    padding:18px 18px 10px;
}

.proof-title{

    margin-bottom:10px;

    font-weight:700;

    color:var(--good);
}

.proof-body{

    white-space:pre-wrap;
}

/* =================================
   QED
   ================================= */

.proof-qed{

    margin-top:0px;

    padding:0px 18px 20px;

    font-style:italic;

    font-weight:600;

    color:var(--muted);

    opacity:.9;
}

/* =================================
   FORMULA / LAW / AXIOM
   ================================= */

.formula-block{

    margin:24px 0;

    border-radius:18px;

    overflow:hidden;

    border:
        1px solid var(--line);

    background:
        rgba(255,255,255,.03);
}

.formula-title{

    padding:
        14px
        18px;

    font-weight:700;

    border-bottom:
        1px solid var(--line);
}

.formula-content {
    padding:20px;
    white-space:pre-wrap;
    font-family:Consolas, Monaco, monospace;
    color:#f2f5ff;
}

.formula-block.formula{

    border-color:
        rgba(124,199,255,.20);
}

.formula-block.formula .formula-title{

    background:
        rgba(124,199,255,.10);

    color:var(--accent);
}

.formula-block.law{

    border-color:
        rgba(255,184,107,.20);
}

.formula-block.law .formula-title{

    background:
        rgba(255,184,107,.10);

    color:var(--warning);
}

.formula-block.axiom{

    border-color:
        rgba(123,224,177,.20);
}

.formula-block.axiom .formula-title{

    background:
        rgba(123,224,177,.10);

    color:var(--good);
}

/* =================================
   EXTENSION
   ================================= */

.extension{

    border-top:
        1px solid var(--line);

    padding:18px;
}

.extension-title{

    margin-bottom:10px;

    font-weight:700;

    color:var(--accent3);
}

.extension ul{

    margin:0;

    padding-left:22px;
}

.extension li{

    margin:6px 0;
}

/* ==========================
   NOTES
   ========================== */

.notes{

    border-top:
        1px solid var(--line);

    padding:18px;

    background:
        rgba(255,255,255,.025);
}

.notes-title{

    margin-bottom:10px;

    font-weight:700;

    color:var(--muted);
}

.notes-body{

    color:#d7e1f0;
}

/* =================================
   LIST
   ================================= */

.list{

    margin:24px 0;

    padding-left:28px;
}

.list li{

    margin:8px 0;
}

/* =================================
   TABLE
   ================================= */

.book-table{

    width:100%;

    border-collapse:collapse;

    margin:28px 0;

    overflow:hidden;

    border-radius:16px;
}

.book-table th{

    background:
        rgba(124,199,255,.12);

    color:var(--accent);

    text-align:left;

    padding:14px;
}

.book-table td{

    padding:14px;

    border-top:
        1px solid var(--line);
}

.book-table tr:hover{

    background:
        rgba(255,255,255,.03);
}

/* =================================
   COLLAPSE
   ================================= */

.collapse{

    margin:24px 0;

    border:
        1px solid var(--line);

    border-radius:16px;

    overflow:hidden;

    background:
        rgba(255,255,255,.03);
}

.collapse summary{

    cursor:pointer;

    list-style:none;

    padding:
        16px
        18px;

    font-weight:700;
}

.collapse summary::-webkit-details-marker{
    display:none;
}

.collapse summary:hover{

    background:
        rgba(255,255,255,.03);
}

.collapse-content{

    border-top:
        1px solid var(--line);

    padding:18px;

    white-space:pre-wrap;
}

/* =================================
   BUTTON UP
   ================================= */

.top-btn{

    position:fixed;

    right:24px;
    bottom:24px;

    width:52px;
    height:52px;

    display:none;
    align-items:center;
    justify-content:center;

    border:none;

    border-radius:50%;

    cursor:pointer;

    color:white;

    font-size:1.3rem;

    background:
        linear-gradient(
            135deg,
            var(--accent),
            var(--accent2)
        );

    box-shadow:
        0 10px 30px rgba(0,0,0,.35);
}

/* =================================
   ERROR
   ================================= */

.error{

    padding:24px;

    border-radius:16px;

    background:
        rgba(255,139,139,.08);

    border:
        1px solid rgba(255,139,139,.18);
}

/* =================================
   NOSCRIPT
   ================================= */

.noscript{

    max-width:1000px;

    margin:30px auto;

    padding:20px;

    border-radius:14px;

    background:
        rgba(255,139,139,.08);

    border:
        1px solid rgba(255,139,139,.18);
}

/* =================================
   MOBILE
   ================================= */

@media (max-width:1100px){

    .page-shell{

        grid-template-columns:1fr;
    }

    .toc-panel{

        position:relative;

        top:auto;
    }
}

@media (max-width:700px){

    .site-header{

        padding:
            50px
            20px
            30px;
    }

    .page-shell{

        padding:
            0
            16px
            40px;
    }

    .book{

        padding:
            24px
            20px;
    }

    .chapter > h2{

        font-size:1.8rem;
    }

    .section > h3{

        font-size:1.35rem;
    }
}

/* =================================
   BACKGROUND ORBS
   ================================= */

.bg-orb{

    position:fixed;

    border-radius:50%;

    pointer-events:none;

    filter:blur(90px);

    opacity:.35;

    z-index:-1;
}

.bg-orb-1{

    width:500px;
    height:500px;

    left:-150px;
    top:-120px;

    background:
        rgba(124,199,255,.20);

    animation:
        orbFloat1 24s ease-in-out infinite;
}

.bg-orb-2{

    width:450px;
    height:450px;

    right:-100px;
    top:20%;

    background:
        rgba(176,140,255,.18);

    animation:
        orbFloat2 30s ease-in-out infinite;
}

.bg-orb-3{

    width:550px;
    height:550px;

    left:30%;
    bottom:-250px;

    background:
        rgba(123,224,177,.12);

    animation:
        orbFloat3 36s ease-in-out infinite;
}

/* =================================
   REFERENCE
   ================================= */

.reference-item{

    margin-bottom:20px;

    border-bottom:
        1px solid var(--line);
}

.reference-item:first-child{

    margin-top:10px;
}

.reference-item:last-child{

    border-bottom:none;

    margin-bottom:0px;
}

.reference-item-title{

    margin:0 0 8px;

    font-weight:700;
}

.reference-item-body{

    margin:0;

    padding:8px 0;
}

.reference-item .formula-content{

    margin-top:8px;
}

.reference-item .proof{

    border-top:none;

    padding:0px 18px 10px;
}

.reference-item .proof-body {

    white-space: normal;

    padding-top: 0;
}

.reference-formula{

    margin-top:6px;

    padding:8px 0;

    white-space:normal;

    font-family:
        Consolas,
        Monaco,
        monospace;

    color:#f2f5ff;
}

/* =================================
   INTERNAL LINKS
   ================================= */

.book-link,
.reference-link{

    color:var(--text);

    text-decoration:underline;

    transition:.2s;

    cursor:pointer;
}

.book-link:hover,
.reference-link:hover{

    color:var(--accent2);

    text-decoration:underline;
}

.book-link:visited,
.reference-link:visited{

    color:var(--accent);
}

.book-link:active,
.reference-link:active{

    color:var(--accent2);
}

@keyframes orbFloat1{

    0%,100%{
        transform:
            translate(0,0);
    }

    50%{
        transform:
            translate(90px,60px);
    }
}

@keyframes orbFloat2{

    0%,100%{
        transform:
            translate(0,0);
    }

    50%{
        transform:
            translate(-105px,90px);
    }
}

@keyframes orbFloat3{

    0%,100%{
        transform:
            translate(0,0);
    }

    50%{
        transform:
            translate(60px,-120px);
    }
}

@media (max-width:900px) and (orientation:portrait){

    h2[id],
    h3[id]{

        scroll-margin-top:90px;
    }

    .formula-block[id],
    .callout--theorem[id]{

        scroll-margin-top:90px;
    }

    .page-shell{
        display:block;
    }

    .toc-panel{

        position:fixed;

        top:0;
        left:0;
        right:0;

        z-index:1000;

        border-radius:0;

        max-height:80vh;
    }

    .toc-panel__head{
        display:none;
    }

    .toc-mobile-header{

        display:flex;

        align-items:center;
        justify-content:center;

        height:56px;

        cursor:pointer;

        font-weight:700;
    }

    .toc{
        display:none;
        overflow-y:auto;
        max-height:calc(80vh - 56px);
    }

    .toc.toc-open{
        display:block;
    }

    .book-shell{
        margin-top:76px;
    }
}

@media (orientation:landscape){

    .page-shell{

        display:grid;

        grid-template-columns:
            minmax(260px,320px)
            minmax(0,1fr);

        gap:24px;
    }

    .toc-panel{

        position:sticky;

        top:20px;

        left:auto;
        right:auto;

        max-height:calc(100vh - 40px);
    }

    .toc-panel__head{
        display:block;
    }

    .toc-mobile-header{
        display:none;
    }

    .toc{
        display:block !important;
    }

    .book-shell{
        margin-top:0;
    }
}