:root {
    --bg-canvas: #08101a;
    --bg-surface: #0e1826;
    --bg-surface-alt: #131f31;
    --bg-glass: rgba(14, 24, 38, 0.82);
    --text-primary: #e7eef8;
    --text-secondary: #b8c9df;
    --text-muted: #8ba0bc;
    --accent-cyan: #00d3a7;
    --accent-blue: #4ea1ff;
    --accent-amber: #f5b84e;
    --accent-rose: #ff7e79;
    --border-soft: rgba(93, 122, 156, 0.38);
    --border-strong: rgba(108, 141, 180, 0.55);
    --shadow-elevated: 0 18px 44px rgba(3, 8, 15, 0.45);
    --radius-xl: 24px;
    --radius-lg: 18px;
    --radius-md: 12px;
    --container-max: 1240px;
}

[data-theme="light"] {
    --bg-canvas: #f4f8fc;
    --bg-surface: #ffffff;
    --bg-surface-alt: #eff4fb;
    --bg-glass: rgba(255, 255, 255, 0.9);
    --text-primary: #132235;
    --text-secondary: #304866;
    --text-muted: #5e7694;
    --accent-cyan: #00a986;
    --accent-blue: #2f7de0;
    --accent-amber: #b9861d;
    --accent-rose: #cc5e5a;
    --border-soft: rgba(125, 152, 184, 0.32);
    --border-strong: rgba(94, 127, 165, 0.5);
    --shadow-elevated: 0 14px 36px rgba(34, 68, 104, 0.12);
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    font-family: 'Source Serif 4', Georgia, serif;
    font-size: 19px;
    line-height: 1.78;
    color: var(--text-primary);
    background: radial-gradient(circle at 82% 6%, rgba(78, 161, 255, 0.16), transparent 42%),
                radial-gradient(circle at 16% 12%, rgba(0, 211, 167, 0.12), transparent 40%),
                var(--bg-canvas);
    -webkit-font-smoothing: antialiased;
}

p,
li {
    color: var(--text-secondary);
}

a {
    color: inherit;
}

.progress-track {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: rgba(44, 61, 86, 0.35);
    z-index: 1600;
}

.progress-fill {
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, var(--accent-cyan), var(--accent-blue));
    transform-origin: left;
    transform: scaleX(0);
}

.controls {
    position: fixed;
    top: 18px;
    left: 0;
    right: 0;
    z-index: 1400;
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: var(--container-max);
    margin: 0 auto;
    padding: 0 18px;
    pointer-events: none;
}

.controls > * {
    pointer-events: auto;
}

.back-home,
.theme-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border-radius: 999px;
    border: 1px solid var(--border-soft);
    background: var(--bg-glass);
    backdrop-filter: blur(10px);
    text-decoration: none;
    color: var(--text-primary);
    font-family: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 13px;
    letter-spacing: 0.4px;
    padding: 11px 16px;
    box-shadow: var(--shadow-elevated);
}

