:root {
  --bg: #0b1016;
  --panel: #131b24;
  --panel-2: #1a2531;
  --border: #22303f;
  --text: #e7edf3;
  --text-dim: #8a99a8;
  --accent: #4da3ff;
  --accent-2: #7b5cff;
  --accent-dim: #22324a;
  --bubble-me: #2a5f8f;
  --bubble-them: #1d2936;
  --danger: #ff6b6b;
  --online: #3ddc84;
  --badge: #ff5a7a;
}

* { box-sizing: border-box; }

img.emoji {
  height: 1.25em;
  width: 1.25em;
  vertical-align: -0.22em;
  margin: 0 0.03em;
}

.emoji-popup img.emoji, .msg-actions img.emoji { height: 22px; width: 22px; margin: 0; }
.reaction-pill img.emoji { height: 14px; width: 14px; }
#reply-preview-body img.emoji, .contact-preview img.emoji, .quote-text img.emoji { height: 1.1em; width: 1.1em; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none;
}

/* custom scrollbars for a tighter, tech look */
* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
*::-webkit-scrollbar { width: 7px; height: 7px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }
*::-webkit-scrollbar-thumb:hover { background: var(--accent-dim); }

.screen { height: 100vh; width: 100vw; }

#auth-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.auth-card {
  width: 100%;
  max-width: 340px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px 24px;
  text-align: center;
}

.auth-card h1 {
  margin: 0 0 4px;
  letter-spacing: 1px;
  color: var(--accent);
  font-size: 26px;
}

.tagline {
  color: var(--text-dim);
  font-size: 13px;
  margin: 0 0 24px;
}

#auth-form { display: flex; flex-direction: column; gap: 10px; }

input {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 15px;
  outline: none;
}

input:focus { border-color: var(--accent); }

button {
  cursor: pointer;
  border: none;
  font-size: 15px;
}

#auth-submit {
  background: var(--accent);
  color: #0a1016;
  font-weight: 600;
  border-radius: 10px;
  padding: 12px;
  margin-top: 6px;
}

#auth-submit:hover { filter: brightness(1.08); }

.link-btn {
  background: none;
  color: var(--text-dim);
  margin-top: 16px;
  font-size: 13px;
  text-decoration: underline;
}

.error { color: var(--danger); font-size: 13px; min-height: 16px; margin: 4px 0 0; }
.success { color: var(--online); font-size: 13px; min-height: 16px; margin: 4px 0 0; }

#password-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#password-form button {
  background: var(--accent);
  color: #0a1016;
  font-weight: 600;
  border-radius: 10px;
  padding: 10px;
  margin-top: 2px;
}

#password-form button:hover { filter: brightness(1.08); }

#app-screen {
  display: flex;
}

#sidebar {
  width: 280px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}

.me-profile {
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  color: var(--text);
  font-weight: 600;
  font-size: 14px;
  padding: 4px;
  border-radius: 8px;
}

.me-profile:hover { background: var(--panel-2); }

.avatar-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-dim);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
  overflow: hidden;
}

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

.avatar-circle.large { width: 72px; height: 72px; font-size: 24px; }

.contact-tagline,
.contact-preview {
  font-size: 12.5px;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 1px;
}

.contact-preview .from-me { color: var(--text-dim); }

.contact-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.contact-row-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
}

.contact-time {
  font-size: 11px;
  color: var(--text-dim);
  flex-shrink: 0;
}

.contact-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 5px;
  flex-shrink: 0;
}

.unread-badge {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--badge);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

#logout-btn, #add-user-btn {
  background: none;
  color: var(--text-dim);
  font-size: 16px;
  padding: 2px 4px;
}

.add-user-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--panel-2);
}

.add-user-form input { font-size: 13px; padding: 9px 11px; }

.add-user-form button {
  background: var(--accent);
  color: #0a1016;
  font-weight: 600;
  border-radius: 8px;
  padding: 8px;
}

.search-wrap {
  position: relative;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}

.search-icon {
  position: absolute;
  left: 24px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  opacity: 0.55;
  pointer-events: none;
  filter: grayscale(1);
}

#contact-search {
  width: 100%;
  padding: 8px 12px 8px 34px;
  border-radius: 10px;
  font-size: 13.5px;
  background: var(--panel-2);
}

#contact-list { overflow-y: auto; flex: 1; }

.contact {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  border-left: 3px solid transparent;
  transition: background 0.12s, border-color 0.12s;
}

.contact:hover { background: var(--panel-2); }
.contact.active { background: var(--panel-2); border-left-color: var(--accent); }

