:root {
  --bg-main: #0f172a;
  --bg-sidebar: #1e293b;
  --bg-chat: #0b1120;
  --bg-input: #1e293b;
  --bg-card: #1e293b;
  --border-color: #334155;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --bubble-me: #2563eb;
  --bubble-other: #1e293b;
  --radius: 12px;
  --transition: all 0.2s ease-in-out;
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-main);
  color: var(--text-main);
  height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* =========================================
   Auth Screen
   ========================================= */
.auth-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: radial-gradient(circle at top right, #1e1b4b, #0f172a 60%);
  padding: 20px;
}

.auth-card {
  background: rgba(30, 41, 59, 0.7);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  width: 100%;
  max-width: 440px;
  padding: 36px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.auth-header {
  text-align: center;
  margin-bottom: 28px;
}

.brand-badge {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  padding: 8px 16px;
  border-radius: 9999px;
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 16px;
}

.auth-header h2 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 8px;
  letter-spacing: -0.5px;
}

.auth-header p {
  color: var(--text-muted);
  font-size: 13px;
}

.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.form-group input {
  width: 100%;
  background: #0f172a;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 12px 14px;
  color: #fff;
  font-size: 16px; /* 16px prevents iOS Safari auto-zoom on focus */
  outline: none;
  transition: var(--transition);
}

.form-group input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 600;
  border-radius: 10px;
  cursor: pointer;
  border: none;
  padding: 10px 18px;
  font-size: 14px;
  transition: var(--transition);
}

.btn-block {
  width: 100%;
  padding: 12px;
  font-size: 15px;
  margin-top: 6px;
}

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

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
  border-radius: 8px;
}

.alert-error {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 16px;
}

.auth-switch {
  margin-top: 20px;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
}

.auth-switch a {
  color: #60a5fa;
  text-decoration: none;
  font-weight: 600;
  margin-left: 6px;
}

.auth-switch a:hover {
  text-decoration: underline;
}

/* =========================================
   Main App Screen
   ========================================= */
.main-wrapper {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: 360px;
  min-width: 320px;
  max-width: 420px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  height: 100%;
  z-index: 10;
}

.user-profile-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: rgba(15, 23, 42, 0.4);
  border-bottom: 1px solid var(--border-color);
}

.user-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 17px;
  color: #fff;
  flex-shrink: 0;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.2);
}

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

.user-nickname {
  font-weight: 600;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-status-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.user-tag {
  color: var(--text-dim);
  font-size: 11px;
}

.status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-dim);
  display: inline-block;
  flex-shrink: 0;
}

.status-indicator.online {
  background: var(--success);
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.6);
}

.profile-actions {
  display: flex;
  gap: 6px;
}

.icon-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

/* Nav Tabs */
.nav-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-color);
  padding: 4px 8px;
  gap: 4px;
}

.nav-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 10px 6px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  position: relative;
  transition: var(--transition);
}

.nav-tab:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.04);
}

.nav-tab.active {
  color: #60a5fa;
  background: rgba(59, 130, 246, 0.12);
}

.badge {
  background: var(--primary);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 9999px;
  min-width: 18px;
  text-align: center;
}

.badge-warning {
  background: var(--warning);
  color: #000;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 16px 8px;
  padding: 8px 12px;
  background: #0f172a;
  border: 1px solid var(--border-color);
  border-radius: 10px;
}

.search-box input {
  background: transparent;
  border: none;
  outline: none;
  color: #fff;
  font-size: 13px;
  width: 100%;
}

.search-box svg {
  color: var(--text-dim);
  flex-shrink: 0;
}

/* Sidebar Tab Panes */
.sidebar-content {
  flex: 1;
  overflow-y: auto;
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
}

.section-container {
  padding: 10px 0;
}

.section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dim);
  padding: 8px 16px 4px;
}

.section-tip {
  font-size: 12px;
  color: var(--text-muted);
  background: rgba(59, 130, 246, 0.08);
  border-left: 3px solid var(--primary);
  padding: 8px 12px;
  margin: 10px 16px;
  border-radius: 0 6px 6px 0;
}

/* Items list */
.item-list {
  display: flex;
  flex-direction: column;
}

.list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  transition: var(--transition);
  border-left: 3px solid transparent;
}

.list-item:hover {
  background: rgba(255, 255, 255, 0.04);
}

