/* ============================================================
   FamilyLink Messenger — Stylesheet
   Aesthetic: Blossom Warm — cream, coral, rounded, premium
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&display=swap');

/* ── Variables ─────────────────────────────────────────────── */
:root {
  --bg:          #FFF8F5;
  --surface:     #FFFFFF;
  --surface2:    #FFF3EE;
  --surface3:    #FFE8DF;
  --primary:     #FF6B6B;
  --primary-d:   #E55555;
  --primary-l:   #FFE0DC;
  --primary-xl:  #FFF0EE;
  --accent:      #FF9055;
  --accent-l:    #FFE9DA;
  --green:       #4CAF9A;
  --green-l:     #D8F5EF;
  --red:         #F44336;
  --red-l:       #FFEBEE;
  --text:        #2D1B14;
  --text-2:      #6B4E42;
  --text-3:      #A08070;
  --border:      #F0DDD4;
  --shadow:      rgba(200, 100, 80, 0.08);
  --shadow-lg:   rgba(200, 100, 80, 0.18);
  --radius:      16px;
  --radius-sm:   10px;
  --radius-lg:   24px;
  --radius-xl:   32px;
  --font:        'Plus Jakarta Sans', system-ui, sans-serif;
  --transition:  0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  height: 100dvh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ── Scrollbars ─────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface3); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary-l); }

/* ── LOGIN SCREEN ────────────────────────────────────────────── */
#login-screen {
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #FFF8F5 0%, #FFE8E0 50%, #FFF0EA 100%);
  position: relative;
  overflow: hidden;
}
#login-screen::before {
  content: '';
  position: absolute;
  width: 600px; height: 600px;
  background: radial-gradient(circle, rgba(255,107,107,.15) 0%, transparent 70%);
  top: -200px; right: -150px;
  border-radius: 50%;
}
#login-screen::after {
  content: '';
  position: absolute;
  width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(255,144,85,.12) 0%, transparent 70%);
  bottom: -100px; left: -100px;
  border-radius: 50%;
}
.login-card {
  background: var(--surface);
  border-radius: var(--radius-xl);
  padding: 2.5rem 2.5rem 2rem;
  width: 380px;
  max-width: calc(100vw - 2rem);
  box-shadow: 0 8px 60px var(--shadow-lg), 0 1px 0 rgba(255,255,255,.8) inset;
  position: relative;
  z-index: 1;
  animation: loginIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes loginIn {
  from { opacity:0; transform:translateY(30px) scale(.96); }
  to   { opacity:1; transform:translateY(0)    scale(1);   }
}
.login-logo {
  display: flex;
  align-items: center;
  gap: .7rem;
  margin-bottom: 1.8rem;
}
.login-logo .logo-icon {
  width: 48px; height: 48px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  box-shadow: 0 4px 16px rgba(255,107,107,.35);
}
.login-logo h1 { font-size: 1.5rem; font-weight: 800; color: var(--text); }
.login-logo span { font-size: .75rem; color: var(--text-3); display: block; font-weight: 500; }
.login-card h2 { font-size: 1.4rem; font-weight: 700; margin-bottom: .4rem; }
.login-card p  { color: var(--text-3); font-size: .9rem; margin-bottom: 1.8rem; }
.input-group { margin-bottom: 1rem; }
.input-group label {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: .4rem;
  letter-spacing: .03em;
}
.input-group input {
  width: 100%;
  padding: .85rem 1.1rem;
  background: var(--surface2);
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: .95rem;
  color: var(--text);
  outline: none;
  transition: var(--transition);
}
.input-group input:focus {
  border-color: var(--primary);
  background: var(--surface);
  box-shadow: 0 0 0 4px var(--primary-xl);
}
.btn-primary {
  width: 100%;
  padding: .9rem;
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  margin-top: .5rem;
  box-shadow: 0 4px 20px rgba(255,107,107,.35);
  letter-spacing: .02em;
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 6px 28px rgba(255,107,107,.45); }
.btn-primary:active { transform: translateY(0); }
.login-error {
  background: var(--red-l);
  color: var(--red);
  padding: .7rem 1rem;
  border-radius: var(--radius-sm);
  font-size: .88rem;
  font-weight: 500;
  margin-top: .8rem;
  display: none;
}

/* ── APP LAYOUT ──────────────────────────────────────────────── */
#app {
  display: none;
  height: 100dvh;
  flex-direction: row;
}
#app.visible { display: flex; }

