/* ─── RESET & BASE ───────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:          #0f1117;
  --surface:     #161b22;
  --surface2:    #1c2128;
  --surface3:    #21262d;
  --border:      rgba(255,255,255,0.07);
  --border2:     rgba(255,255,255,0.12);
  --green:       #3fb950;
  --green-dark:  #2ea043;
  --green-dim:   rgba(63,185,80,0.15);
  --text:        #e6edf3;
  --text-muted:  #7d8590;
  --text-dim:    #484f58;
  --sent-bg:     #1f3d28;
  --recv-bg:     #21262d;
  --active:      #1a2e1d;
  --hover:       rgba(255,255,255,0.04);
  --danger:      #f85149;
  --danger-dim:  rgba(248,81,73,0.12);
  --warn:        #d29922;
}

html, body {
  height: 100%;
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  user-select: none;
}

.hidden { display: none !important; }

/* ─── AUTH SCREEN ────────────────────────────────────────────────────────── */
.auth-screen {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 30% 60%, rgba(63,185,80,0.06) 0%, transparent 60%),
              var(--bg);
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 20px;
  padding: 36px 32px 28px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.6);
}

.auth-logo {
  width: 56px; height: 56px;
  border-radius: 16px;
  background: var(--green-dim);
  color: var(--green);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 14px;
}

.auth-title {
  text-align: center;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.3px;
  margin-bottom: 22px;
}

.auth-tabs {
  display: flex;
  background: var(--surface3);
  border-radius: 10px;
  padding: 3px;
  margin-bottom: 22px;
}

