/* Shared study flow for phones, iPad portrait and short landscape windows. */
@media(max-width:800px),(max-width:1100px) and (orientation:portrait),(max-width:1100px) and (max-height:600px){
  .explorer{padding:18px max(16px,env(safe-area-inset-left)) max(40px,env(safe-area-inset-bottom)) max(16px,env(safe-area-inset-right))}
  .explorer-intro{margin-bottom:14px}
  .explorer-layout{grid-template-columns:minmax(0,1fr);gap:16px}
  .study-workspace{grid-template-columns:minmax(0,1fr);gap:12px}
  .study-board-column .board-wrap{max-width:680px;margin-inline:auto}
  .study-detail{position:static}
  .study-mobile-bar{display:flex;margin:0 0 12px}
  .study-mobile-bar button,.library-close{min-height:44px;padding:8px 12px;border-radius:9px;font-weight:700}
  .library-close{display:block;position:absolute;top:max(14px,env(safe-area-inset-top));right:14px}
  .library-backdrop:not([hidden]){display:block;position:fixed;inset:0;border:0;background:#000a;z-index:1000}
  #library{position:fixed;inset:0 auto 0 0;z-index:1001;width:min(88vw,420px);height:100dvh;max-height:100dvh;overflow-y:auto;overscroll-behavior:contain;border-radius:0 16px 16px 0;padding:20px max(20px,env(safe-area-inset-right)) max(20px,env(safe-area-inset-bottom)) max(20px,env(safe-area-inset-left));opacity:1;transform:translateX(0);transition:opacity 160ms ease,transform 160ms ease,display 160ms allow-discrete}
  #library[hidden]{opacity:0;transform:translateX(-12px);pointer-events:none}
  .opening-library .library-top{padding-right:48px}
  .opening-library .opening-list{max-height:min(60dvh,650px)}
  body.study-drawer-open{overflow:hidden}
  body.study-drawer-open>.sn-account-link{display:none!important}
  .study-jump,.library-return{display:none!important}
  .study-heading h2{font-size:27px}
  .line-navigation,.lesson-actions{margin:8px 0}
  .filters button{min-height:44px;border-radius:10px}
  @starting-style{#library:not([hidden]){opacity:0;transform:translateX(-12px)}}
}
@media(min-width:801px) and (max-width:1100px) and (orientation:portrait){
  .study-heading{max-width:860px}
  .study-workspace{grid-template-columns:minmax(0,1fr) minmax(225px,285px);gap:18px}
  .study-board-column .board-wrap{max-width:680px}
  .study-detail{padding:14px}
}
@media(max-width:1100px) and (max-height:600px) and (orientation:landscape){
  .explorer-intro{display:none}
  .explorer{padding-top:8px}
  .study-mobile-bar{margin-bottom:8px}
  .study-heading p:not(.eyebrow){display:none}
  .study-heading h2{font-size:23px}
  .study-workspace{grid-template-columns:minmax(160px,1fr) minmax(210px,280px);gap:14px}
  .study-board-column .board-wrap{width:min(100%,calc(100dvh - 190px));min-width:150px;margin-inline:auto}
  .board-tip{display:none}
}
/* Keep the opening board in view instead of stacking four toolbars above it. */
@media(min-width:560px) and (max-width:1100px) and (max-height:600px) and (orientation:landscape){
  .study:has(>.line-navigation){display:grid;grid-template-columns:minmax(0,1fr) minmax(210px,.85fr);gap:8px 16px;align-items:start}
  .study:has(>.line-navigation)>.study-heading{grid-column:2;grid-row:1;align-items:center}
  .study:has(>.line-navigation)>.line-navigation{grid-column:2;grid-row:2;margin:0}
  .study:has(>.line-navigation)>.lesson-actions{grid-column:2;grid-row:3;margin:0}
  .study:has(>.line-navigation)>.study-workspace{display:contents}
  .study:has(>.line-navigation) .study-board-column{grid-column:1;grid-row:1 / 5}
  .study:has(>.line-navigation) .study-detail{grid-column:2;grid-row:4;padding:0}
  .study:has(>.line-navigation) .study-heading h2{font-size:21px;margin:0}
  .study:has(>.line-navigation) .study-heading .eyebrow{margin:0 0 3px;font-size:10px}
  .study:has(>.line-navigation) .study-controls{margin:0 0 8px}
  .study:has(>.line-navigation) .board-wrap{width:min(100%,calc(100dvh - 90px));min-width:0}
  .study:has(>.line-navigation) .mobile-guidance{display:none}
}
@media(prefers-reduced-motion:reduce){#library{transition:none!important}}
