/* ===== Cognyzer / Terminus-2.0 Docs ===== */
:root {
    --c-orange: #fa9c3c;
    --c-coral:  #f07348;
    --c-red:    #e34951;
    --c-pink:   #c82561;
    --c-purple: #9d1e77;
    --c-deep:   #711d86;

    --c-ink:    #1a1626;
    --c-body:   #2b2438;
    --c-muted:  #6b6478;
    --c-line:   #ece8f4;
    --c-bg:     #ffffff;
    --c-soft:   #faf8fd;
    --c-card:   #f7f4fb;
    --c-code-bg:#1b1330;

    --grad-brand: linear-gradient(135deg,
                  #fa9c3c 0%, #f07348 22%, #e34951 44%,
                  #c82561 66%, #9d1e77 84%, #711d86 100%);

    --sidebar-w: 280px;
    --rightbar-w: 230px;
    --header-h: 60px;

    --shadow-sm: 0 2px 8px -4px rgba(26,22,38,.18);
    --shadow-md: 0 12px 36px -18px rgba(26,22,38,.35);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, 'Helvetica Neue', Arial, sans-serif;
    color: var(--c-body);
    background: var(--c-soft);
    font-size: 15px;
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}
a { color: var(--c-pink); text-decoration: none; }
a:hover { color: var(--c-deep); }

/* ===================================================================
   TOP BAR
   =================================================================== */
.topbar {
    position: sticky; top: 0; z-index: 50;
    height: var(--header-h);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 22px;
    background: rgba(255,255,255,.92);
    backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--c-line);
}
.brand {
    display: flex; align-items: center; gap: 12px;
    color: var(--c-ink); font-weight: 700;
}
.brand img { width: 28px; height: 28px; }
.brand .b-name {
    background: var(--grad-brand);
    -webkit-background-clip: text; background-clip: text;
    -webkit-text-fill-color: transparent; color: transparent;
    letter-spacing: .04em;
    font-size: 16px;
    text-transform: uppercase;
}
.brand .b-sub {
    color: var(--c-muted);
    font-weight: 500;
    font-size: 13px;
    border-left: 1px solid var(--c-line);
    padding-left: 12px;
    margin-left: 4px;
}
.topbar .actions { display: flex; align-items: center; gap: 14px; }
.topbar .actions a {
    color: var(--c-body);
    font-size: 13px;
    font-weight: 500;
    padding: 6px 12px;
    border-radius: 6px;
    border: 1px solid var(--c-line);
    transition: all .15s;
}
.topbar .actions a:hover { background: var(--c-card); color: var(--c-deep); border-color: var(--c-deep); }
.topbar .actions a.cta {
    background: var(--grad-brand); color: #fff; border-color: transparent;
}
.menu-btn {
    display: none;
    background: transparent;
    border: 1px solid var(--c-line);
    border-radius: 6px;
    padding: 6px 10px;
    color: var(--c-ink);
    font-size: 14px;
    cursor: pointer;
}

/* ===================================================================
   LAYOUT
   =================================================================== */
.layout {
    display: grid;
    grid-template-columns: var(--sidebar-w) minmax(0,1fr) var(--rightbar-w);
    gap: 0;
    max-width: 1440px;
    margin: 0 auto;
    align-items: start;
}

/* ===================================================================
   SIDEBAR (left)
   =================================================================== */
