:root {
  --bg: #f6f7fb;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --primary: #3b82f6;
  --primary-dark: #2563eb;
  --danger: #ef4444;
  --success: #16a34a;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
  --radius: 18px;

  --app-header-h: 72px;
  --app-sidebar-w: 320px;

  --call-bg: #07111f;
  --call-card: #ffffff;
  --call-text: #0f172a;
  --call-muted: #64748b;
  --call-line: #e2e8f0;
  --call-primary: #7c3aed;
  --call-primary-2: #6d28d9;
  --call-shadow: 0 18px 50px rgba(15, 23, 42, 0.18);
  --call-radius: 22px;
  --call-gap: clamp(8px, 1.5vw, 16px);
  --call-pad: clamp(10px, 1.8vw, 18px);
  --call-control-size: clamp(40px, 6vw, 48px);
  --call-control-font: clamp(12px, 2.2vw, 14px);
  --call-manage-z: 4000;
  --call-room-z: 2500;

  --composer-h: clamp(118px, 16dvh, 154px);
  --composer-h-mobile: clamp(124px, 18dvh, 168px);
}

*,
*::before,
*::after { box-sizing: border-box; }

html,
body {
  width: 100%;
  height: 100%;
  overflow-x: hidden;
  overflow-y: hidden;
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: Arial, Helvetica, sans-serif;
  background: var(--bg);
  color: var(--text);
}

button,
input,
textarea,
select { font: inherit; }

img,
video,
audio,
canvas { max-width: 100%; }

.hidden { display: none !important; }
.muted,
.small { color: var(--muted); }

.card {
  background: var(--card);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  padding: 18px;
}

.center {
  width: min(460px, calc(100% - 24px));
  margin: 6vh auto;
}

.stack { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; gap: 10px; }

.btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 12px;
  padding: 10px 14px;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
.btn:hover { transform: translateY(-1px); border-color: #cbd5e1; }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

.btn.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.btn.primary:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}

.btn.small {
  padding: 7px 10px;
  border-radius: 10px;
  font-size: 0.9rem;
}

.btndangersmall {
  border: 1px solid #fecaca;
  background: #fff5f5;
  color: var(--danger);
  border-radius: 10px;
  padding: 7px 10px;
  cursor: pointer;
}

.topbar {
  min-height: var(--app-header-h);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  position: sticky;
  top: 0;
  z-index: 5000;
  flex-wrap: nowrap;
  width: 100%;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}

.logo {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--line);
  background: #fff;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  white-space: nowrap;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 4px;
  margin-left: auto;
  min-width: 0;
}
.header-actions .btn { flex: 0 0 auto; }

#chat { width: 100%; height: 100dvh; overflow: hidden; }

#layout {
  display: grid;
  grid-template-columns: var(--app-sidebar-w) minmax(0, 1fr);
  width: 100%;
  min-height: calc(100dvh - var(--app-header-h));
  height: calc(100dvh - var(--app-header-h));
  overflow: hidden;
}

#sidebar {
  width: 100%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-right: 1px solid var(--line);
  background: #fff;
  height: 100%;
}

.search { padding: 12px; border-bottom: 1px solid var(--line); }

.search input,
#username,
#password,
#avatar,
#groupName,
#groupAvatar,
#newUsername,
#newPassword,
#globalSearch,
#msgContent,
select,
input[type="text"],
input[type="password"],
input[type="url"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  background: #fff;
  outline: none;
}

#globalSearch { padding: 11px 12px; }

.users-list {
  overflow: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-bottom: 80px;
}

