/* Buddy Rooms 0.21.148 · third control-pass corrective over owner-locked B/B/B.
   Scope: apply the selected video-above-panel B geometry to the *room* Chat/Participants panel too,
   keep ordinary B panels non-modal for phone accessibility, remove tablet-only empty top air,
   and preserve the oldest loaded chat-history cursor during background reconcile.
   Inherits 0.21.147 fullscreen precedence/container speech fix and 0.21.144 WAT/tongue arbitration. */

/* The original owner request explicitly covered Chat. 0.21.145 only applied B to workspace tools
   (AI/Support/Transcript), leaving Chat/Participants as a phone bottom sheet / old tablet split.
   A normal open room panel now follows the same narrow contract: full 16:9 stage above, no overlap,
   no resizer spacer, and the panel in normal document flow. Detached/fullscreen/keyboard states keep
   their existing dedicated geometry and therefore are deliberately excluded here. */
@media(max-width:900px){
  html[data-theme][data-buddy-room-view="active"] #roomView.room:not(.panel-closed):not(.panel-detached):not(.panel-fullscreen):not(.workspace-panel-open):not(.keyboard-active) #roomShell{
    display:grid!important;
    grid-template-columns:minmax(0,1fr)!important;
    grid-template-rows:auto auto!important;
    gap:0!important;
    height:max-content!important;
    min-height:0!important;
    max-height:none!important;
    flex:0 0 auto!important;
    align-content:start!important;
    overflow:visible!important;
    resize:none!important;
  }
  html[data-theme][data-buddy-room-view="active"] #roomView.room:not(.panel-closed):not(.panel-detached):not(.panel-fullscreen):not(.workspace-panel-open):not(.keyboard-active) .room-main{
    grid-column:1!important;
    grid-row:1!important;
    width:100%!important;
    max-width:100%!important;
    height:auto!important;
    min-height:0!important;
    aspect-ratio:16/9!important;
    justify-self:center!important;
    align-self:start!important;
    overflow:hidden!important;
  }
  html[data-theme][data-buddy-room-view="active"] #roomView.room:not(.panel-closed):not(.panel-detached):not(.panel-fullscreen):not(.workspace-panel-open):not(.keyboard-active) .video-grid{
    width:100%!important;
    height:100%!important;
    min-height:0!important;
    max-height:none!important;
    padding:0!important;
    overflow:hidden!important;
    align-content:stretch!important;
  }
  html[data-theme][data-buddy-room-view="active"] #roomView.room:not(.panel-closed):not(.panel-detached):not(.panel-fullscreen):not(.workspace-panel-open):not(.keyboard-active) .video-grid:not(.focus-mode){
    grid-auto-rows:minmax(0,1fr)!important;
  }
  html[data-theme][data-buddy-room-view="active"] #roomView.room:not(.panel-closed):not(.panel-detached):not(.panel-fullscreen):not(.workspace-panel-open):not(.keyboard-active) .video-grid>.participant-tile{
    min-height:0!important;
  }
  html[data-theme][data-buddy-room-view="active"] #roomView.room:not(.panel-closed):not(.panel-detached):not(.panel-fullscreen):not(.workspace-panel-open):not(.keyboard-active) .participant-tile video{
    object-fit:contain!important;
    object-position:center center!important;
  }
  html[data-theme][data-buddy-room-view="active"] #roomView.room:not(.panel-closed):not(.panel-detached):not(.panel-fullscreen):not(.workspace-panel-open):not(.keyboard-active) .mobile-panel-resizer{
    display:none!important;
  }
  html[data-theme][data-buddy-room-view="active"] #roomView.room:not(.panel-closed):not(.panel-detached):not(.panel-fullscreen):not(.workspace-panel-open):not(.keyboard-active) #participantPanel{
    display:grid!important;
    position:relative!important;
    z-index:auto!important;
    inset:auto!important;
    top:auto!important;
    right:auto!important;
    bottom:auto!important;
    left:auto!important;
    grid-column:1!important;
    grid-row:2!important;
    width:100%!important;
    height:clamp(480px,72dvh,680px)!important;
    min-width:0!important;
    min-height:480px!important;
    max-width:none!important;
    max-height:none!important;
    margin:0!important;
    transform:none!important;
    visibility:visible!important;
    opacity:1!important;
    pointer-events:auto!important;
    border:1px solid var(--line)!important;
    border-radius:18px!important;
    padding-bottom:0!important;
    box-shadow:var(--edge)!important;
  }
  html[data-theme][data-buddy-room-view="active"] #roomView.room:not(.panel-closed):not(.panel-detached):not(.panel-fullscreen):not(.workspace-panel-open):not(.keyboard-active) #participantPanel::before{
    display:none!important;
  }
}

/* Collapse C needs its 20px hit strip only where the strip actually exists (<=760px).
   On tablet the strip is hidden, so the inherited 20px workspace top padding was just empty air. */
@media(min-width:761px) and (max-width:900px){
  html[data-theme][data-buddy-room-view="active"] #roomView.room.workspace-panel-open:not(.workspace-tool-fullscreen) .workspace-panel-topbar{
    padding:7px 7px 0!important;
  }
}
