/* Omni UI correction: streaming preview stays in the upper media lane,
   with speaking-friend portraits underneath. This stylesheet is last
   intentionally because earlier versions centered previews absolutely. */

/* Put all video cards before the participant photos, irrespective of DOM
   insertion order. Keep the same WebRTC elements; only layout is changed. */
#appShell:not(.nexo-video-fullscreen)
 #voiceStage:not([hidden]) #remoteMedia.remote-media.has-video
 > .remote-tile:is(.is-stream-preview,.is-stream-pending,
                   .is-stream-primary,.is-stream-secondary,.is-stream-equal){
  order:0 !important;
}
#appShell:not(.nexo-video-fullscreen)
 #voiceStage:not([hidden]) #remoteMedia.remote-media.has-video
 > .remote-tile.is-voice-participant:not(.has-video){
  order:20 !important;
  position:relative !important;
  z-index:1;
}

/* The full-width flex row break is drawn after streams and before photos.
   Without it, a video whose width fits beside a 118px avatar ends up on
   the same line, and a former absolute preview can cover people's faces. */
#appShell:not(.nexo-video-fullscreen)
 #voiceStage:not([hidden]) #remoteMedia.remote-media.has-video:has(> .remote-tile.is-voice-participant:not(.has-video))::before{
  content:"" !important;
  display:block !important;
  position:relative !important;
  flex:0 0 100% !important;
  order:10 !important;
  box-sizing:border-box !important;
  width:100% !important;
  height:0 !important;
  min-height:0 !important;
  max-height:0 !important;
  margin:0 !important;
  padding:0 !important;
  border:0 !important;
  visibility:hidden;
  pointer-events:none;
}

/* Unwatched streams: never use absolute top:50% placement. Center the
   video thumbnail as its own row ABOVE, never on top of, friend portraits. */
#appShell:not(.nexo-video-fullscreen)
 #voiceStage:not([hidden]) #remoteMedia.remote-media.has-video[data-watched-count="0"] {
  display:flex !important;
  flex-wrap:wrap !important;
  flex-direction:row !important;
  justify-content:center !important;
  align-content:center !important;
  align-items:center !important;
  gap:clamp(6px,1.2vh,11px) !important;
  padding:clamp(5px,.9vh,9px) clamp(6px,1vw,12px) !important;
}
#appShell:not(.nexo-video-fullscreen)
 #voiceStage:not([hidden]) #remoteMedia.remote-media.has-video[data-watched-count="0"][data-preview-count="1"]{
  align-content:center !important;
  padding-bottom:clamp(6px,1.2vh,11px) !important;
}
#appShell:not(.nexo-video-fullscreen)
 #voiceStage:not([hidden]) #remoteMedia.remote-media.has-video[data-watched-count="0"]
 > .remote-tile.is-stream-preview {
  position:relative !important;
  left:auto !important;
  top:auto !important;
  right:auto !important;
  bottom:auto !important;
  inset:auto !important;
  transform:none !important;
  order:0 !important;
  flex:0 0 min(240px,65%) !important;
  box-sizing:border-box !important;
  width:min(240px,65%) !important;
  max-width:100% !important;
  height:var(--nexo-preview-fit-height,112px) !important;
  min-height:0 !important;
  max-height:var(--nexo-preview-fit-height,112px) !important;
  margin:0 !important;
  align-self:center !important;
  z-index:2;
}
#appShell:not(.nexo-video-fullscreen)
 #voiceStage:not([hidden]) #remoteMedia.remote-media.has-video[data-watched-count="0"]
 > .remote-tile.is-stream-pending {
  order:0 !important;
  position:relative !important;
  min-height:0 !important;
  height:var(--nexo-preview-fit-height,112px) !important;
  max-height:var(--nexo-preview-fit-height,112px) !important;
  margin:0 !important;
}
/* Do not reserve a phantom spacer if the room contains no voice photos. */
#appShell:not(.nexo-video-fullscreen)
 #voiceStage:not([hidden]) #remoteMedia.remote-media.has-video:not(:has(> .remote-tile.is-voice-participant:not(.has-video)))::before{
  display:none !important;content:none !important;
}
/* Watching a stream: keep the player's natural aspect, but give the
   friend thumbnails their own row underneath instead of beside the video. */
#appShell:not(.nexo-video-fullscreen)
 #voiceStage:not([hidden]) #remoteMedia.remote-media.has-video[data-watched-count="1"]
 > .remote-tile.is-stream-watching{
  order:0 !important;
}
#appShell:not(.nexo-video-fullscreen)
 #voiceStage:not([hidden]) #remoteMedia.remote-media.has-video
 > .remote-tile.is-voice-participant:not(.has-video){
  flex-shrink:0 !important;
}

/* Channel selection: use the same understated graphite/green glass for
   text and voice channels. The previous selected state appeared too pale. */
html:not([data-nexo-theme="light"])
 #appShell .channel-sidebar :is(#textChannelItems,#voiceChannelItems)
 .channel-entry > :is(.channel-button,.voice-channel).active{
  color:#e3eae6 !important;
  background:linear-gradient(90deg,
      rgba(95,128,110,.18),rgba(53,65,63,.13) 62%,rgba(33,39,40,.08)) !important;
  border-color:rgba(146,175,160,.20) !important;
  box-shadow:inset 2px 0 0 rgba(129,185,150,.66),
             inset 0 0 0 1px rgba(227,246,237,.065) !important;
  text-shadow:none !important;
}
html:not([data-nexo-theme="light"])
 #appShell .channel-sidebar :is(#textChannelItems,#voiceChannelItems)
 .channel-entry.nexo-colored-channel > :is(.channel-button,.voice-channel).active {
  border-left-color:var(--nexo-channel-accent,rgba(129,185,150,.66)) !important;
  box-shadow:inset 2px 0 0 var(--nexo-channel-accent,rgba(129,185,150,.66)),
             inset 0 0 0 1px rgba(227,246,237,.07) !important;
}
html:not([data-nexo-theme="light"])
 #appShell .channel-sidebar :is(#textChannelItems,#voiceChannelItems)
 .channel-entry > :is(.channel-button,.voice-channel):hover:not(.active){
  background:rgba(255,255,255,.045) !important;
}
/* Preserve readable text and low glare when the user selects light theme. */
html[data-nexo-theme="light"]
 #appShell .channel-sidebar :is(#textChannelItems,#voiceChannelItems)
 .channel-entry > :is(.channel-button,.voice-channel).active{
  color:#283e4a !important;
  background:linear-gradient(90deg,rgba(82,125,104,.12),rgba(47,66,83,.055)) !important;
  border-color:rgba(65,88,83,.16) !important;
  box-shadow:inset 2px 0 rgba(66,132,98,.55),
             inset 0 0 0 1px rgba(60,87,90,.045) !important;
  text-shadow:none !important;
}
html[data-nexo-theme="light"]
 #appShell .channel-sidebar :is(#textChannelItems,#voiceChannelItems)
 .channel-entry > :is(.channel-button,.voice-channel):hover:not(.active){
  background:rgba(27,57,68,.055) !important;
}