.contact-name { flex: 1; font-size: 14.5px; }

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--text-dim);
  flex-shrink: 0;
}

.status-dot.online {
  background: var(--online);
  box-shadow: 0 0 0 0 rgba(61, 220, 132, 0.6);
  animation: pulse-online 2.2s infinite;
}

@keyframes pulse-online {
  0% { box-shadow: 0 0 0 0 rgba(61, 220, 132, 0.45); }
  70% { box-shadow: 0 0 0 6px rgba(61, 220, 132, 0); }
  100% { box-shadow: 0 0 0 0 rgba(61, 220, 132, 0); }
}

#conversation {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.conv-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}

#conv-header-avatar:empty { display: none; }

.conv-header-text {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

#conv-title {
  font-weight: 600;
  font-size: 15px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#conv-subtitle {
  font-size: 11.5px;
  color: var(--text-dim);
}

.back-btn {
  display: none;
  background: none;
  color: var(--text);
  font-size: 20px;
}

#messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background-image: radial-gradient(circle, rgba(77, 163, 255, 0.06) 1px, transparent 1px);
  background-size: 22px 22px;
}

.msg-row { display: flex; margin-top: 10px; animation: msg-in 0.18s ease-out; }
.msg-row.grouped { margin-top: 2px; }
.msg-row.me { justify-content: flex-end; }

@keyframes msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.bubble-col {
  display: flex;
  flex-direction: column;
  max-width: 70%;
}

.msg-row.me .bubble-col { align-items: flex-end; margin-left: auto; }
.msg-row:not(.me) .bubble-col { align-items: flex-start; }

.bubble {
  position: relative;
  max-width: 100%;
  padding: 8px 12px;
  border-radius: 14px;
  background: var(--bubble-them);
  font-size: 14.5px;
  line-height: 1.4;
  word-wrap: break-word;
  white-space: pre-wrap;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  cursor: pointer;
  transition: box-shadow 0.3s;
}

.bubble.flash { box-shadow: 0 0 0 2px var(--accent); }

.bubble-reply-quote {
  background: rgba(0, 0, 0, 0.22);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  padding: 4px 8px;
  margin-bottom: 5px;
  font-size: 12.5px;
  cursor: pointer;
}

.bubble-reply-quote .quote-name { color: var(--accent); font-weight: 600; font-size: 11.5px; }

.bubble-reply-quote .quote-text {
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.msg-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-top: 5px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 3px 5px;
}

.msg-actions button {
  background: none;
  font-size: 17px;
  padding: 3px 6px;
  border-radius: 8px;
  line-height: 1;
}

.msg-actions button:hover { background: var(--panel); }
.msg-actions .reply-action { font-size: 13px; color: var(--text-dim); }

.reactions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.reaction-pill {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12px;
  cursor: pointer;
}

.reaction-pill.mine { border-color: var(--accent); background: var(--accent-dim); }
.reaction-pill .count { color: var(--text-dim); font-size: 11px; }
.reaction-pill.mine .count { color: var(--accent); }

.msg-row.me .bubble { background: var(--bubble-me); }

.msg-row:not(.grouped) .bubble::after {
  content: "";
  position: absolute;
  top: 0;
  width: 10px;
  height: 12px;
  background: inherit;
}

.msg-row:not(.me):not(.grouped) .bubble::after {
  left: -5px;
  border-bottom-right-radius: 14px;
  clip-path: polygon(100% 0, 0 0, 100% 100%);
}

.msg-row.me:not(.grouped) .bubble::after {
  right: -5px;
  border-bottom-left-radius: 14px;
  clip-path: polygon(0 0, 100% 0, 0 100%);
}

.bubble .meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 3px;
  font-size: 10.5px;
  color: var(--text-dim);
  margin-top: 3px;
}

