/* ============================================================
   VIBLO-MSG · stylesheet
   ============================================================ */

/* ---------- tokens ---------- */
:root {
  --bg-0: #070b10;
  --bg-1: #0c1218;
  --bg-2: #131c25;
  --bg-3: #1a2631;
  --line: rgba(255, 255, 255, 0.065);
  --line-strong: rgba(255, 255, 255, 0.13);
  --text: #e8eef4;
  --text-2: #98adc0;
  --text-3: #647c90;
  --brand: #12c48b;
  --brand-2: #22d3ee;
  --brand-grad: linear-gradient(135deg, #12c48b 0%, #22d3ee 100%);
  --brand-soft: rgba(18, 196, 139, 0.12);
  --danger: #f43f5e;
  --warn: #fbbf24;
  --bubble-in: #1b2732;
  --bubble-out: #0c5f4c;
  --tick: #4fc3f7;
  --shadow-lg: 0 26px 70px -24px rgba(0, 0, 0, 0.8);
  --sidebar-w: clamp(310px, 26vw, 396px);
  --radius: 16px;
}

/* ---------- reset ---------- */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: 'Cairo', 'Segoe UI', system-ui, -apple-system, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg-0);
  color: var(--text);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, input, textarea { font-family: inherit; }
button { cursor: pointer; }
img { max-width: 100%; }
[hidden] { display: none !important; }
::selection { background: rgba(18, 196, 139, 0.35); }

*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.1); border-radius: 99px; }
*::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.2); }

:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ---------- helpers ---------- */
.svg-defs { position: absolute; width: 0; height: 0; overflow: hidden; }
.ic { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

.avatar {
  --sz: 44px;
  width: var(--sz); height: var(--sz);
  border-radius: 50%;
  display: inline-grid; place-items: center;
  font-weight: 800; color: #fff;
  font-size: calc(var(--sz) * 0.38);
  background: linear-gradient(140deg, #1f8f74, #147c8a);
  flex: none; user-select: none;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  overflow: hidden;
}
.avatar-sm { --sz: 38px; }
.avatar-md { --sz: 42px; }
.avatar-lg { --sz: 52px; }
.avatar-xl { --sz: 84px; }
.avatar-xxl { --sz: 96px; }
.avatar-huge { --sz: 132px; }

.icon-btn {
  width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center;
  background: transparent; border: 0; color: var(--text-2);
  transition: background 0.15s, color 0.15s, transform 0.12s;
  flex: none;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.07); color: var(--text); }
.icon-btn:active { transform: scale(0.93); }

.btn-primary {
  height: 54px; width: 100%; border: 0; border-radius: 14px;
  background: var(--brand-grad); color: #04150f;
  font-size: 16px; font-weight: 800; letter-spacing: 0.2px;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  box-shadow: 0 18px 38px -16px rgba(18, 196, 139, 0.8);
  transition: transform 0.15s, filter 0.15s, opacity 0.15s;
}
.btn-primary:hover:not(:disabled) { transform: translateY(-1px); filter: brightness(1.06); }
.btn-primary:active:not(:disabled) { transform: translateY(0) scale(0.99); }
.btn-primary:disabled { opacity: 0.6; cursor: progress; }
.btn-primary.slim { height: 44px; width: auto; padding: 0 22px; font-size: 14.5px; border-radius: 12px; }

.btn-ghost {
  height: 40px; border-radius: 12px; padding: 0 16px;
  background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line-strong);
  color: var(--text); font-size: 13.5px; font-weight: 600;
  transition: background 0.15s;
}
.btn-ghost:hover { background: rgba(255, 255, 255, 0.1); }

.btn-danger {
  height: 44px; border-radius: 12px; padding: 0 18px;
  display: inline-flex; align-items: center; gap: 8px;
  background: rgba(244, 63, 94, 0.1); border: 1px solid rgba(244, 63, 94, 0.3);
  color: #fb7185; font-size: 13.5px; font-weight: 700;
  transition: background 0.15s;
}
.btn-danger:hover { background: rgba(244, 63, 94, 0.18); }

.spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2.4px solid rgba(4, 21, 15, 0.25);
  border-top-color: #04150f;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(0.985); } to { opacity: 1; transform: none; } }
@keyframes pulse { 0% { transform: scale(1); opacity: 0.8; } 70% { transform: scale(1.45); opacity: 0; } 100% { opacity: 0; } }
@keyframes toastIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
@keyframes floaty { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-9px); } }

/* ============================================================
   Splash
   ============================================================ */
