/* =============================================================================
   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:   'JetBrains 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.1;
    margin-bottom: 0.6rem;
    color: var(--text);
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    column-gap: 1.5rem;
    row-gap: 0.2rem;
    animation: fade-in 0.6s ease-out 0.15s both;
}
@media (max-width: 640px) {
    .authors { column-gap: 1rem; font-size: 0.95rem; }
}
.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;
    }
}

/* FontAwesome Pro inline icons next to section titles */
h2 > i.fa-solid,
h2 > i.fa-regular,
h2 > i.fa-light,
h2 > i.fa-duotone,
h2 > i.fa-brands,
h3 > i.fa-solid,
h3 > i.fa-regular,
h3 > i.fa-light,
h3 > i.fa-duotone,
h3 > i.fa-brands {
    margin-right: 0.55em;
    font-size: 0.85em;
    color: var(--accent, #b45309);
    opacity: 0.9;
    vertical-align: -0.05em;
}

figcaption > i.fa-light,
figcaption > i.fa-duotone,
figcaption > i.fa-solid {
    margin-right: 0.4em;
    color: var(--accent, #b45309);
    opacity: 0.85;
}

.affiliations > i.fa-light {
    margin-right: 0.5em;
    color: var(--accent, #b45309);
    opacity: 0.7;
    font-size: 0.95em;
}

/* Tables: horizontal scroll wrapper, highlighted "ours" rows, deltas */
.paper-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0.5em 0;
}
.paper-table-wrap table {
    margin: 0 auto;
    border-collapse: collapse;
    font-variant-numeric: tabular-nums;
}
.paper-table-wrap th,
.paper-table-wrap td {
    padding: 0.5em 0.75em;
    text-align: center;
    border-bottom: 1px solid #e5e7eb;
    white-space: nowrap;
}
.paper-table-wrap thead th {
    border-bottom: 2px solid #d1d5db;
    font-weight: 600;
}
.paper-table-wrap tbody tr:hover td {
    background: #fafafa;
}
.paper-table-wrap tr.ours td {
    background: #E0ECFD !important;
}
.paper-table-wrap tr.ours:hover td {
    background: #d2e3fb !important;
}
.delta-pos {
    color: #0f7b6c;
    font-size: 0.82em;
    margin-left: 0.15em;
}
.delta-neg {
    color: #b91c1c;
    font-size: 0.82em;
    margin-left: 0.15em;
}

/* Two-column figure (side-by-side images sharing one caption) */
.paper-figure.two-col {
    display: flex;
    flex-wrap: wrap;
    gap: 1em;
    align-items: flex-start;
}
.paper-figure.two-col > img {
    flex: 1 1 320px;
    min-width: 0;
    max-width: 100%;
    height: auto;
}
.paper-figure.two-col > figcaption {
    flex: 1 0 100%;
}

/* =========================================================================
   Optimization pass — visual polish (appended)
   ========================================================================= */

/* TOC — icon column in each link */
.toc-link {
    display: flex;
    align-items: center;
    gap: 0.55em;
}
.toc-link > i {
    font-size: 0.9em;
    width: 1.1em;
    text-align: center;
    opacity: 0.65;
    flex-shrink: 0;
    transition: opacity 0.15s, color 0.15s;
}
.toc-link.active > i,
.toc-link:hover > i {
    opacity: 1;
    color: var(--accent);
}
.toc-link > .toc-label {
    flex: 1 1 auto;
    min-width: 0;
}
.toc-link.toc-h3 > .toc-label {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
/* h3 links: smaller icon, subtler */
.toc-link.toc-h3 > i {
    font-size: 0.82em;
    opacity: 0.5;
}

/* "ours" row accent bar */
.paper-table-wrap tbody tr.ours td:first-child {
    box-shadow: inset 4px 0 0 var(--accent);
}
/* Zebra stripes (ours highlight wins) */
.paper-table-wrap tbody tr:nth-child(even) td {
    background: #fafafa;
}
.paper-table-wrap tbody tr.ours td,
.paper-table-wrap tbody tr.ours:nth-child(even) td {
    background: #E0ECFD;
}

/* Figcaption: tighter, anchored */
.paper-figure > figcaption,
.paper-table > figcaption {
    font-size: 0.92rem;
    line-height: 1.55;
}

/* Hero subtitle: crisper on cream */
.paper-subtitle {
    letter-spacing: 0.01em;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.4);
}

/* Cite-as line */
.cite-as {
    font-size: 0.92rem;
    color: var(--text-secondary, #555);
    line-height: 1.6;
    margin: 0 0 1rem;
    padding: 0.75rem 1rem;
    border-left: 3px solid var(--accent);
    background: rgba(84, 101, 255, 0.04);
    border-radius: 0 6px 6px 0;
}
.cite-as a { color: var(--accent); }

/* =========================================================================
   Beautification pass 2 — key stats, section dividers, dark polish
   ========================================================================= */

/* Key-stats pills row under abstract */
.key-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin: 1.25rem 0 0;
    padding: 0;
    list-style: none;
}
.key-stats li {
    flex: 1 1 150px;
    min-width: 140px;
    padding: 0.85rem 1rem;
    background: linear-gradient(180deg, rgba(84,101,255,0.07), rgba(84,101,255,0.03));
    border: 1px solid rgba(84,101,255,0.18);
    border-radius: 10px;
    text-align: center;
    box-shadow: 0 1px 2px rgba(0,0,0,0.03),
                0 4px 12px rgba(84,101,255,0.06);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.key-stats li:hover {
    transform: translateY(-2px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05),
                0 10px 24px rgba(84,101,255,0.14);
}
.key-stats .num {
    display: block;
    font-family: var(--serif, Georgia, serif);
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--accent);
    line-height: 1.1;
    letter-spacing: -0.01em;
}
.key-stats .lbl {
    display: block;
    margin-top: 0.25rem;
    font-family: var(--sans);
    font-size: 0.75rem;
    color: var(--text-secondary);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

/* Section divider — replace plain <hr> with a centered accent mark */
.paper-article hr {
    border: none;
    height: 1px;
    background: none;
    position: relative;
    margin: 3rem 0;
    overflow: visible;
}
.paper-article hr::before {
    content: "";
    position: absolute;
    left: 0; right: 0; top: 50%;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--border), transparent);
}
.paper-article hr::after {
    content: "\f067"; /* fa-plus */
    font-family: "Font Awesome 6 Pro", "Font Awesome 7 Pro";
    font-weight: 300;
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    color: var(--accent);
    background: var(--bg, #fff);
    padding: 0 0.7em;
    font-size: 0.85rem;
    opacity: 0.7;
}

/* Figcaption left-anchor bar */
.paper-article figcaption,
.paper-figure > figcaption,
.paper-table > figcaption {
    padding-left: 0.9rem;
    border-left: 3px solid rgba(84,101,255,0.25);
}

/* Ours row — slightly stronger accent on hover */
.paper-table-wrap tbody tr.ours:hover td {
    background: #d7e6fc;
}

/* --- Dark-mode polish for new elements --- */
@media (prefers-color-scheme: dark) {
    .cite-as {
        background: rgba(107,122,255,0.08);
        color: var(--text-secondary);
    }
    .key-stats li {
        background: linear-gradient(180deg, rgba(107,122,255,0.12), rgba(107,122,255,0.05));
        border-color: rgba(107,122,255,0.30);
        box-shadow: 0 1px 2px rgba(0,0,0,0.3),
                    0 6px 18px rgba(107,122,255,0.10);
    }
    .key-stats li:hover {
        box-shadow: 0 2px 4px rgba(0,0,0,0.4),
                    0 12px 28px rgba(107,122,255,0.22);
    }
    .key-stats .num { color: var(--accent); }
    .key-stats .lbl { color: var(--text-secondary); }

    .paper-table-wrap tbody tr:nth-child(even) td {
        background: rgba(255,255,255,0.03);
    }
    .paper-table-wrap tbody tr.ours td,
    .paper-table-wrap tbody tr.ours:nth-child(even) td {
        background: rgba(107,122,255,0.14);
    }
    .paper-table-wrap tbody tr.ours:hover td {
        background: rgba(107,122,255,0.22);
    }
    .paper-table-wrap tbody tr.ours td:first-child {
        box-shadow: inset 4px 0 0 var(--accent);
    }

    .paper-article hr::after { background: var(--bg); }
    .paper-article figcaption,
    .paper-figure > figcaption,
    .paper-table > figcaption {
        border-left-color: rgba(107,122,255,0.40);
    }

    .paper-subtitle {
        text-shadow: 0 1px 0 rgba(0,0,0,0.4);
    }
}

/* =========================================================================
   Polish pass 3 — tables, hero, TL;DR, lightbox, mobile TOC, footer, FX
   ========================================================================= */

/* --- Tables: tabular-nums + right-align numeric cells --- */
.paper-table-wrap table {
    font-variant-numeric: tabular-nums;
}
.paper-table-wrap tbody td {
    text-align: right;
}
/* Keep the first 1-2 label columns left-aligned */
.paper-table-wrap tbody td:first-child,
.paper-table-wrap tbody td:nth-child(2):not(:last-child) {
    text-align: left;
}
/* Ablation and filter_variants tables have a 3rd "Data" column that is a label too */
.paper-table-wrap tbody td:nth-child(3):not(:last-child):not(:nth-last-child(-n+6)) {
    text-align: left;
}
.paper-table-wrap thead th { text-align: center; }
.paper-table-wrap thead th:first-child,
.paper-table-wrap thead th:nth-child(2) { text-align: left; }

/* Best-score highlight: bold only (no underline) */
.paper-table-wrap tbody td strong {
    font-weight: 700;
    color: var(--text);
}

/* Scroll-edge shadow hint on wide tables */
.paper-table-wrap {
    background:
        linear-gradient(90deg, #fff 30%, rgba(255,255,255,0)) left center / 20px 100% no-repeat,
        linear-gradient(90deg, rgba(255,255,255,0), #fff 70%) right center / 20px 100% no-repeat,
        radial-gradient(ellipse at left, rgba(0,0,0,0.12), transparent 70%) left center / 14px 80% no-repeat,
        radial-gradient(ellipse at right, rgba(0,0,0,0.12), transparent 70%) right center / 14px 80% no-repeat;
    background-attachment: local, local, scroll, scroll;
}

/* --- Hero polish: title tightening + subtitle accent underline --- */
.paper-title {
    letter-spacing: -0.025em;
}
.paper-subtitle {
    margin-bottom: 1.2rem;
    position: relative;
    display: inline-block;
    padding-bottom: 0.4rem;
}
.paper-subtitle::after {
    content: "";
    position: absolute;
    left: 50%; bottom: 0;
    width: 44px; height: 2px;
    background: var(--accent);
    border-radius: 2px;
    transform: translateX(-50%);
    opacity: 0.7;
}
.authors { margin-top: 0.6rem; }

/* Slow drift on hero radial highlight */
@keyframes hero-drift {
    0%,100% { transform: translate(0,0) scale(1); opacity: 1; }
    50%     { transform: translate(3%, 1%) scale(1.04); opacity: 0.92; }
}
.header-wrapper::before {
    animation: hero-drift 24s ease-in-out infinite;
}
@media (prefers-reduced-motion: reduce) {
    .header-wrapper::before { animation: none; }
}

/* --- TL;DR badge on abstract card --- */
.abstract-section { position: relative; }
.tldr-badge {
    position: absolute;
    top: -0.7rem; left: 1.25rem;
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.7rem;
    background: var(--accent);
    color: #fff;
    font-family: var(--sans);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    border-radius: 999px;
    box-shadow: 0 2px 6px rgba(84,101,255,0.35),
                0 6px 18px rgba(84,101,255,0.20);
    text-transform: uppercase;
}

/* --- Lightbox overlay (JS-driven) --- */
.lightbox-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 12, 20, 0.92);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.2s ease;
    cursor: zoom-out;
    padding: 2rem;
}
.lightbox-overlay.visible { opacity: 1; }
.lightbox-overlay img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    box-shadow: 0 20px 60px rgba(0,0,0,0.6);
    border-radius: 6px;
    transform: scale(0.96);
    transition: transform 0.2s ease;
}
.lightbox-overlay.visible img { transform: scale(1); }
.lightbox-close {
    position: absolute;
    top: 1rem; right: 1.2rem;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: #fff;
    width: 40px; height: 40px;
    border-radius: 50%;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.lightbox-close:hover { background: rgba(255,255,255,0.18); }
.paper-figure img,
.paper-figure picture img { cursor: zoom-in; }

/* --- Mobile TOC drawer + FAB --- */
.toc-fab {
    position: fixed;
    bottom: 1.25rem;
    right: 1.25rem;
    width: 52px; height: 52px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    border: none;
    font-size: 1.15rem;
    box-shadow: 0 4px 14px rgba(84,101,255,0.35),
                0 10px 30px rgba(16,24,40,0.20);
    cursor: pointer;
    z-index: 9998;
    display: none;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s ease, box-shadow 0.2s ease;
}
.toc-fab:hover { transform: translateY(-2px); }
@media (max-width: 1279px) {
    body.has-toc .toc-fab { display: flex; }
    body.toc-open .toc-sidebar {
        display: block !important;
        position: fixed;
        top: 0; right: 0; bottom: 0;
        width: min(320px, 88vw);
        background: var(--bg, #fff);
        padding: 1.5rem 1.25rem 1.5rem;
        z-index: 9999;
        overflow-y: auto;
        box-shadow: -10px 0 40px rgba(16,24,40,0.25);
        animation: slide-in-right 0.22s ease-out;
    }
    body.toc-open::after {
        content: "";
        position: fixed;
        inset: 0;
        background: rgba(10,12,20,0.55);
        z-index: 9997;
    }
}
@keyframes slide-in-right {
    from { transform: translateX(100%); }
    to   { transform: translateX(0); }
}

/* --- Footer enrichment --- */
.site-footer { padding: 3rem var(--pad) 2rem; }
.footer-inner {
    max-width: var(--text-width);
    margin: 0 auto;
    text-align: center;
}
.footer-title {
    font-family: var(--sans);
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text);
    margin: 0 0 0.4rem;
}
.footer-meta {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin: 0 0 0.6rem;
}
.footer-meta a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.15s;
}
.footer-meta a:hover { color: var(--accent); }
.footer-license {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin: 0;
    opacity: 0.8;
}

/* --- BibTeX code block: JetBrains Mono looks best at slightly loose line-height --- */
.bibtex-code {
    font-family: var(--mono);
    font-size: 0.85rem;
    line-height: 1.7;
}

/* --- Dark-mode touches for the new elements --- */
@media (prefers-color-scheme: dark) {
    .paper-table-wrap {
        background:
            linear-gradient(90deg, #111 30%, rgba(17,17,17,0)) left center / 20px 100% no-repeat,
            linear-gradient(90deg, rgba(17,17,17,0), #111 70%) right center / 20px 100% no-repeat,
            radial-gradient(ellipse at left, rgba(0,0,0,0.5), transparent 70%) left center / 14px 80% no-repeat,
            radial-gradient(ellipse at right, rgba(0,0,0,0.5), transparent 70%) right center / 14px 80% no-repeat;
        background-attachment: local, local, scroll, scroll;
    }
    .paper-table-wrap tbody td strong { color: var(--text); }
    .tldr-badge {
        background: var(--accent);
        box-shadow: 0 2px 6px rgba(107,122,255,0.50),
                    0 6px 18px rgba(107,122,255,0.35);
    }
    .toc-fab {
        box-shadow: 0 4px 14px rgba(107,122,255,0.50),
                    0 10px 30px rgba(0,0,0,0.45);
    }
    body.toc-open .toc-sidebar {
        background: #18181b;
        box-shadow: -10px 0 40px rgba(0,0,0,0.6);
    }
}