.bubble .meta .tick { color: rgba(255, 255, 255, 0.55); font-size: 12px; line-height: 1; }
.bubble .meta .tick.tick-read { color: #6fd6ff; }

.bubble img.attachment {
  max-width: 260px;
  max-height: 320px;
  border-radius: 10px;
  display: block;
  margin-top: 4px;
  cursor: pointer;
  object-fit: cover;
}

.bubble video.attachment {
  max-width: 280px;
  max-height: 320px;
  border-radius: 10px;
  display: block;
  margin-top: 4px;
  background: #000;
}

.audio-player {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  width: 240px;
  max-width: 100%;
  background: #f1f3f4;
  border-radius: 20px;
  padding: 6px 12px 6px 6px;
  color: #3c4043;
}

.audio-play-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #fff;
  color: #3c4043;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 0;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

.audio-play-btn:hover { background: #e8eaed; }
.audio-play-btn svg { margin-left: 1px; }

.audio-progress-wrap { flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; }

.audio-progress-bar {
  position: relative;
  flex: 1;
  height: 3px;
  background: #c8cbcf;
  border-radius: 2px;
  cursor: pointer;
}

.audio-progress-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0%;
  background: #5f6368;
  border-radius: 2px;
}

.audio-progress-handle {
  position: absolute;
  top: 50%;
  left: 0%;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #3c4043;
  transform: translate(-50%, -50%);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.audio-time {
  font-size: 11px;
  color: #5f6368;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.audio-volume-btn {
  background: none;
  color: #5f6368;
  width: 18px;
  height: 18px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.bubble a.file-card {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.18);
  border-radius: 10px;
  text-decoration: none;
  color: inherit;
  min-width: 200px;
}

.file-card-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--accent-dim);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  flex-shrink: 0;
}

.file-card-info { min-width: 0; flex: 1; }

.file-card-name {
  font-size: 13.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-card-size { font-size: 11px; color: var(--text-dim); margin-top: 1px; }

.lightbox-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  padding: 24px;
  cursor: zoom-out;
}

.lightbox-overlay img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 6px;
  object-fit: contain;
}

#send-form {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
}

#attach-btn, #emoji-btn, #camera-btn {
  background: var(--panel-2);
  color: var(--text-dim);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 16px;
  transition: filter 0.15s, transform 0.1s;
}

#attach-btn:hover, #emoji-btn:hover, #camera-btn:hover { filter: brightness(1.2); }
#attach-btn:active, #emoji-btn:active, #camera-btn:active { transform: scale(0.94); }

.emoji-popup {
  position: absolute;
  bottom: 70px;
  left: 14px;
  width: 280px;
  max-height: 220px;
  overflow-y: auto;
  background: rgba(19, 27, 36, 0.97);
  backdrop-filter: blur(6px);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 8px;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  z-index: 15;
  box-shadow: 0 10px 30px -8px rgba(0, 0, 0, 0.5);
}

.emoji-popup button {
  background: none;
  font-size: 20px;
  padding: 5px;
  border-radius: 8px;
  line-height: 1;
}

.emoji-popup button:hover { background: var(--panel-2); }

#conversation { position: relative; }

.reply-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: var(--panel-2);
  border-top: 1px solid var(--border);
}

.reply-preview-bar {
  width: 3px;
  align-self: stretch;
  background: var(--accent);
  border-radius: 2px;
  flex-shrink: 0;
}

.reply-preview-text { flex: 1; min-width: 0; }

#reply-preview-name { font-size: 12.5px; font-weight: 600; color: var(--accent); }

#reply-preview-body {
  font-size: 12.5px;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#reply-preview-cancel {
  background: none;
  color: var(--text-dim);
  font-size: 14px;
  flex-shrink: 0;
}

#message-input {
  flex: 1;
  background: #fff;
  color: #1a1a1a;
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 16px 20px;
  font-size: 15px;
  resize: vertical;
  font-family: inherit;
  min-height: 52px;
  max-height: 170px;
  overflow-y: auto;
  line-height: 1.4;
}

#message-input:focus { border-color: var(--accent); }
#message-input::placeholder { color: #8a8a8a; }

#send-btn { flex-shrink: 0; }

#send-btn {
  background: var(--accent);
  color: #0a1016;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: filter 0.15s, transform 0.1s;
}

#send-btn:hover:not(:disabled) { filter: brightness(1.08); }
#send-btn:active:not(:disabled) { transform: scale(0.94); }

#send-btn:disabled, #message-input:disabled { opacity: 0.5; }

#mic-btn {
  background: var(--panel-2);
  color: var(--text-dim);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: filter 0.15s, transform 0.1s;
}

#mic-btn:hover:not(:disabled) { filter: brightness(1.2); }
#mic-btn:active:not(:disabled) { transform: scale(0.94); }
#mic-btn:disabled { opacity: 0.5; }

#recording-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
}

#recording-cancel {
  background: none;
  color: var(--text-dim);
  font-size: 16px;
  flex-shrink: 0;
}

.recording-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--danger);
  flex-shrink: 0;
  animation: pulse-rec 1.1s infinite;
}

@keyframes pulse-rec {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

#recording-time {
  font-variant-numeric: tabular-nums;
  font-size: 14px;
  color: var(--text);
  flex-shrink: 0;
}

