/* Brintage R588 / Android V6.350: only EDITOR on narrow displays.
   Fixed bottom bar; responsive 1:1 collage; even horizontal & vertical spacing.
   Initial photo picker, desktop, dialogs and rendering are untouched. */
@media (max-width:768px){
  #key > #createpost.pg.mobile-createpost.cp-brintage-toolbar-v2.cp-editor-step{
    --cp-r588-inline:clamp(9px,2.6vw,15px);
    --cp-r588-gap:clamp(8px,1.15dvh,15px);
    display:flex!important;
    flex-direction:column!important;
    align-items:stretch!important;
    justify-content:space-between!important;
    gap:var(--cp-r588-gap)!important;
    position:absolute!important;
    top:0!important;left:0!important;right:0!important;bottom:auto!important;
    width:100%!important;max-width:100%!important;
    height:100%!important;min-height:0!important;max-height:100%!important;
    padding:clamp(4px,.7dvh,10px) var(--cp-r588-inline) var(--cp-r588-bottom-reserve,105px)!important;
    margin:0!important;
    overflow:hidden!important;
    box-sizing:border-box!important;
    overscroll-behavior:none!important;
  }
  /* Reserve a fourth proportional flex gap before the pinned share/publish area.
     This keeps collage → caption → tabs → tools → footer evenly separated. */
  #key > #createpost.pg.mobile-createpost.cp-brintage-toolbar-v2.cp-editor-step::after{
    content:""!important;
    display:block!important;
    flex:0 0 0px!important;
    height:0!important;
    min-height:0!important;
    order:999!important;
    pointer-events:none!important;
  }
  #key > #createpost.pg.mobile-createpost.cp-editor-step.cp-very-short-viewport::after{
    display:none!important;
  }
  /* Collage is never stretched or clipped to fill the extra vertical space. */
  #key > #createpost.pg.mobile-createpost.cp-editor-step > .cp-middle{
    flex:0 0 var(--cp-mobile-collage-side,min(calc(100vw - 20px),43dvh))!important;
    width:var(--cp-mobile-collage-side,min(calc(100vw - 20px),43dvh))!important;
    height:var(--cp-mobile-collage-side,min(calc(100vw - 20px),43dvh))!important;
    max-width:100%!important;
    aspect-ratio:1/1!important;
    margin:0!important;
    align-self:center!important;
  }
  #key > #createpost.pg.mobile-createpost.cp-editor-step > .cp-pos.cp-caption-pos{
    align-self:stretch!important;
    width:100%!important;max-width:100%!important;
    margin:0!important;
    flex:0 0 var(--cp-mobile-caption-height,50px)!important;
  }
  /* Both rows keep the same side inset and proportional gaps.
     Original button/active/disabled styles and event handlers are preserved. */
  #key > #createpost.pg.mobile-createpost.cp-brintage-toolbar-v2.cp-editor-step > .cp-mobile-design-launcher{
    width:100%!important;max-width:100%!important;
    margin:0!important;
    padding:0 clamp(3px,1.2vw,8px)!important;
    gap:clamp(6px,1.45vw,10px)!important;
    box-sizing:border-box!important;
    align-self:stretch!important;
    flex:0 0 var(--cp-mobile-tab-height,42px)!important;
    height:var(--cp-mobile-tab-height,42px)!important;
  }
  #key > #createpost.pg.mobile-createpost.cp-brintage-toolbar-v2.cp-editor-step > .cp-collage-tabs{
    width:100%!important;max-width:100%!important;
    margin:0!important;
    padding:0 clamp(3px,1.2vw,8px)!important;
    box-sizing:border-box!important;
    align-self:stretch!important;
    flex:0 0 var(--cp-mobile-tools-height,55px)!important;
    height:var(--cp-mobile-tools-height,55px)!important;
  }
  #key > #createpost.pg.mobile-createpost.cp-brintage-toolbar-v2.cp-editor-step > .cp-collage-tabs > .cp-collage-tools{
    display:grid!important;
    grid-template-columns:repeat(5,minmax(0,1fr))!important;
    width:100%!important;
    height:100%!important;
    min-width:0!important;
    min-height:0!important;
    margin:0!important;
    padding:0!important;
    gap:clamp(6px,1.45vw,10px)!important;
    box-sizing:border-box!important;
  }
  #key > #createpost.pg.mobile-createpost.cp-brintage-toolbar-v2.cp-editor-step > .cp-collage-tabs .cp-collage-tools > button{
    min-width:0!important;
    width:100%!important;
    max-width:100%!important;
    height:100%!important;
    min-height:0!important;
    margin:0!important;
    box-sizing:border-box!important;
  }
  /* The bottom group aligns with the safe viewport edge, like 'Siguiente'. */
  #key > #createpost.pg.mobile-createpost.cp-editor-step > .mobile-cpb.pB.cp-bottom{
    position:fixed!important;
    top:auto!important;bottom:max(5px,env(safe-area-inset-bottom,0px))!important;
    left:var(--cp-r588-inline,10px)!important;
    right:var(--cp-r588-inline,10px)!important;
    width:auto!important;max-width:none!important;
    height:auto!important;min-height:0!important;
    display:flex!important;flex-direction:column!important;
    gap:clamp(7px,1.1dvh,12px)!important;
    margin:0!important;
    padding:0!important;
    z-index:8!important;
    background:transparent!important;border:0!important;box-shadow:none!important;
    transform:none!important;
  }
  #key > #createpost.pg.mobile-createpost.cp-editor-step > .mobile-cpb.pB.cp-bottom > .cp-cross-share{
    margin:0!important;
    flex:0 0 auto!important;
    width:100%!important;
  }
  #key > #createpost.pg.mobile-createpost.cp-editor-step > .mobile-cpb.pB.cp-bottom > .publish-submit{
    flex:0 0 var(--cp-mobile-publish-height,47px)!important;
    width:100%!important;
    height:var(--cp-mobile-publish-height,47px)!important;
    min-height:0!important;
    margin:0!important;
  }
  /* Allow a temporary internal scroll on landscape or when the keyboard is up. */
  #key > #createpost.pg.mobile-createpost.cp-editor-step.cp-very-short-viewport{
    justify-content:flex-start!important;
    overflow-y:auto!important;
    overscroll-behavior-y:contain!important;
    padding-bottom:calc(var(--cp-r588-bottom-reserve,105px) + 10px)!important;
  }
}