.list-item.active {
  background: rgba(59, 130, 246, 0.12);
  border-left-color: var(--primary);
}

.item-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
  color: #fff;
  position: relative;
  flex-shrink: 0;
}

.item-avatar .avatar-status {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 2px solid var(--bg-sidebar);
}

.item-details {
  flex: 1;
  min-width: 0;
}

.item-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 3px;
}

.item-name {
  font-weight: 600;
  font-size: 14px;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.item-preview {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item-action-btn {
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  border: none;
  flex-shrink: 0;
  transition: var(--transition);
}

/* Chat Stage */
.chat-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-chat);
  height: 100%;
  position: relative;
  overflow: hidden;
}

.chat-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--text-muted);
  padding: 24px;
}

.chat-empty .empty-icon {
  margin-bottom: 20px;
  color: var(--text-dim);
}

.chat-empty h3 {
  color: #fff;
  font-size: 20px;
  margin-bottom: 8px;
}

.chat-empty p {
  font-size: 14px;
  line-height: 1.6;
  max-width: 440px;
}

.chat-window {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* Chat Header */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border-color);
  z-index: 5;
}

.chat-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chat-header-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  color: #fff;
}

.chat-header-title {
  font-weight: 600;
  font-size: 16px;
  color: #fff;
}

.chat-header-subtitle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.chat-header-actions {
  display: flex;
  gap: 10px;
}

.btn-call {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
}

.btn-call:hover {
  background: rgba(16, 185, 129, 0.25);
  color: #6ee7b7;
}

.btn-call-video {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  border-color: rgba(59, 130, 246, 0.3);
}

.btn-call-video:hover {
  background: rgba(59, 130, 246, 0.25);
  color: #93c5fd;
}

/* Messages Container */
.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  scroll-behavior: smooth;
}

.messages-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.msg-row {
  display: flex;
  gap: 12px;
  max-width: 80%;
}

.msg-row.me {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.msg-row.other {
  align-self: flex-start;
}

.msg-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  margin-top: 2px;
}

.msg-bubble-wrapper {
  display: flex;
  flex-direction: column;
}

.msg-row.me .msg-bubble-wrapper {
  align-items: flex-end;
}

.msg-sender {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.msg-bubble {
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
  position: relative;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.msg-row.me .msg-bubble {
  background: var(--bubble-me);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.msg-row.other .msg-bubble {
  background: var(--bubble-other);
  color: var(--text-main);
  border-bottom-left-radius: 4px;
  border: 1px solid var(--border-color);
}

.msg-time {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 4px;
}

/* Message Media Types */
.msg-bubble img.msg-image {
  max-width: 320px;
  max-height: 320px;
  border-radius: 8px;
  cursor: pointer;
  display: block;
  transition: transform 0.2s ease;
}

.msg-bubble img.msg-image:hover {
  transform: scale(1.02);
}

/* Voice Message Bubble Player */
.voice-bubble-player {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 160px;
  cursor: pointer;
}

.voice-play-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: var(--transition);
}

.voice-play-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

.voice-wave-bars {
  display: flex;
  align-items: center;
  gap: 3px;
  flex: 1;
  height: 24px;
}

.voice-wave-bars span {
  width: 3px;
  background: rgba(255, 255, 255, 0.6);
  border-radius: 2px;
  height: 12px;
  transition: height 0.2s ease;
}

.voice-bubble-player.playing .voice-wave-bars span:nth-child(2n) {
  animation: waveAnim 0.6s infinite ease-in-out alternate;
}

.voice-bubble-player.playing .voice-wave-bars span:nth-child(2n+1) {
  animation: waveAnim 0.8s infinite ease-in-out alternate;
}

@keyframes waveAnim {
  0% { height: 4px; }
  100% { height: 22px; }
}

.voice-duration {
  font-size: 13px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.9);
}

/* Chat Footer & Input */
.chat-footer {
  background: var(--bg-sidebar);
  border-top: 1px solid var(--border-color);
  padding: 12px 20px;
}

.input-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.tool-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.tool-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.security-badge {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text-dim);
  background: rgba(16, 185, 129, 0.08);
  padding: 4px 8px;
  border-radius: 6px;
}

.security-badge svg {
  color: var(--success);
}

.input-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: #0f172a;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 8px 12px;
}

