/* ═══════════════════════════════════════════════════
   OYEOO — Messagerie Chiffrée · WhatsApp-like Design
   ═══════════════════════════════════════════════════ */

:root {
  --bg-primary: #f5f0eb;
  --bg-secondary: #fffbf7;
  --bg-chat: #faf7f4;
  --bg-input: #ffffff;
  --bg-sidebar: #f0ebe5;
  --bg-hover: rgba(0, 0, 0, 0.04);
  --text-primary: #1a1715;
  --text-secondary: #6b6560;
  --text-tertiary: #9e9590;
  --text-inverse: #ffffff;
  --accent: #c96442;
  --accent-hover: #b35638;
  --accent-soft: rgba(201, 100, 66, 0.08);
  --accent-glow: rgba(201, 100, 66, 0.15);
  --msg-own: #c96442;
  --msg-own-text: #ffffff;
  --msg-other: #ffffff;
  --msg-other-text: #1a1715;
  --border: rgba(0, 0, 0, 0.08);
  --border-strong: rgba(0, 0, 0, 0.14);
  --success: #3d8c5c;
  --error: #c94442;
  --warning: #c98c42;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-xl: 24px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.06);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.08);
  --font-body: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --panel-left-width: 360px;
}

/* ─── Dark Theme ─── */
[data-theme="dark"] {
  --bg-primary: #1a1715;
  --bg-secondary: #242220;
  --bg-chat: #1e1c1a;
  --bg-input: #2a2826;
  --bg-sidebar: #1e1c1a;
  --bg-hover: rgba(255,255,255,0.06);
  --text-primary: #e8e4e0;
  --text-secondary: #a09890;
  --text-tertiary: #6b6560;
  --text-inverse: #1a1715;
  --msg-other: #2a2826;
  --msg-other-text: #e8e4e0;
  --border: rgba(255,255,255,0.08);
  --border-strong: rgba(255,255,255,0.14);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.12);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.2);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.28);
}

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

html, body {
  height: 100%;
  height: 100dvh; /* dynamic viewport height for mobile */
  font-family: var(--font-body);
  background: var(--bg-primary);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  overscroll-behavior: none;
}

.screen { display: none; height: 100vh; height: 100dvh; width: 100vw; }
.screen.active { display: flex; }
.hidden { display: none !important; }

/* ═══════════════════════════════════════════
   AUTH SCREEN
   ═══════════════════════════════════════════ */

.lobby-container {
  margin: auto;
  width: 100%;
  max-width: 420px;
  padding: 40px 24px;
  animation: fadeInUp 0.5s ease-out;
}
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.lobby-header { text-align: center; margin-bottom: 36px; }
.logo-mark { display: flex; justify-content: center; margin: 0 auto 8px; }
.logo-mark img { filter: drop-shadow(0 4px 12px rgba(201, 100, 66, 0.08)); }

.lobby-tabs {
  display: flex;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: 4px;
  margin-bottom: 28px;
  border: 1px solid var(--border);
}
.tab-btn {
  flex: 1;
  padding: 10px 16px;
  border: none;
  background: transparent;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-tertiary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.25s ease;
}
.tab-btn.active {
  background: var(--bg-input);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}
.tab-content { display: none; }
.tab-content.active { display: block; animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.form-group { margin-bottom: 18px; }
.form-group-row {
  display: flex;
  gap: 12px;
}
.form-group-row .form-group { flex: 1; }
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.form-group input {
  width: 100%;
  padding: 12px 14px;
  font-family: var(--font-body);
  font-size: 14px;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-primary);
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}
.form-group input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.form-group input::placeholder { color: var(--text-tertiary); }

.password-wrapper { position: relative; }
.password-wrapper input { padding-right: 44px; }
.toggle-pw {
  position: absolute; right: 10px; top: 50%;
  transform: translateY(-50%);
  background: none; border: none;
  color: var(--text-secondary);
  cursor: pointer; padding: 6px;
  border-radius: 6px;
  transition: background 0.2s, color 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.toggle-pw:hover {
  background: var(--bg-hover);
  color: var(--accent);
}

.btn-primary {
  width: 100%;
  padding: 13px 24px;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--text-inverse);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 0.2s, transform 0.15s;
  margin-top: 6px;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:active { transform: scale(0.985); }
.btn-primary:disabled { opacity: 0.5; pointer-events: none; }

.btn-secondary {
  width: 100%;
  padding: 10px 16px;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.2s;
}
.btn-secondary:hover { background: var(--bg-hover); border-color: var(--text-tertiary); }

.error-msg {
  margin-top: 16px;
  padding: 10px 14px;
  font-size: 13px;
  background: rgba(201, 68, 66, 0.08);
  color: var(--error);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(201, 68, 66, 0.15);
}

.security-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 28px;
  font-size: 12px;
  color: var(--text-tertiary);
}

/* ═══════════════════════════════════════════
   APP LAYOUT (WhatsApp-like)
   ═══════════════════════════════════════════ */

.app-layout {
  display: flex;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* ─── Left Panel ─── */
.panel-left {
  width: var(--panel-left-width);
  min-width: var(--panel-left-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-left-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
}

.user-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.user-avatar-small {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: var(--accent);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
  overflow: hidden;
  background-size: cover;
  background-position: center;
  transition: transform 0.2s;
}
.user-avatar-small:hover { transform: scale(1.05); }

.user-bar-info {
  flex: 1;
  min-width: 0;
}
.user-bar-name {
  display: block;
  font-weight: 600;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-bar-status {
  font-size: 12px;
  color: var(--success);
}

.user-bar-actions {
  display: flex;
  gap: 2px;
}

.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.2s;
  font-size: 20px;
}
.icon-btn:hover { background: var(--bg-hover); }
.icon-btn.small { width: 28px; height: 28px; }

.search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  padding: 8px 14px;
  border: 1px solid var(--border);
}
.search-bar input {
  flex: 1;
  border: none;
  background: none;
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--text-primary);
  outline: none;
}
.search-bar input::placeholder { color: var(--text-tertiary); }
.search-bar svg { color: var(--text-tertiary); flex-shrink: 0; }

/* Search Results */
.search-results {
  border-bottom: 1px solid var(--border);
  max-height: 300px;
  overflow-y: auto;
  background: var(--bg-secondary);
}
.search-result-item, .conv-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  cursor: pointer;
  transition: background 0.15s;
  position: relative;
}
.search-result-item:hover, .conv-item:hover {
  background: var(--bg-hover);
}
.conv-item.active {
  background: var(--accent-soft);
}
.search-empty {
  padding: 20px;
  text-align: center;
  color: var(--text-tertiary);
  font-size: 13px;
}

/* Conversation List */
.conversation-list {
  flex: 1;
  overflow-y: auto;
}

.conv-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background-color: var(--accent);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 600;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}
.conv-avatar.group {
  background: var(--text-tertiary);
  border-radius: var(--radius-md);
}

.online-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--text-tertiary);
  border: 2px solid var(--bg-sidebar);
  flex-shrink: 0;
}
.conv-avatar .online-dot {
  position: absolute;
  bottom: 0;
  right: 0;
}
.online-dot.active {
  background: var(--success);
}

.conv-info {
  flex: 1;
  min-width: 0;
}
.conv-info-top, .conv-info-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.conv-name {
  font-weight: 600;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.conv-time {
  font-size: 11px;
  color: var(--text-tertiary);
  flex-shrink: 0;
  margin-left: 8px;
}
.conv-last-msg {
  font-size: 13px;
  color: var(--text-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}
.conv-member-count {
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 10px;
  font-weight: 600;
  flex-shrink: 0;
  margin-left: 8px;
}

/* Pending invites */
.pending-invites { border-bottom: 1px solid var(--border); }
.pending-invites-header { padding: 10px 16px 6px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--accent); }
.invite-item { display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: var(--accent-soft); }
.invite-item + .invite-item { border-top: 1px solid var(--border); }
.invite-item-info { flex: 1; min-width: 0; }
.invite-item-name { font-weight: 600; font-size: 14px; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.invite-item-desc { font-size: 12px; color: var(--text-tertiary); margin-top: 2px; }
.invite-item-actions { display: flex; gap: 6px; flex-shrink: 0; }
.invite-accept-btn, .invite-decline-btn { width: 32px; height: 32px; border-radius: 50%; border: none; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: transform 0.15s; }
.invite-accept-btn:active, .invite-decline-btn:active { transform: scale(0.9); }
.invite-accept-btn { background: var(--success); color: white; }
.invite-decline-btn { background: var(--error); color: white; }

.panel-left-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text-tertiary);
  font-size: 14px;
}
.panel-left-empty small {
  font-size: 12px;
  opacity: 0.7;
}

/* ─── Right Panel ─── */
.panel-right {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg-chat);
}

.chat-empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-tertiary);
  font-size: 16px;
}
.chat-empty-state small {
  font-size: 13px;
  opacity: 0.7;
}

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

/* Chat Topbar */
.chat-topbar {
  height: 64px;
  min-height: 64px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
}
.mobile-back { display: none; }

.chat-topbar-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: var(--accent);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 600;
  overflow: hidden;
  flex-shrink: 0;
  background-size: cover;
  background-position: center;
}

