/* =============================================================================
   Paper Template — Modern Minimal
   Inspired by Apple, thinkingmachines.ai, Distill.pub
   ============================================================================= */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Source+Serif+4:ital,opsz,wght@0,8..60,300;0,8..60,400;0,8..60,500;0,8..60,600;1,8..60,400&display=swap');

/* -----------------------------------------------------------------------------
   Design Tokens
   ----------------------------------------------------------------------------- */
:root {
    /* Neutral palette — white base, single accent */
    --bg:               #ffffff;
    --bg-subtle:        #f5f5f7;   /* Apple light gray */
    --text:             #1d1d1f;   /* Apple near-black */
    --text-secondary:   #6e6e73;
    --text-muted:       #a1a1a6;
    --accent:           #5465ff;   /* electric sapphire — links, buttons */
    --accent-hover:     #788bff;
    --color-title:      #5465ff;   /* paper title color — customize freely */
    --border:           #d2d2d7;
    --border-subtle:    #e8e8ed;

    /* Typography */
    --serif:  'Source Serif 4', Charter, Georgia, serif;
    --sans:   'Inter', -apple-system, 'Helvetica Neue', Arial, sans-serif;
    --mono:   'SF Mono', 'Fira Code', Consolas, 'Courier New', monospace;

    /* Layout */
    --page-width:    1120px;  /* full-width elements (teaser, wide figures) */
    --text-width:     800px;  /* comfortable reading column (~65 chars) */
    --pad:             24px;

    /* Elevation shadows — 3-layer architecture: contact edge + key light + ambient float */
    --shadow-sm:  0 1px 2px rgba(0,0,0,0.05),
                  0 2px 8px rgba(16,24,40,0.05),
                  0 6px 20px rgba(16,24,40,0.04);
    --shadow-md:  0 1px 3px rgba(0,0,0,0.07),
                  0 6px 16px rgba(16,24,40,0.08),
                  0 20px 48px rgba(16,24,40,0.07);
    --shadow-lg:  0 2px 4px rgba(0,0,0,0.07),
                  0 12px 28px rgba(16,24,40,0.09),
                  0 40px 80px rgba(16,24,40,0.09);
    /* Apple-style easing — used on all hover transitions */
    --ease:       cubic-bezier(0.25, 0.1, 0.25, 1);
}

*, *::before, *::after { box-sizing: border-box; }

