:root {
    /* ===== Mahogany palette ===== */
    --bg-main: #2b1c16;
    --panel: #34231c;
    --sand: #f0e4cf;
    --sand-soft: #d2c1a6;
    --accent: #d7b06a;
    --muted: rgba(240, 228, 207, 0.62);

    --font-main: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

    /* Layout */
    --wrap: 860px;
    --text-max-width: 700px;

    /* Sticky header height + breathing room for anchor jumps (desktop) */
    --anchor-offset: 82px;

    /* TOC gutter sizing */
    --toc-width: 230px;
    --toc-gap: 42px;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    background: var(--bg-main);
    color: var(--sand);
    font-family: var(--font-main);
    line-height: 1.58;
    font-size: 16.5px;
    text-align: left;

    /* Scroll room at very bottom so last TOC section can land high
     WITHOUT pushing Share/Footer away */
    padding-bottom: 40vh;
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.wrap {
    max-width: var(--wrap);
    margin: 0 auto;
    padding: 0 22px;
}

/* =========================
   HEADER / NAV
   ========================= */
header {
    position: sticky;
    top: 0;
    z-index: 9999;
    background: rgba(43, 28, 22, 0.86);
    backdrop-filter: blur(10px);
}

/* Desktop header height */
.nav {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 64px;
    /* taller */
}

.nav-links {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.nav-links a {
    font-size: 11.5px;
    color: var(--sand-soft);
    text-transform: uppercase;
    letter-spacing: .12em;
    white-space: nowrap;
    padding: 6px 7px;
    line-height: 1.05;
}

.nav-links a:hover {
    color: var(--sand);
}

.nav-links a.active,
.nav-links a[aria-current="page"] {
    color: var(--sand);
    text-decoration: none;
}

/* =========================
   Anchor landing
   ========================= */
/* Apply anchor landing ONLY to headings */
h2[id] {
    scroll-margin-top: var(--anchor-offset);
}

/* =========================
   PAGE HEADER
   ========================= */
.page-header {
    padding: 38px 0 26px;
    text-align: center;
}

.page-header .page-title {
    font-size: 24px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    font-weight: 500;
    margin: 8px 0 6px;
}

.page-header .page-subtitle {
    margin: 8px auto 0;
    font-size: 18px;
    color: var(--sand-soft);
    max-width: var(--text-max-width);
}

.page-header .page-quote {
    margin: 0 auto 10px;
    font-size: 14.5px;
    font-style: italic;
    color: var(--sand-soft);
    max-width: 680px;
}

.page-header .page-quote span {
    display: block;
    margin-top: 5px;
    font-size: 12.5px;
    color: var(--muted);
    font-style: normal;
}

/* =========================
   CONTENT
   ========================= */
section {
    padding: 34px 0;
}

h2,
h3,
p,
.muted {
    max-width: var(--text-max-width);
    margin-left: auto;
    margin-right: auto;
}

h2 {
    font-size: 24px;
    text-align: center;
    letter-spacing: .08em;
    text-transform: uppercase;
    margin-bottom: 12px;
}

h3 {
    font-size: 19px;
    margin: 24px auto 8px;
}

p {
    margin: 9px auto;
}

.muted {
    color: var(--muted);
    font-size: 13.5px;
}

/* remove internal dividers */
.hr-soft {
    display: none;
}

/* =========================
   TOC SYSTEM
   ========================= */
.toc-layout {
    position: relative;
}

.toc-main {
    max-width: var(--text-max-width);
    margin-left: auto;
    margin-right: auto;
}

.toc-side {
    max-width: var(--text-max-width);
    margin: 18px auto 28px;
    padding: 12px 0 10px;
}
/* Hide TOC when it would otherwise stack at the top (below desktop gutter breakpoint) */
@media (max-width: 1199px) {
  .toc-side { display: none !important; }

  /* Optional: remove any TOC-only spacing helpers on mobile */
  .toc-main { padding-bottom: 0 !important; }
}

/* TOC title */
.toc-title {
    font-size: 0.74rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: rgba(240, 228, 207, 0.50);
    margin-bottom: 10px;
}

.toc-title a,
.toc-home {
    color: inherit;
    text-decoration: none;
    display: inline-block;
}

.toc-title a:hover,
.toc-home:hover {
    color: rgba(240, 228, 207, 0.70);
    text-decoration: none;
}

.toc ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.toc li+li {
    margin-top: 6px;
}

.toc a {
    font-size: 0.78rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(240, 228, 207, 0.62);
}

.toc a:hover {
    color: rgba(240, 228, 207, 0.88);
}

/* Desktop TOC gutter */
@media (min-width: 1200px) {
    .toc-side {
        position: fixed;
        top: calc(64px + 34px + 16px);
        /* matches taller header */
        width: var(--toc-width);
        left: max(22px,
                calc(50% - (var(--text-max-width) / 2) - var(--toc-width) - var(--toc-gap)));
        background: transparent;
        z-index: 50;
    }
}

/* =========================
   FOOTER + NEXT PAGE
   ========================= */
footer {
    padding: 30px 0;
    text-align: center;
    font-size: 12.8px;
    color: var(--muted);
}

.next-page {
    margin: 30px auto 0;
    max-width: var(--text-max-width);
    text-align: center;
}

.next-page a {
    font-size: 13px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--sand-soft);
}

.next-page a:hover {
    color: var(--sand);
    text-decoration: none;
}

/* =========================
   SHARE BLOCK
   ========================= */
.share-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    margin-top: 14px;
}

.share-btn {
    display: inline-block;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid rgba(240, 228, 207, 0.16);
    background: rgba(255, 255, 255, 0.04);
    color: var(--sand);
    font-size: 12.5px;
    letter-spacing: .08em;
    text-transform: uppercase;
    text-decoration: none;
    cursor: pointer;
}

.share-btn:hover {
    background: rgba(255, 255, 255, 0.06);
    text-decoration: none;
}

/* =========================
   MOBILE NAV WRAP (2 lines)
   ========================= */
/* If the menu exceeds screen width, it will wrap to 2 (or more) lines automatically */
@media (max-width: 900px) {
    .nav {
        height: auto;
        /* allow height to grow when wrapping */
        padding: 12px 0 14px;
        /* keeps it comfortable */
    }

    .nav-links {
        flex-wrap: wrap;
        /* key: wrap to next line */
        row-gap: 10px;
        column-gap: 16px;
    }

    .nav-links a {
        padding: 6px 6px;
    }

    /* Anchors need a bigger offset because header can become 2 lines */
    :root {
        --anchor-offset: 122px;
    }
}