/* ── SIDEBAR ─────────────────────────────────────────────────── */
#sidebar {
  width: 340px;
  min-width: 340px;
  height: 100dvh;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  transition: transform var(--transition);
  position: relative;
  z-index: 10;
}
.sidebar-header {
  padding: 1.2rem 1.2rem .8rem;
  display: flex;
  align-items: center;
  gap: .8rem;
  border-bottom: 1px solid var(--border);
}
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: .55rem;
  flex: 1;
}
.sidebar-logo .s-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}
.sidebar-logo span { font-size: 1.05rem; font-weight: 800; color: var(--text); }

.sidebar-actions { display: flex; gap: .4rem; }
.icon-btn {
  width: 38px; height: 38px;
  border: none;
  background: var(--surface2);
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-2);
  transition: var(--transition);
  flex-shrink: 0;
  font-size: 1rem;
}
.icon-btn:hover { background: var(--primary-l); color: var(--primary); }
.icon-btn.active { background: var(--primary-l); color: var(--primary); }

/* Search */
.search-box {
  padding: .8rem 1.2rem;
  position: relative;
}
.search-box input {
  width: 100%;
  padding: .65rem 1rem .65rem 2.6rem;
  background: var(--surface2);
  border: 2px solid transparent;
  border-radius: 12px;
  font-family: var(--font);
  font-size: .9rem;
  color: var(--text);
  outline: none;
  transition: var(--transition);
}
.search-box input:focus { border-color: var(--primary); background: var(--surface); }
.search-box::before {
  content: '🔍';
  position: absolute;
  left: 1.85rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: .85rem;
  opacity: .5;
  pointer-events: none;
}

/* Sidebar tabs */
.sidebar-tabs {
  display: flex;
  padding: 0 1.2rem .6rem;
  gap: .4rem;
}
.tab-btn {
  flex: 1;
  padding: .5rem;
  background: transparent;
  border: none;
  border-radius: 10px;
  font-family: var(--font);
  font-size: .82rem;
  font-weight: 600;
  color: var(--text-3);
  cursor: pointer;
  transition: var(--transition);
}
.tab-btn.active { background: var(--primary-l); color: var(--primary); }

/* Conversation list */
#conv-list {
  flex: 1;
  overflow-y: auto;
  padding: .4rem .7rem;
}
.conv-item {
  display: flex;
  align-items: center;
  gap: .9rem;
  padding: .75rem .9rem;
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--transition);
  position: relative;
}
.conv-item:hover   { background: var(--surface2); }
.conv-item.active  { background: var(--primary-xl); }
.avatar-wrap {
  position: relative;
  flex-shrink: 0;
}
.avatar {
  width: 46px; height: 46px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--surface3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary);
  overflow: hidden;
  flex-shrink: 0;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.avatar.group { background: linear-gradient(135deg, var(--primary-l), var(--accent-l)); font-size: .9rem; }
.status-dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--text-3);
  border: 2px solid var(--surface);
  position: absolute;
  bottom: 0; right: 0;
}
.status-dot.online  { background: var(--green); }
.status-dot.offline { background: var(--border); }
.conv-info { flex: 1; overflow: hidden; }
.conv-name {
  font-size: .95rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: .18rem;
}
.conv-last {
  font-size: .8rem;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.conv-last.unread { color: var(--text-2); font-weight: 500; }
.conv-meta { display: flex; flex-direction: column; align-items: flex-end; gap: .3rem; flex-shrink: 0; }
.conv-time { font-size: .72rem; color: var(--text-3); white-space: nowrap; }
.badge {
  background: var(--primary);
  color: #fff;
  font-size: .7rem;
  font-weight: 700;
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  animation: popIn .2s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes popIn { from { transform: scale(0); } to { transform: scale(1); } }

/* Sidebar footer */
.sidebar-footer {
  padding: .9rem 1.2rem;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: .8rem;
}
.my-avatar-wrap {
  position: relative;
  cursor: pointer;
}
.my-info { flex: 1; }
.my-info .my-name { font-size: .9rem; font-weight: 700; color: var(--text); }
.my-info .my-status { font-size: .75rem; color: var(--green); font-weight: 500; }

/* ── CHAT AREA ───────────────────────────────────────────────── */
#chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  background: var(--bg);
  overflow: hidden;
}

/* Empty state */
#chat-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 2rem;
}
#chat-empty .empty-icon {
  font-size: 4rem;
  opacity: .5;
}
#chat-empty h3 { font-size: 1.3rem; font-weight: 700; color: var(--text-2); }
#chat-empty p  { font-size: .9rem; color: var(--text-3); text-align: center; }

