#call-view {
    position: fixed;
    z-index: 9999;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #f0f2f5;
    overflow: hidden;
}

#media-select-dialog {
    position: fixed;
    z-index: 10000;
    top: 30%;
    left: 50%;
    transform: translate(-50%, -30%);
    background: #fff;
    padding: 2em;
    border-radius: 12px;
    box-shadow: 0 2px 20px #0002;
    min-width: 320px;
    max-width: 95vw;
}

.arrow-controls.d-grid {
  display: grid !important;
  grid-template-columns: 60px 60px 60px;
  grid-template-rows: 60px 60px 60px;
  gap: 10px;
  justify-content: center;
  align-items: center;
}

#mobile-device-controls { display: none; }

/* Standard: Dot ist versteckt */
.status-dot {
  display: none !important;
}
/* --- MOBILE PORTRAIT --- */
@media (max-width: 800px) and (orientation: portrait) {

  /* Desktop-Steuerelemente komplett verstecken */
  #call-view .desktop-device-controls,
  #call-view .chatbereich,
  #call-view .d-flex.flex-row.align-items-stretch.justify-content-between,
  #call-view .arrow-controls.d-grid:not(#mobile-controls .arrow-controls) {
    display: none !important;
  }
  

  #call-view .d-flex.flex-row, 
  #call-view .d-flex.flex-row.align-items-stretch, 
  #call-view .d-flex.flex-column {
    flex-direction: column !important;
    align-items: stretch !important;
    width: 100vw !important;
    padding: 0 !important;
  }
  #call-view > .d-flex.flex-column.h-100.w-100 {
    padding: 0 !important;
    margin: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background: #000 !important;
  }
  #call-view .d-flex.justify-content-between {
    height: 40px !important;
    min-height: 32px !important;
    padding: 0 12px !important;
    background: #f0f2f5;
    z-index: 8;
  }
  #call-view .position-relative.w-100.h-100.mx-4 {
    max-width: 100vw !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
  }
  #call-view video#remote-video {
    width: 100vw !important;
    height: calc(100vh - 40px - 54px) !important; /* header + mobile controls */
    object-fit: contain !important;
    margin: 0 !important;
    border-radius: 0 !important;
    background: #111 !important;
    display: block !important;
  }
  #call-view #remote-video-placeholder {
    border-radius: 0 !important;
  }
  #call-view video#local-video {
    display: none !important;
  }
  /* Steuerkreuz sichtbar, absolut platziert im Video */
  #mobile-controls {
    display: block !important;
    /*position: absolute !important;*/
    margin-left: auto !important;
    margin-right: auto !important;
    bottom: 20px !important;
    /*transform: translateX(-50%);*/
    z-index: 30 !important;
    width: 200px !important;
    pointer-events: none;
  }
  #mobile-controls .arrow-controls {
    width: 200px; /* Genaue Breite der Buttons */
    margin: 0 auto !important;
    pointer-events: all;
  }
  /* Kamera/Mikro-Auswahl ganz unten */
  #mobile-device-controls {
    display: flex !important;
    position: fixed !important;
    left: 0; right: 0; bottom: 0;
    width: 100vw !important;
    min-height: 50px;
    background: #fff;
    z-index: 20;
    border-top: 1px solid #ddd;
    box-shadow: 0 -2px 6px #0002;
  }
  /* Chat-Button sichtbar */
  #chat-fab {
    display: block !important;
    position: fixed !important;
    right: 22px;
    bottom: 70px;
    z-index: 1050;
    background: rgba(40,40,50,0.93);
    border-radius: 50%;
    box-shadow: 0 3px 14px #0004;
    width: 58px; height: 58px;
    padding: 0;
    outline: none;
    border: none;
  }
  #chat-fab img {
    width: 32px;
    height: 32px;
    filter: invert(1) brightness(2);
    pointer-events: none;
  }
  #mobile-chat-overlay {
    display: none;
  }
  #mobile-chat-overlay.active {
    display: block !important;
  }
  #mobile-chat-sheet {
    height: 30vh !important;
    min-height: 160px;
    max-height: 60vh;
  }
  #mobile-chat-sheet.active {
    display: block !important;
  }
  .desktop-device-controls { 
    display: none !important; 
  }
  .status-dot {
    display: inline-block !important;
    vertical-align: middle;
  }
  .user_table_desktop {
    display: none !important; 
  }
}

