/* Overlay placement and stable layout; no content clipping in comparisons. */
html{scrollbar-gutter:stable both-edges;overflow-anchor:none}
html:has(dialog[open]){overflow:hidden}
.teaser-grid{aspect-ratio:13/10;grid-template-rows:repeat(4,minmax(0,1fr))}
.teaser-grid>.media-card:nth-child(n){min-height:0;height:100%;aspect-ratio:auto}
/* Top teaser remains clean even during script initialization. Gallery prompts stay. */
#teaser>.teaser-grid>.media-card>figcaption{display:none}
.teaser-grid .media-card>.teaser-caption{left:12px;right:12px;bottom:12px;top:auto;margin:0;padding:12px 14px;max-height:calc(100% - 24px);overflow:auto;border-radius:6px;background:#102135e8;text-align:left;font-size:13px;line-height:1.45;z-index:4;pointer-events:none;visibility:hidden;opacity:0}
.teaser-grid .media-card.has-video>.teaser-caption{bottom:58px;max-height:calc(100% - 72px)}
.teaser-grid .media-card:hover>.teaser-caption,.teaser-grid .media-card:focus-within>.teaser-caption{visibility:visible;opacity:1;pointer-events:auto}
.teaser-caption strong{display:block;font-size:12px;letter-spacing:.2px;font-weight:600;color:#cfe4ff}
.teaser-prompt-origin{display:inline;margin-left:8px;font-size:10px;font-weight:400;letter-spacing:.02em;color:#b9ccdc}
.teaser-caption[data-prompt-provenance="reconstructed"] strong,.teaser-caption[data-prompt-provenance="visual-description"] strong{display:inline}
.teaser-caption,.teaser-prompt{overscroll-behavior:contain}
.teaser-prompt{margin-top:5px;max-height:96px;overflow:auto;white-space:normal;font-size:13px;line-height:1.45;color:#fff}
.overlay-disclosure{position:relative;overflow:visible}
.overlay-disclosure[open]{z-index:25}
.overlay-disclosure>.disclosure-panel{position:absolute;top:100%;left:0;z-index:25;width:min(760px,100%);max-height:min(55vh,480px);overflow:auto;overscroll-behavior:contain;padding:16px 18px;border:1px solid var(--border);border-radius:8px;background:var(--surface);box-shadow:0 8px 28px #10213526}
.overlay-disclosure.opens-up>.disclosure-panel{top:auto;bottom:100%}
.overlay-disclosure.turntable-details>.disclosure-panel,.overlay-disclosure.extra-gallery>.disclosure-panel{width:100%;max-height:70vh}
.overlay-disclosure>.disclosure-panel pre{max-height:none;margin:0;padding:0}
.overlay-disclosure>.disclosure-panel>*:first-child{margin-top:0}
.diversity-row .image-button{aspect-ratio:4/5}
#edit-results .media-card>.image-button,.cross-grid .image-button{aspect-ratio:1}
.diversity-row .image-button img,#edit-results .media-card>.image-button img,.cross-grid .image-button img{width:100%;height:100%;object-fit:contain;background:transparent}
.shape-input>.image-button{height:350px}.shape-input>.image-button img{height:100%;object-fit:contain}
.viewer-toolbar>span{min-height:3em}
.wan-header{min-height:3em}
#wan-results .wan-row .video-wrap{height:clamp(190px,22vw,360px)}
#wan-results .wan-row video{height:100%;width:100%;aspect-ratio:auto;object-fit:contain}
dialog#image-dialog{position:fixed;inset:0;margin:auto;height:min(94vh,1100px);overflow:auto}
#dialog-image{height:76vh;width:100%;max-height:76vh;object-fit:contain}
.dialog-toolbar{min-height:42px}
@media(max-width:1024px){
.teaser-grid{aspect-ratio:26/45;grid-template-rows:2fr 1fr 1fr 2fr}
#wan-results .wan-row .video-wrap{height:clamp(170px,25vw,280px)}
}
@media(max-width:640px){
.teaser-grid{aspect-ratio:13/45;grid-template-rows:repeat(6,minmax(0,1fr))}
.teaser-grid .media-card>.teaser-caption{left:8px;right:8px;bottom:8px;padding:8px 10px}
.teaser-grid .media-card.has-video>.teaser-caption{bottom:54px;max-height:calc(100% - 66px)}
.teaser-prompt{max-height:70px;font-size:12px}
#wan-results .wan-row .video-wrap{height:190px}
.overlay-disclosure>.disclosure-panel{max-height:50vh;padding:12px}
}

/* Keep the original diagonal six-tile composition in desktop side-panel widths.
   Only phone widths use the stacked layout; no media or gallery order changes. */
@media(min-width:641px){
  .teaser-grid{grid-template-columns:repeat(3,minmax(0,1fr));grid-template-rows:repeat(4,minmax(0,1fr));aspect-ratio:13/10}
  .teaser-grid>.media-card:nth-child(1){grid-area:1 / 1 / 3 / 3}
  .teaser-grid>.media-card:nth-child(2){grid-area:1 / 3 / 2 / 4}
  .teaser-grid>.media-card:nth-child(3){grid-area:2 / 3 / 3 / 4}
  .teaser-grid>.media-card:nth-child(4){grid-area:3 / 1 / 4 / 2}
  .teaser-grid>.media-card:nth-child(5){grid-area:4 / 1 / 5 / 2}
  .teaser-grid>.media-card:nth-child(6){grid-area:3 / 2 / 5 / 4}
}

/* Three staggered leads. All six image, Wan and 3D companions are small tiles. */
@media(min-width:641px){
  .teaser-grid.teaser-curated{grid-template-columns:repeat(6,minmax(0,1fr));grid-template-rows:repeat(6,minmax(0,1fr));aspect-ratio:13/15}
  .teaser-grid.teaser-curated>.media-card:nth-child(1){grid-area:1 / 1 / 3 / 5}
  .teaser-grid.teaser-curated>.media-card:nth-child(2){grid-area:1 / 5 / 2 / 7}
  .teaser-grid.teaser-curated>.media-card:nth-child(3){grid-area:2 / 5 / 3 / 7}
  .teaser-grid.teaser-curated>.media-card:nth-child(4){grid-area:3 / 1 / 4 / 3}
  .teaser-grid.teaser-curated>.media-card:nth-child(5){grid-area:4 / 1 / 5 / 3}
  .teaser-grid.teaser-curated>.media-card:nth-child(6){grid-area:3 / 3 / 5 / 7}
  .teaser-grid.teaser-curated>.media-card:nth-child(7){grid-area:5 / 1 / 7 / 5}
  .teaser-grid.teaser-curated>.media-card:nth-child(8){grid-area:5 / 5 / 6 / 7}
  .teaser-grid.teaser-curated>.media-card:nth-child(9){grid-area:6 / 5 / 7 / 7}
}
.teaser-grid.teaser-curated>.media-card{box-shadow:0 1px 3px #263d5010}
/* Keep the small boat in the landscape image inside the shallow teaser crop. */
.teaser-grid.teaser-curated>.media-card:nth-child(8) .image-button img{object-position:center 72%}
.teaser-grid>.teaser-3d video{object-fit:contain;background:#c6cdd4}
@media(max-width:640px){
  .teaser-grid.teaser-curated{grid-template-columns:repeat(2,minmax(0,1fr));grid-template-rows:none;grid-auto-rows:auto;aspect-ratio:auto}
  .teaser-grid.teaser-curated>.media-card:nth-child(n){grid-area:auto;grid-column:1 / -1;height:auto;aspect-ratio:16/9}
  .teaser-grid.teaser-curated>.media-card:nth-child(1){grid-area:1 / 1 / 2 / 3}
  .teaser-grid.teaser-curated>.media-card:nth-child(2){grid-area:2 / 1 / 3 / 2}
  .teaser-grid.teaser-curated>.media-card:nth-child(3){grid-area:2 / 2 / 3 / 3}
  .teaser-grid.teaser-curated>.media-card:nth-child(4){grid-area:3 / 1 / 4 / 2}
  .teaser-grid.teaser-curated>.media-card:nth-child(5){grid-area:3 / 2 / 4 / 3}
  .teaser-grid.teaser-curated>.media-card:nth-child(6){grid-area:4 / 1 / 5 / 3}
  .teaser-grid.teaser-curated>.media-card:nth-child(7){grid-area:5 / 1 / 6 / 3}
  .teaser-grid.teaser-curated>.media-card:nth-child(8){grid-area:6 / 1 / 7 / 2}
  .teaser-grid.teaser-curated>.media-card:nth-child(9){grid-area:6 / 2 / 7 / 3}
}

/* Results share the teaser's full main-column width at every breakpoint. */
#explore,#editing,#shape,#video,#audio,#transfer,#multi-teacher{
  width:100%;max-width:none;margin:76px auto 0;
}
#explore>.section,#shape>.section,#audio>.section{margin:0}
#multi-teacher h2{margin:0 0 14px}
#multi-teacher .multi-metrics{max-width:100%;margin:24px auto 32px}
#multi-teacher .image-button{margin-top:0}
#multi-teacher h2{font-size:clamp(22px,2.4vw,36px);line-height:1.25;text-align:center}
.carousel-stage{grid-template-columns:44px minmax(0,1fr) 44px;gap:12px}
.carousel-footer{margin-left:56px;margin-right:56px}
.carousel-arrow{font-size:28px}
.seed-heading,.diversity-row{grid-template-columns:120px repeat(4,minmax(0,1fr))}
.wan-header,.wan-row{grid-template-columns:110px repeat(3,minmax(0,1fr))}
.seed-heading,.wan-header{font-size:16px}
.row-label,.wan-row .row-label{font-size:16px;padding:0 6px}
.row-label small{font-size:14px}
#wan-results .wan-row .video-wrap{height:auto;aspect-ratio:4/3}
#av-results>.video-group{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:20px}
#av-results>.video-group>.media-card{display:flex;flex-direction:column-reverse;gap:10px}
#av-results>.video-group figcaption{margin:0;text-align:center;font-size:17px}
.cross-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:16px}
.cross-grid>div{display:grid;grid-template-columns:minmax(0,1fr);gap:12px}
.cross-grid h4{margin:0;min-height:48px;display:flex;align-items:center;justify-content:center;font-size:16px}
@media(max-width:1024px){
  #explore,#editing,#shape,#video,#audio,#transfer,#multi-teacher{width:100%;margin:60px auto 0}
  .carousel-stage{grid-template-columns:1fr 1fr}
  .carousel-footer{margin-left:0;margin-right:0}
  .diversity-row{grid-template-columns:repeat(2,minmax(0,1fr))}
  .row-label,.wan-row .row-label{padding:10px 0 4px}
  .wan-row{grid-template-columns:repeat(3,minmax(0,1fr))}
  .cross-grid{grid-template-columns:repeat(2,minmax(0,1fr));gap:24px}
  .cross-grid>div{grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}
  .cross-grid h4{grid-column:1/-1;min-height:24px}
}
@media(max-width:640px){
  #av-results>.video-group{grid-template-columns:1fr;gap:22px}
  .cross-grid{grid-template-columns:1fr}
  #explore,#editing,#shape,#video,#audio,#transfer,#multi-teacher{margin-top:48px}
  #multi-teacher .multi-metrics{margin-top:20px}
}
/* Compact reader view: natural image proportions, close rows, no curation UI. */
.section-heading .caption,#multi-teacher>.caption,#multi-teacher>div>.caption{
  max-width:1000px;font-size:16px;line-height:1.55;text-align:center;margin:16px auto 0;
}
.section-heading{margin-bottom:18px}
.case-carousel{margin:20px 0 0}
.carousel-stage{gap:8px;grid-template-columns:36px minmax(0,1fr) 36px}
.carousel-arrow{border-radius:6px;font-size:28px}
.carousel-arrow:hover{transform:none;box-shadow:none}
.carousel-footer{display:block;margin:12px 44px 0;text-align:center}
.case-page{font-size:16px;font-weight:400}.case-page strong{font-size:22px}
.diversity-row{grid-template-columns:92px repeat(4,minmax(0,1fr));gap:6px;margin-bottom:6px}
.diversity-row .image-button,#edit-results .media-card>.image-button{aspect-ratio:auto}
.diversity-row .image-button img,#edit-results .media-card>.image-button img{height:auto;width:100%;object-fit:contain}
.three-col,.two-col{gap:6px}
#edit-results .media-card{gap:4px}
.media-card figcaption{font-size:16px;margin:4px 0}
.row-label,.wan-row .row-label{font-size:15px}
.row-label small{font-size:13px}
.wan-row{grid-template-columns:92px repeat(3,minmax(0,1fr));gap:6px;margin-bottom:6px}
#wan-results .wan-row .video-wrap{height:auto;aspect-ratio:var(--wan-ratio,832/480)}
#wan-results .wan-row video{height:100%;object-fit:contain}
.wan-row .media-card figcaption{display:none}
#av-results>.video-group{gap:6px}
#av-results>.video-group>.media-card{gap:4px}
#av-results>.video-group figcaption{font-size:16px}
.cross-grid{gap:8px}.cross-grid>div{gap:6px}
.cross-grid h4{font-size:15px;min-height:36px}
.reader-prompts{margin-top:12px}
.inline-prompt{margin:0;color:var(--muted);font-size:14px;line-height:1.5;font-style:italic;white-space:pre-wrap;overflow-wrap:anywhere}
.reader-prompts-wan{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:6px;margin-left:98px}
.prompt-long{margin:0}
.prompt-long summary{font-size:14px}
.reader-prompts-wan .prompt-long>.disclosure-panel{width:min(650px,75vw);left:auto;right:0}
.reader-prompts-wan .prompt-long:first-child>.disclosure-panel{left:0;right:auto}
.playback-tools,.sync-button{margin-top:10px}
@media(max-width:1024px){
  .carousel-stage{grid-template-columns:1fr 1fr}
  .carousel-footer{margin-left:0;margin-right:0}
  .diversity-row{grid-template-columns:repeat(2,minmax(0,1fr))}
  .diversity-row .image-button:after{content:none}
  .wan-row{grid-template-columns:repeat(3,minmax(0,1fr))}
  .wan-row .row-label{padding:4px 0}
  .reader-prompts-wan{margin-left:0}
}
@media(max-width:640px){
  .section-heading .caption,#multi-teacher>div>.caption{font-size:14px;text-align:left}
  .inline-prompt{font-size:13px}
  .reader-prompts-wan{grid-template-columns:1fr;gap:12px}
  #av-results>.video-group{gap:12px}
}
/* One selected prompt per page; portrait outputs stay paired and compact. */
#wan-results>.wan-portrait{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:14px}
.wan-sample-pair{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:6px}
.wan-sample-pair .media-card{display:flex;flex-direction:column-reverse;justify-content:flex-end}
.wan-sample-pair video{aspect-ratio:480/832;max-height:320px;object-fit:contain}
.wan-sample-pair figcaption{font-size:13px;margin:0 0 6px;text-align:center}
@media(max-width:750px){#wan-results>.wan-portrait{grid-template-columns:repeat(3,250px);overflow-x:auto;padding-bottom:8px}}
/* Reserved geometry remains visible while nearby media are fetched. */
.image-button img[data-src]{background:var(--surface-alt)}
.video-wrap.is-loading:after{content:"";position:absolute;right:12px;top:12px;width:18px;height:18px;border:2px solid #ffffff70;border-top-color:#fff;border-radius:50%;animation:media-loading .8s linear infinite;pointer-events:none}
@keyframes media-loading{to{transform:rotate(360deg)}}
@media(prefers-reduced-motion:reduce){.video-wrap.is-loading:after{animation:none}}

/* Reserve exact geometry before decoding and crossfade over a tiny preview. */
.progressive-image{position:relative;isolation:isolate;overflow:hidden;background:var(--surface-alt)}
.progressive-image::before{content:"";position:absolute;inset:0;background-image:var(--preview);background-size:contain;background-repeat:no-repeat;background-position:center;filter:blur(7px);transform:scale(1.03);opacity:1;transition:opacity .22s}
.progressive-image>img{position:absolute;inset:0;width:100%!important;height:100%!important;opacity:0;transition:opacity .22s}
.progressive-image.is-ready>img{opacity:1}
.progressive-image.is-ready::before{opacity:0}
.image-loading-dots{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;gap:6px;pointer-events:none;z-index:2}
.image-loading-dots i{display:block;width:7px;height:7px;border-radius:50%;background:white;box-shadow:0 1px 5px #142f5360}
.progressive-image.is-fetching .image-loading-dots i{animation:image-dot-bounce .9s ease-in-out infinite}
.image-loading-dots i:nth-child(2){animation-delay:.15s!important}
.image-loading-dots i:nth-child(3){animation-delay:.3s!important}
.progressive-image.is-ready .image-loading-dots,.progressive-image.has-error .image-loading-dots{display:none}
.image-load-error{display:none;position:absolute;inset:auto 8px 8px;padding:6px;background:#edf3fae8;font-size:12px}
.progressive-image.has-error .image-load-error{display:block}
.teaser-grid .progressive-image::before{background-size:cover}
@keyframes image-dot-bounce{0%,60%,100%{transform:translateY(0);opacity:.6}30%{transform:translateY(-6px);opacity:1}}
@media(prefers-reduced-motion:reduce){.progressive-image>img,.progressive-image::before{transition:none}.progressive-image.is-fetching .image-loading-dots i{animation:none}}

/* Two media ribbons, independent of the reading column and the result overviews. */
#teaser{width:calc(100vw - 48px);max-width:none;margin-left:calc(50% - (100vw - 48px)/2);margin-top:30px}
.teaser-wall{--rail-height:clamp(190px,19vw,280px);display:grid;gap:14px}
.teaser-rail{display:flex;align-items:center;gap:14px;height:var(--rail-height);overflow-x:auto;overflow-y:hidden;overscroll-behavior-x:contain;scrollbar-width:none;cursor:grab;padding:0;min-width:0;touch-action:pan-x pan-y pinch-zoom;scroll-behavior:auto;overflow-anchor:none}
.teaser-rail::-webkit-scrollbar{display:none}
.teaser-rail:focus-visible{outline:2px solid var(--accent);outline-offset:4px}
.teaser-rail.is-dragging{cursor:grabbing;user-select:none}
.teaser-item{height:100%;aspect-ratio:var(--tile-ratio);flex:0 0 auto;min-width:0;border-radius:8px;overflow:hidden;background:var(--surface-alt)}
.teaser-item.teaser-object{background:#c6cdd4}
.teaser-item .media-card{margin:0;width:100%;height:100%;border:0;box-shadow:none;background:transparent}
.teaser-item .video-wrap,.teaser-item .image-button{display:block;width:100%;height:100%;aspect-ratio:auto!important;border-radius:0}
.teaser-item img,.teaser-item video{display:block;width:100%;height:100%;object-fit:contain;max-height:none;pointer-events:none}
.teaser-item .image-button{cursor:inherit}
.teaser-item .image-button img{object-fit:contain}
.teaser-item .video-start,.teaser-item figcaption{display:none!important}
.teaser-item .media-error{font-size:12px}
.teaser-tools{max-width:1320px;margin:14px auto 0;padding:0 12px;display:flex;align-items:center;justify-content:space-between;gap:16px;color:var(--muted);font:13px/1.4 -apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif}
.teaser-actions{display:flex;align-items:center;gap:9px}
.teaser-motion{min-height:44px;background:none;border:0;padding:8px 14px;color:inherit;font:inherit;white-space:nowrap}
.teaser-motion:hover{text-decoration:underline;text-underline-offset:4px}
.teaser-browse{width:44px;height:44px;border:1px solid var(--border);border-radius:50%;background:transparent;color:var(--ink);font:26px/1 Arial,sans-serif;display:grid;place-items:center;padding:0}
.teaser-browse:hover:not(:disabled){background:#fff9}
.teaser-browse:disabled{opacity:.3}
.editorial-preview #abstract{max-width:850px;margin:38px auto 0;padding:0 12px}
.editorial-preview #abstract p{font:400 clamp(17px,1.45vw,20px)/1.75 Georgia,'Times New Roman',serif;text-align:left;margin-bottom:12px;color:var(--ink)}
.editorial-preview #abstract p:last-child{font-size:clamp(15px,1.25vw,17px);color:var(--muted);margin-bottom:0}
@media(min-width:1700px){.teaser-wall{--rail-height:310px}}
@media(max-width:760px){
 #teaser{width:calc(100vw - 32px);margin-left:calc(50% - (100vw - 32px)/2);margin-top:20px}
 .teaser-wall{--rail-height:clamp(152px,28vw,200px);gap:10px}
 .teaser-rail{gap:10px}
 .teaser-item{border-radius:6px}.teaser-tools{gap:8px;padding:0;margin-top:8px;font-size:11px}
 .teaser-actions{gap:6px}.teaser-motion{padding:8px}.teaser-hint{max-width:100px}
 .editorial-preview #abstract{margin-top:28px;padding:0}.editorial-preview #abstract p{font-size:17px;line-height:1.7}
 .editorial-preview #abstract p:last-child{font-size:15px}
}