html {
    font-size: 18px;
    line-height: 1.7;
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    font-family: var(--serif);
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* -----------------------------------------------------------------------------
   Animations — minimal, purposeful
   ----------------------------------------------------------------------------- */
@keyframes fade-up {
    from { opacity: 0; transform: translateY(18px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.scroll-reveal {
    opacity: 0;
    transition: opacity 0.6s ease-out;
}
.scroll-reveal.revealed {
    opacity: 1;
}

/* -----------------------------------------------------------------------------
   Header — gradient background, Apple-scale title
   ----------------------------------------------------------------------------- */
.header-wrapper {
    background: linear-gradient(180deg, #e8ebff 0%, #dde3ff 50%, #d4dbff 100%);
    position: relative;
    overflow: hidden;
    border-bottom: 1px solid rgba(120, 139, 255, 0.18);
}

/* soft radial highlight at top */
.header-wrapper::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: radial-gradient(ellipse at top, rgba(255,255,255,0.3) 0%, transparent 65%);
    pointer-events: none;
}

.paper-header {
    max-width: var(--page-width);
    margin: 0 auto;
    padding: 4.5rem var(--pad) 3.5rem;
    text-align: center;
}

/* Title — Inter, heavy weight, tight */
.paper-title {
    font-family: var(--sans);
    font-size: clamp(2.2rem, 5vw, 4.2rem);
    font-weight: 800;
    line-height: 1.08;
    letter-spacing: -0.03em;
    color: var(--color-title);
    margin: 0 0 0.75rem;
    animation: fade-up 0.65s ease-out both;
}

.paper-subtitle {
    font-family: var(--sans);
    font-size: clamp(0.95rem, 2.2vw, 1.25rem);
    font-weight: 400;
    color: var(--text-secondary);
    margin: 0 0 2.5rem;
    letter-spacing: 0.01em;
    animation: fade-up 0.65s ease-out 0.08s both;
}

/* Authors */
.authors {
    font-family: var(--sans);
    font-size: 1rem;
    line-height: 2;
    margin-bottom: 0.4rem;
    color: var(--text);
    animation: fade-in 0.6s ease-out 0.15s both;
}
.author { white-space: nowrap; }
.author-name {
    font-weight: 500;
    color: var(--text);
    text-decoration: none;
    transition: color 0.15s;
}
a.author-name:hover { color: var(--accent); }
.authors sup { font-size: 0.68em; margin-left: 1px; color: var(--text-secondary); }

/* Affiliations */
.affiliations {
    font-family: var(--sans);
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
    line-height: 1.6;
    animation: fade-in 0.6s ease-out 0.2s both;
}
.affiliation { margin: 0 0.5rem; white-space: nowrap; }
.affiliation a { color: inherit; text-decoration: none; }
.affiliation a:hover { color: var(--accent); }
.affiliation sup { font-size: 0.75em; margin-right: 2px; color: var(--text-secondary); }

.author-notes {
    font-family: var(--sans);
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 2rem;
    animation: fade-in 0.6s ease-out 0.25s both;
}
.author-notes .note { margin: 0 0.5rem; }

/* Link buttons — elevated light card style with top-light sheen */
.paper-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
    margin: 0 0 1rem;
    animation: fade-in 0.6s ease-out 0.3s both;
}
.paper-link {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.55rem 1.25rem;
    font-family: var(--sans);
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--accent);
    /* White card with subtle accent tint */
    background: #ffffff;
    border: 1px solid rgba(84, 101, 255, 0.28);
    border-radius: 100px;
    text-decoration: none;
    transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease),
                background 0.25s var(--ease), border-color 0.25s var(--ease);
    /* Elevated card: top-light inset + 3-layer shadow */
    box-shadow: inset 0 1px 0 rgba(255,255,255,1),
                0 1px 2px rgba(0,0,0,0.08),
                0 3px 10px rgba(84,101,255,0.14),
                0 8px 24px rgba(84,101,255,0.08);
    letter-spacing: 0.01em;
    position: relative;
    overflow: hidden;
}
.paper-link:hover {
    color: var(--accent);
    background: rgba(84, 101, 255, 0.05);
    border-color: rgba(84, 101, 255, 0.50);
    /* Stronger lift + colored glow */
    box-shadow: inset 0 1px 0 rgba(255,255,255,1),
                0 2px 4px rgba(0,0,0,0.08),
                0 8px 20px rgba(84,101,255,0.26),
                0 20px 40px rgba(84,101,255,0.14);
    transform: translateY(-2px) scale(1.03);
}
/* Primary: slightly more prominent — same card style, slightly deeper tint */
.paper-link.primary {
    background: rgba(84, 101, 255, 0.06);
    border-color: rgba(84, 101, 255, 0.42);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.9),
                0 1px 2px rgba(0,0,0,0.08),
                0 4px 14px rgba(84,101,255,0.20),
                0 10px 28px rgba(84,101,255,0.12);
}
.paper-link.primary:hover {
    background: rgba(84, 101, 255, 0.10);
    border-color: rgba(84, 101, 255, 0.60);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.9),
                0 2px 4px rgba(0,0,0,0.08),
                0 8px 22px rgba(84,101,255,0.32),
                0 22px 44px rgba(84,101,255,0.16);
}
.paper-link i { font-size: 0.95em; }

/* Teaser — fills the full page-width, Apple hero style */
.teaser {
    margin-top: 3rem;
    width: 100%;
    animation: fade-in 0.8s ease-out 0.4s both;
}
.teaser-image {
    width: 100%;
    height: auto;
    border-radius: 16px;
    /* 3-layer: contact edge + key light + ambient colored glow */
    box-shadow: 0 2px 4px rgba(0,0,0,0.07),
                0 12px 28px rgba(16,24,40,0.09),
                0 40px 80px rgba(84,101,255,0.14);
}
.teaser-video {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 40px rgba(0,0,0,0.09);
}
.teaser-video iframe,
.teaser-video video {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%; border: none;
}