.auth-tab {
  flex: 1;
  padding: 8px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.auth-tab.active {
  background: var(--surface2);
  color: var(--text);
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

.auth-form { display: none; flex-direction: column; gap: 14px; }
.auth-form.active { display: flex; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12.5px; font-weight: 500; color: var(--text-muted); letter-spacing: 0.3px; }
.field input {
  background: var(--surface3);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  padding: 10px 14px;
  outline: none;
  transition: border-color 0.2s;
  user-select: text;
}
.field input:focus { border-color: var(--green); }
.field input::placeholder { color: var(--text-dim); }

.form-error {
  font-size: 12.5px;
  color: var(--danger);
  min-height: 16px;
  text-align: center;
}

.btn-primary {
  background: var(--green);
  border: none;
  border-radius: 12px;
  color: #fff;
  font-family: inherit;
  font-size: 14.5px;
  font-weight: 600;
  padding: 12px;
  cursor: pointer;
  transition: background 0.15s, transform 0.12s;
  margin-top: 4px;
}
.btn-primary:hover { background: var(--green-dark); }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border2);
  border-radius: 12px;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 13.5px;
  padding: 10px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.btn-ghost:hover { background: var(--hover); color: var(--text); }

.otp-hint {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.5;
}
.otp-hint strong { color: var(--text); }

/* ─── APP LAYOUT ─────────────────────────────────────────────────────────── */
.app-screen {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ─── SIDEBAR ────────────────────────────────────────────────────────────── */
.sidebar {
  width: 360px;
  min-width: 220px;
  max-width: 55vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  flex-shrink: 0;
  position: relative;
  z-index: 10;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 26px 22px 18px;
}
.sidebar-header h1 { font-size: 21px; font-weight: 600; letter-spacing: -0.3px; }
.sidebar-header-actions { display: flex; gap: 4px; }

.icon-btn {
  width: 34px; height: 34px;
  border-radius: 9px; border: none;
  background: transparent; color: var(--text-muted);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, color 0.15s; flex-shrink: 0;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn.active { color: var(--green); }

.search-wrap { padding: 0 14px 10px; }
.search-box {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface3); border: 1px solid var(--border);
  border-radius: 11px; padding: 8px 13px; transition: border-color 0.2s;
}
.search-box:focus-within { border-color: var(--green); }
.search-box svg { color: var(--text-muted); flex-shrink: 0; }
.search-box input {
  background: none; border: none; outline: none;
  color: var(--text); font-family: inherit; font-size: 13.5px; width: 100%; user-select: text;
}
.search-box input::placeholder { color: var(--text-dim); }

.contact-list {
  flex: 1; overflow-y: auto; padding: 4px 0 80px;
}
.contact-list::-webkit-scrollbar { width: 4px; }
.contact-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* contact item */
.contact-item {
  display: flex; align-items: center; gap: 13px;
  padding: 13px 18px; cursor: pointer;
  border-left: 3px solid transparent;
  transition: background 0.13s, border-color 0.13s;
  position: relative;
}
.contact-item:hover { background: var(--hover); }
.contact-item.active { background: var(--active); border-left-color: var(--green); }
.contact-item.pinned .contact-name::before {
  content: '📌 ';
  font-size: 10px;
}

.avatar {
  width: 44px; height: 44px; border-radius: 13px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 14px; flex-shrink: 0; letter-spacing: 0.5px;
}

.contact-info { flex: 1; min-width: 0; }
.contact-row1 { display: flex; align-items: center; justify-content: space-between; margin-bottom: 3px; }
.contact-name { font-weight: 500; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 160px; }
.contact-meta { display: flex; align-items: center; gap: 5px; flex-shrink: 0; }
.contact-time { font-size: 11px; color: var(--text-muted); }
.unread-badge {
  background: var(--green);
  color: #fff;
  font-size: 10.5px;
  font-weight: 600;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  padding: 0 5px;
  display: flex; align-items: center; justify-content: center;
}
.contact-preview-row { display: flex; align-items: center; gap: 6px; }
.contact-preview {
  font-size: 12.5px; color: var(--text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1;
}
.contact-preview.unread { color: var(--text); font-weight: 500; }

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

.more-btn {
  opacity: 0; width: 26px; height: 26px; border-radius: 7px;
  border: none; background: var(--surface3); color: var(--text-muted);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  transition: opacity 0.13s, background 0.13s; z-index: 2;
}
.contact-item:hover .more-btn { opacity: 1; }
.more-btn:hover { background: var(--surface); color: var(--text); }

/* spinner */
.list-spinner { display: flex; justify-content: center; padding: 32px; }
.spinner {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid var(--border2);
  border-top-color: var(--green);
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* FAB */
.fab {
  position: absolute; bottom: 22px; right: 22px;
  width: 50px; height: 50px; border-radius: 15px;
  background: var(--green); border: none; color: #fff;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 20px rgba(63,185,80,0.35);
  transition: background 0.15s, transform 0.15s, box-shadow 0.15s; z-index: 20;
}
.fab:hover { background: var(--green-dark); transform: scale(1.06); box-shadow: 0 6px 26px rgba(63,185,80,0.45); }
.fab:active { transform: scale(0.97); }

.add-popup {
  display: none;
  position: absolute; bottom: 80px; right: 18px;
  background: var(--surface2); border: 1px solid var(--border2);
  border-radius: 13px; padding: 12px; width: 260px; z-index: 30;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
.add-popup.show { display: flex; gap: 8px; animation: popIn 0.18s ease; }
@keyframes popIn {
  from { opacity: 0; transform: scale(0.92) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.add-popup input {
  flex: 1; background: var(--surface3); border: 1px solid var(--border);
  border-radius: 9px; color: var(--text); font-family: inherit;
  font-size: 13px; padding: 8px 12px; outline: none; transition: border-color 0.2s; user-select: text;
}
.add-popup input:focus { border-color: var(--green); }
.add-popup .add-btn {
  background: var(--green); border: none; border-radius: 9px; color: #fff;
  font-family: inherit; font-weight: 600; font-size: 13px; padding: 8px 13px;
  cursor: pointer; transition: background 0.15s; white-space: nowrap;
}
.add-popup .add-btn:hover { background: var(--green-dark); }
.add-popup .close-btn {
  background: var(--surface3); border: none; border-radius: 9px;
  color: var(--text-muted); font-size: 18px; width: 34px; flex-shrink: 0;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.add-popup .close-btn:hover { background: var(--surface); color: var(--text); }

/* ─── RESIZER ────────────────────────────────────────────────────────────── */
.resizer {
  width: 5px; cursor: col-resize; flex-shrink: 0;
  background: transparent; position: relative; z-index: 15;
  transition: background 0.2s;
}
.resizer:hover { background: rgba(63,185,80,0.2); }
.resizer.dragging { background: rgba(63,185,80,0.45) !important; }
.resizer::after {
  content: ''; position: absolute; top: 50%; left: 50%;
  transform: translate(-50%,-50%);
  width: 1px; height: 48px; background: var(--border); border-radius: 2px;
  transition: background 0.2s, height 0.2s;
}
.resizer:hover::after { background: var(--green); height: 64px; }
.resizer.dragging::after { background: var(--green); height: 80px; }

/* ─── CHAT PANEL ─────────────────────────────────────────────────────────── */
.chat-panel {
  flex: 1; display: flex; flex-direction: column;
  height: 100vh;
  height: 100dvh; /* dynamic viewport height — shrinks when keyboard appears */
  background: var(--bg); min-width: 0;
}

.empty-state {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px;
  animation: fadeUp 0.3s ease;
}
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.empty-icon {
  width: 76px; height: 76px; border-radius: 22px;
  background: var(--green-dim); display: flex; align-items: center; justify-content: center;
  margin-bottom: 4px;
}
.empty-icon svg { color: var(--green); }
.empty-state h2 { font-size: 19px; font-weight: 600; }
.empty-state p  { font-size: 13.5px; color: var(--text-muted); }

/* chat header */
.chat-header {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  background: var(--surface); flex-shrink: 0;
}
.chat-header .avatar { width: 40px; height: 40px; border-radius: 12px; font-size: 14px; }
.chat-header-info { flex: 1; min-width: 0; }
.chat-header-info .cname { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-header-info .cstatus { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }
.chat-header-info .cstatus.online { color: var(--green); }
.chat-header-actions { display: flex; gap: 4px; align-items: center; flex-shrink: 0; }

.back-btn {
  display: none; width: 34px; height: 34px; border-radius: 9px;
  border: none; background: transparent; color: var(--text-muted);
  cursor: pointer; align-items: center; justify-content: center;
  transition: background 0.15s, color 0.15s; flex-shrink: 0;
}
.back-btn:hover { background: var(--hover); color: var(--text); }

/* typing indicator */
.typing-indicator {
  display: none;
  align-items: center;
  gap: 4px;
  padding: 6px 16px 0;
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
}
.typing-indicator.show { display: flex; }
.typing-dots span {
  display: inline-block;
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: blink 1.2s infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%,80%,100% { opacity: 0.2; } 40% { opacity: 1; } }

/* messages */
.messages-wrap {
  flex: 1; overflow-y: auto; padding: 18px 22px;
  display: flex; flex-direction: column; gap: 8px; scroll-behavior: smooth; user-select: text;
}
.messages-wrap::-webkit-scrollbar { width: 4px; }
.messages-wrap::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.msg {
  max-width: 66%; display: flex; flex-direction: column;
  animation: msgIn 0.2s ease;
}
@keyframes msgIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
.msg.sent  { align-self: flex-end;  align-items: flex-end;  }
.msg.recv  { align-self: flex-start; align-items: flex-start; }

.bubble {
  padding: 10px 15px; border-radius: 18px;
  font-size: 13.5px; line-height: 1.55; word-break: break-word; position: relative;
}
.msg.sent .bubble {
  background: var(--sent-bg); border-bottom-right-radius: 5px;
  border: 1px solid rgba(63,185,80,0.18); color: #d2f4d8;
}
.msg.recv .bubble {
  background: var(--recv-bg); border-bottom-left-radius: 5px;
  border: 1px solid var(--border); color: var(--text);
}
.bubble.deleted-msg {
  font-style: italic; color: var(--text-dim) !important;
  background: transparent !important; border-style: dashed !important;
}

.msg-footer {
  display: flex; align-items: center; gap: 5px;
  font-size: 10.5px; color: var(--text-dim); margin-top: 3px; padding: 0 3px;
}
.msg.sent .msg-footer { flex-direction: row-reverse; }
.read-tick { color: var(--green); font-size: 12px; }

/* message context menu trigger */
.bubble:hover .msg-menu-btn { opacity: 1; }
.msg-menu-btn {
  opacity: 0; position: absolute; top: 4px;
  background: var(--surface2); border: none; border-radius: 5px;
  color: var(--text-muted); width: 22px; height: 22px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  font-size: 14px; line-height: 1; transition: opacity 0.15s, background 0.15s;
  z-index: 3;
}
.msg.sent  .msg-menu-btn { right: -28px; }
.msg.recv  .msg-menu-btn { right: -28px; }
.msg-menu-btn:hover { background: var(--surface); color: var(--text); opacity: 1; }

.date-sep {
  display: flex; align-items: center; gap: 10px;
  color: var(--text-dim); font-size: 11.5px; margin: 6px 0;
}
.date-sep::before, .date-sep::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* load more */
.load-more-btn {
  align-self: center;
  background: var(--surface3); border: 1px solid var(--border);
  border-radius: 20px; color: var(--text-muted);
  font-family: inherit; font-size: 12px; padding: 6px 16px;
  cursor: pointer; transition: background 0.15s, color 0.15s; margin-bottom: 6px;
}
.load-more-btn:hover { background: var(--hover); color: var(--text); }

/* input bar */
.input-bar {
  display: flex; align-items: flex-end; gap: 10px;
  padding: 13px 18px;
  padding-bottom: calc(13px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border);
  background: var(--surface); flex-shrink: 0;
  position: sticky; bottom: 0; z-index: 5;
}
.msg-input {
  flex: 1; background: var(--surface3); border: 1px solid var(--border);
  border-radius: 13px; color: var(--text); font-family: inherit;
  font-size: 13.5px; padding: 10px 16px; outline: none;
  transition: border-color 0.2s; resize: none; user-select: text;
  max-height: 120px; overflow-y: auto; line-height: 1.5;
}
.msg-input:focus { border-color: var(--green); }
.msg-input::placeholder { color: var(--text-dim); }
.send-btn {
  width: 42px; height: 42px; border-radius: 12px;
  background: var(--green); border: none; color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  transition: background 0.15s, transform 0.12s;
  box-shadow: 0 2px 10px rgba(63,185,80,0.3);
}
.send-btn:hover { background: var(--green-dark); transform: scale(1.05); }
.send-btn:active { transform: scale(0.95); }

/* ─── DROPDOWN ───────────────────────────────────────────────────────────── */
.dropdown {
  position: fixed;
  background: var(--surface2); border: 1px solid var(--border2);
  border-radius: 12px; padding: 6px; min-width: 190px; z-index: 99999;
  box-shadow: 0 12px 40px rgba(0,0,0,0.65), 0 2px 8px rgba(0,0,0,0.4);
  display: none;
}
.dropdown.show { display: block; animation: dropIn 0.14s ease; }
@keyframes dropIn {
  from { opacity: 0; transform: scale(0.93) translateY(-4px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.dd-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 8px; cursor: pointer;
  font-size: 13.5px; color: var(--text-muted);
  transition: background 0.1s, color 0.1s; white-space: nowrap;
}
.dd-item:hover { background: var(--hover); color: var(--text); }
.dd-item.danger { color: var(--danger); }
.dd-item.danger:hover { background: var(--danger-dim); }
.dd-item svg { flex-shrink: 0; opacity: 0.75; }
.dd-sep { height: 1px; background: var(--border); margin: 5px 0; }
.dd-item.disabled { opacity: 0.4; cursor: default; pointer-events: none; }

/* ─── CALL OVERLAY ───────────────────────────────────────────────────────── */
.call-overlay {
  position: fixed; inset: 0; z-index: 10000;
  background: rgba(0,0,0,0.75); backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
}

.call-box {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 24px;
  padding: 36px 32px 28px;
  min-width: 300px; max-width: 380px;
  text-align: center;
  box-shadow: 0 32px 80px rgba(0,0,0,0.6);
  position: relative;
  transition: all 0.3s ease;
}

/* Video call full-screen mode */
.call-box.video-mode {
  min-width: 0;
  max-width: 100vw;
  width: 100vw;
  height: 100vh;
  border-radius: 0;
  padding: 0;
  background: #000;
  display: flex;
  align-items: stretch;
  justify-content: stretch;
}
.call-box.video-mode .call-section { width: 100%; height: 100%; justify-content: flex-end; padding-bottom: 32px; }
.call-box.video-mode #remote-video {
  position: absolute; inset: 0; width: 100%; height: 100%;
  max-height: none; border-radius: 0; object-fit: cover; z-index: 0;
}
.call-box.video-mode #local-video {
  position: absolute; bottom: 100px; right: 18px;
  width: 120px; height: 90px; border-radius: 12px;
  border: 2px solid rgba(255,255,255,0.3); z-index: 2; object-fit: cover;
}
.call-box.video-mode .call-controls {
  position: relative; z-index: 3;
  background: rgba(0,0,0,0.45); border-radius: 40px; padding: 8px 18px;
}
.call-box.video-mode .call-avatar,
.call-box.video-mode .call-name-act,
.call-box.video-mode .call-timer { position: relative; z-index: 3; color: #fff; }

.call-section { display: flex; flex-direction: column; align-items: center; gap: 14px; }

.call-avatar {
  width: 76px; height: 76px; border-radius: 22px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 26px; letter-spacing: 1px;
  margin-bottom: 4px;
}
.call-name    { font-size: 20px; font-weight: 600; }
.call-subtitle { font-size: 13px; color: var(--text-muted); }
.call-timer   { font-size: 13px; color: var(--green); font-variant-numeric: tabular-nums; }

.call-actions { display: flex; gap: 20px; margin-top: 10px; }
.call-btn {
  width: 60px; height: 60px; border-radius: 50%; border: none;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: transform 0.15s, background 0.15s;
}
.call-btn:hover { transform: scale(1.08); }
.call-btn.accept { background: var(--green); color: #fff; }
.call-btn.decline { background: var(--danger); color: #fff; }

.call-controls { display: flex; gap: 14px; margin-top: 8px; }
.ctrl-btn {
  width: 48px; height: 48px; border-radius: 50%; border: none;
  background: var(--surface3); color: var(--text-muted); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.ctrl-btn:hover { background: var(--hover); color: var(--text); }
.ctrl-btn.danger { background: var(--danger); color: #fff; }
.ctrl-btn.active { background: var(--green-dim); color: var(--green); }

.call-video {
  width: 100%; border-radius: 12px; background: #000;
  max-height: 220px; object-fit: cover; margin-top: 4px;
}
.call-video.local {
  width: 100px; height: 75px; position: absolute;
  bottom: 120px; right: 24px; border-radius: 10px; border: 2px solid var(--border2);
}

/* username under name in chat header */
.cusername {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.2px;
}

/* load spinner for pagination */
.load-spinner {
  display: flex; justify-content: center; padding: 12px 0;
}

/* ─── TOAST ──────────────────────────────────────────────────────────────── */
#toast-container {
  position: fixed; bottom: 24px; right: 24px;
  display: flex; flex-direction: column; gap: 8px; z-index: 99998;
  pointer-events: none;
}
.toast {
  background: var(--surface2); border: 1px solid var(--border2);
  border-radius: 10px; padding: 10px 16px;
  font-size: 13px; color: var(--text);
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
  animation: slideIn 0.2s ease;
  max-width: 300px;
}
.toast.error { border-color: var(--danger); color: var(--danger); }
.toast.success { border-color: var(--green); color: var(--green); }
@keyframes slideIn { from { opacity:0; transform: translateX(20px); } to { opacity:1; transform: translateX(0); } }

/* ─── AVATAR PALETTES ────────────────────────────────────────────────────── */
.av-0 { background: #1a3547; color: #58b5e8; }
.av-1 { background: #2a1f42; color: #9e7fe0; }
.av-2 { background: #3a1e1e; color: #e07070; }
.av-3 { background: #1e3526; color: #52c27a; }
.av-4 { background: #3a2e0e; color: #d4a82e; }
.av-5 { background: #1e2e3a; color: #4e9fd4; }
.av-6 { background: #2e1e35; color: #b870d0; }
.av-7 { background: #2e2216; color: #c8864e; }

/* ─── MOBILE ─────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .resizer { display: none !important; }

  .app-screen {
    height: 100dvh;
    overflow: hidden;
  }

  .sidebar {
    width: 100vw !important; min-width: 100vw !important; max-width: 100vw !important;
    position: fixed; top: 0; left: 0; z-index: 20;
    height: 100dvh;
    transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
  }
  .sidebar.slide-out { transform: translateX(-100%); }

  .chat-panel {
    position: fixed; top: 0; left: 0;
    width: 100vw;
    height: 100dvh;
    z-index: 10;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
    overflow: hidden;
  }
  .chat-panel.slide-in { transform: translateX(0); }

  .messages-wrap {
    /* allow messages area to shrink when keyboard opens */
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .back-btn { display: flex !important; }
  .call-video { max-height: 50vh; }
}
