/* Fixed-size viewport + object-fit contain: never let intrinsic canvas height
   establish an overflowing grid row. Applies to every frame thumbnail. */
#presetGrid .preset-thumb,
#mobilePresetRail .mobile-preset-thumb{
  position:relative!important;
  display:block!important;
  min-width:0!important;
  min-height:0!important;
  aspect-ratio:auto!important;
  padding:0!important;
  overflow:hidden!important;
}
#presetGrid .preset-thumb{height:156px!important}
#presetGrid .preset-thumb::before,#presetGrid .preset-thumb::after{display:none!important}
#presetGrid .preset-thumb canvas,
#mobilePresetRail .mobile-preset-thumb canvas{
  position:absolute!important;
  inset:7px!important;
  display:block!important;
  width:calc(100% - 14px)!important;
  height:calc(100% - 14px)!important;
  max-width:none!important;
  max-height:none!important;
  object-fit:contain!important;
  background:transparent!important;
  box-shadow:none!important;
}
#presetGrid .preset>span{align-items:flex-start!important;gap:4px!important}
#presetGrid .preset>span b{
  white-space:normal!important;
  overflow:visible!important;
  font-size:11px!important;
  line-height:1.35!important;
}
#presetGrid .preset>span small{font-size:9px!important}
#presetGrid .preset.active{border-color:#20252c!important;box-shadow:inset 0 0 0 1px #20252c!important}
@media(min-width:901px){
  body.has-media #presetGrid{grid-template-columns:repeat(3,minmax(0,1fr))!important}
}

@media(max-width:900px){
  /* Page scrolling owns the two-column catalogue; only the result stays pinned. */
  body.has-media #mobileFrameStudio .mobile-frame-browser,
  body.has-media.is-media-landscape:not([data-editor-tab='text']) #mobileFrameStudio .mobile-frame-browser{display:none!important}
  body.has-media #mobileFrameStudio,
  body.has-media.is-media-landscape:not([data-editor-tab='text']) #mobileFrameStudio{
    grid-template-columns:minmax(0,1fr)!important;
    grid-template-rows:minmax(0,1fr)!important;
    height:clamp(200px,34svh,310px)!important;
    margin:5px 6px!important;padding:5px!important;gap:0!important;
  }
  body.has-media .editor-panel[data-panel='frame']>.section-heading{display:flex!important}
  body.has-media .editor-panel[data-panel='frame']>#presetGrid{
    display:grid!important;
    grid-template-columns:repeat(2,minmax(0,1fr))!important;
    grid-auto-flow:row!important;
    gap:9px!important;
    overflow:visible!important;
  }
  body.has-media #presetGrid .preset{padding:6px!important;min-height:0!important}
  body.has-media #presetGrid .preset-thumb{height:144px!important}
  body.has-media #presetGrid .preset>span{min-height:30px!important}
  body.has-media #presetGrid .preset-more{min-height:60px!important;grid-column:1/-1}
  body.has-media #presetGrid .preset-more>span{align-items:center!important}
  body.has-media.editor-keyboard-open #mobileFrameStudio{
    height:clamp(110px,calc(var(--editor-visual-height,400px)*.3),170px)!important;
  }
}
@media(min-width:600px) and (max-width:900px){
  body.has-media .editor-panel[data-panel='frame']>#presetGrid{grid-template-columns:repeat(3,minmax(0,1fr))!important}
}
@media(max-width:900px) and (max-height:520px){
  body.has-media #mobileFrameStudio,
  body.has-media.is-media-landscape:not([data-editor-tab='text']) #mobileFrameStudio{
    height:clamp(125px,37svh,185px)!important;
  }
}
