:root {
    --ink: #f4f0e6;
    --muted: #aaa79f;
    --paper: #080a09;
    --panel: #101310;
    --panel-soft: #151914;
    --line: rgba(244, 240, 230, 0.14);
    --gold: #e4b85b;
    --gold-soft: rgba(228, 184, 91, 0.12);
    --lime: #b7d66d;
    --lime-soft: rgba(183, 214, 109, 0.1);
    --warning: #e78a58;
    --warning-soft: rgba(231, 138, 88, 0.1);
    --max: 1160px;
}

* { box-sizing: border-box; }

html {
    scroll-behavior: smooth;
    scroll-padding-top: 88px;
}

body {
    margin: 0;
    background:
        radial-gradient(circle at 82% 4%, rgba(228, 184, 91, 0.08), transparent 28rem),
        radial-gradient(circle at 8% 18%, rgba(183, 214, 109, 0.05), transparent 24rem),
        var(--paper);
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.65;
}

a { color: inherit; }

.skip-link {
    position: fixed;
    left: 1rem;
    top: -5rem;
    z-index: 100;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    background: var(--gold);
    color: #111;
    font-weight: 800;
}

.skip-link:focus { top: 1rem; }

.course-header {
    position: sticky;
    top: 0;
    z-index: 30;
    border-bottom: 1px solid var(--line);
    background: rgba(8, 10, 9, 0.9);
    backdrop-filter: blur(18px);
}

.header-inner,
.course-shell,
.hero-inner,
.course-footer-inner {
    width: min(calc(100% - 2rem), var(--max));
    margin-inline: auto;
}

.header-inner {
    min-height: 70px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.7rem;
    color: var(--ink);
    text-decoration: none;
    font-weight: 820;
    letter-spacing: -0.02em;
}

.brand img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
}