.sidebar {
    position: sticky;
    top: var(--header-h);
    height: calc(100vh - var(--header-h));
    overflow-y: auto;
    padding: 22px 16px 40px 22px;
    border-right: 1px solid var(--c-line);
    background: var(--c-bg);
}
.search-wrap {
    position: relative;
    margin-bottom: 18px;
}
.search-wrap input {
    width: 100%;
    padding: 9px 12px 9px 36px;
    border: 1px solid var(--c-line);
    border-radius: 8px;
    font-size: 13.5px;
    background: var(--c-soft);
    color: var(--c-body);
    transition: all .15s;
    font-family: inherit;
}
.search-wrap input:focus {
    outline: none;
    border-color: var(--c-pink);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(200,37,97,.12);
}
.search-wrap::before {
    content: "";
    position: absolute;
    left: 12px; top: 50%;
    width: 14px; height: 14px;
    transform: translateY(-50%);
    background: no-repeat center/contain url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b6478' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><circle cx='11' cy='11' r='7'/><path d='m21 21-4.3-4.3'/></svg>");
    opacity: .8;
}
.search-results {
    position: absolute;
    left: 0; right: 0; top: 100%;
    margin-top: 6px;
    background: #fff;
    border: 1px solid var(--c-line);
    border-radius: 10px;
    box-shadow: var(--shadow-md);
    max-height: 360px;
    overflow-y: auto;
    z-index: 20;
    display: none;
}
.search-results.open { display: block; }
.search-results .item {
    display: block;
    padding: 10px 14px;
    border-bottom: 1px solid var(--c-line);
    color: var(--c-body);
}
.search-results .item:last-child { border-bottom: none; }
.search-results .item:hover { background: var(--c-card); }
.search-results .item .t { font-weight: 600; color: var(--c-ink); font-size: 13.5px; }
.search-results .item .s { font-size: 11px; color: var(--c-pink); letter-spacing: .04em; text-transform: uppercase; }
.search-results .item .e { font-size: 12px; color: var(--c-muted); margin-top: 4px; line-height: 1.45; }
.search-results .empty {
    padding: 16px;
    color: var(--c-muted);
    font-size: 13px;
    text-align: center;
}

.nav-section { margin-bottom: 18px; }
.nav-section-head {
    display: flex; align-items: baseline; gap: 8px;
    padding: 6px 6px;
    cursor: pointer;
    user-select: none;
    border-radius: 6px;
}
.nav-section-head:hover { background: var(--c-card); }
.nav-section-num {
    font-family: 'JetBrains Mono', ui-monospace, Menlo, monospace;
    font-size: 10px;
    color: #fff;
    background: var(--grad-brand);
    padding: 2px 6px;
    border-radius: 4px;
    letter-spacing: .06em;
}
.nav-section-title {
    font-size: 12.5px;
    font-weight: 700;
    color: var(--c-ink);
    text-transform: uppercase;
    letter-spacing: .06em;
}
.nav-section-arrow {
    margin-left: auto;
    color: var(--c-muted);
    font-size: 11px;
    transition: transform .2s;
}
.nav-section.collapsed .nav-section-arrow { transform: rotate(-90deg); }
.nav-list { list-style: none; padding: 4px 0 0 14px; margin: 0; border-left: 1px dashed var(--c-line); }
.nav-section.collapsed .nav-list { display: none; }
.nav-list li { margin: 0; }
.nav-list a {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 5px 10px;
    color: var(--c-body);
    font-size: 13px;
    border-radius: 6px;
    line-height: 1.4;
    transition: all .12s;
}
.nav-list a:hover { background: var(--c-card); color: var(--c-deep); }
.nav-list a.active {
    background: linear-gradient(135deg, rgba(250,156,60,.10), rgba(157,30,119,.10));
    color: var(--c-deep);
    font-weight: 600;
    border-left: 2px solid var(--c-pink);
    padding-left: 10px;
    margin-left: -2px;
}
.nav-list .num {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    color: var(--c-pink);
    flex-shrink: 0;
    width: 18px;
    opacity: .85;
}

/* ===================================================================
   MAIN CONTENT
   =================================================================== */
.content {
    padding: 36px 48px 80px;
    min-width: 0;
}
.breadcrumb {
    font-size: 12px;
    letter-spacing: .04em;
    color: var(--c-muted);
    margin-bottom: 18px;
    display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
}
.breadcrumb a { color: var(--c-muted); }
.breadcrumb a:hover { color: var(--c-deep); }
.breadcrumb .sep { opacity: .5; }
.breadcrumb .cur { color: var(--c-ink); font-weight: 600; }