/* -----------------------------------------------------------------------------
   Main container — narrow reading column
   ----------------------------------------------------------------------------- */
.paper-container {
    max-width: var(--text-width);
    margin: 0 auto;
    padding: 0 var(--pad) 4rem;
}

/* -----------------------------------------------------------------------------
   Abstract — glassmorphism card
   ----------------------------------------------------------------------------- */
.abstract-section {
    margin: 2.5rem 0 0;
    padding: 1.75rem 2rem;
    background: #ffffff;
    border: 1px solid var(--border-subtle);
    border-radius: 14px;
    /* 3-layer elevation: inset top-light (simulates overhead lighting) + contact edge + key light + ambient float */
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.9),
                0 1px 3px rgba(0,0,0,0.07),
                0 6px 16px rgba(16,24,40,0.08),
                0 20px 48px rgba(16,24,40,0.07);
    transition: box-shadow 0.25s var(--ease);
    opacity: 0;
    animation: fade-up 0.8s ease-out 0.2s forwards;
}
.abstract-section:hover {
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.9),
                0 1px 3px rgba(0,0,0,0.07),
                0 8px 24px rgba(16,24,40,0.10),
                0 32px 64px rgba(84,101,255,0.08);
}
.abstract-section h2 {
    font-family: var(--sans);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin: 0 0 1rem;
    text-align: center;
}
.abstract-content {
    font-size: 1rem;
    line-height: 1.85;
    text-align: left;
}
.abstract-content p { margin: 0 0 0.85rem; }
.abstract-content p:last-child { margin-bottom: 0; }

/* -----------------------------------------------------------------------------
   Article typography
   ----------------------------------------------------------------------------- */
.paper-article {
    font-size: 1.05rem;
    line-height: 1.9;
    margin-top: 2.5rem;
}

/* No staggered animations on article children — scroll-reveal handles depth */

.paper-article h2 {
    font-family: var(--sans);
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text);
    margin: 4rem 0 0.85rem;
    padding: 0;
    border: none;
    line-height: 1.2;
    /* Clear sticky nav (52px) + breathing room when scrolled-to via anchor */
    scroll-margin-top: 4.5rem;
}
/* Appendix / minor section headings — visually step back from core h2s */
.paper-article h2[data-toc="appendix"] {
    font-size: 1.35rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-top: 2.5rem;
}
/* h3s nested under an appendix h2 also de-emphasized */
.paper-article h2[data-toc="appendix"] ~ h3 {
    color: var(--text-secondary);
    font-weight: 500;
}

/* No decorative underline — size + weight provides hierarchy */
.paper-article h3 {
    font-family: var(--sans);
    font-size: 1.15rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--text);
    margin: 2.5rem 0 0.65rem;
    scroll-margin-top: 4.5rem;
}
.paper-article h4 {
    font-family: var(--sans);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin: 2rem 0 0.6rem;
}
.paper-article p { margin: 0 0 1.25rem; text-align: left; }

.paper-article a {
    color: var(--accent);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color 0.15s;
}
.paper-article a:hover { border-bottom-color: var(--accent); }

.paper-article ul, .paper-article ol { margin: 0 0 1.25rem; padding-left: 1.5rem; }
.paper-article li { margin-bottom: 0.45rem; }

.paper-article hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 3.5rem 0;
}

/* Pull-quote blockquote — left-border accent style */
.paper-article blockquote {
    margin: 2.5rem 0;
    padding: 1.25rem 1.75rem 1.25rem 2rem;
    background: linear-gradient(135deg,
        rgba(84, 101, 255, 0.05) 0%,
        rgba(120, 139, 255, 0.08) 100%);
    border-left: 3px solid var(--accent);
    border-radius: 0 10px 10px 0;
    border-top: none;
    border-right: none;
    border-bottom: none;
    color: var(--text);
    font-family: var(--serif);
    font-size: 1.05rem;
    font-style: italic;
    font-weight: 400;
    line-height: 1.85;
    text-align: left;
    position: relative;
}
.paper-article blockquote p { margin: 0; text-align: left; }
.paper-article blockquote::before {
    content: '\201D';
    font-size: 5rem;
    line-height: 1;
    color: var(--accent);
    opacity: 0.12;
    position: absolute;
    top: -0.5rem;
    right: 1rem;
    left: auto;
    font-family: Georgia, serif;
    pointer-events: none;
}

