
/* call-layout.css */
:root {
  --call-bg: #1a1a1a;
  --call-text: #ffffff;
  --call-text-muted: rgba(255, 255, 255, 0.6);
  --call-panel-bg: rgba(30, 30, 30, 0.85);
  --call-glass: rgba(20, 20, 20, 0.6);
  --call-border: rgba(255, 255, 255, 0.1);
  --call-primary: #007bff;
  --call-danger: #ff4d4f;
  --call-glow: rgba(0, 123, 255, 0.5);
  --call-speaking-glow: rgba(7, 207, 193, 0.8);
  --call-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  --call-radius: 16px;
  --call-radius-sm: 8px;
  --call-z-base: 9000;
  --call-transition: 250ms cubic-bezier(0.4, 0, 0.2, 1);
}

#call-system-root {
  font-family: inherit;
  color: var(--call-text);
}
#call-system-root * {
  box-sizing: border-box;
}

.call-manager-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: var(--call-z-base);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--call-transition), visibility var(--call-transition), background-color var(--call-transition), backdrop-filter var(--call-transition);
}

.call-manager-overlay.is-active {
  opacity: 1;
  visibility: visible;
}

/*
 * Hard guarantee: with no active call the entire call layer is pulled out of the
 * layout / paint / hit-testing tree. Without this, mount() pre-activates the default
 * ('medium') view container and `.call-view-container.is-active` re-asserts
 * `visibility: visible`, overriding the parent overlay's `visibility: hidden` and
 * leaving the call layer partially live (capturing space / blocking clicks) before
 * any call has even started.
 */
.call-manager-overlay:not(.is-active) {
  display: none !important;
}

/* Medium Backdrop (Items 2 & 6) */
.call-manager-overlay.has-backdrop {
  background-color: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.call-view-container {
  opacity: 0;
  visibility: hidden;
  position: absolute;
  inset: 0;
  transition: opacity var(--call-transition), visibility var(--call-transition);
}
.call-view-container.is-active {
  opacity: 1;
  visibility: visible;
  position: relative;
}

/*
 * The per-view content node must fill its view container and establish a
 * positioning context. The LayoutEngine places blobs with absolute left/top
 * computed from this element's clientWidth/clientHeight — if it collapses to
 * auto height (because blobs are absolutely positioned) the math falls back to
 * viewport size and the stage renders off-place. Lock it to the full box.
 */
.call-view-content {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: visible;
}

/* === Unobits Call UI (custom-realtime) ===================================== */

/* VAD glow classes */

/* Blob (Picture-in-Picture) */

/* Perf mode: reduce animations, pause non-essential motion */

/* === Calls: VAD speaking glow ============================================== */
/* Local user speaking: primary color ring */

/* Remote user speaking: light grey ring (per spec) */

/* keep native look & perf-mode already defined above */

/* ==========================================================================
   Unified Calling Overhaul (Custom controls + Cloudflare RealtimeKit)
   ========================================================================== */

/* Ensure dropdowns / context menus always appear above the call window */
menu,
.menu,
.chat-header .menu {
  z-index: 7000 !important;
}

/* Ongoing Call pill (in chat header) */
.ongoing-call-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid color-mix(in oklab, var(--primary) 70%, white);
  background: color-mix(in oklab, var(--primary-faded) 70%, transparent);
  color: var(--text);
  cursor: pointer;
  user-select: none;
  box-shadow: 0 0 0 rgba(0, 0, 0, 0);
  transition: transform .12s ease, box-shadow .2s ease;
}

.ongoing-call-pill:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 26px rgba(0, 0, 0, .25);
}

.ongoing-call-pill[hidden] {
  display: none
}

.ongoing-call-pill .glow-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--primary);
  box-shadow: 0 0 10px var(--primary), 0 0 18px color-mix(in oklab, var(--primary) 70%, transparent);
  animation: ubGlowPulse 1.2s infinite ease-in-out;
}

@keyframes ubGlowPulse {
  0% {
    transform: scale(.95);
    opacity: .65;
  }

  50% {
    transform: scale(1.15);
    opacity: 1;
  }

  100% {
    transform: scale(.95);
    opacity: .65;
  }
}

/* Call overlay (NOT a <dialog>) so other modals/menus can stack above it */
.ub-call-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(0, 0, 0, .35);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  isolation: isolate;
  z-index: 4500;
  /* below app modals (typically 5000+), and below toast-bar (9999) */
}

.ub-call-overlay[hidden] {
  display: none;
}

.ub-call-window {
  width: min(980px, calc(100vw - 32px));
  height: min(640px, calc(100vh - 32px));
  background: color-mix(in oklab, var(--surface) 92%, transparent);
  border: var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  overflow: hidden;
  display: grid;
  grid-template-rows: auto 1fr auto;
  position: relative;
}

/* Window modes */
.ub-call-window.mode-full {
  width: 100vw;
  height: 100vh;
  border-radius: 0;
}

