:root {
    /* blacks */
    --bg:           #030303;
    --surface:      #080808;
    --surface-2:    #101010;
    --border:       #1c1c1c;
    --border-2:     #282828;

    /* cream */
    --cream:         #F5EFE0;
    --cream-light:   #FAF6ED;
    --cream-bright:  #FDFAF4;

    /* wine / champagne */
    --wine:          #7B2D3E;
    --champ:         #C9955A;
    --champ-light:   #DEBB8A;
    --champ-bright:  #EDD9B0;
    --champ-dim:     rgba(201, 149, 90, 0.09);
    --champ-border:  rgba(201, 149, 90, 0.22);

    /* aliases so existing selectors using --gold still resolve */
    --gold:         var(--champ);
    --gold-light:   var(--champ-light);
    --gold-bright:  var(--champ-bright);
    --gold-dim:     var(--champ-dim);
    --gold-border:  var(--champ-border);

    /* text */
    --text-1:        #F5EFE0;
    --text-2:        #B0A898;
    --text-3:        #6A6258;
    --accent:        var(--gold);
}

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg);
    color: var(--text-2);
    line-height: 1.75;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

/* ── BACKGROUND ── */
.bg-base {
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse 90% 70% at 50% 0%, rgba(201, 149, 90, 0.03) 0%, transparent 65%),
        linear-gradient(170deg, #0a0a0a 0%, var(--bg) 55%, var(--bg) 100%);
    z-index: -1;
}

.bg-grid {
    position: fixed;
    inset: 0;
    background-image: radial-gradient(circle, rgba(245, 239, 224, 0.03) 1px, transparent 1px);
    background-size: 36px 36px;
    mask-image: radial-gradient(ellipse 80% 80% at 50% 50%, black 40%, transparent 100%);
    z-index: -1;
}

/* Typography */
h1,
h2,
h3,
h4 {
    font-family: 'Cormorant Garamond', serif;
    color: var(--text-1);
    font-weight: 600;
}

h2 {
    font-size: 28px;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

h3 {
    font-size: 22px;
    margin: 32px 0 16px;
    color: var(--gold-light);
}

h4 {
    font-size: 18px;
    margin-bottom: 12px;
}

p,
ul,
ol {
    margin-bottom: 20px;
    font-size: 15px;
}

ul,
ol {
    padding-left: 24px;
}

li {
    margin-bottom: 8px;
}

code {
    font-family: monospace;
    background: var(--surface-2);
    padding: 3px 6px;
    border: 1px solid var(--border);
    border-radius: 3px;
    color: var(--gold-light);
    font-size: 13.5px;
}

a {
    color: var(--gold);
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    color: var(--gold-light);
    text-decoration: underline;
}

/* Layout */
.topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 70px;
    background: rgba(8, 8, 8, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 40px;
    z-index: 100;
}

.logo h1 {
    font-size: 22px;
    margin: 0;
    display: inline-block;
}

/* Mobile Table of Contents Menu Button — Hidden on Desktop */
.mobile-toc-btn {
    display: none;
    align-items: center;
    gap: 8px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--gold-light);
    padding: 7px 14px;
    font-weight: 500;
    font-size: 13.5px;
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    cursor: pointer;
    transition: all 0.2s ease;
}

.mobile-toc-btn:hover {
    border-color: var(--border-accent);
    color: var(--text-1);
    background: var(--surface);
}

.mobile-toc-menu {
    display: none;
    position: fixed;
    top: 70px;
    left: 0;
    right: 0;
    max-height: calc(100vh - 70px);
    max-height: calc(100dvh - 70px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: var(--gold-border) rgba(255, 255, 255, 0.03);
    background: rgba(16, 16, 16, 0.98);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.85);
    padding: 16px 20px 40px 20px;
    z-index: 150;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

.mobile-toc-menu::-webkit-scrollbar {
    width: 6px;
}

.mobile-toc-menu::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.03);
}

.mobile-toc-menu::-webkit-scrollbar-thumb {
    background: var(--gold-border);
    border-radius: 4px;
}

.mobile-toc-menu::-webkit-scrollbar-thumb:hover {
    background: var(--gold);
}