.user-item {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 14px;
  padding: 10px;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.user-item:hover { border-color: #cbd5e1; transform: translateY(-1px); }

.user-item .badge,
.unread-badge {
  display: inline-flex;
  min-width: 20px;
  height: 20px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 0.75rem;
  padding: 0 6px;
  line-height: 1;
}

.presence { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.presence.online { background: var(--success); }
.presence.offline { background: #9ca3af; }

.main-area {
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
  height: 100%;

  position: relative;
}

.chat-pane-header {
  display: none;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: #fff;
  flex: 0 0 auto;
  position: sticky;
  top: 0;
  z-index: 40;
}

.chat-pane-titlewrap { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
#chatPaneTitle { font-size: 1rem; line-height: 1.2; }
#chatPaneSub { font-size: 0.8rem; }

#messages {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;

  padding: 16px;

  display: flex;
  flex-direction: column;
  gap: 10px;

  margin-bottom: var(--composer-h);

  scroll-padding-bottom: 20px;
}

.message {
  max-width: min(78%, 760px);
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 16px;
  padding: 10px 12px;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.02);
  word-break: break-word;
}
.message.sent { margin-left: auto; background: #eff6ff; border-color: #dbeafe; }
.message.received { margin-right: auto; background: #fff; }
.message.selected { outline: 2px solid var(--primary); }

.content { white-space: pre-wrap; line-height: 1.45; }
.time { font-size: 0.76rem; color: var(--muted); }
.seentick { font-size: 0.95rem; color: #9ca3af; }
.seentick.read { color: var(--success); font-weight: 700; }

.file-div {
  margin-top: 8px;
  padding: 8px;
  border: 1px solid #eef2f7;
  border-radius: 12px;
  background: #fafafa;
}

.chat-image-preview {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  max-height: 240px;
  border-radius: 12px;
  margin-bottom: 8px;
  object-fit: cover;
}

/* SABİT ALT PANEL */
.controls.sticky {
  position: fixed;
  left: var(--app-sidebar-w);
  right: 0;
  bottom: 0;
  width: auto;
  height: var(--composer-h);
  max-height: var(--composer-h);
  z-index: 60;
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding: 7px 10px calc(7px + env(safe-area-inset-bottom));
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 5px;
  box-shadow: 0 -10px 24px rgba(15, 23, 42, 0.08);
  overflow: hidden;
  min-height: 0;
  box-sizing: border-box;
}

body.chat-conversation-open .controls.sticky {
  left: 0;
}

body.chat-list-mode .controls.sticky {
  display: none;
}

/* Mesaj yazılan yer */
#msgContent {
  width: 100%;
  min-height: 0;
  max-height: none;
  resize: none;
  line-height: 1.45;
  border-radius: 14px;
  padding: 8px 12px;
  flex: 1 1 auto;
}

/* Alt düymələr */
.msg-toolbar {
  display: grid;
  grid-template-columns: 34px 34px 34px minmax(0, 1fr);
  gap: 5px;
  width: 100%;
  min-width: 0;
  align-items: center;
}

.msg-toolbar > .btn,
.msg-toolbar > label {
  min-width: 0;
  width: 100%;
}

#recordBtn,
#moreActionsBtn,
#cancelRecordBtn {
  width: 34px;
  min-width: 34px;
  height: 34px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

#sendBtn {
  width: 100%;
  min-width: 0;
  height: 34px;
  padding: 0 8px;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 600;
  visibility: visible !important;
  opacity: 1 !important;
  flex: 1 1 auto;
  font-size: clamp(0.78rem, 1.8vw, 0.92rem);
}

#sendBtn .icon-svg {
  width: 15px;
  height: 15px;
}

#cancelRecordBtn {
  border-color: #fecaca;
  background: #fff5f5;
  color: var(--danger);
}

#clearFileBtn,
#shareInlineBtn,
#exportInlineBtn {
  min-height: 38px;
  height: 38px;
  border-radius: 12px;
  padding: 0 12px;
  font-size: 0.92rem;
  white-space: nowrap;
  background: #f8fafc;
}

#clearFileBtn:hover,
#shareInlineBtn:hover,
#exportInlineBtn:hover {
  background: #eef2f7;
}


/* DİGER POPUP HƏMİŞƏ ƏN ÜSTDƏ */
.more-actions-popup {
  position: fixed;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  width: min(420px, calc(100vw - 16px));
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.18);
  padding: 8px;
  z-index: 30000;
  max-height: 60dvh;
  overflow-y: auto;
}

.more-actions-popup.hidden { display: none !important; }