/* Chat header */
#chat-header {
  display: flex;
  align-items: center;
  gap: .9rem;
  padding: .9rem 1.4rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  box-shadow: 0 2px 12px var(--shadow);
}
.chat-peer-info { flex: 1; overflow: hidden; }
.chat-peer-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-peer-sub {
  font-size: .78rem;
  color: var(--text-3);
  margin-top: 2px;
}
.chat-peer-sub.online { color: var(--green); }
.chat-call-btns { display: flex; gap: .5rem; }
.call-btn {
  width: 40px; height: 40px;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  transition: var(--transition);
}
.call-btn.video { background: var(--primary-xl); color: var(--primary); }
.call-btn.audio { background: var(--green-l); color: var(--green); }
.call-btn:hover { transform: scale(1.08); }
#back-btn {
  display: none;
  background: transparent;
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
  color: var(--text-2);
  padding: .3rem;
}

/* Messages area */
#messages-area {
  flex: 1;
  overflow-y: auto;
  padding: 1.2rem 1rem;
  display: flex;
  flex-direction: column;
  gap: .35rem;
  scroll-behavior: smooth;
}

/* Date separator */
.date-sep {
  display: flex;
  align-items: center;
  gap: .8rem;
  margin: .6rem 0;
}
.date-sep::before, .date-sep::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}
.date-sep span {
  font-size: .72rem;
  color: var(--text-3);
  font-weight: 600;
  white-space: nowrap;
  letter-spacing: .03em;
}

/* Message bubbles */
.msg-row {
  display: flex;
  align-items: flex-end;
  gap: .5rem;
  animation: msgIn .2s ease;
}
@keyframes msgIn {
  from { opacity:0; transform:translateY(8px); }
  to   { opacity:1; transform:translateY(0); }
}
.msg-row.mine { flex-direction: row-reverse; }
.msg-row .msg-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--surface3);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .7rem;
  font-weight: 700;
  color: var(--primary);
  overflow: hidden;
}
.msg-row .msg-avatar img { width: 100%; height: 100%; object-fit: cover; }
.msg-row.mine .msg-avatar { display: none; }

.bubble-wrap { display: flex; flex-direction: column; max-width: min(70%, 480px); }
.msg-row.mine .bubble-wrap { align-items: flex-end; }
.bubble-sender {
  font-size: .72rem;
  font-weight: 600;
  color: var(--text-3);
  margin-bottom: .2rem;
  padding: 0 .5rem;
}
.bubble {
  padding: .65rem .9rem;
  border-radius: 18px;
  font-size: .9rem;
  line-height: 1.5;
  word-break: break-word;
  position: relative;
}
/* Theirs */
.msg-row:not(.mine) .bubble {
  background: var(--surface);
  color: var(--text);
  border-bottom-left-radius: 5px;
  box-shadow: 0 1px 6px var(--shadow);
}
/* Mine */
.msg-row.mine .bubble {
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  color: #fff;
  border-bottom-right-radius: 5px;
  box-shadow: 0 2px 12px rgba(255,107,107,.3);
}
.bubble-meta {
  display: flex;
  align-items: center;
  gap: .3rem;
  font-size: .68rem;
  color: var(--text-3);
  padding: .1rem .5rem 0;
  flex-wrap: nowrap;
  white-space: nowrap;
}
.msg-row.mine .bubble-meta { justify-content: flex-end; }
.msg-status { color: var(--primary); font-size: .75rem; }
.msg-status.read { color: var(--primary); }