.mobile-toc-menu.active {
    display: block;
    animation: slideDown 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.mobile-toc-links {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-bottom: 20px;
}

.mobile-toc-links a {
    color: var(--text-2);
    font-size: 14.5px;
    padding: 9px 14px;
    border-radius: 4px;
    text-decoration: none;
    transition: all 0.2s ease;
}

.mobile-toc-links a:hover,
.mobile-toc-links a:active {
    color: var(--text-1);
    background: var(--surface-2);
    transform: translateX(4px);
}

/* Primary floating action button — fixed bottom right */
.btn-primary {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 200;
    background: var(--champ);
    color: #1A0808 !important;
    border: 1px solid var(--border-accent);
    padding: 12px 22px;
    border-radius: 5px;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none !important;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.btn-primary:hover {
    background: var(--champ-light);
    border-color: var(--border-accent);
    transform: translateY(-2px);
}

.layout {
    display: flex;
    max-width: 1200px;
    margin: 70px auto 0;
    min-height: calc(100vh - 70px);
}

/* Sidebar */
.sidebar {
    width: 260px;
    flex-shrink: 0;
    border-right: 1px solid var(--border);
    background: transparent;
    position: sticky;
    top: 70px;
    height: calc(100vh - 70px);
    overflow-y: auto;
}

.sidebar-inner {
    padding: 40px 30px;
}

.sidebar-inner h3 {
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-3);
    margin: 0 0 20px;
}

.toc {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.toc a {
    font-size: 14.5px;
    color: var(--text-2);
    text-decoration: none;
    padding: 6px 12px;
    border-radius: 4px;
    transition: all 0.2s;
    margin-left: -12px;
}

.toc a:hover {
    color: var(--text-1);
    background: var(--surface);
}

/* Content */
.content {
    flex: 1;
    padding: 50px 60px 80px;
    max-width: 780px;
}

.hero {
    margin-bottom: 60px;
}

.hero h2 {
    font-size: 42px;
    border-bottom: none;
    margin-bottom: 16px;
    padding-bottom: 0;
}

.hero p {
    font-size: 18px;
    color: var(--text-3);
    line-height: 1.7;
}

.doc-section {
    margin-bottom: 80px;
    scroll-margin-top: 100px;
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin: 30px 0;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 24px;
}

.card p {
    margin-bottom: 0;
    font-size: 14px;
}

.notice {
    background: var(--gold-dim);
    border-left: 3px solid var(--border-accent);
    padding: 16px 20px;
    border-radius: 0 4px 4px 0;
    margin: 24px 0;
    font-size: 14.5px;
}

.notice strong {
    color: var(--gold);
}

.doc-footer {
    border-top: 1px solid var(--border);
    padding-top: 40px;
    margin-top: 60px;
    text-align: center;
    color: var(--text-3);
    font-size: 13.5px;
}

.doc-footer p {
    margin-bottom: 0;
}

/* Responsive */
@media (max-width: 900px) {
    .mobile-toc-btn {
        display: inline-flex;
    }

    .sidebar {
        display: none;
    }

    .layout {
        flex-direction: column;
    }

    .content {
        padding: 40px 24px;
    }
}

@media (max-width: 600px) {
    .topbar {
        padding: 0 20px;
    }

    .grid-2 {
        grid-template-columns: 1fr;
    }

    .content {
        padding: 30px 20px;
    }

    .sidebar-inner {
        padding: 30px 20px;
    }

    .hero h2 {
        font-size: 32px;
    }
}

/* CSV Columns Grid */
.csv-cols-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 15px 0;
}

.csv-col {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 9px;
    border-radius: 20px;
    font-size: 11.5px;
    font-family: monospace;
    font-weight: 500;
    letter-spacing: 0.01em;
}

.csv-col em {
    font-style: normal;
    font-weight: 400;
    opacity: 0.75;
    font-size: 10.5px;
}

.csv-col--required {
    background: var(--gold-dim);
    color: var(--gold-light);
    border: 1px solid var(--gold-border);
}

.csv-col--optional {
    background: var(--surface-2);
    color: var(--text-2);
    border: 1px solid var(--border);
}

/* ── READING AIDS ── */
.read-progress {
    position: fixed;
    top: 70px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--champ);
    transform-origin: 0 50%;
    transform: scaleX(0);
    z-index: 101;
    pointer-events: none;
}

/* current-section highlight in the contents lists */
.toc a {
    border-left: 2px solid transparent;
    border-radius: 0 4px 4px 0;
    margin-left: -12px;
}

.toc a.active {
    color: var(--gold-light);
    background: var(--champ-dim);
    border-left-color: var(--border-accent);
}

.mobile-toc-links a.active {
    color: var(--gold-light);
    background: var(--champ-dim);
}

.sidebar {
    scrollbar-width: thin;
    scrollbar-color: var(--border-2) transparent;
}