.topbar-info {
  flex: 1;
  cursor: pointer;
  min-width: 0;
}
#topbar-conv-name {
  display: block;
  font-weight: 600;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-status {
  font-size: 12px;
  color: var(--text-tertiary);
}
.topbar-status.online {
  color: var(--success);
}
.topbar-status.last-seen {
  color: var(--text-tertiary);
  font-style: italic;
  font-size: 11px;
}

.member-last-seen {
  font-size: 11px;
  color: var(--text-tertiary);
  font-style: italic;
  margin-top: 1px;
}
.member-last-seen.online-text {
  color: var(--success);
  font-style: normal;
}

.topbar-actions {
  display: flex;
  gap: 4px;
}

/* Messages */
.messages-container {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  scroll-behavior: smooth;
}

.messages {
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
}

.msg-row {
  display: flex;
  gap: 8px;
  margin-bottom: 4px;
  animation: msgIn 0.2s ease-out;
}
.msg-row.own {
  flex-direction: row-reverse;
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--text-tertiary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
  align-self: flex-end;
}
.msg-avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.msg-bubble-wrap {
  max-width: 70%;
  min-width: 80px;
}

.msg-sender {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 2px;
  display: block;
  padding-left: 4px;
}

.msg-bubble {
  padding: 8px 12px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
  position: relative;
}

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

.msg-text {
  margin-bottom: 2px;
}

.msg-time {
  font-size: 10px;
  opacity: 0.6;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 3px;
  margin-top: 2px;
}

/* Read receipt check marks */
.msg-status {
  display: inline-flex;
  align-items: center;
  margin-left: 2px;
}
.msg-check {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: -3px;
  line-height: 1;
}
.msg-check.sent {
  color: rgba(255, 255, 255, 0.5);
}
.msg-check.delivered {
  color: rgba(255, 255, 255, 0.5);
}
.msg-check.read {
  color: #7dd3fc;
}

/* Unread message badge */
.conv-unread-badge {
  background: var(--accent);
  color: white;
  font-size: 11px;
  font-weight: 700;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-left: 8px;
}
.conv-time.unread {
  color: var(--accent);
  font-weight: 600;
}

.msg-file img {
  max-width: 260px;
  max-height: 200px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  margin-top: 4px;
}
.msg-file img:hover { opacity: 0.9; }

.msg-file-doc {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(0,0,0,0.06);
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: inherit;
  font-size: 13px;
  margin-top: 4px;
}
.msg-row.own .msg-file-doc { background: rgba(255,255,255,0.15); }

/* Call event messages */
.msg-call-event {
  display: flex;
  justify-content: center;
  padding: 8px 0;
  animation: msgIn 0.2s ease-out;
}
.msg-call-event-content {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 13px;
  color: var(--text-secondary);
  box-shadow: var(--shadow-sm);
}
.msg-call-event-text {
  font-weight: 500;
}
.msg-call-event-time {
  font-size: 10px;
  color: var(--text-tertiary);
  white-space: nowrap;
}
.msg-file-icon {
  width: 32px; height: 32px;
  border-radius: 6px;
  background: rgba(0,0,0,0.06);
  display: flex;
  align-items: center;
  justify-content: center;
}
.msg-file-name { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 180px; }
.msg-file-size { font-size: 11px; opacity: 0.7; }

/* Typing Bar */
.typing-bar {
  padding: 4px 14px;
  font-size: 12px;
  color: var(--text-tertiary);
  display: flex;
  align-items: center;
  gap: 6px;
}
.typing-bar .dot {
  width: 4px; height: 4px;
  border-radius: 50%;
  background: var(--text-tertiary);
  animation: typingPulse 1.4s infinite ease-in-out;
}
.typing-bar .dot:nth-child(2) { animation-delay: 0.2s; }
.typing-bar .dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingPulse {
  0%, 60%, 100% { opacity: 0.3; transform: scale(0.85); }
  30% { opacity: 1; transform: scale(1); }
}

/* Input Area */
.input-area {
  padding: 8px 24px 16px;
  background: var(--bg-chat);
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
  position: relative;
}

.file-preview {
  padding: 8px 12px;
  margin-bottom: 8px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}
.file-preview img { width: 40px; height: 40px; object-fit: cover; border-radius: 4px; }
.file-preview-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-secondary); }
.file-preview-remove { background: none; border: none; color: var(--text-tertiary); cursor: pointer; font-size: 18px; }

.input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--bg-input);
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 6px 8px 6px 4px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.input-row:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.attach-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  border-radius: 50%;
  cursor: pointer;
  color: var(--text-tertiary);
  transition: all 0.2s;
  flex-shrink: 0;
}
.attach-btn:hover { background: var(--bg-hover); color: var(--text-secondary); }

#message-input {
  flex: 1;
  border: none;
  background: transparent;
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--text-primary);
  resize: none;
  outline: none;
  line-height: 1.5;
  max-height: 140px;
  padding: 6px 0;
}
#message-input::placeholder { color: var(--text-tertiary); }

.send-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: white;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s, transform 0.15s, opacity 0.2s;
}
.send-btn:hover:not(:disabled) { background: var(--accent-hover); }
.send-btn:active:not(:disabled) { transform: scale(0.92); }
.send-btn:disabled { opacity: 0.35; cursor: default; }

/* ─── Mic Button ─── */
.mic-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.2s;
}
.mic-btn:hover { background: var(--bg-hover); color: var(--accent); }
.mic-btn:active { transform: scale(0.92); }

/* ─── Voice Recording UI ─── */
.recording-row {
  border-color: var(--error) !important;
  box-shadow: 0 0 0 3px rgba(201, 68, 66, 0.15) !important;
}
.recording-row.hidden { display: none !important; }

.voice-cancel-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  border-radius: 50%;
  border: none;
  background: rgba(201, 68, 66, 0.1);
  color: var(--error);
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.2s;
}
.voice-cancel-btn:hover { background: rgba(201, 68, 66, 0.2); }
.voice-cancel-btn:active { transform: scale(0.92); }

.voice-recording-info {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px;
  min-width: 0;
}

.voice-rec-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--error);
  flex-shrink: 0;
  animation: voicePulse 1s ease-in-out infinite;
}
@keyframes voicePulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.8); }
}

.voice-rec-timer {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 500;
  color: var(--error);
  flex-shrink: 0;
  min-width: 40px;
}

.voice-waveform {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 24px;
  flex: 1;
  min-width: 0;
}
.wave-bar {
  width: 3px;
  border-radius: 2px;
  background: var(--error);
  animation: waveAnim 0.8s ease-in-out infinite;
  opacity: 0.7;
}
.wave-bar:nth-child(1) { height: 8px;  animation-delay: 0s; }
.wave-bar:nth-child(2) { height: 14px; animation-delay: 0.1s; }
.wave-bar:nth-child(3) { height: 20px; animation-delay: 0.2s; }
.wave-bar:nth-child(4) { height: 12px; animation-delay: 0.3s; }
.wave-bar:nth-child(5) { height: 18px; animation-delay: 0.15s; }
.wave-bar:nth-child(6) { height: 10px; animation-delay: 0.25s; }
.wave-bar:nth-child(7) { height: 16px; animation-delay: 0.05s; }
.wave-bar:nth-child(8) { height: 22px; animation-delay: 0.35s; }
.wave-bar:nth-child(9) { height: 14px; animation-delay: 0.2s; }
@keyframes waveAnim {
  0%, 100% { transform: scaleY(0.4); }
  50% { transform: scaleY(1); }
}

.voice-send-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: white;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s, transform 0.15s;
}
.voice-send-btn:hover { background: var(--accent-hover); }
.voice-send-btn:active { transform: scale(0.92); }

/* ─── Audio Message Player ─── */
.msg-audio-player {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 4px;
  min-width: 200px;
  max-width: 280px;
}
.audio-play-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.2s;
}
.msg-row.own .audio-play-btn {
  background: rgba(255,255,255,0.2);
  color: white;
}
.msg-row.other .audio-play-btn {
  background: var(--accent-soft);
  color: var(--accent);
}
.audio-play-btn:hover { transform: scale(1.08); }
.audio-play-btn:active { transform: scale(0.95); }

.audio-wave-track {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.audio-wave-bars {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 24px;
  position: relative;
  cursor: pointer;
}
.audio-wave-bars .aw-bar {
  width: 3px;
  border-radius: 2px;
  transition: opacity 0.1s;
}
.msg-row.own .audio-wave-bars .aw-bar { background: rgba(255,255,255,0.4); }
.msg-row.own .audio-wave-bars .aw-bar.aw-played { background: rgba(255,255,255,0.9); }
.msg-row.other .audio-wave-bars .aw-bar { background: rgba(0,0,0,0.15); }
.msg-row.other .audio-wave-bars .aw-bar.aw-played { background: var(--accent); }

.audio-duration {
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1;
}
.msg-row.own .audio-duration { color: rgba(255,255,255,0.7); }
.msg-row.other .audio-duration { color: var(--text-tertiary); }

.input-footer { display: flex; justify-content: center; margin-top: 6px; }
.encryption-badge {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text-tertiary);
}

/* ═══════════════════════════════════════════
   MODALS
   ═══════════════════════════════════════════ */