.ub-call-window.mode-voice-tiny {
  width: min(520px, calc(100vw - 32px));
  height: auto;
  min-height: 260px;
}

/* Header */
.ub-call-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: var(--line);
  background: color-mix(in oklab, var(--surface) 85%, transparent);
}

.ub-call-header-left {
  display: grid;
  gap: 2px;
}

.ub-call-header-right {
  display: flex;
  align-items: center;
  gap: 8px
}

.ub-call-header-title {
  font-weight: 800;
  letter-spacing: .2px;
}

.ub-call-header-sub {
  font-size: 12px;
  opacity: .75;
}

/* Main area */
.ub-call-main {
  position: relative;
  display: grid;
  grid-template-columns: 1fr;
  height: 100%;
  overflow: hidden;
}

.ub-call-video-stage {
  position: relative;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, .35);
}

.ub-call-media-mount {
  width: 100%;
  height: 100%;
}

.ub-call-media-mount iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

/* --------------------------------------------------------------------------
   Cloudflare RealtimeKit stage (rendered inside the existing call mount)
----------------------------------------------------------------------------*/

.ub-call-media-mount .ub-rtk-stage {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.ub-call-media-mount .ub-rtk-grid {
  position: absolute;
  inset: 0;
  padding: 14px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  align-content: stretch;
}

.ub-call-media-mount .ub-rtk-tile {
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .08);
}

.ub-call-media-mount .ub-rtk-tile video {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.ub-call-media-mount .ub-rtk-tile .ub-rtk-label {
  position: absolute;
  left: 10px;
  bottom: 10px;
  max-width: calc(100% - 20px);
  padding: 6px 10px;
  border-radius: 12px;
  font-size: 12px;
  line-height: 1.1;
  color: rgba(255, 255, 255, .95);
  background: rgba(0, 0, 0, .45);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  isolation: isolate;
}

.ub-call-media-mount .ub-rtk-tile.speaking {
  box-shadow:
    0 0 0 2px color-mix(in oklab, var(--primary) 55%, rgba(255, 255, 255, .15)) inset,
    0 10px 40px rgba(0, 0, 0, .22);
}

.ub-call-media-mount .ub-rtk-tile.screenshare {
  grid-column: 1 / -1;
  min-height: 280px;
}

.ub-call-media-mount .ub-rtk-tile.no-video {
  display: grid;
  place-items: center;
}

.ub-call-media-mount .ub-rtk-tile.no-video .ub-rtk-avatar {
  width: 68px;
  height: 68px;
  border-radius: 999px;
  border: 1px solid color-mix(in oklab, var(--primary) 35%, rgba(255, 255, 255, .15));
  background: rgba(255, 255, 255, .06);
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 22px;
  opacity: .95;
}

/* Hide the embedded iframe while connecting (prevents any pre-join UI flashes) */
.ub-call-window.media-hidden .ub-call-media-mount {
  opacity: 0;
  pointer-events: none;
}

/* Hide the video stage in voice calls (voice UI uses a separate stage) */
.ub-call-window.is-voice-call .ub-call-media-mount {
  opacity: 0;
  pointer-events: none;
}

/* Allow temporary technical view to reveal the stage */
.ub-call-window.is-voice-call.tech-mode .ub-call-media-mount {
  opacity: 1;
  pointer-events: auto;
}

/* Voice-only stage */
.ub-call-voice-stage {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 10px;
  padding: 16px;
  background: var(--surface);
  pointer-events: auto;
}

.ub-voice-top {
  font-weight: 700;
  opacity: .9;
}

.ub-voice-avatars {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 14px;
  justify-items: center;
}

.ub-voice-avatar {
  width: 86px;
  height: 86px;
  border-radius: 999px;
  border: 1px solid color-mix(in oklab, var(--primary) 35%, rgba(255, 255, 255, .15));
  background: rgba(255, 255, 255, .06);
  display: grid;
  place-items: center;
  overflow: hidden;
}

.ub-voice-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ub-voice-avatar .initial {
  font-weight: 900;
  font-size: 30px;
  opacity: .9;
}

.ub-voice-avatar.is-waiting {
  animation: ubWaitingPulse 1.2s infinite ease-in-out;
}

.ub-voice-avatar.is-speaking {
  box-shadow:
    0 0 0 2px color-mix(in oklab, var(--primary) 55%, rgba(255, 255, 255, .15)) inset,
    0 10px 40px rgba(0, 0, 0, .22);
}

@keyframes ubWaitingPulse {
  0% {
    opacity: .35;
  }

  50% {
    opacity: 1;
  }

  100% {
    opacity: .35;
  }
}

/* Dot line animation (15 dots flowing left->right) */
.ub-voice-dots {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 2px;
}

.ub-voice-dots span {
  width: 4px;
  height: 4px;
  border-radius: 999px;
  background: color-mix(in oklab, var(--primary) 80%, white);
  opacity: .18;
  transform: translateY(0);
  animation: ubDotFlow 1.05s infinite ease-in-out;
}

@keyframes ubDotFlow {
  0% {
    opacity: .16;
    transform: translateY(0);
  }

  25% {
    opacity: 1;
    transform: translateY(-2px);
  }

  55% {
    opacity: .16;
    transform: translateY(0);
  }

  100% {
    opacity: .16;
    transform: translateY(0);
  }
}

/* Footer controls */
.ub-call-footer {
  padding: 12px 14px;
  border-top: var(--line);
  background: color-mix(in oklab, var(--surface) 85%, transparent);
}

.ub-call-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* Primary border call buttons */
.icon-btn.call-ctrl {
  border: 1px solid color-mix(in oklab, var(--primary) 70%, rgba(255, 255, 255, .25)) !important;
  background: rgba(0, 0, 0, .10);
  color: var(--text);
}

.icon-btn.call-ctrl:hover {
  background: rgba(0, 0, 0, .18);
}

.icon-btn.call-ctrl.is-active {
  background: color-mix(in oklab, var(--primary-faded) 70%, rgba(0, 0, 0, .10));
  box-shadow: 0 0 0 2px color-mix(in oklab, var(--primary) 25%, transparent);
}

.icon-btn.call-ctrl.danger {
  border-color: #b00020 !important;
  background: #b00020;
  color: #fff;
}

.icon-btn.call-ctrl.danger:hover {
  filter: brightness(1.05);
}

/* Chat panel (group video calls only) */
.ub-call-chat-panel {
  position: absolute;
  top: 12px;
  right: 12px;
  width: min(360px, calc(100% - 24px));
  height: calc(100% - 24px);
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, .14);
  background: rgba(0, 0, 0, .28);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  isolation: isolate;
  display: grid;
  grid-template-rows: auto 1fr auto;
  overflow: hidden;
}