.brand small {
    display: block;
    color: var(--muted);
    font-size: 0.68rem;
    font-weight: 650;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.text-link,
.button {
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    padding: 0.6rem 0.95rem;
    font-size: 0.83rem;
    font-weight: 780;
    text-decoration: none;
}

.text-link { color: var(--muted); }
.text-link:hover { color: var(--ink); }

.button {
    border: 1px solid var(--gold);
    background: var(--gold);
    color: #16130d;
}

.button:hover { background: #f1c76f; }

.button.secondary {
    border-color: var(--line);
    background: transparent;
    color: var(--ink);
}

.button.secondary:hover { border-color: var(--gold); }

.reading-progress {
    height: 2px;
    background: rgba(255, 255, 255, 0.04);
}

.reading-progress span {
    display: block;
    width: 0;
    height: 100%;
    background: linear-gradient(90deg, var(--lime), var(--gold));
    transition: width 120ms linear;
}

.course-hero {
    padding: clamp(4rem, 8vw, 7.5rem) 0 3.5rem;
    border-bottom: 1px solid var(--line);
}

.hero-inner {
    display: grid;
    grid-template-columns: minmax(0, 1.3fr) minmax(280px, 0.7fr);
    gap: clamp(2rem, 6vw, 5rem);
    align-items: end;
}

.eyebrow,
.chapter-kicker,
.mini-label {
    color: var(--gold);
    font-size: 0.73rem;
    font-weight: 850;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

h1,
h2,
h3,
.pull-quote {
    font-family: Georgia, "Times New Roman", serif;
}

h1 {
    max-width: 820px;
    margin: 0.75rem 0 1.1rem;
    font-size: clamp(3rem, 7vw, 6.3rem);
    line-height: 0.96;
    letter-spacing: -0.055em;
}

.hero-copy {
    max-width: 700px;
    margin: 0;
    color: #c9c5ba;
    font-size: clamp(1.05rem, 2vw, 1.3rem);
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.7rem;
    margin-top: 1.65rem;
}

.hero-facts {
    display: grid;
    gap: 0.85rem;
    padding: 1.25rem;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: rgba(16, 19, 16, 0.78);
}

.hero-fact {
    display: grid;
    grid-template-columns: 100px 1fr;
    gap: 0.85rem;
    align-items: start;
}

.hero-fact strong {
    color: var(--gold);
    font-family: Georgia, "Times New Roman", serif;
    font-size: 1.65rem;
    line-height: 1;
}

.hero-fact span {
    color: var(--muted);
    font-size: 0.87rem;
}

.hero-fact span b {
    display: block;
    margin-bottom: 0.12rem;
    color: var(--ink);
}

.course-shell {
    display: grid;
    grid-template-columns: 250px minmax(0, 760px);
    gap: clamp(2rem, 6vw, 5rem);
    align-items: start;
    padding: 3rem 0 6rem;
}

.course-nav {
    position: sticky;
    top: 98px;
    max-height: calc(100vh - 118px);
    overflow: auto;
    padding: 1rem;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: rgba(16, 19, 16, 0.72);
}

.course-nav-title {
    margin: 0 0 0.7rem;
    color: var(--muted);
    font-size: 0.7rem;
    font-weight: 850;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.course-nav ol {
    display: grid;
    gap: 0.12rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.course-nav a {
    display: grid;
    grid-template-columns: 1.65rem 1fr;
    gap: 0.55rem;
    padding: 0.6rem 0.55rem;
    border-radius: 9px;
    color: var(--muted);
    font-size: 0.78rem;
    line-height: 1.3;
    text-decoration: none;
}

.course-nav a span:first-child { color: var(--gold); }

.course-nav a:hover,
.course-nav a[aria-current="location"] {
    background: var(--gold-soft);
    color: var(--ink);
}

.course-content { min-width: 0; }

.chapter {
    position: relative;
    padding: 1rem 0 1.75rem;
    border-bottom: 1px solid var(--line);
}

.chapter + .chapter { padding-top: 2.25rem; }
.chapter:last-of-type { border-bottom: 0; }

.chapter-header { margin-bottom: 1.5rem; }

.chapter-heading-row {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 1rem;
}

.chapter h2 {
    max-width: 680px;
    margin: 0.55rem 0 0;
    font-size: clamp(1.5rem, 2vw, 1.9rem);
    line-height: 1.2;
    letter-spacing: -0.02em;
}

.share-button {
    min-width: 42px;
    min-height: 42px;
    display: inline-grid;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
}

.share-button:hover,
.share-button:focus-visible {
    border-color: var(--gold);
    color: var(--gold);
}

.chapter-deck {
    max-width: 680px;
    margin: 1rem 0 0;
    color: #c9c5ba;
    font-size: 1.12rem;
}

.chapter h3 {
    margin: 2.4rem 0 0.7rem;
    font-size: 1.45rem;
    line-height: 1.2;
}

.chapter p { margin: 0.7rem 0; }

.source-answer {
    font-size: 1.02rem;
    line-height: 1.78;
}

.source-answer p {
    margin: 1rem 0;
}

.source-question p {
    margin: 0.72rem 0 0;
}

.source-question p:first-of-type {
    margin-top: 0.45rem;
}

.source-question p:last-child {
    margin-bottom: 0;
}

.chapter ul,
.chapter ol { padding-left: 1.25rem; }
.chapter li {
    line-height: 1.72;
}

.chapter li + li { margin-top: 0.8rem; }

.plain-definition,
.worked-example,
.myth,
.lesson-check,
.source-note,
.decision-card {
    margin: 1.7rem 0;
    padding: 1.2rem 1.25rem;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--panel);
}

.plain-definition { border-left: 3px solid var(--gold); }

.plain-definition strong,
.worked-example > strong,
.myth > strong,
.decision-card > strong {
    display: block;
    margin-bottom: 0.35rem;
    color: var(--ink);
}

.worked-example {
    border-color: rgba(183, 214, 109, 0.28);
    background: var(--lime-soft);
}

.worked-example > strong { color: var(--lime); }

.example-grid,
.ledger-grid,
.comparison-grid,
.scenario-grid {
    display: grid;
    gap: 0.75rem;
    margin-top: 1rem;
}

.example-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.ledger-grid,
.comparison-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.scenario-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.example-cell,
.ledger-card,
.comparison-card,
.scenario-card {
    padding: 0.85rem;
    border: 1px solid var(--line);
    border-radius: 11px;
    background: rgba(8, 10, 9, 0.5);
}

.example-cell span,
.ledger-card span,
.comparison-card span,
.scenario-card span {
    display: block;
    margin-bottom: 0.2rem;
    color: var(--muted);
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.example-cell strong,
.ledger-card strong,
.comparison-card strong,
.scenario-card strong {
    display: block;
    color: var(--ink);
    font-size: 1.03rem;
}

.ledger-card:first-child { border-top: 3px solid var(--lime); }
.ledger-card:last-child { border-top: 3px solid var(--warning); }

.stress-ladder {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 3px;
    margin: 1.2rem 0;
}

.stress-ladder span {
    min-height: 74px;
    display: grid;
    place-items: center;
    padding: 0.45rem;
    border: 1px solid var(--line);
    background: var(--panel-soft);
    color: var(--muted);
    font-size: 0.75rem;
    text-align: center;
}

.stress-ladder span:first-child { border-radius: 10px 0 0 10px; }
.stress-ladder span:last-child { border-radius: 0 10px 10px 0; }
.stress-ladder .danger { background: var(--warning-soft); color: #f3b391; }

.formula {
    margin: 1.15rem 0;
    padding: 1rem 1.1rem;
    overflow-x: auto;
    border: 1px dashed rgba(228, 184, 91, 0.42);
    border-radius: 12px;
    background: var(--gold-soft);
    color: #f2d391;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.87rem;
}

.table-scroll {
    margin: 1.35rem 0;
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 12px;
}

.table-scroll table {
    width: 100%;
    min-width: 560px;
    border-collapse: collapse;
    background: var(--panel);
    font-size: 0.88rem;
}

.table-scroll th,
.table-scroll td {
    padding: 0.8rem 0.9rem;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

.table-scroll th {
    color: var(--gold);
    font-size: 0.73rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.table-scroll tbody tr:last-child td {
    border-bottom: 0;
}

.source-diagram {
    margin: 1.35rem 0;
    padding: 1rem;
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--panel);
    color: #d8d2c5;
    font: 0.82rem/1.6 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.myth {
    border-color: rgba(231, 138, 88, 0.32);
    background: var(--warning-soft);
}

.myth > strong { color: #f3b391; }

.pull-quote {
    margin: 2.2rem 0;
    padding-left: 1.2rem;
    border-left: 3px solid var(--gold);
    color: #ead8ae;
    font-size: clamp(1.35rem, 3vw, 2rem);
    line-height: 1.3;
}

.lesson-check summary,
.source-note summary {
    cursor: pointer;
    color: var(--ink);
    font-weight: 800;
}

.lesson-check summary::marker,
.source-note summary::marker { color: var(--gold); }

.lesson-check p:last-child,
.source-note p:last-child { margin-bottom: 0; }

.source-note { color: var(--muted); font-size: 0.88rem; }

.source-note a,
.sources a {
    color: #f0ca77;
    text-underline-offset: 0.2em;
}

.chapter-nav {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 2.3rem;
}

.chapter-nav a {
    color: var(--gold);
    font-size: 0.83rem;
    font-weight: 780;
    text-decoration: none;
}

.sources {
    padding-top: 4.5rem;
}

.sources h2 {
    font-size: clamp(1.5rem, 2vw, 1.9rem);
    line-height: 1.2;
    letter-spacing: -0.02em;
}

.sources li + li { margin-top: 0.8rem; }

.course-cta {
    margin-top: 3rem;
    padding: 1.5rem;
    border: 1px solid rgba(228, 184, 91, 0.3);
    border-radius: 18px;
    background: linear-gradient(135deg, var(--gold-soft), rgba(183, 214, 109, 0.06));
}

.course-cta h2 { margin: 0.35rem 0 0.5rem; }
.course-cta p { color: #c9c5ba; }

.course-footer {
    border-top: 1px solid var(--line);
    padding: 2.2rem 0;
    color: var(--muted);
}

.course-footer-inner {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.course-footer-main,
.course-footer-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
}

.course-footer-brand {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 0.7rem;
    min-height: 44px;
    color: var(--ink);
    text-decoration: none;
}

.course-footer-brand img {
    width: 38px;
    height: 38px;
    border-radius: 50%;
}

.course-footer-brand strong,
.course-footer-brand small {
    display: block;
}

.course-footer-brand strong {
    font-size: 0.84rem;
}

.course-footer-brand small {
    color: var(--muted);
    font-size: 0.67rem;
}

.course-footer-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0 1.2rem;
}

.course-footer-links a {
    display: inline-flex;
    align-items: center;
    gap: 0.38rem;
    min-height: 44px;
    color: var(--muted);
    font-size: 0.72rem;
    text-decoration: none;
}

.course-footer-links a:hover,
.course-footer-links a:focus-visible {
    color: var(--ink);
}

.course-footer-meta {
    padding-top: 0.85rem;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 0.72rem;
}

.toast {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    z-index: 40;
    padding: 0.75rem 1rem;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #171b16;
    color: var(--ink);
    font-size: 0.82rem;
    box-shadow: 0 16px 44px rgba(0, 0, 0, 0.42);
}

@media (max-width: 920px) {
    .hero-inner { grid-template-columns: 1fr; }
    .hero-facts { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .hero-fact { grid-template-columns: 1fr; }
    .course-shell { grid-template-columns: 1fr; }
    .course-nav {
        position: relative;
        top: auto;
        max-height: none;
    }
    .course-nav ol { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
    .header-inner { min-height: 64px; }
    .brand small,
    .header-actions .text-link { display: none; }
    .course-hero { padding-top: 3.5rem; }
    .hero-facts { grid-template-columns: 1fr; }
    .hero-fact { grid-template-columns: 100px 1fr; }
    .course-shell { width: min(calc(100% - 1.25rem), var(--max)); padding-top: 1rem; }
    .course-nav ol { grid-template-columns: 1fr; }
    .chapter + .chapter { padding-top: 1.75rem; }
    .example-grid,
    .ledger-grid,
    .comparison-grid,
    .scenario-grid { grid-template-columns: 1fr; }
    .stress-ladder { grid-template-columns: 1fr; }
    .stress-ladder span:first-child,
    .stress-ladder span:last-child { border-radius: 8px; }
    .chapter-heading-row { align-items: center; }
    .chapter-nav { flex-direction: column; }
    .course-footer-main,
    .course-footer-meta { align-items: flex-start; flex-direction: column; gap: 0.4rem; }
    .course-footer-links { justify-content: flex-start; column-gap: 1rem; }
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
    }
}