.paper-article code {
    font-family: var(--mono);
    font-size: 0.875em;
    padding: 0.15rem 0.4rem;
    background: var(--bg-subtle);
    border-radius: 4px;
}
.paper-article pre {
    margin: 1.5rem 0;
    padding: 1.25rem;
    background: var(--bg-subtle);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    overflow-x: auto;
    font-size: 0.85rem;
    line-height: 1.6;
}
.paper-article pre code { padding: 0; background: none; }

/* -----------------------------------------------------------------------------
   Callout boxes — inspired by thinking-in-space "Finding N:" style
   Usage: <div class="callout callout-finding"> ... </div>
   ----------------------------------------------------------------------------- */
.callout {
    padding: 1rem 1.25rem;
    margin: 1.75rem 0;
    border-radius: 0 10px 10px 0;
    border-left: 3.5px solid;
    font-family: var(--sans);
    font-size: 0.95rem;
    line-height: 1.7;
}
.callout p { margin: 0; text-align: left; }
.callout strong:first-child { display: block; margin-bottom: 0.3rem; font-size: 0.78rem; letter-spacing: 0.08em; text-transform: uppercase; }

/* Finding / Key Result — green */
.callout-finding {
    background: #f0fdf4;
    border-color: #22c55e;
    color: #14532d;
}
.callout-finding strong:first-child { color: #16a34a; }

/* Key Insight / Tip — blue (accent) */
.callout-tip, .highlight-box {
    background: #f0f4ff;
    border-color: var(--accent);
    color: #1e1b4b;
}
.callout-tip strong:first-child { color: var(--accent); }

/* Note / Warning — amber */
.callout-note {
    background: #fffbeb;
    border-color: #f59e0b;
    color: #78350f;
}
.callout-note strong:first-child { color: #d97706; }

/* Dark mode adjustments */
@media (prefers-color-scheme: dark) {
    .callout-finding { background: #052e16; color: #bbf7d0; }
    .callout-tip, .highlight-box { background: #1e1d3f; color: #c7d2fe; }
    .callout-note { background: #2d1f00; color: #fde68a; }
}

/* Table row highlights (thinking-in-space style) */
.paper-table tr.best td { background: rgba(34, 197, 94, 0.08); font-weight: 600; }
.paper-table tr.human td { background: rgba(245, 158, 11, 0.08); font-style: italic; }
.paper-table tr.baseline td { opacity: 0.65; }

/* -----------------------------------------------------------------------------
   Figures — break out of text column for wide ones
   ----------------------------------------------------------------------------- */
.paper-figure {
    margin: 2.5rem 0;
    text-align: center;
}

/* Wide figure: extend beyond the text column via negative margins (no transform) */
.paper-figure.wide {
    width: min(var(--page-width), calc(100vw - 2 * var(--pad)));
    margin-left: calc((var(--text-width) - min(var(--page-width), calc(100vw - 2 * var(--pad)))) / 2);
}

.paper-figure img {
    max-width: 100%;
    height: auto;
    border-radius: 10px;
    /* Resting: subtle 3-layer shadow with top-light inset */
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.5),
                0 1px 3px rgba(0,0,0,0.06),
                0 4px 12px rgba(16,24,40,0.07),
                0 12px 32px rgba(16,24,40,0.06);
    transition: transform 0.3s var(--ease), box-shadow 0.3s var(--ease);
}
.paper-figure:hover img {
    transform: scale(1.012);
    /* Hover: elevated shadow + colored glow — card "floats" */
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.5),
                0 2px 4px rgba(0,0,0,0.07),
                0 12px 28px rgba(16,24,40,0.10),
                0 8px 32px rgba(84,101,255,0.18);
}

.paper-figure figcaption {
    margin-top: 0.85rem;
    font-family: var(--sans);
    font-size: 0.84rem;
    color: var(--text-secondary);
    line-height: 1.55;
    text-align: left;
}
/* Bold the "Figure N:" label — write captions as **Figure 1:** description */
.paper-figure figcaption strong,
.paper-video figcaption strong,
.paper-table figcaption strong {
    color: var(--text);
    font-weight: 600;
}

/* -----------------------------------------------------------------------------
   Videos
   ----------------------------------------------------------------------------- */
.paper-video { margin: 2.5rem 0; }
.video-container {
    position: relative;
    width: 100%;
    border-radius: 8px;
    overflow: hidden;
    background: var(--bg-subtle);
}
.video-container.youtube { padding-bottom: 56.25%; }
.video-container.youtube iframe {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
}
.video-container.mp4 video { width: 100%; display: block; }
.paper-video figcaption {
    margin-top: 0.75rem;
    font-family: var(--sans);
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-align: left;
}

/* -----------------------------------------------------------------------------
   Tables — clean, no background on header
   ----------------------------------------------------------------------------- */
.paper-table { margin: 2rem 0; overflow-x: auto; }
.paper-table table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--sans);
    font-size: 0.9rem;
}
.paper-table th, .paper-table td {
    padding: 0.65rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-subtle);
}
.paper-table th {
    font-weight: 600;
    font-size: 0.78rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-secondary);
    background: transparent;
    border-bottom: 2px solid var(--border);
}
.paper-table tbody tr {
    transition: background 0.2s ease;
}
/* Alternating rows — subtle blue-family tint, same family as hover */
.paper-table tbody tr:nth-child(even) {
    background: rgba(84, 101, 255, 0.05);
}
.paper-table tbody tr:hover {
    background: rgba(84, 101, 255, 0.10);
}
.paper-table figcaption {
    margin-top: 0.75rem;
    font-family: var(--sans);
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-align: left;
}
.paper-table.centered th,
.paper-table.centered td { text-align: center; }