.ub-call-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, .12);
}

.ub-call-chat-title {
  font-weight: 800;
  font-size: 13px;
}

.ub-call-chat-body {
  padding: 10px 12px;
  overflow: auto;
}

.ub-call-chat-footer {
  display: flex;
  gap: 10px;
  padding: 10px 12px;
  border-top: 1px solid rgba(255, 255, 255, .12);
}

.ub-call-chat-footer input {
  flex: 1;
  min-width: 0;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, .16);
  background: rgba(0, 0, 0, .18);
  color: var(--text);
  padding: 10px 12px;
}

/* Minimized chat pill */
.ub-call-chat-panel.is-minimized {
  height: auto;
  width: min(360px, calc(100% - 24px));
  grid-template-rows: auto;
}

.ub-call-chat-panel.is-minimized .ub-call-chat-body,
.ub-call-chat-panel.is-minimized .ub-call-chat-footer {
  display: none;
}

/* Settings panel */

.ub-call-chat-panel[hidden],
.ub-call-controls[hidden] {
  display: none
}

.ub-call-settings-body {
  padding: 12px;
  overflow: auto;
  display: grid;
  gap: 12px;
}

.ub-call-settings-body .row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, .10);
  background: rgba(0, 0, 0, .16);
}

.ub-call-settings-body .row .label {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ub-call-settings-body .row .label .t {
  font-weight: 800;
  font-size: 13px;
}

.ub-call-settings-body .row .label .d {
  opacity: .7;
  font-size: 12px;
}

.ub-call-settings-body .row .actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

#supportFab[hidden] {
  display: none
}

/* Base styles for mode-min window */
.ub-call-window.mode-min {
  position: fixed;
  right: 16px;
  bottom: 16px;
  width: auto;
  height: auto;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, .16);
  background: rgba(0, 0, 0, .35);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  isolation: isolate;
  box-shadow: 0 0 18px rgba(0, 0, 0, .35), 0 0 22px color-mix(in oklab, var(--primary) 24%, transparent);
  z-index: 4600;
}

/* Minimized call layer (inside window now) */

.ub-call-minibar-left {
  font-weight: 900;
  letter-spacing: .3px;
  min-width: 58px;
  text-align: center;
}

.ub-call-mini-btns {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
  /* no-wrap */
}

.ub-call-mini-btns[hidden] {
  display: none
}

/* ==========================================================================
   Call enhancements: reduced app load, quick device switching, people panel,
   richer settings shell, and larger minimized video card.
   ========================================================================== */

body.ub-call-app-soft [data-ub-call-frozen="1"],
body.ub-call-app-hard [data-ub-call-frozen="1"] {
  pointer-events: none !important;
  user-select: none !important;
}

body.ub-call-app-soft [data-ub-call-frozen="1"] {
  filter: saturate(.82) brightness(.88);
}

body.ub-call-app-hard [data-ub-call-frozen="1"] {
  visibility: hidden !important;
  opacity: 0 !important;
}

body.ub-call-app-soft *:not(#ubCallOverlay):not(#ubCallOverlay *):not(#ubCallMinibar):not(#ubCallMinibar *) {
  animation-play-state: paused !important;
}