.mobile-rail-toggle {
    display: none;
    align-items: center;
    gap: 7px;
    border-radius: 999px;
    border: 1px solid var(--border-soft);
    background: var(--bg-glass);
    backdrop-filter: blur(10px);
    color: var(--text-primary);
    font-family: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12px;
    letter-spacing: 0.3px;
    padding: 9px 12px;
    box-shadow: var(--shadow-elevated);
    opacity: 0;
    pointer-events: none;
    transform: translateY(-6px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.mobile-rail-toggle i {
    color: var(--accent-cyan);
}

.mobile-rail-toggle.is-visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.mobile-rail-panel {
    display: none;
}

.theme-toggle {
    cursor: pointer;
}

.back-home i,
.theme-toggle i {
    color: var(--accent-cyan);
}

.hero {
    max-width: var(--container-max);
    margin: 82px auto 26px;
    padding: 0 18px;
}

.hero-shell {
    border-radius: var(--radius-xl);
    overflow: hidden;
    border: 1px solid var(--border-soft);
    background: var(--bg-surface);
    box-shadow: var(--shadow-elevated);
}

.hero-art {
    width: 100%;
    display: block;
    border-bottom: 1px solid var(--border-soft);
}

.hero-copy {
    padding: 34px 36px 36px;
    background: linear-gradient(180deg, rgba(17, 30, 46, 0.52), transparent), var(--bg-surface);
}

.eyebrow {
    margin: 0 0 10px;
    font-family: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 13px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--accent-cyan);
}

.hero-title {
    margin: 0;
    font-family: 'Space Grotesk', 'Inter', sans-serif;
    font-size: clamp(2.2rem, 4.6vw, 3.45rem);
    line-height: 1.04;
    letter-spacing: -0.6px;
    color: var(--text-primary);
    max-width: 15ch;
}

.hero-subtitle {
    margin: 15px 0 0;
    font-size: clamp(1.05rem, 2vw, 1.26rem);
    color: var(--text-secondary);
    max-width: 58ch;
}

.hero-meta {
    margin: 20px 0 0;
    padding: 0;
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.hero-meta li {
    font-family: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12px;
    color: var(--text-muted);
    border: 1px solid var(--border-soft);
    background: var(--bg-surface-alt);
    border-radius: 999px;
    padding: 6px 11px;
}

.layout {
    max-width: var(--container-max);
    margin: 0 auto 86px;
    padding: 0 18px;
    display: grid;
    gap: 30px;
    grid-template-columns: 272px minmax(0, 1fr);
}

.ledger-nav {
    align-self: start;
    position: sticky;
    top: 92px;
    padding: 8px 0 6px 22px;
    background: transparent;
}

.ledger-nav::before {
    content: '';
    position: absolute;
    left: 9px;
    top: 6px;
    bottom: 6px;
    width: 1px;
    background: var(--border-soft);
}

.ledger-nav::after {
    content: '';
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 38%;
    border-radius: 99px;
    background: linear-gradient(180deg, var(--accent-cyan), var(--accent-blue));
}

.ledger-nav h2 {
    margin: 0 0 2px;
    font-family: 'Space Grotesk', 'Inter', sans-serif;
    font-size: 1.12rem;
    letter-spacing: 0.2px;
}

.ledger-nav p {
    margin: 0 0 14px;
    font-family: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--text-muted);
}

.phase-links {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.phase-link {
    display: grid;
    grid-template-columns: 10px 1fr;
    align-items: center;
    column-gap: 10px;
    text-decoration: none;
    border-radius: 8px;
    border: 1px solid transparent;
    color: var(--text-secondary);
    padding: 6px 8px;
    transition: border-color 0.18s ease, background-color 0.18s ease, color 0.18s ease;
    font-size: 0.89rem;
    line-height: 1.2;
}

.phase-dot {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: #385272;
}

.phase-link:hover {
    color: var(--text-primary);
    background: rgba(78, 161, 255, 0.06);
}

.phase-link.active {
    color: var(--text-primary);
    border-color: var(--border-soft);
    background: rgba(78, 161, 255, 0.11);
}

.phase-link.active .phase-dot {
    background: linear-gradient(180deg, var(--accent-cyan), var(--accent-blue));
}

.article {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.disclaimer-card,
.stat-band,
.section-card {
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
}

.disclaimer-card {
    padding: 0;
    margin-bottom: 28px;
}

.disclaimer-card p {
    margin: 0;
}

.disclaimer-label {
    margin: 0 0 10px;
    font-family: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12px;
    color: var(--text-muted);
    letter-spacing: 0.7px;
    text-transform: uppercase;
}

.disclaimer-card strong {
    color: var(--text-primary);
}

.stat-band {
    padding: 0 0 8px;
    display: grid;
    gap: 14px;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    margin-bottom: 26px;
}

.stat-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 92px;
}

.stat-value {
    font-family: 'Space Grotesk', 'Inter', sans-serif;
    font-size: clamp(2rem, 4vw, 2.7rem);
    line-height: 1;
    letter-spacing: -0.5px;
    color: var(--text-primary);
}

.stat-label {
    margin-top: 8px;
    font-family: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
}

.stat-arrow {
    font-family: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 20px;
    color: var(--accent-blue);
}

.section-card {
    padding: 0;
}

.section-card h2 {
    margin: 0 0 14px;
    font-family: 'Space Grotesk', 'Inter', sans-serif;
    font-size: clamp(1.3rem, 2.6vw, 1.86rem);
    line-height: 1.18;
    color: var(--text-primary);
}

.section-card p {
    margin: 0 0 15px;
}

.section-card p:last-child {
    margin-bottom: 0;
}

.section-card ul {
    margin: 0 0 16px;
    padding-left: 1.2em;
}

.section-card li {
    margin: 0 0 7px;
}

.section-card strong {
    color: var(--text-primary);
}

.callout {
    margin: 17px 0;
    padding: 2px 0 2px 14px;
    border: 0;
    border-left: 2px solid var(--border-soft);
    background: transparent;
    border-radius: 0;
}

.callout h3 {
    margin: 0 0 7px;
    font-family: 'Space Grotesk', 'Inter', sans-serif;
    font-size: 1.02rem;
}

.callout p {
    margin: 0;
}

.callout.reality {
    border-left-color: var(--accent-amber);
}

.callout.side-topic {
    border-left-color: var(--accent-blue);
}

blockquote {
    margin: 16px 0;
    padding: 0 0 0 14px;
    border-left: 2px solid var(--accent-cyan);
    background: transparent;
    color: var(--text-secondary);
    font-style: italic;
    border-radius: 0;
}

.section-divider {
    position: relative;
    border: 0;
    margin: 30px 0 34px;
    height: 12px;
}

.section-divider::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    height: 1px;
    background: var(--border-soft);
}

.section-divider::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 96px;
    height: 3px;
    border-radius: 99px;
    background: linear-gradient(90deg, var(--accent-cyan), var(--accent-blue));
}