/* -----------------------------------------------------------------------------
   BibTeX
   ----------------------------------------------------------------------------- */
.bibtex-section {
    margin: 4rem 0 2rem;
    padding-top: 2.5rem;
    border-top: 1px solid var(--border);
}
.bibtex-section h2 {
    font-family: var(--sans);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin: 0 0 1rem;
}
.bibtex-container {
    position: relative;
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}
.bibtex-code {
    margin: 0;
    padding: 1.25rem;
    padding-right: 7rem;
    font-family: var(--mono);
    font-size: 0.8rem;
    line-height: 1.65;
    overflow-x: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
    color: var(--text);
}
.bibtex-code code { background: none; padding: 0; }

.copy-bibtex {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.85rem;
    background: var(--bg);
    border: 1.5px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    font-family: var(--sans);
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text);
    transition: background 0.18s, color 0.18s, border-color 0.18s;
}
.copy-bibtex:hover {
    background: var(--text);
    color: var(--bg);
    border-color: var(--text);
}
.copy-bibtex.copied {
    background: #16a34a;
    border-color: #16a34a;
    color: #fff;
}

/* -----------------------------------------------------------------------------
   Acknowledgments
   ----------------------------------------------------------------------------- */
.acknowledgments {
    margin: 2rem 0;
    padding: 1.5rem 0;
    border-top: 1px solid var(--border-subtle);
}
.acknowledgments h2 {
    font-family: var(--sans);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin: 0 0 0.75rem;
}
.acknowledgments p {
    margin: 0;
    font-family: var(--sans);
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.65;
}

/* -----------------------------------------------------------------------------
   Responsive
   ----------------------------------------------------------------------------- */
@media (max-width: 768px) {
    :root { --pad: 18px; }
    html { font-size: 16px; }

    .paper-header { padding: 2.5rem var(--pad) 2rem; }

    /* Buttons wrap nicely in 2 columns on small screens */
    .paper-links {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
        gap: 0.45rem;
    }
    .paper-link {
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
        justify-content: center;
    }

    .abstract-section {
        padding: 1.25rem 1.25rem;
        border-radius: 10px;
    }

    .paper-figure.wide {
        width: calc(100% + 2 * var(--pad));
        margin-left: calc(-1 * var(--pad));
        border-radius: 0;
    }
    .paper-figure.wide img { border-radius: 0; }

    .paper-article h2 { font-size: 1.35rem; }
    .paper-article h3 { font-size: 1rem; }

    .toc-sidebar { display: none; }
    .scroll-to-top { width: 40px; height: 40px; font-size: 0.85rem; bottom: 1.25rem; right: 1.25rem; }
}