.more-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  cursor: pointer;
  background: #fff;
  border: 0;
  text-align: left;
  font: inherit;
  color: var(--text);
}
.more-item:hover { background: #f8fafc; }
.more-item strong { font-weight: 600; }

.message audio { width: 100%; margin-top: 8px; }
.message .download-line {
  margin-top: 8px;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.message .download-line .file-name,
.file-name {
  font-size: 0.9rem;
  color: var(--muted);
  word-break: break-word;
}

.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 11000;
}

.popup-card {
  display: none;
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(760px, calc(100% - 20px));
  max-height: 90dvh;
  overflow: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 16px;
  z-index: 12500;
  overscroll-behavior: contain;
}

.popup-card.small { width: min(560px, calc(100% - 20px)); }

.popup-header {
  margin: 0 0 12px 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.popup-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.toast-root {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 20000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast-item {
  background: #111827;
  color: #fff;
  padding: 10px 14px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  max-width: 320px;
}

.alluser-item,
.notif-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  background: #fff;
  margin-bottom: 8px;
}

.avatar-small {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  vertical-align: middle;
  margin-right: 8px;
}

.icon-btn,
.top-icon-btn,
.tool-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
}

.icon-btn {
  width: 44px;
  height: 44px;
  padding: 0;
  font-size: 20px;
}

.icon-btn span { display: none; }

.icon-svg {
  width: 20px;
  height: 20px;
  display: block;
  flex: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.top-icon-btn .icon-svg { width: 21px; height: 21px; }
.tool-btn .icon-svg { width: 19px; height: 19px; }

.top-icon-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.top-icon-primary:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}

#notifBtn { position: relative; }

#notifBadge {
  display: inline-flex;
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 20px;
  height: 20px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 0.75rem;
  padding: 0 6px;
  line-height: 1;
}

#notifBtn.has-notifications {
  border-color: var(--line);
  background: #fff;
  color: inherit;
}

#notifBtn.has-notifications:hover {
  border-color: #cbd5e1;
  background: #fff;
  color: inherit;
}

body.chat-list-mode .main-area { display: none; }
body.chat-list-mode #sidebar { grid-column: 1 / -1; width: 100%; }
body.chat-conversation-open #sidebar { display: none; }
body.chat-conversation-open .main-area { display: flex; grid-column: 1 / -1; width: 100%; }
body.chat-conversation-open .chat-pane-header { display: flex; }

.call-room-shell {
  display: grid;
  grid-template-columns: minmax(0, 2fr) 380px;
  gap: 12px;
  min-height: 72vh;
}

.call-panel-card {
  border: 1px solid #e5e7eb;
  background: #fff;
  border-radius: 18px;
  padding: 12px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
}

.call-remote-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
}

.call-remote-tile {
  position: relative;
  min-height: 160px;
  background: #0f172a;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.call-remote-tile video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
}

.call-remote-badge {
  position: absolute;
  left: 8px;
  bottom: 8px;
  background: rgba(15, 23, 42, 0.72);
  color: #fff;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.82rem;
}

#callStage,
#callVideoContainer { min-height: 620px; }
#callRightPanel { min-width: 0; }

.call-drag-handle {
  width: 72px;
  height: 8px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.55);
  margin: 0 auto 10px auto;
  cursor: move;
  touch-action: none;
}
.call-drag-handle:hover { background: rgba(124, 58, 237, 0.65); }

#callHiddenAudioBox { display: none !important; }

#callRoomPopup,
#callCreatePopup,
#incomingCallPopup,
#callManagePopup { box-sizing: border-box; }

body.call-room-docked-active #popupOverlay {
  background: transparent !important;
  backdrop-filter: none !important;
  pointer-events: none !important;
}

#callRoomPopup {
  width: min(1040px, calc(100vw - 16px)) !important;
  max-width: min(1040px, calc(100vw - 16px)) !important;
  height: min(84dvh, 760px) !important;
  max-height: calc(100dvh - 16px) !important;
  padding: clamp(10px, 1.8vw, 18px);
  border-radius: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: auto !important;
  scrollbar-gutter: stable both-edges;
  z-index: var(--call-room-z);
}