.ub-call-overlay,
.ub-call-window,
.ub-call-minibar,
.ub-call-chat-panel {
  will-change: transform, opacity;
}

.ub-call-overlay {
  transition: opacity .18s ease;
}

.ub-call-window {
  transition: transform .18s ease, box-shadow .18s ease, width .18s ease, height .18s ease;
}

.ub-call-overlay:not([hidden]) .ub-call-window {
  transform: translateY(0) scale(1);
}

.ub-call-ctrl-stack {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.ub-call-ctrl-stack .ub-call-ctrl-quick {
  position: absolute;
  top: -3px;
  right: -3px;
  width: 16px;
  height: 16px;
  min-width: 16px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, .18);
  background: color-mix(in oklab, var(--surface) 80%, rgba(0, 0, 0, .22));
  color: var(--text);
  display: grid;
  place-items: center;
  font-size: 10px;
  line-height: 1;
  z-index: 2;
}

.ub-call-ctrl-stack .ub-call-ctrl-quick:hover {
  background: color-mix(in oklab, var(--primary-faded) 72%, rgba(0, 0, 0, .22));
}

.ub-call-device-menu {
  position: fixed;
  min-width: 220px;
  max-width: min(320px, calc(100vw - 24px));
  max-height: min(360px, calc(100vh - 24px));
  overflow: auto;
  padding: 8px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, .16);
  background: rgba(0, 0, 0, .62);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  isolation: isolate;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .34);
  z-index: 7002;
}

.ub-call-device-menu[hidden] {
  display: none;
}

.ub-call-device-menu button {
  width: 100%;
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0;
  padding: 10px 12px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--text);
}

.ub-call-device-menu button:hover,
.ub-call-device-menu button.is-selected {
  background: rgba(255, 255, 255, .08);
}

.ub-call-device-menu .muted {
  opacity: .66;
  font-size: 12px;
}

.ub-call-people-body {
  overflow: auto;
  padding: 12px;
  display: grid;
  gap: 14px;
}

.ub-call-person-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, .08);
  background: rgba(255, 255, 255, .04);
}

.ub-call-person-avatar {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, .08);
  border: 1px solid rgba(255, 255, 255, .12);
  font-weight: 900;
}

