/* ========================================
   D4RT Style - Light Theme Academic Template
   Replicated from https://d4rt-paper.github.io/
   ======================================== */

:root {
    --btn-height: 44px;
    --btn-gap: 8px;
    --img-size: calc((var(--btn-height) * 2) + var(--btn-gap));
    --btn-height-mobile: 30px;
    --btn-gap-mobile: 4px;
    --img-size-mobile: calc((var(--btn-height-mobile) * 2) + var(--btn-gap-mobile));
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Google Sans', Arial, sans-serif;
    line-height: 1.6;
    color: #333;
    max-width: 1200px;
    margin: 40px auto;
    padding: 0 40px;
    background-color: #fff;
}

a {
    color: #1a73e8;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

h1, h2 {
    color: #202124;
    text-align: center;
    font-weight: 500;
}

h1 {
    font-size: 2.8em;
    margin-bottom: 0.6em;
    line-height: 1.2;
}

h2 {
    font-size: 1.9em;
    margin-top: 1.5em;
    margin-bottom: 1em;
}

/* Authors */
.authors {
    text-align: center;
    margin-bottom: 10px;
    font-size: 1em;
    color: #3c4043;
}

.authors span {
    display: inline-block;
    margin: 0 5px;
    white-space: nowrap;
}

/* Affiliations */
.affiliations {
    text-align: center;
    font-size: 0.9em;
    margin-bottom: 30px;
    color: #5f6368;
}

sup {
    line-height: 0;
    font-size: 75%;
}

/* Links */
.links {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 40px;
}

.links a {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-width: 105px;
    height: 46px;
    padding: 10px 20px;
    background-color: #1a73e8;
    color: white;
    text-decoration: none;
    border-radius: 8px;
    transition: background-color 0.3s, box-shadow 0.3s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    font-weight: 500;
    line-height: 1;
    box-sizing: border-box;
}

.links a svg,
.links a img {
    display: block;
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.links a:hover {
    background-color: #185abc;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

/* Video Container */
.video-container {
    background-color: #f8f9fa;
    padding: 0;
    border-radius: 18px;
    margin-bottom: 30px;
    border: 1px solid #e1e5ea;
    overflow: hidden;
    position: relative;
}

.video-container video {
    width: 100%;
    display: block;
    border-radius: 18px 18px 0 0;
}

.video-container video.video-fullscreen-enabled {
    cursor: zoom-in;
}

.video-container video.video-fullscreen-enabled:focus-visible,
.zoomable-image:focus-visible {
    outline: 3px solid #1a73e8;
    outline-offset: 4px;
}

.video-placeholder {
    width: 100%;
    aspect-ratio: 16/9;
    background: linear-gradient(135deg, #f8f9fa 0%, #e8eaed 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #5f6368;
    font-size: 1.2em;
    border-radius: 30px 30px 0 0;
}

.video-placeholder small {
    font-size: 0.7em;
    margin-top: 8px;
    opacity: 0.7;
}

.video-container video:not([src=""]) + .video-placeholder {
    display: none;
}

/* Chapters Navigation */
.chapters {
    display: flex;
    justify-content: center;
    gap: 5px;
    margin-bottom: -10px;
    padding: 0 30px 30px;
    flex-wrap: wrap;
}

.chapters button {
    padding: 5px 7px;
    border: 3px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.3s, box-shadow 0.3s, filter 0.3s, border-color 0.3s, color 0.3s;
    font-size: 0.82em;
    color: white;
    font-weight: 500;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    text-align: center;
    line-height: 1.3;
    background-color: #1a73e8;
    flex: 1 1 100px;
    font-family: inherit;
}

.chapters button:hover:not(.selected) {
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
    filter: brightness(110%);
}

.chapters button.selected {
    background-color: #fff;
    border-color: #1a73e8;
    color: #1a73e8;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

/* Section blocks */
.abstract, .citation, .visualization-container, .method, .results, .capabilities, .demo-container, .acknowledgements {
    background-color: #f8f9fa;
    padding: 30px;
    border-radius: 18px;
    margin-bottom: 30px;
    border: 1px solid #e1e5ea;
    transition: padding-bottom 0.1s ease-in-out;
}

.abstract h2, .citation h2, .visualization-container h2, .method h2, .results h2, .capabilities h2, .demo-container h2, .acknowledgements h2 {
    margin-top: 0;
    text-align: left;
    font-size: 1.5em;
}

.abstract p, .method p, .results p, .capabilities p, .acknowledgements p {
    text-align: justify;
    font-size: 1.05em;
}

/* Figure Container */
.fig-container {
    background-color: transparent;
    padding: 0;
    border-radius: 16px;
    border: none;
    margin-bottom: 15px;
    box-sizing: border-box;
}

.overview-image {
    width: 65%;
    max-width: 100%;
    border-radius: 20px;
    display: inline-block;
}

.zoomable-image {
    cursor: zoom-in;
}

.capabilities-images {
    display: flex;
    gap: 10px;
}

.capabilities-images img {
    min-width: 0;
    flex: 1;
    height: auto;
    display: block;
    margin: 0 auto;
    max-width: 100%;
    border-radius: 20px;
}

.img-placeholder {
    flex: 1;
    min-height: 200px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e8eaed 100%);
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #5f6368;
    font-size: 0.9em;
    text-align: center;
}

.img-placeholder small {
    font-size: 0.8em;
    opacity: 0.7;
    margin-top: 4px;
}

/* Results */
.results-intro {
    max-width: 920px;
    margin: 0 0 12px;
    color: #3c4043;
}

.result-summary-list {
    max-width: 920px;
    margin: 0 0 24px;
    padding-left: 20px;
    color: #3c4043;
    line-height: 1.55;
}

.result-summary-list li + li {
    margin-top: 6px;
}

.result-table-list {
    display: grid;
    gap: 22px;
}

.result-table-list .result-figure {
    width: 100%;
    margin-left: auto;
    margin-right: auto;
}

.result-table-list .result-figure-pair {
    width: 100%;
    margin: 0 auto;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 16px;
}

.result-table-list .result-figure-pair .result-figure {
    width: 100%;
}

.result-task-title {
    width: 100%;
    margin: 8px auto -8px;
    padding-top: 12px;
    border-top: 1px solid #e8eaed;
    color: #202124;
    font-size: 1.15em;
    font-weight: 500;
}

.result-task-desc {
    width: 100%;
    margin: 0;
    color: #5f6368;
    font-size: 0.95em;
    line-height: 1.45;
}

.result-task-title-wide {
    width: 100%;
    margin-top: 24px;
}

.result-figure-group {
    margin: 0;
}

.result-figure {
    margin: 0;
    overflow: hidden;
    border: 1px solid #e8eaed;
    border-radius: 8px;
    background: #fff;
}

.result-figure img {
    display: block;
    width: 100%;
    height: auto;
    background: #fff;
}

.result-figure-wide {
    margin-bottom: 22px;
}

.result-figure-after-tables {
    margin-top: 22px;
}

.result-figure figcaption {
    padding: 10px 14px 12px;
    border-top: 1px solid #edf0f2;
    color: #5f6368;
    font-size: 0.9em;
    line-height: 1.45;
}

.result-figure figcaption.result-task-desc {
    color: #4f5b67;
    font-size: 0.95em;
}

.result-group-caption {
    margin-top: 10px;
    color: #5f6368;
    font-size: 0.92em;
    line-height: 1.45;
}

/* Full-screen Image Viewer */
body.lightbox-open {
    overflow: hidden;
}

.image-lightbox {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(8, 12, 22, 0.94);
    color: #fff;
}

.image-lightbox.open {
    display: flex;
}

.image-lightbox-viewport {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 56px;
    overflow: hidden;
    touch-action: none;
}

.image-lightbox-img {
    max-width: 100%;
    max-height: 100%;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 18px 60px rgba(0, 0, 0, 0.35);
    object-fit: contain;
    transform-origin: center center;
    transition: transform 0.12s ease-out;
    user-select: none;
    -webkit-user-drag: none;
    cursor: zoom-in;
}

.image-lightbox-img.is-zoomed {
    cursor: grab;
}

.image-lightbox-img.is-dragging {
    cursor: grabbing;
    transition: none;
}

.image-lightbox-close,
.image-lightbox-control {
    border: 1px solid rgba(255, 255, 255, 0.24);
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
    font-family: inherit;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.image-lightbox-close {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 10002;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    font-size: 1.35rem;
}

.image-lightbox-toolbar {
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 10002;
    display: flex;
    gap: 8px;
}

.image-lightbox-control {
    min-width: 42px;
    height: 42px;
    border-radius: 8px;
    padding: 0 12px;
    font-size: 1rem;
}

.image-lightbox-close:hover,
.image-lightbox-control:hover {
    background: rgba(255, 255, 255, 0.22);
}

/* Visualization */
.visualization-container h2 {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Interactive Examples — single centered 3D viewer + video thumbnails */
.demo-hint {
    text-align: center;
    color: #5f6368;
    font-size: 0.9em;
    margin-bottom: 18px;
}

.demo-ply-panel {
    position: relative;
    width: 100%;
    max-width: 1000px;
    margin: 0 auto;
    border-radius: 16px;
    overflow: hidden;
    background-color: #f8f9fa;
    aspect-ratio: 16 / 9;
    min-height: 380px;
}

.measure-button {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 10;
    height: 42px;
    padding: 0 16px;
    border: none;
    border-radius: 21px;
    background: linear-gradient(135deg, #4285f4 0%, #1a73e8 100%);
    color: #fff;
    box-shadow: 0 3px 12px rgba(26, 115, 232, 0.35);
    cursor: pointer;
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.measure-button .measure-icon { font-size: 17px; line-height: 1; }
.measure-button .measure-label { white-space: nowrap; }

.measure-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 5px 16px rgba(26, 115, 232, 0.5);
}

.measure-button:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.35), 0 3px 12px rgba(26, 115, 232, 0.4);
}

.measure-button.active {
    background: linear-gradient(135deg, #0b5cb8 0%, #0b5cb8 100%);
    box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.28), 0 3px 12px rgba(26, 115, 232, 0.45);
}

/* Brief attention pulse so first-time visitors notice the measure tool.
   Stops on hover or when activated. Runs 3 cycles (~6s) then rests. */
@keyframes measureButtonPulse {
    0%, 100% { box-shadow: 0 3px 12px rgba(26, 115, 232, 0.35), 0 0 0 0 rgba(26, 115, 232, 0.45); }
    50%      { box-shadow: 0 3px 12px rgba(26, 115, 232, 0.35), 0 0 0 10px rgba(26, 115, 232, 0); }
}
.measure-button:not(.active):not(:hover) {
    animation: measureButtonPulse 2.2s ease-out 0.6s 3;
}

.measure-hint {
    display: none;
    text-align: center;
    color: #e67e22;
    font-size: 0.85em;
    padding: 8px 16px;
    background: #fff8f0;
    border: 1px solid #f5cba7;
    border-radius: 6px;
    width: fit-content;
    margin: 0 auto 12px;
}

.measure-hint.visible {
    display: block;
}

#demo-message {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 500;
    font-size: 1em;
    color: #9aa0a6;
    pointer-events: none;
    text-align: center;
    padding: 20px;
}

#demo-canvas {
    display: block;
    width: 100%;
    height: 100%;
    touch-action: none;
    z-index: 1;
}

.samples-row.demo-thumbs {
    --demo-thumb-width: 164px;
    display: grid;
    grid-template-columns: repeat(6, var(--demo-thumb-width));
    gap: 14px;
    justify-content: center;
    align-items: start;
}

.demo-thumb {
    all: unset;
    box-sizing: border-box;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 4px;
    border-radius: 10px;
    border: 3px solid transparent;
    transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
    font-family: inherit;
    width: 100%;
    min-width: 0;
}

.demo-thumb video {
    width: 150px;
    height: 94px;
    object-fit: cover;
    border-radius: 6px;
    display: block;
    background: #000;
}

.samples-row.demo-thumbs .demo-thumb video {
    width: 100%;
}

.demo-thumb span {
    display: block;
    width: 100%;
    font-size: 0.82em;
    color: #5f6368;
    font-weight: 500;
    line-height: 1.2;
    text-align: center;
}

.demo-thumb:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.demo-thumb.selected {
    border-color: #1a73e8;
}

.demo-thumb.selected span {
    color: #1a73e8;
}

@media (max-width: 1194px) {
    .samples-row.demo-thumbs {
        grid-template-columns: repeat(3, var(--demo-thumb-width));
    }
}

@container (max-width: 1054px) {
    .samples-row.demo-thumbs {
        grid-template-columns: repeat(3, var(--demo-thumb-width));
    }
}

@media (max-width: 800px) {
    .samples-row.demo-thumbs {
        --demo-thumb-width: 124px;
    }
    .demo-ply-panel {
        min-height: 280px;
    }
    .demo-thumb video {
        width: 100%;
        height: 68px;
    }
    /* Drop "distance" from the pill so both top-right controls fit
       on phone-width screens without overlapping each other. */
    .measure-button .measure-label { font-size: 13px; }
    .measure-button .measure-label::after { content: ""; }
}

@media (max-width: 450px) {
    .samples-row.demo-thumbs {
        grid-template-columns: repeat(2, minmax(0, var(--demo-thumb-width)));
        gap: 10px;
    }
}

@container (max-width: 400px) {
    .samples-row.demo-thumbs {
        grid-template-columns: repeat(2, minmax(0, var(--demo-thumb-width)));
        gap: 10px;
    }
}

@media (max-width: 520px) {
    .measure-button { padding: 0 12px; gap: 6px; }
    .measure-button .measure-label { display: none; }
    .controls-toggle { right: 64px; }
}

/* ============================================================
   View controls panel — MeshLab-style live tweaks (point size,
   sampling rate, brightness, background, scene rotation, camera).
   Lives as an overlay inside the demo panel so the 3D canvas stays
   interactive even while the user drags sliders.
   ============================================================ */

.controls-toggle {
    position: absolute;
    top: 12px;
    /* Measure button sits at right:12px and is ~172px wide with the
       "Measure distance" label. Leave an 8px gap so the two controls
       sit cleanly side-by-side without overlapping. */
    right: 192px;
    z-index: 10;
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.94);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.controls-toggle:hover {
    background: #fff;
    transform: scale(1.05);
}

.controls-toggle.active {
    background: #1a73e8;
    color: #fff;
}

.demo-controls-panel {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 280px;
    max-width: calc(100% - 24px);
    max-height: calc(100% - 24px);
    z-index: 20;
    background: rgba(255, 255, 255, 0.97);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
    display: none;
    flex-direction: column;
    overflow: hidden;
    font-size: 0.82em;
}

.demo-controls-panel.open {
    display: flex;
}

.controls-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    font-weight: 500;
    color: #202124;
    background: rgba(255, 255, 255, 0.7);
}

.controls-header button {
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 22px;
    line-height: 1;
    color: #5f6368;
    padding: 2px 6px;
    border-radius: 6px;
    transition: background 0.15s;
}

.controls-header button:hover {
    background: rgba(0, 0, 0, 0.06);
    color: #202124;
}

.controls-body {
    padding: 12px 14px 14px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.control-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 500;
    color: #3c4043;
}

.control-value {
    font-family: 'Roboto Mono', monospace;
    font-size: 0.9em;
    color: #5f6368;
    min-width: 46px;
    text-align: right;
}

.control-group input[type=range] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    background: #dadce0;
    border-radius: 2px;
    outline: none;
    margin: 4px 0;
}

.control-group input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #1a73e8;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.control-group input[type=range]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #1a73e8;
    cursor: pointer;
    border: none;
}