.recording-hint {
  flex: 1;
  color: var(--text-dim);
  font-size: 13px;
}

#recording-stop {
  background: var(--accent);
  color: #0a1016;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.pending-file {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: var(--panel-2);
  border-top: 1px solid var(--border);
  font-size: 13px;
}

.pending-file button {
  background: none;
  color: var(--danger);
  font-size: 15px;
}

.empty-hint {
  color: var(--text-dim);
  text-align: center;
  margin-top: 40px;
  font-size: 14px;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 12, 0.6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  padding: 20px;
  animation: fade-in 0.15s ease-out;
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-card {
  width: 100%;
  max-width: 420px;
  max-height: 85vh;
  overflow-y: auto;
  background: rgba(19, 27, 36, 0.92);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 20px 60px -15px rgba(0, 0, 0, 0.6);
  animation: modal-in 0.18s ease-out;
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: rgba(19, 27, 36, 0.92);
  backdrop-filter: blur(6px);
}

.modal-header h2 { margin: 0; font-size: 17px; }

.modal-close {
  background: none;
  color: var(--text-dim);
  font-size: 16px;
}

.modal-body { padding: 20px; display: flex; flex-direction: column; gap: 10px; }

.modal-body h3 { margin: 0 0 4px; font-size: 14px; color: var(--text-dim); }

.modal-divider { border: none; border-top: 1px solid var(--border); margin: 10px 0; }

.avatar-edit {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 6px;
}

.avatar-edit-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.btn-secondary {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 13px;
}

.avatar-edit-actions .link-btn { margin-top: 0; font-size: 12px; color: var(--danger); }

.field-label { font-size: 12px; color: var(--text-dim); margin-top: 4px; }

#profile-save-btn {
  background: var(--accent);
  color: #0a1016;
  font-weight: 600;
  border-radius: 10px;
  padding: 10px;
  margin-top: 4px;
}

#profile-save-btn:hover { filter: brightness(1.08); }

#files-library-list { display: flex; flex-direction: column; gap: 6px; max-height: 240px; overflow-y: auto; }

.lib-file {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--panel-2);
  border-radius: 10px;
  font-size: 13px;
  text-decoration: none;
  color: var(--text);
}

.lib-file-info { flex: 1; min-width: 0; }

.lib-file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.lib-file-meta { font-size: 11px; color: var(--text-dim); }

@media (max-width: 720px) {
  #sidebar {
    width: 100%;
    position: absolute;
    inset: 0;
    z-index: 2;
  }
  #app-screen.chat-open #sidebar { display: none; }
  #conversation { width: 100%; }
  #app-screen:not(.chat-open) #conversation { display: none; }
  .back-btn { display: inline-block; }
}

/* ---------- Calls ---------- */

.call-header-btn {
  background: var(--panel-2);
  color: var(--text-dim);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-left: 4px;
  transition: filter 0.15s;
}

.call-header-btn:hover:not(:disabled) { filter: brightness(1.2); color: var(--accent); }
.call-header-btn:disabled { opacity: 0.4; }

.call-overlay {
  position: fixed;
  inset: 0;
  background: linear-gradient(180deg, #0c1016 0%, #151d26 100%);
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 48px 24px calc(36px + env(safe-area-inset-bottom));
}

.call-remote-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
  display: none;
}

.call-remote-video.active { display: block; }

.call-info {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-top: 10vh;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

.call-info .avatar-circle.large { width: 96px; height: 96px; font-size: 32px; }

.call-peer-name { font-size: 22px; font-weight: 700; }
.call-status-text { font-size: 14px; color: var(--text-dim); }

.call-local-video {
  position: absolute;
  bottom: 120px;
  right: 18px;
  width: 92px;
  height: 130px;
  object-fit: cover;
  border-radius: 12px;
  background: #000;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  z-index: 2;
  display: none;
}

.call-local-video.active { display: block; }

.call-controls {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 22px;
}

.call-btn {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  color: #fff;
  transition: filter 0.15s, transform 0.1s;
}

.call-btn:active { transform: scale(0.94); }

.call-btn-accept { background: var(--online); }
.call-btn-danger { background: var(--danger); }
.call-btn-secondary { background: rgba(255, 255, 255, 0.18); }
.call-btn-secondary.on { background: #fff; color: #0a1016; }

@media (max-width: 720px) {
  .call-overlay { padding: 36px 20px calc(28px + env(safe-area-inset-bottom)); }
  .call-info { margin-top: 8vh; }
}