.chapter-head {
    margin-bottom: 22px;
    padding-bottom: 22px;
    border-bottom: 1px solid var(--c-line);
}
.chapter-head .meta {
    display: flex; align-items: center; gap: 10px;
    margin-bottom: 10px;
}
.chapter-head .num {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    background: var(--grad-brand);
    color: #fff;
    padding: 3px 9px;
    border-radius: 5px;
    letter-spacing: .08em;
}
.chapter-head .tag {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .15em;
    color: var(--c-muted);
}
.chapter-head h1 {
    font-size: 34px;
    font-weight: 800;
    color: var(--c-ink);
    margin: 4px 0 0;
    line-height: 1.15;
    letter-spacing: -.02em;
}

article { font-size: 15px; }

article h1, article h2, article h3, article h4, article h5, article h6 {
    color: var(--c-ink);
    font-weight: 700;
    line-height: 1.3;
    margin: 1.8em 0 .55em;
    scroll-margin-top: calc(var(--header-h) + 16px);
}
article h1 {
    font-size: 26px;
    border-bottom: 2px solid var(--c-line);
    padding-bottom: 8px;
}
article h2 {
    font-size: 22px;
    color: var(--c-purple);
    border-left: 4px solid var(--c-pink);
    padding-left: 12px;
}
article h3 { font-size: 18px; color: var(--c-deep); }
article h4 {
    font-size: 14px; color: var(--c-pink);
    text-transform: uppercase; letter-spacing: .05em;
}
article h5 { font-size: 13px; }
article h6 { font-size: 12px; color: var(--c-muted); }

article p { margin: .55em 0 .9em; }
article a { color: var(--c-pink); border-bottom: 1px solid rgba(200,37,97,.25); }
article a:hover { color: var(--c-deep); border-color: var(--c-deep); }
article ul, article ol { margin: .5em 0 1em; padding-left: 1.4em; }
article li { margin: .25em 0; }
article hr {
    border: 0; height: 2px;
    background: var(--grad-brand);
    margin: 2em 0; opacity: .55;
    border-radius: 2px;
}

article blockquote {
    margin: 1.2em 0;
    padding: 12px 18px;
    background: linear-gradient(135deg, #fff7ec 0%, #fdecf2 100%);
    border-left: 4px solid var(--c-coral);
    border-radius: 0 10px 10px 0;
    font-style: italic;
    color: var(--c-body);
}
article blockquote p:first-child { margin-top: 0; }
article blockquote p:last-child  { margin-bottom: 0; }

article code {
    font-family: 'JetBrains Mono', ui-monospace, Menlo, Monaco, Consolas, monospace;
    font-size: .89em;
    background: #f3eef9;
    color: var(--c-deep);
    padding: 2px 6px;
    border-radius: 5px;
    border: 1px solid #ece4f5;
}
article pre,
article .codehilite {
    background: var(--c-code-bg);
    color: #f3ecff;
    border-radius: 10px;
    padding: 14px 16px;
    overflow-x: auto;
    line-height: 1.55;
    font-size: 13px;
    margin: 1em 0;
    box-shadow: 0 8px 24px -14px rgba(113,29,134,.5);
    border: 1px solid #2a1d44;
}
article pre code,
article .codehilite code {
    background: transparent;
    color: inherit;
    padding: 0;
    border: 0;
    font-size: 13px;
}

article table {
    width: 100%;
    border-collapse: collapse;
    margin: 1em 0 1.4em;
    font-size: 13.5px;
    background: var(--c-bg);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    display: table;
}
article thead { background: var(--grad-brand); color: #fff; }
article th { text-align: left; padding: 10px 14px; font-weight: 600; font-size: 12.5px; letter-spacing: .03em; }
article td { padding: 9px 14px; border-bottom: 1px solid var(--c-line); vertical-align: top; }
article tbody tr:nth-child(even) { background: var(--c-soft); }
article tbody tr:last-child td { border-bottom: none; }
.table-scroll { overflow-x: auto; }

article img { max-width: 100%; border-radius: 10px; margin: 1em 0; }

article details {
    margin: 1em 0;
    padding: 8px 14px;
    background: var(--c-card);
    border: 1px solid var(--c-line);
    border-radius: 8px;
}
article details summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--c-deep);
    padding: 4px 0;
}
article details[open] { padding-bottom: 12px; }