#callRoomPopup.call-room-popup { background: #fff; }

#callRoomPopup.is-docked {
  position: fixed !important;
  right: 12px !important;
  bottom: 12px !important;
  left: auto !important;
  top: auto !important;
  transform: none !important;
  width: min(360px, calc(100vw - 24px)) !important;
  height: min(300px, 45vh) !important;
  max-width: min(420px, calc(100vw - 24px)) !important;
  max-height: min(320px, calc(100dvh - 24px)) !important;
  border-radius: 18px;
  z-index: var(--call-room-z);
  box-shadow: 0 22px 60px rgba(2, 6, 23, 0.35);
}

#callRoomPopup.is-docked #callStage { min-height: 150px !important; }

#callRoomPopup .call-room-header,
#incomingCallPopup .popup-header,
#callCreatePopup .popup-header,
#notificationPopup .popup-header,
#addFriendsPopup .popup-header,
#sharePopup .popup-header,
#groupManagePopup .popup-header,
#createGroupPopup .popup-header,
#settingsPopup .popup-header {
  cursor: move;
  user-select: none;
}

.call-room-topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.call-room-titleblock { min-width: 0; flex: 1 1 auto; }
.call-room-title-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  flex-wrap: wrap;
  min-width: 0;
}
.call-room-titlewrap { min-width: 0; }
.call-room-title {
  margin: 0;
  font-size: clamp(1rem, 2.6vw, 1.25rem);
  line-height: 1.2;
}
.call-room-meta {
  font-size: clamp(0.8rem, 1.8vw, 0.92rem);
  color: var(--call-muted);
}
.call-room-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.call-icon-btn,
.call-room-controls .btn,
.call-room-controls button,
.call-control-row .btn,
.call-control-row button {
  min-height: var(--call-control-size);
  padding: 0 clamp(10px, 2vw, 16px);
  font-size: var(--call-control-font);
  border-radius: 14px;
}
.call-icon-btn {
  min-width: var(--call-control-size);
  width: var(--call-control-size);
  justify-content: center;
  display: inline-flex;
  align-items: center;
  padding: 0;
  font-weight: 700;
}
.call-exit-btn { white-space: nowrap; }

#callStage {
  position: relative;
  border-radius: 22px;
  overflow: auto;
  background: linear-gradient(180deg, #07111f 0%, #0f172a 100%);
  min-height: clamp(220px, 35vh, 500px);
  box-shadow: var(--call-shadow);
  flex: 1 1 auto;
  min-width: 0;
}

#callVideoContainer,
.call-video-container {
  width: 100%;
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.call-video-container.docked { opacity: 1; }

.call-stage-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px;
  box-sizing: border-box;
}

.call-main-area {
  position: relative;
  flex: 1 1 auto;
  min-height: 240px;
  border-radius: 22px;
  overflow: hidden;
  background: #020617;
  border: 1px solid rgba(148, 163, 184, 0.18);
}

.call-stream-box {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 100%;
  background: #020617;
}

.call-stream-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background: #000;
}

.call-stream-video.is-self-mirror { transform: scaleX(-1); }

.call-stream-badge {
  position: absolute;
  left: 10px;
  top: 10px;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(15, 23, 42, 0.72);
  color: #fff;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: clamp(0.72rem, 1.8vw, 0.82rem);
  backdrop-filter: blur(8px);
}

.call-pip-stack {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 4;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(28vw, 220px);
  max-width: 220px;
}
.call-pip-stack .call-stream-box {
  aspect-ratio: 16 / 9;
  min-height: 0;
  height: auto;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.25);
}

.call-main-namebar {
  position: absolute;
  left: 12px;
  top: 12px;
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: rgba(2, 6, 23, 0.55);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  padding: 10px 12px;
  border-radius: 14px;
  max-width: min(80%, 520px);
}
.call-main-title {
  font-size: clamp(1rem, 2.3vw, 1.15rem);
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.call-main-sub {
  font-size: clamp(0.78rem, 1.8vw, 0.9rem);
  color: rgba(255, 255, 255, 0.8);
}

.call-thumb-strip {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: thin;
}
.call-thumb-item {
  flex: none;
  max-width: 220px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: rgba(255, 255, 255, 0.94);
  padding: 10px;
  border-radius: 16px;
  cursor: pointer;
  text-align: left;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.08);
}
.call-thumb-item:hover { transform: translateY(-1px); }
.call-thumb-item img {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  flex: none;
}
.call-thumb-item strong { display: block; font-size: 0.92rem; }
.call-thumb-item span {
  display: block;
  color: var(--call-muted);
  font-size: 0.78rem;
  margin-top: 2px;
}