.input-row textarea {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: #fff;
  font-size: 16px; /* 16px prevents iOS Safari auto-zoom on focus */
  font-family: inherit;
  resize: none;
  max-height: 120px;
  min-height: 24px;
  line-height: 24px;
}

.btn-send {
  padding: 8px 12px;
  border-radius: 8px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Voice Recorder Live Bar */
.voice-recorder-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 12px;
}

.record-pulse-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--danger);
  animation: pulse 1.2s infinite ease-in-out;
}

@keyframes pulse {
  0% { transform: scale(0.9); opacity: 0.8; }
  50% { transform: scale(1.3); opacity: 1; }
  100% { transform: scale(0.9); opacity: 0.8; }
}

.record-timer {
  font-size: 15px;
  font-weight: 700;
  color: #fca5a5;
  font-variant-numeric: tabular-nums;
}

.record-waveform {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  height: 20px;
}

.record-waveform .bar {
  width: 4px;
  height: 8px;
  background: #ef4444;
  border-radius: 2px;
  animation: waveAnim 0.7s infinite alternate ease-in-out;
}

.record-waveform .bar:nth-child(2) { animation-delay: 0.1s; }
.record-waveform .bar:nth-child(3) { animation-delay: 0.2s; }
.record-waveform .bar:nth-child(4) { animation-delay: 0.3s; }
.record-waveform .bar:nth-child(5) { animation-delay: 0.4s; }
.record-waveform .bar:nth-child(6) { animation-delay: 0.5s; }
.record-waveform .bar:nth-child(7) { animation-delay: 0.6s; }
.record-waveform .bar:nth-child(8) { animation-delay: 0.7s; }

/* =========================================
   Modals
   ========================================= */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  width: 100%;
  max-width: 480px;
  padding: 24px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.modal-close {
  background: transparent;
  border: none;
  font-size: 24px;
  color: var(--text-muted);
  cursor: pointer;
}

.select-member-list {
  max-height: 240px;
  overflow-y: auto;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 8px;
  margin-top: 8px;
}

.member-checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: 6px;
  cursor: pointer;
}

.member-checkbox-row:hover {
  background: rgba(255, 255, 255, 0.05);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
}

/* Lightbox */
.lightbox-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1200;
}

.lightbox-content {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
}

.lightbox-content img {
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: 8px;
}

.lightbox-close {
  position: absolute;
  top: -40px;
  right: 0;
  background: transparent;
  border: none;
  color: #fff;
  font-size: 32px;
  cursor: pointer;
}

/* =========================================
   WebRTC Call Modals & Overlay
   ========================================= */
.call-modal .call-dialog-card {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 20px;
  padding: 32px;
  text-align: center;
  max-width: 380px;
  width: 100%;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
  animation: dropIn 0.3s ease-out;
}

@keyframes dropIn {
  0% { transform: translateY(-20px); opacity: 0; }
  100% { transform: translateY(0); opacity: 1; }
}

.caller-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 16px;
  box-shadow: 0 0 20px rgba(59, 130, 246, 0.4);
}

.call-dialog-card h3 {
  font-size: 20px;
  margin-bottom: 6px;
}

.call-dialog-card p {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 14px;
}

.call-encryption-tag {
  font-size: 11px;
  color: #34d399;
  background: rgba(16, 185, 129, 0.1);
  padding: 6px 12px;
  border-radius: 9999px;
  display: inline-block;
  margin-bottom: 24px;
}

.call-actions-row {
  display: flex;
  justify-content: center;
  gap: 32px;
}

.btn-circle {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #fff;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.btn-circle:hover {
  transform: scale(1.1);
}

.btn-accept {
  background: var(--success);
  box-shadow: 0 8px 16px rgba(16, 185, 129, 0.4);
}

.btn-reject {
  background: var(--danger);
  box-shadow: 0 8px 16px rgba(239, 68, 68, 0.4);
}

/* Active Call Overlay (Screen filling) */
.active-call-overlay {
  position: fixed;
  inset: 0;
  background: #020617;
  z-index: 1100;
  display: flex;
  flex-direction: column;
}

.video-stage {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #000;
}