.modal {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(4px);
}
.modal-content {
  position: relative;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  width: 90%;
  max-width: 440px;
  max-height: 80vh;
  overflow-y: auto;
  animation: modalIn 0.25s ease-out;
}
.modal-lg { max-width: 520px; }

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

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

.modal-body {
  padding: 20px;
}

/* Selected members bar in new chat */
.nc-selected-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-primary);
  max-height: 100px;
  overflow-y: auto;
}

/* Modal tabs */
.modal-tabs {
  display: flex;
  background: var(--bg-primary);
  border-radius: var(--radius-sm);
  padding: 3px;
  margin-bottom: 14px;
  border: 1px solid var(--border);
}
.modal-tab {
  flex: 1;
  padding: 8px 12px;
  border: none;
  background: transparent;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-tertiary);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}
.modal-tab.active {
  background: var(--bg-input);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

.modal-user-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 300px;
  overflow-y: auto;
}

.modal-user-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s;
}
.modal-user-item:hover { background: var(--bg-hover); }
.modal-user-item.selected { background: var(--accent-soft); }
.modal-user-item .conv-avatar {
  width: 40px; height: 40px; font-size: 14px;
}

/* Selected members chips */
.selected-members {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0;
}
.selected-member-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
}
.selected-member-chip button {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 0 2px;
}
.selected-member-chip.invited {
  background: rgba(61, 140, 92, 0.1);
  color: var(--success);
  border: 1px dashed var(--success);
}
.selected-member-chip.invited button {
  color: var(--success);
}
.selected-member-chip small {
  font-size: 10px;
  opacity: 0.7;
}

/* Profile */
.profile-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  font-weight: 600;
  margin: 0 auto;
  background-size: cover;
  background-position: center;
}
.profile-avatar.group {
  border-radius: var(--radius-lg);
  background: var(--text-tertiary);
}

.conv-info-avatar-wrap {
  position: relative;
  display: inline-block;
}
.conv-avatar-edit-btn {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: 2px solid var(--bg-secondary);
  transition: transform 0.2s;
}
.conv-avatar-edit-btn:hover {
  transform: scale(1.1);
}

/* Conversation Info */
.conv-info-members {
  margin-top: 16px;
}
.conv-info-member {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.conv-info-member:last-child { border-bottom: none; }

.role-tag {
  font-size: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 600;
  margin-left: 6px;
}

.member-actions {
  margin-left: auto;
}

/* Ephemeral messages */
.ephemeral-select {
  width: 100%;
  padding: 10px 14px;
  font-family: var(--font-body);
  font-size: 14px;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-primary);
  outline: none;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239e9590' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}
.ephemeral-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.topbar-status-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ephemeral-badge {
  display: inline-flex;
  align-items: center;
  color: var(--accent);
  opacity: 0.8;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
}
.ephemeral-badge:hover { opacity: 1; background: var(--accent-soft); }

/* Ephemeral options list */
.ephemeral-options {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.ephemeral-option {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s;
  border: 1.5px solid transparent;
}
.ephemeral-option:hover { background: var(--bg-hover); }
.ephemeral-option.active {
  background: var(--accent-soft);
  border-color: var(--accent);
}
.ephemeral-option-radio {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.ephemeral-option.active .ephemeral-option-radio {
  border-color: var(--accent);
}
.ephemeral-option-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
}
.ephemeral-option-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}
.ephemeral-option-desc {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 2px;
}

/* Invite link box */
.invite-link-box {
  display: flex;
  gap: 8px;
}
.invite-link-box input {
  flex: 1;
  padding: 10px 12px;
  font-family: var(--font-mono);
  font-size: 12px;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  color: var(--text-primary);
  outline: none;
}
.btn-copy-link {
  padding: 10px 16px;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: white;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s;
}
.btn-copy-link:hover { background: var(--accent-hover); }

/* Progress bar for conversation creation */
.nc-progress {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg-primary);
}
.nc-progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.nc-progress-header span:first-child {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}
.nc-progress-header span:last-child {
  font-size: 12px;
  color: var(--text-tertiary);
}
.nc-progress-bar-track {
  width: 100%;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 10px;
}
.nc-progress-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.4s ease;
}
.nc-progress-log {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 120px;
  overflow-y: auto;
}
.nc-progress-log .log-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-secondary);
  padding: 4px 0;
}
.nc-progress-log .log-item .log-icon {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 10px;
}
.nc-progress-log .log-icon.ok { background: rgba(61,140,92,0.15); color: var(--success); }
.nc-progress-log .log-icon.fail { background: rgba(201,68,66,0.15); color: var(--error); }
.nc-progress-log .log-icon.wait { background: var(--accent-soft); color: var(--accent); }
@keyframes spin { to { transform: rotate(360deg); } }
.nc-progress-log .log-icon.wait svg { animation: spin 1s linear infinite; }

.invite-actions-row {
  display: flex;
  gap: 8px;
}
.invite-actions-row .btn-secondary,
.invite-actions-row .btn-primary {
  flex: 1;
  font-size: 13px;
  padding: 11px 12px;
}

/* ═══════════════════════════════════════════
   LIGHTBOX & TOAST
   ═══════════════════════════════════════════ */

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(8px);
  cursor: pointer;
}
.lightbox img {
  max-width: 90vw;
  max-height: 90vh;
  border-radius: var(--radius-md);
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.lightbox-close {
  position: absolute;
  top: 20px; right: 24px;
  font-size: 32px;
  color: white;
  background: none;
  border: none;
  cursor: pointer;
  opacity: 0.7;
}
.lightbox-close:hover { opacity: 1; }

.toast-container {
  position: fixed;
  top: 20px; right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: var(--font-body);
  color: white;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.3s ease-out;
  max-width: 340px;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--error); }
.toast.info { background: var(--text-secondary); }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(30px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ═══════════════════════════════════════════
   SCROLLBAR
   ═══════════════════════════════════════════ */

::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-tertiary); }

/* ═══════════════════════════════════════════
   CALL UI
   ═══════════════════════════════════════════ */

.call-btn-topbar { color: var(--accent); }
.call-btn-topbar:hover { background: var(--accent-soft); }

/* Call Screen Overlay */
.call-screen {
  position: fixed;
  inset: 0;
  z-index: 700;
  background: linear-gradient(135deg, #1a1715 0%, #2d2520 50%, #1a1715 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: white;
}

.call-info-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 20px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 10;
}
.call-type-label {
  font-size: 13px;
  opacity: 0.7;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 500;
}
.call-duration {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 500;
}

/* Call Avatar Area (audio calls / ringing state) */
.call-avatar-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  z-index: 5;
}
.call-peer-avatar {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  font-weight: 600;
  color: white;
  box-shadow: 0 0 0 0 rgba(201, 100, 66, 0.4);
  animation: callPulse 2s ease-in-out infinite;
}
@keyframes callPulse {
  0% { box-shadow: 0 0 0 0 rgba(201, 100, 66, 0.4); }
  50% { box-shadow: 0 0 0 20px rgba(201, 100, 66, 0); }
  100% { box-shadow: 0 0 0 0 rgba(201, 100, 66, 0); }
}

.call-avatar-area h2 {
  font-size: 24px;
  font-weight: 600;
}
.call-status-text {
  font-size: 14px;
  opacity: 0.6;
  animation: fadeInOut 2s ease-in-out infinite;
}
@keyframes fadeInOut {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 0.8; }
}

/* Video elements */
.call-remote-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 1;
}
.call-local-video {
  position: absolute;
  bottom: 120px;
  right: 20px;
  width: 140px;
  height: 190px;
  border-radius: 12px;
  object-fit: cover;
  border: 2px solid rgba(255,255,255,0.3);
  z-index: 10;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}

/* Call Controls */
.call-controls {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 24px 32px 40px;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 32px;
  z-index: 10;
  background: linear-gradient(transparent, rgba(0,0,0,0.6));
}

.call-controls-connected {
  display: flex;
  gap: 32px;
}

.call-ctrl-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.call-ctrl-label {
  font-size: 11px;
  opacity: 0.7;
  color: white;
}