/* Image message */
.bubble.image-bubble {
  padding: .3rem;
  background: transparent !important;
  box-shadow: none !important;
}
.bubble.image-bubble img {
  max-width: 220px;
  max-height: 200px;
  border-radius: 14px;
  display: block;
  cursor: pointer;
  object-fit: cover;
}
/* Call message */
.bubble.call-bubble {
  display: flex;
  align-items: center;
  gap: .6rem;
  font-size: .85rem;
  font-style: italic;
}

/* Reply preview inside bubble */
.reply-preview {
  background: rgba(0,0,0,.08);
  border-left: 3px solid rgba(255,255,255,.5);
  border-radius: 6px;
  padding: .3rem .5rem;
  margin-bottom: .4rem;
  font-size: .78rem;
  opacity: .9;
}
.msg-row:not(.mine) .reply-preview {
  background: var(--surface2);
  border-left-color: var(--primary);
  color: var(--text-2);
}
.reply-preview .rp-name { font-weight: 700; margin-bottom: .15rem; }

/* Typing indicator */
#typing-indicator {
  display: none;
  padding: .4rem 1rem;
  font-size: .8rem;
  color: var(--text-3);
  font-style: italic;
  animation: fadeIn .2s ease;
}
@keyframes fadeIn { from {opacity:0} to {opacity:1} }
.typing-dots { display: inline-flex; gap: 3px; margin-right: .3rem; }
.typing-dots span {
  width: 5px; height: 5px;
  background: var(--text-3);
  border-radius: 50%;
  animation: bounce 1.2s infinite;
}
.typing-dots span:nth-child(2) { animation-delay: .2s; }
.typing-dots span:nth-child(3) { animation-delay: .4s; }
@keyframes bounce {
  0%,80%,100% { transform:translateY(0); }
  40%         { transform:translateY(-5px); }
}

/* ── INPUT BAR ───────────────────────────────────────────────── */
#input-bar {
  padding: .8rem 1rem;
  padding-bottom: calc(.8rem + env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: .5rem;
  flex-shrink: 0;
}

/* Reply bar */
#reply-bar {
  display: none;
  background: var(--primary-xl);
  border-radius: 10px;
  padding: .5rem .8rem;
  font-size: .82rem;
  color: var(--text-2);
  display: none;
  align-items: center;
  gap: .6rem;
}
#reply-bar.visible { display: flex; }
#reply-bar .rb-name { font-weight: 700; color: var(--primary); }
#reply-bar .rb-text { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
#reply-bar .rb-close { cursor: pointer; color: var(--text-3); font-size: 1rem; flex-shrink: 0; }

.input-row {
  display: flex;
  align-items: flex-end;
  gap: .6rem;
}
.attach-btn {
  width: 42px; height: 42px;
  background: var(--surface2);
  border: none;
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  color: var(--text-2);
  transition: var(--transition);
  flex-shrink: 0;
}
.attach-btn:hover { background: var(--primary-l); color: var(--primary); }
#msg-input {
  flex: 1;
  padding: .7rem 1rem;
  background: var(--surface2);
  border: 2px solid transparent;
  border-radius: 14px;
  font-family: var(--font);
  font-size: .95rem;
  color: var(--text);
  outline: none;
  resize: none;
  line-height: 1.4;
  max-height: 120px;
  transition: var(--transition);
}
#msg-input:focus { border-color: var(--primary); background: var(--surface); }
#msg-input::placeholder { color: var(--text-3); }
.send-btn {
  width: 42px; height: 42px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border: none;
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  color: #fff;
  transition: var(--transition);
  flex-shrink: 0;
  box-shadow: 0 3px 12px rgba(255,107,107,.35);
}
.send-btn:hover { transform: scale(1.08); box-shadow: 0 5px 18px rgba(255,107,107,.45); }