@media (max-width: 480px) {
    .paper-links { grid-template-columns: repeat(2, 1fr); }
    .teaser-image { border-radius: 10px; }
}

/* -----------------------------------------------------------------------------
   Reading Progress Bar — Thinking Machines style thin line at top
   ----------------------------------------------------------------------------- */
.reading-progress {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    width: 0%;
    background: linear-gradient(90deg, var(--accent) 0%, #9bb1ff 100%);
    z-index: 200;
    transition: width 0.1s linear;
    pointer-events: none;
}

/* -----------------------------------------------------------------------------
   Sticky Mini-Nav — appears after scrolling past header
   ----------------------------------------------------------------------------- */
.sticky-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 150;
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border-subtle);
    transform: translateY(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 0 var(--pad);
}
.sticky-nav.visible { transform: translateY(0); }

.sticky-nav-inner {
    max-width: var(--page-width);
    margin: 0 auto;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}
.sticky-nav-title {
    font-family: var(--sans);
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}
.sticky-nav-links {
    display: flex;
    gap: 0.35rem;
    flex-shrink: 0;
}
.sticky-nav-link {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.3rem 0.85rem;
    font-family: var(--sans);
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--accent);
    background: #ffffff;
    border: 1px solid rgba(84, 101, 255, 0.30);
    border-radius: 100px;
    text-decoration: none;
    transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease), background 0.2s var(--ease), border-color 0.2s var(--ease);
    box-shadow: inset 0 1px 0 rgba(255,255,255,1),
                0 1px 2px rgba(0,0,0,0.06),
                0 3px 8px rgba(84,101,255,0.14);
}
.sticky-nav-link:hover {
    color: var(--accent);
    background: rgba(84, 101, 255, 0.06);
    border-color: rgba(84, 101, 255, 0.50);
    box-shadow: inset 0 1px 0 rgba(255,255,255,1),
                0 2px 4px rgba(0,0,0,0.08),
                0 6px 16px rgba(84,101,255,0.24);
    transform: translateY(-1px);
}

@media (prefers-color-scheme: dark) {
    .sticky-nav {
        background: rgba(17, 17, 17, 0.88);
    }
}
@media (max-width: 600px) {
    .sticky-nav-title { display: none; }
}

/* -----------------------------------------------------------------------------
   TOC Sidebar — LEFT-side sticky column (like Thinking Machines Lab)
   Two-column layout: TOC | paper-main
   Visible only on wide screens (≥ 1280px)
   ----------------------------------------------------------------------------- */
.toc-sidebar {
    display: none;
}

.toc-title {
    font-family: var(--sans);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin: 0 0 1rem;
    padding-bottom: 0.6rem;
    border-bottom: 1px solid var(--border-subtle);
}
.toc-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.toc-list li { margin: 0; }

/* h2 items — main section, more prominent */
.toc-link {
    display: block;
    font-family: var(--sans);
    font-size: 0.9rem;
    font-weight: 400;
    line-height: 1.45;
    color: var(--text-secondary);
    text-decoration: none;
    padding: 0.32rem 0.75rem 0.32rem 0.25rem;
    border-right: 2px solid transparent;
    transition: color 0.15s, background 0.15s, border-color 0.15s;
    word-break: break-word;
}
/* h2 section items — darker, more prominent than h3 */
.toc-link.toc-h2 {
    color: var(--text);
    font-weight: 500;
}
/* Visual grouping: extra space before h2 sections (except first), no border */
.toc-list li + li .toc-h2 {
    margin-top: 0.5rem;
}
/* Appendix / minor sections — visually subordinate, doesn't compete with core sections */
.toc-link.toc-appendix {
    color: var(--text-muted);
    font-weight: 400;
}
.toc-link.toc-appendix:hover {
    color: var(--text-secondary);
}
.toc-link.toc-appendix.active {
    color: var(--accent);
    font-weight: 500;
}
.toc-link:hover {
    color: var(--accent);
    background: rgba(84, 101, 255, 0.06);
    border-radius: 4px 0 0 4px;
}
.toc-link.active {
    color: var(--accent);
    border-right-color: var(--accent);
    font-weight: 600;
    background: rgba(84, 101, 255, 0.07);
    border-radius: 4px 0 0 4px;
}