article .admonition {
    margin: 1em 0; padding: 12px 16px;
    border-radius: 10px;
    background: var(--c-card);
    border-left: 4px solid var(--c-pink);
}
article .admonition-title { font-weight: 700; color: var(--c-deep); margin-bottom: 4px; }

/* prev / next */
.pager {
    margin-top: 50px;
    padding-top: 22px;
    border-top: 1px solid var(--c-line);
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}
.pager a {
    display: block;
    padding: 14px 18px;
    border: 1px solid var(--c-line);
    border-radius: 12px;
    background: var(--c-bg);
    color: var(--c-body);
    transition: all .15s;
    border-bottom: 1px solid var(--c-line);
}
.pager a:hover {
    border-color: var(--c-pink);
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}
.pager .dir {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .15em;
    color: var(--c-muted);
}
.pager .lbl {
    font-weight: 600;
    color: var(--c-ink);
    margin-top: 4px;
    display: block;
}
.pager .next { text-align: right; }
.pager .placeholder {
    visibility: hidden;
    pointer-events: none;
}

/* ===================================================================
   RIGHT IN-PAGE TOC
   =================================================================== */
.page-toc {
    position: sticky;
    top: var(--header-h);
    height: calc(100vh - var(--header-h));
    overflow-y: auto;
    padding: 36px 22px;
    font-size: 13px;
    border-left: 1px solid var(--c-line);
}
.page-toc .h {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .15em;
    color: var(--c-muted);
    font-weight: 700;
    margin-bottom: 12px;
}
.page-toc ul { list-style: none; padding: 0; margin: 0; border-left: 2px solid var(--c-line); }
.page-toc li { margin: 0; }
.page-toc a {
    display: block;
    padding: 4px 12px;
    color: var(--c-muted);
    border-left: 2px solid transparent;
    margin-left: -2px;
    line-height: 1.45;
    transition: all .12s;
    font-size: 12.5px;
}
.page-toc a:hover { color: var(--c-deep); }
.page-toc a.active {
    color: var(--c-pink);
    border-left-color: var(--c-pink);
    font-weight: 600;
}
.page-toc ul ul a { padding-left: 24px; font-size: 12px; }

/* ===================================================================
   LANDING PAGE (index.html)
   =================================================================== */