.call-ctrl-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.15);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  backdrop-filter: blur(10px);
}
.call-ctrl-btn:hover { background: rgba(255,255,255,0.25); }
.call-ctrl-btn.active {
  background: rgba(255,255,255,0.9);
  color: #1a1715;
}
.call-ctrl-btn.hangup {
  background: var(--error);
  width: 64px;
  height: 64px;
}
.call-ctrl-btn.hangup:hover { background: #e04040; }

/* Incoming Call Modal */
.incoming-call-modal {
  background: linear-gradient(135deg, #1a1715, #2d2520);
  color: white;
  text-align: center;
  max-width: 340px;
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.incoming-call-body {
  padding: 40px 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}
.incoming-call-body h3 {
  font-size: 22px;
  font-weight: 600;
  color: white;
}
.incoming-call-type {
  font-size: 14px;
  opacity: 0.6;
  color: white;
}
.incoming-call-avatar {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  font-weight: 600;
  color: white;
  background-size: cover;
  background-position: center;
}
.incoming-call-avatar.pulse-ring {
  animation: incomingPulse 1.5s ease-in-out infinite;
}
@keyframes incomingPulse {
  0% { box-shadow: 0 0 0 0 rgba(201, 100, 66, 0.6); }
  70% { box-shadow: 0 0 0 24px rgba(201, 100, 66, 0); }
  100% { box-shadow: 0 0 0 0 rgba(201, 100, 66, 0); }
}

.incoming-call-actions {
  display: flex;
  gap: 40px;
  margin-top: 24px;
}
.call-action-btn {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}
.call-action-btn:active { transform: scale(0.9); }
.call-action-btn.accept {
  background: var(--success);
  box-shadow: 0 4px 20px rgba(61, 140, 92, 0.4);
}
.call-action-btn.reject {
  background: var(--error);
  box-shadow: 0 4px 20px rgba(201, 68, 66, 0.4);
}
.call-action-btn:hover {
  box-shadow: 0 6px 28px rgba(0,0,0,0.3);
}

/* ═══════════════════════════════════════════
   MOBILE-FIRST RESPONSIVE
   ═══════════════════════════════════════════ */

/* Safe area for notch devices (iPhone etc.) */
@supports (padding: env(safe-area-inset-top)) {
  .panel-left-header { padding-top: calc(12px + env(safe-area-inset-top)); }
  .chat-topbar { padding-top: env(safe-area-inset-top); height: calc(64px + env(safe-area-inset-top)); }
  .call-info-bar { padding-top: calc(20px + env(safe-area-inset-top)); }
  .call-controls { padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
  .input-area { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
}

/* Touch optimization */
@media (pointer: coarse) {
  .icon-btn { width: 40px; height: 40px; }
  .conv-item { padding: 12px 16px; }
  .search-result-item { padding: 12px 16px; }
  .modal-user-item { padding: 12px; }
  .call-ctrl-btn { width: 60px; height: 60px; }
  .call-ctrl-btn.hangup { width: 68px; height: 68px; }
  .call-action-btn { width: 68px; height: 68px; }
  .send-btn { width: 40px; height: 40px; }
  .attach-btn { width: 40px; height: 40px; }
  .mic-btn { width: 40px; height: 40px; }
  .voice-cancel-btn { width: 40px; height: 40px; }
  .voice-send-btn { width: 40px; height: 40px; }
  .audio-play-btn { width: 40px; height: 40px; }
}

@media (max-width: 768px) {
  /* ─── Layout: full-screen panels ─── */
  .app-layout {
    position: relative;
  }
  .panel-left {
    width: 100%;
    min-width: 100%;
    max-width: 100%;
    position: absolute;
    inset: 0;
    z-index: 10;
  }
  .panel-left.mobile-hidden {
    display: none;
  }
  .panel-right {
    width: 100%;
    min-width: 100%;
  }
  .panel-right.mobile-visible {
    display: flex;
  }
  .mobile-back {
    display: flex !important;
  }

  /* ─── Auth screen ─── */
  .lobby-container {
    padding: 24px 20px;
    max-width: 100%;
  }
  .lobby-header { margin-bottom: 24px; }
  .logo-mark img { width: 140px !important; }
  .lobby-tabs { margin-bottom: 20px; }
  .form-group { margin-bottom: 14px; }
  .form-group input { padding: 14px; font-size: 16px; /* prevents iOS zoom */ }
  .btn-primary { padding: 14px 24px; font-size: 15px; }
  .security-badge { margin-top: 20px; }

  /* ─── User bar ─── */
  .panel-left-header { padding: 10px 12px; }
  .user-bar { margin-bottom: 10px; gap: 6px; flex-wrap: nowrap; }
  .user-avatar-small { width: 32px; height: 32px; font-size: 12px; }
  .user-bar-name { font-size: 13px; }
  .user-bar-info { min-width: 0; }
  .user-bar-actions { gap: 0; flex-shrink: 0; }
  .user-bar-actions .icon-btn { width: 30px; height: 30px; }
  .user-bar-actions .icon-btn svg { width: 17px; height: 17px; }

  /* ─── Search ─── */
  .search-bar { padding: 8px 12px; }
  .search-bar input { font-size: 15px; }
  .search-results { max-height: 50vh; }

  /* ─── Conversation list ─── */
  .conv-avatar { width: 50px; height: 50px; font-size: 19px; }
  .conv-name { font-size: 15px; }
  .conv-last-msg { font-size: 13px; }
  .conv-item { gap: 10px; }
  .panel-left-empty { padding: 40px 20px; }
  .panel-left-empty p { font-size: 15px; }

  /* ─── Chat topbar ─── */
  .chat-topbar {
    gap: 8px;
    padding: 0 10px;
    height: 56px;
    min-height: 56px;
  }
  .chat-topbar-avatar { width: 36px; height: 36px; font-size: 14px; }
  #topbar-conv-name { font-size: 14px; }
  .topbar-actions { gap: 0; }

  /* ─── Messages ─── */
  .messages-container { -webkit-overflow-scrolling: touch; }
  .messages {
    padding: 12px 12px;
    gap: 2px;
  }
  .msg-avatar { width: 28px; height: 28px; font-size: 11px; }
  .msg-bubble-wrap { max-width: 85%; }
  .msg-bubble { padding: 8px 10px; font-size: 14px; border-radius: 14px; }
  .msg-sender { font-size: 11px; }
  .msg-time { font-size: 9px; }
  .msg-file img { max-width: 200px; max-height: 160px; }
  .msg-file-doc { padding: 6px 10px; font-size: 12px; }
  .msg-file-name { max-width: 140px; }
  .msg-row { gap: 6px; }

  /* ─── Input area ─── */
  .input-area {
    padding: 6px 10px 10px;
  }
  .input-row {
    padding: 4px 6px 4px 2px;
    border-radius: 24px;
    gap: 4px;
  }
  #message-input {
    font-size: 16px; /* prevents iOS zoom */
    padding: 8px 0;
  }
  .input-footer { margin-top: 4px; }
  .encryption-badge { font-size: 10px; }
  .typing-bar { padding: 2px 10px; font-size: 11px; }

  /* ─── Voice recording (mobile) ─── */
  .voice-rec-timer { font-size: 13px; }
  .voice-waveform { gap: 2px; }
  .wave-bar { width: 2.5px; }
  .msg-audio-player { min-width: 180px; max-width: 240px; gap: 8px; }
  .audio-wave-bars .aw-bar { width: 2.5px; }

  /* ─── Modals ─── */
  .modal-content {
    width: 95%;
    max-width: 100%;
    max-height: 90vh;
    border-radius: var(--radius-md);
  }
  .modal-lg { max-width: 100%; }
  .modal-header { padding: 14px 16px; }
  .modal-body { padding: 16px; }
  .modal-body .form-group input { font-size: 16px; }
  .selected-member-chip { font-size: 12px; padding: 3px 8px; }

  /* ─── Profile modal ─── */
  .profile-avatar { width: 72px; height: 72px; font-size: 28px; }

  /* ─── Conv info ─── */
  .conv-info-member { padding: 10px 0; gap: 10px; }

  /* ─── Toast ─── */
  .toast-container {
    top: auto;
    bottom: 20px;
    right: 12px;
    left: 12px;
  }
  .toast {
    max-width: 100%;
    font-size: 13px;
    padding: 10px 14px;
  }

  /* ─── Lightbox ─── */
  .lightbox img { max-width: 95vw; max-height: 85vh; border-radius: 8px; }
  .lightbox-close { top: 12px; right: 16px; font-size: 28px; }

  /* ─── Call UI ─── */
  .call-local-video {
    width: 100px;
    height: 140px;
    bottom: 140px;
    right: 12px;
    border-radius: 10px;
  }
  .call-controls {
    padding: 20px 16px 28px;
    gap: 24px;
  }
  .call-controls-connected { gap: 24px; }
  .call-peer-avatar { width: 100px; height: 100px; font-size: 40px; }
  .call-avatar-area h2 { font-size: 20px; }
  .incoming-call-modal { max-width: 92%; }
  .incoming-call-body { padding: 32px 24px; }
  .incoming-call-actions { gap: 48px; }

  /* ─── File preview ─── */
  .file-preview { padding: 6px 10px; font-size: 12px; gap: 8px; }
  .file-preview img { width: 36px; height: 36px; }
}

/* ─── Very small phones (< 380px) ─── */
@media (max-width: 380px) {
  .lobby-container { padding: 16px 14px; }
  .form-group input { padding: 12px; }
  .btn-primary { padding: 12px 16px; }
  .user-bar-actions .icon-btn { width: 28px; height: 28px; }
  .user-bar-actions .icon-btn svg { width: 15px; height: 15px; }
  .conv-avatar { width: 44px; height: 44px; font-size: 16px; }
  .conv-name { font-size: 14px; }
  .chat-topbar { padding: 0 8px; }
  .topbar-actions .call-btn-topbar { width: 32px; height: 32px; }
  .msg-bubble-wrap { max-width: 90%; }
  .call-controls { gap: 16px; }
  .call-controls-connected { gap: 16px; }
  .call-ctrl-btn { width: 50px; height: 50px; }
  .call-ctrl-btn.hangup { width: 58px; height: 58px; }
}

/* ─── Landscape phone ─── */
@media (max-height: 500px) and (max-width: 900px) {
  .lobby-container { padding: 12px 20px; }
  .lobby-header { margin-bottom: 12px; }
  .logo-mark img { width: 100px !important; }
  .lobby-tabs { margin-bottom: 12px; }
  .form-group { margin-bottom: 8px; }
  .call-peer-avatar { width: 60px; height: 60px; font-size: 24px; }
  .call-controls { padding: 12px 20px 16px; }
  .incoming-call-body { padding: 20px 24px; }
  .incoming-call-avatar { width: 64px; height: 64px; font-size: 24px; }
}

/* ═══════════════════════════════════════════
   EMOJI PICKER
   ═══════════════════════════════════════════ */

.emoji-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  border-radius: 50%;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--text-tertiary);
  transition: all 0.2s;
  flex-shrink: 0;
  font-size: 18px;
}
.emoji-btn:hover { background: var(--bg-hover); color: var(--text-secondary); }

.emoji-picker {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 8px;
  width: 320px;
  max-height: 340px;
  background: var(--bg-input);
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 100;
  display: flex;
  flex-direction: column;
  animation: fadeInUp 0.18s ease-out;
}

.emoji-picker-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  padding: 4px 4px 0;
  gap: 2px;
  overflow-x: auto;
  flex-shrink: 0;
}

.emoji-picker-tab {
  padding: 6px 8px;
  border: none;
  background: transparent;
  font-size: 16px;
  cursor: pointer;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  transition: background 0.15s;
  flex-shrink: 0;
}
.emoji-picker-tab:hover { background: var(--bg-hover); }
.emoji-picker-tab.active {
  background: var(--accent-soft);
  border-bottom: 2px solid var(--accent);
}

.emoji-picker-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
  padding: 8px;
  overflow-y: auto;
  flex: 1;
}