.ub-call-person-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ub-call-person-name {
  font-weight: 800;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ub-call-person-meta {
  font-size: 12px;
  opacity: .7;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.ub-call-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  border: 1px solid rgba(255, 255, 255, .10);
  background: rgba(255, 255, 255, .05);
}

.ub-call-settings-body.ub-call-settings-enhanced {
  padding: 0;
  display: grid;
}

.ub-call-settings-shell {
  min-height: 100%;
  display: grid;
  grid-template-columns: minmax(180px, 220px) 1fr;
}

.ub-call-settings-nav {
  display: grid;
  align-content: start;
  gap: 8px;
}

.ub-call-settings-nav button {
  width: 100%;
  text-align: left;
  display: grid;
  gap: 2px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
}

.ub-call-settings-nav button .t {
  font-size: 13px;
  font-weight: 900;
}

.ub-call-settings-nav button .d {
  font-size: 12px;
  opacity: .7;
}

.ub-call-settings-nav button.is-active {
  border-color: rgba(255, 255, 255, .10);
  background: color-mix(in oklab, var(--primary-faded) 72%, rgba(255, 255, 255, .03));
}

.ub-call-settings-detail {
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 16px;
}

.ub-call-mini-video-preview {
  width: 100%;
  min-width: 0;
  border-radius: 16px;
  overflow: hidden;
  background: rgba(255, 255, 255, .05);
  border: 1px solid rgba(255, 255, 255, .10);
  display: grid;
  grid-template-rows: 1fr auto;
}

.ub-call-mini-video-preview video {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: rgba(0, 0, 0, .18);
}

.ub-call-mini-video-label {
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 800;
  background: rgba(0, 0, 0, .22);
}

body.ub-call-no-glow .ub-call-media-mount .ub-rtk-tile.speaking,
body.ub-call-no-glow .ub-voice-avatar.is-speaking,
body.ub-call-no-glow .ongoing-call-pill .glow-dot {
  box-shadow: none !important;
  animation: none !important;
}

body.ub-call-reduce-motion .ub-call-overlay,
body.ub-call-reduce-motion .ub-call-window,
body.ub-call-reduce-motion .ub-call-minibar,
body.ub-call-reduce-motion .ub-voice-dots span,
body.ub-call-reduce-motion .ongoing-call-pill .glow-dot {
  animation: none !important;
  transition-duration: 0s !important;
}

@media (max-width: 900px) {
  .ub-call-settings-shell {
    grid-template-columns: 1fr;
  }

  .ub-call-settings-nav {
    border-right: 0;
    border-bottom: 1px solid rgba(255, 255, 255, .10);
  }
}


/* === Calling enhancement layer =========================================== */
body.ub-call-app-suspended,
html.ub-call-app-suspended {
  overflow: hidden;
}

body.ub-call-app-suspended * {
  animation-play-state: paused !important;
}

/* Keep the call's own animations alive while the rest of the app is suspended. The call
   window can be relocated into a top-level .ub-call-core-dialog, so cover it explicitly
   (not just #ubCallOverlay) — otherwise its content/animations freeze and can disappear. */
body.ub-call-app-suspended .ub-call-overlay,
body.ub-call-app-suspended .ub-call-overlay *,
body.ub-call-app-suspended .ub-call-core-dialog,
body.ub-call-app-suspended .ub-call-core-dialog *,
body.ub-call-app-suspended .ub-call-window,
body.ub-call-app-suspended .ub-call-window *,
body.ub-call-app-suspended .ub-call-minibar,
body.ub-call-app-suspended .ub-call-minibar * {
  animation-play-state: running !important;
}

body.ub-call-app-relaxed .ub-call-overlay {
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  isolation: isolate;
}

.ub-call-overlay {
  transition: opacity .22s ease, backdrop-filter .22s ease;
}

.ub-call-window {
  transition: width .2s ease, height .2s ease, transform .2s ease, border-radius .2s ease;
}

.ub-call-window .ub-call-main > * {
  transition: transform .18s ease, opacity .18s ease;
}

.ub-call-window.mode-min.is-video-bar {
  width: 380px;
  height: auto;
  min-height: 176px;
  border-radius: 20px;
}

.ub-call-mini-preview {
  width: 100%;
  min-height: 102px;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(0,0,0,.35);
  position: relative;
}

.ub-call-mini-preview video {
  width: 100%;
  height: 100%;
  min-height: 102px;
  object-fit: cover;
  display: block;
}

.ub-call-mini-preview-label {
  position: absolute;
  left: 10px;
  bottom: 10px;
  padding: 5px 9px;
  border-radius: 999px;
  background: rgba(0,0,0,.46);
  color: rgba(255,255,255,.94);
  font-size: 12px;
  line-height: 1;
  max-width: calc(100% - 20px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ub-call-switchable {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.ub-call-switchable > .call-ctrl,
.ub-call-switchable > .icon-btn {
  margin-right: 0;
}

.ub-call-device-toggle {
  position: absolute;
  right: -3px;
  top: -3px;
  width: 18px;
  height: 18px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.18);
  background: rgba(0,0,0,.68);
  color: rgba(255,255,255,.92);
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(0,0,0,.25);
  z-index: 3;
}

.ub-call-device-toggle i {
  font-size: 9px;
  line-height: 1;
}

.ub-call-device-menu {
  position: absolute;
  top: -200px;
  right: 0;
  min-width: 220px;
  max-width: min(260px, 72vw);
  display: grid;
  gap: 6px;
  padding: 10px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,.12);
  background: color-mix(in oklab, var(--surface) 92%, transparent);
  box-shadow: 0 20px 50px rgba(0,0,0,.35);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  isolation: isolate;
  z-index: 7;
}

.ub-call-device-menu[hidden] {
  display: none;
}

.ub-call-device-menu-title {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .02em;
  opacity: .78;
}

.ub-call-device-option {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 12px;
  background: rgba(255,255,255,.04);
  color: inherit;
  padding: 9px 10px;
  cursor: pointer;
  text-align: left;
}

.ub-call-device-option .txt {
  display: inline-block;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ub-call-device-option.is-selected {
  border-color: color-mix(in oklab, var(--primary) 65%, rgba(255,255,255,.2));
  background: color-mix(in oklab, var(--primary-faded) 65%, rgba(255,255,255,.04));
}

.ub-call-device-empty {
  font-size: 12px;
  opacity: .72;
  padding: 10px 0 4px;
}

.ub-call-participants-body,
.ub-call-settings-body {
  overflow: hidden;
  min-height: 0;
  padding: 14px;
  height: -webkit-fill-available;
}

.ub-call-settings-shell {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 16px;
  min-height: min(520px, calc(100vh - 180px));
}

.ub-call-settings-nav {
  display: grid;
  gap: 8px;
  align-content: start;
  padding-right: 6px;
}

.ub-call-settings-navbtn {
  width: 100%;
  text-align: left;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 14px;
  background: rgba(255,255,255,.03);
  color: inherit;
  font: inherit;
  padding: 12px 13px;
  cursor: pointer;
}

.ub-call-settings-navbtn.is-active {
  border-color: color-mix(in oklab, var(--primary) 68%, rgba(255,255,255,.2));
  background: color-mix(in oklab, var(--primary-faded) 70%, rgba(255,255,255,.04));
}

.ub-call-settings-detail {
  min-width: 0;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 12px;
}

.ub-call-settings-detail-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.ub-call-settings-title-strong {
  font-size: 18px;
  font-weight: 900;
}

.ub-call-settings-sub {
  font-size: 12px;
  opacity: .72;
}

.ub-call-settings-detail-body {
  display: grid;
  gap: 16px;
  align-content: start;
}

.ub-call-settings-copycard {
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,.08);
  background: rgba(255,255,255,.035);
}

.ub-call-settings-copycard.compact {
  padding: 12px 14px;
}

.ub-call-settings-copycard p {
  margin: 6px 0 0;
  font-size: 13px;
  line-height: 1.45;
  opacity: .75;
}

.ub-call-settings-headline {
  font-size: 15px;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 8px;
}

.ub-call-settings-section-extra {
  display: grid;
  gap: 12px;
}

.ub-call-settings-actions-row,
.ub-call-actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.ub-call-fields-grid {
  display: grid;
  gap: 12px;
}

.ub-call-fields-grid.two-up {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.ub-call-field {
  display: grid;
  gap: 8px;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,.08);
  background: rgba(255,255,255,.03);
}

.ub-call-field > span {
  font-size: 13px;
  font-weight: 700;
}

.ub-call-field select,
.ub-call-field input[type="range"] {
  width: 100%;
}

.ub-call-range-wrap {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
}

.ub-call-range-wrap strong {
  min-width: 56px;
  text-align: right;
  font-size: 12px;
  font-weight: 800;
}

.ub-call-range-wrap strong em {
  font-style: normal;
  opacity: .72;
  margin-left: 2px;
}

.ub-call-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,.08);
  background: rgba(255,255,255,.03);
}