.call-empty-state,
.call-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
  color: #fff;
  padding: 24px;
  box-sizing: border-box;
  background: radial-gradient(circle at top, rgba(124, 58, 237, 0.12), transparent 45%),
    linear-gradient(180deg, #07111f, #0b1220);
}
.call-placeholder-avatar {
  width: clamp(72px, 14vw, 100px);
  height: clamp(72px, 14vw, 100px);
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.18);
}
.call-placeholder-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.call-placeholder-title {
  font-size: clamp(1rem, 2.4vw, 1.2rem);
  font-weight: 700;
}
.call-placeholder-subtitle {
  font-size: clamp(0.84rem, 2vw, 0.95rem);
  color: rgba(255, 255, 255, 0.72);
  max-width: 32ch;
}

.call-control-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: center;
}
.call-control-row .btn.primary { background: var(--call-primary); }
.call-control-row .btn.primary:hover { background: var(--call-primary-2); }

#callParticipantsList,
#callManageFriendList,
#callManageParticipantsList {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}

.call-participant-tile {
  width: 100%;
  border: 1px solid #e6eaf1;
  background: #fff;
  border-radius: 18px;
  padding: 12px;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 10px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.call-participant-tile:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(15, 23, 42, 0.08);
}
.call-participant-tile.is-selected {
  border-color: var(--call-primary);
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.12);
}
.call-participant-tile-head {
  display: flex;
  gap: 10px;
  align-items: center;
  min-width: 0;
}
.call-participant-tile-meta {
  min-width: 0;
  flex: 1;
}
.call-participant-name-line {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}
.call-participant-name {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: clamp(0.95rem, 2vw, 1.02rem);
}
.call-participant-sub {
  color: var(--call-muted);
  font-size: clamp(0.78rem, 1.8vw, 0.88rem);
  margin-top: 2px;
}
.call-participant-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.call-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 9px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #0f172a;
  font-size: 0.76rem;
  line-height: 1;
}
.call-chip-green { background: rgba(34, 197, 94, 0.12); color: #166534; }
.call-chip-blue { background: rgba(14, 165, 233, 0.12); color: #075985; }
.call-chip-purple { background: rgba(124, 58, 237, 0.12); color: #6d28d9; }
.call-chip-dark { background: #e2e8f0; color: #334155; }

.call-avatar-sm {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: cover;
  flex: none;
}

.call-manage-row,
.call-friend-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid #eef2f7;
  background: #fff;
}
.call-manage-row-main,
.call-friend-meta {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.call-manage-row-title {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}
.call-manage-row-sub,
.call-friend-meta span {
  color: var(--call-muted);
  font-size: 0.8rem;
}
.call-manage-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.btn-xs {
  min-height: 34px !important;
  padding: 0 10px !important;
  border-radius: 10px !important;
  font-size: 0.76rem !important;
}
.btn-ghost {
  background: #f8fafc !important;
  border: 1px solid #e2e8f0 !important;
  color: #0f172a !important;
}
.btn-danger {
  background: #ef4444 !important;
  color: #fff !important;
}
.btn-danger:hover { background: #dc2626 !important; }

.call-invite-board {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 10000;
  width: min(360px, calc(100vw - 24px));
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.call-invite-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.12);
  border-radius: 18px;
  padding: 12px;
}
.call-invite-top { display: flex; gap: 10px; align-items: center; }
.call-invite-meta { display: flex; flex-direction: column; gap: 2px; }
.call-invite-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}

#callManagePopup {
  position: fixed;
  inset: 0;
  z-index: var(--call-manage-z);
  display: none;
}
#callManageOverlay {
  position: absolute;
  inset: 0;
  background: rgba(2, 6, 23, 0.55);
  backdrop-filter: blur(6px);
}
.call-manage-modal {
  position: absolute;
  inset: clamp(10px, 2vw, 24px);
  margin: auto;
  width: min(1080px, calc(100vw - 20px));
  max-width: min(1080px, calc(100vw - 20px));
  height: min(84dvh, 820px);
  max-height: calc(100dvh - 20px);
  background: #fff;
  border-radius: 24px;
  box-shadow: 0 30px 80px rgba(2, 6, 23, 0.35);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.call-manage-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 16px 18px 10px 18px;
  border-bottom: 1px solid #e8edf4;
}
.call-manage-headtext { min-width: 0; }
.call-manage-kicker {
  display: inline-flex;
  align-items: center;
  padding: 5px 9px;
  border-radius: 999px;
  background: rgba(124, 58, 237, 0.1);
  color: var(--call-primary-2);
  font-size: 0.75rem;
  font-weight: 700;
  margin-bottom: 8px;
}
.call-manage-title {
  margin: 0;
  font-size: clamp(1rem, 2.4vw, 1.2rem);
}
.call-manage-sub {
  color: var(--call-muted);
  font-size: 0.88rem;
  margin-top: 4px;
}
.call-manage-tabs {
  display: flex;
  gap: 8px;
  padding: 12px 18px 0 18px;
  flex-wrap: wrap;
}
.call-manage-tab {
  appearance: none;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  color: #0f172a;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 600;
}
.call-manage-tab.is-active {
  background: var(--call-primary);
  color: #fff;
  border-color: var(--call-primary);
}
.call-manage-body {
  flex: 1;
  min-height: 0;
  display: grid;
  gap: 0;
  padding: 12px 18px 0 18px;
}
.call-manage-pane {
  display: none;
  min-height: 0;
}
.call-manage-pane.is-active { display: flex; }
.call-manage-section {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  padding: 0;
}
.call-manage-section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.call-manage-section h4 { margin: 0; font-size: 1rem; }
.call-manage-section-note {
  color: var(--call-muted);
  font-size: 0.82rem;
}
.call-manage-section .section-scroll {
  overflow: auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-right: 2px;
  padding-bottom: 4px;
}
.call-manage-footer {
  padding: 14px 18px 18px 18px;
  border-top: 1px solid #e8edf4;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}
.call-manage-grid-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

#callManagePopup .btn,
#callManagePopup button { min-height: 40px; }
#callManagePopup .btn.btndangersmall { white-space: nowrap; }

#callCreatePopup,
#incomingCallPopup {
  width: min(720px, calc(100vw - 16px));
  max-width: min(720px, calc(100vw - 16px));
}
#callCreatePopup .popup-actions,
#incomingCallPopup .popup-actions,
#callManagePopup .popup-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

#callCreatePopup,
#incomingCallPopup,
#notificationPopup,
#addFriendsPopup,
#sharePopup,
#groupManagePopup,
#createGroupPopup,
#settingsPopup { z-index: 12500; }

#callRoomPopup .call-room-header,
#incomingCallPopup .popup-header,
#callCreatePopup .popup-header,
#notificationPopup .popup-header,
#addFriendsPopup .popup-header,
#sharePopup .popup-header,
#groupManagePopup .popup-header,
#createGroupPopup .popup-header,
#settingsPopup .popup-header {
  cursor: move;
  user-select: none;
}