.emoji-picker-grid span {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.12s, transform 0.12s;
  user-select: none;
}
.emoji-picker-grid span:hover {
  background: var(--bg-hover);
  transform: scale(1.2);
}

@media (max-width: 600px) {
  .emoji-picker {
    left: 4px;
    right: 4px;
    width: auto;
    max-height: 280px;
  }
  .emoji-picker-grid {
    grid-template-columns: repeat(7, 1fr);
  }
  .emoji-picker-grid span {
    font-size: 20px;
    width: 32px; height: 32px;
  }
}

/* ═══════════════════════════════════════════
   THEME TOGGLE BUTTON
   ═══════════════════════════════════════════ */

#btn-theme-toggle {
  position: relative;
}
#btn-theme-toggle svg {
  transition: transform 0.3s ease;
}
#btn-theme-toggle:hover svg {
  transform: rotate(20deg);
}

/* ═══════════════════════════════════════════
   REPLY & REACTIONS
   ═══════════════════════════════════════════ */

/* Reply preview bar above input */
.reply-preview {
  padding: 8px 12px;
  margin-bottom: 4px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  animation: fadeIn 0.2s ease;
}
.reply-preview-bar {
  display: flex;
  align-items: center;
  gap: 8px;
}
.reply-preview-bar > svg {
  color: var(--accent);
  flex-shrink: 0;
}
.reply-preview-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.reply-preview-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
}
.reply-preview-text {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.reply-preview-close {
  background: none;
  border: none;
  font-size: 20px;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  flex-shrink: 0;
  transition: color 0.2s;
}
.reply-preview-close:hover {
  color: var(--text-primary);
}

/* Quoted message block inside a message bubble */
.msg-reply-quote {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 6px 10px;
  margin-bottom: 6px;
  border-left: 3px solid var(--accent);
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.04);
  cursor: pointer;
  transition: background 0.15s;
  max-width: 100%;
  overflow: hidden;
}
.msg-reply-quote:hover {
  background: rgba(0, 0, 0, 0.07);
}
.msg-row.own .msg-reply-quote {
  background: rgba(255, 255, 255, 0.12);
  border-left-color: rgba(255, 255, 255, 0.5);
}
.msg-row.own .msg-reply-quote:hover {
  background: rgba(255, 255, 255, 0.18);
}
.msg-reply-name {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
}
.msg-row.own .msg-reply-name {
  color: rgba(255, 255, 255, 0.85);
}
.msg-reply-text {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.msg-row.own .msg-reply-text {
  color: rgba(255, 255, 255, 0.7);
}

/* Highlight animation when scrolling to a replied message */
.msg-highlight {
  animation: highlightPulse 1.5s ease-out;
}
@keyframes highlightPulse {
  0% { background: var(--accent-glow); }
  100% { background: transparent; }
}

/* Context menu for messages */
.msg-context-menu {
  position: fixed;
  z-index: 800;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  min-width: 160px;
  padding: 4px;
  animation: contextIn 0.15s ease-out;
}
@keyframes contextIn {
  from { opacity: 0; transform: scale(0.92) translateY(4px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.msg-context-menu button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 14px;
  border: none;
  background: transparent;
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--text-primary);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}
.msg-context-menu button:hover {
  background: var(--bg-hover);
}
.msg-context-menu button svg {
  color: var(--text-secondary);
  flex-shrink: 0;
}

/* Emoji quick reaction bar */
.emoji-reaction-bar {
  position: fixed;
  z-index: 810;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 28px;
  padding: 6px 8px;
  display: flex;
  gap: 2px;
  box-shadow: var(--shadow-lg);
  animation: contextIn 0.15s ease-out;
}
.emoji-btn {
  width: 38px;
  height: 38px;
  border: none;
  background: transparent;
  border-radius: 50%;
  font-size: 22px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s, background 0.15s;
  line-height: 1;
}
.emoji-btn:hover {
  background: var(--bg-hover);
  transform: scale(1.25);
}
.emoji-btn:active {
  transform: scale(0.9);
}

/* Reaction chips below message bubble */
.msg-reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
  padding-left: 4px;
}
.reaction-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-secondary);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
  font-family: var(--font-body);
  color: var(--text-secondary);
  line-height: 1.4;
}
.reaction-chip:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
}
.reaction-chip.own {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}
.reaction-chip.own:hover {
  background: rgba(201, 100, 66, 0.15);
}

/* Mobile adjustments for reactions & reply */
@media (max-width: 768px) {
  .emoji-btn {
    width: 42px;
    height: 42px;
    font-size: 24px;
  }
  .emoji-reaction-bar {
    padding: 8px 10px;
  }
  .msg-context-menu button {
    padding: 12px 16px;
    font-size: 15px;
  }
  .reply-preview {
    padding: 6px 10px;
    margin-bottom: 2px;
  }
  .msg-reply-quote {
    padding: 4px 8px;
    margin-bottom: 4px;
  }
  .reaction-chip {
    font-size: 12px;
    padding: 1px 6px;
  }
}

/* ═══════════════════════════════════════════
   TEXT FORMATTING
   ═══════════════════════════════════════════ */

.msg-text strong {
  font-weight: 700;
}

.msg-text em {
  font-style: italic;
}

.msg-text s {
  text-decoration: line-through;
  opacity: 0.7;
}

.msg-text code {
  font-family: var(--font-mono);
  font-size: 13px;
  background: rgba(0, 0, 0, 0.06);
  padding: 1px 5px;
  border-radius: 4px;
}

.msg-row.own .msg-text code {
  background: rgba(255, 255, 255, 0.18);
}

.msg-text pre {
  margin: 6px 0 4px;
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.06);
  border-radius: var(--radius-sm);
  overflow-x: auto;
  max-width: 100%;
}

.msg-row.own .msg-text pre {
  background: rgba(255, 255, 255, 0.14);
}

.msg-text pre code {
  background: none;
  padding: 0;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.msg-text a.msg-link {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  word-break: break-all;
}

.msg-row.own .msg-text a.msg-link {
  color: rgba(255, 255, 255, 0.9);
}

/* ═══════════════════════════════════════════
   LINK PREVIEW CARD
   ═══════════════════════════════════════════ */

.link-preview-card {
  display: block;
  margin-top: 8px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: rgba(0, 0, 0, 0.04);
  border: 1px solid var(--border);
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  transition: background 0.15s;
}

.link-preview-card:hover {
  background: rgba(0, 0, 0, 0.07);
}

.link-preview-card.own {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.15);
}

.link-preview-card.own:hover {
  background: rgba(255, 255, 255, 0.15);
}

.link-preview-img {
  width: 100%;
  max-height: 160px;
  overflow: hidden;
}

.link-preview-img img {
  width: 100%;
  height: 100%;
  max-height: 160px;
  object-fit: cover;
  display: block;
}

.link-preview-body {
  padding: 8px 10px;
}

