/* ==========================================================================
   MeetVibe — WhatsApp Business-inspired design system
   MeetVibe identity preserved: indigo → violet → pink brand gradient, dark UI.
   ========================================================================== */

:root {
  --bg: #0b0e1a;          /* app canvas / chat wallpaper base */
  --bg2: #111528;         /* rails, list panels */
  --surface: #171b30;     /* cards, headers, incoming bubbles */
  --surface2: #20253f;    /* raised controls, chips */
  --surface3: #272d4d;    /* hover */
  --border: #2a3050;
  --text: #eef0fb;
  --text2: #a6adcd;
  --muted: #727aa0;
  --primary: #6366f1;
  --primary2: #8b5cf6;
  --pink: #ec4899;
  --green: #22c55e;
  --red: #ef4444;
  --amber: #f59e0b;
  --cyan: #22d3ee;
  --accent: var(--primary);
  --danger: var(--red);
  --radius: 16px;
  --radius-sm: 12px;
  --radius-lg: 22px;
  --shadow: 0 18px 44px rgba(3, 5, 15, .55);
  --shadow-sm: 0 6px 18px rgba(3, 5, 15, .35);
  --grad: linear-gradient(135deg, #6366f1, #8b5cf6 55%, #ec4899);
  --wall: radial-gradient(rgba(139, 92, 246, .08) 1.3px, transparent 1.3px);
  font-size: 15px;
}

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

html, body, #app { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(900px 600px at 85% -10%, rgba(99, 102, 241, .12), transparent 60%),
    radial-gradient(700px 500px at 5% 110%, rgba(236, 72, 153, .08), transparent 60%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ------------------------------- Scrollbars ------------------------------ */
* { scrollbar-width: thin; scrollbar-color: #333a63 transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #333a63; border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: #454d80; }

a { color: var(--primary2); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; color: inherit; cursor: pointer; background: none; border: none; }
img { max-width: 100%; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* --------------------------------- Buttons ------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: 999px; font-weight: 700; font-size: .9rem;
  border: 1px solid transparent; transition: transform .1s ease, background .15s ease, box-shadow .15s ease, filter .15s ease;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn-primary { background: var(--grad); color: #fff; box-shadow: 0 8px 22px rgba(99, 102, 241, .35); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-success { background: rgba(34, 197, 94, .16); color: #4ade80; border-color: rgba(34, 197, 94, .35); }
.btn-success:hover { background: rgba(34, 197, 94, .24); }
.btn-danger { background: rgba(239, 68, 68, .14); color: #fca5a5; border-color: rgba(239, 68, 68, .35); }
.btn-danger:hover { background: rgba(239, 68, 68, .24); }
.btn-ghost { background: var(--surface2); color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface3); }
.btn-ghost.active, .btn-ghost.active:hover { background: rgba(99, 102, 241, .2); border-color: rgba(99, 102, 241, .5); color: #c7cbff; }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: .8rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-icon {
  width: 40px; height: 40px; flex-shrink: 0; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text2); transition: background .15s, color .15s, transform .1s;
}
.btn-icon:hover { background: var(--surface3); color: var(--text); }
.btn-icon:active { transform: scale(.94); }
.btn-icon svg { width: 19px; height: 19px; }

/* --------------------------------- Inputs -------------------------------- */
.input, .textarea, .select {
  width: 100%; padding: 12px 15px; border-radius: var(--radius-sm);
  background: var(--bg2); border: 1.5px solid var(--border); color: var(--text);
  outline: none; transition: border .15s ease, box-shadow .15s ease, background .15s ease;
}
.input::placeholder, .textarea::placeholder { color: var(--muted); }
.input:focus, .textarea:focus, .select:focus {
  border-color: var(--primary); background: var(--surface);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, .22);
}
.textarea { resize: vertical; min-height: 84px; }
.select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; }
.label { display: block; font-size: .78rem; font-weight: 700; color: var(--text2); margin-bottom: 6px; letter-spacing: .02em; }
.field { margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }

/* ---------------------------------- Cards -------------------------------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-sm);
}
.muted { color: var(--muted); }
.text2 { color: var(--text2); }

/* --------------------------------- Avatars ------------------------------- */
.avatar {
  border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; flex-shrink: 0; user-select: none;
  position: relative; letter-spacing: .5px; overflow: hidden; line-height: 1;
}
.status-dot {
  position: absolute; bottom: 1px; right: 1px; width: 12px; height: 12px;
  border-radius: 50%; background: var(--muted); border: 2.5px solid var(--bg2);
}
.status-dot.online { background: var(--green); }
.status-dot.on_call { background: var(--cyan); }
.status-dot.away { background: var(--amber); }

/* ================================ Shell ================================== */
.shell { display: flex; height: 100%; }

.sidebar {
  width: 264px; flex-shrink: 0; background: var(--bg2);
  border-right: 1px solid var(--border); display: flex; flex-direction: column;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 18px 18px 12px; }
.brand .logo {
  width: 38px; height: 38px; border-radius: 12px; background: var(--grad);
  display: flex; align-items: center; justify-content: center; font-size: 1.15rem; color: #fff;
  box-shadow: 0 8px 20px rgba(99, 102, 241, .4);
}
.brand h1 {
  font-size: 1.2rem; font-weight: 800; letter-spacing: -.02em;
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}

.nav { flex: 1; padding: 8px 12px; overflow-y: auto; }
.nav-section { font-size: .68rem; text-transform: uppercase; letter-spacing: 1.2px; color: var(--muted); padding: 16px 12px 6px; font-weight: 800; }
.nav-item {
  display: flex; align-items: center; gap: 13px; padding: 11px 13px; border-radius: 12px;
  color: var(--text2); font-weight: 650; font-size: .95rem; cursor: pointer; position: relative;
  transition: background .13s, color .13s;
}
.nav-item:hover { background: var(--surface); color: var(--text); }
.nav-item.active { background: rgba(99, 102, 241, .16); color: #cfd2ff; }
.nav-item.active::before {
  content: ''; position: absolute; left: 3px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 20px; border-radius: 3px; background: var(--grad);
}
.nav-item svg { width: 20px; height: 20px; flex-shrink: 0; }
.nav-item .badge {
  margin-left: auto; background: var(--grad); color: #fff; font-size: .72rem; font-weight: 800;
  min-width: 20px; height: 20px; border-radius: 999px; display: flex; align-items: center; justify-content: center; padding: 0 6px;
}

.me-card {
  margin: 10px 12px 14px; padding: 10px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.me-card .info { flex: 1; min-width: 0; }
.me-card .name { font-weight: 700; font-size: .92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-card .status { font-size: .76rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--bg); }
.page { flex: 1; overflow-y: auto; }
.page-inner { max-width: 900px; margin: 0 auto; padding: 26px 22px 90px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h2 { font-size: 1.5rem; font-weight: 800; letter-spacing: -.02em; }

.burger {
  display: none; width: 42px; height: 42px; border-radius: 12px; align-items: center;
  justify-content: center; background: var(--surface2); border: 1px solid var(--border);
  margin: 12px 14px; flex-shrink: 0; color: var(--text2);
}
.burger svg { width: 22px; height: 22px; }

.nav-icon { display: flex; align-items: center; flex-shrink: 0; }
.nav-label { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.topbar { display: none; align-items: center; gap: 10px; padding: 10px 12px; background: var(--bg2); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 30; }
.topbar-title { font-weight: 800; font-size: 1.05rem; letter-spacing: -.01em; }

/* ================================= Auth ================================== */
.auth-wrap {
  min-height: 100%; display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(720px 460px at 12% 8%, rgba(99, 102, 241, .25), transparent 65%),
    radial-gradient(720px 460px at 88% 92%, rgba(236, 72, 153, .2), transparent 65%),
    var(--bg);
  padding: 24px;
}
.auth-card { width: 100%; max-width: 430px; }
.auth-logo { text-align: center; margin-bottom: 26px; }
.auth-logo .orb {
  width: 68px; height: 68px; border-radius: 22px; margin: 0 auto 16px;
  background: var(--grad); display: flex; align-items: center; justify-content: center;
  font-size: 2rem; color: #fff; box-shadow: 0 18px 44px rgba(99, 102, 241, .45);
}
.auth-logo h1 { font-size: 1.85rem; font-weight: 800; letter-spacing: -.02em; }
.auth-logo p { color: var(--text2); margin-top: 6px; }
.auth-card .card { box-shadow: var(--shadow); }
.auth-tabs { display: flex; background: var(--bg2); border-radius: 999px; padding: 4px; margin-bottom: 20px; }
.auth-tabs button { flex: 1; padding: 10px; border-radius: 999px; font-weight: 700; color: var(--text2); transition: .15s; }
.auth-tabs button.active { background: var(--grad); color: #fff; box-shadow: 0 6px 16px rgba(99, 102, 241, .35); }
.auth-error {
  background: rgba(239, 68, 68, .12); border: 1px solid rgba(239, 68, 68, .3); color: #fca5a5;
  padding: 11px 14px; border-radius: var(--radius-sm); margin-bottom: 14px; font-size: .88rem;
}
.auth-forgot:hover { text-decoration: underline; }

/* =============================== Discover =============================== */
.searchbar { position: relative; margin-bottom: 20px; }
.searchbar svg { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--muted); }
.searchbar .input { padding-left: 44px; border-radius: 999px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(228px, 1fr)); gap: 16px; }
.user-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px 18px; text-align: center; transition: transform .14s, border .14s, box-shadow .14s;
}
.user-card:hover { transform: translateY(-3px); border-color: rgba(99, 102, 241, .55); box-shadow: var(--shadow-sm); }
.user-card .avatar { margin: 0 auto 12px; }
.user-card .name { font-weight: 750; font-size: 1.02rem; }
.user-card .handle { color: var(--muted); font-size: .8rem; }
.user-card .bio {
  color: var(--text2); font-size: .85rem; margin: 10px 0 14px; min-height: 36px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.user-card .actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 8px; }
.chip { background: var(--surface2); border: 1px solid var(--border); color: var(--text2); font-size: .73rem; padding: 4px 11px; border-radius: 999px; }

.searchbar { position: relative; margin-bottom: 20px; }
.searchbar svg { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--muted); }
.searchbar .input { padding-left: 44px; border-radius: 999px; }

.empty { text-align: center; padding: 56px 20px; color: var(--muted); }
.empty .big { font-size: 2.8rem; margin-bottom: 12px; }
.empty h3 { color: var(--text); font-size: 1.05rem; margin-bottom: 4px; }

/* =============================== Friends ================================= */
.sec-title {
  font-size: .74rem; font-weight: 800; color: var(--text2); text-transform: uppercase;
  letter-spacing: 1px; margin: 26px 0 10px; display: flex; align-items: center; gap: 8px;
}
.sec-title .count { background: var(--surface2); color: var(--text2); border-radius: 999px; padding: 1px 9px; font-size: .72rem; }
.friend-row {
  display: flex; align-items: center; gap: 13px; padding: 11px 12px; border-radius: 14px;
  transition: background .13s;
}
.friend-row:hover { background: var(--surface); }
.friend-row .info { flex: 1; min-width: 0; }
.friend-row .name { font-weight: 700; font-size: .95rem; cursor: pointer; }
.friend-row .sub { font-size: .8rem; color: var(--muted); }

/* ================================= Chat ================================== */
.chat-layout { display: flex; height: 100%; }

.chat-list {
  width: 340px; flex-shrink: 0; border-right: 1px solid var(--border);
  display: flex; flex-direction: column; background: var(--bg2);
}
.chat-list .head { padding: 16px 16px 8px; }
.chat-list .head h2 { font-size: 1.35rem; font-weight: 800; letter-spacing: -.02em; }
.chat-list .head .btn-icon { background: var(--grad); color: #fff; border: none; box-shadow: 0 6px 16px rgba(99,102,241,.4); }
.chat-list .items { flex: 1; overflow-y: auto; padding: 6px 10px 16px; }
.new-chat { padding: 12px 0 4px; }
.new-chat .input { border-radius: 999px; padding: 10px 16px; }

.conv-item { display: flex; align-items: center; gap: 13px; padding: 11px 12px; border-radius: 14px; cursor: pointer; transition: background .13s; }
.conv-item:hover { background: var(--surface); }
.conv-item.active { background: rgba(99, 102, 241, .15); }
.conv-item .info { flex: 1; min-width: 0; }
.conv-item .name { font-weight: 700; font-size: .95rem; display: flex; align-items: center; gap: 6px; }
.conv-item .name .online-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex-shrink: 0; }
.online-dot.online { background: var(--green); box-shadow: 0 0 0 3px rgba(34, 197, 94, .18); }
.online-dot.on_call { background: var(--cyan); box-shadow: 0 0 0 3px rgba(34, 211, 238, .18); }
.conv-item .last { font-size: .82rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.conv-item .time { font-size: .72rem; color: var(--muted); align-self: flex-start; margin-top: 4px; flex-shrink: 0; }
.conv-item.active .name { color: #d7d9ff; }

.chat-main { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; }
.chat-main > .empty { margin: auto; }
.chat-head {
  display: flex; align-items: center; gap: 12px; padding: 11px 18px;
  border-bottom: 1px solid var(--border); background: var(--surface); min-height: 62px;
}
.chat-head .info { flex: 1; min-width: 0; }
.chat-head .name { font-weight: 750; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-head .sub { font-size: .78rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.chat-body {
  flex: 1; overflow-y: auto; padding: 22px 20px 12px;
  display: flex; flex-direction: column;
  background-color: var(--bg);
  background-image: var(--wall);
  background-size: 24px 24px;
}
.msg { display: flex; gap: 10px; margin-bottom: 8px; max-width: 76%; animation: pop .16s ease; }
@keyframes pop { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: none; } }
.msg .bubble {
  position: relative; background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 8px 13px 6px; box-shadow: 0 1px 1px rgba(0,0,0,.18);
}
.msg:not(.mine) .bubble { border-top-left-radius: 4px; }
.msg.mine .bubble { border-top-right-radius: 4px; background: linear-gradient(135deg, #4f46e5, #7c3aed); border-color: transparent; }
.msg .sender { font-size: .78rem; font-weight: 800; margin-bottom: 2px; }
.msg .text { word-break: break-word; white-space: pre-wrap; line-height: 1.45; font-size: .93rem; }
.msg .meta { font-size: .66rem; color: var(--muted); margin-top: 3px; text-align: right; display: flex; justify-content: flex-end; align-items: center; gap: 4px; }
.msg.mine .meta { color: rgba(255, 255, 255, .8); }
.msg.mine { align-self: flex-end; flex-direction: row-reverse; }
.msg.mine .sender { display: none; }

.msg .attachment { display: flex; flex-direction: column; gap: 8px; max-width: 320px; }
.msg .attachment img, .msg .attachment video {
  border-radius: 10px; max-height: 320px; width: auto; object-fit: cover; display: block; cursor: zoom-in;
}
.file-card {
  display: flex; align-items: center; gap: 10px; background: rgba(255, 255, 255, .1);
  border: 1px solid rgba(255, 255, 255, .12); border-radius: 10px; padding: 10px 12px; font-size: .88rem; color: var(--text);
}
.msg.mine .file-card { color: #fff; }
.file-card:hover { text-decoration: none; background: rgba(255, 255, 255, .16); }
.file-card svg { width: 22px; height: 22px; flex-shrink: 0; }
.file-card .fname { font-weight: 600; word-break: break-all; }

.chat-input {
  display: flex; align-items: flex-end; gap: 9px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border); background: var(--surface);
}
.chat-input .input { border-radius: 999px; }
.typing-ind { font-size: .78rem; color: var(--primary2); padding: 0 8px 8px; font-style: italic; min-height: 16px; }
.new-chat { display: flex; gap: 8px; }

/* ---- Composer (emoji / attach / media / mic / send) ---- */
.composer-wrap { position: relative; display: flex; flex-direction: column; background: var(--surface); border-top: 1px solid var(--border); }
.chat-input { border-top: none; }
.conn-banner {
  font-size: .78rem; text-align: center; padding: 7px 12px; font-weight: 600;
  color: #92400e; background: #fef3c7; border-bottom: 1px solid #fde68a;
}
.conn-banner.ok { color: #065f46; background: #d1fae5; border-bottom-color: #a7f3d0; }
.conn-banner.bad { color: #991b1b; background: #fee2e2; border-bottom-color: #fecaca; }
.chat-input textarea.composer-input {
  resize: none; border-radius: 20px; padding: 10px 15px; max-height: 132px;
  line-height: 1.4; overflow-y: auto; font-family: inherit; font-size: .95rem;
}
.chat-input .btn-icon { flex-shrink: 0; }
.chat-input .send-btn { background: var(--grad); color: #fff; border: none; box-shadow: 0 6px 16px rgba(99,102,241,.4); }
.chat-input .send-btn:hover { filter: brightness(1.08); }
.chat-input .emoji-btn, .chat-input .attach-btn, .chat-input .media-btn, .chat-input .voice-btn { color: var(--muted); }
.chat-input .emoji-btn:hover, .chat-input .attach-btn:hover, .chat-input .media-btn:hover, .chat-input .voice-btn:hover { color: var(--text); background: var(--surface2); }

.attach-tray { display: flex; gap: 8px; padding: 10px 16px 0; overflow-x: auto; }
.attach-chip {
  position: relative; display: flex; align-items: center; gap: 8px; flex-shrink: 0;
  background: var(--surface2); border: 1px solid var(--border); border-radius: 12px; padding: 6px 8px; max-width: 210px;
}
.attach-chip img { width: 44px; height: 44px; object-fit: cover; border-radius: 8px; display: block; }
.attach-chip .file-ic { display: flex; width: 32px; height: 32px; align-items: center; justify-content: center; color: var(--muted); }
.attach-chip .file-ic svg { width: 20px; height: 20px; }
.attach-chip .fname { font-size: .78rem; max-width: 110px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.attach-chip .btn-icon { width: 24px; height: 24px; }
.attach-chip .btn-icon svg { width: 14px; height: 14px; }
.up-progress { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: rgba(0, 0, 0, .25); border-radius: 0 0 12px 12px; overflow: hidden; }
.up-progress span { display: block; height: 100%; width: 0; background: var(--primary); transition: width .15s ease; }

.emoji-panel {
  position: absolute; bottom: 100%; left: 12px; right: 12px; margin-bottom: 8px; z-index: 30;
  background: var(--surface2); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow);
  max-height: 320px; display: flex; flex-direction: column; overflow: hidden;
}
.emoji-panel[hidden] { display: none; }
.emoji-tabs { display: flex; gap: 2px; padding: 6px 6px 0; overflow-x: auto; border-bottom: 1px solid var(--border); }
.emoji-tab { background: none; border: none; font-size: 1.05rem; padding: 6px 8px; border-radius: 8px; cursor: pointer; opacity: .6; }
.emoji-tab.active { opacity: 1; background: var(--surface); }
.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; padding: 8px; overflow-y: auto; }
.emoji-cell { background: none; border: none; font-size: 1.35rem; line-height: 1; padding: 6px 0; border-radius: 8px; cursor: pointer; }
.emoji-cell:hover { background: var(--surface); }

.media-menu {
  position: absolute; bottom: 100%; right: 12px; margin-bottom: 8px; z-index: 30;
  background: var(--surface2); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow);
  padding: 6px; display: flex; flex-direction: column; gap: 2px; min-width: 210px;
}
.media-opt { display: flex; align-items: center; gap: 10px; background: none; border: none; color: var(--text); font-size: .9rem; padding: 10px 12px; border-radius: 10px; cursor: pointer; text-align: left; width: 100%; }
.media-opt:hover { background: var(--surface); }
.media-opt .ic { display: flex; color: var(--primary2); }
.media-opt .ic svg { width: 18px; height: 18px; }

.chat-empty { margin: auto; text-align: center; color: var(--muted); padding: 30px; }
.chat-empty .big { font-size: 3rem; margin-bottom: 6px; }
.chat-empty h3 { color: var(--text); margin-bottom: 4px; }

.lightbox { position: fixed; inset: 0; background: rgba(0, 0, 0, .9); display: flex; align-items: center; justify-content: center; z-index: 80; padding: 24px; }
.lightbox img { max-width: 92vw; max-height: 88vh; border-radius: 10px; }
.lightbox-close { position: absolute; top: 18px; right: 18px; color: #fff; background: rgba(255, 255, 255, .12); }

.hidden { display: none !important; }
[hidden] { display: none !important; }

/* ================================ Profile ================================ */
.profile-hero {
  background: linear-gradient(180deg, rgba(99, 102, 241, .12), transparent), var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 30px; text-align: center; margin-bottom: 20px;
}
.profile-hero .avatar { margin: 0 auto 14px; }
.profile-hero h2 { font-size: 1.6rem; font-weight: 800; letter-spacing: -.02em; }
.profile-hero .handle { color: var(--muted); font-size: .9rem; }
.profile-hero .bio { color: var(--text2); margin: 14px auto 16px; max-width: 480px; }
.profile-hero .actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.profile-meta { display: flex; justify-content: center; gap: 26px; margin-bottom: 16px; color: var(--text2); font-size: .85rem; flex-wrap: wrap; }
.profile-meta b { color: var(--text); }

/* ============================= Notifications ============================= */
.notif {
  display: flex; gap: 13px; padding: 14px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--border); margin-bottom: 10px; align-items: flex-start;
  transition: background .13s, border .13s;
}
.notif:hover { background: var(--surface2); }
.notif.unread { border-color: rgba(99, 102, 241, .5); background: linear-gradient(90deg, rgba(99, 102, 241, .12), var(--surface)); }
.notif .body { flex: 1; min-width: 0; }
.notif .time { font-size: .76rem; color: var(--muted); margin-top: 3px; }
.notif .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); margin-top: 7px; flex-shrink: 0; }

/* ============================= Modal drawer ============================== */
.modal-back {
  position: fixed; inset: 0; background: rgba(4, 5, 13, .72); backdrop-filter: blur(5px);
  display: flex; align-items: center; justify-content: center; z-index: 60; padding: 20px;
  animation: fade .15s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--surface); border: 1px solid var(--border); border-radius: 18px;
  padding: 24px; width: 100%; max-width: 440px; max-height: 88vh; overflow-y: auto;
  box-shadow: var(--shadow); animation: pop .18s ease;
}
.modal h3 { margin-bottom: 16px; font-size: 1.16rem; font-weight: 750; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

/* ================================ Toasts ================================= */
#toasts { position: fixed; bottom: 22px; right: 22px; z-index: 100; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--primary);
  color: var(--text); padding: 12px 16px; border-radius: 12px; box-shadow: var(--shadow);
  max-width: 340px; animation: slideIn .2s ease;
}
.toast.error { border-left-color: var(--red); }
.toast.success { border-left-color: var(--green); }
@keyframes slideIn { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ============================== Call overlay ============================= */
.call-overlay { position: fixed; inset: 0; z-index: 90; background: #06080f; display: flex; flex-direction: column; }
.call-top { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; }
.call-top .title { font-size: 1.12rem; font-weight: 750; }
.call-top .sub { font-size: .82rem; color: var(--text2); }
.call-videos { flex: 1; display: grid; gap: 14px; padding: 10px 22px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); align-content: center; }
.call-videos.single { display: flex; align-items: center; justify-content: center; }
.vid-tile {
  position: relative; border-radius: 18px; overflow: hidden; background: #12162a;
  aspect-ratio: 4/3; display: flex; align-items: center; justify-content: center;
}
.vid-tile video { width: 100%; height: 100%; object-fit: cover; }
.vid-tile.local video { transform: scaleX(-1); }
.vid-tile .label {
  position: absolute; left: 12px; bottom: 12px; background: rgba(0, 0, 0, .55); color: #fff;
  padding: 4px 11px; border-radius: 999px; font-size: .76rem; font-weight: 600;
}
.vid-tile .avatar-fallback { display: flex; flex-direction: column; align-items: center; gap: 10px; color: var(--text2); }
.call-bar { display: flex; align-items: center; justify-content: center; gap: 14px; padding: 20px 0 28px; }
.call-btn {
  width: 56px; height: 56px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: var(--surface2); border: 1px solid var(--border); transition: .15s;
}
.call-btn:hover { background: var(--surface3); }
.call-btn svg { width: 24px; height: 24px; }
.call-btn.end, .call-btn.muted { background: var(--red); border-color: var(--red); color: #fff; }
.call-btn.end:hover { background: #dc2626; }
.call-btn.sharing { background: rgba(34, 211, 238, .22); border-color: var(--cyan); color: var(--cyan); }
.audio-unlock {
  position: absolute; left: 50%; top: 16px; transform: translateX(-50%); z-index: 3;
  background: rgba(250, 204, 21, .95); color: #422006; border: none; border-radius: 999px;
  padding: 10px 18px; font-weight: 700; font-size: .85rem; box-shadow: 0 8px 20px rgba(0,0,0,.4); cursor: pointer;
}
.call-btn.accept { background: var(--green); border-color: var(--green); width: 66px; height: 66px; color: #fff; }
.call-btn.decline { background: var(--red); border-color: var(--red); width: 66px; height: 66px; color: #fff; }

/* ============================= Incoming ring ============================ */
.incoming {
  position: fixed; inset: 0; z-index: 95; background: rgba(6, 8, 18, .94); backdrop-filter: blur(9px);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  animation: fade .2s ease;
}
.incoming .ring-avatar { animation: ringPulse 1.3s infinite; border-radius: 50%; }
@keyframes ringPulse {
  0% { box-shadow: 0 0 0 0 rgba(99, 102, 241, .5); }
  70% { box-shadow: 0 0 0 28px rgba(99, 102, 241, 0); }
  100% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0); }
}
.incoming h2 { font-size: 1.6rem; }
.incoming .btns { display: flex; gap: 44px; margin-top: 14px; }
.incoming .info { color: var(--text2); }

/* =============================== Settings =============================== */
.color-row { display: flex; gap: 10px; flex-wrap: wrap; }
.color-swatch { width: 40px; height: 40px; border-radius: 50%; cursor: pointer; border: 3px solid transparent; transition: .12s; }
.color-swatch.selected { border-color: #fff; transform: scale(1.12); }
.interests-input { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 12px; border-radius: var(--radius-sm); background: var(--bg2); border: 1.5px solid var(--border); }
.interest-tag { display: inline-flex; align-items: center; gap: 6px; background: var(--surface2); border: 1px solid var(--border); border-radius: 999px; padding: 4px 10px; font-size: .82rem; }
.interest-tag button { color: var(--muted); font-size: 1rem; line-height: 1; }

/* =============================== Dropdown =============================== */
.dropdown { position: relative; }
.dropdown-menu {
  position: absolute; right: 0; top: calc(100% + 6px); background: var(--surface);
  border: 1px solid var(--border); border-radius: 12px; min-width: 178px;
  box-shadow: var(--shadow); z-index: 50; padding: 6px; animation: fade .12s ease;
}
.dropdown-menu button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 11px; border-radius: 9px; font-size: .88rem; color: var(--text); text-align: left; }
.dropdown-menu button:hover { background: var(--surface2); }
.dropdown-menu button.danger { color: var(--red); }
.dropdown-menu button svg { width: 16px; height: 16px; }

/* ================================ Loader ================================ */
.loader { display: flex; justify-content: center; padding: 44px; }
.spinner { width: 32px; height: 32px; border-radius: 50%; border: 3px solid var(--border); border-top-color: var(--primary); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================== Admin panel ============================= */
.admin-table-header {
  display: grid; grid-template-columns: 1fr 100px 150px; gap: 12px; align-items: center;
  padding: 12px 16px; font-size: .78rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text2); border-bottom: 1px solid var(--border); font-weight: 700;
}
.admin-row {
  display: grid; grid-template-columns: 1fr 100px 150px; gap: 12px; align-items: center;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
}
.admin-row:last-child { border-bottom: none; }
.group-row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.group-row:last-child { border-bottom: none; }
.group-row .admin-info { flex: 1; min-width: 0; }
.group-row .avatar { flex: none; }
.admin-avatar {
  width: 40px; height: 40px; border-radius: 50%; background: var(--grad);
  display: flex; align-items: center; justify-content: center; font-weight: 700;
  grid-row: span 2; align-self: center; color: #fff;
}
.admin-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.admin-info .name { font-weight: 650; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.badge-pill {
  display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .7rem;
  font-weight: 800; text-transform: uppercase; letter-spacing: .04em; width: fit-content; white-space: nowrap;
}
.badge-pill.online { background: rgba(16, 185, 129, .18); color: #34d399; }
.badge-pill.offline { background: rgba(148, 163, 184, .15); color: #94a3b8; }
.badge-pill.blocked { background: rgba(245, 158, 11, .18); color: #fbbf24; }
.badge-pill.banned { background: rgba(239, 68, 68, .2); color: #f87171; }
.badge-pill.admin { background: rgba(99, 102, 241, .22); color: #a5b4fc; }
@media (max-width: 640px) {
  .admin-row, .admin-table-header { grid-template-columns: 1fr; }
  .admin-row { gap: 8px; }
}

/* ============================ Support tickets =========================== */
.ticket-thread { display: flex; flex-direction: column; gap: 8px; }
.ticket-msg { background: rgba(127, 127, 127, .09); border-radius: 11px; padding: 8px 12px; max-width: 90%; }
.ticket-msg.ticket-admin { background: rgba(99, 102, 241, .14); margin-left: auto; }
.ticket-msg.ticket-warn { background: rgba(239, 68, 68, .12); border-left: 3px solid var(--red); }
.ticket-msg .name { font-weight: 650; font-size: .9rem; }
.ticket-reply { display: flex; gap: 8px; margin-top: 4px; }
.ticket-reply .input { flex: 1; }

/* ========================= Message reporting ============================ */
.msg .report-btn {
  width: 22px; height: 22px; font-size: 13px; opacity: 0; transition: opacity .15s;
  color: var(--muted); background: none; border: none;
}
.msg .bubble:hover .report-btn { opacity: 1; }
.msg .report-btn:hover { color: var(--red); }

/* ========================= Closed group banner ========================== */
.closed-banner { background: rgba(239, 68, 68, .12); border: 1px solid rgba(239, 68, 68, .3); color: #fca5a5; border-radius: 12px; padding: 10px 14px; font-size: .9rem; margin-bottom: 12px; }

/* ========================= Admin report context ========================= */
.report-ctx { background: rgba(127, 127, 127, .09); border-radius: 9px; padding: 6px 10px; margin-top: 4px; font-size: .82rem; color: var(--text2); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ============================= Unread badge ============================= */
.unread-badge {
  background: var(--grad); color: #fff; font-size: .68rem; font-weight: 800;
  padding: 2px 7px; border-radius: 999px; min-width: 19px; text-align: center; flex-shrink: 0; margin-left: auto;
}

/* ==================== Recording UI (WhatsApp style) ==================== */
.recording-overlay {
  position: fixed; bottom: 0; left: 0; right: 0; background: var(--surface);
  border-top: 1px solid var(--border); padding: 12px 16px 24px; z-index: 1000;
  animation: slideUp .2s ease;
}
@keyframes slideUp { from { transform: translateY(100%); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.recording-header { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; position: relative; }
.cancel-btn {
  width: 36px; height: 36px; border-radius: 50%; background: var(--surface2); border: 1px solid var(--border);
  color: var(--text); font-size: 1.5rem; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.cancel-btn:hover { background: var(--surface3); }
.recording-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--red); animation: pulse 1s infinite; flex-shrink: 0; }
@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .6; transform: scale(.9); } }
.recording-timer { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 1rem; font-weight: 600; min-width: 48px; }
.slide-hint {
  position: absolute; left: 56px; right: 56px; text-align: center; font-size: .75rem; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: opacity .3s ease;
}
.lock-rail {
  position: absolute; top: 0; right: 8px; bottom: 100%; width: 4px;
  background: linear-gradient(to top, var(--primary), transparent); border-radius: 2px;
  opacity: 0; transition: opacity .2s ease, height .2s ease; height: 0; pointer-events: none;
}
.recording-overlay.recording_locked .lock-rail { opacity: 1; height: 60px; }
.recording-overlay.cancelling .slide-hint { color: var(--red); font-weight: 600; }
.recording-waveform { width: 100%; height: 60px; display: block; margin: 0 auto 8px; max-width: 400px; }
.recording-controls { display: flex; justify-content: center; gap: 16px; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); }
.control-btn {
  width: 48px; height: 48px; border-radius: 50%; background: var(--surface2); border: 1px solid var(--border);
  color: var(--text); font-size: 1.25rem; display: flex; align-items: center; justify-content: center; transition: all .15s ease;
}
.control-btn:hover { background: var(--surface3); }
.control-btn.send-btn { background: var(--primary); border-color: var(--primary); color: #fff; }
.control-btn.send-btn:hover { filter: brightness(1.1); }

.preview-overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, .85); display: flex; align-items: center; justify-content: center; z-index: 1001; padding: 24px; }
.preview-container { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 16px; width: 100%; max-width: 400px; max-height: 80vh; }
.preview-container video, .preview-container audio { width: 100%; border-radius: 12px; display: block; margin-bottom: 12px; }
.preview-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* ==================== Voice / video message players ==================== */
.msg.audio, .msg.video { max-width: 78%; }
.msg.audio .bubble, .msg.video .bubble { padding: 9px 12px; }
.audio-player, .video-player { display: flex; flex-direction: column; gap: 6px; }
.audio-controls, .video-controls { display: flex; align-items: center; gap: 9px; font-size: .75rem; color: var(--text2); }
.msg.mine .audio-controls, .msg.mine .video-controls { color: rgba(255, 255, 255, .85); }
.waveform { display: flex; align-items: center; gap: 2px; height: 34px; flex: 1; min-width: 90px; }
.waveform-bar { width: 3px; border-radius: 2px; background: currentColor; opacity: .55; transition: height .1s, background-color .1s, opacity .1s; flex-shrink: 0; }
.msg.mine .waveform-bar { background: #fff; opacity: .7; }
.waveform-bar.played, .msg.mine .waveform-bar.played { background: var(--primary2); opacity: 1; }
.msg.mine .waveform-bar.played { background: #fff; opacity: 1; }
.play-btn {
  width: 34px; height: 34px; border-radius: 50%; background: var(--grad); border: none; color: #fff;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.play-btn:hover { filter: brightness(1.1); }
.speed-btn {
  background: var(--surface2); border: 1px solid var(--border); border-radius: 999px; padding: 4px 10px;
  font-size: .7rem; font-weight: 700; color: var(--text2); flex-shrink: 0;
}
.msg.mine .speed-btn { background: rgba(255, 255, 255, .2); border-color: rgba(255, 255, 255, .25); color: #fff; }
.duration { font-size: .7rem; font-family: ui-monospace, Menlo, monospace; }
.video-player video { width: 100%; border-radius: 12px; display: block; background: #000; }

/* Chat input voice/video buttons */
.chat-input .voice-btn, .chat-input .video-btn {
  width: 40px; height: 40px; border-radius: 50%; background: var(--surface2); border: 1px solid var(--border);
  color: var(--primary2); display: flex; align-items: center; justify-content: center; flex-shrink: 0; transition: all .15s ease;
}
.chat-input .voice-btn:hover, .chat-input .video-btn:hover { background: var(--primary); color: #fff; border-color: var(--primary); }
.chat-input .voice-btn:active, .chat-input .video-btn:active { transform: scale(.95); }
.chat-input .voice-btn.recording, .chat-input .video-btn.recording {
  background: var(--red); color: #fff; border-color: var(--red);
  animation: pulse 1s infinite; box-shadow: 0 0 0 3px rgba(239, 68, 68, .4);
}

/* Message status ticks */
.msg .meta .status { display: inline-flex; align-items: center; gap: 3px; font-size: .66rem; }
.msg .status.sent::before { content: '✓'; }
.msg .status.delivered::before { content: '✓✓'; }
.msg .status.read::before { content: '✓✓'; color: var(--cyan); }

/* ================================ Misc ================================= */
.highlight { background: rgba(245, 158, 11, .32); padding: 0 2px; border-radius: 2px; }
.typing-ind .dots { display: flex; gap: 3px; }
.typing-ind .dots span { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: typingBounce 1.4s infinite ease-in-out; }
.typing-ind .dots span:nth-child(2) { animation-delay: .2s; }
.typing-ind .dots span:nth-child(3) { animation-delay: .4s; }
@keyframes typingBounce { 0%, 60%, 100% { transform: translateY(0); } 30% { transform: translateY(-4px); } }

.chat-body::-webkit-scrollbar { width: 6px; }
.chat-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.chat-body::-webkit-scrollbar-thumb:hover { background: var(--muted); }

.msg { animation: messagePop .2s ease-out; }
@keyframes messagePop { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: translateY(0) scale(1); } }

/* forward/reply decorations kept for parity */
.reply-preview { background: rgba(0, 0, 0, .12); border-radius: 8px; padding: 6px 10px; margin-bottom: 4px; font-size: .8rem; border-left: 3px solid var(--primary); }
.msg.mine .reply-preview { background: rgba(255, 255, 255, .15); }
.forwarded-label { font-size: .65rem; color: var(--muted); margin-bottom: 4px; text-transform: uppercase; letter-spacing: .05em; }

/* ============================== Responsive ============================= */
@media (max-width: 900px) {
  .sidebar { position: fixed; z-index: 40; left: 0; top: 0; bottom: 0; transform: translateX(-100%); transition: transform .22s ease; width: 272px; }
  .sidebar.open { transform: none; box-shadow: var(--shadow); }
  .chat-list { width: 100%; border-right: none; }
  .chat-main.hidden-mobile { display: none; }
  .chat-list.hidden-mobile { display: none; }
  .burger { display: flex; margin: 0; }
  .topbar { display: flex; }
  .page-inner { padding: 16px 14px 90px; }
  .msg { max-width: 88%; }
}
@media (max-width: 520px) {
  .page-head h2 { font-size: 1.3rem; }
  .grid { grid-template-columns: 1fr 1fr; }
  .user-card { padding: 14px; }
  .msg { max-width: 92%; }
  #toasts { left: 14px; right: 14px; bottom: 14px; }
  .toast { max-width: none; }
}

/* ============================ Reduced motion =========================== */
@media (prefers-reduced-motion: reduce) {
  .msg, .recording-overlay, .recording-dot, .control-btn, .btn-icon, .btn, .modal, .notif { animation: none !important; transition: none !important; }
}
@media (prefers-contrast: high) {
  :root { --border: #6a6f96; --muted: #a8afd0; }
}

/* ================================ Print ================================ */
@media print {
  .chat-input, .recording-overlay, .preview-overlay, .modal-back, .nav, .me-card, .sidebar { display: none !important; }
  .msg { break-inside: avoid; page-break-inside: avoid; }
}