.call-mini-launcher {
  position: fixed;
  right: 12px;
  bottom: 12px;
  z-index: 99999;
  display: none;
  align-items: center;
  gap: 8px;
  border: none;
  border-radius: 16px;
  padding: 10px 14px;
  background: rgba(15, 23, 42, 0.96);
  color: #fff;
  box-shadow: 0 14px 36px rgba(15, 23, 42, 0.22);
  cursor: pointer;
  pointer-events: auto;
}
.call-mini-launcher .call-mini-icon { font-size: 18px; line-height: 1; }

.file-hidden {
  position: fixed;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

@media (max-width: 1100px) {
  .call-room-shell { grid-template-columns: 1fr; }
  #callRightPanel { order: 2; }
}

@media (max-width: 980px) {
  .call-manage-body {
    grid-template-columns: 1fr;
    padding-inline: 12px;
  }
  .call-manage-modal {
    width: calc(100vw - 14px);
    max-width: calc(100vw - 14px);
    height: calc(100dvh - 14px);
    max-height: calc(100dvh - 14px);
    inset: 7px;
    border-radius: 20px;
  }
}

@media (max-width: 900px) {
  :root {
    --composer-h: var(--composer-h-mobile);
  }

  #layout {
    display: block;
    height: calc(100dvh - var(--app-header-h));
    min-height: calc(100dvh - var(--app-header-h));
    overflow: hidden;
  }

  #sidebar {
    width: 100% !important;
    min-width: 0 !important;
    max-height: none !important;
    height: calc(100dvh - var(--app-header-h));
    border-right: 0;
    border-bottom: 0;
  }

  .main-area {
    width: 100%;
    height: calc(100dvh - var(--app-header-h));
  }

  #messages {
    padding: 10px 10px calc(var(--composer-h) + 24px);
  }

  .message { max-width: 94%; }

  .topbar {
    min-height: auto;
    padding: 10px 12px;
    flex-wrap: wrap;
  }

  .brand strong { font-size: 1rem; }

  .header-actions {
    width: 100%;
    margin-left: 0;
  }

  .popup-card {
    width: calc(100% - 16px);
    max-height: 88dvh;
    padding: 14px;
  }

  .popup-card.small { width: calc(100% - 16px); }

  .chat-pane-header { display: flex; }

  .controls.sticky {
    left: 0;
    right: 0;
    width: 100vw;
    height: var(--composer-h);
    max-height: var(--composer-h);
    padding: 7px 8px calc(7px + env(safe-area-inset-bottom));
  }

  #callStage,
  #callVideoContainer { min-height: 420px !important; }
  #callRoomPopup { width: calc(100% - 16px) !important; }

  .msg-toolbar {
    grid-template-columns: 32px 32px 32px minmax(0, 1fr);
    gap: 4px;
    grid-auto-rows: 34px;
  }

  #recordBtn,
  #moreActionsBtn,
  #cancelRecordBtn,
  #sendBtn {
    width: 100%;
    min-width: 0;
    height: 34px;
  }

  #sendBtn {
    grid-column: auto;
    font-size: 0.82rem;
    padding-inline: 6px;
  }

  .more-actions-popup {
    width: min(420px, calc(100vw - 24px));
    max-height: 46dvh;
  }
}

