/* ============ وصل — الأنماط ============ */
:root {
  --brand: #0f7c86;
  --brand-dark: #0a5f67;
  --brand-light: #19a3a9;
  --accent: #1fb5a6;
  --bg: #e7ecee;
  --panel: #ffffff;
  --panel-2: #f2f5f6;
  --head: #f2f5f6;
  --line: #e3e8ea;
  --text: #15232a;
  --muted: #687b83;
  --hover: #f2f5f6;
  --active: #e6eef0;
  --out: #d3efec;
  --in: #ffffff;
  --chat-bg: #e9eef0;
  --chat-dot: rgba(15, 124, 134, .07);
  --read: #2f9fe8;
  --danger: #e2445c;
  --shadow: 0 1px .5px rgba(11, 20, 26, .13);
  --sys: #fff8e1;
  --radius: 8px;
  --font: "Segoe UI", "SF Arabic", "Noto Sans Arabic", Tahoma, system-ui, -apple-system, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c1519;
    --panel: #121e23;
    --panel-2: #1b292f;
    --head: #1b292f;
    --line: #23343b;
    --text: #e4ecef;
    --muted: #8ea2aa;
    --hover: #1b292f;
    --active: #24353c;
    --out: #0f5158;
    --in: #1b292f;
    --chat-bg: #0b1418;
    --chat-dot: rgba(31, 181, 166, .05);
    --sys: #1f2c31;
    --shadow: 0 1px .5px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font); font-size: 15px; color: var(--text); background: var(--bg);
  overflow: hidden; height: 100dvh;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
input, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
svg { display: block; }

/* ---------- auth ---------- */
.auth { min-height: 100dvh; display: grid; place-items: center; padding: 24px;
  background: linear-gradient(180deg, var(--brand) 0 220px, var(--bg) 220px); }
.auth-card { width: 100%; max-width: 400px; background: var(--panel); border-radius: 16px; padding: 32px 28px;
  box-shadow: 0 10px 40px rgba(0,0,0,.12); text-align: center; }