.sub-control {
    display: grid;
    grid-template-columns: 60px 1fr 44px;
    align-items: center;
    gap: 8px;
    font-size: 0.92em;
    color: #5f6368;
}

.sub-control input[type=range] {
    width: 100%;
    margin: 2px 0;
}

.bg-swatches {
    display: flex;
    gap: 8px;
}

.bg-swatch {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid rgba(0, 0, 0, 0.12);
    cursor: pointer;
    padding: 0;
    transition: transform 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
}

.bg-swatch:hover {
    transform: scale(1.08);
}

.bg-swatch.selected {
    border-color: #1a73e8;
    box-shadow: 0 0 0 2px rgba(26, 115, 232, 0.25);
}

.control-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    margin-top: 4px;
}

.ctrl-btn {
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid rgba(0, 0, 0, 0.12);
    background: #fff;
    font-size: 0.92em;
    font-family: inherit;
    font-weight: 500;
    color: #3c4043;
    cursor: pointer;
    transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.ctrl-btn:hover {
    background: #f1f3f4;
}

.ctrl-btn-primary {
    grid-column: span 2;
    background: #1a73e8;
    border-color: #1a73e8;
    color: #fff;
}

.ctrl-btn-primary:hover {
    background: #185abc;
}

.ctrl-btn-ghost {
    color: #5f6368;
}

.ctrl-copy-output {
    margin-top: 6px;
    padding: 10px;
    background: #f8f9fa;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 8px;
    font-size: 0.78em;
    font-family: 'Roboto Mono', monospace;
    white-space: pre-wrap;
    word-break: break-word;
    color: #3c4043;
}

@media (max-width: 800px) {
    .demo-controls-panel {
        width: calc(100% - 24px);
    }
    .controls-toggle {
        right: 58px;
    }
}

#canvas {
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    touch-action: none;
    border-radius: 16px;
    z-index: 1;
}