.ub-call-toggle-copy {
  display: grid;
  gap: 4px;
}

.ub-call-toggle-title {
  font-size: 13px;
  font-weight: 800;
}

.ub-call-toggle-desc {
  font-size: 12px;
  opacity: .72;
  line-height: 1.35;
}

.ub-call-toggle-control {
  position: relative;
  width: 48px;
  flex: 0 0 auto;
}

.ub-call-toggle-control input {
  position: absolute;
  inset: 0;
  opacity: 0;
}

.ub-call-toggle-ui {
  display: block;
  width: 48px;
  height: 28px;
  border-radius: 999px;
  background: rgba(255,255,255,.16);
  position: relative;
  transition: background .15s ease;
}

.ub-call-toggle-ui::after {
  content: '';
  position: absolute;
  left: 3px;
  top: 3px;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: white;
  transition: transform .15s ease;
}

.ub-call-toggle input:checked + .ub-call-toggle-ui {
  background: color-mix(in oklab, var(--primary) 74%, rgba(255,255,255,.18));
}

.ub-call-toggle input:checked + .ub-call-toggle-ui::after {
  transform: translateX(20px);
}

.ub-call-visualizer-card {
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,.08);
  background: rgba(255,255,255,.03);
  display: grid;
  gap: 10px;
}

.ub-call-visualizer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
  opacity: .78;
}

#ubCallInputVisualizer {
  width: 100%;
  height: 60px;
  border-radius: 12px;
  background: rgba(0,0,0,.22);
  display: block;
}

.ub-call-section {
  display: grid;
  gap: 10px;
}

.ub-call-section-head {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .03em;
  text-transform: uppercase;
  opacity: .7;
}

.ub-call-list-stack {
  display: grid;
  gap: 10px;
}

.ub-call-person-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,.08);
  background: rgba(255,255,255,.03);
}

.ub-call-person-avatar {
  width: 42px;
  height: 42px;
  border-radius: 999px;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.08);
  font-weight: 800;
}

.ub-call-person-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ub-call-person-copy {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.ub-call-person-name {
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ub-call-person-meta,
.ub-call-inline-copy,
.ub-call-empty {
  font-size: 12px;
  opacity: .72;
  line-height: 1.4;
}

.ub-call-inline-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.ub-call-inline-header .btn.soft {
  flex: 0 0 auto;
}

.ub-call-inline-action,
.btn.xs {
  padding: 8px 10px;
  min-height: 0;
  font-size: 12px;
  background: var(--muted);
  border: var(--line);
  border-radius: 12px;
  block-size: 35px;
}

.ub-call-guest-card {
  display: grid;
  gap: 12px;
  margin-bottom: 14px;
}

.ub-call-link-block {
  display: grid;
  gap: 10px;
}

.ub-call-link-block textarea {
  width: 100%;
  min-height: 92px;
  resize: vertical;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,.08);
  background: rgba(0,0,0,.22);
  color: inherit;
  padding: 12px 14px;
}

.ub-call-settings-copycard .pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 9px;
  border-radius: 999px;
  background: color-mix(in oklab, var(--primary-faded) 72%, rgba(255,255,255,.06));
  border: 1px solid color-mix(in oklab, var(--primary) 62%, rgba(255,255,255,.18));
  font-size: 11px;
  font-weight: 800;
}

.ub-call-media-mount .ub-rtk-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

body.ub-call-app-suspended .ub-call-window,
body.ub-call-app-relaxed .ub-call-minibar {
  will-change: transform, opacity;
}