.remote-video-el {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.audio-call-visualizer {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
}

.pulse-ring {
  position: absolute;
  width: 160px;
  height: 160px;
  border-radius: 50%;
  border: 2px solid rgba(59, 130, 246, 0.4);
  animation: ripple 2s infinite ease-out;
}

@keyframes ripple {
  0% { transform: scale(0.8); opacity: 1; }
  100% { transform: scale(1.6); opacity: 0; }
}

.pulse-avatar {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  font-weight: 700;
  color: #fff;
  z-index: 2;
  box-shadow: 0 0 30px rgba(59, 130, 246, 0.5);
}

.pulse-name {
  margin-top: 20px;
  font-size: 18px;
  font-weight: 600;
  color: #fff;
  z-index: 2;
}

/* Local Picture-In-Picture View */
.local-pip-container {
  position: absolute;
  bottom: 24px;
  right: 24px;
  width: 220px;
  height: 140px;
  background: #1e293b;
  border-radius: 12px;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  z-index: 10;
}

.local-video-el {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1); /* Mirror camera */
}

.pip-label {
  position: absolute;
  bottom: 6px;
  left: 8px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
}

/* Call Controls Bottom Bar */
.call-control-bar {
  height: 90px;
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  z-index: 20;
}

.call-meta-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.call-timer {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  font-variant-numeric: tabular-nums;
}

.call-badge {
  font-size: 11px;
  color: #34d399;
  background: rgba(16, 185, 129, 0.15);
  padding: 4px 8px;
  border-radius: 4px;
}

.call-buttons {
  display: flex;
  align-items: center;
  gap: 18px;
}

.call-tool-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #334155;
  border: none;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
}

.call-tool-btn:hover {
  background: #475569;
}

.call-tool-btn.btn-hangup {
  background: var(--danger);
}

.call-tool-btn.btn-hangup:hover {
  background: #dc2626;
}

/* ========================================== */
/* Group Announcement Pinned Bar              */
/* ========================================== */
.group-announcement-bar {
  background: linear-gradient(90deg, rgba(30, 41, 59, 0.95), rgba(15, 23, 42, 0.95));
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
  backdrop-filter: blur(10px);
  position: relative;
  z-index: 25;
  transition: all 0.25s ease;
}

.announcement-bar-main {
  display: flex;
  align-items: center;
  padding: 8px 16px;
  gap: 12px;
  min-height: 42px;
}

.announcement-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(59, 130, 246, 0.15);
  border: 1px solid rgba(59, 130, 246, 0.35);
  color: #60a5fa;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  flex-shrink: 0;
  letter-spacing: 0.3px;
}

.announcement-content {
  flex: 1;
  min-width: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  user-select: none;
}

.announcement-text {
  font-size: 13px;
  color: #e2e8f0;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: max-height 0.25s ease;
}

.group-announcement-bar.is-expanded .announcement-text {
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 240px;
  overflow-y: auto;
  padding: 4px 0;
  user-select: text;
}

.announcement-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.announcement-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #cbd5e1;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.announcement-btn:hover {
  background: rgba(59, 130, 246, 0.2);
  border-color: rgba(59, 130, 246, 0.4);
  color: #60a5fa;
}

.announcement-toggle-btn {
  background: transparent;
  border: none;
  color: #94a3b8;
  padding: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: transform 0.2s ease, color 0.15s ease;
}

.announcement-toggle-btn:hover {
  color: #f8fafc;
  background: rgba(255, 255, 255, 0.06);
}

.announcement-chevron {
  transition: transform 0.25s ease;
}

.group-announcement-bar.is-expanded .announcement-chevron {
  transform: rotate(180deg);
}

/* Header Invite Member Button */
.btn-invite-member {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.35);
  color: #34d399;
  padding: 5px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-invite-member:hover {
  background: rgba(16, 185, 129, 0.25);
  border-color: rgba(16, 185, 129, 0.5);
  color: #10b981;
}

/* Modal Textarea */
.modal-textarea {
  width: 100%;
  box-sizing: border-box;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: #fff;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  line-height: 1.5;
  outline: none;
  transition: border-color 0.2s ease;
}

.modal-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

/* ==========================================================================
   Apple iOS Safari & PWA Viewport Optimization
   ========================================================================== */
html, body {
  height: 100dvh;
  min-height: -webkit-fill-available;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

.chat-header {
  padding-top: max(12px, env(safe-area-inset-top, 12px));
}

.chat-footer {
  padding-bottom: max(12px, calc(10px + env(safe-area-inset-bottom, 0px)));
}

.mobile-bottom-nav {
  padding-bottom: max(6px, env(safe-area-inset-bottom, 0px));
}