@media (max-width: 768px) {
  :root {
    --composer-h: clamp(130px, 19dvh, 176px);
  }

  #callRoomPopup {
    width: calc(100vw - 12px) !important;
    max-width: calc(100vw - 12px) !important;
    height: calc(100dvh - 12px);
    max-height: calc(100dvh - 12px);
    margin: 0;
    padding: 12px;
    border-radius: 18px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
  }

  #callRoomPopup.is-docked {
    width: calc(100vw - 16px) !important;
    height: min(300px, calc(100dvh - 16px)) !important;
    right: 8px !important;
    bottom: 8px !important;
  }

  .call-room-topbar { gap: 10px; }
  .call-room-controls { justify-content: flex-start; }
  .call-room-shell { gap: 10px; }

  #callStage { min-height: clamp(220px, 46vh, 420px) !important; }

  .call-stage-wrap { padding: 10px; }
  .call-main-area {
    min-height: 200px;
    border-radius: 18px;
  }

  .call-pip-stack { width: min(38vw, 180px); }

  .call-control-row { justify-content: stretch; }
  .call-control-row .btn,
  .call-control-row button {
    flex: 1 1 calc(50% - 8px);
    min-width: 0;
  }

  .call-manage-modal {
    inset: 6px;
    width: calc(100vw - 12px);
    max-width: calc(100vw - 12px);
    height: calc(100dvh - 12px);
    border-radius: 18px;
  }

  .call-manage-header { padding: 14px 14px 10px 14px; }
  .call-manage-tabs { padding-inline: 14px; }
  .call-manage-body { padding-inline: 14px; }

  .controls.sticky {
    padding: 7px 8px calc(7px + env(safe-area-inset-bottom));
    gap: 5px;
    min-height: 0;
  }

  #msgContent {
    min-height: 50px;
    max-height: 74px;
    padding: 8px 10px;
  }

  .msg-toolbar {
    grid-template-columns: 30px 30px 30px minmax(0, 1fr);
    gap: 4px;
    grid-auto-rows: 32px;
  }

  #recordBtn,
  #moreActionsBtn,
  #cancelRecordBtn,
  #sendBtn {
    width: 100%;
    min-width: 0;
    height: 32px;
  }

  #sendBtn {
    grid-column: auto;
    font-size: 0.8rem;
    padding-inline: 6px;
  }

  #sendBtn .icon-svg {
    width: 14px;
    height: 14px;
  }

  .more-actions-popup {
    width: min(420px, calc(100vw - 20px));
    max-height: 48dvh;
  }
}