code {
    font-family: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.9em;
    background: rgba(78, 161, 255, 0.12);
    border: 1px solid var(--border-soft);
    border-radius: 6px;
    padding: 1px 6px;
    color: var(--text-primary);
}

.section-kicker {
    margin: 0 0 10px;
    font-family: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 11px;
    letter-spacing: 0.7px;
    text-transform: uppercase;
    color: var(--text-muted);
}

.page-footer {
    max-width: var(--container-max);
    margin: 0 auto 28px;
    padding: 0 18px;
}

.page-footer-inner {
    border-radius: 0;
    border: 0;
    background: transparent;
    padding: 2px 0;
    font-family: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12px;
    color: var(--text-muted);
}

@media (max-width: 1080px) {
    body {
        font-size: 18px;
    }

    .layout {
        grid-template-columns: minmax(0, 1fr);
    }

    .mobile-rail-toggle {
        display: inline-flex;
        position: fixed;
        top: 14px;
        left: 50%;
        z-index: 1450;
        transform: translate(-50%, -6px);
    }

    .mobile-rail-toggle.is-visible {
        transform: translate(-50%, 0);
    }

    .ledger-nav {
        position: relative;
        top: 0;
        margin: 0 0 18px;
        padding: 0;
    }

    .ledger-nav::before,
    .ledger-nav::after {
        display: none;
    }

    .ledger-nav h2,
    .ledger-nav p {
        display: none;
    }

    .phase-links {
        display: flex;
        gap: 8px;
        overflow-x: auto;
        padding: 0 2px 2px 0;
        scrollbar-width: thin;
        -webkit-overflow-scrolling: touch;
        flex-wrap: wrap;
    }

    .phase-link {
        display: inline-flex;
        align-items: center;
        gap: 7px;
        grid-template-columns: none;
        white-space: nowrap;
        min-height: 0;
        font-size: 12.5px;
        padding: 8px 10px;
        border-radius: 999px;
        border: 1px solid var(--border-soft);
        background: var(--bg-surface);
    }

    .phase-link.active {
        border-color: var(--border-strong);
        background: rgba(78, 161, 255, 0.14);
    }

    .phase-dot {
        width: 6px;
        height: 6px;
    }

    .mobile-rail-panel {
        display: block;
        position: fixed;
        top: 56px;
        left: 12px;
        right: 12px;
        z-index: 1380;
        opacity: 0;
        pointer-events: none;
        transform: translateY(-8px);
        transition: opacity 0.18s ease, transform 0.18s ease;
    }

    .mobile-rail-panel.is-open {
        opacity: 1;
        pointer-events: auto;
        transform: translateY(0);
    }

    .mobile-rail-panel-inner {
        border-radius: 14px;
        background: var(--bg-glass);
        border: 1px solid var(--border-soft);
        box-shadow: var(--shadow-elevated);
        padding: 10px;
    }

    .mobile-rail-panel .phase-links {
        display: flex;
        flex-direction: column;
        gap: 8px;
        max-height: min(62vh, 340px);
        overflow-y: auto;
        overflow-x: hidden;
        padding-right: 2px;
    }

    .mobile-rail-panel .phase-link {
        width: 100%;
        justify-content: flex-start;
        border-radius: 10px;
    }
}

@media (max-width: 760px) {
    .controls {
        top: 12px;
        padding: 0 12px;
    }

    .back-home,
    .theme-toggle {
        padding: 9px 13px;
        font-size: 12px;
    }

    .hero {
        margin-top: 72px;
        padding: 0 12px;
    }

    .hero-copy {
        padding: 22px 18px 24px;
    }

    .layout {
        padding: 0 12px;
        gap: 10px;
        margin-bottom: 56px;
    }

    .ledger-nav {
        margin: 0 0 14px;
    }

    .mobile-rail-toggle {
        top: 12px;
    }

    .mobile-rail-panel {
        top: 52px;
        left: 10px;
        right: 10px;
    }

    .mobile-rail-panel-inner {
        padding: 9px;
    }

    .stat-band {
        grid-template-columns: 1fr;
    }

    .stat-arrow {
        justify-self: center;
        transform: rotate(90deg);
    }

    .section-divider {
        margin: 24px 0 26px;
    }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }
}