@media (max-width: 920px) {
  .ub-call-settings-shell {
    grid-template-columns: 1fr;
  }

  .ub-call-settings-nav {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {

  .ub-call-fields-grid.two-up {
    grid-template-columns: 1fr;
  }

  .ub-call-settings-nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .ub-call-inline-header {
    flex-direction: column;
    align-items: stretch;
  }

  .ub-call-minibar.is-video-bar {
    min-width: min(92vw, 420px);
  }
}


/* Compatibility aliases for integrated call enhancements */
.ub-call-minibar.is-video-bar .ub-call-mini-video-preview {
  display: grid;
}

/* Top-level call dialogs and popups */
.ub-call-core-dialog {
  z-index: 9800;
}

.ub-call-core-dialog .u-head,
.ub-call-core-dialog .u-foot {
  display: none;
}

.ub-call-core-dialog .u-card {
  padding: 0;
  overflow: hidden;
}

.ub-call-core-dialog .u-body {
  padding: 0;
  display: block;
  overflow: hidden;
}

.ub-call-core-dialog.is-settings .u-card {
  width: min(1080px, calc(100vw - 36px));
  max-width: min(1080px, calc(100vw - 36px));
  max-height: min(92vh, 920px);
}

.ub-call-core-dialog.is-participants .u-card {
  width: min(520px, calc(100vw - 36px));
  max-width: min(520px, calc(100vw - 36px));
  max-height: min(88vh, 840px);
}

.ub-call-core-dialog #ubCallSettingsBodyMount,
.ub-call-core-dialog #ubCallParticipantsBodyMount {
  position: relative;
  inset: auto;
  width: 100%;
  max-width: none;
  min-height: 0;
  border: 0;
  box-shadow: none;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  isolation: isolate;
  background: transparent;
  border-radius: 0;
}

.ub-call-core-dialog #ubCallSettingsBodyMount {
  height: min(92vh, 920px);
}

.ub-call-core-dialog #ubCallParticipantsBodyMount {
  height: min(88vh, 840px);
}

.ub-call-core-dialog .ub-call-settings-shell {
  min-height: min(640px, calc(90vh - 120px));
}

.ub-call-core-dialog .ub-call-settings-body,
.ub-call-core-dialog .ub-call-participants-body {
  max-height: none;
}

.ub-call-core-dialog .ub-call-settings-body,
.ub-call-core-dialog .ub-call-participants-body,
.ub-call-core-dialog .ub-call-settings-detail-body {
  overscroll-behavior: contain;
}

.ub-call-core-dialog .ub-call-settings-body,
.ub-call-core-dialog .ub-call-participants-body {
  padding: 18px;
}

.ub-call-device-core-popup {
  min-width: 250px;
  max-width: min(320px, calc(100vw - 24px));
  z-index: 9900;
}

.ub-call-device-core-popup .u-body {
  padding: 0;
}

.ub-call-device-core-popup .ub-call-device-menu {
  position: static;
  top: auto;
  right: auto;
  min-width: 0;
  max-width: none;
  max-height: min(360px, calc(100vh - 40px));
  box-shadow: none;
  border: 0;
  border-radius: 0;
  background: transparent;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  isolation: isolate;
}

@media (max-width: 920px) {
  .ub-call-core-dialog.is-settings .u-card,
  .ub-call-core-dialog.is-participants .u-card {
    width: calc(100vw - 20px);
    max-width: calc(100vw - 20px);
  }
}

@media (max-width: 760px) {
  .ub-call-core-dialog.is-settings .u-card,
  .ub-call-core-dialog.is-participants .u-card {
    width: calc(100vw - 12px);
    max-width: calc(100vw - 12px);
  }

  .ub-call-core-dialog .ub-call-settings-shell {
    min-height: auto;
  }
}


/* === Batch 3: chat call polish ========================================== */

.ongoing-call-pill .timer {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 54px;
  padding-left: 8px;
  margin-left: 2px;
  border-left: 1px solid color-mix(in oklab, var(--text) 12%, transparent);
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: .02em;
  opacity: .92;
}

.ongoing-call-pill[data-call-state="ringing"] .timer {
  opacity: .55;
}

.call-card.call-missed.modern {
  display: grid;
  gap: 10px;
  padding: 2px 0 0;
  border-radius: 16px;
  border: 0;
  box-shadow: none;
  background: none;
}

.call-missed-modern-shell {
  display: grid;
  grid-template-columns: 25px minmax(0, 1fr) 30px;
  align-items: center;
  gap: 10px;
  border-radius: 16px;
  background: var(--dots);
  padding: 8px;
}

.call-missed-modern-icon {
  width: 26px;
  height: 26px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, #ff6b57, #f24d3d);
  color: white;
  box-shadow: 0 10px 18px rgba(242, 77, 61, .22);
}

