/* Research portfolio / editorial system. Loaded after the legacy component sheet. */
:root {
    --bg-color: #f7f8fa; --bg-primary: var(--bg-color); --bg-secondary: #edf0f4;
    --card-bg: #fff; --text-primary: #14202d; --text-secondary: #536170;
    --text-tertiary: #65717e; --accent-color: #1968d9; --accent-hover: #0b51ba;
    --border-color: #cbd3dd; --border-light: #dfe4eb; --radius-lg: 16px;
    --container-max: 1200px; --editorial-serif: Georgia, 'Times New Roman', serif;
}
[data-theme="dark"] {
    --bg-color: #0b1018; --bg-secondary: #131c28; --card-bg: #111a26;
    --text-primary: #edf2f7; --text-secondary: #b0bdcb; --text-tertiary: #94a5b8;
    --accent-color: #83b5ff; --accent-hover: #a9ceff;
    --border-color: #344356; --border-light: #253246;
    --glass-bg: rgba(11,16,24,.92);
}
html { scroll-padding-top: 100px; }
body { background: var(--bg-color); }
body, a, button, input, select { cursor: auto; }
a, button, select, input[type="range"] { cursor: pointer; }
body.custom-cursor-active, body.custom-cursor-active a, body.custom-cursor-active button { cursor: auto !important; }
#cursor, #heroCanvas { display: none !important; }
button, a, select, input { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, select:focus-visible, input:focus-visible, summary:focus-visible {
    outline: 2px solid var(--accent-color); outline-offset: 5px;
}
button, .btn, .btn-pill { min-height: 40px; }
.container { max-width: 1200px; }
.eyebrow { font: 500 10px/1.6 'JetBrains Mono', monospace; text-transform: uppercase; letter-spacing: .13em; color: var(--text-secondary); }
.site-nav { top: 18px; background: var(--glass-bg); box-shadow: none; border: 1px solid var(--border-light); }
.nav-container { gap: 20px; }
.nav-brand { font-weight: 600; letter-spacing: -.03em; }
.site-nav .nav-brand { display: inline-flex; flex-shrink: 0; }
.nav-links, [data-theme="dark"] .nav-links { background: transparent; border: 0; box-shadow: none; }
.nav-link { font-size: 12px; }
.nav-indicator { border-radius: 999px; box-shadow: none !important; }
.editorial-hero { display: grid; grid-template-columns: 1.08fr 1fr; gap: 32px 70px; padding-top: 146px; padding-bottom: 24px; }
.editorial-hero h1 { font-family: 'Sora', sans-serif; font-size: clamp(52px, 5.8vw, 82px); line-height: 1.05; font-weight: 500; letter-spacing: -.065em; margin: 26px 0; }
.editorial-hero em { font-family: var(--editorial-serif); font-weight: 400; color: var(--accent-color); letter-spacing: -.06em; }
.action-text { display: inline-flex; align-items: center; justify-content: space-between; gap: 24px; font-size: 12px; font-weight: 600; text-decoration: none; min-height: 44px; }
.action-text { color: var(--text-primary); border-bottom: 1px solid var(--border-color); }
.action-text:hover { color: var(--accent-color); border-color: var(--accent-color); }
.recent-updates { padding-top: 64px; margin-bottom: 0; }
.section-head { font-size: clamp(26px,3.2vw,40px); font-weight: 500; letter-spacing: -.04em; }
.section-head span { color: var(--text-primary); }
.research-thesis { box-shadow: none; border: 0; border-top: 1px solid var(--border-color); border-bottom: 1px solid var(--border-color); background: transparent; border-radius: 0; }
.pub-card { border-radius: 12px; box-shadow: none !important; transform: none !important; }
.pub-card:hover { border-color: var(--accent-color); }
.pub-title { letter-spacing: -.025em; }
.filter-chip { border-radius: 5px; min-height: 36px; }
.filter-bar { gap: 8px; }
.project-page main { padding-top: 110px; }
.project-page .breadcrumb { margin-bottom: 34px; font-size: 11px; }
.project-page .project-hero, .project-page .paper-hero { margin-bottom: 32px; }
.project-page .project-hero h1, .project-page .paper-hero h1 { font-size: clamp(32px,4.1vw,54px); line-height: 1.12; letter-spacing: -.05em; font-weight: 500; max-width: 1000px; }
.project-page .project-lede, .project-page .paper-abstract, .project-page .project-glance p,
.project-page .project-threads p, .project-page .related-paper p, .project-page .section-intro {
    text-align: left; text-justify: auto; max-width: 72ch; line-height: 1.8;
}
.project-detail main .project-lede,
.project-detail main .project-glance > p,
.project-detail main .project-section p {
    text-align: left;
    text-justify: auto;
}
/* Long, full-width paragraphs read as justified blocks; hyphenation keeps
   word spacing even. Short paragraphs in narrow columns stay ragged. */
.project-page .paper-abstract, .project-page .project-lede, .project-page .section-intro,
.project-page .project-glance > p, .project-detail main .project-section > p,
.project-page .briefing p, .project-page .evidence-boundary p {
    text-align: justify; text-justify: inter-word; -webkit-hyphens: auto; hyphens: auto;
}
/* A caption under a centred inset figure shares its width and left edge. */
.media-inset + .figure-caption { max-width: 760px; margin-inline: auto; }
.project-page .project-lede { font-size: 17px; max-width: 760px; display: block; -webkit-line-clamp: unset; }
.project-page .hero-summary-toggle { display: none !important; }
.project-detail.project-page .project-hero:not(.hero-summary-expanded) .project-lede { display: block; -webkit-line-clamp: unset; line-clamp: unset; overflow: visible; }
.form-group label { display: block; font-size: 12px; color: var(--text-secondary); margin-bottom: 8px; }
.project-eyebrow { font: 10px 'JetBrains Mono',monospace; letter-spacing: .12em; color: var(--accent-color); }
.paper-authors { font-size: 13px; max-width: 850px; line-height: 1.8; }
.paper-name { display: block; font-size: clamp(42px,5.5vw,72px); margin-bottom: 14px; letter-spacing: -.06em; }
.paper-fulltitle { display: block; max-width: 900px; font-size: clamp(23px,2.5vw,34px); line-height: 1.25; letter-spacing: -.035em; text-wrap: balance; }
.project-hero h1,
.figure-title { text-wrap: balance; }
.paper-authors,
.stat-label,
.figure-sub,
.figure-note { overflow-wrap: break-word; }
.tag-cloud, .paper-actions { flex-wrap: wrap; }
.paper-actions { gap: 8px; margin-top: 22px; }
.btn-pill { border-radius: 5px; font-size: 11px; }
.detail-stat-row, .stat-row { border-radius: 0 !important; box-shadow: none !important; border: 0; border-block: 1px solid var(--border-color); background: transparent; }
.detail-stat, .stat-tile { border-radius: 0; background: transparent; }
.project-page .detail-stat-row, .project-page .detail-stat-row.stat-row { grid-template-columns: repeat(var(--stat-columns, 4), minmax(0, 1fr)); }
.detail-stat strong { white-space: nowrap; font-size: clamp(23px,2.2vw,32px); letter-spacing: -.04em; }
.stat-value { font-weight: 500; letter-spacing: -.05em; }
.stat-label { color: var(--text-secondary); line-height: 1.6; }
.stat-attribution { grid-column: 1/-1; padding: 12px 20px; font-size: 11px; color: var(--text-secondary); line-height: 1.7; border-top: 1px solid var(--border-light); }
.project-section { margin-top: 64px; margin-bottom: 64px; }
.project-overview { border-radius: 12px; box-shadow: none; }
.project-glance { padding: 28px; }
.project-media { position: relative; border-radius: 10px; overflow: hidden; }
.project-threads { gap: 0; }
.project-threads > li { padding: 26px 28px; border-bottom: 1px solid var(--border-light); }
.project-threads h3 { font-size: 18px; letter-spacing: -.025em; }
.project-threads p { font-size: 14px; }
.thread-index { font: 11px 'JetBrains Mono',monospace; color: var(--accent-color); }
.paper-figure { margin: 32px 0; }
.figure-plate { border-radius: 8px; }
.figure-caption, .figure-sub, .figure-note { text-align: left !important; }
.figure-card { padding: 28px; border: 1px solid var(--border-color); border-radius: 12px; background: var(--card-bg); box-shadow: none; margin-block: 28px; }
.figure-title { font-size: 20px; letter-spacing: -.025em; font-weight: 500; }
/* Keep the original neutral baselines and per-paper blue highlight. */
.figure-card { --fig-s1: #7a818b; --fig-s2: #979da6; --fig-s3: #606873; --fig-s4: #aeb3ba; --fig-s6: #515a66; }
[data-theme="dark"] .figure-card { --fig-s1: #c0c3c8; --fig-s2: #a2a6ad; --fig-s3: #7f858e; --fig-s4: #656c77; --fig-s6: #535b67; --fig-grid: #29374a; }
.figure-controls { gap: 12px; margin-bottom: 16px; }
.figure-plot-context { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; margin-top: 24px; padding: 12px 0; border-bottom: 1px solid var(--border-color); }
.figure-current-metric { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.figure-direction { background: #e8eef7; border-color: #7388a5; color: #17365d; }
[data-theme="dark"] .figure-direction { background: #2b405c; border-color: #8099bb; color: #f3f7ff; }
.figure-plot-context .figure-direction { margin: 0; border-radius: 6px; padding: 7px 10px; font-size: 11px; letter-spacing: .02em; }
.figure-direction .figure-direction-arrow { color: #174f92; font-size: 17px; }
[data-theme="dark"] .figure-direction .figure-direction-arrow { color: #b7d5ff; }
.figure-export-error { color: var(--text-primary); font-size: 12px; margin-top: 12px; }
.figure-card .figure-seg { border-radius: 14px; padding: 4px; flex-wrap: wrap; gap: 4px; }
.figure-card .figure-seg-btn { border-radius: 9px; font-size: 11px; min-height: 40px; padding: 10px 16px; }
.figure-card .figure-seg-btn[aria-pressed="true"] { background: var(--fig-s5); color: #fff; }
.figure-sub, .figure-note { font-size: 12px; line-height: 1.8; color: var(--text-secondary); }
.figure-note { max-width: 100%; }
.figure-tick { font-size: 11px; }
.figure-legend { gap: 8px 14px; }
.figure-legend-item { font-size: 11px; }
.figure-legend-button { display: inline-flex; align-items: center; gap: 7px; background: transparent; border: 1px solid transparent; border-radius: 4px; padding: 5px 7px; color: inherit; font: inherit; min-height: 32px; }
.figure-legend-button:hover { border-color: var(--border-color); }
.figure-legend-button[aria-pressed="false"] { opacity: .45; text-decoration: line-through; }
.figure-utility-bar { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border-light); }
.figure-utility-bar button { background: transparent; color: var(--text-secondary); border: 1px solid var(--border-color); border-radius: 5px; padding: 7px 10px; font: 11px 'IBM Plex Sans',sans-serif; min-height: 34px; }
.figure-utility-bar button:hover { color: var(--accent-color); border-color: var(--accent-color); }
.figure-evidence { color: var(--accent-color); font: 9px/1.5 'JetBrains Mono',monospace; letter-spacing: .06em; text-transform: uppercase; margin-bottom: 12px; }
.comparison-table { overflow: auto; margin-top: 18px; }
.comparison-table table { width: 100%; border-collapse: collapse; font-size: 12px; font-variant-numeric: tabular-nums; }
.comparison-table th, .comparison-table td { padding: 10px; text-align: right; border-bottom: 1px solid var(--border-light); white-space: nowrap; }
.comparison-table th:first-child { text-align: left; }
.comparison-table caption { text-align: left; line-height: 1.7; color: var(--text-secondary); padding-bottom: 12px; }
.comparison-table .positive { color: var(--accent-color); }
.briefing { padding: 28px 0; margin: 28px 0 40px; border-block: 1px solid var(--border-color); display: grid; grid-template-columns: 160px 1fr; gap: 24px; }
.briefing h2 { font-size: 22px; font-weight: 500; line-height: 1.3; letter-spacing: -.03em; }
.briefing p { font-size: 16px; color: var(--text-secondary); line-height: 1.8; max-width: 72ch; margin-bottom: 14px; }
.briefing-actions { display: flex; flex-wrap: wrap; gap: 8px 28px; }
/* Quiet secondary links; primary actions and navigation retain their hierarchy. */
.orion-paper-video { height: auto; aspect-ratio: 2 / 1; }
body a.editorial-link {
    display: inline-flex; align-items: center; min-height: 44px;
    color: var(--text-secondary); font-size: 12px; font-weight: 400;
    background: transparent; border: 0; border-radius: 0; padding: 0;
    box-shadow: none; transform: none;
    text-decoration: underline; text-decoration-color: var(--border-color);
    text-decoration-thickness: 1px; text-underline-offset: 5px;
    transition: color 160ms ease, text-decoration-color 160ms ease;
}
body a.editorial-link:hover,
body a.editorial-link:focus-visible {
    color: var(--accent-color); text-decoration-color: currentColor;
    background: transparent; border: 0; box-shadow: none; transform: none;
}
.stat-evaluation-link {
    grid-column: 1 / -1; text-align: right; padding-top: 12px;
}
.paper-actions, .pub-links, .related-links, .home-page .pub-links { column-gap: 24px; align-items: center; }
.home-page .hp-pillars .hp-evidence { gap: 4px 18px; }
@media (prefers-reduced-motion: reduce) {
    body a.editorial-link { transition: none; }
}
.evidence-boundary { padding: 22px 26px; border-left: 2px solid var(--accent-color); background: var(--bg-secondary); margin: 40px 0; }
.evidence-boundary h2 { font-size: 17px; font-weight: 500; margin-bottom: 10px; }
.evidence-boundary p { color: var(--text-secondary); font-size: 13px; line-height: 1.8; max-width: 80ch; }
.research-strands { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 24px; margin: 30px 0; }
.research-strand { border-top: 2px solid var(--accent-color); padding: 20px 0; }
.research-strand h3 { font-size: 18px; letter-spacing: -.03em; margin-bottom: 12px; }
.research-strand p { color: var(--text-secondary); font-size: 13px; line-height: 1.8; margin-bottom: 15px; }
.research-strand a { font-size: 12px; color: var(--accent-color); }
.study-status { display: inline-block; background: var(--bg-secondary); border: 1px solid var(--border-color); padding: 7px 10px; margin: 16px 0; border-radius: 4px; font: 10px 'JetBrains Mono',monospace; }
.walkthrough { margin: 32px 0; border: 1px solid var(--border-color); border-radius: 12px; overflow: hidden; background: var(--card-bg); }
.walkthrough-tabs { display: flex; gap: 8px; padding: 10px; border-bottom: 1px solid var(--border-color); overflow-x: auto; scroll-padding-inline: 10px; }
.walkthrough-tabs button { flex: 1 0 160px; padding: 16px 24px; border: 0; border-radius: 7px; background: transparent; color: var(--text-secondary); font: 12px/1.6 'IBM Plex Sans',sans-serif; min-width: 160px; }
.walkthrough-tabs button[aria-pressed="true"] { background: var(--bg-secondary); color: var(--accent-color); box-shadow: inset 0 0 0 1px var(--border-color); }
.walkthrough-panel { display: grid; grid-template-columns: 1.2fr 1fr; align-items: center; gap: 30px; padding: 30px; }
.walkthrough-panel img { width: 100%; height: 260px; object-fit: contain; background: #fff; border-radius: 6px; }
.walkthrough-panel h3 { font-size: 24px; font-weight: 500; letter-spacing: -.04em; margin: 12px 0; }
.walkthrough-panel p { color: var(--text-secondary); font-size: 14px; line-height: 1.8; }
.walkthrough-panel .concept-steps { display: grid; gap: 10px; }
.concept-steps span { padding: 18px; border: 1px solid var(--border-color); border-radius: 6px; color: var(--text-secondary); font-size: 14px; }
.concept-steps span.is-current { background: var(--bg-secondary); border-color: var(--accent-color); color: var(--accent-color); }
.media-toggle { position: absolute; bottom: 12px; right: 12px; border: 1px solid #ffffff55; background: #0b1018dd; color: #fff; border-radius: 5px; padding: 8px 12px; font-size: 11px; z-index: 3; }
/* "On this page": a quiet table of contents in the right margin. One hairline
   track with an accent marker beside the current section, no per-item dots,
   so labels align and the rail stays compact. These rules replace the older
   timeline and bottom-bar variants in style.css, hence the !important. */
.reader-rail {
    position: fixed !important; top: 120px !important; right: 24px !important; bottom: auto !important; left: auto !important;
    z-index: 80 !important; width: 168px !important; margin: 0 !important; transform: none !important;
    background: transparent !important; border: 0 !important; border-radius: 0 !important; box-shadow: none !important;
    -webkit-backdrop-filter: none !important; backdrop-filter: none !important; overflow: visible !important;
    opacity: .78; transition: opacity 200ms ease;
}
.reader-rail:hover, .reader-rail:focus-within { opacity: 1; }
.reader-rail-label {
    display: block; margin: 0 0 12px !important; padding: 0 !important; color: var(--text-tertiary);
    font: 500 10.5px/1 'JetBrains Mono', monospace; letter-spacing: .12em; text-transform: uppercase;
}
.reader-rail-inner {
    display: flex !important; flex-direction: column !important; align-items: stretch !important;
    gap: 0 !important; min-height: 0 !important; padding: 0 !important; overflow: visible !important;
}
.reader-rail a {
    position: relative; display: block !important; min-height: 0 !important; margin: 0 !important;
    padding: 6px 0 6px 14px !important; border-left: 1px solid var(--border-color); border-radius: 0 !important;
    background: none !important; color: var(--text-tertiary) !important; text-decoration: none;
    font: 500 12.5px/1.35 'IBM Plex Sans', sans-serif !important; white-space: normal !important;
}
.reader-rail a::after { display: none !important; }
.reader-rail a::before {
    content: "" !important; display: block !important; position: absolute; left: -1px !important; top: 5px !important; bottom: 5px;
    width: 2px !important; height: auto !important; border: 0 !important; border-radius: 2px !important;
    background: var(--accent-color) !important; box-shadow: none !important;
    transform: scaleY(0); transition: transform 200ms ease;
}
.reader-rail a:hover { color: var(--text-primary) !important; }
.reader-rail a.is-current { color: var(--text-primary) !important; font-weight: 600 !important; }
.reader-rail a.is-current::before { transform: scaleY(1); }
.reader-rail a:focus-visible { outline: 2px solid var(--accent-color); outline-offset: 2px; }
.reader-rail-track, .reader-rail-progress { display: none !important; }
.project-page main > .container, .project-page .container { max-width: 1080px; }
.project-page .project-footer .container { max-width: 1200px; }
.config-section .form-input { max-width: 100%; }
.reader-flow { display: flex; gap: 12px; flex-wrap: wrap; padding: 18px 0; border-block: 1px solid var(--border-color); margin-bottom: 30px; }
.reader-flow span { flex: 1; min-width: 130px; font-size: 12px; color: var(--text-secondary); }
.reader-flow b { color: var(--accent-color); margin-right: 8px; font-family: 'JetBrains Mono',monospace; }
.reader-privacy { display: flex; flex-direction: column; gap: 12px; margin-top: 18px; font-size: 12px; color: var(--text-secondary); line-height: 1.8; }
.reader-privacy input { margin-right: 8px; accent-color: var(--accent-color); }
.reader-notice { padding: 15px 18px; background: var(--bg-secondary); border: 1px solid var(--border-color); border-radius: 6px; font-size: 13px; line-height: 1.7; color: var(--text-secondary); }
.reader-error { color: #bf3434; }
.reader-page .section-head { text-align: left; }
.reader-page .section-head h1 { font-size: clamp(34px,5vw,60px); line-height: 1.12; font-weight: 500; letter-spacing: -.05em; }
.reader-page .section-head > p:not(.eyebrow) { font-size: 16px; margin: 18px 0 0 !important; line-height: 1.75 !important; }
.reader-page .section-head > .eyebrow { font-size: 10px; margin-bottom: 14px; }
.reader-page .config-section { box-shadow: none; }
.reader-page .config-section > div:first-child > div { min-width: 0 !important; }
.reader-page progress { accent-color: var(--accent-color); }
.reader-page input[type="checkbox"] { accent-color: var(--accent-color); }
[data-theme="dark"] .reader-error { color: #ffa2a2; }
.reveal { transition-duration: 400ms; }
.figure-anim-pending.figure-anim-revealed .figure-bar,
.figure-anim-pending.figure-anim-revealed .figure-curve,
.figure-anim-pending.figure-anim-revealed .figure-line { animation-duration: 420ms; animation-delay: 0ms; }
@keyframes editorial-enter { from { opacity: .4; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (max-width: 1390px) {
    .reader-rail { display: none !important; }
    /* html's scroll-padding-top already clears the floating nav. */
    .project-page section[id], .project-page [data-figure][id] { scroll-margin-top: 0; }
}
@media (min-width: 1391px) { .project-page main { padding-right: 140px; } }
@media (max-width: 800px) {
    .editorial-hero { grid-template-columns: 1fr; gap: 36px; padding-top: 120px; }
    .editorial-hero h1 { font-size: clamp(48px,10.5vw,74px); }
    .editorial-hero h1 br:nth-of-type(1), .editorial-hero h1 br:nth-of-type(3) { display: none; }
    .research-strands { grid-template-columns: 1fr; gap: 0; }
    .walkthrough-panel { grid-template-columns: 1fr; gap: 18px; }
    .walkthrough-panel img { height: 220px; }
    .briefing { grid-template-columns: 1fr; gap: 14px; }
    .briefing p { font-size: 15px; }
}
@media (max-width: 600px) {
    .container { padding-inline: 22px; }
    .site-nav { left: 14px; right: 14px; top: 12px; width: auto; transform: none; }
    .nav-container { gap: 8px; padding: 8px 12px; }
    .nav-brand { font-size: 13px; }
    .nav-links { display: flex; gap: 0; overflow: visible; }
    .nav-links .nav-link { font-size: 10px; padding: 8px; }
    .nav-links .nav-link[href="#work"], .nav-links .nav-link[href="#contact"] { display: none; }
    .search-trigger { display: none; }
    .theme-toggle { margin-left: auto; width: 32px; min-width: 32px; }
    .editorial-hero { padding-top: 108px; padding-bottom: 0; }
    .editorial-hero h1 { margin: 20px 0; letter-spacing: -.06em; font-size: 51px; }
    .project-page main { padding-top: 90px; }
    .project-page .project-hero h1, .project-page .paper-hero h1 { font-size: 32px; }
    .project-page .project-lede { font-size: 15px; }
    .project-page .breadcrumb { margin-bottom: 28px; }
    .project-page .paper-abstract { font-size: 14px; }
    .project-section { margin-block: 44px; }
    .project-threads > li { padding: 22px 18px; }
    .figure-card { padding: 18px 14px; border-radius: 9px; }
    .figure-title { font-size: 18px; }
    .figure-controls { gap: 8px; }
    .figure-seg { max-width: 100%; }
    .figure-seg-btn { padding: 8px 10px; }
    .figure-head-row { gap: 12px; }
    .figure-note { font-size: 12px; }
    .walkthrough-panel { padding: 20px; }
    .project-page .detail-stat-row, .project-page .detail-stat-row.stat-row { grid-template-columns: repeat(2,minmax(0,1fr)); }
    .detail-stat, .stat-tile { padding: 20px 12px; }
    .reader-flow { flex-direction: column; }
}
/* A consistent inset chevron, independent of browser-native select chrome. */
body select:not([multiple]) {
    appearance: none;
    -webkit-appearance: none;
    padding-right: 42px;
    background-image: linear-gradient(45deg, transparent 50%, var(--text-secondary) 50%), linear-gradient(135deg, var(--text-secondary) 50%, transparent 50%);
    background-position: calc(100% - 18px) calc(50% + 1px), calc(100% - 14px) calc(50% + 1px);
    background-size: 4px 4px;
    background-repeat: no-repeat;
}
@media (forced-colors: active) {
    body select:not([multiple]) { appearance: auto; -webkit-appearance: auto; background-image: none; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
    .motion-ready .reveal { opacity: 1 !important; transform: none !important; }
}
@media print {
    .site-nav, .reader-rail, .section-menu-panel, .figure-utility-bar, .media-toggle { display: none !important; }
    .project-page main { padding: 0; }
    .figure-card { break-inside: avoid; }
}

/* Section menu in the floating nav. Shown where the side rail is hidden: the
   button names the current section, the panel lists every section. */
.section-menu { display: none; }
@media (max-width: 1390px) { .section-menu { display: flex; flex: 0 1 auto; min-width: 0; } }
.section-menu-trigger {
    display: inline-flex; align-items: center; gap: 6px; min-width: 0; max-width: 100%; height: 34px; padding: 0 10px 0 13px;
    border: 1px solid var(--border-light); border-radius: 999px; background: var(--bg-secondary); color: var(--text-primary);
    font: 600 13px/1 'IBM Plex Sans', sans-serif; cursor: pointer; transition: border-color .2s ease, color .2s ease;
}
.section-menu-trigger:hover, .section-menu-trigger[aria-expanded="true"] { border-color: var(--accent-color); color: var(--accent-color); }
.section-menu-current { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.section-menu-trigger svg { flex: 0 0 auto; transition: transform .2s ease; }
.section-menu-trigger[aria-expanded="true"] svg { transform: rotate(180deg); }
.section-menu-panel {
    position: fixed; z-index: 1001; max-height: min(62vh, 440px); overflow-y: auto; padding: 6px;
    background: var(--card-bg); border: 1px solid var(--border-color); border-radius: 16px;
    box-shadow: 0 20px 48px -20px rgb(0 0 0 / .4); animation: section-menu-in 160ms ease;
}
.section-menu-panel[hidden] { display: none !important; }
.section-menu-label { padding: 10px 10px 6px; color: var(--text-tertiary); font: 500 10.5px/1 'JetBrains Mono', monospace; letter-spacing: .12em; text-transform: uppercase; }
.section-menu-list { margin: 0; padding: 0; list-style: none; }
.section-menu-link {
    display: flex; align-items: baseline; gap: 12px; padding: 11px 10px; border-radius: 10px;
    color: var(--text-secondary); text-decoration: none; font: 500 14px/1.35 'IBM Plex Sans', sans-serif;
}
.section-menu-link:hover, .section-menu-link:focus-visible { background: var(--bg-secondary); color: var(--text-primary); outline: none; }
.section-menu-link[aria-current] { background: color-mix(in srgb, var(--accent-color) 12%, transparent); color: var(--text-primary); font-weight: 600; }
.section-menu-index { flex: 0 0 auto; color: var(--text-tertiary); font: 500 11px/1 'JetBrains Mono', monospace; }
.section-menu-link[aria-current] .section-menu-index { color: var(--accent-color); }
@keyframes section-menu-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

/* The light dark-mode accent needs dark text on the primary pill button. */
[data-theme="dark"] .btn-pill-strong, [data-theme="dark"] .btn-pill-strong:hover { color: #0b1018; }

/* Compact top pill on desktop; move the same pill to the bottom on mobile. */
html { scroll-padding-top: 100px; scroll-padding-bottom: 24px; }
body { padding-bottom: 0; }
body .site-nav, body .site-nav.nav-scrolled {
    top: 18px; bottom: auto;
    left: 0; right: 0; margin-inline: auto; transform: none;
    width: fit-content; max-width: calc(100% - 24px); height: auto; min-height: 56px;
    padding: 6px; border-radius: 28px;
    background: var(--glass-bg); border: 1px solid var(--border-color);
    box-shadow: 0 8px 32px #0002; overflow: visible;
}
body .site-nav .nav-container {
    height: auto; min-width: 0; gap: 8px; padding: 0 6px; flex-wrap: wrap;
}
body .site-nav .nav-brand { display: inline-flex; white-space: nowrap; }
body .site-nav .nav-back { flex: 0 0 auto; width: auto; max-width: none; min-height: 44px; }
body .site-nav .nav-back span {
    position: static; width: auto; height: auto; max-width: none; opacity: 1;
    overflow: visible; clip: auto; text-overflow: clip; white-space: normal;
}
body .site-nav .search-trigger, body .site-nav .theme-toggle {
    display: inline-flex; flex: 0 0 44px; width: 44px; min-width: 44px; height: 44px; min-height: 44px;
    margin: 0; padding: 0; align-items: center; justify-content: center;
}
body .site-nav .search-trigger kbd { display: none; }
body .site-nav .section-menu { flex: 0 1 auto; min-width: 0; max-width: none; }
body .site-nav .section-menu-trigger { min-height: 44px; height: auto; max-width: none; padding: 10px 14px; }
body .site-nav .section-menu-current { max-width: none; white-space: normal; overflow: visible; text-overflow: clip; text-align: left; }
.section-menu-trigger svg { transform: rotate(0); flex-shrink: 0; }
.section-menu-trigger[aria-expanded="true"] svg { transform: rotate(180deg); }
.section-menu-panel { transform-origin: top center; overflow-y: auto; overscroll-behavior: contain; }
@media (max-width: 600px) {
    html { scroll-padding-top: 24px; scroll-padding-bottom: calc(var(--bottom-nav-space, 100px) + env(safe-area-inset-bottom, 0px)); }
    body { padding-bottom: calc(var(--bottom-nav-space, 100px) + env(safe-area-inset-bottom, 0px)); }
    body .site-nav, body .site-nav.nav-scrolled {
        top: auto; bottom: calc(12px + env(safe-area-inset-bottom, 0px));
        padding: 4px; min-height: 54px;
    }
    body .site-nav .nav-container { justify-content: center; flex-wrap: nowrap; gap: 4px; padding-inline: 2px; }
    body .site-nav .nav-brand { display: none; }
    body .site-nav .nav-links {
        display: flex; order: 0; flex: 0 1 auto; width: auto; max-width: 100%; min-width: 0;
        flex-wrap: nowrap; justify-content: center; overflow-x: auto; overflow-y: visible; gap: 0; padding: 0;
        scrollbar-width: none;
    }
    body .site-nav .nav-links::-webkit-scrollbar { display: none; }
    body.home-page .site-nav .nav-links .nav-link {
        display: inline-flex; flex: 0 0 auto; white-space: nowrap; font-size: 12px; min-width: 44px; min-height: 44px; padding: 10px 5px;
    }
    body .site-nav .nav-indicator { display: none; }
    body .site-nav .nav-link.active { color: var(--accent-color); background: var(--bg-secondary); border-radius: 16px; }
    body.home-page .site-nav.nav-compact .nav-link:not(.active) { display: none; }
    body.home-page .site-nav.nav-compact:focus-within .nav-link { display: inline-flex; }
    body.home-page .site-nav.nav-compact:focus-within { width: calc(100% - 24px); }
    body.home-page .site-nav.nav-compact:focus-within .nav-links { flex: 0 1 auto; width: auto; }
    body .site-nav-minimal .nav-back { padding-inline: 6px; }
    body .site-nav-minimal .nav-container { gap: 4px; padding-inline: 2px; }
    body .site-nav-minimal .section-menu-trigger { padding-inline: 10px; }
    .section-menu-trigger svg { transform: rotate(180deg); }
    .section-menu-trigger[aria-expanded="true"] svg { transform: rotate(0); }
    .section-menu-panel { transform-origin: bottom center; }
}
@media (hover: hover) {
    body.home-page .site-nav.nav-compact:hover .nav-link { display: inline-flex; }
    body.home-page .site-nav.nav-compact:hover { width: calc(100% - 24px); }
    body.home-page .site-nav.nav-compact:hover .nav-links { flex: 0 1 auto; width: auto; }
}
@media (max-width: 360px) {
    body .site-nav-minimal .section-menu { order: 4; flex-basis: 100%; }
    body .site-nav-minimal .section-menu-trigger { width: 100%; justify-content: space-between; }
}
@media print { body { padding-bottom: 0; } }

/* Pages without a side rail (no hero media, e.g. 3D Map Generation) keep the
   section button at every width, so wide screens still get section navigation. */
body:not(:has(.reader-rail)) .section-menu { display: flex; flex: 0 1 auto; min-width: 0; }
