/* =========================================================
   ChatApp — styles
   ========================================================= */
:root {
  --accent: #6c5ce7;
  --accent-2: #8e7dff;
  --accent-soft: rgba(108, 92, 231, 0.12);
  --grad: linear-gradient(135deg, #8e7dff 0%, #6c5ce7 55%, #5a3fd8 100%);
  --bg: #f4f3fb;
  --panel: #ffffff;
  --panel-2: #f7f6fd;
  --text: #1d1b2e;
  --muted: #7a7891;
  --border: #e8e6f3;
  --bubble-in: #ffffff;
  --bubble-out: var(--grad);
  --danger: #ef4565;
  --success: #22c55e;
  --shadow: 0 10px 30px rgba(41, 30, 120, 0.08);
  --shadow-lg: 0 24px 60px rgba(41, 30, 120, 0.18);
  --radius: 18px;
  --chat-bg: #efedf9;
  --font: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
[data-theme="dark"] {
  --bg: #0f0e17;
  --panel: #17162a;
  --panel-2: #1e1c35;
  --text: #ecebf5;
  --muted: #9b99b5;
  --border: #2a2846;
  --bubble-in: #232140;
  --accent-soft: rgba(142, 125, 255, 0.16);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.55);
  --chat-bg: #12111f;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  transition: background .25s, color .25s;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; font-weight: 600; }
a:hover { text-decoration: underline; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.block { display: block; width: 100%; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row-end { display: flex; justify-content: flex-end; margin: -4px 0 14px; font-size: 13px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 20px; border-radius: 14px; font-weight: 700; font-size: 14.5px;
  transition: transform .12s, box-shadow .2s, background .2s, opacity .2s;
  user-select: none;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--grad); color: #fff; box-shadow: 0 8px 20px rgba(108, 92, 231, .35); }
.btn.primary:hover { box-shadow: 0 10px 26px rgba(108, 92, 231, .5); }
.btn.ghost { background: var(--accent-soft); color: var(--accent); }
[data-theme="dark"] .btn.ghost { color: var(--accent-2); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.sm { padding: 8px 14px; font-size: 13px; border-radius: 11px; }
.btn.block { width: 100%; }
.btn.block + .btn.block { margin-top: 10px; }
.btn:disabled { opacity: .45; pointer-events: none; }
.btn.round { width: 64px; height: 64px; border-radius: 50%; font-size: 24px; padding: 0; }

.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; display: inline-grid; place-items: center;
  color: var(--muted); transition: background .2s, color .2s, transform .12s; flex-shrink: 0;
}
.icon-btn:hover { background: var(--accent-soft); color: var(--accent); }
.icon-btn:active { transform: scale(.92); }
.icon-btn.accent { background: var(--grad); color: #fff; border-radius: 50%; width: 44px; height: 44px; box-shadow: 0 6px 16px rgba(108, 92, 231, .35); }
.icon-btn.accent:hover { color: #fff; filter: brightness(1.08); }

.theme-toggle .i-sun { display: none; }
[data-theme="dark"] .theme-toggle .i-sun { display: block; }
[data-theme="dark"] .theme-toggle .i-moon { display: none; }

/* ---------- Screens ---------- */
.screen { position: fixed; inset: 0; }

#loading { display: grid; place-items: center; background: var(--bg); z-index: 50; }
.loader-logo { text-align: center; color: var(--muted); }
.loader-logo img { width: 72px; animation: pop 1.4s ease-in-out infinite; }
.spinner { width: 28px; height: 28px; margin: 18px auto 10px; border-radius: 50%; border: 3px solid var(--accent-soft); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pop { 50% { transform: scale(1.08); } }

/* ---------- Auth ---------- */
#auth { display: grid; place-items: center; padding: 20px; overflow-y: auto; }
.auth-bg { position: fixed; inset: 0; overflow: hidden; z-index: -1; }
.blob { position: absolute; border-radius: 50%; filter: blur(60px); opacity: .55; animation: float 14s ease-in-out infinite; }
.b1 { width: 420px; height: 420px; background: #8e7dff; top: -120px; left: -100px; }
.b2 { width: 360px; height: 360px; background: #ff7eb3; bottom: -120px; right: -80px; animation-delay: -5s; }
.b3 { width: 260px; height: 260px; background: #4fd1c5; top: 40%; left: 60%; animation-delay: -9s; opacity: .35; }
[data-theme="dark"] .blob { opacity: .28; }
@keyframes float { 50% { transform: translate(40px, 30px) scale(1.1); } }
.floating { position: fixed; top: 16px; right: 16px; background: var(--panel); box-shadow: var(--shadow); }

.auth-card {
  width: 100%; max-width: 420px; padding: 34px 30px 26px;
  background: color-mix(in srgb, var(--panel) 82%, transparent);
  backdrop-filter: blur(22px); -webkit-backdrop-filter: blur(22px);
  border: 1px solid var(--border); border-radius: 26px; box-shadow: var(--shadow-lg);
  animation: rise .45s cubic-bezier(.2, .9, .3, 1.2);
}
@keyframes rise { from { opacity: 0; transform: translateY(18px) scale(.98); } }
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.auth-brand img { width: 40px; }
.auth-brand h1 { font-size: 22px; font-weight: 800; letter-spacing: -.3px; }
.auth-pane h2 { font-size: 24px; font-weight: 800; letter-spacing: -.4px; }
.auth-pane > .muted { margin: 4px 0 22px; }
.auth-pane { animation: fade .3s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } }
.switch { text-align: center; margin-top: 18px; font-size: 14px; color: var(--muted); }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.hint { display: block; color: var(--muted); font-size: 12px; margin: -6px 0 14px; }
.verify-icon { font-size: 48px; margin-bottom: 8px; }

.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--muted); }
.field input, .input, .at-wrap {
  width: 100%; padding: 12px 14px; border-radius: 13px; border: 1.5px solid var(--border);
  background: var(--panel-2); outline: none; transition: border .2s, box-shadow .2s;
}
.field input:focus, .input:focus, .at-wrap:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 44px; }
.pw-eye { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); width: 32px; height: 32px; border-radius: 8px; opacity: .6; }
.pw-eye:hover { opacity: 1; }
.at-wrap { display: flex; align-items: center; gap: 4px; padding: 0 14px; }
.at-wrap span { color: var(--muted); font-weight: 700; }
.at-wrap input { border: 0; background: none; padding: 12px 0; outline: none; flex: 1; box-shadow: none !important; }

/* ---------- App layout ---------- */
#app { display: grid; grid-template-columns: 360px 1fr; height: 100dvh; }

.sidebar { position: relative; display: flex; flex-direction: column; background: var(--panel); border-right: 1px solid var(--border); min-width: 0; }
.side-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 14px 10px; gap: 8px; }
.me-chip { display: flex; align-items: center; gap: 10px; padding: 6px 10px 6px 6px; border-radius: 16px; text-align: left; min-width: 0; transition: background .2s; }
.me-chip:hover { background: var(--accent-soft); }
.me-text { display: flex; flex-direction: column; min-width: 0; }
.me-text b { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-text small { color: var(--muted); font-size: 12.5px; }
.side-actions { display: flex; gap: 2px; }

.menu-wrap { position: relative; }
.dropdown {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; min-width: 200px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-lg);
  padding: 6px; animation: drop .16s ease;
}
.dropdown.up { top: auto; bottom: calc(100% + 8px); left: 0; right: auto; }
@keyframes drop { from { opacity: 0; transform: translateY(-4px) scale(.98); } }
.dropdown button { display: block; width: 100%; text-align: left; padding: 10px 12px; border-radius: 10px; font-size: 14px; font-weight: 500; }
.dropdown button:hover { background: var(--accent-soft); }
.dropdown button.danger { color: var(--danger); }
.dropdown hr { border: 0; border-top: 1px solid var(--border); margin: 6px 4px; }

.search-box { margin: 4px 14px 10px; display: flex; align-items: center; gap: 8px; background: var(--panel-2); border: 1.5px solid var(--border); border-radius: 14px; padding: 0 12px; transition: border .2s; }
.search-box:focus-within { border-color: var(--accent); }
.search-box svg { color: var(--muted); width: 18px; }
.search-box input { flex: 1; border: 0; background: none; padding: 11px 0; outline: none; }

.tabs { display: flex; gap: 6px; padding: 0 14px 8px; }
.tab { flex: 1; padding: 9px; border-radius: 12px; font-weight: 600; font-size: 14px; color: var(--muted); display: flex; align-items: center; justify-content: center; gap: 6px; transition: .2s; }
.tab.active { background: var(--accent-soft); color: var(--accent); }
[data-theme="dark"] .tab.active { color: var(--accent-2); }
.badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--accent); color: #fff; font-size: 11.5px; font-weight: 700; display: inline-grid; place-items: center; }

.list-wrap { flex: 1; overflow-y: auto; padding: 0 8px 90px; }
.friend-list { list-style: none; }
.friend {
  display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: 16px; cursor: pointer;
  transition: background .15s; position: relative; animation: fade .25s ease;
}
.friend:hover { background: var(--panel-2); }
.friend.active { background: var(--accent-soft); }
.friend .info { flex: 1; min-width: 0; }
.friend .top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.friend .top b { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.friend .top time { font-size: 11.5px; color: var(--muted); flex-shrink: 0; }
.friend .bottom { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 2px; }
.friend .preview { font-size: 13.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.friend.unread .preview { color: var(--text); font-weight: 600; }
.friend .req-actions { display: flex; gap: 6px; }

.empty { text-align: center; padding: 50px 20px; color: var(--muted); }
.empty-emoji { font-size: 44px; margin-bottom: 8px; }
.empty p { margin-bottom: 14px; }

.fab { position: absolute; right: 20px; bottom: 22px; width: 54px; height: 54px; border-radius: 18px; background: var(--grad); color: #fff; display: grid; place-items: center; box-shadow: 0 12px 26px rgba(108, 92, 231, .45); transition: transform .15s; }
.fab:hover { transform: translateY(-2px) rotate(90deg); }
.fab svg { width: 24px; height: 24px; stroke-width: 2.5; }

/* ---------- Avatars ---------- */
.avatar { position: relative; flex-shrink: 0; width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 16px; background-size: cover; background-position: center; }
.avatar.sm { width: 38px; height: 38px; font-size: 14px; }
.avatar.lg { width: 96px; height: 96px; font-size: 34px; }
.avatar .dot { position: absolute; right: 0; bottom: 1px; width: 13px; height: 13px; border-radius: 50%; background: var(--success); border: 2.5px solid var(--panel); }
.avatar-slot { display: inline-flex; }

/* ---------- Chat ---------- */
.chat { position: relative; background: var(--chat-bg); min-width: 0; display: flex; flex-direction: column; }
.chat-placeholder { margin: auto; text-align: center; padding: 30px; max-width: 380px; }
.ph-art { width: 110px; height: 110px; margin: 0 auto 18px; border-radius: 34px; background: var(--grad); display: grid; place-items: center; font-size: 52px; box-shadow: 0 20px 40px rgba(108, 92, 231, .35); animation: pop 3s ease-in-out infinite; }
.chat-placeholder h3 { font-size: 20px; margin-bottom: 8px; }

.chat-inner { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.chat-head { display: flex; align-items: center; gap: 8px; padding: 10px 14px; background: color-mix(in srgb, var(--panel) 88%, transparent); backdrop-filter: blur(14px); border-bottom: 1px solid var(--border); z-index: 2; }
.back-btn { display: none; }
.peer { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.peer > div { display: flex; flex-direction: column; min-width: 0; }
.peer b { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.peer small { color: var(--muted); font-size: 12.5px; }
.peer small.online { color: var(--success); font-weight: 600; }
.head-actions { display: flex; gap: 2px; }

.messages { flex: 1; overflow-y: auto; padding: 18px 6% 10px; background-size: cover; background-position: center; background-attachment: local; }
.msg-list { display: flex; flex-direction: column; gap: 3px; }
.day-sep { align-self: center; margin: 14px 0 8px; font-size: 12px; font-weight: 600; color: var(--muted); background: var(--panel); padding: 5px 12px; border-radius: 20px; box-shadow: var(--shadow); }
.sys-msg { align-self: center; margin: 6px 0; font-size: 12.5px; color: var(--muted); background: var(--panel); padding: 6px 12px; border-radius: 12px; }

.msg { display: flex; max-width: 72%; animation: bubble .22s cubic-bezier(.2, .9, .3, 1.3); position: relative; }
@keyframes bubble { from { opacity: 0; transform: translateY(8px) scale(.96); } }
.msg.in { align-self: flex-start; }
.msg.out { align-self: flex-end; }
.msg.gap { margin-top: 8px; }
.bubble { padding: 8px 12px 6px; border-radius: 18px; box-shadow: 0 1px 2px rgba(0, 0, 0, .06); word-wrap: break-word; overflow-wrap: anywhere; min-width: 70px; }
.msg.in .bubble { background: var(--bubble-in); border-bottom-left-radius: 6px; }
.msg.out .bubble { background: var(--bubble-out); color: #fff; border-bottom-right-radius: 6px; }
.bubble .text { white-space: pre-wrap; line-height: 1.45; }
.msg.out .bubble a { color: #fff; text-decoration: underline; }
[data-theme="dark"] .msg.in .bubble a { color: var(--accent-2); }
.bubble .meta { display: flex; justify-content: flex-end; align-items: center; gap: 4px; font-size: 10.5px; margin-top: 2px; opacity: .7; }
.bubble .ticks { font-size: 12px; letter-spacing: -3px; }
.bubble .ticks.seen { color: #7ef0ff; opacity: 1; }
.bubble.media { padding: 4px; }
.bubble.media .meta { padding: 0 8px 2px; }
.bubble img, .bubble video { display: block; max-width: 300px; max-height: 340px; width: 100%; border-radius: 14px; object-fit: cover; cursor: pointer; background: #000; }
.bubble audio { width: 240px; max-width: 100%; height: 40px; display: block; }
.msg.out .bubble audio { filter: invert(1) hue-rotate(180deg) brightness(1.6); }
.msg-del { position: absolute; top: 50%; transform: translateY(-50%); opacity: 0; width: 30px; height: 30px; border-radius: 50%; background: var(--panel); box-shadow: var(--shadow); font-size: 13px; transition: opacity .15s; }
.msg.out .msg-del { left: -38px; }
.msg.in .msg-del { right: -38px; }
.msg:hover .msg-del { opacity: 1; }

.typing-row { padding: 4px 6% 6px; font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.dots { display: inline-flex; gap: 3px; background: var(--bubble-in); padding: 8px 10px; border-radius: 14px; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.dots i:nth-child(2) { animation-delay: .15s; }
.dots i:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%, 60%, 100% { opacity: .3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

.composer { display: flex; align-items: flex-end; gap: 8px; padding: 10px 14px calc(12px + env(safe-area-inset-bottom)); background: color-mix(in srgb, var(--panel) 92%, transparent); backdrop-filter: blur(14px); border-top: 1px solid var(--border); }
.composer textarea { flex: 1; min-width: 0; height: 46px; min-height: 46px; resize: none; border: 1.5px solid var(--border); background: var(--panel-2); border-radius: 22px; padding: 11px 16px; max-height: 140px; outline: none; line-height: 1.4; transition: border .2s; }
.composer textarea:focus { border-color: var(--accent); }

/* ---------- Overlays / sheets ---------- */
.overlay { position: fixed; inset: 0; z-index: 60; background: rgba(15, 12, 40, .45); backdrop-filter: blur(6px); display: grid; place-items: center; padding: 16px; animation: fadeIn .2s ease; }
@keyframes fadeIn { from { opacity: 0; } }
.sheet { width: 100%; max-width: 520px; max-height: 92dvh; overflow-y: auto; background: var(--panel); border-radius: 24px; padding: 22px; box-shadow: var(--shadow-lg); animation: rise .3s cubic-bezier(.2, .9, .3, 1.2); }
.sheet.small { max-width: 400px; }
.sheet h3 { font-size: 19px; font-weight: 800; }
.sheet > p { margin: 8px 0 14px; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.sheet-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
#dialog .input { margin-top: 4px; }

.settings-section { padding: 16px 0; border-top: 1px solid var(--border); }
.settings-section h4 { font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); margin-bottom: 12px; }
.profile-edit { display: flex; gap: 16px; align-items: center; }
.avatar-upload { position: relative; cursor: pointer; }
.avatar-upload .cam { position: absolute; right: -2px; bottom: -2px; width: 32px; height: 32px; border-radius: 50%; background: var(--accent); display: grid; place-items: center; font-size: 15px; border: 3px solid var(--panel); }
.seg { display: flex; background: var(--panel-2); padding: 4px; border-radius: 14px; gap: 4px; margin-bottom: 14px; }
.seg button { flex: 1; padding: 9px; border-radius: 10px; font-size: 13.5px; font-weight: 600; color: var(--muted); }
.seg button.active { background: var(--panel); color: var(--text); box-shadow: var(--shadow); }
.bg-row { display: flex; gap: 14px; align-items: flex-start; }
.bg-preview { width: 92px; height: 120px; border-radius: 14px; border: 1px solid var(--border); background: var(--chat-bg); background-size: cover; background-position: center; flex-shrink: 0; }
.bg-btns { display: flex; flex-direction: column; gap: 10px; }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch { width: 28px; height: 28px; border-radius: 9px; border: 2px solid transparent; cursor: pointer; }
.swatch.active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--panel) inset; }
.switch-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; cursor: pointer; gap: 12px; }
.switch-row small.block { display: block; font-size: 12px; }
.toggle { appearance: none; width: 46px; height: 27px; border-radius: 20px; background: var(--border); position: relative; cursor: pointer; transition: background .2s; flex-shrink: 0; }
.toggle::after { content: ""; position: absolute; top: 3px; left: 3px; width: 21px; height: 21px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 2px 4px rgba(0, 0, 0, .2); }
.toggle:checked { background: var(--accent); }
.toggle:checked::after { transform: translateX(19px); }

#add-result { margin-bottom: 12px; }
.found { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 16px; background: var(--panel-2); margin-bottom: 4px; animation: fade .25s; }
.found .grow b { display: block; }
.found .grow small { color: var(--muted); }

/* ---------- Recorder ---------- */
.recorder-sheet { max-width: 380px; text-align: center; }
.recorder-sheet h3 { margin-bottom: 14px; }
#rec-preview { width: 100%; border-radius: 16px; background: #000; max-height: 50dvh; margin-bottom: 12px; transform: scaleX(-1); }
#rec-preview.playback { transform: none; }
.rec-visual { position: relative; width: 110px; height: 110px; margin: 6px auto 14px; border-radius: 50%; background: var(--accent-soft); display: grid; place-items: center; font-size: 42px; }
.rec-visual .pulse { position: absolute; inset: 0; border-radius: 50%; border: 3px solid var(--accent); opacity: 0; }
.recording .rec-visual .pulse { animation: ring 1.3s ease-out infinite; }
@keyframes ring { from { transform: scale(.9); opacity: .9; } to { transform: scale(1.4); opacity: 0; } }
.rec-timer { font-weight: 700; font-size: 18px; font-variant-numeric: tabular-nums; }
.rec-bar { height: 6px; background: var(--border); border-radius: 6px; overflow: hidden; margin: 10px 0 18px; }
.rec-bar span { display: block; height: 100%; width: 0; background: var(--grad); transition: width .2s linear; }
.rec-actions { display: flex; justify-content: space-between; align-items: center; }
.recording #rec-toggle { animation: pop 1s infinite; }

/* ---------- Calls ---------- */
.call-screen { position: fixed; inset: 0; z-index: 80; background: radial-gradient(circle at 50% 30%, #3b2f8f, #120f2b 70%); color: #fff; display: flex; flex-direction: column; justify-content: flex-end; animation: fadeIn .25s; }
#remote-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: transparent; }
#local-video { position: absolute; right: 18px; top: 18px; width: 130px; aspect-ratio: 3/4; object-fit: cover; border-radius: 18px; border: 2px solid rgba(255, 255, 255, .5); box-shadow: 0 10px 30px rgba(0, 0, 0, .4); transform: scaleX(-1); z-index: 2; background: #000; }
.call-info { position: absolute; top: 18%; left: 0; right: 0; text-align: center; z-index: 1; }
.call-info .avatar { margin: 0 auto 18px; box-shadow: 0 0 0 0 rgba(142, 125, 255, .6); animation: callring 1.8s infinite; }
@keyframes callring { 0% { box-shadow: 0 0 0 0 rgba(142, 125, 255, .6); } 100% { box-shadow: 0 0 0 36px rgba(142, 125, 255, 0); } }
.call-info h2 { font-size: 26px; }
.call-info p { opacity: .75; margin-top: 6px; font-variant-numeric: tabular-nums; }
.call-screen.video-live .call-info { top: auto; bottom: 130px; }
.call-screen.video-live .call-info .avatar { display: none; }
.call-screen.video-live .call-info h2 { font-size: 18px; text-shadow: 0 2px 8px rgba(0, 0, 0, .6); }
.call-controls { position: relative; z-index: 3; display: flex; justify-content: center; gap: 18px; padding: 26px 20px calc(34px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, rgba(0, 0, 0, .5)); }
.call-btn { width: 60px; height: 60px; border-radius: 50%; background: rgba(255, 255, 255, .16); backdrop-filter: blur(10px); display: grid; place-items: center; font-size: 22px; transition: transform .12s, background .2s; color: #fff; }
.call-btn:hover { background: rgba(255, 255, 255, .26); }
.call-btn:active { transform: scale(.92); }
.call-btn.off { background: #fff; color: #222; filter: grayscale(1); }
.call-btn.end { background: var(--danger); }
.call-btn.accept { background: var(--success); }
.call-btn.sm { width: 46px; height: 46px; font-size: 18px; }
.call-btn svg { width: 26px; height: 26px; }

.incoming { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 90; display: flex; align-items: center; gap: 12px; padding: 12px 12px 12px 14px; width: min(420px, calc(100% - 24px)); background: #1b1838; color: #fff; border-radius: 22px; box-shadow: var(--shadow-lg); animation: slideDown .35s cubic-bezier(.2, .9, .3, 1.3); }
@keyframes slideDown { from { transform: translate(-50%, -120%); } }
.incoming .in-text { flex: 1; min-width: 0; }
.incoming small { opacity: .7; display: block; }
.incoming .avatar { animation: callring 1.6s infinite; }

/* ---------- Lightbox / toasts ---------- */
.lightbox { position: fixed; inset: 0; z-index: 95; background: rgba(0, 0, 0, .92); display: grid; place-items: center; padding: 20px; animation: fadeIn .2s; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 10px; }
.lightbox .icon-btn { position: absolute; top: 14px; right: 14px; color: #fff; background: rgba(255, 255, 255, .12); }

#toasts { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { padding: 11px 18px; border-radius: 14px; background: #1d1b2e; color: #fff; font-size: 14px; font-weight: 500; box-shadow: var(--shadow-lg); animation: rise .3s cubic-bezier(.2, .9, .3, 1.2); max-width: 90vw; }
.toast.error { background: var(--danger); }
.toast.success { background: #16a34a; }
.toast.out { opacity: 0; transform: translateY(10px); transition: .3s; }

/* scrollbars */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- Responsive ---------- */
@media (max-width: 820px) {
  #app { grid-template-columns: 1fr; }
  .chat { position: fixed; inset: 0; transform: translateX(100%); transition: transform .3s cubic-bezier(.2, .8, .2, 1); z-index: 10; }
  #app.chat-open .chat { transform: none; }
  .back-btn { display: inline-grid; }
  .messages { padding: 14px 10px 8px; }
  .typing-row { padding: 4px 12px 6px; }
  .msg { max-width: 84%; }
  .msg-del { display: none; }
  .bubble img, .bubble video { max-width: 240px; }
  .two-col { grid-template-columns: 1fr; gap: 0; }
  .auth-card { padding: 28px 22px 22px; }
  #local-video { width: 100px; }
  .sheet { border-radius: 22px; }
}