/* ── CALL UI ─────────────────────────────────────────────────── */
#call-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  background: rgba(30,10,5,.75);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  align-items: center;
  justify-content: center;
  flex-direction: column;
}
#call-overlay.visible { display: flex; }
#call-overlay.mini {
  inset: auto;
  bottom: 5rem;
  right: 1.5rem;
  left: auto;
  top: auto;
  background: transparent;
  align-items: flex-end;
}

.call-card {
  background: var(--surface);
  border-radius: var(--radius-xl);
  padding: 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.4rem;
  width: 320px;
  box-shadow: 0 20px 80px rgba(0,0,0,.3);
  animation: callIn .35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes callIn { from { opacity:0; transform:scale(.8); } to { opacity:1; transform:scale(1); } }
.call-avatar {
  width: 80px; height: 80px;
  border-radius: 50%;
  background: var(--surface3);
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem; font-weight: 700; color: var(--primary);
  position: relative;
}
.call-avatar.ring::after {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 3px solid var(--primary);
  animation: callRing 1.2s infinite;
}
@keyframes callRing {
  0%   { opacity:1; transform:scale(1); }
  100% { opacity:0; transform:scale(1.4); }
}
.call-name  { font-size: 1.2rem; font-weight: 700; }
.call-status { font-size: .85rem; color: var(--text-3); }
.call-timer  { font-size: 1rem; color: var(--green); font-weight: 600; font-variant-numeric: tabular-nums; }
.call-actions { display: flex; gap: 1rem; }
.call-action {
  width: 56px; height: 56px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
  transition: var(--transition);
}
.call-action:hover { transform: scale(1.1); }
.call-action.end   { background: var(--red);     color: #fff; }
.call-action.ans   { background: var(--green);   color: #fff; }
.call-action.mute  { background: var(--surface2); color: var(--text-2); }
.call-action.cam   { background: var(--surface2); color: var(--text-2); }
.call-action.active { background: var(--primary-l); color: var(--primary); }

/* Video streams */
#video-grid {
  display: none;
  width: 100%;
  max-width: 720px;
  gap: 1rem;
  flex-direction: column;
  align-items: center;
}
#call-overlay.video-call #video-grid { display: flex; }
#call-overlay.video-call .call-card  { width: auto; max-width: 720px; }
#remote-video {
  width: 100%;
  max-height: 360px;
  border-radius: var(--radius-lg);
  background: #111;
  object-fit: cover;
  display: block;
}
#local-video {
  width: 120px; height: 90px;
  border-radius: 12px;
  position: absolute;
  bottom: 1rem;
  right: 1rem;
  background: #333;
  object-fit: cover;
  border: 2px solid var(--surface);
  box-shadow: 0 4px 20px rgba(0,0,0,.3);
}