/* h3 items — sub-sections, clearly subordinate */
.toc-link.toc-h3 {
    font-size: 0.83rem;
    font-weight: 400;
    color: var(--text-muted);
    padding-left: 0.9rem;
    padding-top: 0.22rem;
    padding-bottom: 0.22rem;
    /* Clamp to 2 lines max — prevents a single long title from dominating */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: normal;
}
.toc-link.toc-h3:hover {
    color: var(--text-secondary);
}
.toc-link.toc-h3.active {
    color: var(--accent);
    font-weight: 500;
}

@media (min-width: 1280px) {
    /* Two-column layout only when TOC sidebar is present */
    body.has-toc .paper-container {
        /* max-width includes horizontal padding (border-box) */
        max-width: calc(240px + 48px + var(--text-width) + 2 * var(--pad));
        display: flex;
        align-items: flex-start;
        gap: 48px;
    }

    /* TOC: sticky left column */
    body.has-toc .toc-sidebar {
        display: block;
        position: sticky;
        top: 5rem;
        flex-shrink: 0;
        width: 240px;
        max-height: calc(100vh - 7rem);
        overflow-y: auto;
        /* No full-height border — active link indicator handles separation */
        padding-right: 1.25rem;
        padding-top: 2.5rem;  /* align with abstract card top margin */
        text-align: right;
    }
    .toc-sidebar::-webkit-scrollbar { width: 3px; }
    .toc-sidebar::-webkit-scrollbar-track { background: transparent; }
    .toc-sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

    /* Content column */
    body.has-toc .paper-main {
        flex: 1;
        min-width: 0;
        max-width: var(--text-width);
    }

    /* Wide figures: no leftward breakout into TOC space */
    body.has-toc .paper-figure.wide {
        width: 100%;
        margin-left: 0;
        margin-right: 0;
    }
}

/* -----------------------------------------------------------------------------
   Scroll-to-top button
   ----------------------------------------------------------------------------- */
.scroll-to-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--bg);
    border: 1.5px solid var(--border);
    color: var(--text-secondary);
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transform: translateY(8px);
    transition: opacity 0.25s var(--ease), transform 0.25s var(--ease), background 0.18s var(--ease), color 0.18s var(--ease), border-color 0.18s var(--ease), box-shadow 0.25s var(--ease);
    box-shadow: var(--shadow-sm);
    z-index: 100;
}
.scroll-to-top.visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}
.scroll-to-top:hover {
    background: var(--text);
    color: var(--bg);
    border-color: var(--text);
}

/* -----------------------------------------------------------------------------
   Dark Mode
   ----------------------------------------------------------------------------- */