.call-missed-modern-copy {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.call-missed-modern-title {
  font-weight: 800;
  color: #dc4b39;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.call-missed-modern-sub {
  color: var(--text);
  font-size: 11px;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Call-back button (replaces the old "more" menu on missed-call cards). */
.call-missed-callback {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  justify-self: end;
  align-self: center;
  border: 0;
  border-radius: 999px;
  background: var(--ok, #16a34a);
  color: #fff;
  cursor: pointer;
  transition: filter .15s ease, transform .12s ease;
}
.call-missed-callback:hover {
  filter: brightness(1.08);
}
.call-missed-callback:active {
  transform: scale(.94);
}

@media (max-width: 640px) {
  .call-missed-modern-shell {
    grid-template-columns: 34px minmax(0, 1fr) auto;
    gap: 10px;
    padding: 9px 11px;
  }
}

/* Override the core dialog styles so our full call overlay acts full screen instead of small box */
.ub-call-core-dialog.is-call-overlay-modal .u-card {
  width: 100vw;
  height: 100vh;
  max-width: none;
  max-height: none;
  border-radius: 0;
  margin: 0;
  padding: 0;
  background: transparent;
  box-shadow: none;
  border: none;
}


.ub-call-core-dialog.is-call-overlay-modal #ubCallOverlayMount {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}


/* === Morphing between display modes =======================================
   The call lives in a single #ubCallWindow; switching mode only swaps classes, so
   size / shape / position interpolate as one element expanding (bubble <-> mid <-> full).
   Major mode changes use 350ms; this is the single authoritative transition for the
   window (it overrides the earlier shorter declarations above). */
.ub-call-window,
.ub-call-window.mode-min {
  transition:
    width 0.35s cubic-bezier(0.4, 0, 0.2, 1),
    height 0.35s cubic-bezier(0.4, 0, 0.2, 1),
    transform 0.35s cubic-bezier(0.4, 0, 0.2, 1),
    border-radius 0.35s cubic-bezier(0.4, 0, 0.2, 1),
    box-shadow 0.35s cubic-bezier(0.4, 0, 0.2, 1),
    background 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* === Voice vs Video/Conference distinction ================================
   Voice  = cleaner, lighter, calmer surface (phone iconography, big avatars, dots).
   Video  = darker, immersive stage (camera iconography, participant tiles, presenter).
   Scoped to :not(.mode-min) so the minimized bubble keeps its own pill styling. */
.ub-call-window:not(.mode-min).is-voice-call {
  background:
    radial-gradient(120% 80% at 50% 0%, color-mix(in oklab, var(--primary) 10%, transparent), transparent 60%),
    color-mix(in oklab, var(--surface) 96%, transparent);
  border: 1px solid rgba(255, 255, 255, 0.12);
}
.ub-call-window:not(.mode-min):not(.is-voice-call) {
  background:
    radial-gradient(130% 90% at 50% -10%, rgba(42, 46, 64, 0.55), transparent 55%),
    #0c0c0f;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

/* Call Performance Pills
 * Each pill renders three parts (icon / text / status). Which parts are visible is decided
 * here off the window mode class so the pills morph in step with the overlay:
 *   mode-full        -> [icon · text · status]
 *   mode-middle/voice-> [text · status]
 *   mode-min         -> [icon]
 */

.ub-call-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  background: rgba(0, 0, 0, 0.42);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.12);
  transition: padding .25s cubic-bezier(0.4, 0, 0.2, 1),
              border-color .25s ease, background .25s ease;
  position: relative;
  cursor: default;
}

.ub-call-pill i {
  font-size: 14px;
}

.ub-call-pill .pill-icon {
  display: inline-flex;
  align-items: center;
}

.ub-call-pill .pill-text {
  display: inline;
  letter-spacing: .01em;
}

.ub-call-pill .pill-status {
  display: inline;
  font-weight: 700;
  opacity: .96;
}

/* Mid / starting overlay: [text · status] (drop the icon) */
.ub-call-window.mode-middle .ub-call-pill .pill-icon,
.ub-call-window.mode-voice-tiny .ub-call-pill .pill-icon {
  display: none;
}

/* Minimized bubble: [icon] only — the app is no longer focused on the call */
.ub-call-window.mode-min .ub-call-pill .pill-text,
.ub-call-window.mode-min .ub-call-pill .pill-status {
  display: none;
}
.ub-call-window.mode-min .ub-call-pill {
  padding: 5px;
  gap: 0;
}

/* Status colours + border pulse/glow */

/* Hover tooltip: actionable recommendation per status */
.ub-call-pill[data-tip]:hover::after {
  content: attr(data-tip);
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 60;
  min-width: 170px;
  max-width: 260px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(15, 15, 18, 0.97);
  color: #fff;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.35;
  white-space: normal;
  text-align: left;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.12);
  pointer-events: none;
}

/* Reduced-motion / decorative pause must not jitter the pills */
body.ub-call-reduce-motion .ub-call-pill {
  animation: none !important;
}

@keyframes pulse-warning {
  0% { box-shadow: 0 0 0 0 rgba(234, 179, 8, 0.4); }
  70% { box-shadow: 0 0 0 6px rgba(234, 179, 8, 0); }
  100% { box-shadow: 0 0 0 0 rgba(234, 179, 8, 0); }
}

@keyframes pulse-danger {
  0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  70% { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
  100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}
