/* 💜 دردشة العائلة — التصميم */
:root {
  --a1: #9b7bff; --a2: #ff7eb6; --a3: #ffc46b;
  --bg: #f6f1ff; --panel: #ffffff; --panel2: #fbf9ff; --text: #2b2442; --muted: #8b83a6; --line: #efe9fb;
  --chip: #f2ecff; --theirs: #ffffff; --theirs-text: #2b2442; --mine-text: #ffffff;
  --shadow: 0 6px 24px rgba(110, 80, 190, .10); --shadow-sm: 0 2px 8px rgba(110, 80, 190, .08);
  --danger: #ff5c7a; --ok: #2ecc9a; --read: #6be4ff;
  --r: 22px; --font: 'Rubik', 'Baloo Bhaijaan 2', system-ui, -apple-system, 'Segoe UI', Tahoma, sans-serif;
  --font-fun: 'Baloo Bhaijaan 2', 'Rubik', system-ui, sans-serif;
  --pat: #e9e0ff; --patfade: transparent;
  --sat: env(safe-area-inset-top); --sab: env(safe-area-inset-bottom);
  color-scheme: light;
}
:root[data-theme="rose"] { --a1: #ff7aa8; --a2: #ffb36b; --a3: #ffd86b; --bg: #fff3f6; --chip: #ffeaf1; --line: #fbe6ee; --pat: #ffe0ea; }
:root[data-theme="sky"] { --a1: #4fa3ff; --a2: #6be0d0; --a3: #b7a2ff; --bg: #f0f7ff; --chip: #e6f1ff; --line: #e3eefb; --pat: #d9ebff; }
:root[data-theme="mint"] { --a1: #2ec4a0; --a2: #9be15d; --a3: #ffd36b; --bg: #effbf6; --chip: #e2f7ee; --line: #dff3ea; --pat: #d3f2e5; }
:root[data-theme="sunset"] { --a1: #ff6b6b; --a2: #ffa94d; --a3: #ffd43b; --bg: #fff5ef; --chip: #ffece2; --line: #fbe7dc; --pat: #ffe2d2; }

@media (prefers-color-scheme: dark) {
  :root:not([data-mode="light"]) {
    --bg: #15121f; --panel: #1e1a2c; --panel2: #191625; --text: #f1ecff; --muted: #9c94b9; --line: #2b2640;
    --chip: #2a2440; --theirs: #29243d; --theirs-text: #f1ecff; --shadow: 0 6px 24px rgba(0,0,0,.35); --shadow-sm: 0 2px 8px rgba(0,0,0,.25);
    --pat: #221d33; --patfade: rgba(21,18,31,.6); color-scheme: dark;
  }
}
:root[data-mode="dark"] {
  --bg: #15121f; --panel: #1e1a2c; --panel2: #191625; --text: #f1ecff; --muted: #9c94b9; --line: #2b2640;
  --chip: #2a2440; --theirs: #29243d; --theirs-text: #f1ecff; --shadow: 0 6px 24px rgba(0,0,0,.35); --shadow-sm: 0 2px 8px rgba(0,0,0,.25);
  --pat: #221d33; --patfade: rgba(21,18,31,.6); color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 16px; overscroll-behavior: none; }
body { overflow: hidden; -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
input, textarea { font: inherit; color: inherit; }
svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.hidden { display: none !important; }
a { color: inherit; }
::selection { background: color-mix(in srgb, var(--a1) 30%, transparent); }

/* ── إيموجي ── */
.emo { width: 1.35em; height: 1.35em; vertical-align: -0.3em; margin: 0 .03em; object-fit: contain; display: inline-block; }
.emo-txt { font-size: 1.15em; line-height: 1; width: auto; height: auto; vertical-align: -0.1em; }
.emo-big { width: 72px; height: 72px; display: inline-block; object-fit: contain; }
.emo-big.emo-txt { font-size: 60px; width: auto; height: auto; line-height: 1.1; }
.jumbo-1 .emo-big { width: 120px; height: 120px; } .jumbo-1 .emo-big.emo-txt { font-size: 96px; }
.jumbo-2 .emo-big { width: 88px; height: 88px; }

.lot { display: inline-block; position: relative; vertical-align: middle; }
.lot > svg { width: 100% !important; height: 100% !important; display: block; }
.lot .lot-ph { width: 100%; height: 100%; display: block; }
.emo.lot { vertical-align: -0.3em; }
.emo-big-s { width: 72px; height: 72px; }

/* ── البداية ── */
.splash { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); z-index: 100; transition: opacity .4s; }
.splash.fade { opacity: 0; pointer-events: none; }
.splash-logo { font-size: 72px; animation: bob 1.4s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-10px) scale(1.06); } }

/* ── الدخول ── */
.auth { position: fixed; inset: 0; display: grid; place-items: center; padding: 20px; overflow: auto;
  background: radial-gradient(1200px 600px at 100% -10%, color-mix(in srgb, var(--a2) 28%, transparent), transparent 60%),
              radial-gradient(900px 600px at -10% 110%, color-mix(in srgb, var(--a1) 30%, transparent), transparent 60%), var(--bg); }
.auth-bg span { position: fixed; font-size: 34px; opacity: .5; animation: floaty 9s ease-in-out infinite; pointer-events: none; }
.auth-bg span:nth-child(1) { top: 10%; left: 8%; } .auth-bg span:nth-child(2) { top: 18%; right: 10%; animation-delay: -2s; }
.auth-bg span:nth-child(3) { bottom: 16%; left: 12%; animation-delay: -4s; } .auth-bg span:nth-child(4) { bottom: 10%; right: 14%; animation-delay: -6s; }
.auth-bg span:nth-child(5) { top: 48%; left: 4%; animation-delay: -3s; } .auth-bg span:nth-child(6) { top: 55%; right: 5%; animation-delay: -5s; }
@keyframes floaty { 50% { transform: translateY(-22px) rotate(10deg); } }
.auth-card { width: 100%; max-width: 400px; background: color-mix(in srgb, var(--panel) 88%, transparent); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  border-radius: 32px; padding: 28px 24px 22px; box-shadow: var(--shadow); position: relative; animation: pop .5s cubic-bezier(.2,1.4,.4,1); }
@keyframes pop { from { transform: scale(.9) translateY(20px); opacity: 0; } }
.auth-logo { width: 104px; height: 104px; margin: -70px auto 6px; border-radius: 34px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--a1), var(--a2)); box-shadow: 0 12px 30px color-mix(in srgb, var(--a1) 45%, transparent); transform: rotate(-6deg); }
.auth-logo .emo-big { width: 76px; height: 76px; transform: rotate(6deg); }
.auth-title { font-family: var(--font-fun); text-align: center; margin: 6px 0 0; font-size: 30px; font-weight: 800;
  background: linear-gradient(90deg, var(--a1), var(--a2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.auth-sub { text-align: center; color: var(--muted); margin: 2px 0 18px; }
.tabs { display: flex; background: var(--chip); border-radius: 16px; padding: 4px; margin-bottom: 16px; }
.tab { flex: 1; padding: 10px; border-radius: 12px; font-weight: 600; color: var(--muted); transition: .2s; }
.tab.active { background: var(--panel); color: var(--text); box-shadow: var(--shadow-sm); }
.form { display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); font-weight: 500; }
.field input, .field textarea, .inp { background: var(--panel2); border: 2px solid var(--line); border-radius: 16px; padding: 13px 14px; font-size: 16px; outline: none; transition: .2s; color: var(--text); width: 100%; }
.field input:focus, .inp:focus { border-color: var(--a1); box-shadow: 0 0 0 4px color-mix(in srgb, var(--a1) 15%, transparent); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 11px 18px; border-radius: 16px; font-weight: 600; transition: transform .15s, filter .2s; }
.btn:active { transform: scale(.97); }
.btn.big { padding: 14px 18px; font-size: 17px; }
.btn.primary { background: linear-gradient(135deg, var(--a1), var(--a2)); color: #fff; box-shadow: 0 8px 20px color-mix(in srgb, var(--a1) 35%, transparent); }
.btn.soft { background: var(--chip); color: var(--text); }
.btn.danger { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
.btn.sm { padding: 7px 12px; font-size: 14px; border-radius: 12px; }
.btn[disabled] { opacity: .6; pointer-events: none; }
.bio-ico { font-size: 20px; }
.or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.or::before, .or::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.auth-err { color: var(--danger); text-align: center; min-height: 1.2em; margin: 12px 0 0; font-weight: 500; }

/* ── التخطيط ── */
.app { position: fixed; inset: 0; display: grid; grid-template-columns: 380px 1fr; height: 100dvh; }
.sidebar { background: var(--panel); border-inline-end: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; padding-top: var(--sat); }
.chat { position: relative; min-width: 0; min-height: 0; display: flex; flex-direction: column; background: var(--bg); }
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .chat { position: fixed; inset: 0; z-index: 5; transform: translateX(-100%); transition: transform .32s cubic-bezier(.3,.9,.3,1); box-shadow: var(--shadow); visibility: hidden; }
  body.in-chat .chat { transform: none; visibility: visible; }
  body.in-chat .sidebar { transform: translateX(22%); }
  .sidebar { transition: transform .32s cubic-bezier(.3,.9,.3,1); }
  .chat-empty { display: none !important; }
}
@media (min-width: 861px) { .back { display: none !important; } }

/* ── القائمة الجانبية ── */
.side-head { display: flex; align-items: center; gap: 12px; padding: 14px 16px 8px; }
.side-title { flex: 1; min-width: 0; }
.side-title h2 { margin: 0; font-family: var(--font-fun); font-size: 25px; font-weight: 800; line-height: 1.2; }
.conn { color: var(--muted); font-size: 12px; display: block; height: 16px; }
.conn.bad { color: var(--danger); }
.icon-btn { width: 42px; height: 42px; border-radius: 14px; display: inline-grid; place-items: center; color: var(--text); transition: background .2s, transform .15s; flex: none; }
.icon-btn:hover { background: var(--chip); }
.icon-btn:active { transform: scale(.92); }
.icon-btn.sm { width: 32px; height: 32px; }
.icon-btn.sm svg { width: 18px; height: 18px; }
.icon-btn.light { color: #fff; background: rgba(255,255,255,.12); }
.icon-btn.danger { color: var(--danger); }
#newChatBtn { background: linear-gradient(135deg, var(--a1), var(--a2)); color: #fff; box-shadow: 0 6px 16px color-mix(in srgb, var(--a1) 35%, transparent); }
.me-btn { width: 44px; height: 44px; border-radius: 50%; flex: none; }
.search { margin: 6px 16px 8px; display: flex; align-items: center; gap: 8px; background: var(--chip); border-radius: 16px; padding: 0 12px; color: var(--muted); }
.search svg { width: 18px; height: 18px; }
.search input { flex: 1; border: 0; background: none; outline: none; padding: 11px 0; font-size: 15px; min-width: 0; }
.online-strip { display: flex; gap: 14px; overflow-x: auto; padding: 6px 16px 10px; scrollbar-width: none; }
.online-strip::-webkit-scrollbar { display: none; }
.online-strip:empty { display: none; }
.ostory { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 58px; flex: none; font-size: 12px; color: var(--muted); }
.ostory .avatar { width: 54px; height: 54px; font-size: 28px; }
.ostory span.n { max-width: 58px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-list { list-style: none; margin: 0; padding: 0 8px calc(12px + var(--sab)); overflow-y: auto; flex: 1; }
.chat-item { display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: 18px; cursor: pointer; transition: background .15s; position: relative; animation: slideIn .3s both; }
@keyframes slideIn { from { opacity: 0; transform: translateY(6px); } }
.chat-item:hover { background: var(--panel2); }
.chat-item.active { background: var(--chip); }
.ci-body { flex: 1; min-width: 0; }
.ci-top, .ci-bot { display: flex; align-items: center; gap: 6px; }
.ci-name { flex: 1; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 16px; }
.ci-time { font-size: 12px; color: var(--muted); flex: none; }
.ci-last { flex: 1; font-size: 14px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.ci-last .emo { width: 1.2em; height: 1.2em; }
.ci-last.typing { color: var(--a1); font-weight: 500; }
.unread { background: linear-gradient(135deg, var(--a1), var(--a2)); color: #fff; min-width: 22px; height: 22px; border-radius: 11px; font-size: 12px; font-weight: 700; display: grid; place-items: center; padding: 0 6px; animation: pop .3s; }
.chat-item.unread-row .ci-time { color: var(--a1); font-weight: 600; }
.muted-ico { font-size: 12px; opacity: .6; }

/* ── الأفاتار ── */
.avatar { width: 50px; height: 50px; border-radius: 50%; display: grid; place-items: center; font-size: 27px; flex: none; position: relative;
  background: radial-gradient(circle at 30% 25%, rgba(255,255,255,.55), transparent 60%), var(--c, var(--a1)); box-shadow: inset 0 -3px 0 rgba(0,0,0,.06); }
.avatar .emo { width: 62%; height: 62%; margin: 0; vertical-align: 0; }
.avatar .emo-txt { font-size: 1em; }
.avatar.sm { width: 32px; height: 32px; font-size: 17px; }
.avatar.xs { width: 26px; height: 26px; font-size: 14px; }
.avatar.xl { width: 110px; height: 110px; font-size: 60px; }
.avatar.online::after { content: ''; position: absolute; bottom: 1px; left: 1px; width: 13px; height: 13px; border-radius: 50%; background: var(--ok); border: 3px solid var(--panel); }
.avatar.sm.online::after { width: 10px; height: 10px; border-width: 2px; }

/* ── بطاقة الإشعارات ── */
.notif-card { margin: 0 16px 10px; padding: 14px; border-radius: 20px; display: flex; gap: 12px; align-items: center;
  background: linear-gradient(135deg, color-mix(in srgb, var(--a1) 16%, var(--panel)), color-mix(in srgb, var(--a2) 16%, var(--panel))); }
.notif-card .ico { font-size: 30px; }
.notif-card .t { flex: 1; font-size: 14px; line-height: 1.5; }
.notif-card .t b { display: block; font-size: 15px; }

/* ── المحادثة ── */
.chat-empty { flex: 1; display: grid; place-content: center; text-align: center; color: var(--muted); padding: 20px; }
.chat-empty h3 { color: var(--text); font-family: var(--font-fun); font-size: 22px; margin: 10px 0 4px; }
.empty-emoji .emo-big { width: 130px; height: 130px; }
.chat-inner { flex: 1; display: flex; flex-direction: column; min-height: 0; position: relative; }
.chat-head { display: flex; align-items: center; gap: 4px; padding: calc(8px + var(--sat)) 8px 8px; background: color-mix(in srgb, var(--panel) 85%, transparent);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-bottom: 1px solid var(--line); z-index: 2; }
.chat-peer { flex: 1; display: flex; align-items: center; gap: 10px; min-width: 0; text-align: start; padding: 4px; border-radius: 14px; }
.chat-peer .avatar { width: 42px; height: 42px; font-size: 23px; }
.peer-text { display: flex; flex-direction: column; min-width: 0; }
.peer-text b { font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.peer-text small { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.peer-text small.on { color: var(--ok); }
.peer-text small.typing { color: var(--a1); }

.messages { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 10px 12px 6px; position: relative; overscroll-behavior: contain; background-color: var(--bg);
  background-image: linear-gradient(var(--patfade), var(--patfade)), url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160' viewBox='0 0 160 160'%3E%3Cg fill='none' stroke='%239b7bff' stroke-opacity='.12' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M30 38c-4-6-14-4-13 4 1 6 13 12 13 12s12-6 13-12c1-8-9-10-13-4z'/%3E%3Cpath d='M118 30l3 7 7 1-5 5 1 7-6-3-6 3 1-7-5-5 7-1z'/%3E%3Ccircle cx='128' cy='118' r='9'/%3E%3Cpath d='M40 120q8-10 16 0t16 0'/%3E%3Cpath d='M86 80a8 8 0 1 0 8 8'/%3E%3C/g%3E%3C/svg%3E");
  background-size: 180px; }
.msg-list { display: flex; flex-direction: column; gap: 2px; max-width: 820px; margin: 0 auto; padding-bottom: 4px; }
.day-sep { align-self: center; margin: 12px 0 8px; padding: 5px 14px; border-radius: 12px; font-size: 12.5px; font-weight: 500;
  background: color-mix(in srgb, var(--panel) 85%, transparent); color: var(--muted); box-shadow: var(--shadow-sm); backdrop-filter: blur(8px); position: sticky; top: 4px; z-index: 1; }
.sys-msg { align-self: center; margin: 6px 0; padding: 5px 14px; border-radius: 12px; font-size: 13px; background: color-mix(in srgb, var(--a1) 12%, var(--panel)); color: var(--text); }
.load-more { align-self: center; margin: 8px; }

.row { display: flex; align-items: flex-end; gap: 6px; position: relative; }
.row.mine { flex-direction: row-reverse; }
.row.first { margin-top: 8px; }
.row .avatar.sm { visibility: hidden; margin-bottom: 2px; }
.row.last .avatar.sm { visibility: visible; }
.row.new { animation: msgIn .35s cubic-bezier(.2,1.3,.4,1) both; }
@keyframes msgIn { from { opacity: 0; transform: translateY(12px) scale(.94); } }
.row.mine.new { transform-origin: left bottom; } .row:not(.mine).new { transform-origin: right bottom; }
.row.flash .bubble { animation: flash 1.2s; }
@keyframes flash { 30% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--a3) 70%, transparent); } }

.bubble { max-width: min(78%, 560px); padding: 8px 12px 6px; border-radius: var(--r); position: relative; box-shadow: var(--shadow-sm); word-wrap: break-word; overflow-wrap: anywhere;
  background: var(--theirs); color: var(--theirs-text); line-height: 1.5; user-select: text; -webkit-user-select: text; -webkit-touch-callout: none; }
.row:not(.mine) .bubble { border-start-start-radius: 8px; }
.row:not(.mine):not(.first) .bubble { border-start-start-radius: 8px; border-end-start-radius: 8px; }
.row.mine .bubble { background: linear-gradient(135deg, var(--a1), var(--a2)); color: var(--mine-text); border-start-end-radius: 8px; }
.row.mine:not(.first) .bubble { border-end-end-radius: 8px; }
.row:not(.mine).first .bubble { border-start-start-radius: 8px; }
.sender { font-size: 13px; font-weight: 600; margin-bottom: 2px; font-family: var(--font-fun); }
.text { white-space: normal; font-size: 15.5px; }
.text a { text-decoration: underline; }
.meta { display: flex; align-items: center; justify-content: flex-end; gap: 3px; font-size: 11px; opacity: .72; margin-top: 1px; direction: ltr; user-select: none; }
.meta .edited { font-style: italic; }
.meta svg { width: 16px; height: 16px; stroke-width: 2.2; }
.meta .ticks.read { color: var(--read); opacity: 1; }
.row:not(.mine) .meta { opacity: .55; }
.pending .meta svg { animation: spin 1.5s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.bubble.deleted { font-style: italic; opacity: .7; }

.bubble.jumbo { background: none !important; box-shadow: none; padding: 0; }
.bubble.jumbo .meta { background: color-mix(in srgb, var(--panel) 80%, transparent); color: var(--text); border-radius: 10px; padding: 2px 6px; width: max-content; margin-inline-start: auto; }
.row.mine .bubble.jumbo .meta .ticks.read { color: var(--a1); }
.jumbo-emojis { display: flex; gap: 4px; }
.jumbo-emojis .emo-big { animation: jumboIn .5s cubic-bezier(.2,1.6,.4,1); }
@keyframes jumboIn { from { transform: scale(.3) rotate(-15deg); opacity: 0; } }

.reply-q { display: block; border-inline-start: 3px solid var(--a1); background: rgba(127,100,220,.1); border-radius: 10px; padding: 5px 8px; margin: 2px 0 5px; font-size: 13px; cursor: pointer; text-align: start; width: 100%; }
.row.mine .reply-q { border-color: #fff; background: rgba(255,255,255,.2); }
.reply-q b { display: block; font-size: 12.5px; }
.reply-q span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: .85; }

.media { display: block; margin: -4px -8px 4px; border-radius: 16px; overflow: hidden; background: rgba(0,0,0,.06); position: relative; cursor: zoom-in; }
.media img, .media video { display: block; width: 100%; height: 100%; max-height: 360px; object-fit: cover; min-width: 120px; }
.media video { cursor: auto; background: #000; object-fit: contain; }
.bubble.has-media { padding: 8px 8px 6px; }
.bubble.has-media .text { padding: 0 4px; }
.bubble.has-media .meta { padding: 0 4px; }
.bubble.media-only .media { margin-bottom: 0; }
.bubble.media-only .meta { position: absolute; bottom: 12px; left: 14px; background: rgba(0,0,0,.45); color: #fff; padding: 2px 7px; border-radius: 10px; opacity: 1; }

.file-card { display: flex; align-items: center; gap: 10px; padding: 6px 2px; text-decoration: none; min-width: 200px; }
.file-ico { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; background: rgba(127,100,220,.14); font-size: 22px; flex: none; }
.row.mine .file-ico { background: rgba(255,255,255,.22); }
.file-info { min-width: 0; flex: 1; }
.file-info b { display: block; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.file-info small { opacity: .75; font-size: 12px; }
.progress { height: 5px; border-radius: 3px; background: rgba(127,127,127,.25); overflow: hidden; margin-top: 6px; }
.progress i { display: block; height: 100%; width: 0; background: currentColor; transition: width .2s; }

.voice { display: flex; align-items: center; gap: 10px; min-width: 210px; padding: 4px 0; }
.vplay { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: linear-gradient(135deg, var(--a1), var(--a2)); color: #fff; flex: none; }
.row.mine .vplay { background: #fff; color: var(--a1); }
.vplay svg { width: 20px; height: 20px; fill: currentColor; stroke: none; }
.vbars { flex: 1; display: flex; align-items: center; gap: 2px; height: 30px; cursor: pointer; direction: ltr; }
.vbars i { flex: 1; min-width: 2px; border-radius: 2px; background: currentColor; opacity: .35; transition: opacity .1s; }
.vbars i.on { opacity: 1; }
.vtime { font-size: 12px; opacity: .8; min-width: 32px; }

.call-log { display: flex; align-items: center; gap: 10px; padding: 4px 2px; min-width: 170px; }
.call-log .cl-ico { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: rgba(127,100,220,.14); font-size: 18px; }
.row.mine .call-log .cl-ico { background: rgba(255,255,255,.22); }
.call-log small { display: block; opacity: .8; font-size: 12px; }
.call-log.missed b { color: var(--danger); }
.row.mine .call-log.missed b { color: #fff; }

.reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: -8px; margin-bottom: 4px; position: relative; z-index: 1; padding: 0 10px; }
.reactions.mine { justify-content: flex-end; }
.reactions:not(.mine) { padding-inline-start: 14px; }
.react-chip { display: inline-flex; align-items: center; gap: 3px; padding: 2px 8px 2px 6px; border-radius: 14px; background: var(--panel); box-shadow: var(--shadow-sm); font-size: 12.5px; border: 2px solid var(--bg); animation: pop .35s cubic-bezier(.2,1.6,.4,1); }
.react-chip.me { background: color-mix(in srgb, var(--a1) 18%, var(--panel)); }
.react-chip .emo { width: 20px; height: 20px; vertical-align: 0; }

.typing-row .bubble { padding: 12px 16px; }
.dots { display: inline-flex; gap: 4px; }
.dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); animation: dot 1.2s infinite; }
.dots i:nth-child(2) { animation-delay: .15s; } .dots i:nth-child(3) { animation-delay: .3s; }
@keyframes dot { 30% { transform: translateY(-5px); opacity: 1; } 0%, 60%, 100% { opacity: .4; } }

.swipe-ico { position: absolute; top: 50%; transform: translateY(-50%) scale(.5); opacity: 0; color: var(--a1); transition: .15s; }

.scroll-down { position: absolute; bottom: calc(86px + var(--sab)); left: 16px; width: 44px; height: 44px; border-radius: 50%; background: var(--panel); box-shadow: var(--shadow); display: grid; place-items: center; z-index: 3; animation: pop .25s; }
.scroll-down span:not(:empty) { position: absolute; top: -6px; right: -4px; background: linear-gradient(135deg, var(--a1), var(--a2)); color: #fff; border-radius: 10px; font-size: 11px; padding: 1px 6px; font-weight: 700; }

/* ── الكتابة ── */
.composer { padding: 8px 10px calc(8px + var(--sab)); background: color-mix(in srgb, var(--panel) 88%, transparent); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-top: 1px solid var(--line); z-index: 2; }
.compose-row, .rec-row { display: flex; align-items: flex-end; gap: 6px; max-width: 820px; margin: 0 auto; }
.input-wrap { flex: 1; display: flex; align-items: flex-end; background: var(--panel2); border: 2px solid var(--line); border-radius: 24px; padding-inline-start: 14px; transition: border-color .2s; min-width: 0; }
.input-wrap:focus-within { border-color: color-mix(in srgb, var(--a1) 55%, transparent); }
#input { flex: 1; border: 0; outline: none; background: none; resize: none; padding: 10px 0; max-height: 140px; line-height: 1.45; font-size: 16px; min-width: 0; }
.emoji-toggle { width: 40px; height: 40px; color: var(--muted); }
.emoji-toggle.on { color: var(--a1); }
.send-btn { width: 46px; height: 46px; border-radius: 50%; flex: none; display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, var(--a1), var(--a2)); box-shadow: 0 6px 16px color-mix(in srgb, var(--a1) 35%, transparent); transition: transform .2s; }
.send-btn:active { transform: scale(.9); }
.send-btn svg { position: absolute; transition: transform .25s cubic-bezier(.2,1.4,.4,1), opacity .2s; }
.send-btn .ico-send { transform: scale(.3) rotate(-45deg); opacity: 0; scale: -1 1; }
.send-btn.on .ico-send { transform: none; opacity: 1; }
.send-btn.on .ico-mic { transform: scale(.3); opacity: 0; }
.rec-row { align-items: center; }
.rec-info { flex: 1; display: flex; align-items: center; gap: 10px; background: var(--panel2); border-radius: 24px; padding: 10px 16px; min-width: 0; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); animation: blink 1s infinite; flex: none; }
@keyframes blink { 50% { opacity: .2; } }
.rec-wave { flex: 1; display: flex; align-items: center; gap: 2px; height: 24px; overflow: hidden; direction: ltr; justify-content: flex-end; }
.rec-wave i { width: 3px; border-radius: 2px; background: var(--a1); flex: none; }
.reply-bar { display: flex; align-items: center; gap: 8px; max-width: 820px; margin: 0 auto 8px; padding: 6px 10px; border-radius: 14px; background: var(--chip); border-inline-start: 4px solid var(--a1); animation: slideIn .2s; }
.reply-inner { flex: 1; min-width: 0; font-size: 13px; }
.reply-inner b { display: block; color: var(--a1); }
.reply-inner span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); }
.quick-emoji { display: flex; gap: 6px; max-width: 820px; margin: 0 auto 6px; overflow-x: auto; scrollbar-width: none; }
.quick-emoji::-webkit-scrollbar { display: none; }
.quick-emoji:empty { display: none; }
.qe { width: 44px; height: 44px; flex: none; border-radius: 14px; display: grid; place-items: center; background: var(--chip); transition: transform .15s; }
.qe:active { transform: scale(.85); }
.qe .emo { width: 32px; height: 32px; margin: 0; vertical-align: 0; }

.emoji-panel { max-width: 820px; margin: 8px auto 0; height: min(300px, 40dvh); display: flex; flex-direction: column; position: relative; }
.emoji-tabs { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--line); padding-bottom: 6px; }
.emoji-tabs::-webkit-scrollbar { display: none; }
.etab { width: 40px; height: 36px; border-radius: 12px; font-size: 20px; flex: none; opacity: .55; transition: .2s; }
.etab.active { opacity: 1; background: var(--chip); }
.emoji-grid { flex: 1; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 2px; padding: 8px 0; align-content: start; }
.eg { height: 44px; font-size: 28px; border-radius: 12px; display: grid; place-items: center; transition: transform .12s; line-height: 1; }
.eg:hover { background: var(--chip); transform: scale(1.15); }
.eg:active { transform: scale(.9); }
.eg .emo { width: 36px; height: 36px; margin: 0; vertical-align: 0; }
.emoji-grid.anim { grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); }
.emoji-grid.anim .eg { height: 64px; }
.emoji-grid.anim .eg .emo { width: 52px; height: 52px; }
.emoji-empty { grid-column: 1 / -1; text-align: center; color: var(--muted); padding: 30px; }
.emoji-preview { position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); background: var(--panel); border-radius: 28px; box-shadow: var(--shadow); padding: 10px; pointer-events: none; animation: pop .2s; }
.emoji-preview .emo-big { width: 110px; height: 110px; }

/* ── الأوراق والقوائم ── */
.sheet-wrap, .menu-wrap { position: fixed; inset: 0; z-index: 30; background: rgba(20,12,40,.38); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); display: flex; align-items: flex-end; justify-content: center; animation: fadeIn .2s; }
@keyframes fadeIn { from { opacity: 0; } }
.sheet { width: 100%; max-width: 520px; max-height: 92dvh; background: var(--panel); border-radius: 30px 30px 0 0; overflow-y: auto; padding: 8px 18px calc(22px + var(--sab)); animation: sheetUp .35s cubic-bezier(.2,1.1,.3,1); overscroll-behavior: contain; }
@media (min-width: 700px) { .sheet-wrap { align-items: center; } .sheet { border-radius: 30px; max-height: 86dvh; } }
@keyframes sheetUp { from { transform: translateY(40%); opacity: 0; } }
.sheet-handle { width: 42px; height: 5px; border-radius: 3px; background: var(--line); margin: 4px auto 10px; }
.sheet h3 { font-family: var(--font-fun); font-size: 22px; margin: 4px 0 14px; display: flex; align-items: center; gap: 8px; }
.sheet h3 .x { margin-inline-start: auto; }
.sec { background: var(--panel2); border: 1px solid var(--line); border-radius: 22px; padding: 14px; margin-bottom: 12px; }
.sec-title { font-weight: 600; font-size: 14px; color: var(--muted); margin: 0 0 10px; display: flex; align-items: center; gap: 6px; }
.row-line { display: flex; align-items: center; gap: 10px; padding: 8px 0; }
.row-line + .row-line { border-top: 1px solid var(--line); }
.row-line .grow { flex: 1; min-width: 0; }
.row-line small { color: var(--muted); display: block; font-size: 12.5px; }
.profile-top { display: flex; flex-direction: column; align-items: center; gap: 8px; margin: 4px 0 16px; text-align: center; }
.profile-top .avatar.xl { cursor: pointer; transition: transform .2s; }
.profile-top .avatar.xl:active { transform: scale(.95); }
.profile-top h2 { margin: 4px 0 0; font-family: var(--font-fun); }
.profile-top p { margin: 0; color: var(--muted); }
.swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.sw { width: 38px; height: 38px; border-radius: 50%; border: 3px solid transparent; box-shadow: var(--shadow-sm); transition: transform .15s; }
.sw.on { border-color: var(--text); transform: scale(1.1); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 8px 14px; border-radius: 14px; background: var(--chip); font-weight: 500; font-size: 14px; border: 2px solid transparent; }
.chip.on { border-color: var(--a1); background: color-mix(in srgb, var(--a1) 14%, var(--panel)); }
.avatar-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(48px, 1fr)); gap: 6px; max-height: 220px; overflow-y: auto; }
.avatar-grid button { height: 48px; font-size: 28px; border-radius: 14px; }
.avatar-grid button.on { background: var(--chip); outline: 2px solid var(--a1); }
.big-code { font-size: 34px; letter-spacing: 8px; font-weight: 800; text-align: center; font-family: ui-monospace, monospace; direction: ltr; padding: 6px; background: linear-gradient(90deg, var(--a1), var(--a2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.pick-list { list-style: none; margin: 0; padding: 0; }
.pick { display: flex; align-items: center; gap: 12px; padding: 10px 6px; border-radius: 16px; cursor: pointer; }
.pick:hover { background: var(--chip); }
.pick .grow { flex: 1; min-width: 0; }
.pick small { color: var(--muted); display: block; }
.check { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; transition: .2s; }
.pick.on .check { background: linear-gradient(135deg, var(--a1), var(--a2)); border-color: transparent; }
.pick.on .check::after { content: '✓'; color: #fff; font-size: 14px; font-weight: 700; }
.toggle { width: 50px; height: 30px; border-radius: 15px; background: var(--line); position: relative; transition: .2s; flex: none; }
.toggle::after { content: ''; position: absolute; top: 3px; right: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.2); transition: .25s cubic-bezier(.3,1.4,.5,1); }
.toggle.on { background: linear-gradient(135deg, var(--a1), var(--a2)); }
.toggle.on::after { right: 23px; }
.media-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.media-grid a, .media-grid button { aspect-ratio: 1; border-radius: 12px; overflow: hidden; background: var(--chip); display: grid; place-items: center; font-size: 26px; }
.media-grid img { width: 100%; height: 100%; object-fit: cover; }
.hint { font-size: 13px; color: var(--muted); line-height: 1.6; }
.steps { margin: 0; padding-inline-start: 22px; line-height: 1.9; }
.attach-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.attach-grid button { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 6px; border-radius: 20px; background: var(--panel2); font-size: 14px; font-weight: 500; }
.attach-grid .ai { width: 56px; height: 56px; border-radius: 18px; display: grid; place-items: center; font-size: 28px; color: #fff; }

.msg-menu { width: min(340px, calc(100% - 24px)); display: flex; flex-direction: column; gap: 8px; position: fixed; animation: pop .25s cubic-bezier(.2,1.4,.4,1); }
.menu-wrap { align-items: stretch; background: rgba(20,12,40,.25); }
.react-bar { display: flex; justify-content: space-between; background: var(--panel); border-radius: 30px; padding: 6px 8px; box-shadow: var(--shadow); }
.react-bar button { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; transition: transform .15s; }
.react-bar button:hover { transform: scale(1.25) translateY(-4px); }
.react-bar button.on { background: var(--chip); }
.react-bar .emo { width: 36px; height: 36px; margin: 0; vertical-align: 0; }
.react-bar .more { font-size: 22px; color: var(--muted); background: var(--chip); }
.menu-actions { background: var(--panel); border-radius: 20px; box-shadow: var(--shadow); overflow: hidden; }
.menu-actions button { display: flex; align-items: center; gap: 12px; width: 100%; padding: 13px 16px; font-size: 15.5px; text-align: start; }
.menu-actions button + button { border-top: 1px solid var(--line); }
.menu-actions button:hover { background: var(--panel2); }
.menu-actions button.danger { color: var(--danger); }
.menu-actions svg { width: 20px; height: 20px; }

/* ── الصور ── */
.lightbox { position: fixed; inset: 0; z-index: 40; background: rgba(8,4,18,.94); display: grid; place-items: center; animation: fadeIn .2s; }
.lightbox img { max-width: 100%; max-height: 100dvh; object-fit: contain; animation: pop .25s; touch-action: pinch-zoom; }
.lb-top { position: absolute; top: calc(10px + var(--sat)); left: 10px; right: 10px; display: flex; justify-content: space-between; z-index: 2; }

/* ── المكالمة ── */
.call { position: fixed; inset: 0; z-index: 50; color: #fff; background: #120d22; display: flex; flex-direction: column; overflow: hidden; }
.call-bg { position: absolute; inset: -20%; background: radial-gradient(closest-side at 30% 30%, color-mix(in srgb, var(--a1) 70%, transparent), transparent), radial-gradient(closest-side at 70% 70%, color-mix(in srgb, var(--a2) 60%, transparent), transparent); filter: blur(40px); animation: drift 12s ease-in-out infinite alternate; opacity: .8; }
@keyframes drift { to { transform: rotate(30deg) scale(1.2); } }
.call.has-video .call-bg, .call.has-video .call-center .call-avatar { display: none; }
.call.has-video .call-center { background: linear-gradient(rgba(0,0,0,.45), transparent); padding-bottom: 40px; }
#remoteVideo { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: none; background: #000; }
.call.has-video #remoteVideo { display: block; }
#localVideo { position: absolute; width: 110px; height: 160px; object-fit: cover; border-radius: 20px; top: calc(20px + var(--sat)); left: 16px; box-shadow: 0 8px 30px rgba(0,0,0,.4); display: none; transform: scaleX(-1); z-index: 3; border: 2px solid rgba(255,255,255,.3); }
#localVideo.back { transform: none; }
.call.local-video #localVideo { display: block; }
.call-center { position: relative; z-index: 2; text-align: center; padding: calc(60px + var(--sat)) 20px 20px; }
.call.has-video .call-center { padding-top: calc(24px + var(--sat)); }
.call-avatar { width: 130px; height: 130px; margin: 0 auto 18px; border-radius: 50%; display: grid; place-items: center; font-size: 70px; background: rgba(255,255,255,.18); position: relative; }
.call-avatar .emo { width: 88px; height: 88px; margin: 0; vertical-align: 0; }
.call-avatar::before, .call-avatar::after { content: ''; position: absolute; inset: -12px; border-radius: 50%; border: 2px solid rgba(255,255,255,.35); animation: ring 2s ease-out infinite; }
.call-avatar::after { animation-delay: 1s; }
.call.active .call-avatar::before, .call.active .call-avatar::after { animation-duration: 3.5s; opacity: .5; }
@keyframes ring { from { transform: scale(.9); opacity: 1; } to { transform: scale(1.5); opacity: 0; } }
.call-center h2 { margin: 0; font-family: var(--font-fun); font-size: 30px; text-shadow: 0 2px 10px rgba(0,0,0,.3); }
.call-center p { margin: 4px 0 0; opacity: .85; font-variant-numeric: tabular-nums; }
.call-controls { position: absolute; bottom: 0; left: 0; right: 0; z-index: 3; display: flex; justify-content: center; gap: 16px; padding: 24px 16px calc(34px + var(--sab)); background: linear-gradient(transparent, rgba(0,0,0,.45)); }
.cbtn { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 12px; color: #fff; }
.cbtn svg { width: 60px; height: 60px; padding: 17px; border-radius: 50%; background: rgba(255,255,255,.18); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); transition: .2s; box-sizing: border-box; }
.cbtn.off svg { background: #fff; color: #1b1330; }
.cbtn.end svg { background: var(--danger); }
.cbtn.accept svg { background: var(--ok); animation: shake 1.2s infinite; }
.cbtn.big svg { width: 74px; height: 74px; padding: 21px; }
.call-controls.incoming { gap: 90px; }
@keyframes shake { 0%, 50%, 100% { transform: rotate(0); } 10%, 30% { transform: rotate(-14deg); } 20%, 40% { transform: rotate(14deg); } }
.call:not(.video) #cFlip, .call:not(.video) #cCam { display: none; }

/* ── تنبيهات صغيرة ── */
.toast-wrap { position: fixed; top: calc(12px + var(--sat)); left: 0; right: 0; display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 60; pointer-events: none; }
.toast { background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 16px; box-shadow: var(--shadow); font-size: 14.5px; animation: toastIn .35s cubic-bezier(.2,1.4,.4,1); max-width: calc(100% - 32px); pointer-events: auto; }
.toast.out { opacity: 0; transform: translateY(-10px); transition: .3s; }
@keyframes toastIn { from { transform: translateY(-20px) scale(.9); opacity: 0; } }
.in-toast { display: flex; align-items: center; gap: 10px; background: var(--panel); color: var(--text); cursor: pointer; }
.in-toast .avatar { width: 36px; height: 36px; font-size: 20px; }

/* ── تأثيرات الإيموجي ── */
.burst-layer { position: fixed; inset: 0; pointer-events: none; z-index: 70; overflow: hidden; }
.burst-item { position: absolute; bottom: -60px; animation: burstUp linear forwards; opacity: 0; }
@keyframes burstUp {
  0% { transform: translate(0, 0) rotate(0) scale(.6); opacity: 0; }
  10% { opacity: 1; }
  100% { transform: translate(var(--drift), -110vh) rotate(var(--rot)) scale(1.2); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; } }
@media (hover: none) { .eg:hover { transform: none; background: none; } .react-bar button:hover { transform: none; } }