.splash {
  position: fixed; inset: 0; z-index: 400;
  background: radial-gradient(70% 60% at 50% 30%, #0f2a26 0%, #070b10 65%);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  transition: opacity 0.35s ease, visibility 0.35s;
}
.splash.done { opacity: 0; visibility: hidden; }
.splash-logo {
  width: 76px; height: 76px; border-radius: 22px;
  background: var(--brand-grad); color: #04150f;
  display: grid; place-items: center; font-size: 40px; font-weight: 900;
  box-shadow: 0 24px 60px -18px rgba(18, 196, 139, 0.85);
  animation: floaty 2.4s ease-in-out infinite;
}
.splash-name { font-weight: 800; letter-spacing: 2px; color: var(--text-2); font-size: 13px; }
.splash-bar { width: 140px; height: 3px; border-radius: 99px; background: rgba(255, 255, 255, 0.1); overflow: hidden; }
.splash-bar span { display: block; height: 100%; width: 40%; border-radius: 99px; background: var(--brand-grad); animation: splashSlide 1.1s ease-in-out infinite; }
@keyframes splashSlide { 0% { transform: translateX(80%); } 100% { transform: translateX(-260%); } }

/* ============================================================
   Auth
   ============================================================ */
.auth {
  position: fixed; inset: 0; z-index: 200;
  display: flex; flex-direction: column;
  overflow-y: auto;
  background: #060a0e;
}
.auth-bg { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.orb { position: absolute; border-radius: 50%; filter: blur(90px); opacity: 0.5; }
.orb-1 { width: 520px; height: 520px; background: #0f766e; top: -180px; inset-inline-start: -120px; animation: floaty 9s ease-in-out infinite; }
.orb-2 { width: 420px; height: 420px; background: #0e7490; bottom: -160px; inset-inline-end: -80px; animation: floaty 11s ease-in-out infinite reverse; }
.orb-3 { width: 320px; height: 320px; background: #4338ca; top: 40%; inset-inline-start: 45%; opacity: 0.32; animation: floaty 13s ease-in-out infinite; }
.auth-grid {
  position: absolute; inset: 0;
  background-image: linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
                    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(70% 60% at 50% 40%, #000 20%, transparent 80%);
  -webkit-mask-image: radial-gradient(70% 60% at 50% 40%, #000 20%, transparent 80%);
}

.auth-wrap {
  position: relative; z-index: 2;
  width: 100%; max-width: 1200px; margin: auto;
  padding: 48px 40px;
  display: grid; grid-template-columns: 1.05fr 0.95fr;
  gap: 60px; align-items: center;
}

.auth-mobile-brand { display: none; }

.auth-hero { max-width: 560px; }
.brand-row { display: flex; align-items: center; gap: 14px; margin-bottom: 34px; }
.brand-logo {
  width: 54px; height: 54px; border-radius: 16px;
  background: var(--brand-grad); color: #04150f;
  display: grid; place-items: center; font-size: 30px; font-weight: 900;
  box-shadow: 0 16px 36px -14px rgba(18, 196, 139, 0.9);
}
.brand-text { font-size: 20px; font-weight: 800; letter-spacing: 1px; }
.brand-text span { background: var(--brand-grad); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }

.hero-title {
  font-size: clamp(32px, 3.6vw, 50px); line-height: 1.2;
  font-weight: 800; margin: 0 0 18px;
}
.hero-title em { font-style: normal; background: var(--brand-grad); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.hero-sub { font-size: 15.5px; line-height: 1.9; color: var(--text-2); margin: 0 0 28px; max-width: 480px; }

.hero-features { list-style: none; padding: 0; margin: 0 0 30px; display: flex; flex-direction: column; gap: 10px; }
.hero-features li {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; border-radius: 14px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid var(--line);
  font-size: 14px; color: var(--text-2);
  width: fit-content; min-width: min(100%, 380px);
}
.hero-features b { color: var(--text); font-weight: 700; }
.hf-ic { font-size: 18px; }

.hero-mock { display: flex; flex-direction: column; gap: 10px; max-width: 420px; }
.mock-bubble {
  max-width: 82%; padding: 11px 15px; font-size: 13.5px; line-height: 1.6;
  border-radius: 16px; animation: floaty 6s ease-in-out infinite;
  box-shadow: 0 16px 40px -22px rgba(0, 0, 0, 0.9);
}
.mock-bubble.in { background: rgba(27, 39, 50, 0.85); border: 1px solid var(--line); align-self: flex-start; border-start-start-radius: 6px; }
.mock-bubble.out { background: rgba(12, 95, 76, 0.9); align-self: flex-end; border-start-end-radius: 6px; animation-delay: 1.4s; }
.mock-bubble:nth-child(3) { animation-delay: 0.7s; }
.mock-tick { margin-inline-start: 8px; color: var(--tick); font-size: 11px; }

.auth-card {
  position: relative; justify-self: center;
  width: 100%; max-width: 448px;
  padding: 34px 32px 28px;
  border-radius: 26px;
  background: linear-gradient(180deg, rgba(21, 31, 41, 0.92), rgba(9, 14, 19, 0.96));
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(20px);
  animation: pop 0.35s ease-out;
}
.card-glow {
  position: absolute; inset-inline: 12%; top: -1px; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(18, 196, 139, 0.9), rgba(34, 211, 238, 0.9), transparent);
  filter: blur(0.5px);
}
.card-head h2 { margin: 0 0 8px; font-size: 25px; font-weight: 800; }
.card-head p { margin: 0 0 24px; font-size: 13.5px; line-height: 1.85; color: var(--text-2); }

.field-label { display: block; font-size: 12.5px; font-weight: 700; color: var(--text-2); margin: 0 0 8px; }
.field {
  display: flex; align-items: center; gap: 10px;
  height: 54px; padding: 0 16px;
  direction: ltr;
  background: rgba(255, 255, 255, 0.045);
  border: 1.5px solid var(--line-strong);
  border-radius: 14px;
  transition: border-color 0.18s, box-shadow 0.18s, background 0.18s;
}
.field:focus-within { border-color: rgba(18, 196, 139, 0.65); box-shadow: 0 0 0 4px rgba(18, 196, 139, 0.1); background: rgba(255, 255, 255, 0.06); }
.field.ok { border-color: rgba(18, 196, 139, 0.6); }
.field.taken { border-color: rgba(79, 195, 247, 0.55); }
.field.bad { border-color: rgba(244, 63, 94, 0.6); }
.field-prefix { color: var(--text-3); font-weight: 700; font-size: 16px; }
.field input { flex: 1; min-width: 0; background: none; border: 0; outline: none; color: var(--text); font-size: 16px; letter-spacing: 0.3px; }
.field input::placeholder { color: var(--text-3); }
.field-state { font-size: 12px; font-weight: 700; white-space: nowrap; direction: rtl; }
.field-state.ok { color: var(--brand); }
.field-state.info { color: var(--tick); }
.field-state.bad { color: #fb7185; }

.field-msg { min-height: 20px; font-size: 12px; color: var(--text-3); margin: 9px 2px 18px; line-height: 1.6; }
.field-msg.ok { color: #34d399; }
.field-msg.bad { color: #fb7185; }

.auth-sep { display: flex; align-items: center; gap: 12px; margin: 24px 0 16px; color: var(--text-3); font-size: 11.5px; }
.auth-sep::before, .auth-sep::after { content: ''; height: 1px; flex: 1; background: var(--line); }

.mini-features { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.mini-features div {
  display: flex; align-items: center; gap: 9px;
  padding: 10px 12px; border-radius: 12px;
  background: rgba(255, 255, 255, 0.03); border: 1px solid var(--line);
  font-size: 12.5px; color: var(--text-2);
}
.mini-features b { font-size: 15px; }
.fine-print { margin: 18px 0 0; font-size: 11.5px; color: var(--text-3); text-align: center; line-height: 1.7; }

.auth-foot {
  position: relative; z-index: 2;
  text-align: center; padding: 18px; font-size: 11.5px; color: var(--text-3);
}

/* ============================================================
   Shell
   ============================================================ */
.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100dvh; width: 100%;
  background: var(--bg-0);
  animation: fade 0.3s ease;
}

.sidebar {
  display: flex; flex-direction: column; min-height: 0;
  background: var(--bg-1);
  border-inline-end: 1px solid var(--line);
  position: relative; z-index: 2;
}

.side-head {
  display: flex; align-items: center; gap: 12px;
  height: 64px; padding: 0 12px 0 16px;
  border-bottom: 1px solid var(--line);
  flex: none;
}
.me-btn { position: relative; background: none; border: 0; padding: 0; border-radius: 50%; line-height: 0; }
.me-pulse {
  position: absolute; inset-inline-end: 0; bottom: 0;
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--brand); border: 2px solid var(--bg-1);
}
.side-brand {
  flex: 1; display: flex; align-items: center; gap: 8px;
  font-weight: 800; font-size: 14.5px; letter-spacing: 0.4px;
  color: var(--text);
}
.brand-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--brand); box-shadow: 0 0 10px var(--brand); }
.side-tools { display: flex; gap: 2px; }

.side-search {
  display: flex; align-items: center; gap: 9px;
  margin: 10px 14px 6px; padding: 0 12px; height: 42px;
  background: var(--bg-2); border: 1px solid transparent; border-radius: 12px;
  transition: border-color 0.15s;
  flex: none;
}
.side-search:focus-within { border-color: rgba(18, 196, 139, 0.4); }
.side-search .search-ic { width: 18px; height: 18px; color: var(--text-3); }
.side-search input {
  flex: 1; min-width: 0; background: none; border: 0; outline: none;
  color: var(--text); font-size: 13.5px;
}
.side-search input::placeholder { color: var(--text-3); }

.side-scroll { flex: 1; overflow-y: auto; min-height: 0; padding-bottom: 12px; }

.list-label {
  padding: 12px 20px 6px;
  font-size: 11px; font-weight: 700; letter-spacing: 1px;
  color: var(--text-3);
}

.chat-list { display: flex; flex-direction: column; gap: 2px; padding: 0 8px; }
.chat-item {
  display: flex; align-items: center; gap: 12px;
  width: 100%; padding: 9px 10px;
  border: 0; border-radius: 14px; background: transparent;
  text-align: start; color: inherit;
  transition: background 0.15s;
}
.chat-item:hover { background: rgba(255, 255, 255, 0.045); }
.chat-item.active {
  background: linear-gradient(90deg, rgba(18, 196, 139, 0.16), rgba(18, 196, 139, 0.03));
  box-shadow: inset 0 0 0 1px rgba(18, 196, 139, 0.18);
}
.ci-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.ci-top { display: flex; align-items: center; gap: 8px; }
.ci-name { flex: 1; font-size: 14.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ci-time { font-size: 10.5px; color: var(--text-3); flex: none; }
.ci-time.unread { color: var(--brand); font-weight: 700; }
.ci-bottom { display: flex; align-items: center; gap: 8px; }
.ci-preview { flex: 1; font-size: 12.5px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ci-preview.mine::before { content: 'أنت: '; color: var(--text-3); }
.ci-badge {
  min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 10px; background: var(--brand); color: #04150f;
  font-size: 11px; font-weight: 800;
  display: grid; place-items: center; flex: none;
}

/* requests block */
.req-block {
  margin: 10px 12px 4px; padding: 10px 12px 8px;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(18, 196, 139, 0.08), rgba(18, 196, 139, 0.015));
  border: 1px solid rgba(18, 196, 139, 0.22);
}
.req-head {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; font-weight: 700; color: var(--text-2);
  margin-bottom: 6px;
}
.req-head .req-count {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--brand); color: #04150f; font-size: 10.5px; font-weight: 800;
  display: grid; place-items: center;
}
.req-item { display: flex; align-items: center; gap: 10px; padding: 7px 0; }
.req-item .avatar { --sz: 38px; }
.req-info { flex: 1; min-width: 0; }
.req-name { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.req-sub { font-size: 11px; color: var(--text-3); direction: ltr; text-align: start; }
.req-actions { display: flex; gap: 5px; flex: none; }
.mini-btn {
  height: 30px; padding: 0 11px; border-radius: 9px;
  font-size: 11.5px; font-weight: 700; border: 1px solid transparent;
  transition: filter 0.15s, background 0.15s;
}
.mini-btn.accept { background: var(--brand); color: #04150f; }
.mini-btn.accept:hover { filter: brightness(1.08); }
.mini-btn.decline { background: rgba(255, 255, 255, 0.06); color: var(--text-2); border-color: var(--line-strong); }
.mini-btn.decline:hover { background: rgba(255, 255, 255, 0.1); color: var(--text); }

.side-empty { padding: 40px 28px; text-align: center; color: var(--text-3); }
.side-empty-ic { font-size: 34px; margin-bottom: 10px; opacity: 0.8; }
.side-empty p { margin: 0 0 6px; font-size: 14px; font-weight: 600; color: var(--text-2); }
.side-empty span { display: block; font-size: 12px; line-height: 1.8; margin-bottom: 16px; }

.side-foot {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 16px; border-top: 1px solid var(--line);
  font-size: 11px; color: var(--text-3); flex: none;
}
.conn-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--brand); box-shadow: 0 0 8px rgba(18, 196, 139, 0.8); }
.conn-dot.off { background: var(--warn); box-shadow: 0 0 8px rgba(251, 191, 36, 0.8); }
.side-user { margin-inline-start: auto; direction: ltr; color: var(--text-3); }

/* ============================================================
   Chat panel
   ============================================================ */
.chat-panel { position: relative; display: flex; flex-direction: column; min-width: 0; background: var(--bg-0); }

.welcome {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 40px 24px; position: relative; overflow: hidden;
  background:
    radial-gradient(60% 45% at 50% 0%, rgba(18, 196, 139, 0.07), transparent 70%),
    radial-gradient(50% 40% at 20% 100%, rgba(34, 211, 238, 0.05), transparent 70%);
}
.welcome::after {
  content: ''; position: absolute; inset: 0;
  background-image: radial-gradient(rgba(255, 255, 255, 0.055) 1px, transparent 1px);
  background-size: 26px 26px;
  mask-image: radial-gradient(60% 60% at 50% 50%, #000 10%, transparent 75%);
  -webkit-mask-image: radial-gradient(60% 60% at 50% 50%, #000 10%, transparent 75%);
  pointer-events: none;
}
.welcome-inner { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; max-width: 460px; }
.welcome-logo {
  width: 96px; height: 96px; border-radius: 30px;
  background: var(--brand-grad); color: #04150f;
  display: grid; place-items: center; font-size: 52px; font-weight: 900;
  box-shadow: 0 30px 70px -24px rgba(18, 196, 139, 0.85);
  margin-bottom: 24px;
}
.welcome h2 { margin: 0 0 12px; font-size: 28px; font-weight: 800; letter-spacing: 0.5px; }
.welcome h2 em { font-style: normal; background: var(--brand-grad); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.welcome p { margin: 0 0 20px; font-size: 13.5px; line-height: 1.9; color: var(--text-2); }
.welcome-pills { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-bottom: 26px; }
.welcome-pills span {
  padding: 7px 13px; border-radius: 999px; font-size: 12px; color: var(--text-2);
  background: rgba(255, 255, 255, 0.04); border: 1px solid var(--line);
}
.welcome-foot {
  position: absolute; bottom: 16px; z-index: 1;
  font-size: 11px; color: var(--text-3);
}

.chat-pane { display: flex; flex-direction: column; height: 100%; min-height: 0; }

.chat-head {
  display: flex; align-items: center; gap: 8px;
  height: 64px; padding: 0 10px;
  background: rgba(12, 18, 24, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
  flex: none; z-index: 6;
}
.chat-peer {
  flex: 1; min-width: 0;
  display: flex; align-items: center; gap: 11px;
  background: none; border: 0; padding: 4px; border-radius: 12px;
  text-align: start; color: inherit;
  transition: background 0.15s;
}
.chat-peer:hover { background: rgba(255, 255, 255, 0.04); }
.peer-meta { display: flex; flex-direction: column; min-width: 0; gap: 1px; }
.peer-name { font-size: 15px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.peer-status { font-size: 11.5px; color: var(--text-2); }
.peer-status.online { color: var(--brand); font-weight: 600; }
.chat-actions { display: flex; gap: 2px; flex: none; }
.chat-actions .icon-btn { color: var(--text-2); }
.chat-actions .icon-btn:hover { color: var(--brand); background: rgba(18, 196, 139, 0.1); }

/* messages */
.messages {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  padding: 16px 8px 8px;
  display: flex; flex-direction: column;
  background-color: #070c11;
  background-image:
    radial-gradient(70% 50% at 85% 0%, rgba(18, 196, 139, 0.055), transparent 70%),
    radial-gradient(60% 45% at 5% 100%, rgba(34, 211, 238, 0.045), transparent 70%);
  scroll-behavior: smooth;
  overscroll-behavior: contain;
}
.msgs-inner {
  display: flex; flex-direction: column;
  max-width: 980px; margin: auto auto 0; width: 100%;
  padding: 0 6px;
  flex: 0 0 auto;
}

.day-sep {
  align-self: center; margin: 12px 0 12px;
  padding: 4px 13px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid var(--line);
  font-size: 11px; color: var(--text-2);
  backdrop-filter: blur(8px);
}

.msg { display: flex; margin: 1.5px 0; animation: pop 0.16s ease-out; }
.msg.mine { justify-content: flex-end; }
.msg.theirs { justify-content: flex-start; }
.bubble {
  position: relative; max-width: min(78%, 620px);
  padding: 7px 11px 5px;
  border-radius: 16px;
  font-size: 14.6px; line-height: 1.62;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.045);
  word-break: break-word; overflow-wrap: anywhere;
}
.msg.theirs .bubble { background: var(--bubble-in); border-start-start-radius: 5px; }
.msg.mine .bubble { background: var(--bubble-out); border-start-end-radius: 5px; }
.msg.mine + .msg.mine { margin-top: 1.5px; }

.b-body { white-space: pre-wrap; }
.b-body a { color: #7dd3fc; text-decoration: underline; }
.msg.emoji-only .b-body { font-size: 40px; line-height: 1.3; letter-spacing: 1px; }
.b-meta {
  display: flex; align-items: center; justify-content: flex-start; gap: 5px;
  margin-top: 1px; font-size: 10px; line-height: 1.4;
  color: rgba(232, 238, 244, 0.5);
  direction: ltr;
}
.msg.mine .b-meta { justify-content: flex-end; }
.ticks { display: inline-flex; color: rgba(255, 255, 255, 0.55); }
.ticks .ic { width: 15px; height: 15px; stroke-width: 2.4; }
.ticks.read { color: var(--tick); }
.msg.failed .bubble { border-color: rgba(244, 63, 94, 0.5); }
.msg.sending .bubble { opacity: 0.72; }

.msg-img {
  display: block; border-radius: 12px; cursor: zoom-in;
  max-height: 420px; width: auto; max-width: 100%;
  background: #0a0f14; object-fit: cover;
  margin-bottom: 2px;
}
.msg-video {
  display: block; border-radius: 12px; background: #000;
  max-width: 100%; max-height: 420px; width: min(360px, 68vw);
  margin-bottom: 2px;
}
.bubble.media { padding: 4px 4px 3px; }
.bubble.media .b-meta { padding: 0 5px 2px; }

/* typing */
.typing-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 0 22px 6px; font-size: 11.5px; color: var(--brand);
  background: #070c11;
  animation: fade 0.2s;
}
.typing-dots { display: inline-flex; gap: 3px; }
.typing-dots i {
  width: 5px; height: 5px; border-radius: 50%; background: var(--brand);
  animation: typingBounce 1.2s infinite;
}
.typing-dots i:nth-child(2) { animation-delay: 0.15s; }
.typing-dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes typingBounce { 0%, 60%, 100% { opacity: 0.3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

/* composer */
.composer {
  display: flex; align-items: flex-end; gap: 5px;
  padding: 9px 10px calc(9px + env(safe-area-inset-bottom));
  background: rgba(12, 18, 24, 0.97);
  border-top: 1px solid var(--line);
  flex: none; position: relative; z-index: 8;
}
.composer .icon-btn { width: 42px; height: 42px; }
.input-wrap {
  flex: 1; display: flex; align-items: center;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 22px; padding: 0 16px; min-height: 44px;
  transition: border-color 0.15s;
}
.input-wrap:focus-within { border-color: rgba(18, 196, 139, 0.4); }
.input-wrap textarea {
  flex: 1; width: 100%; background: none; border: 0; outline: none;
  color: var(--text); font-size: 14.5px; line-height: 1.55;
  resize: none; max-height: 132px; padding: 11px 0;
  overflow-y: auto;
}
.input-wrap textarea::placeholder { color: var(--text-3); }
.send-btn {
  width: 46px; height: 46px; border-radius: 50%; border: 0;
  background: var(--brand-grad); color: #04150f;
  display: grid; place-items: center; flex: none;
  transition: transform 0.15s, opacity 0.2s, filter 0.2s;
  box-shadow: 0 12px 26px -14px rgba(18, 196, 139, 0.95);
}
.send-btn .ic { color: #04150f; stroke-width: 2; }
.send-btn .ic { transform: scaleX(-1); }
.send-btn:disabled { opacity: 0.32; cursor: default; box-shadow: none; filter: saturate(0.3); }
.send-btn:not(:disabled):active { transform: scale(0.93); }

/* emoji */
.emoji-panel {
  position: absolute; bottom: 76px; inset-inline-start: 10px;
  width: 354px; max-width: calc(100vw - 20px); height: 336px;
  display: flex; flex-direction: column;
  background: var(--bg-1);
  border: 1px solid var(--line-strong);
  border-radius: 18px; overflow: hidden;
  box-shadow: var(--shadow-lg); z-index: 30;
  animation: pop 0.16s ease-out;
}
.emoji-tabs {
  display: flex; gap: 2px; padding: 6px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto; scrollbar-width: none;
}
.emoji-tabs::-webkit-scrollbar { display: none; }
.emoji-tab {
  flex: none; width: 38px; height: 34px; border: 0; border-radius: 9px;
  background: transparent; font-size: 17px; display: grid; place-items: center;
  opacity: 0.6; transition: background 0.12s, opacity 0.12s;
}
.emoji-tab:hover { background: rgba(255, 255, 255, 0.06); opacity: 1; }
.emoji-tab.active { background: rgba(18, 196, 139, 0.16); opacity: 1; }
.emoji-grid {
  flex: 1; overflow-y: auto; padding: 8px;
  display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px;
  align-content: start;
}
.emoji-btn {
  aspect-ratio: 1; border: 0; border-radius: 8px; background: transparent;
  font-size: 22px; line-height: 1; display: grid; place-items: center;
  transition: background 0.1s, transform 0.1s;
}
.emoji-btn:hover { background: rgba(255, 255, 255, 0.09); transform: scale(1.14); }

/* ============================================================
   Modals
   ============================================================ */
.modal-layer { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 18px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(3, 6, 10, 0.72); backdrop-filter: blur(7px); animation: fade 0.2s; }
.modal {
  position: relative; width: min(540px, 100%);
  max-height: min(86dvh, 780px);
  display: flex; flex-direction: column;
  background: linear-gradient(180deg, #121a22, #0b1117);
  border: 1px solid var(--line-strong);
  border-radius: 22px; overflow: hidden;
  box-shadow: var(--shadow-lg);
  animation: pop 0.22s ease-out;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 12px 14px 20px;
  border-bottom: 1px solid var(--line); flex: none;
}
.modal-head h3 { margin: 0; font-size: 16px; font-weight: 700; }
.modal-search {
  display: flex; align-items: center; gap: 9px;
  margin: 14px 16px 4px; padding: 0 14px; height: 46px;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 13px;
  flex: none;
}
.modal-search:focus-within { border-color: rgba(18, 196, 139, 0.45); }
.modal-search .ic { width: 18px; height: 18px; color: var(--text-3); }
.modal-search input { flex: 1; min-width: 0; background: none; border: 0; outline: none; color: var(--text); font-size: 14px; }
.modal-body { flex: 1; overflow-y: auto; padding: 10px 12px 18px; }
.modal-foot {
  padding: 12px 20px; border-top: 1px solid var(--line);
  font-size: 11.5px; color: var(--text-3); flex: none;
}
.hint { opacity: 0.8; }

.user-results { display: flex; flex-direction: column; gap: 2px; }
.user-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px; border-radius: 14px;
  transition: background 0.15s;
}
.user-row:hover { background: rgba(255, 255, 255, 0.04); }
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 14.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-handle { font-size: 12px; color: var(--text-3); direction: ltr; text-align: start; }
.user-sub { font-size: 11px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.pill-btn {
  height: 34px; padding: 0 14px; border-radius: 10px;
  border: 1px solid transparent; font-size: 12.5px; font-weight: 700;
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  transition: filter 0.15s, background 0.15s;
}
.pill-btn.primary { background: var(--brand-grad); color: #04150f; }
.pill-btn.primary:hover { filter: brightness(1.08); }
.pill-btn.ghost { background: rgba(255, 255, 255, 0.06); color: var(--text-2); border-color: var(--line-strong); }
.pill-btn.ghost:hover { background: rgba(255, 255, 255, 0.1); color: var(--text); }
.pill-btn.chat { background: rgba(18, 196, 139, 0.14); color: #5eead4; border-color: rgba(18, 196, 139, 0.25); }
.pill-btn.muted { background: transparent; color: var(--text-3); border-color: var(--line); cursor: default; }

.section-title {
  padding: 18px 10px 8px; font-size: 11px; font-weight: 700;
  letter-spacing: 0.8px; color: var(--text-3);
}
.results-empty { padding: 42px 20px; text-align: center; color: var(--text-3); font-size: 13px; line-height: 1.9; }
.results-empty b { color: var(--text-2); }

/* profile */
.profile-body { display: flex; flex-direction: column; gap: 8px; }
.profile-avatar-wrap { display: flex; align-items: center; gap: 16px; margin-bottom: 8px; }
.profile-id { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.profile-username { font-size: 18px; font-weight: 800; direction: ltr; text-align: start; }
.profile-hint { font-size: 11.5px; color: var(--text-3); }
.avatar-picker { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; margin-bottom: 8px; }
.avatar-opt {
  aspect-ratio: 1; border-radius: 12px; border: 1.5px solid var(--line);
  background: rgba(255, 255, 255, 0.03); font-size: 18px;
  display: grid; place-items: center;
  transition: border-color 0.15s, background 0.15s, transform 0.12s;
}
.avatar-opt:hover { transform: translateY(-1px); background: rgba(255, 255, 255, 0.07); }
.avatar-opt.active { border-color: var(--brand); background: rgba(18, 196, 139, 0.14); }
.avatar-opt.initial { font-weight: 800; font-size: 13px; color: var(--text-2); }
.text-input {
  width: 100%; height: 46px; padding: 0 14px;
  background: rgba(255, 255, 255, 0.045);
  border: 1.5px solid var(--line-strong); border-radius: 12px;
  color: var(--text); font-size: 14px; outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.text-input:focus { border-color: rgba(18, 196, 139, 0.6); box-shadow: 0 0 0 4px rgba(18, 196, 139, 0.08); }
.text-input::placeholder { color: var(--text-3); }
.profile-actions { display: flex; gap: 10px; align-items: center; margin-top: 16px; }
.profile-actions .btn-primary { flex: 1; }

/* media preview */
.media-modal { width: min(480px, 100%); }
.media-preview {
  margin: 14px 16px 0; border-radius: 14px; overflow: hidden;
  background: #05090d; display: grid; place-items: center;
  max-height: 320px;
}
.media-preview img, .media-preview video { max-width: 100%; max-height: 320px; display: block; }
.media-meta { padding: 9px 18px; font-size: 11.5px; color: var(--text-3); direction: ltr; text-align: start; }
.media-caption { padding: 0 16px; }
.upload-line { height: 4px; margin: 12px 16px 0; border-radius: 99px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }
.upload-fill { height: 100%; width: 0%; background: var(--brand-grad); transition: width 0.2s; }
.media-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 14px; padding-top: 14px; }

/* ============================================================
   Lightbox
   ============================================================ */
.lightbox {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0, 0, 0, 0.94);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 24px; animation: fade 0.18s;
}
.lightbox-body img, .lightbox-body video {
  max-width: min(94vw, 1200px); max-height: 78dvh;
  border-radius: 12px; box-shadow: 0 40px 100px -40px #000;
}
.lightbox-close {
  position: absolute; top: 16px; inset-inline-end: 16px;
  width: 44px; height: 44px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.1); border: 0; color: #fff;
  display: grid; place-items: center;
}
.lightbox-dl {
  position: absolute; bottom: 20px;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 18px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.1); color: #fff;
  font-size: 13px; text-decoration: none;
}
.lightbox-dl:hover { background: rgba(255, 255, 255, 0.18); }

/* ============================================================
   Calls
   ============================================================ */
.call-overlay {
  position: fixed; inset: 0; z-index: 150;
  background: #05090d; overflow: hidden;
  display: flex; flex-direction: column;
  animation: fade 0.2s;
}
.call-bg {
  position: absolute; inset: 0;
  background:
    radial-gradient(80% 60% at 50% 0%, rgba(18, 196, 139, 0.16), transparent 60%),
    radial-gradient(60% 50% at 50% 100%, rgba(34, 211, 238, 0.1), transparent 70%),
    #05090d;
}
.remote-video {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; background: #000; z-index: 1;
}
.call-stage {
  position: relative; z-index: 2;
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 6px;
  padding: 70px 24px 40px;
}
.call-avatar-wrap { position: relative; margin-bottom: 18px; }
.call-pulse {
  position: absolute; inset: -6px; border-radius: 50%;
  border: 2px solid rgba(18, 196, 139, 0.55);
  animation: pulse 2.2s ease-out infinite;
}
.call-name { font-size: 25px; font-weight: 800; }
.call-status { font-size: 13.5px; color: var(--text-2); min-height: 20px; }
.call-timer {
  margin-top: 6px; font-size: 16px; font-weight: 700;
  color: var(--brand); direction: ltr; font-variant-numeric: tabular-nums;
  letter-spacing: 1px;
}
.local-video {
  position: absolute; bottom: 128px; inset-inline-end: 16px;
  width: 118px; height: 168px; border-radius: 16px;
  object-fit: cover; background: #000; z-index: 5;
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-lg);
}
.call-topbar { position: absolute; top: 0; inset-inline: 0; z-index: 3; padding: 16px; display: flex; justify-content: center; }
.call-badge {
  padding: 6px 14px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.08); backdrop-filter: blur(10px);
  font-size: 11.5px; color: var(--text-2);
}
.call-controls {
  position: relative; z-index: 4;
  display: flex; justify-content: center; gap: 14px;
  padding: 18px 20px calc(32px + env(safe-area-inset-bottom));
  background: linear-gradient(0deg, rgba(5, 9, 13, 0.92), transparent);
}
.call-ctrl {
  display: flex; flex-direction: column; align-items: center; gap: 7px;
  background: none; border: 0; color: var(--text-2);
  font-size: 10.5px; font-weight: 600;
}
.call-ctrl svg {
  width: 56px; height: 56px; padding: 16px; box-sizing: border-box;
  border-radius: 50%; background: rgba(255, 255, 255, 0.1);
  color: #fff; transition: background 0.15s, color 0.15s, transform 0.12s;
}
.call-ctrl:hover svg { background: rgba(255, 255, 255, 0.18); }
.call-ctrl:active svg { transform: scale(0.94); }
.call-ctrl.active svg { background: #fff; color: #04150f; }
.call-ctrl.hangup svg { background: #e11d48; color: #fff; }
.call-ctrl.hangup:hover svg { background: #f43f5e; }

/* incoming */
.incoming-layer { background: rgba(3, 6, 10, 0.88); backdrop-filter: blur(12px); }
.incoming-card {
  position: relative; width: min(360px, 100%);
  padding: 34px 26px 28px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  background: linear-gradient(180deg, rgba(21, 31, 41, 0.97), rgba(9, 14, 19, 0.98));
  border: 1px solid var(--line-strong); border-radius: 26px;
  box-shadow: var(--shadow-lg);
  animation: pop 0.25s ease-out;
}
.incoming-rings { position: absolute; top: 34px; width: 96px; height: 96px; pointer-events: none; }
.incoming-rings span {
  position: absolute; inset: 0; border-radius: 50%;
  border: 2px solid rgba(18, 196, 139, 0.55);
  animation: pulse 2s ease-out infinite;
}
.incoming-rings span:nth-child(2) { animation-delay: 0.6s; }
.incoming-rings span:nth-child(3) { animation-delay: 1.2s; }
.incoming-card .avatar-xxl { position: relative; z-index: 1; margin-bottom: 10px; }
.incoming-name { font-size: 21px; font-weight: 800; margin-top: 6px; }
.incoming-type { font-size: 12.5px; color: var(--text-2); margin-bottom: 22px; }
.incoming-actions { display: flex; gap: 28px; }
.call-round {
  width: 66px; height: 66px; border-radius: 50%; border: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; color: #fff; font-size: 9.5px; font-weight: 700;
  transition: transform 0.15s, filter 0.15s;
}
.call-round .ic { width: 24px; height: 24px; }
.call-round.decline { background: #e11d48; box-shadow: 0 14px 30px -14px rgba(225, 29, 72, 0.9); }
.call-round.accept { background: #12c48b; color: #04150f; box-shadow: 0 14px 30px -14px rgba(18, 196, 139, 0.9); animation: pulseSoft 1.6s infinite; }
.call-round:hover { transform: translateY(-2px); filter: brightness(1.06); }
.call-round.accept .ic { color: #04150f; }
@keyframes pulseSoft { 0%, 100% { box-shadow: 0 14px 30px -14px rgba(18, 196, 139, 0.9); } 50% { box-shadow: 0 14px 44px -10px rgba(18, 196, 139, 0.8); } }

/* ============================================================
   Toasts
   ============================================================ */
.toasts {
  position: fixed; top: 16px; left: 50%; transform: translateX(-50%);
  z-index: 300; display: flex; flex-direction: column; gap: 8px;
  align-items: center; pointer-events: none;
  max-width: calc(100vw - 24px);
}
.toast {
  padding: 10px 18px; border-radius: 12px;
  background: rgba(20, 29, 38, 0.97);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-lg);
  font-size: 13px; color: var(--text);
  animation: toastIn 0.22s ease-out;
  max-width: 92vw; text-align: center;
}
.toast.error { border-color: rgba(244, 63, 94, 0.45); color: #fda4af; }
.toast.success { border-color: rgba(18, 196, 139, 0.45); }

/* ============================================================
   Responsive
   ============================================================ */
.only-mobile { display: none; }

@media (max-width: 1080px) {
  .auth-wrap { gap: 36px; padding: 40px 28px; }
  .hero-title { font-size: 38px; }
}

@media (max-width: 900px) {
  .auth-wrap { grid-template-columns: 1fr; max-width: 480px; padding: 28px 18px 10px; gap: 26px; }
  .auth-hero { display: none; }
  .auth-mobile-brand { display: flex; align-items: center; justify-content: center; gap: 12px; margin-bottom: 2px; }
  .auth-mobile-brand .brand-logo { width: 46px; height: 46px; font-size: 26px; border-radius: 14px; }
  .auth-mobile-brand .brand-text { font-size: 18px; }
  .auth-card { max-width: 100%; padding: 26px 22px 22px; }
  .auth-foot { padding: 14px; }
  .mini-features { grid-template-columns: 1fr 1fr; }
  .mini-features div { padding: 9px 10px; font-size: 11.5px; gap: 7px; }

  .shell { grid-template-columns: 1fr; height: 100dvh; }
  .chat-panel {
    position: fixed; inset: 0; z-index: 40;
    display: none;
  }
  .shell.chat-open .sidebar { display: none; }
  .shell.chat-open .chat-panel { display: flex; }
  .only-mobile { display: grid; }

  .emoji-panel { width: calc(100vw - 20px); height: 300px; bottom: 74px; inset-inline-start: 10px; }
  .messages { padding: 12px 4px 6px; }
  .msgs-inner { padding: 0 2px; }
  .bubble { max-width: 86%; font-size: 14.2px; }
  .local-video { width: 100px; height: 142px; bottom: 150px; }
  .call-ctrl svg { width: 52px; height: 52px; padding: 15px; }
  .chat-head { padding: 0 6px; }
  .composer .icon-btn { width: 38px; height: 38px; }
  .welcome-logo { width: 78px; height: 78px; font-size: 42px; border-radius: 24px; }
}

@media (max-width: 480px) {
  .modal-layer { padding: 10px; }
  .modal { border-radius: 18px; max-height: 92dvh; }
  .avatar-picker { grid-template-columns: repeat(7, 1fr); }
  .incoming-actions { gap: 20px; }
  .bubble { max-width: 88%; }
  .msg.emoji-only .b-body { font-size: 34px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