@media (max-width: 640px) {
  .controls.sticky {
    padding: 6px 7px calc(6px + env(safe-area-inset-bottom));
    gap: 4px;
    height: var(--composer-h);
    max-height: var(--composer-h);
  }

  #msgContent {
    min-height: 48px;
    max-height: 68px;
  }

  .msg-toolbar {
    grid-template-columns: 30px 30px 30px minmax(0, 1fr);
    gap: 3px;
    grid-auto-rows: 32px;
  }

  #recordBtn,
  #moreActionsBtn,
  #cancelRecordBtn {
    width: 100%;
    min-width: 0;
    height: 32px;
  }

  #sendBtn {
    grid-column: auto;
    width: 100%;
    min-height: 32px;
    font-size: 0.78rem;
    padding-inline: 6px;
  }

  #sendBtn .icon-svg {
    width: 14px;
    height: 14px;
  }

  .center { margin: 3vh auto; }

  .card,
  .popup-card.small,
  .popup-card { padding: 14px; }

  .btn { padding: 9px 12px; }

  .header-actions { gap: 6px; }
  .topbar { align-items: stretch; }
  .brand { width: 100%; }

  .toast-root {
    right: 10px;
    left: 10px;
    bottom: 10px;
  }

  .toast-item {
    max-width: none;
    width: 100%;
  }

  .chat-image-preview { max-height: 200px; }

   .more-actions-popup {
    width: min(420px, calc(100vw - 16px));
    max-height: 50dvh;
  }
}

@media (max-width: 480px) {
  :root {
    --composer-h: clamp(132px, 20dvh, 176px);
  }

  .controls.sticky {
    height: var(--composer-h);
    max-height: var(--composer-h);
  }

  #recordBtn,
  #moreActionsBtn,
  #cancelRecordBtn {
    width: 100%;
    min-width: 0;
    height: 32px;
    flex: 0 0 auto;
  }

  #sendBtn {
    min-height: 32px;
    width: 100%;
    min-width: 0;
    grid-column: auto;
  }

  .call-avatar-sm {
    width: 36px;
    height: 36px;
  }

  .call-participant-tile { padding: 10px; }

  .call-manage-row,
  .call-friend-row {
    grid-template-columns: auto minmax(0, 1fr);
    grid-auto-flow: row;
  }

  .call-manage-actions {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }

  .call-manage-actions .btn-xs { flex: 1 1 calc(50% - 4px); }
  .call-manage-footer { justify-content: stretch; }
  .call-manage-footer .btn { flex: 1 1 calc(50% - 8px); }

  .msg-toolbar {
    grid-template-columns: 30px 30px 30px minmax(0, 1fr);
    gap: 3px;
    grid-auto-rows: 30px;
  }

  #sendBtn {
    display: inline-flex !important;
  }

  #sendBtn .icon-svg {
    width: 14px;
    height: 14px;
  }

  .more-actions-popup {
    width: min(420px, calc(100vw - 12px));
    max-height: 52dvh;
  }
}