.auth-logo { width: 72px; height: 72px; }
.auth-card h1 { margin: 10px 0 2px; color: var(--brand); font-size: 28px; }
.auth-tabs { display: flex; background: var(--panel-2); border-radius: 10px; padding: 4px; margin: 20px 0 16px; }
.auth-tabs button { flex: 1; padding: 9px; border-radius: 8px; color: var(--muted); font-weight: 600; }
.auth-tabs button.active { background: var(--panel); color: var(--brand); box-shadow: var(--shadow); }
.field { display: block; text-align: right; margin-bottom: 12px; }
.field span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
.field input, .field textarea { width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--panel); outline: none; }
.field input:focus, .field textarea:focus { border-color: var(--brand); }
.auth:not(.register) .reg-only { display: none; }
.error { color: var(--danger); min-height: 20px; font-size: 13px; margin-bottom: 6px; }
.btn { padding: 11px 18px; border-radius: 24px; font-weight: 600; }
.btn.primary { background: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.primary:disabled { opacity: .6; }
.btn.ghost { color: var(--brand); }
.btn.danger { color: var(--danger); }
.btn.block { width: 100%; }

/* ---------- layout ---------- */
.main { display: flex; height: 100dvh; max-width: 1600px; margin: 0 auto; background: var(--panel); position: relative; }
@media (min-width: 1440px) { body { padding: 19px 0; } .main { height: calc(100dvh - 38px); box-shadow: 0 6px 18px rgba(0,0,0,.08); } }
.sidebar { width: 30%; min-width: 320px; max-width: 460px; border-left: 1px solid var(--line); display: flex;
  flex-direction: column; position: relative; overflow: hidden; background: var(--panel); }
.pane { flex: 1; position: relative; display: flex; min-width: 0; }

.bar { height: 60px; display: flex; align-items: center; gap: 6px; padding: 0 12px; background: var(--head); flex-shrink: 0; }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; color: var(--muted); flex-shrink: 0; }
.icon-btn:hover { background: var(--active); }
.icon-btn.light { color: #fff; }
.icon-btn.light:hover { background: rgba(255,255,255,.12); }
.icon-btn.danger { color: var(--danger); }
.icon-btn svg { width: 24px; height: 24px; }
.avatar-btn { border-radius: 50%; }

.avatar { width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0; background: #c5d3d8 center/cover no-repeat;
  display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 16px; overflow: hidden; user-select: none; }
.avatar.lg { width: 49px; height: 49px; font-size: 19px; }
.avatar.xl { width: 120px; height: 120px; font-size: 44px; }
.avatar.xxl { width: 200px; height: 200px; font-size: 70px; }
.avatar.sm { width: 32px; height: 32px; font-size: 13px; }
.avatar svg { width: 60%; height: 60%; color: #fff; }

.menu-wrap { position: relative; }
.dropdown { position: absolute; top: 44px; left: 0; background: var(--panel); border-radius: 6px; padding: 8px 0; min-width: 190px;
  box-shadow: 0 2px 5px rgba(11,20,26,.26), 0 2px 10px rgba(11,20,26,.16); z-index: 50; }
.dropdown button { display: flex; align-items: center; gap: 12px; width: 100%; text-align: right; padding: 11px 22px; font-size: 14.5px; }
.dropdown button:hover { background: var(--hover); }
.dropdown.ctx { position: fixed; top: 0; left: 0; }
.dropdown.up { top: auto; bottom: 62px; right: 56px; left: auto; }
.dot { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; color: #fff; }
.dot svg { width: 18px; height: 18px; }
.dot.media { background: #8a5cf6; } .dot.doc { background: #5b6bf5; } .dot.cam { background: #e2445c; }

/* ---------- sidebar lists ---------- */
.search-box { margin: 8px 12px; position: relative; }
.search-box input { width: 100%; padding: 9px 46px 9px 14px; background: var(--panel-2); border: 0; border-radius: 8px; outline: none; font-size: 14px; }
.search-ico { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search-ico svg { width: 18px; height: 18px; }
.tabs { display: flex; gap: 8px; padding: 2px 12px 8px; }
.tab { padding: 6px 14px; border-radius: 18px; background: var(--panel-2); color: var(--muted); font-size: 14px; }
.tab.active { background: color-mix(in srgb, var(--brand) 16%, transparent); color: var(--brand); font-weight: 600; }
.list { flex: 1; overflow-y: auto; overscroll-behavior: contain; }
.list-empty { padding: 40px 24px; text-align: center; color: var(--muted); font-size: 14px; line-height: 1.8; }
.list-section { padding: 14px 24px 8px; color: var(--brand); font-size: 14px; }

.row { display: flex; align-items: center; gap: 14px; padding: 0 14px; height: 72px; cursor: pointer; position: relative; }
.row:hover { background: var(--hover); }
.row.active { background: var(--active); }
.row .row-main { flex: 1; min-width: 0; height: 100%; display: flex; flex-direction: column; justify-content: center;
  border-bottom: 1px solid var(--line); gap: 3px; }
.row:last-child .row-main { border-bottom: 0; }
.row-top, .row-bot { display: flex; align-items: center; gap: 6px; }
.row-title { flex: 1; min-width: 0; font-size: 16.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-time { font-size: 12px; color: var(--muted); flex-shrink: 0; }
.row.unread .row-time { color: var(--accent); font-weight: 600; }
.row-sub { flex: 1; min-width: 0; font-size: 14px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  display: flex; align-items: center; gap: 3px; }
.row-sub .typing { color: var(--accent); }
.row-sub svg { width: 16px; height: 16px; flex-shrink: 0; }
.badge { background: var(--accent); color: #fff; border-radius: 12px; min-width: 20px; height: 20px; padding: 0 6px;
  font-size: 12px; font-weight: 700; display: inline-grid; place-items: center; flex-shrink: 0; }
.row .check { width: 22px; height: 22px; border-radius: 4px; border: 2px solid var(--muted); flex-shrink: 0; display: grid; place-items: center; }
.row.selected .check { background: var(--accent); border-color: var(--accent); color: #fff; }
.row .check svg { width: 14px; height: 14px; }
.row .call-icon { color: var(--brand); }
.missed { color: var(--danger) !important; }
.online-dot { position: absolute; bottom: 12px; right: 48px; width: 12px; height: 12px; background: #25c16f; border-radius: 50%; border: 2px solid var(--panel); }

.conn-banner { background: #ffd279; color: #3b2a00; padding: 10px 16px; font-size: 14px; }

/* ---------- drawer ---------- */
.drawer { position: absolute; inset: 0; background: var(--panel); display: flex; flex-direction: column; z-index: 20;
  transform: translateX(100%); transition: transform .25s ease; visibility: hidden; }
.drawer.open { transform: translateX(0); visibility: visible; }
.drawer-head { height: 108px; background: var(--brand); color: #fff; display: flex; align-items: flex-end; gap: 18px; padding: 0 18px 16px; flex-shrink: 0; }
.drawer-head .icon-btn { color: #fff; }
.drawer-head .icon-btn:hover { background: rgba(255,255,255,.12); }
.drawer-head h2 { margin: 0 0 6px; font-size: 19px; font-weight: 600; }
.drawer-body { flex: 1; overflow-y: auto; background: var(--panel-2); }
.drawer-section { background: var(--panel); padding: 16px 28px; margin-bottom: 10px; box-shadow: var(--shadow); }
.drawer-section h3 { margin: 0 0 12px; color: var(--brand); font-size: 14px; font-weight: 500; }
.profile-photo { display: grid; place-items: center; padding: 28px 0; background: var(--panel-2); }
.photo-pick { position: relative; cursor: pointer; border-radius: 50%; }
.photo-pick .overlay { position: absolute; inset: 0; border-radius: 50%; background: rgba(0,0,0,.45); color: #fff; display: grid;
  place-items: center; text-align: center; font-size: 13px; opacity: 0; transition: opacity .2s; padding: 30px; }
.photo-pick:hover .overlay { opacity: 1; }
.edit-line { display: flex; align-items: center; gap: 8px; border-bottom: 2px solid transparent; }
.edit-line input { flex: 1; border: 0; outline: none; background: transparent; padding: 8px 0; font-size: 16px; }
.edit-line input:focus { border-bottom: 2px solid var(--brand); }
.hint { color: var(--muted); font-size: 13.5px; line-height: 1.6; padding: 4px 28px 18px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 12px 18px; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--panel-2); border-radius: 18px; padding: 3px 4px 3px 10px; font-size: 14px; }
.chip button { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; color: var(--muted); }
.chip button svg { width: 14px; height: 14px; }
.fab { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 50%; background: var(--accent); color: #fff;
  margin: 24px auto; box-shadow: 0 2px 8px rgba(0,0,0,.25); }
.fab svg { width: 26px; height: 26px; }
.lookup { display: flex; gap: 8px; padding: 14px 18px; background: var(--panel); }
.lookup input { flex: 1; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); outline: none; }
.lookup input:focus { border-color: var(--brand); }
.lookup .btn { padding: 8px 16px; }

/* ---------- empty pane ---------- */
.empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 40px;
  background: var(--panel-2); border-bottom: 6px solid var(--brand); color: var(--muted); }
.empty h2 { color: var(--text); font-weight: 300; font-size: 32px; margin: 24px 0 8px; }
.empty p { max-width: 460px; line-height: 1.7; }
.empty-logo { width: 140px; opacity: .9; }
.lock { display: inline-block; vertical-align: -2px; }
.lock svg { width: 12px; height: 12px; display: inline; }

/* ---------- chat ---------- */
.chat { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; }
.chat-head { border-right: 0; z-index: 3; }
.back-btn { display: none; }
.chat-who { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; cursor: pointer; padding: 0 4px; }
.who-text { min-width: 0; }
.who-name { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who-status { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who-status.typing { color: var(--accent); }

.msgs-wrap { flex: 1; position: relative; min-height: 0; background-color: var(--chat-bg);
  background-image: radial-gradient(var(--chat-dot) 1.5px, transparent 1.5px), radial-gradient(var(--chat-dot) 1.5px, transparent 1.5px);
  background-size: 28px 28px; background-position: 0 0, 14px 14px; }
.msgs { position: absolute; inset: 0; overflow-y: auto; padding: 12px 6% 8px; display: flex; flex-direction: column; overscroll-behavior: contain; }
.msgs-loader { text-align: center; padding: 8px; color: var(--muted); font-size: 13px; }
.day { align-self: center; background: var(--panel); color: var(--muted); font-size: 12.5px; padding: 5px 12px; border-radius: 8px;
  margin: 10px 0; box-shadow: var(--shadow); position: sticky; top: 4px; z-index: 2; }
.sys { align-self: center; background: var(--sys); color: var(--muted); font-size: 12.5px; padding: 6px 12px; border-radius: 8px;
  margin: 6px 0; box-shadow: var(--shadow); text-align: center; max-width: 80%; }
.e2e { align-self: center; background: #fdf3c4; color: #54471b; font-size: 12.5px; padding: 6px 12px; border-radius: 8px; margin: 6px 0 12px; text-align: center; max-width: 520px; }
@media (prefers-color-scheme: dark) { .e2e { background: #2a2a1a; color: #e9dea8; } }

.msg { display: flex; margin-top: 2px; position: relative; }
.msg.first { margin-top: 10px; }
.msg.out { justify-content: flex-end; }   /* RTL: end = left (mirrored like the original) */
.msg.in { justify-content: flex-start; }
.bubble { max-width: min(65%, 560px); background: var(--in); border-radius: 8px; padding: 6px 8px 8px 9px; box-shadow: var(--shadow);
  position: relative; word-wrap: break-word; overflow-wrap: anywhere; line-height: 1.45; font-size: 14.5px; }
.msg.out .bubble { background: var(--out); }
.msg.first.out .bubble { border-top-left-radius: 0; }
.msg.first.in .bubble { border-top-right-radius: 0; }
.msg.first.out .bubble::before, .msg.first.in .bubble::before { content: ""; position: absolute; top: 0; width: 8px; height: 13px; }
.msg.first.out .bubble::before { left: -8px; background: var(--out); clip-path: polygon(0 0, 100% 0, 100% 100%); }
.msg.first.in .bubble::before { right: -8px; background: var(--in); clip-path: polygon(0 0, 100% 0, 0 100%); }
.msg.highlight .bubble { animation: flash 1.2s; }
@keyframes flash { 0%, 60% { filter: brightness(.85); } }
.sender { font-size: 13px; font-weight: 600; margin-bottom: 2px; }
.text { white-space: pre-wrap; }
.text a { color: var(--read); }
.text.big-emoji { font-size: 38px; line-height: 1.2; }
.meta { float: left; margin: 6px 10px -4px 0; font-size: 11px; color: var(--muted); display: inline-flex; align-items: center; gap: 3px; height: 15px; white-space: nowrap; }
.meta.overlay { position: absolute; left: 8px; bottom: 6px; margin: 0; color: #fff; background: linear-gradient(transparent, rgba(0,0,0,.35)); padding: 2px 6px; border-radius: 8px; float: none; }
.meta svg { width: 16px; height: 16px; }
.tick.read { color: var(--read); }
.deleted { color: var(--muted); font-style: italic; display: flex; align-items: center; gap: 4px; }
.deleted svg { width: 15px; height: 15px; }
.msg-arrow { position: absolute; top: 2px; left: 2px; width: 26px; height: 26px; border-radius: 50%; display: none; place-items: center;
  color: var(--muted); background: inherit; }
.bubble:hover .msg-arrow { display: grid; }
.msg-arrow svg { width: 18px; height: 18px; }

.quote { background: rgba(0,0,0,.05); border-right: 4px solid var(--accent); border-radius: 6px; padding: 5px 9px; margin-bottom: 5px;
  font-size: 13px; cursor: pointer; overflow: hidden; }
@media (prefers-color-scheme: dark) { .quote { background: rgba(255,255,255,.06); } }
.quote .q-name { color: var(--accent); font-weight: 600; font-size: 12.5px; }
.quote .q-text { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.media { margin: -3px -5px 4px; border-radius: 6px; overflow: hidden; position: relative; cursor: pointer; background: rgba(0,0,0,.06); }
.media img, .media video { display: block; max-width: 100%; max-height: 340px; min-width: 160px; min-height: 80px; object-fit: cover; width: 330px; }
.media.only { margin-bottom: -5px; }
.media .play { position: absolute; inset: 0; display: grid; place-items: center; }
.media .play span { width: 52px; height: 52px; border-radius: 50%; background: rgba(0,0,0,.5); display: grid; place-items: center; color: #fff; }
.media .play svg { width: 28px; height: 28px; }

.filecard { display: flex; align-items: center; gap: 10px; background: rgba(0,0,0,.05); border-radius: 6px; padding: 10px; margin-bottom: 4px;
  text-decoration: none; color: inherit; min-width: 240px; }
@media (prefers-color-scheme: dark) { .filecard { background: rgba(255,255,255,.06); } }
.filecard .ficon { width: 36px; height: 42px; border-radius: 4px; background: var(--brand); color: #fff; font-size: 10px; font-weight: 700;
  display: grid; place-items: center; flex-shrink: 0; text-transform: uppercase; }
.filecard .fname { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.filecard .fsize { font-size: 12px; color: var(--muted); }
.filecard .dl { color: var(--muted); }
.filecard .dl svg { width: 22px; height: 22px; }

.voice { display: flex; align-items: center; gap: 10px; min-width: 240px; padding: 4px 0 2px; direction: ltr; }
.voice .vplay { width: 34px; height: 34px; display: grid; place-items: center; color: var(--muted); flex-shrink: 0; }
.voice .vplay svg { width: 30px; height: 30px; }
.voice .vtrack { flex: 1; height: 26px; position: relative; cursor: pointer; display: flex; align-items: center; }
.voice .vbars { display: flex; align-items: center; gap: 2px; height: 100%; width: 100%; }
.voice .vbars i { flex: 1; background: color-mix(in srgb, var(--muted) 55%, transparent); border-radius: 2px; min-height: 3px; }
.voice .vbars i.on { background: var(--accent); }
.voice .vdur { font-size: 11px; color: var(--muted); position: absolute; bottom: -14px; left: 0; }
.voice .avatar { width: 46px; height: 46px; }

.to-bottom { position: absolute; left: 18px; bottom: 16px; width: 42px; height: 42px; border-radius: 50%; background: var(--panel);
  box-shadow: 0 1px 3px rgba(0,0,0,.25); display: grid; place-items: center; color: var(--muted); z-index: 4; }
.to-bottom svg { width: 24px; height: 24px; }
.to-bottom .badge { position: absolute; top: -8px; left: -4px; }

.reply-bar { display: flex; align-items: center; gap: 8px; background: var(--head); padding: 8px 14px 0; }
.reply-quote { flex: 1; min-width: 0; }
.reply-quote .quote { margin: 0; cursor: default; }

.emoji-panel { height: 240px; background: var(--head); overflow-y: auto; padding: 8px 12px; display: grid;
  grid-template-columns: repeat(auto-fill, minmax(42px, 1fr)); gap: 2px; border-top: 1px solid var(--line); }
.emoji-panel button { font-size: 26px; height: 42px; border-radius: 6px; }
.emoji-panel button:hover { background: var(--active); }

.composer { background: var(--head); padding: 6px 10px; min-height: 62px; display: flex; align-items: center; position: relative; flex-shrink: 0;
  padding-bottom: max(6px, env(safe-area-inset-bottom)); }
.compose-normal, .compose-rec { display: flex; align-items: flex-end; gap: 4px; width: 100%; }
.compose-rec { align-items: center; gap: 10px; padding: 0 6px; }
.input-wrap { flex: 1; background: var(--panel); border-radius: 8px; padding: 9px 12px; margin: 0 4px; display: flex; min-width: 0; }
#msgInput { width: 100%; border: 0; outline: 0; resize: none; background: transparent; max-height: 120px; line-height: 1.45; font-size: 15px; padding: 0; }
.round-btn { width: 46px; height: 46px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; flex-shrink: 0; }
.round-btn:hover { background: var(--brand-dark); }
.round-btn svg { width: 22px; height: 22px; }
.compose-normal .icon-btn { margin-bottom: 3px; }
.rec-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--danger); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .2; } }
.rec-time { font-variant-numeric: tabular-nums; font-size: 17px; direction: ltr; }

/* ---------- info panel ---------- */
.info-panel { position: absolute; inset: 0 auto 0 0; width: min(420px, 100%); background: var(--panel-2); z-index: 10; display: flex; flex-direction: column;
  border-right: 1px solid var(--line); box-shadow: 4px 0 14px rgba(0,0,0,.08); }
.info-panel .bar { gap: 16px; }
.info-body { flex: 1; overflow-y: auto; }
.info-hero { background: var(--panel); text-align: center; padding: 28px 20px 20px; margin-bottom: 10px; box-shadow: var(--shadow); }
.info-hero .avatar { margin: 0 auto 14px; }
.info-hero h2 { margin: 0; font-weight: 400; font-size: 22px; }
.info-hero p { margin: 4px 0 0; color: var(--muted); }
.info-actions { display: flex; justify-content: center; gap: 12px; margin-top: 18px; }
.info-actions button { display: flex; flex-direction: column; align-items: center; gap: 6px; color: var(--brand); font-size: 13px; padding: 10px 18px;
  border: 1px solid var(--line); border-radius: 10px; }
.info-actions svg { width: 22px; height: 22px; }
.info-row { padding: 14px 28px; display: flex; align-items: center; gap: 18px; cursor: pointer; }
.info-row:hover { background: var(--hover); }
.info-row.danger { color: var(--danger); }
.info-row svg { width: 22px; height: 22px; }
.role-tag { font-size: 11.5px; color: var(--accent); border: 1px solid currentColor; border-radius: 4px; padding: 0 5px; }

/* ---------- call ---------- */
.call { position: fixed; inset: 0; z-index: 100; background: radial-gradient(circle at 50% 30%, #1c4b52, #0a1d21 70%); color: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: space-between; overflow: hidden; }
#remoteVideo { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #000; display: none; }
.call.video-on #remoteVideo { display: block; }
#localVideo { position: absolute; top: 18px; left: 18px; width: 130px; aspect-ratio: 3/4; object-fit: cover; border-radius: 12px;
  background: #000; transform: scaleX(-1); box-shadow: 0 4px 14px rgba(0,0,0,.5); display: none; z-index: 2; }
.call.local-on #localVideo { display: block; }
.call.video-on.connected .call-info .avatar, .call.video-on.connected .call-lock { display: none; }
.call-info { position: relative; z-index: 1; text-align: center; padding-top: 9vh; }
.call.video-on.connected .call-info { padding-top: 20px; text-shadow: 0 1px 4px rgba(0,0,0,.6); }
.call-lock { font-size: 13px; opacity: .75; margin-bottom: 26px; }
.call-info .avatar { margin: 0 auto 18px; box-shadow: 0 0 0 10px rgba(255,255,255,.06), 0 0 0 22px rgba(255,255,255,.03); }
.call.ringing .call-info .avatar { animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 16px rgba(255,255,255,.09), 0 0 0 34px rgba(255,255,255,.04); } }
.call-name { font-size: 28px; font-weight: 500; }
.call-status { margin-top: 8px; opacity: .85; font-variant-numeric: tabular-nums; }
.call-controls { position: relative; z-index: 1; display: flex; gap: 22px; padding: 22px 30px calc(30px + env(safe-area-inset-bottom));
  background: rgba(0,0,0,.25); border-radius: 30px 30px 0 0; width: 100%; justify-content: center; }
.call-btn { width: 60px; height: 60px; border-radius: 50%; background: rgba(255,255,255,.16); display: grid; place-items: center; color: #fff; }
.call-btn:hover { background: rgba(255,255,255,.26); }
.call-btn.off { background: #fff; color: #1b292f; }
.call-btn.end { background: var(--danger); }
.call-btn.accept { background: #25c16f; animation: bounce 1.2s infinite; }
@keyframes bounce { 50% { transform: translateY(-6px); } }
.call-btn svg { width: 28px; height: 28px; }

/* ---------- viewer ---------- */
.viewer { position: fixed; inset: 0; z-index: 90; background: rgba(8, 16, 19, .96); display: flex; flex-direction: column; color: #fff; }
.viewer-head { height: 60px; display: flex; align-items: center; gap: 10px; padding: 0 12px; }
.viewer-body { flex: 1; display: grid; place-items: center; min-height: 0; padding: 12px; overflow: auto; }
.viewer-body img, .viewer-body video { max-width: 100%; max-height: 100%; object-fit: contain; }
.preview-grid { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }
.preview-grid .pitem { width: 220px; background: rgba(255,255,255,.08); border-radius: 10px; padding: 12px; text-align: center; font-size: 13px; word-break: break-all; }
.preview-grid img, .preview-grid video { width: 100%; max-height: 260px; object-fit: contain; border-radius: 6px; margin-bottom: 6px; }
.preview-foot { display: flex; gap: 10px; padding: 12px 16px calc(14px + env(safe-area-inset-bottom)); align-items: center; }
.preview-foot input { flex: 1; padding: 12px 14px; border-radius: 8px; border: 0; background: rgba(255,255,255,.12); color: #fff; outline: none; }
.preview-foot input::placeholder { color: rgba(255,255,255,.6); }

.toast { position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%); background: #263238; color: #fff; padding: 11px 20px;
  border-radius: 8px; z-index: 200; font-size: 14px; box-shadow: 0 4px 12px rgba(0,0,0,.3); max-width: 90vw; text-align: center; }

/* scrollbars */
.list::-webkit-scrollbar, .msgs::-webkit-scrollbar, .drawer-body::-webkit-scrollbar, .info-body::-webkit-scrollbar { width: 6px; }
.list::-webkit-scrollbar-thumb, .msgs::-webkit-scrollbar-thumb, .drawer-body::-webkit-scrollbar-thumb, .info-body::-webkit-scrollbar-thumb { background: rgba(0,0,0,.2); }

/* ---------- mobile ---------- */
@media (max-width: 800px) {
  .sidebar { width: 100%; max-width: none; min-width: 0; border: 0; }
  .pane { position: absolute; inset: 0; z-index: 30; transform: translateX(-100%); transition: transform .22s ease; visibility: hidden; }
  .main.in-chat .pane { transform: translateX(0); visibility: visible; }
  .main.in-chat .sidebar { visibility: hidden; }
  .empty { display: none; }
  .back-btn { display: grid; }
  .bar.chat-head { padding: 0 4px; gap: 0; }
  .msgs { padding: 8px 10px; }
  .bubble { max-width: 82%; }
  .msg-arrow { display: none !important; }
  .side-head { background: var(--brand); color: #fff; }
  .side-head .icon-btn { color: #fff; }
  .side-head .icon-btn:hover { background: rgba(255,255,255,.14); }
  .info-panel { width: 100%; }
  .media img, .media video { width: 260px; }
  #localVideo { width: 100px; }
  .call-btn { width: 56px; height: 56px; }
  .call-controls { gap: 16px; }
}