/* Timeline Controls */
#timeline {
    position: absolute;
    bottom: 20px;
    left: 10%;
    width: 80%;
    z-index: 999;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.95);
    padding: 10px 15px;
    border-radius: 25px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.15);
}

#play-pause {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: #1a73e8;
    color: white;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
    flex-shrink: 0;
}

#play-pause:hover {
    background: #185abc;
}

#play-pause span {
    line-height: 1;
}

#frame-slider {
    -webkit-appearance: none;
    appearance: none;
    flex: 1;
    height: 6px;
    background: #ddd;
    border-radius: 3px;
    outline: none;
}

#frame-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #1a73e8;
    cursor: pointer;
    transition: transform 0.1s;
}

#frame-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

#frame-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #1a73e8;
    cursor: pointer;
    border: none;
}

#frame-counter {
    font-size: 0.85em;
    color: #5f6368;
    min-width: 60px;
    text-align: right;
    font-family: 'Roboto Mono', monospace;
}

#info-button {
    background-color: #1a73e8;
    color: white;
    border: none;
    border-radius: 50%;
    width: 26px;
    height: 26px;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    padding: 0;
    line-height: 1;
    flex-shrink: 0;
    font-family: serif;
    font-style: italic;
}

#info-button:hover {
    background-color: #185abc;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