.link-preview-title {
  font-weight: 600;
  font-size: 13px;
  line-height: 1.3;
  margin-bottom: 2px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.link-preview-card.own .link-preview-title {
  color: var(--msg-own-text);
}

.link-preview-desc {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
  margin-bottom: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.link-preview-card.own .link-preview-desc {
  color: rgba(255, 255, 255, 0.7);
}

.link-preview-domain {
  font-size: 11px;
  color: var(--accent);
  font-weight: 500;
  text-transform: lowercase;
}

.link-preview-card.own .link-preview-domain {
  color: rgba(255, 255, 255, 0.6);
}

@media (max-width: 768px) {
  .link-preview-img {
    max-height: 120px;
  }
  .link-preview-img img {
    max-height: 120px;
  }
}

/* ═══════════════════════════════════════════
   DELETED MESSAGES
   ═══════════════════════════════════════════ */

.msg-bubble.msg-deleted {
  opacity: 0.7;
}
.msg-row.own .msg-bubble.msg-deleted {
  background: rgba(201, 100, 66, 0.5);
}
.msg-row.other .msg-bubble.msg-deleted {
  background: rgba(0, 0, 0, 0.03);
}
.msg-deleted-text {
  font-style: italic;
  color: rgba(128, 128, 128, 0.9);
  font-size: 13px;
}
.msg-row.own .msg-deleted-text {
  color: rgba(255, 255, 255, 0.7);
}

/* Context menu delete divider & danger items */
.msg-context-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}
.msg-context-danger {
  color: var(--error) !important;
}
.msg-context-danger svg {
  stroke: var(--error) !important;
}

/* ═══════════════════════════════════════════
   MESSAGE SEARCH BAR
   ═══════════════════════════════════════════ */

.msg-search-bar {
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
  padding: 8px 16px;
  animation: fadeIn 0.2s ease;
}
.msg-search-inner {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  padding: 6px 12px;
  border: 1px solid var(--border);
}
.msg-search-inner svg {
  color: var(--text-tertiary);
  flex-shrink: 0;
}
.msg-search-inner input {
  flex: 1;
  border: none;
  background: none;
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--text-primary);
  outline: none;
  min-width: 0;
}
.msg-search-inner input::placeholder {
  color: var(--text-tertiary);
}
.msg-search-results-info {
  font-size: 12px;
  color: var(--text-tertiary);
  white-space: nowrap;
  flex-shrink: 0;
}

/* Search highlight on messages */
.msg-row.search-highlight .msg-bubble {
  box-shadow: 0 0 0 2px var(--accent);
}
.msg-row.search-flash .msg-bubble {
  animation: searchFlash 1.5s ease;
}
@keyframes searchFlash {
  0% { box-shadow: 0 0 0 3px var(--accent), 0 0 12px rgba(201, 100, 66, 0.4); }
  100% { box-shadow: 0 0 0 2px var(--accent); }
}

@media (max-width: 768px) {
  .msg-search-bar {
    padding: 6px 10px;
  }
  .msg-search-inner {
    padding: 4px 8px;
    gap: 4px;
  }
  .msg-search-inner input {
    font-size: 14px;
  }
}

/* ═══════════════════════════════════════════
   MUTE CONVERSATIONS
   ═══════════════════════════════════════════ */

.conv-muted-icon {
  display: inline-flex;
  align-items: center;
  margin-left: 4px;
  color: var(--text-tertiary);
  opacity: 0.7;
  flex-shrink: 0;
}
.conv-muted-icon svg {
  width: 14px;
  height: 14px;
}

.mute-options-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 8px;
}
.mute-option {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s;
  border: 1.5px solid transparent;
}
.mute-option:hover { background: var(--bg-hover); }
.mute-option.active {
  background: var(--accent-soft);
  border-color: var(--accent);
}
.mute-option-radio {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.mute-option.active .mute-option-radio {
  border-color: var(--accent);
}
.mute-option-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
}
.mute-option-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}

/* ═══════════════════════════════════════════
   BLOCK USERS
   ═══════════════════════════════════════════ */

.blocked-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 20px;
  background: rgba(201, 68, 66, 0.06);
  border: 1px solid rgba(201, 68, 66, 0.12);
  border-radius: var(--radius-sm);
  color: var(--error);
  font-size: 13px;
  font-weight: 500;
  margin: 12px 24px;
}

.btn-block {
  width: 100%;
  padding: 10px 16px;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  border: 1.5px solid var(--error);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--error);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.2s;
}
.btn-block:hover { background: rgba(201, 68, 66, 0.08); }

.btn-unblock {
  padding: 6px 14px;
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 500;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}
.btn-unblock:hover { background: var(--bg-hover); border-color: var(--text-tertiary); }

.blocked-user-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.blocked-user-item:last-child { border-bottom: none; }

/* ═══════════════════════════════════════════
   STORIES / STATUS
   ═══════════════════════════════════════════ */

.stories-bar {
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
  flex-shrink: 0;
}
.stories-scroll {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.stories-scroll::-webkit-scrollbar { display: none; }

.story-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  flex-shrink: 0;
  width: 64px;
}
.story-avatar-wrap {
  position: relative;
  width: 52px;
  height: 52px;
}
.story-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background-color: var(--accent);
  background-size: cover;
  background-position: center;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 600;
  overflow: hidden;
  transition: transform 0.2s;
}
.story-item:hover .story-avatar { transform: scale(1.05); }

.story-avatar-wrap.has-story {
  padding: 2px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-hover), #e8855a);
}
.story-avatar-wrap.has-story .story-avatar {
  border: 2px solid var(--bg-secondary);
  width: 48px;
  height: 48px;
}
.story-avatar-wrap.viewed {
  background: var(--border-strong);
}

.story-avatar-add {
  background: var(--bg-primary);
  color: var(--accent);
  border: 2px dashed var(--accent);
  font-size: 22px;
}

.story-name {
  font-size: 10px;
  color: var(--text-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 64px;
  text-align: center;
}

/* Story Viewer */
.story-viewer {
  position: fixed;
  inset: 0;
  z-index: 800;
  background: #000;
  display: flex;
  flex-direction: column;
  cursor: pointer;
}
.story-viewer-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  padding: 8px 16px;
  background: linear-gradient(to bottom, rgba(0,0,0,0.6), transparent);
}
.story-progress-bar {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
}
.story-progress-segment {
  flex: 1;
  height: 3px;
  background: rgba(255,255,255,0.3);
  border-radius: 2px;
  overflow: hidden;
}
.story-progress-fill {
  height: 100%;
  background: #fff;
  border-radius: 2px;
  width: 0%;
  transition: width 0.1s linear;
}
.story-progress-segment.viewed .story-progress-fill { width: 100%; }
.story-progress-segment.active .story-progress-fill {
  animation: storyProgress 5s linear forwards;
}
@keyframes storyProgress {
  from { width: 0%; }
  to { width: 100%; }
}

.story-viewer-info {
  display: flex;
  align-items: center;
  gap: 10px;
}
.story-viewer-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  background-size: cover;
  background-position: center;
  overflow: hidden;
}
.story-viewer-meta {
  flex: 1;
  display: flex;
  flex-direction: column;
}
.story-viewer-name {
  color: white;
  font-size: 14px;
  font-weight: 600;
}
.story-viewer-time {
  color: rgba(255,255,255,0.6);
  font-size: 11px;
}
.story-viewer-close {
  background: none;
  border: none;
  color: white;
  font-size: 28px;
  cursor: pointer;
  opacity: 0.7;
  padding: 4px 8px;
  line-height: 1;
}
.story-viewer-close:hover { opacity: 1; }

.story-viewer-content {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 80px 24px 40px;
  overflow: hidden;
}
.story-viewer-content img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: var(--radius-sm);
}
.story-viewer-content .story-text-display {
  color: white;
  font-size: 24px;
  font-weight: 500;
  text-align: center;
  line-height: 1.6;
  max-width: 480px;
  word-wrap: break-word;
  text-shadow: 0 2px 8px rgba(0,0,0,0.5);
}

@media (max-width: 768px) {
  .stories-scroll { padding: 8px 12px; gap: 8px; }
  .story-avatar-wrap { width: 48px; height: 48px; }
  .story-avatar { width: 48px; height: 48px; font-size: 16px; }
  .story-avatar-wrap.has-story .story-avatar { width: 44px; height: 44px; }
  .story-item { width: 56px; }
  .story-name { max-width: 56px; font-size: 9px; }
  .story-viewer-content .story-text-display { font-size: 20px; }
}

/* ═══════════════════════════════════════════
   E2E ENCRYPTED MESSAGE ICON
   ═══════════════════════════════════════════ */

.msg-encrypted-icon {
  display: inline-flex;
  align-items: center;
  margin-right: 3px;
  opacity: 0.5;
  vertical-align: middle;
}
.msg-row.own .msg-encrypted-icon { color: rgba(255,255,255,0.7); }
.msg-row.other .msg-encrypted-icon { color: var(--text-tertiary); }

/* ═══════════════════════════════════════════
   PIN LOCK SCREEN
   ═══════════════════════════════════════════ */

#screen-lock {
  background: var(--bg-primary);
  align-items: center;
  justify-content: center;
}

.lock-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40px 24px;
  max-width: 360px;
  width: 100%;
  animation: fadeInUp 0.4s ease-out;
}

.lock-logo {
  margin-bottom: 24px;
}

.lock-icon-wrap {
  margin-bottom: 16px;
  opacity: 0.8;
}

.lock-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 24px;
}

.lock-dots {
  display: flex;
  gap: 16px;
  margin-bottom: 12px;
  transition: transform 0.1s;
}

.lock-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  background: transparent;
  transition: all 0.2s ease;
}

.lock-dot.filled {
  background: var(--accent);
  border-color: var(--accent);
  transform: scale(1.15);
  box-shadow: 0 0 8px rgba(201, 100, 66, 0.3);
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-6px); }
  20%, 40%, 60%, 80% { transform: translateX(6px); }
}
.lock-dots.shake {
  animation: shake 0.5s ease;
}