a:focus-visible,
button:focus-visible {
    outline: 2px solid var(--champ-light);
    outline-offset: 3px;
}

@media print {
    .bg-base,
    .bg-grid,
    .topbar,
    .sidebar,
    .btn-primary,
    .read-progress,
    .mobile-toc-menu {
        display: none !important;
    }

    body {
        background: #fff;
        color: #111;
    }

    .layout {
        display: block;
        margin: 0;
    }

    .content {
        max-width: none;
        padding: 0;
    }

    h1, h2, h3, h4 {
        color: #111;
    }

    h3 {
        color: #444;
    }

    .card,
    .notice {
        background: none;
        border-color: #ccc;
    }

    .doc-section {
        break-inside: avoid-page;
        margin-bottom: 32px;
    }

    a {
        color: inherit;
    }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    .mobile-toc-menu.active {
        animation: none;
    }
}

/* ═══════════════════════════════════════════════════
   SOFT UI THEME — matches the portal (dark)
═══════════════════════════════════════════════════ */
:root {
    --bg:            #080707;
    --surface:       #121111;
    --surface-2:     #1b1a1a;
    --surface-3:     #232222;
    --border:        #201f1f;
    --border-2:      #2e2d2d;

    --text-1:        #f5f5f5;
    --text-2:        #a3a3a3;
    --text-3:        #727272;

    --champ:         #e8e8e8;
    --champ-light:   #f2f2f2;
    --champ-bright:  #fafafa;
    --champ-dim:     rgba(255, 255, 255, 0.084);
    --champ-border:  rgba(255, 255, 255, 0.30);

    --btn-solid-bg:  #f5f5f5;
    --btn-solid-fg:  #080707;
}

body {
    background-color: var(--bg);
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible {
    outline: 2px solid var(--champ-light);
    outline-offset: 3px;
}
.bg-base {
    background:
        radial-gradient(ellipse 90% 70% at 50% 0%, rgba(255, 255, 255, 0.025) 0%, transparent 65%),
        var(--bg);
}

.bg-grid {
    background-image: radial-gradient(circle, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
}

.topbar {
    background: rgba(8, 7, 7, 0.85);
    border-bottom-color: var(--border);
}

.mobile-toc-btn {
    border-radius: 999px;
    background: var(--surface-2);
    border-color: var(--border-2);
    color: var(--text-1);
}

.mobile-toc-menu {
    background: rgba(18, 17, 17, 0.98);
}

.mobile-toc-links a {
    border-radius: 999px;
}

.toc a {
    border-radius: 0 999px 999px 0;
}

.toc a.active,
.mobile-toc-links a.active {
    color: var(--text-1);
    background: var(--surface-2);
}

h3 {
    color: var(--text-1);
}

.card {
    background: var(--surface);
    border-color: var(--border);
    border-radius: 20px;
}

.notice {
    background: var(--surface);
    border-left-color: var(--border-accent);
    border-radius: 0 16px 16px 0;
}

.notice strong {
    color: var(--champ-light);
}

code {
    border-radius: 6px;
    background: var(--surface-2);
    border-color: var(--border-2);
    color: var(--text-1);
}

a {
    color: var(--champ-light);
}

a:hover {
    color: var(--champ-bright);
}

.csv-col {
    border-radius: 999px;
}

.btn-primary {
    background: var(--btn-solid-bg);
    color: var(--btn-solid-fg) !important;
    border: 1px solid var(--btn-solid-bg);
    border-radius: 999px;
}

.btn-primary:hover {
    background: color-mix(in srgb, var(--btn-solid-bg) 86%, var(--champ));
    border-color: color-mix(in srgb, var(--btn-solid-bg) 86%, var(--border-accent));
}

/* Borders use a neutral light grey, not the accent colour */
:root,
html[data-theme="dark"] {
    --border-accent: #8a8a8a;
    --champ-border: rgba(255, 255, 255, 0.16);
    --gold-border: rgba(255, 255, 255, 0.16);
    --focus-ring: 0 0 0 2px rgba(255, 255, 255, 0.22);
}

html[data-theme="light"] {
    --border-accent: #5c5c5c;
    --champ-border: rgba(0, 0, 0, 0.18);
    --gold-border: rgba(0, 0, 0, 0.18);
    --focus-ring: 0 0 0 2px rgba(0, 0, 0, 0.18);
}

/* No outline or glow ring on focused inputs */
input:focus,
input:focus-visible,
select:focus,
select:focus-visible,
textarea:focus,
textarea:focus-visible {
    outline: none !important;
    box-shadow: none !important;
}