.hero {
    position: relative;
    overflow: hidden;
    color: #fff;
    padding: 80px 22px 100px;
    background:
        radial-gradient(circle at 18% 12%, rgba(250,156,60,.45) 0%, transparent 45%),
        radial-gradient(circle at 82% 88%, rgba(113,29,134,.6) 0%, transparent 50%),
        linear-gradient(135deg, #1a0f24 0%, #2a1138 45%, #3d1652 100%);
}
.hero-inner {
    max-width: 1100px;
    margin: 0 auto;
    text-align: center;
}
.hero .eyebrow {
    font-size: 12px;
    letter-spacing: .42em;
    text-transform: uppercase;
    color: rgba(255,255,255,.6);
    font-weight: 600;
    margin-bottom: 14px;
}
.hero h1 {
    font-size: 76px;
    line-height: 1;
    font-weight: 800;
    margin: 0 0 18px;
    letter-spacing: -.025em;
    background: linear-gradient(135deg, #fa9c3c 0%, #f07348 28%, #e34951 50%, #c82561 72%, #9d1e77 100%);
    -webkit-background-clip: text; background-clip: text;
    -webkit-text-fill-color: transparent; color: transparent;
}
.hero p {
    font-size: 19px;
    color: rgba(255,255,255,.85);
    max-width: 680px;
    margin: 0 auto 28px;
    font-weight: 300;
    line-height: 1.5;
}
.hero .ctas { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 12px 22px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 14px;
    transition: all .15s;
    border: 1px solid transparent;
}
.btn-primary { background: #fff; color: var(--c-deep); }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 12px 28px -10px rgba(250,156,60,.5); color: var(--c-deep); }
.btn-ghost {
    background: rgba(255,255,255,.04);
    color: #fff;
    border-color: rgba(255,255,255,.25);
}
.btn-ghost:hover { background: rgba(255,255,255,.10); color: #fff; }

.stats {
    display: grid;
    grid-template-columns: repeat(4,1fr);
    gap: 16px;
    margin-top: 50px;
}
.stat {
    background: rgba(255,255,255,.05);
    border: 1px solid rgba(255,255,255,.12);
    border-radius: 14px;
    padding: 18px;
    text-align: center;
}
.stat .n {
    font-size: 30px;
    font-weight: 800;
    background: linear-gradient(135deg,#fa9c3c,#c82561);
    -webkit-background-clip: text; background-clip: text;
    -webkit-text-fill-color: transparent; color: transparent;
}
.stat .l { font-size: 11px; letter-spacing: .15em; text-transform: uppercase; color: rgba(255,255,255,.7); }

.sections-wrap {
    max-width: 1100px;
    margin: 0 auto;
    padding: 60px 22px 80px;
}
.sections-wrap h2 {
    font-size: 28px;
    margin: 0 0 6px;
    color: var(--c-ink);
}
.sections-wrap .sub {
    color: var(--c-muted);
    margin: 0 0 32px;
    font-size: 14px;
}

.section-card {
    background: var(--c-bg);
    border: 1px solid var(--c-line);
    border-radius: 14px;
    padding: 22px 24px;
    margin-bottom: 18px;
    box-shadow: var(--shadow-sm);
    transition: all .15s;
}
.section-card:hover {
    border-color: var(--c-pink);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}
.section-card .head {
    display: flex; align-items: baseline; gap: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--c-line);
    margin-bottom: 12px;
}
.section-card .num {
    background: var(--grad-brand);
    color: #fff;
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    padding: 3px 9px;
    border-radius: 5px;
    letter-spacing: .08em;
}
.section-card h3 { margin: 0; font-size: 18px; color: var(--c-ink); }
.section-card .desc { color: var(--c-muted); font-size: 13px; margin-left: auto; font-style: italic; }
.section-card .chapters {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 6px;
}
.section-card .chapters a {
    display: flex; align-items: baseline; gap: 8px;
    padding: 7px 10px;
    border-radius: 6px;
    font-size: 13.5px;
    color: var(--c-body);
    transition: background .12s;
}
.section-card .chapters a:hover { background: var(--c-card); color: var(--c-deep); }
.section-card .chapters a .num {
    background: transparent;
    color: var(--c-pink);
    font-size: 11px;
    padding: 0;
    width: 22px;
    flex-shrink: 0;
}

/* ===================================================================
   FOOTER
   =================================================================== */
.footer {
    border-top: 1px solid var(--c-line);
    padding: 22px;
    text-align: center;
    color: var(--c-muted);
    font-size: 12px;
    background: var(--c-bg);
}
.footer .b {
    background: var(--grad-brand);
    -webkit-background-clip: text; background-clip: text;
    -webkit-text-fill-color: transparent; color: transparent;
    font-weight: 700; letter-spacing: .12em;
}

/* ===================================================================
   RESPONSIVE
   =================================================================== */
@media (max-width: 1180px) {
    .layout { grid-template-columns: var(--sidebar-w) minmax(0,1fr); }
    .page-toc { display: none; }
}
@media (max-width: 880px) {
    .layout { grid-template-columns: 1fr; }
    .sidebar {
        position: fixed;
        top: var(--header-h);
        left: 0; right: 0;
        height: calc(100vh - var(--header-h));
        width: min(86%, 320px);
        background: #fff;
        z-index: 60;
        transform: translateX(-100%);
        transition: transform .25s ease;
        box-shadow: var(--shadow-md);
    }
    .sidebar.open { transform: translateX(0); }
    .menu-btn { display: inline-flex; }
    .content { padding: 22px 18px 60px; }
    .hero { padding: 56px 18px 64px; }
    .hero h1 { font-size: 50px; }
    .hero p  { font-size: 16px; }
    .stats { grid-template-columns: repeat(2,1fr); }
    .brand .b-sub { display: none; }
}

/* mobile sidebar overlay */
.sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(26,22,38,.45);
    z-index: 55;
}
.sidebar-overlay.open { display: block; }