.lock-error {
  font-size: 13px;
  color: var(--error);
  margin-bottom: 12px;
  text-align: center;
  min-height: 20px;
}

.lock-numpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  max-width: 280px;
  width: 100%;
  margin-top: 16px;
}

.numpad-btn {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 1.5px solid var(--border-strong);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 24px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  justify-self: center;
  transition: all 0.15s ease;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.numpad-btn:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: var(--accent);
}

.numpad-btn:active:not(:disabled) {
  transform: scale(0.92);
  background: var(--accent-soft);
  border-color: var(--accent);
}

.numpad-btn:disabled {
  opacity: 0.3;
  cursor: default;
}

.numpad-empty {
  border: none;
  background: transparent;
  cursor: default;
}

.numpad-back {
  border: none;
  background: transparent;
  color: var(--text-secondary);
}
.numpad-back:hover:not(:disabled) {
  background: var(--bg-hover);
  border: none;
}

.lock-forgot {
  margin-top: 24px;
  background: none;
  border: none;
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  transition: color 0.2s;
}
.lock-forgot:hover {
  color: var(--accent);
}

/* ─── Toggle Switch ─── */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--border-strong);
  border-radius: 24px;
  transition: all 0.3s ease;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: transform 0.3s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.toggle-switch input:checked + .toggle-slider {
  background: var(--accent);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(20px);
}

/* ─── Lock screen mobile ─── */
@media (max-width: 768px) {
  .lock-container { padding: 32px 20px; }
  .numpad-btn { width: 64px; height: 64px; font-size: 22px; }
  .lock-numpad { gap: 10px; max-width: 250px; }
  .lock-dot { width: 14px; height: 14px; }
  .lock-dots { gap: 14px; }
}

@media (max-width: 380px) {
  .numpad-btn { width: 56px; height: 56px; font-size: 20px; }
  .lock-numpad { gap: 8px; max-width: 220px; }
}

@media (pointer: coarse) {
  .numpad-btn { width: 68px; height: 68px; }
}

/* ═══════════════════════════════════════════
   FORWARDED MESSAGE LABEL
   ═══════════════════════════════════════════ */

.msg-forwarded {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-style: italic;
  color: var(--text-tertiary);
  padding: 2px 0 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.msg-row.own .msg-forwarded {
  color: rgba(255, 255, 255, 0.65);
}
.msg-forwarded svg {
  flex-shrink: 0;
  opacity: 0.7;
}

/* Forward modal conversation list */
.forward-conv-list {
  max-height: 320px;
  overflow-y: auto;
}
.forward-conv-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s;
}
.forward-conv-item:hover {
  background: var(--bg-hover);
}
.forward-conv-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}

/* ═══════════════════════════════════════════
   PINNED MESSAGE BANNER & ICON
   ═══════════════════════════════════════════ */

.pinned-banner {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: 0;
  min-height: 0;
}
.pinned-banner-content {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  cursor: pointer;
  transition: background 0.15s;
}
.pinned-banner-content:hover {
  background: var(--bg-hover);
}
.pinned-banner-content > svg {
  flex-shrink: 0;
  color: var(--accent);
}
.pinned-banner-text {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}
.pinned-banner-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.pinned-banner-preview {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pinned-banner-count {
  font-size: 10px;
  color: var(--text-tertiary);
  flex-shrink: 0;
}

.msg-pinned-icon {
  display: inline-flex;
  align-items: center;
  margin-right: 3px;
  color: var(--accent);
  vertical-align: middle;
  opacity: 0.7;
}
.msg-row.own .msg-pinned-icon {
  color: rgba(255, 255, 255, 0.65);
}

/* ═══════════════════════════════════════════
   ARCHIVE CONVERSATIONS
   ═══════════════════════════════════════════ */

.btn-show-archived {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  border-top: 1px solid var(--border);
}
.btn-show-archived:hover {
  background: var(--bg-hover);
  color: var(--accent);
}
.btn-show-archived svg {
  flex-shrink: 0;
}
.archive-count {
  margin-left: auto;
  font-size: 11px;
  font-weight: 600;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 2px 8px;
  border-radius: 10px;
}

.archived-section {
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
}
.archived-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.archived-conv-item {
  opacity: 0.75;
  position: relative;
}
.archived-conv-item:hover {
  opacity: 1;
}
.btn-unarchive {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  transition: background 0.15s, color 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-unarchive:hover {
  background: var(--bg-hover);
  color: var(--accent);
}

/* ═══════════════════════════════════════════
   MEETINGS
   ═══════════════════════════════════════════ */

/* ─── Meetings List ─── */
.meetings-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.meeting-card {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s;
}
.meeting-card:hover {
  background: var(--bg-hover);
  box-shadow: var(--shadow-sm);
}
.meeting-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.meeting-card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  margin-right: 8px;
}
.meeting-status-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}
.meeting-status-badge.active {
  background: rgba(61, 140, 92, 0.12);
  color: #3d8c5c;
}
.meeting-status-badge.scheduled {
  background: rgba(59, 130, 246, 0.12);
  color: #3b82f6;
}
.meeting-status-badge.ended {
  background: rgba(107, 101, 96, 0.12);
  color: #6b6560;
}
.meeting-card-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  color: var(--text-tertiary);
  margin-bottom: 8px;
}
.meeting-card-meta svg {
  flex-shrink: 0;
}
.meeting-card-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}
.meeting-card-actions button {
  padding: 6px 12px;
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s;
}
.meeting-card-actions button:hover {
  background: var(--bg-hover);
  border-color: var(--text-tertiary);
}
.meeting-card-actions .btn-join-meeting {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}
.meeting-card-actions .btn-join-meeting:hover {
  background: var(--accent-hover);
}

.meeting-card-actions .meeting-btn-danger { color: var(--error); border-color: var(--error); }
.meeting-card-actions .meeting-btn-danger:hover { background: var(--error); color: white; }

/* ─── Meeting Waiting Room ─── */
.meeting-waiting {
  position: fixed;
  inset: 0;
  z-index: 800;
  background: linear-gradient(135deg, #1a1715 0%, #2d2520 50%, #1a1715 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
}
.meeting-waiting-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  animation: fadeInUp 0.5s ease-out;
}
.meeting-waiting-icon {
  margin-bottom: 8px;
  opacity: 0.8;
}
.meeting-waiting-content h2 {
  font-size: 22px;
  font-weight: 600;
}
.meeting-waiting-text {
  font-size: 15px;
  opacity: 0.6;
}
.meeting-waiting-dots {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}
.meeting-waiting-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: meetingWaitPulse 1.4s ease-in-out infinite;
}
.meeting-waiting-dots span:nth-child(2) { animation-delay: 0.2s; }
.meeting-waiting-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes meetingWaitPulse {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
  40% { opacity: 1; transform: scale(1.1); }
}

/* ─── Meeting Room ─── */
.meeting-room {
  position: fixed;
  inset: 0;
  z-index: 800;
  background: #1a1715;
  display: flex;
  flex-direction: column;
  color: white;
}

/* Top Bar */
.meeting-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(12px);
  z-index: 10;
  flex-shrink: 0;
}
.meeting-topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}
.meeting-topbar-left h3 {
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.meeting-topbar-center {
  flex-shrink: 0;
}
.meeting-timer {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 500;
  opacity: 0.8;
}
.meeting-topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  justify-content: flex-end;
}
.meeting-participant-count {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  opacity: 0.7;
}
.meeting-leave-btn {
  padding: 7px 16px;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  border: none;
  border-radius: 6px;
  background: var(--error);
  color: white;
  cursor: pointer;
  transition: background 0.15s;
}
.meeting-leave-btn:hover {
  background: #e04040;
}

/* Recording Indicator */
.meeting-rec-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  color: #ef4444;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.meeting-rec-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ef4444;
  animation: recPulse 1.2s ease-in-out infinite;
}
@keyframes recPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* Video Grid */
.meeting-grid-container {
  flex: 1;
  overflow: hidden;
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.meeting-grid {
  display: grid;
  gap: 8px;
  width: 100%;
  height: 100%;
  grid-template-columns: 1fr;
  grid-template-rows: 1fr;
}
.meeting-grid[data-count="2"] {
  grid-template-columns: 1fr 1fr;
}
.meeting-grid[data-count="3"],
.meeting-grid[data-count="4"] {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
}
.meeting-grid[data-count="5"],
.meeting-grid[data-count="6"] {
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-rows: 1fr 1fr;
}
.meeting-grid[data-count="many"] {
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  grid-auto-rows: minmax(180px, 1fr);
}

/* Video Tile */
.meeting-video-tile {
  position: relative;
  background: #2a2826;
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
}
.meeting-video-tile video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.meeting-video-tile.pinned {
  grid-column: 1 / -1;
  grid-row: 1 / -1;
}
.meeting-tile-name {
  position: absolute;
  bottom: 8px;
  left: 8px;
  font-size: 12px;
  font-weight: 500;
  background: rgba(0, 0, 0, 0.6);
  padding: 3px 8px;
  border-radius: 4px;
  color: white;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 4px;
}
.meeting-tile-icons {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  gap: 4px;
  z-index: 2;
}
.meeting-tile-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  cursor: pointer;
}
.meeting-tile-icon.muted-icon {
  background: rgba(239, 68, 68, 0.8);
  color: white;
}
.meeting-tile-icon.hand-icon {
  background: rgba(245, 158, 11, 0.9);
  color: white;
  animation: handWave 1s ease-in-out infinite alternate;
}
@keyframes handWave {
  from { transform: rotate(-10deg); }
  to { transform: rotate(10deg); }
}
.meeting-tile-icon.pin-icon {
  background: rgba(255, 255, 255, 0.2);
  color: white;
  opacity: 0;
  transition: opacity 0.15s;
}
.meeting-video-tile:hover .pin-icon {
  opacity: 1;
}
.meeting-tile-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  font-weight: 600;
  color: white;
}