/* Sample Selector */
.sample-selector {
    container-type: inline-size;
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 20px;
    gap: 10px;
    padding: 0 0 15px;
    width: 100%;
    box-sizing: border-box;
}

.sample-buttons {
    display: flex;
    flex-direction: row;
    gap: 10px;
    flex-shrink: 0;
    width: calc(8 * var(--img-size) + 7 * var(--btn-gap));
    max-width: 100%;
}

.sample-type-button {
    height: auto;
    flex: 1;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px 10px;
    border: 3px solid #1a73e8;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.3s, color 0.3s;
    font-size: 0.9em;
    background-color: #1a73e8;
    color: #fff;
    font-weight: 500;
    text-align: center;
    white-space: nowrap;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
    font-family: inherit;
}

.sample-type-button:hover {
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.sample-type-button.selected {
    background-color: #fff;
    color: #1a73e8;
}

.sample-type-button:not(.selected):hover {
    background-color: #185abc;
}

.sample-type-button.selected:hover {
    background-color: #e8f0fe;
}

.samples-row {
    display: flex;
    flex-wrap: wrap;
    gap: var(--btn-gap);
    justify-content: center;
}

.sample-img {
    height: var(--img-size);
    width: var(--img-size);
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    border: 3px solid transparent;
    object-fit: cover;
    box-sizing: border-box;
}

.sample-img:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.sample-img.selected {
    border-color: #1a73e8;
}

/* Video Display */
.video-display {
    background-color: #000;
    border-radius: 16px;
    border: none;
    overflow: hidden;
    position: relative;
    width: 100%;
}

.video-display video {
    width: 100%;
    height: auto;
    max-height: 600px;
    display: block;
    object-fit: contain;
}

.video-thumbs .sample-img {
    width: auto;
    height: var(--img-size);
    aspect-ratio: 16/9;
}

@media (max-width: 600px) {
    .video-display {
        border-radius: 12px;
    }
    
    .video-display video {
        max-height: 300px;
    }
    
    .video-thumbs .sample-img {
        height: var(--img-size-mobile);
        width: auto;
    }
}

/* Hugging Face Demo */
.demo-container {
    margin-bottom: 30px;
}

.demo-container h2 {
    margin-bottom: 10px;
}

.demo-description {
    text-align: center;
    color: #666;
    margin-bottom: 20px;
    font-size: 0.95em;
}

.hf-space-wrapper {
    position: relative;
    width: 100%;
    border-radius: 16px;
    overflow: hidden;
    background: #fff;
    border: 1px solid #e8eaed;
}

.hf-space-wrapper iframe {
    display: block;
    border-radius: 16px;
    position: relative;
    z-index: 2;
}

.demo-link {
    text-align: center;
    margin-top: 15px;
}

.demo-link a {
    color: #ff9d00;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}

.demo-link a:hover {
    color: #e68a00;
    text-decoration: underline;
}

/* Citation */
.citation pre {
    white-space: pre-wrap;
    word-wrap: break-word;
    background-color: #f5f5f5;
    padding: 20px;
    border-radius: 12px;
    overflow-x: auto;
    border: none;
    font-size: 0.9em;
    color: #3c4043;
    font-family: 'Roboto Mono', monospace;
}

/* Collapsible Sections */
.collapsible:hover:not(.active) {
    padding-bottom: 33px;
}

.collapsible h2 {
    cursor: pointer;
    user-select: none;
    position: relative;
    padding-right: 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0;
}

.collapsible.active h2 {
    margin-bottom: 1em;
}

.collapsible h2::after {
    content: '›';
    font-size: 2em;
    font-weight: 500;
    position: absolute;
    right: 0;
    top: 52%;
    transform: translateY(-50%) rotate(0deg);
    line-height: 1;
    transition: transform 0.2s ease-out;
    color: #5f6368;
}

.collapsible.active h2::after {
    transform: translateY(-50%) rotate(90deg);
}

.collapsible .collapsible-content {
    display: none;
}

.collapsible.active .collapsible-content {
    display: block;
}

/* Footer */
footer {
    text-align: center;
    padding: 20px 0 40px;
    color: #5f6368;
    font-size: 0.85em;
}

/* Responsive */
@media (max-width: 600px) {
    body {
        margin: 0 auto 24px;
        padding: max(30px, calc(env(safe-area-inset-top) + 18px)) 12px 24px;
    }
    
    h1 {
        max-width: 24rem;
        margin: 0 auto 18px;
        font-size: clamp(1.55rem, 6.4vw, 1.95rem);
        line-height: 1.12;
    }

    h2 {
        font-size: 1.4em;
    }
    
    .authors {
        margin-bottom: 10px;
        font-size: 0.8rem;
        line-height: 1.45;
    }

    .authors span {
        margin: 0 3px;
    }

    .affiliations {
        margin-bottom: 24px;
        font-size: 0.74rem;
        line-height: 1.45;
    }

    .links {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 8px;
        margin-bottom: 30px;
    }

    .links a {
        width: 100%;
        min-width: 0;
        height: 42px;
        padding: 8px 10px;
        gap: 7px;
        font-size: 0.94rem;
    }

    .links a svg,
    .links a img {
        width: 18px;
        height: 18px;
    }
    
    .abstract, .citation, .visualization-container, .method, .results, .capabilities, .demo-container, .acknowledgements {
        padding: 20px 16px;
        border-radius: 14px;
        margin-bottom: 24px;
    }
    
    .video-container {
        border-radius: 14px;
        margin-bottom: 24px;
    }

    .video-container video {
        aspect-ratio: 16 / 9;
        border-radius: 14px 14px 0 0;
        background: #fff;
        object-fit: contain;
    }

    .video-placeholder {
        border-radius: 12px;
    }
    
    .abstract h2, .citation h2, .visualization-container h2, .method h2, .results h2, .capabilities h2, .demo-container h2, .acknowledgements h2 {
        margin-bottom: 0.8em;
        font-size: 1.45rem;
        line-height: 1.2;
    }

    .chapters {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
        margin-bottom: 0;
        padding: 12px;
    }

    .chapters button {
        min-height: 40px;
        padding: 6px 8px;
        font-size: 0.82rem;
        line-height: 1.2;
    }
    
    .visualization {
        height: 300px;
        border-radius: 12px;
    }
    
    #canvas { border-radius: 12px; }
    
    .abstract p, .method p, .results p, .capabilities p, .acknowledgements p {
        text-align: left;
        font-size: 0.95rem;
        line-height: 1.58;
    }

    .fig-container {
        padding: 0;
        border-radius: 10px;
    }

    .overview-image {
        width: 100%;
        border-radius: 12px;
    }

    .demo-description {
        margin-bottom: 16px;
        font-size: 0.95rem;
        line-height: 1.5;
    }

    .hf-space-wrapper {
        display: none;
    }

    .demo-link {
        margin-top: 0;
    }

    .demo-link a {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 100%;
        min-height: 42px;
        padding: 9px 14px;
        border-radius: 8px;
        background: #1a73e8;
        color: #fff;
        text-decoration: none;
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    }

    .demo-link a:hover {
        background: #185abc;
        color: #fff;
        text-decoration: none;
    }

    .result-table-list {
        gap: 16px;
    }

    .result-table-list .result-figure {
        width: 100%;
    }

    .result-table-list .result-figure-pair {
        width: 100%;
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .result-task-title {
        width: 100%;
        margin: 4px 0 -4px;
        font-size: 1.05rem;
        line-height: 1.25;
    }

    .result-task-desc,
    .result-group-caption {
        font-size: 0.88rem;
        line-height: 1.45;
    }

    .result-figure {
        overflow: hidden;
    }

    .result-figure img,
    .result-figure-wide img {
        width: 100%;
        min-width: 0;
        max-width: 100%;
        height: auto;
    }

    .result-figure figcaption {
        padding: 10px 12px;
        font-size: 0.84rem;
        line-height: 1.42;
    }

    .image-lightbox-viewport {
        padding: 18px;
    }

    .image-lightbox-close {
        top: max(12px, env(safe-area-inset-top));
        right: 12px;
        width: 40px;
        height: 40px;
    }

    .image-lightbox-toolbar {
        right: 12px;
        bottom: max(12px, env(safe-area-inset-bottom));
    }

    .image-lightbox-control {
        min-width: 40px;
        height: 40px;
        padding: 0 10px;
    }
    
    .citation pre {
        padding: 14px;
        border-radius: 10px;
        font-size: 0.72rem;
        line-height: 1.55;
    }
    
    .capabilities-images {
        flex-direction: column;
        gap: 10px;
    }
    
    .capabilities-images img {
        width: 100%;
        height: auto;
        align-self: center;
    }
    
    .sample-selector {
        gap: 6px;
        padding: 0 0 15px;
    }
    
    .sample-buttons {
        gap: var(--btn-gap-mobile);
        width: 100%;
    }
    
    .sample-type-button {
        height: var(--btn-height-mobile);
        font-size: 0.8em;
        padding: 0 8px;
    }
    
    .samples-row {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: var(--btn-gap-mobile);
        justify-content: normal;
    }
    
    .sample-img {
        height: var(--img-size-mobile);
        width: 100%;
        aspect-ratio: 1 / 1;
        border-width: 2px;
    }
}