@media (prefers-color-scheme: dark) {
    :root {
        --bg:             #111111;
        --bg-subtle:      #1c1c1e;   /* Apple dark */
        --text:           #f5f5f7;   /* Apple light */
        --text-secondary: #98989d;
        --text-muted:     #636366;
        --accent:         #6b7aff;   /* lighter blue for dark bg */
        --accent-hover:   #8b98ff;
        --color-title:    #6b7aff;
        --border:         #3a3a3c;
        --border-subtle:  #2c2c2e;
    }

    /* Subtle radial highlight on dark header */
    .header-wrapper::before {
        background: radial-gradient(ellipse at top, rgba(107, 122, 255, 0.18) 0%, transparent 65%);
    }

    /* Gradient header on dark */
    .header-wrapper {
        background: linear-gradient(180deg, #1a1d2e 0%, #151829 50%, #111422 100%);
    }

    /* Abstract card on dark — deeper shadows, darker surfaces absorb more light */
    .abstract-section {
        background: #1c1c1e;
        border-color: var(--border-subtle);
        box-shadow: inset 0 1px 0 rgba(255,255,255,0.07),
                    0 1px 3px rgba(0,0,0,0.30),
                    0 6px 16px rgba(0,0,0,0.28),
                    0 20px 48px rgba(0,0,0,0.24);
    }
    .abstract-section:hover {
        box-shadow: inset 0 1px 0 rgba(255,255,255,0.07),
                    0 1px 3px rgba(0,0,0,0.30),
                    0 8px 24px rgba(0,0,0,0.32),
                    0 32px 64px rgba(107,122,255,0.14);
    }

    /* Teaser shadow on dark — 3-layer with colored glow at higher opacity */
    .teaser-image,
    .teaser-video {
        box-shadow: 0 2px 4px rgba(0,0,0,0.30),
                    0 12px 28px rgba(0,0,0,0.36),
                    0 40px 80px rgba(107,122,255,0.20);
    }

    /* Highlight box */
    .highlight-box { background: #1a1d35; }

    /* Table alternating + hover */
    .paper-table tbody tr:nth-child(even) { background: rgba(107, 122, 255, 0.07); }
    .paper-table tbody tr:hover { background: rgba(107, 122, 255, 0.14); }

    /* Scroll-to-top on dark */
    .scroll-to-top {
        box-shadow: 0 2px 16px rgba(0,0,0,0.4);
    }

    /* Paper link buttons on dark — card bg becomes dark card */
    .paper-link {
        background: rgba(255,255,255,0.06);
        border-color: rgba(107,122,255,0.35);
        color: var(--accent);
        box-shadow: inset 0 1px 0 rgba(255,255,255,0.08),
                    0 1px 2px rgba(0,0,0,0.30),
                    0 3px 10px rgba(107,122,255,0.18),
                    0 8px 24px rgba(107,122,255,0.10);
    }
    .paper-link:hover {
        background: rgba(107,122,255,0.12);
        border-color: rgba(107,122,255,0.55);
        box-shadow: inset 0 1px 0 rgba(255,255,255,0.08),
                    0 2px 4px rgba(0,0,0,0.30),
                    0 8px 20px rgba(107,122,255,0.30),
                    0 20px 40px rgba(107,122,255,0.18);
    }
    .paper-link.primary {
        background: rgba(107,122,255,0.12);
        border-color: rgba(107,122,255,0.50);
    }

    /* Sticky nav links on dark */
    .sticky-nav-link {
        background: rgba(255,255,255,0.06);
        border-color: rgba(107,122,255,0.35);
        color: var(--accent);
        box-shadow: inset 0 1px 0 rgba(255,255,255,0.08),
                    0 1px 2px rgba(0,0,0,0.30),
                    0 3px 8px rgba(107,122,255,0.18);
    }
    .sticky-nav-link:hover {
        background: rgba(107,122,255,0.14);
        border-color: rgba(107,122,255,0.55);
        box-shadow: inset 0 1px 0 rgba(255,255,255,0.08),
                    0 2px 4px rgba(0,0,0,0.30),
                    0 6px 16px rgba(107,122,255,0.28);
    }

    /* TOC hover on dark */
    .toc-link:hover {
        color: var(--accent);
        background: rgba(107,122,255,0.08);
    }
}

/* -----------------------------------------------------------------------------
   Footer
   ----------------------------------------------------------------------------- */
.site-footer {
    text-align: center;
    padding: 2.5rem var(--pad);
    font-family: var(--sans);
    font-size: 0.8rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border-subtle);
}
.site-footer p { margin: 0; }

/* -----------------------------------------------------------------------------
   Utilities
   ----------------------------------------------------------------------------- */
.text-center { text-align: center; }
.text-left   { text-align: left; }
.text-right  { text-align: right; }
.mt-0 { margin-top: 0; }      .mb-0 { margin-bottom: 0; }
.mt-1 { margin-top: 0.5rem; } .mb-1 { margin-bottom: 0.5rem; }
.mt-2 { margin-top: 1rem; }   .mb-2 { margin-bottom: 1rem; }
.mt-3 { margin-top: 2rem; }   .mb-3 { margin-bottom: 2rem; }
.mt-4 { margin-top: 3rem; }   .mb-4 { margin-bottom: 3rem; }
.hidden { display: none; }

/* -----------------------------------------------------------------------------
   Accessibility — prefers-reduced-motion
   ----------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
