/* Reading safety only: preserve scene geometry, authored motion and desktop widths. */
#reader #reader-surface{display:flex;flex-direction:column;min-height:0;min-width:0}
#reader .reader-toolbar{flex-shrink:0;gap:8px 16px;flex-wrap:wrap}
#reader #reader-scroll{flex:1;min-height:0;min-width:0;height:auto}
/* Data/campaign use their existing absolute toolbar and local reading scrollers. */
#reader:is([data-module="data"],[data-module="campaign"]) #reader-scroll{height:100%}
#reader-scroll :is(img,video){max-width:100%}
#reader :is(.resume-content,.ai-workflow-content,.school-library){overflow-wrap:anywhere}
#reader :is(pre,.table-wrap){max-width:100%;overflow-x:auto}
#reader .ai-workflow-content :is(.workspace,.workspace>*,.star>*,.report-items>*){min-width:0}
/* Do not allow a viewport-minus-toolbar formula to produce a zero-height video. */
#reader .ai-course-video{height:auto;max-height:min(65dvh,740px);max-width:100%;object-fit:contain}

@media(max-height:620px){
  /* Navigation artwork may scroll on short screens; the global toolbar stays outside. */
  #reader:is([data-view="ai-gallery"],[data-view="personal-gallery"]) #reader-scroll{overflow:auto}
  #reader:is([data-view="ai-gallery"],[data-view="personal-gallery"]) #module-slot,
  #reader:is([data-view="ai-gallery"],[data-view="personal-gallery"]) #module-slot>div{height:auto;min-height:100%}
  #reader[data-view="ai-gallery"] .ai-gallery,
  #reader[data-view="personal-gallery"] .personal-gallery{height:560px;min-height:560px}
  /* Fit both book choices in the available height; keep the existing cart center. */
  #reader[data-module="campaign"] .cb-book{width:min(240px,26vw,calc((100dvh - 150px)*.7))}
  #reader[data-module="data"] .data-analysis-index{top:0;bottom:0;overflow-y:auto;align-content:start}
  #reader[data-module="data"] .data-board-directory{width:min(940px,calc(100vw - 36px));max-height:calc(100dvh - 100px)}
  #reader[data-module="data"] .data-board-directory:not(:has([data-phase="extracting"],[data-phase="returning"])){overflow-y:auto}
}