/* ── INCOMING CALL BANNER ─────────────────────────────────────── */
#incoming-banner {
  position: fixed;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%) translateY(-150%);
  z-index: 200;
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 1rem 1.5rem;
  box-shadow: 0 8px 40px rgba(0,0,0,.2);
  display: flex;
  align-items: center;
  gap: 1rem;
  min-width: 300px;
  max-width: 380px;
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
#incoming-banner.visible { transform: translateX(-50%) translateY(0); }
.ib-info { flex: 1 }
.ib-name { font-weight: 700; font-size: .95rem; }
.ib-type { font-size: .8rem; color: var(--text-3); }
.ib-actions { display: flex; gap: .5rem; }
.ib-btn {
  width: 44px; height: 44px;
  border-radius: 50%; border: none; cursor: pointer;
  font-size: 1.2rem;
  display: flex; align-items: center; justify-content: center;
  transition: var(--transition);
}
.ib-btn:hover { transform: scale(1.1); }
.ib-btn.ans { background: var(--green); color: #fff; }
.ib-btn.rej { background: var(--red);   color: #fff; }

/* ── MESSAGE NOTIFICATION TOAST ──────────────────────────────── */
#toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: .6rem;
  pointer-events: none;
}
.toast {
  background: var(--surface);
  border-radius: var(--radius);
  padding: .85rem 1.1rem;
  box-shadow: 0 6px 30px rgba(0,0,0,.15);
  display: flex;
  align-items: center;
  gap: .8rem;
  max-width: 320px;
  pointer-events: all;
  cursor: pointer;
  animation: toastIn .3s cubic-bezier(0.34, 1.56, 0.64, 1);
  border-left: 4px solid var(--primary);
}
@keyframes toastIn {
  from { opacity:0; transform:translateX(60px); }
  to   { opacity:1; transform:translateX(0); }
}
.toast.out {
  animation: toastOut .25s ease forwards;
}
@keyframes toastOut {
  to { opacity:0; transform:translateX(60px); }
}
.toast-avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--surface3);
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: .85rem; font-weight: 700; color: var(--primary);
  overflow: hidden;
}
.toast-avatar img { width: 100%; height: 100%; object-fit: cover; }
.toast-body { flex: 1; overflow: hidden; }
.toast-name { font-size: .85rem; font-weight: 700; margin-bottom: .15rem; }
.toast-text { font-size: .8rem; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── PROFILE MODAL ───────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(30,10,5,.4);
  backdrop-filter: blur(6px);
  z-index: 150;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal-overlay.visible { display: flex; }
.modal {
  background: var(--surface);
  border-radius: var(--radius-xl);
  padding: 2rem;
  width: 400px;
  max-width: 100%;
  box-shadow: 0 20px 80px rgba(0,0,0,.2);
  animation: callIn .3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.modal h3 { font-size: 1.2rem; font-weight: 700; margin-bottom: 1.5rem; }
.modal .close-btn {
  float: right;
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: var(--text-3);
  margin-top: -.3rem;
}
.avatar-upload-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .8rem;
  margin-bottom: 1.5rem;
}
.avatar-upload-wrap .big-avatar {
  width: 80px; height: 80px;
  border-radius: 50%;
  background: var(--surface3);
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem; font-weight: 700; color: var(--primary);
  cursor: pointer;
  position: relative;
}
.avatar-upload-wrap .big-avatar::after {
  content: '📷';
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.4);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem;
  opacity: 0;
  transition: var(--transition);
  border-radius: 50%;
}
.avatar-upload-wrap .big-avatar:hover::after { opacity: 1; }
.modal-actions { display: flex; gap: .8rem; margin-top: 1.5rem; }
.btn-secondary {
  flex: 1;
  padding: .8rem;
  background: var(--surface2);
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-2);
  transition: var(--transition);
}
.btn-secondary:hover { background: var(--surface3); }
.modal-actions .btn-primary { flex: 2; margin-top: 0; padding: .8rem; }

/* ── INSTALL PROMPT ──────────────────────────────────────────── */
#install-prompt {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(150%);
  z-index: 100;
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.4rem;
  box-shadow: 0 8px 40px rgba(0,0,0,.18);
  display: flex;
  align-items: center;
  gap: 1rem;
  max-width: 380px;
  width: calc(100vw - 2rem);
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
#install-prompt.visible { transform: translateX(-50%) translateY(0); }
#install-prompt p { flex: 1; font-size: .85rem; color: var(--text-2); line-height: 1.4; }
#install-prompt p strong { color: var(--text); }
#install-prompt .ip-btn {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: .6rem 1rem;
  font-family: var(--font);
  font-size: .85rem;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
}
#install-prompt .ip-close {
  background: none; border: none; font-size: 1.1rem;
  color: var(--text-3); cursor: pointer; flex-shrink: 0; padding: 0 .2rem;
}

/* ── RESPONSIVE ──────────────────────────────────────────────── */
@media (max-width: 768px) {
  #sidebar {
    position: fixed;
    padding-top: env(safe-area-inset-top);
    left: 0; top: 0; bottom: 0;
    transform: translateX(-100%);
    box-shadow: 4px 0 30px rgba(0,0,0,.12);
  }
  #sidebar.open { transform: translateX(0); }
  #chat-area { flex: 1; }
  #back-btn  { display: flex !important; }
  #toast-container { right: .5rem; left: .5rem; }
  .toast { max-width: 100%; }
  #call-overlay:not(.mini) { padding: 1rem; }
  .call-card { width: 100%; max-width: 380px; }
  #local-video { width: 90px; height: 68px; }
}

/* ── UTILS ───────────────────────────────────────────────────── */
.hidden { display: none !important; }
.spin   { animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