/* Controls Bar */
.meeting-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(12px);
  flex-shrink: 0;
  z-index: 10;
}
.meeting-ctrl-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.12);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.1s;
}
.meeting-ctrl-btn:hover {
  background: rgba(255, 255, 255, 0.22);
}
.meeting-ctrl-btn:active {
  transform: scale(0.93);
}
.meeting-ctrl-btn.active {
  background: #ef4444;
  color: white;
}
.meeting-ctrl-btn.hangup {
  background: #ef4444;
}
.meeting-ctrl-btn.hangup:hover {
  background: #e04040;
}
.meeting-ctrl-btn.hand-raised {
  background: #f59e0b;
  color: white;
}

/* Side Panel */
.meeting-side-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 320px;
  background: rgba(30, 28, 26, 0.95);
  backdrop-filter: blur(12px);
  border-left: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  z-index: 20;
  animation: slidePanelIn 0.2s ease-out;
}
@keyframes slidePanelIn {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}
.meeting-side-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 12px 12px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.meeting-side-header .modal-tabs {
  flex: 1;
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.08);
}
.meeting-side-header .modal-tab {
  color: rgba(255, 255, 255, 0.5);
}
.meeting-side-header .modal-tab.active {
  background: rgba(255, 255, 255, 0.12);
  color: white;
  box-shadow: none;
}
.meeting-side-body {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.meeting-side-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Meeting Chat */
.meeting-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.meeting-chat-msg {
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  font-size: 13px;
}
.meeting-chat-msg-name {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 2px;
}
.meeting-chat-msg-text {
  color: rgba(255, 255, 255, 0.85);
  word-break: break-word;
}
.meeting-chat-msg-time {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.35);
  margin-top: 2px;
  text-align: right;
}
.meeting-chat-input-area {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.meeting-chat-input-area input {
  flex: 1;
  padding: 8px 12px;
  font-family: var(--font-body);
  font-size: 13px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.06);
  color: white;
  outline: none;
}
.meeting-chat-input-area input::placeholder {
  color: rgba(255, 255, 255, 0.35);
}
.meeting-chat-input-area input:focus {
  border-color: var(--accent);
}
.meeting-chat-input-area .send-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  padding: 0;
  min-width: 0;
}

/* Participants List */
.meeting-section-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: rgba(255, 255, 255, 0.4);
  padding: 10px 14px 6px;
}
.meeting-participant-list {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}
.meeting-participant-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  transition: background 0.15s;
}
.meeting-participant-item:hover {
  background: rgba(255, 255, 255, 0.04);
}
.meeting-participant-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  color: white;
  flex-shrink: 0;
  background-size: cover;
  background-position: center;
}
.meeting-participant-info {
  flex: 1;
  min-width: 0;
}
.meeting-participant-name {
  font-size: 13px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.85);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.meeting-participant-role {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.4);
}
.meeting-participant-badges {
  display: flex;
  gap: 4px;
  align-items: center;
}
.meeting-participant-badge {
  font-size: 14px;
}
.meeting-participant-actions {
  display: flex;
  gap: 4px;
}
.meeting-participant-actions button {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.6);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  transition: background 0.15s;
}
.meeting-participant-actions button:hover {
  background: rgba(255, 255, 255, 0.15);
  color: white;
}
.meeting-participant-actions button.admit-btn {
  background: rgba(61, 140, 92, 0.3);
  color: #4ade80;
}
.meeting-participant-actions button.admit-btn:hover {
  background: rgba(61, 140, 92, 0.5);
}
.meeting-participant-actions button.reject-btn {
  background: rgba(239, 68, 68, 0.3);
  color: #f87171;
}
.meeting-participant-actions button.reject-btn:hover {
  background: rgba(239, 68, 68, 0.5);
}
.meeting-participant-actions button.kick-btn:hover {
  background: rgba(239, 68, 68, 0.3);
  color: #f87171;
}

/* ─── Meeting Responsive ─── */
@media (max-width: 768px) {
  .meeting-side-panel {
    width: 100%;
    border-left: none;
  }
  .meeting-controls {
    gap: 6px;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  }
  .meeting-ctrl-btn {
    width: 42px;
    height: 42px;
  }
  .meeting-topbar {
    padding: 10px 14px;
  }
  .meeting-grid {
    gap: 4px;
  }
  .meeting-grid[data-count="5"],
  .meeting-grid[data-count="6"] {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr 1fr;
  }
  .meeting-grid[data-count="many"] {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    grid-auto-rows: minmax(120px, 1fr);
  }
}

@media (max-width: 480px) {
  .meeting-ctrl-btn {
    width: 38px;
    height: 38px;
  }
  .meeting-ctrl-btn svg {
    width: 18px;
    height: 18px;
  }
  .meeting-controls {
    gap: 4px;
    padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  }
  .meeting-topbar-left h3 {
    font-size: 13px;
  }
  .meeting-leave-btn {
    font-size: 11px;
    padding: 5px 10px;
  }
}

/* Edit meeting participants */
.edit-participant-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.edit-participant-item:last-child { border-bottom: none; }

/* Meeting control badges */
.meeting-ctrl-btn { position: relative; }
.mtg-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  background: var(--error);
  color: white;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  border: 2px solid #1a1715;
  animation: badgePop 0.3s ease-out;
  pointer-events: none;
}
@keyframes badgePop {
  0% { transform: scale(0); }
  70% { transform: scale(1.2); }
  100% { transform: scale(1); }
}
.mtg-badge.hidden { display: none !important; }

/* Meeting Pre-Join Screen */
.meeting-prejoin {
  position: fixed;
  inset: 0;
  z-index: 750;
  background: rgba(0,0,0,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
}
.prejoin-card {
  background: var(--bg-secondary);
  border-radius: 20px;
  padding: 32px;
  width: 90%;
  max-width: 440px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  animation: modalIn 0.3s ease-out;
}
.prejoin-title {
  text-align: center;
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 20px;
}
.prejoin-preview {
  position: relative;
  width: 100%;
  aspect-ratio: 16/9;
  background: #1a1715;
  border-radius: 14px;
  overflow: hidden;
  margin-bottom: 16px;
}
.prejoin-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}
.prejoin-no-video {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: rgba(255,255,255,0.5);
  font-size: 13px;
  background: #1a1715;
}
.prejoin-no-video.hidden { display: none; }
.prejoin-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 600;
}
.prejoin-controls {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-bottom: 16px;
}
.prejoin-ctrl-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.prejoin-ctrl-btn {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  background: var(--bg-input);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}
.prejoin-ctrl-btn:hover { border-color: var(--accent); }
.prejoin-ctrl-btn.off {
  background: var(--error);
  border-color: var(--error);
  color: white;
}
.prejoin-ctrl-label {
  font-size: 11px;
  color: var(--text-tertiary);
}
.prejoin-selects {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}
.prejoin-actions {
  display: flex;
  gap: 10px;
}
.prejoin-actions .btn-secondary,
.prejoin-actions .btn-primary {
  flex: 1;
}

/* ═══════════════════════════════════════════
   EMAIL VERIFICATION SCREEN
   ═══════════════════════════════════════════ */

.verify-code-inputs {
  display: flex;
  justify-content: center;
  gap: 8px;
}
.verify-code-inputs input {
  width: 48px;
  height: 56px;
  text-align: center;
  font-size: 24px;
  font-weight: 600;
  font-family: var(--font-body);
  border: 2px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  caret-color: var(--accent);
}
.verify-code-inputs input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.verify-code-inputs input.filled {
  border-color: var(--accent);
  background: var(--accent-soft);
}

#btn-resend-code:disabled {
  color: var(--text-tertiary);
  cursor: not-allowed;
  opacity: 0.6;
}

/* Email verification banner in app */
.email-verify-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 900;
  background: var(--accent-soft);
  border-bottom: 1px solid var(--accent);
  padding: 10px 48px 10px 16px;
  text-align: center;
  font-size: 13px;
  color: var(--accent);
  font-family: var(--font-body);
  animation: slideDown 0.3s ease-out;
}
@keyframes slideDown {
  from { transform: translateY(-100%); }
  to { transform: translateY(0); }
}
.email-verify-banner-close {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  font-size: 20px;
  color: var(--accent);
  cursor: pointer;
  line-height: 1;
  padding: 4px;
  opacity: 0.7;
}
.email-verify-banner-close:hover { opacity: 1; }

@media (max-width: 480px) {
  .verify-code-inputs input {
    width: 40px;
    height: 48px;
    font-size: 20px;
  }
  .verify-code-inputs {
    gap: 6px;
  }
}