@media (max-width: 1024px) and (orientation: landscape) {
  #call-view > .d-flex.flex-column.h-100.w-100 {
    display: grid !important;
    grid-template-columns: 20vw 1fr 27vw;
    grid-template-rows: 90px 1fr auto;
    grid-template-areas:
      "left video right"
      "left video right"
      ". device .";
    height: 100vh !important;
    width: 100vw !important;
    background: #23262a !important;
    padding: 0 !important;
    position: relative !important;
    overflow: hidden !important;
  }

  /* Linker Bereich: Call beenden, Username */
  #call-view .d-flex.justify-content-between.align-items-center {
    grid-area: left;
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    justify-content: flex-start !important;
    background: #23262a !important;
    box-shadow: 1px 0 0 #1112;
    padding: 34px 12px 0 26px !important;
    z-index: 2;
    height: 100%;
  }
  #end-call-btn {
    margin-bottom: 28px !important;
    width: 100% !important;
    max-width: 160px !important;
    font-size: 1em !important;
    border-radius: 12px !important;
  }
  #remote-username {
    font-size: 1.13em !important;
    margin: 0 !important;
    color: #fff !important;
    text-align: left !important;
    width: 100% !important;
    word-break: break-word;
    font-weight: bold !important;
    letter-spacing: 0.01em;
    opacity: 1 !important;
  }

  /* Mittlerer Bereich: Video */
  #call-view .d-flex.align-items-center.justify-content-center.position-relative {
    grid-area: video;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: #17181a !important;
    margin: 0 !important;
    height: 90% !important;
    width: 100% !important;
    position: relative !important;
    z-index: 1;
  }
  #call-view .position-relative.w-100.h-100.mx-4 {
    width: 95% !important;
    height: 83vh !important;
    max-height: 83vh !important;
    margin: 0 auto !important;
    background: #111 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 14px !important;
    box-shadow: 0 4px 16px #0003;
  }
  #call-view video#remote-video, #call-view #remote-video-placeholder {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain !important;
    background: #111 !important;
    border-radius: 14px !important;
    display: block !important;
    margin: 0 auto !important;
    max-height: 100% !important;
  }
  #remote-video-placeholder {
    color: #bbb !important;
    font-size: 1.15em !important;
  }

  /* Rechter Bereich: Chatbereich und Steuerkreuz */
  #call-view .d-flex.flex-row.align-items-stretch.justify-content-between {
    grid-area: right;
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    justify-content: flex-start !important;
    background: #23262a !important;
    box-shadow: -1px 0 0 #1112;
    width: 100% !important;
    height: 100% !important;
    padding: 38px 26px 0 18px !important;
    z-index: 3;
    gap: 0;
  }
  #call-view .d-flex.flex-column.justify-content-end {
    width: 100% !important;
    min-width: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
  }
  #chat-area {
    min-height: 98px !important;
    max-height: 200px !important;
    background: #fff !important;
    border-radius: 10px !important;
    margin-bottom: 14px !important;
    font-size: 1em !important;
    overflow-y: auto !important;
    box-shadow: 0 1px 8px #0002;
    padding: 14px 16px !important;
  }
  .input-group {
    margin-bottom: 0 !important;
    width: 100% !important;
  }
  #chat-input {
    min-width: 0 !important;
    font-size: 1em !important;
  }
  #chat-send-btn {
    min-width: 70px !important;
  }

  /* Steuerkreuz unverzerrt, Abstand nach oben */
  #call-view .d-flex.flex-column.align-items-center.justify-content-center {
    width: 100% !important;
    margin-top: 30px !important;
    margin-bottom: 20px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: flex-end !important;
    padding: 0 !important;
  }
  .arrow-controls.d-grid.gap-2 {
    width: 102px !important;
    height: 102px !important;
    grid-template-columns: 34px 34px 34px !important;
    grid-template-rows: 34px 34px 34px !important;
    gap: 4px !important;
  }
  .arrow-controls.d-grid.gap-2 button {
    font-size: 1.3em !important;
    border-radius: 8px !important;
  }

  /* NUR Mobile Controls: Sichtbar und zentriert unter dem Video */
  #mobile-device-controls {
    display: flex !important;
    position: absolute !important;
    height: 15px !important;
    max-width: 900px !important;
    min-width: 220px !important;
    justify-content: center !important;
    align-items: center !important;
    gap: 18px !important;
    background: #f5f6f8 !important;
    border-radius: 8px 8px 0 0 !important;
    box-shadow: 0 0 12px #0001;
    border: 1px solid #d2d2d2 !important;
    z-index: 99 !important;
    padding: 12px 0 !important;
    margin-left: auto !important;
    margin-right: auto !important;
  }
  #mobile-device-controls select,
  #mobile-device-controls button {
    min-width: 48px !important;
    max-width: 150px !important;
    font-size: 1em !important;
    border-radius: 7px !important;
    color: #23262a !important;
    background: #fff !important;
    border: 1px solid #bbb !important;
    box-shadow: 0 1px 4px #0001;
    margin: 0 2px !important;
    height: 38px !important;
  }
  .desktop-device-controls {
    display: none !important;
  }

  /* Alle übrigen mobilen Controls/Overlays weiter verstecken */
  #chat-fab, #mobile-chat-overlay, #mobile-chat-sheet, #local-video {
    display: none !important;
  }
}
