/* ═════════════ الثيمات ═════════════
   لإضافة ثيم جديد: انسخ أي كتلة [data-theme="..."] وغيّر الألوان،
   ثم أضف اسمه في قائمة THEMES داخل js/app.js */
:root,
[data-theme="night"] {
  --bg: #0f172a; --surface: #1e293b; --surface2: #273449; --border: #334155;
  --text: #e2e8f0; --muted: #94a3b8; --primary: #6366f1; --primary-text: #fff;
  --bubble: #1e293b; --bubble-me: #4f46e5; --bubble-me-text: #fff; --danger: #ef4444;
  --admin: #fbbf24; --mod: #34d399;
}
[data-theme="light"] {
  --bg: #f1f5f9; --surface: #ffffff; --surface2: #e2e8f0; --border: #cbd5e1;
  --text: #0f172a; --muted: #64748b; --primary: #2563eb; --primary-text: #fff;
  --bubble: #ffffff; --bubble-me: #2563eb; --bubble-me-text: #fff; --danger: #dc2626;
  --admin: #b45309; --mod: #047857;
}
[data-theme="ocean"] {
  --bg: #042f3a; --surface: #0b4352; --surface2: #115565; --border: #17697b;
  --text: #e0f7fa; --muted: #8cc7d1; --primary: #06b6d4; --primary-text: #022c33;
  --bubble: #0b4352; --bubble-me: #0891b2; --bubble-me-text: #fff; --danger: #f87171;
  --admin: #fcd34d; --mod: #6ee7b7;
}
[data-theme="sunset"] {
  --bg: #2a1215; --surface: #3d1a1f; --surface2: #52232a; --border: #6b2e36;
  --text: #fde8e4; --muted: #d4a5a0; --primary: #f97316; --primary-text: #fff;
  --bubble: #3d1a1f; --bubble-me: #ea580c; --bubble-me-text: #fff; --danger: #f43f5e;
  --admin: #fde047; --mod: #86efac;
}
[data-theme="forest"] {
  --bg: #0c1f14; --surface: #14301f; --surface2: #1b3f29; --border: #255436;
  --text: #e3f5e8; --muted: #9dc5a8; --primary: #22c55e; --primary-text: #052e12;
  --bubble: #14301f; --bubble-me: #16a34a; --bubble-me-text: #fff; --danger: #f87171;
  --admin: #fcd34d; --mod: #5eead4;
}
[data-theme="purple"] {
  --bg: #1a0f2e; --surface: #2a1a47; --surface2: #36225a; --border: #4a2f78;
  --text: #f1e9ff; --muted: #b9a6dc; --primary: #c026d3; --primary-text: #fff;
  --bubble: #2a1a47; --bubble-me: #a21caf; --bubble-me-text: #fff; --danger: #fb7185;
  --admin: #fde047; --mod: #6ee7b7;
}
[data-theme="rose"] {
  --bg: #fff1f4; --surface: #ffffff; --surface2: #ffe4ea; --border: #fbc6d2;
  --text: #4a1020; --muted: #9f5b6c; --primary: #e11d48; --primary-text: #fff;
  --bubble: #ffffff; --bubble-me: #e11d48; --bubble-me-text: #fff; --danger: #b91c1c;
  --admin: #b45309; --mod: #047857;
}

/* ═════════════ الأساسيات ═════════════ */
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font-family: 'Readex Pro', 'Segoe UI', Tahoma, system-ui, sans-serif; font-size: 15px;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--danger); min-height: 1.4em; margin: 6px 0 0; font-size: 14px; }
.grow { flex: 1; }

input, select, textarea {
  width: 100%; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface2); outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); }
textarea { min-height: 90px; resize: vertical; direction: rtl; }
textarea.code { direction: ltr; font-family: ui-monospace, Consolas, monospace; font-size: 13px; }

.btn {
  padding: 9px 16px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface2); cursor: pointer; white-space: nowrap;
}
.btn:hover { filter: brightness(1.1); }
.btn.primary { background: var(--primary); color: var(--primary-text); border-color: transparent; font-weight: 600; }
.btn.danger { background: var(--danger); color: #fff; border-color: transparent; }
.btn.small { padding: 4px 10px; font-size: 13px; border-radius: 8px; }
.btn.block { width: 100%; }
.link { background: none; border: 0; color: var(--primary); cursor: pointer; padding: 6px; }
.icon-btn {
  min-width: 38px; height: 38px; border-radius: 10px; border: 0;
  background: transparent; cursor: pointer; font-size: 18px; display: inline-flex;
  align-items: center; justify-content: center; gap: 4px; padding: 0 8px;
}
.icon-btn:hover { background: var(--surface2); }
.icon-btn.pill { font-size: 14px; background: var(--surface2); }

/* ═════════════ الهيكل ═════════════ */
.app { height: 100vh; height: 100dvh; display: flex; flex-direction: column; }
.shell { flex: 1; min-height: 0; display: flex; }
.views { flex: 1; min-width: 0; min-height: 0; position: relative; }
.view { display: none; height: 100%; flex-direction: column; }
.view.active { display: flex; }

.ad { text-align: center; overflow: hidden; background: var(--surface); border-bottom: 1px solid var(--border); }
#adBottom { border-bottom: 0; border-top: 1px solid var(--border); }
.ad:empty { display: none; }
.ad img { max-width: 100%; height: auto; display: block; margin: 0 auto; }

.bar {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.bar .title { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.bar .title strong, .bar .title small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar .actions { display: flex; gap: 2px; }

/* ═════════════ صفحة الدخول ═════════════ */
#viewLogin { overflow-y: auto; }
.landing {
  position: relative; flex: 1 0 auto; display: flex; flex-direction: column; justify-content: flex-start; align-items: center;
  padding: 32px 16px 76px; isolation: isolate;
}
.landing-inner { margin-top: clamp(0px, 4vh, 40px); }
/* خلفية: دوائر ملوّنة ضبابية تتحرك ببطء، بألوان الثيم المختار */
.landing-bg { position: absolute; inset: 0; overflow: hidden; z-index: -1; pointer-events: none; }
.landing-bg span { position: absolute; border-radius: 50%; filter: blur(70px); opacity: .32; animation: drift 20s ease-in-out infinite; }
.landing-bg span:nth-child(1) { width: 360px; height: 360px; background: var(--primary); top: -90px; inset-inline-start: -80px; }
.landing-bg span:nth-child(2) { width: 300px; height: 300px; background: var(--bubble-me); bottom: 6%; inset-inline-end: -90px; animation-delay: -7s; }
.landing-bg span:nth-child(3) { width: 240px; height: 240px; background: var(--mod); top: 42%; inset-inline-start: 32%; opacity: .16; animation-delay: -14s; }
@keyframes drift { 50% { transform: translate(34px, -44px) scale(1.1); } }

.landing-inner { width: 100%; max-width: 440px; display: flex; flex-direction: column; gap: 18px; text-align: center; }
.logo-bubble {
  width: 78px; height: 78px; margin: 0 auto; border-radius: 26px; display: grid; place-items: center; font-size: 40px;
  background: linear-gradient(135deg, var(--primary), var(--bubble-me));
  box-shadow: 0 14px 34px color-mix(in srgb, var(--primary) 45%, transparent);
  animation: bob 4s ease-in-out infinite;
}
@keyframes bob { 50% { transform: translateY(-6px) rotate(-4deg); } }
.hero h1 { margin: 10px 0 4px; font-size: clamp(28px, 7vw, 40px); font-weight: 700; }
.tagline { margin: 0; color: var(--muted); font-size: 16px; }

.live-stats { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 14px; }
.stat {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 13px; border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 85%, transparent); border: 1px solid var(--border); font-size: 13px;
}
.stat b { font-size: 15px; }
.pulse { width: 9px; height: 9px; border-radius: 50%; background: #22c55e; animation: ping 1.8s infinite; }
@keyframes ping { 0% { box-shadow: 0 0 0 0 rgb(34 197 94 / .6); } 70%, 100% { box-shadow: 0 0 0 9px rgb(34 197 94 / 0); } }

.join-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 22px; padding: 22px 20px;
  display: flex; flex-direction: column; gap: 10px; text-align: start; box-shadow: 0 22px 50px rgb(0 0 0 / .22);
}
.join-card label { font-weight: 700; font-size: 15px; }
.nick-row { display: flex; gap: 8px; }
.nick-row input { font-size: 17px; padding: 13px 14px; }
.dice {
  flex: 0 0 52px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface2);
  font-size: 22px; cursor: pointer; transition: transform .3s;
}
.dice:hover { transform: rotate(-20deg) scale(1.06); }
.dice.roll { animation: roll .45s ease-out; }
@keyframes roll { from { transform: rotate(0); } to { transform: rotate(360deg); } }
.join-btn {
  padding: 14px; font-size: 17px; border-radius: 14px; transition: transform .15s, filter .15s;
  background: linear-gradient(135deg, var(--primary), var(--bubble-me));
  box-shadow: 0 10px 24px color-mix(in srgb, var(--primary) 38%, transparent);
}
.join-btn:hover { transform: translateY(-1px); }
.fine { margin: 0; font-size: 12px; color: var(--muted); text-align: center; }
.join-card .error { margin: 0; text-align: center; }
.join-card .error:empty { display: none; }

/* زر دخول الإدارة: صغير وهادئ في الزاوية السفلية */
.staff-btn {
  position: absolute; bottom: 16px; inset-inline-start: 16px; display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 13px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface);
  color: var(--muted); font-size: 12px; cursor: pointer; opacity: .85; transition: opacity .15s, color .15s;
}
.staff-btn:hover { opacity: 1; color: var(--text); }
@media (prefers-reduced-motion: reduce) {
  .landing-bg span, .logo-bubble, .pulse { animation: none; }
}

/* ═════════════ الغرف ═════════════ */
.lobby-body { flex: 1; overflow-y: auto; padding: 14px; max-width: 1000px; width: 100%; margin: 0 auto; }
.search { margin-bottom: 14px; }
.cat h2 { font-size: 16px; margin: 18px 4px 10px; color: var(--muted); }
.room-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }

.count { font-size: 13px; color: var(--muted); }

/* ═════════════ الدردشة ═════════════ */
.chat-body { flex: 1; min-height: 0; display: flex; position: relative; }
.messages { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.msg {
  max-width: min(78%, 560px); background: var(--bubble); border: 1px solid var(--border);
  padding: 6px 12px 8px; border-radius: 14px; border-top-right-radius: 4px; align-self: flex-start;
  word-wrap: break-word; overflow-wrap: anywhere;
}
.msg.me {
  align-self: flex-end; background: var(--bubble-me); color: var(--bubble-me-text);
  border-color: transparent; border-top-right-radius: 14px; border-top-left-radius: 4px;
}
.msg.me .meta, .msg.me .meta time { color: inherit; opacity: .85; }
.msg.system {
  align-self: center; background: transparent; border: 0; color: var(--muted);
  font-size: 13px; padding: 0; max-width: 90%; text-align: center;
}
.msg.welcome { background: var(--surface2); padding: 8px 14px; border-radius: 10px; color: var(--text); }
.meta { display: flex; align-items: center; gap: 8px; font-size: 12px; margin-bottom: 2px; }
.nick { font-weight: 700; }
.role-admin .nick { color: var(--admin); }
.role-moderator .nick { color: var(--mod); }
.msg.me .nick { color: inherit; }
.meta time { color: var(--muted); margin-inline-start: auto; }
.del:hover { opacity: 1; color: var(--danger); }
.voice { display: flex; align-items: center; gap: 8px; }
.voice audio { height: 36px; max-width: 240px; }
.voice span { font-size: 12px; opacity: .8; }

.side-panel {
  width: 230px; flex-shrink: 0; background: var(--surface);
  overflow-y: auto; padding: 10px; display: flex; flex-direction: column;
}
.users-panel { width: 250px; border-inline-start: 1px solid var(--border); }
.side-panel h3 { font-size: 14px; color: var(--muted); margin: 4px 6px 10px; }

/* الإطارات الإعلانية الجانبية */
.ad-side { margin-top: auto; padding-top: 12px; background: none; border: 0; }

/* إطار "أعلن هنا" عندما تكون المساحة فارغة */
.ad-placeholder {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  border: 2px dashed var(--border); border-radius: 10px; color: var(--muted);
  min-height: 70px; max-width: 728px; margin: 6px auto; padding: 8px; font-weight: 600; font-size: 14px;
}
.ad-placeholder small { font-weight: 400; font-size: 12px; opacity: .8; }
.ad-side .ad-placeholder { min-height: 300px; margin: 0; }
.users-panel ul { list-style: none; margin: 0; padding: 0; }
.users-panel li {
  padding: 7px 10px; border-radius: 8px; display: flex; gap: 6px; align-items: center; cursor: default;
}
.users-panel li.away { opacity: .55; }
.users-panel li.clickable { cursor: pointer; }
.users-panel li.clickable:hover { background: var(--surface2); }
.users-panel li.role-admin { color: var(--admin); font-weight: 700; }
.users-panel li.role-moderator { color: var(--mod); font-weight: 600; }
.users-panel li.self::after { content: '(أنت)'; color: var(--muted); font-size: 12px; margin-inline-start: auto; }
.chat-body.hide-users .users-panel { display: none; }
@media (max-width: 1100px) and (min-width: 761px) {
  .users-panel { width: 210px; }
}

.composer {
  display: flex; gap: 8px; padding: 10px; background: var(--surface);
  border-top: 1px solid var(--border); padding-bottom: max(10px, env(safe-area-inset-bottom));
}
.rec-bar {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px;
  background: var(--surface2); border-top: 1px solid var(--border);
}
.rec-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--danger); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .3; } }
#micBtn.recording { background: var(--danger); }

/* ═════════════ النافذة المنبثقة ═════════════ */
.modal {
  position: fixed; inset: 0; background: rgb(0 0 0 / .55); z-index: 50;
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal-box {
  width: 100%; max-width: 440px; max-height: 92vh; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border); border-radius: 18px; overflow: hidden;
  animation: pop .18s ease-out;
}
.modal-box.wide { max-width: 900px; height: 92vh; }
@keyframes pop { from { transform: scale(.94); opacity: 0; } }
.modal-head { display: flex; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.modal-head h3 { flex: 1; margin: 0; font-size: 17px; }
.modal-body { padding: 14px; overflow-y: auto; flex: 1; }

.menu { display: flex; flex-direction: column; gap: 8px; }
.theme-grid{ display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.theme-opt{
  border: 2px solid var(--border); border-radius: 12px; padding: 12px; cursor: pointer;
  background: var(--surface2); text-align: center;
}
.theme-opt.active { border-color: var(--primary); }
.swatch { display: flex; height: 26px; border-radius: 6px; overflow: hidden; margin-bottom: 6px; }
.swatch i { flex: 1; }

.toast {
  position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 12px;
  opacity: 0; pointer-events: none; transition: .25s; z-index: 60; max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%); }

/* ═════════════ لوحة التحكم ═════════════ */
.tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 10px; margin-bottom: 12px; border-bottom: 1px solid var(--border); }
.tab { padding: 7px 14px; border-radius: 999px; border: 1px solid var(--border); background: none; cursor: pointer; white-space: nowrap; }
.tab.active { background: var(--primary); color: var(--primary-text); border-color: transparent; }
.panel { background: var(--surface2); border-radius: 12px; padding: 12px; margin-bottom: 14px; }
.panel h4 { margin: 0 0 10px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row > input, .row > select { flex: 1; min-width: 140px; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; font-size: 14px; }
.check { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; cursor: pointer; }
.check input { width: auto; }
.list-item {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 10px;
  background: var(--surface); margin-bottom: 6px; flex-wrap: wrap;
}
.list-item .grow { min-width: 120px; }
.list-item.sub { margin-inline-start: 26px; }
.tag { font-size: 12px; padding: 1px 8px; border-radius: 999px; background: var(--surface2); color: var(--muted); }
.tag.off { background: var(--danger); color: #fff; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 2px 10px; max-height: 220px; overflow-y: auto; }

/* ═════════════ التفاعلات والإشارات والرسائل المؤقتة ═════════════ */
.nick { cursor: pointer; }
.act, .del { background: none; border: 0; color: inherit; opacity: .35; cursor: pointer; padding: 0 3px; font-size: 13px; }
.msg:hover .act, .msg:hover .del { opacity: .9; }
.act:hover { opacity: 1; }
@media (hover: none) { .act, .del { opacity: .7; } }

.reactions { display: flex; flex-wrap: wrap; gap: 4px; }
.reactions:not(:empty) { margin-top: 6px; }
.chip {
  border: 1px solid var(--border); background: var(--surface2); color: var(--text); border-radius: 999px;
  padding: 1px 9px; font-size: 13px; cursor: pointer;
}
.chip.mine { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 25%, var(--surface2)); }
.picker {
  display: flex; gap: 2px; margin-top: 6px; padding: 4px; border-radius: 999px; width: max-content; max-width: 100%;
  background: var(--surface2); border: 1px solid var(--border); color: var(--text);
}
.picker button { background: none; border: 0; font-size: 20px; cursor: pointer; padding: 2px 5px; border-radius: 8px; }
.picker button:hover { background: var(--surface); }

.mention { color: var(--primary); font-weight: 700; background: color-mix(in srgb, var(--primary) 16%, transparent); border-radius: 4px; padding: 0 3px; }
.msg.me .mention { color: inherit; background: rgb(255 255 255 / .22); }
.mention.me { background: var(--admin); color: #000; }
.msg.mentioned { border-color: var(--admin); box-shadow: 0 0 0 1px var(--admin); }

.msg.ephemeral { border-style: dashed; }
.eph-note { font-size: 12px; opacity: .8; margin-top: 4px; }

.composer .input-wrap { flex: 1; position: relative; min-width: 0; }
.mention-box {
  position: absolute; bottom: calc(100% + 6px); inset-inline-start: 0; min-width: 180px; max-width: 100%;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden;
  box-shadow: 0 6px 24px rgb(0 0 0 / .35); z-index: 8;
}
.mention-opt { display: block; width: 100%; text-align: start; background: none; border: 0; padding: 9px 14px; cursor: pointer; }
.mention-opt:hover { background: var(--surface2); }
#ttlBtn.active { background: var(--primary); color: var(--primary-text); font-size: 13px; font-weight: 700; }

/* ═════════════ لوحة الإيموجي ═════════════ */
.composer { position: relative; }
#emojiBtn.active { background: var(--surface2); }
.emoji-panel {
  position: absolute; bottom: calc(100% + 6px); inset-inline-start: 10px; z-index: 9;
  width: min(352px, calc(100vw - 20px)); display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; overflow: hidden;
  box-shadow: 0 8px 28px rgb(0 0 0 / .4);
}
.emoji-tabs { display: flex; border-bottom: 1px solid var(--border); overflow-x: auto; }
.emoji-tabs button {
  flex: 1 0 auto; min-width: 44px; padding: 8px 6px; font-size: 18px; background: none; border: 0;
  border-bottom: 2px solid transparent; cursor: pointer;
}
.emoji-tabs button.active { border-bottom-color: var(--primary); background: var(--surface2); }
.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; padding: 8px; height: 224px; overflow-y: auto; align-content: start; }
.emoji-grid button { font-size: 22px; line-height: 1.2; padding: 4px 0; background: none; border: 0; border-radius: 8px; cursor: pointer; }
.emoji-grid button:hover { background: var(--surface2); }

/* ═════════════ عدادات فتح وإغلاق الغرف ═════════════ */
.cd { font-size: 11px; font-weight: 700; }
.cd-open { color: var(--mod); }
.cd-closed { color: var(--muted); }
.cd-soon { color: var(--danger); }
.rname { display: flex; flex-direction: column; line-height: 1.3; }
.sched-box { border: 1px dashed var(--border); border-radius: 10px; padding: 10px 12px; margin: 4px 0 10px; }

/* ═════════════ غرفة المراقبة (للمدير) ═════════════ */
#viewMonitor .bar .title small { display: flex; align-items: center; gap: 6px; }
.mon-body { flex: 1; min-height: 0; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 14px; }
.mon-kpis { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.mon-kpi {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 12px 14px;
  display: flex; flex-direction: column; gap: 2px;
}
.mon-kpi b { font-size: 26px; line-height: 1.2; }
.mon-kpi small { color: var(--muted); font-size: 12px; }
.mon-kpi-icon { font-size: 18px; }
.mon-kpi.live b { color: #22c55e; }
.mon-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(280px, 1fr); gap: 14px; align-items: start; }
.mon-panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 12px;
  display: flex; flex-direction: column; min-height: 0;
}
.mon-msgs { height: min(75vh, 760px); }
.mon-side { display: flex; flex-direction: column; gap: 14px; }
.mon-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.mon-head h3 { margin: 0; font-size: 15px; }
.mon-tools { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.mon-tools select { flex: 0 1 190px; }
.mon-tools input { flex: 1 1 160px; }
.mon-list { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.mon-msg { padding: 8px 10px; border-radius: 10px; background: var(--surface2); }
.mon-msg.eph { border: 1px dashed var(--border); }
.mon-msg.new, .mon-entry.new { animation: monFlash 1.6s ease-out; }
@keyframes monFlash { from { box-shadow: inset 0 0 0 2px var(--primary); background: color-mix(in srgb, var(--primary) 18%, var(--surface2)); } }
.mon-meta { display: flex; align-items: center; gap: 6px; font-size: 12px; flex-wrap: wrap; margin-bottom: 3px; }
.mon-meta time { color: var(--muted); }
.mon-nick { background: none; border: 0; padding: 0; font-weight: 700; cursor: pointer; color: var(--text); }
.mon-nick:hover { text-decoration: underline; }
.mon-nick.role-admin { color: var(--admin); }
.mon-nick.role-moderator { color: var(--mod); }
.mon-del { margin-inline-start: auto; background: none; border: 0; cursor: pointer; opacity: .55; font-size: 14px; }
.mon-del:hover { opacity: 1; }
.mon-text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; }
.mon-msg audio { height: 32px; max-width: 100%; }
.mon-tabs { display: flex; gap: 2px; background: var(--surface2); border-radius: 10px; padding: 3px; }
.mon-tabs button { border: 0; background: none; padding: 4px 9px; border-radius: 7px; font-size: 12px; cursor: pointer; color: var(--muted); }
.mon-tabs button.active { background: var(--primary); color: var(--primary-text); }
#monCountries { max-height: 340px; overflow-y: auto; }
.mon-country { display: grid; grid-template-columns: 26px minmax(0, 1fr) 64px auto 34px; align-items: center; gap: 8px; padding: 5px 2px; font-size: 14px; }
.mon-country .cname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mon-country small { text-align: end; }
.cbar { height: 6px; background: var(--surface2); border-radius: 3px; overflow: hidden; }
.cbar i { display: block; height: 100%; background: var(--primary); border-radius: 3px; }
.flag { font-size: 18px; text-align: center; }
.mon-note { font-size: 12px; margin: 8px 0 0; }
.mon-note a { color: var(--primary); }
.mon-entries { display: flex; flex-direction: column; gap: 4px; max-height: 340px; overflow-y: auto; }
.mon-entry { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 8px; font-size: 13px; }
.live-dot { font-size: 12px; color: #22c55e; font-weight: 700; }
@media (max-width: 900px) {
  .mon-grid { grid-template-columns: 1fr; }
  .mon-kpis { grid-template-columns: repeat(3, 1fr); }
  .mon-msgs { height: 60vh; }
}
@media (max-width: 480px) { .mon-kpis { grid-template-columns: repeat(2, 1fr); } }

/* ═════════════ الأصوات ═════════════ */
.sound-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
.snd-opt {
  border: 2px solid var(--border); border-radius: 12px; padding: 10px 6px; background: var(--surface2);
  color: var(--text); cursor: pointer; font-weight: 600;
}
.snd-opt:hover { filter: brightness(1.12); }
.snd-opt.active { border-color: var(--primary); }
input[type=range] { padding: 0; border: 0; background: none; accent-color: var(--primary); margin-top: 6px; }

/* ═════════════ طلبات الزوار ═════════════ */

.req-types { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.req-type {
  border: 2px solid var(--border); border-radius: 12px; padding: 10px 6px; background: var(--surface2);
  cursor: pointer; font-size: 13px; font-weight: 600;
}
.req-type b { display: block; font-size: 24px; }
.req-type.active { border-color: var(--primary); }
.req-item { background: var(--surface2); border-radius: 12px; padding: 10px 12px; margin-bottom: 10px; }
.req-body { margin: 6px 0; white-space: pre-wrap; font-size: 14px; }
.req-reply { margin-top: 8px; padding: 8px 10px; border-radius: 8px; background: var(--surface); border-inline-start: 3px solid var(--primary); white-space: pre-wrap; }
.status { font-size: 12px; padding: 2px 10px; border-radius: 999px; font-weight: 700; white-space: nowrap; }
.st-new { background: #3b82f6; color: #fff; }
.st-progress { background: #f59e0b; color: #000; }
.st-done { background: #22c55e; color: #fff; }
.st-rejected { background: #ef4444; color: #fff; }
.adminBtn, .repBtn { position: relative; }
.adminBtn[data-badge]::after, .repBtn[data-badge]::after {
  content: attr(data-badge); position: absolute; top: 0; inset-inline-end: 0;
  background: var(--danger); color: #fff; font-size: 11px; font-weight: 700;
  min-width: 18px; height: 18px; border-radius: 9px; display: flex; align-items: center; justify-content: center; padding: 0 4px;
}

/* ═════════════ الألعاب ═════════════ */
.game { text-align: center; }
.game .status { font-size: 17px; font-weight: 700; margin: 8px 0 12px; min-height: 1.5em; }
.xo { display: grid; grid-template-columns: repeat(3, 80px); gap: 6px; justify-content: center; direction: ltr; }
.xo button { height: 80px; font-size: 38px; font-weight: 700; border-radius: 12px; border: 0; background: var(--surface2); cursor: pointer; }
.game-actions { margin-top: 14px; display: flex; gap: 8px; justify-content: center; }

/* ═════════════ الهاتف ═════════════ */
@media (max-width: 760px) {
  .side-panel {
    position: absolute; inset-block: 0; width: 78%; max-width: 290px;
    z-index: 5; box-shadow: 0 0 30px rgb(0 0 0 / .4); display: none;
  }
  .users-panel { inset-inline-end: 0; }
  .chat-body.show-users .users-panel { display: flex; }
  .chat-body.hide-users .users-panel { display: none; }
  .ad-placeholder { min-height: 50px; }
  .ad-side .ad-placeholder { min-height: 160px; }
  .msg { max-width: 88%; }
  .bar .actions .icon-btn { min-width: 34px; padding: 0 6px; }
  .modal { padding: 0; align-items: flex-end; }
  .modal-box, .modal-box.wide { max-width: 100%; border-radius: 18px 18px 0 0; max-height: 94vh; }
  .modal-box.wide { height: 94vh; }
  .xo { grid-template-columns: repeat(3, 72px); }
  .xo button { height: 72px; }
}

/* ═════════════ القائمة الرئيسية ═════════════
   العنصر الحالي يأخذ شكل فقاعة رسالة (زاوية واحدة حادة)، وهو نفس شكل الشعار وبطاقة الدردشة العامة */
:root { --tail: 18px 18px 18px 5px; }
.rail, .tabbar { display: none; }
body:not([data-view="login"]) .rail {
  display: flex; flex-direction: column; gap: 4px; width: 210px; flex-shrink: 0; padding: 14px 10px;
  background: var(--surface); border-inline-end: 1px solid var(--border); overflow-y: auto; scrollbar-width: none;
}
.nav-item {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 8px 4px 7px; border: 0; border-radius: 14px; background: none; color: var(--muted);
  cursor: pointer; font-size: 11px; line-height: 1.25; text-align: center; transition: background .15s, color .15s;
}
.nav-item .ni { font-size: 21px; line-height: 1; }
.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item:focus-visible, .more-item:focus-visible, .shortcut:focus-visible, .game-card:focus-visible{
  outline: 2px solid var(--primary); outline-offset: 2px;
}
.rail .nav-item.active { background: var(--primary); color: var(--primary-text); border-radius: var(--tail); font-weight: 500; }
.nav-item[data-badge]::after {
  content: attr(data-badge); position: absolute; top: 3px; inset-inline-end: 10px; min-width: 18px; height: 18px;
  padding: 0 5px; border-radius: 9px; background: var(--danger); color: #fff; font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}

.rail-title { padding: 4px 14px 10px; font-size: 13px; font-weight: 700; color: var(--muted); }
/* شعار الموقع واسمه أعلى القائمة */
.rail-brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px 14px; margin-bottom: 6px; border-bottom: 1px solid var(--border); min-width: 0; }
.rail-brand b { font-size: 17px; font-weight: 700; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-brand .logo-bubble { width: 36px; height: 36px; margin: 0; flex: none; font-size: 18px; border-radius: 12px 12px 12px 4px; animation: none; box-shadow: none; }
.rail-brand .logo-img { width: 36px; height: 36px; flex: none; object-fit: contain; border-radius: 10px; }
/* شعار CHAT4PRO الافتراضي (رسم SVG من server/brand.js) */
.hero .logo-mark { display: block; width: 92px; height: 92px; margin: 0 auto; filter: drop-shadow(0 14px 28px rgb(240 178 74 / .28)); }
.rail-brand .logo-mark { width: 38px; height: 38px; flex: none; filter: none; }
.rail-logout .nl { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; }
#rail .nav-item { flex-direction: row; justify-content: flex-start; gap: 12px; padding: 11px 14px; font-size: 15px; text-align: start; color: var(--text); }
#rail .nav-item .ni { width: 26px; text-align: center; font-size: 20px; }
#rail .nav-item[data-badge]::after { position: static; margin-inline-start: auto; }

/* الهاتف: شريط سفلي بأزرار القائمة، ويظهر داخل الدردشة أيضاً */
@media (max-width: 760px) {
  body:not([data-view="login"]) .rail { display: none; }
  body:not([data-view="login"]):not([data-view="monitor"]) .tabbar {
    display: flex; background: var(--surface); border-top: 1px solid var(--border);
    padding: 4px 4px max(4px, env(safe-area-inset-bottom));
  }
  .tabbar .nav-item { flex: 1; min-width: 0; padding: 5px 2px 4px; border-radius: 12px; }
  .tabbar .nav-item:hover { background: none; }
  .tabbar .nav-item .ni { padding: 4px 14px; border-radius: 14px; transition: background .15s; }
  .tabbar .nav-item.active { color: var(--text); font-weight: 500; }
  .tabbar .nav-item.active .ni { background: var(--primary); border-radius: var(--tail); }
  .tabbar .nav-item[data-badge]::after { inset-inline-end: calc(50% - 26px); top: 0; }
  .bar .page-actions { display: none; }
  #viewChat .bar .soundBtn, #viewChat .bar .themeBtn { display: none; } /* موجودة في "المزيد" */
  body:not([data-view="login"]) .toast { bottom: 84px; }
}

/* ═════════════ الصفحات (الرئيسية، الأشخاص، الألعاب) ═════════════ */
.page { flex: 1; min-height: 0; overflow-y: auto; }
.page-inner { max-width: 880px; margin: 0 auto; padding: 18px 16px 32px; display: flex; flex-direction: column; gap: 22px; }
.page-note { margin: 0; font-size: 14px; line-height: 1.7; }
.block-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.block-head h3 { margin: 0; font-size: 17px; font-weight: 700; }
.home-block { display: flex; flex-direction: column; gap: 10px; }

.avatar {
  flex-shrink: 0; display: inline-grid; place-items: center; border-radius: 50%; font-weight: 700; color: #fff;
  background: hsl(var(--av) 52% 44%);
}
.avatar.preset { line-height: 1; font-weight: 400; box-shadow: inset 0 0 0 2px rgb(255 255 255 / .18); }

/* حالة الشخص: متاح (دائرة خضراء ممتلئة)، مشغول (نصف ممتلئة كهرمانية)، غائب (حلقة فارغة رمادية) */
.st { display: inline-block; flex-shrink: 0; width: 12px; height: 12px; border-radius: 50%; box-sizing: border-box; vertical-align: middle; }
.st-online { background: #22c55e; border: 2px solid #16a34a; }
.st-busy { border: 2px solid #f59e0b; background: linear-gradient(90deg, #f59e0b 50%, transparent 50%); }
.st-away { border: 2px solid #94a3b8; background: transparent; }
.st-off { border: 2px dashed #64748b; background: transparent; opacity: .7; }
.av-wrap > .st { position: absolute; bottom: -1px; inset-inline-end: -2px; box-shadow: 0 0 0 2px var(--surface); background-color: var(--surface); }
.av-wrap > .st-online { background: #22c55e; }
.av-wrap > .st-busy { background: linear-gradient(90deg, #f59e0b 50%, var(--surface) 50%); }
.av-wrap > .st.sm { width: 9px; height: 9px; border-width: 1.5px; }
.st-note { font-size: 11px; color: var(--muted); margin-inline-start: auto; white-space: nowrap; }
.users-panel li .ul-name { flex: 1; min-width: 0; }
.users-panel li.self::after { content: none; }
.av-pick { flex: 0 0 52px; height: 52px; padding: 0; border-radius: 12px; border: 1px solid var(--border); background: var(--surface2); cursor: pointer; display: grid; place-items: center; }
.av-pick:hover { border-color: var(--primary); }
.av-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 8px; justify-items: center; }
.av-opt { padding: 4px; border-radius: 50%; border: 2px solid transparent; background: none; cursor: pointer; }
.av-opt:hover { border-color: var(--border); }
.av-opt.on { border-color: var(--primary); }
.msg .meta .avatar { margin-inline-end: -2px; }

/* بطاقة الدردشة العامة: آخر ما قيل فيها الآن */
.home-general {
  background: var(--surface); border: 1px solid var(--border); border-radius: 26px 26px 26px 6px;
  padding: 18px; display: flex; flex-direction: column; gap: 14px;
}
.home-general h2 { margin: 0; font-size: clamp(22px, 4vw, 28px); font-weight: 700; }
.home-general.empty { align-items: flex-start; }
.home-general.empty p { margin: 0; }
.hg-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.hg-online { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 14px; margin-top: 4px; }
.hg-join { padding: 12px 22px; font-size: 16px; border-radius: 14px; }
.hg-feed { display: flex; flex-direction: column; gap: 8px; }
.hg-feed > .muted { margin: 0; }
.hg-msg { display: flex; align-items: flex-end; gap: 8px; }
.hg-bubble {
  background: var(--surface2); border-radius: 16px 16px 16px 4px; padding: 7px 12px; max-width: min(100%, 560px);
  display: flex; flex-direction: column; gap: 1px; overflow-wrap: anywhere; font-size: 14px;
}
.hg-bubble b { font-size: 12px; display: flex; gap: 8px; }
.hg-bubble time { color: var(--muted); font-weight: 400; }
.hg-msg.role-admin .hg-bubble b { color: var(--admin); }
.hg-msg.role-moderator .hg-bubble b { color: var(--mod); }

.home-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.shortcut {
  display: flex; flex-direction: column; align-items: flex-start; gap: 3px; text-align: start; padding: 14px;
  border: 1px solid var(--border); border-radius: 16px; background: var(--surface); cursor: pointer;
}
.shortcut:hover { background: var(--surface2); }
.shortcut small { font-size: 13px; }
.sc-icon { font-size: 26px; line-height: 1.2; }
.app-card {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 16px;
  border: 1px dashed var(--border); background: var(--surface);
}
.app-card .grow { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.app-card small { font-size: 13px; }

/* اكتشف الأشخاص */
.people-list { display: flex; flex-direction: column; }
.people-count { margin: 0 0 6px; font-size: 13px; }
.person { display: flex; align-items: center; gap: 12px; padding: 10px 4px; border-bottom: 1px solid var(--border); }
.person .grow { display: flex; flex-direction: column; min-width: 0; }
.person .grow b, .person .grow small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person.role-admin b { color: var(--admin); }
.person.role-moderator b { color: var(--mod); }
#peopleSearch { margin: 0; }

/* الألعاب */
.games-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.game-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px; text-align: start; padding: 16px;
  border: 1px solid var(--border); border-radius: 18px; background: var(--surface); cursor: pointer;
}
.game-card:hover { border-color: var(--primary); }
.game-card b { font-size: 16px; }
.game-card small { font-size: 13px; line-height: 1.6; flex: 1; }
.gc-icon { font-size: 32px; line-height: 1.3; }
.gc-icon.small { font-size: 24px; }
.gc-play {
  margin-top: 8px; padding: 5px 16px; border-radius: 12px 12px 12px 4px; background: var(--primary);
  color: var(--primary-text); font-weight: 500; font-size: 14px;
}

/* الأقسام قيد البناء */
.soon { max-width: 480px; margin: 24px auto 0; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.soon-icon {
  width: 92px; height: 92px; display: grid; place-items: center; font-size: 46px;
  background: var(--surface2); border-radius: 30px 30px 30px 8px;
}
.soon h2 { margin: 4px 0 0; font-size: 22px; }
.soon p { margin: 0; line-height: 1.9; color: var(--muted); }

/* "المزيد" */
.more { display: flex; flex-direction: column; gap: 14px; }
.more-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.more-grid .more-item {
  flex-direction: column; justify-content: center; text-align: center; gap: 4px; padding: 12px 4px;
  border-radius: 16px; background: var(--surface2); font-size: 13px;
}
.more-grid .more-item .ni { font-size: 24px; }
.more-list { display: flex; flex-direction: column; }
.more-item {
  position: relative; display: flex; align-items: center; gap: 12px; padding: 11px 8px; border: 0;
  border-radius: 12px; background: none; cursor: pointer; text-align: start;
}
.more-list .more-item .ni { font-size: 20px; width: 28px; text-align: center; }
.more-item:hover { background: var(--surface2); }
.soon-tag { font-size: 11px; color: var(--muted); }

/* ═════════════ الحسابات والملف الشخصي ═════════════ */
img.avatar { border-radius: 50%; object-fit: cover; flex-shrink: 0; background: var(--surface2); display: inline-block; }
.btn.loading { opacity: .6; pointer-events: none; }
.users-panel li { gap: 8px; }
.users-panel li .ul-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* بطاقة الشخص (نافذة منبثقة) */
.pcard { display: flex; flex-direction: column; gap: 12px; }
.pc-head { display: flex; align-items: center; gap: 14px; }
.pc-id { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pc-id h3 { margin: 0; font-size: 20px; overflow-wrap: anywhere; }
.pc-status { margin: 0; font-size: 14px; }
.pc-bio { margin: 0; line-height: 1.8; white-space: pre-wrap; overflow-wrap: anywhere; }
.pc-facts { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; color: var(--muted); }
.pc-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.pc-block { align-self: flex-start; color: var(--muted); font-size: 13px; padding: 0; }
.pc-block:hover { color: var(--danger); }

/* صفحة "ملفي" */
.pitch { max-width: 460px; margin: 10px auto 0; display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.pitch h2 { margin: 0; font-size: 22px; }
.pitch > p { margin: 0; line-height: 1.9; }
.pitch .join-card { width: 100%; }
.profile-page { display: flex; flex-direction: column; gap: 16px; }
.pp-head {
  display: grid; grid-template-columns: auto 1fr; gap: 14px 18px; align-items: center; padding: 18px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 26px 26px 26px 6px;
}
.pp-id { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.pp-id h2 { margin: 0; font-size: 24px; overflow-wrap: anywhere; }
.pp-stats { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pp-stats > * {
  display: flex; flex-direction: column; align-items: center; gap: 0; padding: 8px; border-radius: 14px;
  background: var(--surface2); border: 0; font-size: 13px; color: var(--muted);
}
.pp-stats button { cursor: pointer; }
.pp-stats button:hover { filter: brightness(1.1); }
.pp-stats b { font-size: 20px; color: var(--text); }
.pp-form .btn.primary { min-width: 120px; }
.person-btn, .person-open { width: 100%; background: none; border: 0; cursor: pointer; text-align: start; color: inherit; }
.person-open { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; padding: 0; }
.person-open .grow { display: flex; flex-direction: column; min-width: 0; }
.person-btn:hover, .person-open:hover b { color: var(--primary); }

/* ═════════════ الرسائل الخاصة: صفحة مراسلة كاملة ═════════════ */
.dm-body { flex: 1; min-height: 0; display: flex; }
.dm-page { flex: 1; min-width: 0; min-height: 0; display: grid; grid-template-columns: 350px minmax(0, 1fr); background: var(--bg); }
.dm-side { display: flex; flex-direction: column; min-height: 0; background: var(--surface); border-inline-end: 1px solid var(--border); }
.dm-side-head { display: flex; flex-direction: column; gap: 10px; padding: 16px 14px 10px; }
.dm-side-head h2 { margin: 0; font-size: 22px; }
.dm-search { width: 100%; padding: 10px 14px; border-radius: 12px; border: 1px solid transparent; background: var(--surface2); color: var(--text); font: inherit; font-size: 14px; }
.dm-search:focus { outline: none; border-color: var(--primary); }
.dm-threads { flex: 1; min-height: 0; overflow-y: auto; padding: 0 8px 12px; }
.dm-note { padding: 14px; margin: 0; font-size: 14px; }
.dm-thread {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px; margin-bottom: 2px; border: 0; border-radius: 14px;
  background: none; color: inherit; font: inherit; cursor: pointer; text-align: start;
}
.dm-thread:hover { background: var(--surface2); }
.dm-thread.active { background: color-mix(in srgb, var(--primary) 16%, var(--surface)); }
.av-wrap { position: relative; display: inline-flex; flex-shrink: 0; }
.dm-t-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.dm-t-main b, .dm-t-main small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dm-t-main small { color: var(--muted); font-size: 13px; }
.dm-thread.unread .dm-t-main small { color: var(--text); font-weight: 600; }
.dm-t-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; font-size: 11px; color: var(--muted); }
.dm-badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--primary); color: var(--primary-text); font-size: 11px; font-weight: 700; display: grid; place-items: center; }
.tag-temp { color: var(--muted); font-weight: 400; font-size: 11px; }

.dm-main { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.dm-empty { margin: auto; text-align: center; padding: 24px; display: flex; flex-direction: column; align-items: center; gap: 10px; max-width: 420px; }
.dm-empty h3 { margin: 0; }
.dm-head { display: flex; align-items: center; gap: 8px; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border); }
.dm-peer { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; background: none; border: 0; cursor: pointer; text-align: start; padding: 0; color: inherit; font: inherit; }
.dm-peer span:last-child { display: flex; flex-direction: column; min-width: 0; }
.dm-peer small { font-size: 12px; }
.dm-x { font-size: 24px; line-height: 1; }
.dm-temp-note { padding: 6px 14px 0; text-align: center; font-size: 12px; }
.dm-msgs { flex: 1; min-height: 0; overflow-y: auto; padding: 16px 20px; display: flex; flex-direction: column; gap: 8px; }
.dm-older { align-self: center; }
.dm-day { align-self: center; margin: 8px 0 4px; padding: 3px 14px; border-radius: 12px; background: var(--surface2); color: var(--muted); font-size: 12px; }
.dm-row { display: flex; align-items: flex-end; gap: 8px; max-width: min(82%, 600px); }
.dm-row.mine { align-self: flex-end; }
.dm-row.theirs { align-self: flex-start; }
.dm-msg {
  padding: 8px 14px 5px; border-radius: 18px; display: flex; flex-direction: column; gap: 2px; overflow-wrap: anywhere;
  background: var(--bubble); border: 1px solid var(--border); border-end-start-radius: 4px;
}
.dm-row.mine .dm-msg { background: var(--bubble-me); color: var(--bubble-me-text); border-color: transparent; border-end-start-radius: 18px; border-end-end-radius: 4px; }
.dm-msg.t-sticker, .dm-msg.t-image { background: none; border-color: transparent; padding: 0; }
.dm-row.mine .dm-msg.t-sticker, .dm-row.mine .dm-msg.t-image { color: var(--text); }
.dm-sticker { font-size: 56px; line-height: 1.15; }
.dm-img { max-width: min(300px, 100%); max-height: 340px; border-radius: 14px; cursor: zoom-in; display: block; }
.dm-text { white-space: pre-wrap; }
.dm-meta { font-size: 11px; opacity: .75; align-self: flex-end; }
.tick.read { color: #38bdf8; opacity: 1; }
.dm-row.mine .dm-msg:not(.t-sticker):not(.t-image) .tick.read { color: inherit; font-weight: 700; }
.dm-blocked { margin: 0; padding: 14px; text-align: center; color: var(--muted); background: var(--surface); border-top: 1px solid var(--border); }
.sticker-panel {
  position: absolute; bottom: calc(100% + 6px); inset-inline-start: 10px; z-index: 9; width: min(330px, calc(100vw - 20px));
  display: grid; grid-template-columns: repeat(6, 1fr); gap: 2px; padding: 8px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 8px 28px rgb(0 0 0 / .4);
}
.sticker-panel button { font-size: 28px; padding: 4px 0; background: none; border: 0; border-radius: 10px; cursor: pointer; }
.sticker-panel button:hover { background: var(--surface2); }
.dmBtn[data-badge]::after {
  content: attr(data-badge); position: absolute; top: 0; inset-inline-end: 0; background: var(--danger); color: #fff; font-size: 11px; font-weight: 700;
  min-width: 18px; height: 18px; border-radius: 9px; display: flex; align-items: center; justify-content: center; padding: 0 4px;
}

@media (max-width: 760px) {
  .dm-row { max-width: 90%; }
  .dm-msgs { padding: 12px; }
  .pp-head { grid-template-columns: 1fr; justify-items: center; text-align: center; }
  .pp-id .row { justify-content: center; }
}

/* ═════════════ الألعاب الجماعية ═════════════ */
.duel-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.duel-wait { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; padding: 8px 0; }
.duel-wait p { margin: 0; font-size: 17px; }
.duel-spinner { font-size: 40px; animation: bob 1.6s ease-in-out infinite; }
.duel { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.duel-players { display: flex; gap: 10px; width: 100%; justify-content: center; }
.duel-player {
  display: flex; align-items: center; gap: 8px; padding: 6px 12px 6px 8px; border-radius: 999px;
  background: var(--surface2); border: 2px solid transparent; font-weight: 500; min-width: 0;
}
.duel-player > span:nth-child(2) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 110px; }
.duel-player.turn { border-color: var(--primary); }
.mark { font-weight: 700; display: inline-flex; }
.m-X { color: #ef4444; }
.m-O { color: #3b82f6; }
.duel-status { font-size: 18px; font-weight: 700; min-height: 1.5em; color: var(--muted); }
.duel-status.mine { color: var(--text); }
.duel-status.over { color: var(--text); font-size: 20px; }
.duel-xo button { color: inherit; }
.duel-xo button.m-X { color: #ef4444; }
.duel-xo button.m-O { color: #3b82f6; }
.duel-xo button:disabled { cursor: default; }
.duel-xo button.win, .c4-cell.win { box-shadow: inset 0 0 0 3px var(--admin); }

/* أربعة في صف: 7 أعمدة × 6 صفوف، والأعمدة من اليسار لليمين كما في اللعبة المعروفة */
.c4 {
  direction: ltr; display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; padding: 8px;
  width: min(100%, 400px); background: #1d4ed8; border-radius: 16px;
}
.c4-cell { aspect-ratio: 1; border: 0; border-radius: 50%; background: var(--bg); padding: 0; display: grid; place-items: center; cursor: pointer; }
.c4-cell:disabled { cursor: default; }
.c4.my-turn .c4-cell:hover { background: color-mix(in srgb, var(--bg) 70%, #fff); }
.disc { display: block; width: 86%; height: 86%; border-radius: 50%; }
.duel-player .disc { width: 16px; height: 16px; }
.disc.red { background: radial-gradient(circle at 35% 35%, #f87171, #dc2626); }
.disc.yellow { background: radial-gradient(circle at 35% 35%, #fde047, #eab308); }

.duel-pill {
  position: fixed; z-index: 40; bottom: 92px; inset-inline-end: 16px; padding: 10px 16px; border: 0; cursor: pointer;
  border-radius: 18px 18px 18px 5px; background: var(--surface); color: var(--text); font-weight: 500;
  box-shadow: 0 8px 24px rgb(0 0 0 / .35); border: 1px solid var(--border);
}
.duel-pill.attention { background: var(--primary); color: var(--primary-text); animation: bob 1.4s ease-in-out infinite; }

/* رسائل المسابقة داخل الدردشة */
.msg.system.game { color: var(--text); font-weight: 500; }
@keyframes drain { to { transform: scaleX(0); } }
@media (max-width: 480px) { }
@media (prefers-reduced-motion: reduce) { .duel-pill.attention, .duel-spinner { animation: none; } }

/* ═════════════ الترتيب ═════════════ */
.rank-me {
  display: flex; align-items: center; gap: 12px; padding: 14px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 22px 22px 22px 6px;
}
.rank-me .grow { display: flex; flex-direction: column; min-width: 0; }
.rank-me-num { display: flex; flex-direction: column; align-items: center; min-width: 64px; }
.rank-me-num b { font-size: 22px; }
.rank-me-num small { font-size: 11px; color: var(--muted); text-align: center; }
.rank-tabs { display: flex; gap: 4px; padding: 4px; background: var(--surface2); border-radius: 14px; }
.rank-tabs button { flex: 1; border: 0; background: none; padding: 8px; border-radius: 10px; cursor: pointer; color: var(--muted); font-weight: 500; }
.rank-tabs button.active { background: var(--primary); color: var(--primary-text); }
.rank-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.rank-list li { display: flex; align-items: center; gap: 10px; padding: 9px 6px; border-bottom: 1px solid var(--border); }
.rank-list li.me { background: color-mix(in srgb, var(--primary) 14%, transparent); border-radius: 12px; }
.rank-list .grow { display: flex; flex-direction: column; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-n { width: 30px; height: 30px; flex-shrink: 0; display: grid; place-items: center; border-radius: 50%; font-weight: 700; color: var(--muted); }
.rank-n.top { color: #1f2937; }
.rank-n.top1 { background: #fbbf24; }
.rank-n.top2 { background: #cbd5e1; }
.rank-n.top3 { background: #d97706; color: #fff; }
.rank-pts { font-size: 17px; }
.points-table { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 6px; }
.points-table div { display: flex; justify-content: space-between; gap: 10px; padding: 8px 12px; border-radius: 12px; background: var(--surface2); font-size: 14px; }
.points-table b { color: var(--mod); }

/* ═════════════ المذيع والفعاليات ═════════════ */
.role-host .nick { color: #f472b6; }
@keyframes pingRed { 0% { box-shadow: 0 0 0 0 rgb(239 68 68 / .6); } 70%, 100% { box-shadow: 0 0 0 9px rgb(239 68 68 / 0); } }
@media (max-width: 560px) { }

/* ═════════════ مركز التحكم ═════════════ */
:root { --st-good: #16a34a; --st-warning: #d97706; --st-serious: #ea580c; --st-critical: #dc2626; --st-info: #64748b; }
.page-inner.wide { max-width: 1200px; }
.cc-grid { display: grid; gap: 12px; }
.cc-kpis { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.cc-two { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); align-items: start; }
.cc-tile {
  display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 16px; min-width: 0;
}
.cc-tile small { color: var(--muted); font-size: 13px; }
.cc-tile b { font-size: 26px; line-height: 1.25; font-variant-numeric: tabular-nums; }
.cc-tile span { font-size: 12px; }
.cc-tile.hero { border-color: var(--primary); border-radius: 22px 22px 22px 6px; }
.cc-tile.hero b { font-size: 34px; }
.cc-panel { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 14px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.cc-panel h3 { margin: 0; font-size: 16px; }
.cc-note { margin: 0; font-size: 13px; }
.cc-chart-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.cc-chart-head b { font-size: 22px; }
.cc-chart-head span { font-size: 13px; }
.cc-plot { position: relative; padding-top: 26px; }
.cc-bars { display: flex; align-items: flex-end; gap: 2px; height: 120px; border-bottom: 1px solid var(--border); direction: ltr; }
.cc-bar { flex: 1; height: 100%; display: flex; align-items: flex-end; cursor: default; outline: none; }
.cc-bar i { display: block; width: 100%; background: var(--primary); border-radius: 4px 4px 0 0; }
.cc-bar:hover i, .cc-bar:focus-visible i { filter: brightness(1.25); }
.cc-tip {
  position: absolute; top: 0; padding: 3px 9px; border-radius: 8px; background: var(--text); color: var(--bg);
  font-size: 12px; white-space: nowrap; pointer-events: none;
}
.cc-axis { position: relative; height: 18px; font-size: 11px; color: var(--muted); direction: ltr; }
.cc-axis span { position: absolute; transform: translateX(50%); white-space: nowrap; }
.cc-axis span:first-child { transform: none; }
.cc-axis span:last-child { transform: translateX(100%); }
.cc-table summary { font-size: 12px; color: var(--muted); cursor: pointer; }
.cc-table table { width: 100%; font-size: 13px; border-collapse: collapse; margin-top: 6px; }
.cc-table td { padding: 3px 6px; border-bottom: 1px solid var(--border); }
.cc-sev { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.cc-sev-item {
  display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 12px; background: var(--surface2);
  border-inline-start: 4px solid var(--st-info);
}
.cc-sev-item .grow { display: flex; flex-direction: column; min-width: 0; }
.cc-sev-item small { font-size: 11px; }
.cc-sev-icon { font-size: 18px; }
.cc-sev-n { font-size: 22px; }
.cc-sev-item.zero { opacity: .55; }
.cc-sev-item.st-critical { border-inline-start-color: var(--st-critical); }
.cc-sev-item.st-serious { border-inline-start-color: var(--st-serious); }
.cc-sev-item.st-warning { border-inline-start-color: var(--st-warning); }
.cc-list { display: flex; flex-direction: column; }
.cc-log { max-height: 340px; overflow-y: auto; }
.cc-row { display: flex; align-items: center; gap: 8px; padding: 7px 2px; border-bottom: 1px solid var(--border); font-size: 14px; flex-wrap: wrap; }
.cc-row:last-child { border-bottom: 0; }
.cc-time { min-width: 92px; }
.cc-st { font-size: 12px; font-weight: 700; padding: 1px 8px; border-radius: 999px; background: var(--surface2); }
.cc-st.st-critical { color: var(--st-critical); }
.cc-st.st-serious { color: var(--st-serious); }
.cc-st.st-warning { color: var(--st-warning); }
.cc-st.st-good { color: var(--st-good); }
.cc-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--border); }
.cc-dot.on { background: #22c55e; }
@media (max-width: 480px) { .cc-sev { grid-template-columns: 1fr; } .cc-two { grid-template-columns: 1fr; } }

/* روابط الصفحات العامة أسفل صفحة الدخول */

@media (max-width: 520px) {
  .landing { padding-bottom: 110px; }
  
}
.more-links { display: flex; flex-wrap: wrap; gap: 4px 14px; justify-content: center; font-size: 13px; padding-top: 6px; border-top: 1px solid var(--border); }
.more-links a { color: var(--muted); }

/* ═════════════ بطاقات الغرف (صورة أو تدرّج وأيقونة) ═════════════ */
.room-grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.rtile { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: 20px; overflow: hidden; transition: transform .18s, box-shadow .18s, border-color .18s; }
.rtile:hover { transform: translateY(-3px); box-shadow: 0 16px 36px rgb(0 0 0 / .32); border-color: color-mix(in srgb, var(--primary) 55%, var(--border)); }
.rtile.closed { opacity: .68; }
.rt-main { position: relative; display: block; width: 100%; padding: 0; border: 0; background: none; cursor: pointer; color: #fff; text-align: start; font: inherit; }
.rt-main:focus-visible { outline: 3px solid var(--primary); outline-offset: -3px; }
.rt-cover {
  position: relative; display: grid; place-items: center; width: 100%; aspect-ratio: 16 / 10; overflow: hidden;
  background:
    radial-gradient(circle at 18% 22%, hsl(var(--h) 85% 68% / .55), transparent 46%),
    radial-gradient(circle at 85% 80%, hsl(calc(var(--h) + 50) 80% 55% / .5), transparent 50%),
    linear-gradient(135deg, hsl(var(--h) 62% 40%), hsl(calc(var(--h) + 35) 66% 22%));
}
.rt-cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.rt-cover::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, rgb(0 0 0 / .12) 0%, transparent 38%, rgb(0 0 0 / .72) 100%); }
.rt-icon { font-size: clamp(54px, 9vw, 78px); line-height: 1; filter: drop-shadow(0 8px 16px rgb(0 0 0 / .4)); transform: translateY(-8px); }
.rt-live {
  position: absolute; z-index: 2; top: 12px; inset-inline-start: 12px; display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px;
  border-radius: 999px; background: rgb(0 0 0 / .55); color: #fff; font-size: 12px; font-weight: 600; backdrop-filter: blur(5px);
}
.rt-live i { width: 8px; height: 8px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 0 3px rgb(34 197 94 / .3); }
.rt-flag { position: absolute; z-index: 2; top: 10px; inset-inline-end: 12px; font-size: 18px; filter: drop-shadow(0 2px 4px rgb(0 0 0 / .5)); }
.rt-title { position: absolute; z-index: 2; inset-inline: 14px; bottom: 11px; display: block; font-size: 19px; font-weight: 700; text-shadow: 0 2px 10px rgb(0 0 0 / .65); }
.rt-title .cd { display: block; font-size: 12px; font-weight: 500; opacity: .92; }
.rt-body { display: flex; flex-direction: column; gap: 8px; padding: 12px 14px 14px; flex: 1; }
.rt-desc { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.6; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.rt-subs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; }
.rt-sub { display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface2); color: var(--text); font: inherit; font-size: 13px; cursor: pointer; }
.rt-sub:hover { border-color: var(--primary); }
.rt-sub b { font-size: 11px; color: var(--muted); font-weight: 600; }
.rt-sub.closed { opacity: .55; }
.cover-prev { width: 96px; height: 60px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); }
@media (prefers-reduced-motion: reduce) { .rtile { transition: none; } .rtile:hover { transform: none; } }

/* ═════════════ صفحة الدخول: الغرف وخطوات البدء ═════════════ */

/* رابط English وروابط صفحات الغرف في صفحة الدخول */
.lang-switch { position: absolute; top: 14px; inset-inline-start: 16px; z-index: 3; padding: 5px 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: 13px; text-decoration: none; }
.lang-switch:hover { border-color: var(--primary); }

/* ═════════════ الولاء والمستويات والجنس ═════════════ */
.lvl { margin-inline-end: 3px; font-size: .95em; cursor: help; }
.gnd { font-weight: 700; margin-inline-end: 3px; cursor: help; }
.gnd-m { color: #38bdf8; }
.gnd-f { color: #f472b6; }
.rainbow {
  background: linear-gradient(90deg, #f43f5e, #f59e0b, #22c55e, #0ea5e9, #a855f7, #f43f5e); background-size: 200% auto;
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; color: transparent !important; animation: rbflow 4s linear infinite;
}
@keyframes rbflow { to { background-position: 200% center; } }
@media (prefers-reduced-motion: reduce) { .rainbow { animation: none; } }
.avatar.f1 { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--primary); }
.avatar.f2 { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px #a78bfa; }
.avatar.f3 { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px #facc15; }
.avatar.f4 { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px #facc15, 0 0 14px 3px rgb(250 204 21 / .55); }
.gender-row { display: flex; gap: 6px; }
.gender-row button { flex: 1; padding: 8px 6px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface2); color: var(--text); font: inherit; font-size: 14px; cursor: pointer; }
.gender-row button.on { background: var(--primary); color: var(--primary-text); border-color: transparent; font-weight: 700; }
.join-card .gender-row { margin-top: 2px; }
.loy { display: flex; flex-direction: column; }
.loy-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.loy-ic { font-size: 40px; line-height: 1; }
.loy-bar { height: 10px; border-radius: 6px; background: var(--surface2); overflow: hidden; }
.loy-bar i { display: block; height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--primary), var(--bubble-me)); transition: width .4s; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.sw { width: 38px; height: 38px; border-radius: 50%; border: 2px solid var(--border); background: var(--sw, var(--surface2)); color: var(--text); font-size: 16px; font-weight: 700; cursor: pointer; display: grid; place-items: center; }
.sw.on { border-color: var(--text); box-shadow: 0 0 0 3px var(--primary); }
.sw.locked { opacity: .4; }
.rainbow-bg { background: linear-gradient(135deg, #f43f5e, #f59e0b, #22c55e, #0ea5e9, #a855f7); }
.pc-level { margin: 0; font-size: 14px; color: var(--muted); }

/* ═════════════ المحادثة الخاصة: الصوت والرسائل الزمنية ═════════════ */
.dm-voice { display: flex; align-items: center; gap: 8px; }
.dm-voice audio { height: 36px; max-width: 230px; }
.dm-voice small { font-size: 12px; opacity: .8; }
.dm-timer { font-size: 11px; opacity: .9; align-self: flex-start; }
.dm-row.timed .dm-msg { outline: 1px dashed color-mix(in srgb, currentColor 40%, transparent); outline-offset: 2px; }
.dm-ttl.on { background: var(--primary); color: var(--primary-text); border-radius: 10px; padding-inline: 8px; font-weight: 700; }
.dm-recbar { display: none; align-items: center; gap: 10px; flex: 1; padding: 4px 6px; }
.dm-composer.recording > :not(.dm-recbar):not(.sticker-panel) { display: none; }
.dm-composer.recording .dm-recbar { display: flex; }
.dm-recbar[hidden] { display: none !important; }

/* ═════════════ اسم الغرفة قائمة صغيرة تفتح الغرف الفرعية ═════════════ */
.bar { position: relative; }
.room-switch { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; margin-inline-start: -10px; background: none; border: 0; border-radius: 10px; color: inherit; font: inherit; cursor: pointer; }
.room-switch:hover:not(.single), .room-switch[aria-expanded="true"] { background: var(--surface2); }
.room-switch.single { cursor: default; }
.room-switch.single .rs-caret { display: none; }
.rs-caret { font-size: 12px; opacity: .7; }
.room-menu {
  position: absolute; top: calc(100% - 4px); inset-inline-start: 56px; z-index: 30; min-width: 230px; max-width: min(320px, 92vw); max-height: 60vh; overflow-y: auto;
  padding: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 12px 32px rgb(0 0 0 / .45);
}
.room-menu[hidden] { display: none; }
.rm-head { padding: 6px 10px; font-size: 12px; color: var(--muted); }
.rm-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px; background: none; border: 0; border-radius: 10px; color: var(--text); font: inherit; text-align: start; cursor: pointer; }
.rm-item:hover { background: var(--surface2); }
.rm-item.active { background: var(--primary); color: var(--primary-text); font-weight: 700; }
.rm-item.closed { opacity: .55; }
.rm-name { flex: 1; }
.rm-count { font-size: 12px; opacity: .8; }

/* اختيار حالتي أعلى قائمة المتواجدين */
.my-status-wrap { position: relative; margin: 0 6px 10px; }
.my-status { display: flex; align-items: center; gap: 6px; width: 100%; padding: 8px 12px; background: var(--surface2); border: 1px solid var(--border); border-radius: 12px; color: var(--text); font: inherit; font-size: 14px; cursor: pointer; }
.my-status:hover { border-color: var(--primary); }
.my-status .rs-caret { margin-inline-start: auto; }
.status-menu { position: absolute; top: calc(100% + 4px); inset-inline: 0; z-index: 12; padding: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 12px 32px rgb(0 0 0 / .45); }
.status-menu[hidden] { display: none; }
.status-menu .rm-item { gap: 10px; }

/* زر الخروج أسفل القائمة الجانبية */
.rail-logout { margin-top: auto; }
#rail .rail-logout { color: var(--danger); border-top: 1px solid var(--border); border-radius: 0 0 14px 14px; padding-top: 14px; }

/* إعلانات Adsterra وغيرها: توسيط الإطارات وإخفاء الحاوية إن لم تحمل إعلاناً */
.ad iframe { display: block; margin: 0 auto; max-width: 100%; border: 0; }
.ad:not(:has(:not(script, style, noscript))):not(:empty) { display: none; }
#adMobile { display: none; }
@media (max-width: 760px) { #adMobile { display: block; } #adMobile:empty { display: none; } }

/* إعلان تحت القائمة اليمنى */
#rail .rail-ad { margin: 12px 0 0; padding: 0; }
#rail .rail-ad .ad-placeholder { min-height: 300px; }
/* شعار الموقع المرفوع من المدير */
.logo-img { display: block; margin: 0 auto 10px; max-width: 200px; max-height: 110px; width: auto; height: auto; object-fit: contain; }
/* قائمة المتواجدين: فاصل قسم غير المتصلين */
.users-panel li.ul-sep { cursor: default; font-size: 12px; color: var(--muted); padding: 10px 10px 4px; border-top: 1px solid var(--border); margin-top: 6px; opacity: 1; }
.admin-info { background: var(--surface2); border-radius: 10px; padding: 8px 12px; font-size: 13px; line-height: 1.7; }
.mon-entry small.dev { display: block; }

/* اللوحة اليسرى: القائمة تمرَّر وحدها، والإعلان ثابت وظاهر كاملاً في الأسفل */
.users-panel { overflow: hidden; }
.users-panel #userList { flex: 1 1 auto; min-height: 90px; overflow-y: auto; }
.users-panel .ad-side{ flex-shrink: 0; }
.users-panel .ad-side { margin-top: 10px; padding-top: 0; display: flex; justify-content: center; }
.users-panel .ad-side .ad-placeholder { min-height: 250px; width: 100%; }
@media (max-height: 760px) { .users-panel .ad-side .ad-placeholder { min-height: 160px; }  }

/* الإعلان تحت القائمة اليمنى: ثابت الحجم وظاهر كاملاً في منتصف القائمة، وشريط تمرير رفيع إن ضاقت الشاشة */
body:not([data-view="login"]) .rail { scrollbar-width: thin; }
#rail .rail-ad { flex: 0 0 auto; display: flex; justify-content: center; margin: 10px 0; }
#rail .rail-ad:empty { display: none; }
#rail .rail-ad .ad-placeholder { min-height: 250px; width: 100%; }
#rail .rail-logout { flex: 0 0 auto; }
@media (max-height: 760px) { #rail .rail-ad .ad-placeholder { min-height: 160px; } #rail .nav-item { padding-top: 8px; padding-bottom: 8px; } }
@media (max-height: 700px) {
  body:not([data-view="login"]) .rail { padding: 8px 10px; gap: 2px; }
  #rail .rail-title { display: none; }
  #rail .nav-item { padding-top: 6px; padding-bottom: 6px; }
  #rail .rail-ad { margin: 6px 0; }
  #rail .rail-ad .ad-placeholder { min-height: 130px; }
  #rail .rail-logout { padding-top: 8px; }
}

/* النظام الاجتماعي */
.pc-cover { height: 64px; border-radius: 12px; margin: -2px 0 -34px; }
.pc-tags { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.cover-sw { width: 34px; height: 34px; border-radius: 10px; border: 2px solid transparent; color: var(--muted); }
.cover-sw.on { border-color: var(--text); }

/* نظام الغرف */
.lobby-top { display: flex; gap: 10px; align-items: center; }
.lobby-top .search { flex: 1; }
.kind-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 4px; }
.kind-chips:empty { display: none; }
.chip { border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 999px; padding: 5px 14px; font-size: 13px; cursor: pointer; }
.chip.on { background: var(--primary); color: var(--primary-text); border-color: transparent; }
.rt-kind { position: absolute; z-index: 2; top: 10px; inset-inline-start: 12px; background: rgb(0 0 0 / .55); color: #fff; border-radius: 999px; padding: 2px 10px; font-size: 12px; }
.room-info { display: flex; flex-direction: column; gap: 10px; }
.room-info h4 { margin: 6px 0 0; }
.ri-facts { display: flex; flex-wrap: wrap; gap: 6px; }
.ri-rules { white-space: pre-wrap; background: var(--surface2); border-radius: 10px; padding: 8px 12px; margin: 0; font-size: 14px; }

/* اختيار اللغة */
.lang-switch { display: flex; gap: 4px; padding: 3px; }
.lang-btn { border: 0; background: none; color: var(--muted); font-size: 13px; padding: 3px 10px; border-radius: 999px; cursor: pointer; }
.lang-btn.on { background: var(--primary); color: var(--primary-text); }
.lang-picker { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin: 12px 0 4px; }

/* الإعلانات الجانبية لا تبتلع القوائم: ارتفاعها محدود، وقائمة المتواجدين تأخذ المساحة المتبقية وتُمرَّر وحدها */
.users-panel { overflow-y: auto; }
.users-panel #userList { flex: 1 1 auto; min-height: 220px; }
.users-panel .ad-side { flex: 0 1 auto; max-height: 300px; overflow: hidden; align-items: flex-start; }
.users-panel .ad-side > * { max-width: 100%; }
.users-panel .ad-side .ad-placeholder { min-height: 160px; }
#rail .rail-ad { max-height: 320px; overflow: hidden; }
.users-panel #userList { min-height: 150px; }
.users-panel .ad-side { flex: 0 0 auto; }

/* زر «راسل الإدارة» في رأس الدردشة بين الجرس والثيمات */
.req-top { width: auto; padding: 0 12px; gap: 6px; display: inline-flex; align-items: center; font-size: 13px; white-space: nowrap; }
.req-top[hidden] { display: none; }
/* النص بجانب الأيقونة يظهر فقط حين تتسع الشاشة، وإلا يأخذ مكان اسم الغرفة ويقطعه */
@media (max-width: 1179px) { .req-top span { display: none; } .req-top { padding: 0; width: 38px; justify-content: center; } }

/* ═════════ واجهة الدردشة: فقاعات، شريط كتابة، غرف نشطة، قائمة أصدقاء ═════════ */
/* رأس الغرفة بتدرّج لوني وصورة الغرفة */
#viewChat > .chat-bar { background: linear-gradient(135deg, var(--primary), color-mix(in srgb, var(--primary) 50%, #a855f7)); color: #fff; border-bottom: 0; padding: 10px 14px; gap: 10px; }
#viewChat > .chat-bar .title strong, #viewChat > .chat-bar .room-switch { color: #fff; font-size: 17px; }
#viewChat > .chat-bar .muted, #viewChat > .chat-bar small { color: rgb(255 255 255 / .85); }
#viewChat > .chat-bar .icon-btn { color: #fff; }
#viewChat > .chat-bar .icon-btn:hover { background: rgb(255 255 255 / .18); }
.room-av { width: 46px; height: 46px; border-radius: 50%; background: rgb(255 255 255 / .25); display: flex; align-items: center; justify-content: center; font-size: 25px; overflow: hidden; flex: none; border: 2px solid rgb(255 255 255 / .6); }
.room-av img { width: 100%; height: 100%; object-fit: cover; }

/* رسائل بشكل فقاعة وبجانبها صورة صاحبها. رسائلي على اليمين دائماً وبلون الموقع */
.messages { gap: 12px; padding: 16px 14px; }
.msg { display: flex; align-items: flex-end; gap: 8px; background: none; border: 0; padding: 0; border-radius: 0; max-width: min(84%, 640px); box-shadow: none; }
.msg.system, .msg.welcome { display: block; }
.msg.welcome { background: var(--surface2); padding: 8px 14px; border-radius: 12px; }
.msg.me { background: none; border: 0; }
.msg.mentioned { box-shadow: none; border: 0; }
:root[dir="rtl"] .msg:not(.me):not(.system) { align-self: flex-end; flex-direction: row-reverse; }
:root[dir="rtl"] .msg.me { align-self: flex-start; flex-direction: row; }
:root[dir="ltr"] .msg:not(.me):not(.system) { align-self: flex-start; flex-direction: row; }
:root[dir="ltr"] .msg.me { align-self: flex-end; flex-direction: row-reverse; }
.msg > .avatar { flex: none; align-self: flex-end; }
.msg .bubble { background: var(--bubble); border: 1px solid var(--border); padding: 8px 14px 9px; border-radius: 18px; min-width: 0; overflow-wrap: anywhere; }
.msg:not(.me) .bubble { border-bottom-left-radius: 5px; }
.msg.me .bubble { background: linear-gradient(135deg, var(--bubble-me), color-mix(in srgb, var(--bubble-me) 72%, #000)); color: var(--bubble-me-text); border-color: transparent; border-bottom-right-radius: 5px; }
.msg.mentioned .bubble { border-color: var(--admin); box-shadow: 0 0 0 1px var(--admin); }
.msg.ephemeral .bubble { border-style: dashed; }
.msg .meta { margin-bottom: 3px; gap: 10px; }
.msg .meta time { font-size: 11px; }
.msg .text { line-height: 1.55; }

/* شريط الكتابة: كبسولة بزر إرسال دائري */
.composer { margin: 8px 14px 12px; padding: 5px 6px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); align-items: center; gap: 2px; box-shadow: 0 2px 10px rgb(0 0 0 / .12); }
:root[dir="ltr"] .composer { flex-direction: row-reverse; }
.composer .input-wrap input { border: 0; background: transparent; padding: 10px 10px; border-radius: 999px; }
.composer .icon-btn { font-size: 20px; }
.send-btn { width: 44px; height: 44px; flex: none; border: 0; border-radius: 50%; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; background: linear-gradient(135deg, var(--primary), color-mix(in srgb, var(--primary) 55%, #7c3aed)); color: var(--primary-text); transition: transform .12s, filter .12s; }
.send-btn:hover { filter: brightness(1.1); transform: scale(1.05); }
:root[dir="rtl"] .send-btn svg { transform: scaleX(-1); }

/* قائمة المتصلين */
.users-panel h3 { font-size: 17px; color: var(--text); margin: 6px 6px 10px; }
.user-search { margin: 0 2px 10px; border-radius: 12px; padding: 9px 12px; width: calc(100% - 4px); }
.users-panel li { padding: 8px 8px; gap: 12px; border-radius: 12px; }
.users-panel li .ul-info { display: flex; flex-direction: column; min-width: 0; line-height: 1.35; }
.users-panel li .ul-name { font-weight: 600; }
.users-panel li .st-note { color: var(--muted); font-size: 12px; font-weight: 400; margin: 0; }

/* غرف الدردشة النشطة في القائمة اليمنى */
.rail-rooms { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; min-height: 0; flex: 1 1 auto; }
.rail-rooms:empty { display: none; }

.rr-new { border: 0; border-radius: 14px; padding: 12px; font-weight: 600; cursor: pointer; background: var(--text); color: var(--surface); }
.rr-new:hover { filter: brightness(1.15); }
body:not([data-view="login"]) .rail { width: 256px; }
#rail .nav-item { padding-top: 8px; padding-bottom: 8px; }
@media (max-width: 1000px) { body:not([data-view="login"]) .rail { width: 210px; } }
/* تصحيح: قائمة الغرف تأخذ ارتفاعها الكامل ولا تتداخل مع الإعلان، والقائمة اليمنى تُمرَّر إن ضاقت الشاشة */
.rail-rooms { flex: 0 0 auto; min-height: 0; }

.users-panel #userList { scrollbar-width: thin; }
@media (max-width: 480px) { .room-av { display: none; } #viewChat > .chat-bar { padding: 8px 10px; } }

/* اتجاه نص الرسائل تلقائي: العربية تبدأ من اليمين والإنجليزية من اليسار */
.msg .text, .dm-text, #msgInput { unicode-bidi: plaintext; text-align: start; }

/* الغرف في القائمة اليمنى: أسماء رئيسية تنفتح على فرعية، وبجانب كل غرفة عدد المتصلين */
.rail-rooms { gap: 2px; margin-top: 6px; }
.rr-group { display: flex; flex-direction: column; }
.rr-main, .rr-sub { display: flex; align-items: center; gap: 8px; width: 100%; text-align: start; border: 0; background: none; color: var(--text); cursor: pointer; border-radius: 12px; font-size: 15px; transition: background .15s; }
.rr-main { padding: 10px 14px; font-weight: 600; }
.rr-sub { padding: 8px 14px; font-size: 14px; color: var(--muted); }
.rr-main:hover, .rr-sub:hover { background: var(--surface2); }
.rr-main.on { background: color-mix(in srgb, var(--primary) 14%, var(--surface)); }
.rr-sub.on { color: var(--primary); font-weight: 700; background: color-mix(in srgb, var(--primary) 10%, var(--surface)); }
.rr-main.closed, .rr-sub.closed { opacity: .6; }
.rr-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rr-count { min-width: 24px; padding: 1px 8px; border-radius: 999px; background: var(--surface2); color: var(--muted); font-size: 12px; font-weight: 700; text-align: center; }
.rr-count.live { background: color-mix(in srgb, #22c55e 22%, var(--surface)); color: #16a34a; }
.rr-caret { font-size: 12px; color: var(--muted); transition: transform .18s; }
.rr-main.open .rr-caret { transform: rotate(180deg); }
.rr-subs { display: flex; flex-direction: column; margin: 2px 14px 6px; padding-inline-start: 8px; border-inline-start: 2px solid var(--border); }
.rr-new { margin: 8px 6px 0; padding: 9px; font-size: 13px; background: none; color: var(--primary); border: 1px dashed var(--border); border-radius: 12px; font-weight: 600; cursor: pointer; }
.rr-new:hover { border-color: var(--primary); }
.lang-picker .chip { font-size: 15px; padding: 8px 18px; }

.rooms-sheet { display: flex; flex-direction: column; gap: 4px; max-height: 70vh; overflow-y: auto; }
.rooms-sheet .rr-main { font-size: 16px; padding: 13px 14px; }
.rooms-sheet .rr-sub { font-size: 15px; padding: 11px 14px; }

/* زر «تابعنا» ونافذة مواقع التواصل */
.social-fab { position: absolute; bottom: 16px; inset-inline-end: 16px; display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: 13px; cursor: pointer; }
.social-fab[hidden] { display: none; }
.social-fab:hover { border-color: var(--primary); }
.social-list { display: flex; flex-direction: column; gap: 10px; }
.social-link { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: 14px; background: var(--surface2); border: 1px solid var(--border); color: var(--text); text-decoration: none; transition: transform .12s, border-color .12s; }
.social-link:hover { transform: translateY(-1px); border-color: var(--c, var(--primary)); }
.sl-ic { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font-size: 20px; background: color-mix(in srgb, var(--c) 28%, var(--surface)); flex: none; }

/* ═════════ سباق السيارات ═════════ */
body.race-open { overflow: hidden; }
.rc-root { position: fixed; inset: 0; z-index: 95; background: #1e272e; color: #fff; display: flex; flex-direction: column; }
.rc-hud { height: 70px; flex: none; background: #11161b; display: flex; align-items: center; gap: 10px; padding: 0 12px; border-bottom: 4px solid #ff9f1a; }
.rc-box { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.rc-box.end { align-items: flex-end; text-align: end; }
.rc-tag { padding: 2px 8px; border-radius: 5px; font-weight: 700; font-size: .85rem; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rc-tag.me { background: #0be881; color: #111; }
.rc-tag.opp { background: #ff3f34; color: #fff; }
.rc-dist { font-size: 1.2rem; font-weight: 900; }
.rc-timer { background: #ffd32a; color: #1e272e; padding: 6px 16px; border-radius: 20px; font-size: 1.4rem; font-weight: 900; box-shadow: 0 0 12px rgb(255 211 42 / .5); direction: ltr; }
.rc-timer.low { background: #ff3f34; color: #fff; }
.rc-btn { background: #485460; border: 0; color: #fff; padding: 8px 12px; border-radius: 8px; cursor: pointer; font-size: 1.1rem; }
.rc-btn.quit { background: #c0392b; }
.rc-progress { flex: none; display: grid; grid-template-rows: 4px 4px; background: #11161b; direction: ltr; }
.rc-progress i { display: block; height: 100%; width: 0; transition: width .15s linear; }
.rc-progress .me { background: #0be881; }
.rc-progress .opp { background: #ff3f34; }
.rc-stage { position: relative; flex: 1; min-height: 0; display: flex; justify-content: center; background: #2ed573; }
.rc-canvas { display: block; width: 100%; max-width: 600px; height: 100%; box-shadow: 0 0 30px rgb(0 0 0 / .5); touch-action: none; }
.rc-banner { position: absolute; top: 30%; left: 0; right: 0; text-align: center; font-size: 3rem; font-weight: 900; color: #ffd32a; text-shadow: 3px 3px 0 #ff3f34; opacity: 0; pointer-events: none; transition: opacity .15s; padding: 0 20px; }
.rc-banner.show { opacity: 1; }
.rc-touch { position: absolute; bottom: 20px; left: 0; right: 0; max-width: 600px; margin: 0 auto; display: flex; justify-content: space-between; padding: 0 20px; direction: ltr; pointer-events: none; z-index: 5; }
.rc-pad { display: flex; gap: 15px; pointer-events: auto; }
.rc-touch .t-btn { width: 65px; height: 65px; border-radius: 50%; background: rgb(255 255 255 / .25); border: 3px solid rgb(255 255 255 / .7); color: #fff; font-size: 1.6rem; font-weight: 700; display: flex; align-items: center; justify-content: center; backdrop-filter: blur(3px); touch-action: none; user-select: none; -webkit-user-select: none; }
.rc-touch .t-btn:active { background: rgb(255 211 42 / .7); transform: scale(.92); }
@media (hover: hover) and (pointer: fine) { .rc-touch { display: none; } }
.rc-result { position: absolute; inset: 0; z-index: 10; background: rgb(17 22 27 / .95); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 20px; text-align: center; }
.rc-result h2 { margin: 0; color: #ffd32a; text-shadow: 2px 2px 0 #ff3f34; font-size: 2rem; }
.rc-win { font-size: 1.6rem; font-weight: 900; padding: 14px 22px; border-radius: 14px; background: #2f3640; border: 3px solid #ffd32a; }
.rc-win.win { color: #0be881; }
.rc-win.lose { color: #ff6b6b; }
.rc-win.draw { color: #ffd32a; }
.rc-scores { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; }
.rc-scores > div { display: flex; flex-direction: column; align-items: center; gap: 4px; background: #2f3640; padding: 12px 18px; border-radius: 12px; min-width: 120px; }
.rc-actions { display: flex; gap: 10px; }
@media (max-width: 480px) { .rc-banner { font-size: 2.2rem; } .rc-timer { padding: 4px 10px; font-size: 1.1rem; } }
.rc-box { align-items: flex-start; }
.rc-box.end { align-items: flex-end; }

.rc-rank { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); z-index: 4; padding: 6px 16px; border-radius: 999px; font-weight: 800; font-size: .95rem; background: rgb(17 22 27 / .82); border: 2px solid #57606f; white-space: nowrap; pointer-events: none; }
.rc-rank:empty { display: none; }
.rc-rank.lead { border-color: #0be881; color: #0be881; }
.rc-rank.behind { border-color: #ff6b6b; color: #ff8c8c; }
.rc-rank.tie { border-color: #ffd32a; color: #ffd32a; }

/* قائمة المتصلين: مضغوطة وأنيقة لتظهر كل الأسماء */
.users-panel h3 { margin: 4px 6px 8px; font-size: 16px; }
.user-search { padding: 7px 12px; font-size: 14px; margin-bottom: 8px; }
.users-panel #userList { display: flex; flex-direction: column; gap: 1px; min-height: 200px; }
.users-panel li { padding: 4px 8px; gap: 9px; border-radius: 10px; min-height: 36px; }
.users-panel li:hover { background: var(--surface2); }
.users-panel li.self { background: color-mix(in srgb, var(--primary) 12%, transparent); }
.users-panel li .ul-info { flex-direction: row; align-items: center; gap: 8px; flex: 1; min-width: 0; line-height: 1.2; }
.users-panel li .ul-name { font-size: 14px; font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.users-panel li .st-note { flex: none; font-size: 10.5px; padding: 1px 7px; border-radius: 999px; background: var(--surface2); color: var(--muted); }
.users-panel li .av-wrap > .st { width: 10px; height: 10px; }
.users-panel li.ul-sep { margin-top: 4px; padding: 8px 8px 2px; min-height: 0; }
.dm-game { font-size: 18px; }
/* إحصاءات الألعاب (للمدير) */
.gs-row { display: grid; grid-template-columns: minmax(120px, 1.3fr) 2fr auto auto; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); }
.gs-name { font-weight: 600; }
.gs-bar { height: 10px; background: var(--surface2); border-radius: 999px; overflow: hidden; }
.gs-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--primary), color-mix(in srgb, var(--primary) 50%, #a855f7)); border-radius: 999px; }
/* القائمة تأخذ طولها كاملاً (كل الأسماء ظاهرة) واللوحة نفسها تُمرَّر، والإعلان بعد القائمة */
.users-panel #userList { flex: 0 0 auto; min-height: 0; overflow: visible; }
.users-panel .ad-side { margin-top: 12px; }

/* الرسائل الخاصة: مربع مثبّت أسفل الدردشة فوق مربع الكتابة (قائمة أو محادثة) */
.dm-dock { flex: none; height: min(56vh, 480px); display: flex; flex-direction: column; background: var(--surface); border-top: 2px solid var(--primary); box-shadow: 0 -8px 24px rgb(0 0 0 / .28); min-height: 0; z-index: 6; }
.dm-dock[hidden] { display: none; }
.dm-dock .dm-page { flex: 1; min-height: 0; display: flex; flex-direction: column; background: var(--bg); }
.dm-dock .dm-side, .dm-dock .dm-main { flex: 1; min-height: 0; display: flex; flex-direction: column; border: 0; }
.dm-dock:not(.dm-open) .dm-main { display: none; }
.dm-dock.dm-open .dm-side { display: none; }
.dm-dock .dm-side-head { padding: 10px 12px 6px; gap: 8px; }
.dm-dock .dm-side-head h2 { font-size: 17px; }
.dm-title-row { display: flex; align-items: center; justify-content: space-between; }
.dm-dock .dm-threads { flex: 1; min-height: 0; overflow-y: auto; padding: 0 6px 8px; }
.dm-dock .dm-thread { padding: 8px 10px; }
.dm-dock .dm-head { padding: 6px 10px; }
.dm-dock .dm-msgs { flex: 1; min-height: 0; }
@media (max-width: 760px) { .dm-dock { height: min(68vh, 520px); } }
/* زر الرسالة الخاصة السريع في قائمة المتصلين */
.users-panel li .ul-dm { flex: none; border: 0; background: none; cursor: pointer; font-size: 14px; opacity: .55; padding: 2px 4px; border-radius: 8px; }
.users-panel li .ul-dm:hover { opacity: 1; background: var(--surface2); }

/* ═════════ ثيم واتساب ═════════ */
[data-theme="whatsapp"] {
  --bg: #0b141a; --surface: #111b21; --surface2: #202c33; --border: #2a3942;
  --text: #e9edef; --muted: #8696a0; --primary: #00a884; --primary-text: #fff;
  --bubble: #202c33; --bubble-me: #005c4b; --bubble-me-text: #e9edef; --danger: #f15c6d;
  --admin: #ffd279; --mod: #53bdeb;
  --wa-header: #202c33; --wa-header-text: #e9edef; --wa-bar: #202c33; --wa-input: #2a3942; --nick-l: 66%;
  --wa-doodle: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140' viewBox='0 0 140 140'%3E%3Cg fill='none' stroke='%23ffffff' stroke-opacity='.045' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='22' cy='24' r='8'/%3E%3Cpath d='M78 20l12 12M90 20L78 32'/%3E%3Cpath d='M18 90q9-14 18 0t18 0'/%3E%3Crect x='88' y='84' width='18' height='18' rx='5'/%3E%3Cpath d='M118 30l6 10h-12z'/%3E%3Cpath d='M60 120a8 8 0 1 1 16 0'/%3E%3C/g%3E%3C/svg%3E");
}
[data-theme="wa-light"] {
  --bg: #efeae2; --surface: #ffffff; --surface2: #f0f2f5; --border: #e1e5e8;
  --text: #111b21; --muted: #667781; --primary: #008069; --primary-text: #fff;
  --bubble: #ffffff; --bubble-me: #d9fdd3; --bubble-me-text: #111b21; --danger: #d93025;
  --admin: #b45309; --mod: #027b6c;
  --wa-header: #008069; --wa-header-text: #ffffff; --wa-bar: #f0f2f5; --wa-input: #ffffff; --nick-l: 34%;
  --wa-doodle: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140' viewBox='0 0 140 140'%3E%3Cg fill='none' stroke='%23000000' stroke-opacity='.06' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='22' cy='24' r='8'/%3E%3Cpath d='M78 20l12 12M90 20L78 32'/%3E%3Cpath d='M18 90q9-14 18 0t18 0'/%3E%3Crect x='88' y='84' width='18' height='18' rx='5'/%3E%3Cpath d='M118 30l6 10h-12z'/%3E%3Cpath d='M60 120a8 8 0 1 1 16 0'/%3E%3C/g%3E%3C/svg%3E");
}

/* ═════════ شكل الدردشة على طريقة واتساب ═════════ */
#viewChat > .chat-bar { background: var(--wa-header, linear-gradient(135deg, var(--primary), color-mix(in srgb, var(--primary) 50%, #a855f7))); color: var(--wa-header-text, #fff); }
#viewChat > .chat-bar .title strong, #viewChat > .chat-bar .room-switch, #viewChat > .chat-bar .icon-btn { color: var(--wa-header-text, #fff); }
#viewChat > .chat-bar .muted, #viewChat > .chat-bar small { color: color-mix(in srgb, var(--wa-header-text, #fff) 72%, transparent); }
.room-av { background: color-mix(in srgb, var(--wa-header-text, #fff) 18%, transparent); border-color: transparent; }
#messages { background-color: var(--bg); background-image: var(--wa-doodle, none); gap: 3px; padding: 14px 12px; }
.msg { max-width: min(80%, 620px); gap: 6px; }
.msg .bubble { border-radius: 8px; padding: 5px 9px 4px; border: 0; box-shadow: 0 1px 1px rgb(0 0 0 / .22); }
.msg:not(.me) .bubble { border-top-left-radius: 0; border-bottom-left-radius: 8px; }
.msg.me .bubble { border-top-right-radius: 0; border-bottom-right-radius: 8px; background: var(--bubble-me); }
.msg.me > .avatar { display: none; }
.msg > .avatar { width: 28px !important; height: 28px !important; font-size: 12px !important; align-self: flex-start; }
.msg .meta { margin: 0 0 1px; gap: 8px; min-height: 0; }
.msg .nick[style*="--nh"] { color: hsl(var(--nh) 62% var(--nick-l, 66%)); }
.msg.me .meta .nick { display: none; }
.msg .meta .act, .msg .meta .del { opacity: 0; }
.msg:hover .meta .act, .msg:hover .meta .del { opacity: .8; }
.msg .text { line-height: 1.45; font-size: 14.5px; }
.msg .foot { display: flex; justify-content: flex-end; align-items: center; gap: 4px; font-size: 11px; color: color-mix(in srgb, currentColor 55%, transparent); margin-top: -2px; line-height: 1; }
.msg .foot time { font-size: 11px; }
.msg .ticks { color: #53bdeb; letter-spacing: -2px; font-size: 12px; }
.composer { margin: 0; padding: 8px 10px; border: 0; border-radius: 0; background: var(--wa-bar, var(--surface2)); box-shadow: none; gap: 6px; }
.composer .input-wrap input { background: var(--wa-input, var(--surface)); border-radius: 22px; padding: 11px 16px; }
.composer .icon-btn { font-size: 21px; }
.send-btn { background: var(--primary); }
.dm-row .dm-msg { border-radius: 8px; }
.dm-row.mine .dm-msg { border-top-right-radius: 0; }
.dm-row.theirs .dm-msg { border-top-left-radius: 0; }

/* ── الرسائل الخاصة بكامل الشاشة + شريط الاسم السفلي + ألوان الجنس ── */
.dm-dock { position: fixed; inset: 0; height: auto; z-index: 60; border-top: 0; box-shadow: none; }
@media (max-width: 760px) { .dm-dock { height: auto; } }
.dm-dock .dm-side { max-width: 640px; width: 100%; margin-inline: auto; }
.dm-dock .dm-main { max-width: 900px; width: 100%; margin-inline: auto; }
.dm-chip { position: fixed; inset-inline: 0; bottom: 0; z-index: 55; display: flex; justify-content: center; gap: 6px; padding: 6px 10px calc(6px + env(safe-area-inset-bottom)); pointer-events: none; }
.dm-chip > button { pointer-events: auto; border: 0; font: inherit; color: var(--wa-header-text, var(--text)); background: var(--wa-header, var(--surface)); box-shadow: 0 4px 18px rgb(0 0 0 / .4); cursor: pointer; }
.dm-chip-open { display: flex; align-items: center; gap: 10px; padding: 6px 16px 6px 10px; border-radius: 999px; max-width: min(80vw, 360px); }
.dm-chip-open b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dm-chip-x { width: 38px; height: 38px; border-radius: 50%; }
@media (max-width: 760px) { .dm-chip { bottom: 62px; } }
.av-click { cursor: pointer; }
.av-menu { display: grid; gap: 10px; min-width: min(80vw, 260px); }
.av-menu-head { display: flex; justify-content: center; padding-bottom: 4px; }
.gn-m, .msg .nick.gn-m { color: #1e88e5; }
.gn-f, .msg .nick.gn-f { color: #ec4899; }
.gn-u, .msg .nick.gn-u { color: #000; background: rgb(255 255 255 / .88); padding: 0 7px; border-radius: 8px; }
.ul-name.gn-u { background: rgb(255 255 255 / .88); padding: 0 7px; border-radius: 8px; }
[data-theme="wa-light"] .gn-u, [data-theme="wa-light"] .msg .nick.gn-u { background: none; padding: 0; }

/* ── هاتف: كواتساب مع الكيبورد، ومربع صغير لكل محادثة خاصة ── */
.dm-chip { justify-content: flex-start; gap: 8px; overflow-x: auto; pointer-events: none; scrollbar-width: none; }
.dm-chip-item { pointer-events: auto; flex: none; display: flex; align-items: center; background: var(--wa-header, var(--surface)); color: var(--wa-header-text, var(--text)); border-radius: 999px; box-shadow: 0 4px 16px rgb(0 0 0 / .4); }
.dm-chip-item.unread { outline: 2px solid #25d366; }
.dm-chip-item button { border: 0; background: none; color: inherit; font: inherit; cursor: pointer; }
.dm-chip-item .dm-chip-open { padding: 5px 12px 5px 8px; max-width: 150px; gap: 7px; font-size: 14px; }
.dm-chip-item .dm-chip-x { width: 30px; height: 30px; opacity: .7; font-size: 12px; }
.dm-chip .dm-badge { position: static; }
.dm-back { font-size: 22px; }
@media (max-width: 760px) {
  .app { height: var(--vvh, 100dvh); }
  .dm-dock { height: var(--vvh, 100dvh); bottom: auto; }
  body.kb-open .tabbar, body.kb-open .ad, body.kb-open .dm-chip { display: none !important; }
  .composer { padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); }
  body.kb-open .composer { padding-bottom: 6px; }
  .composer .input-wrap input { font-size: 16px; }
  .send-btn, #micBtn { width: 44px; height: 44px; border-radius: 50%; background: #00a884; color: #fff; flex: none; }
  #ttlBtn { display: none; }
  /* العرض الأقصى على .msg نفسها؛ نسبة على الفقاعة كانت تُحسب من عرضها هي فتلفّ الرسائل القصيرة على سطرين */
  .msg { max-width: 86%; }
}

.dm-dock input, .dm-dock textarea { font-size: 16px; }

/* مربعات المحادثات تقع فوق شريط الكتابة ضمن الصفحة فلا تغطيه */
.dm-chip { position: static; inset: auto; padding: 6px 10px; background: var(--wa-bar, var(--surface2)); flex: none; pointer-events: auto; }
@media (max-width: 760px) { .dm-chip { bottom: auto; } }

/* هاتف: التطبيق يثبَّت على المساحة المرئية فوق الكيبورد (حل مشكلة اختفاء الرسائل في iOS) */
@media (max-width: 760px) {
  .app { position: fixed; top: var(--vvt, 0px); inset-inline: 0; height: var(--vvh, 100dvh); overflow: hidden; }
  .dm-dock { position: fixed; top: var(--vvt, 0px); height: var(--vvh, 100dvh); }
  body.kb-open { overflow: hidden; overscroll-behavior: none; }
  body.kb-open .chat-bar { min-height: 0; }
  #viewChat { min-height: 0; }
  #messages { min-height: 0; flex: 1; }
}

/* ── إعلانات المحادثة الخاصة: أعلى وأسفل وجانبان، والمحادثة بينها ── */
.dm-dock { top: var(--dm-top, 0px); bottom: var(--dm-bot, 0px); height: auto; }
.dm-ad { position: fixed; top: var(--dm-top, 0px); bottom: var(--dm-bot, 0px); width: 160px; z-index: 61; display: none; align-items: flex-start; justify-content: center; overflow: hidden; background: var(--bg); }
.dm-ad-l { left: 0; }
.dm-ad-r { right: 0; }
body.dm-dock-open.dm-has-side .dm-ad:not([hidden]) { display: flex; }
body.dm-has-side .dm-dock { left: 160px; right: 160px; }
.dm-ad .ad-placeholder { min-height: 250px; width: 100%; margin: 0; }
@media (max-width: 760px) {
  .dm-dock { top: calc(var(--vvt, 0px) + var(--dm-top, 0px)); bottom: auto; height: calc(var(--vvh, 100dvh) - var(--dm-top, 0px) - var(--dm-bot, 0px)); }
}

/* على اللمس: أزرار التفاعل والبلاغ والحذف ظاهرة دائماً (لا يوجد hover) */
@media (hover: none) { .msg .meta .act, .msg .meta .del { opacity: .75; } }

/* ── نصوص صغيرة بجانب أيقونات الرأس + تخفيف ازدحامها على الهاتف ── */
.icon-btn .lbl { display: none; font-size: 12px; margin-inline-start: 4px; font-weight: 500; }
@media (min-width: 1180px) {
  .bar .actions .icon-btn:has(.lbl) { width: auto; padding: 0 10px; display: inline-flex; align-items: center; gap: 2px; }
  .icon-btn .lbl { display: inline; }
}
.room-switch { min-width: 0; max-width: 100%; }
.room-switch strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 760px) {
  /* الهاتف: الاسم يأخذ العرض، والأدوات الثانوية في «المزيد» */
  .bar .actions .soundBtn, .bar .actions .langBtn, .bar .actions .themeBtn, .bar .actions .logoutBtn,
  .chat-bar .actions .reqBtn, #reportRoomBtn, .bar .actions .gamesStatsBtn { display: none; }
  .chat-bar .actions { gap: 0; }
  .chat-bar .title { flex: 1 1 auto; }
}

/* ── تنبيه 18+ والتذييل في صفحة الدخول ── */
.age-gate { display: flex; align-items: flex-start; gap: 8px; text-align: start; font-weight: 400 !important; font-size: 13px !important; line-height: 1.6; color: var(--muted); }
.age-gate input { margin-top: 4px; flex: none; width: 18px; height: 18px; accent-color: var(--primary); }
.age-gate a { color: inherit; text-decoration: underline; }
.landing-foot { margin-top: 6px; font-size: 12px; color: var(--muted); text-align: center; }
.landing-foot nav { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 14px; margin-bottom: 6px; }
.landing-foot a { color: inherit; text-decoration: none; }
.landing-foot a:hover { text-decoration: underline; color: var(--text); }
.landing-foot p { margin: 0; }

/* الإعلان العلوي والسفلي: شريط بعرض الصفحة كاملة في كل الصفحات، والإطار الفارغ يمتد بدل أن يترك فراغاً على الجانبين */
#adTop, #adBottom, #adMobile { width: 100%; flex: none; }
#adTop .ad-placeholder, #adBottom .ad-placeholder, #adMobile .ad-placeholder { max-width: none; width: calc(100% - 20px); margin: 5px 10px; min-height: 60px; }

/* ═════════════ لمسات أخيرة: شكل أنظف وأنعم في كل الثيمات ═════════════ */
/* اسم غير محدد الجنس: نص رمادي عادي بلا خلفية بيضاء (طلب المدير)، وأسود في الثيمات الفاتحة */
.gn-u, .msg .nick.gn-u, .users-panel li .ul-name.gn-u {
  display: inline-block; width: fit-content; max-width: 100%;
  padding: 0; border-radius: 0; background: none; color: #a8adbd;
}
.users-panel li .ul-name.gn-u { flex: 0 1 auto; margin-inline-end: auto; }
:is([data-theme="light"], [data-theme="wa-light"], [data-theme="rose"]) :is(.gn-u, .msg .nick.gn-u, .users-panel li .ul-name.gn-u) {
  background: none; padding: 0; color: #111;
}

/* فقاعات الرسائل: ظل خفيف يفصلها عن الخلفية */
.msg:not(.system) .bubble { box-shadow: 0 1px .5px rgb(0 0 0 / .16); }
.msg.me .bubble { border-color: transparent; }

/* رسالة جديدة تظهر بحركة قصيرة ناعمة (تتوقف لمن طلب تقليل الحركة من إعدادات جهازه) */
@media (prefers-reduced-motion: no-preference) {
  #messages > .msg:last-child { animation: msg-in .18s ease-out; }
  @keyframes msg-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
  .btn, .icon-btn, .send-btn, #micBtn, .tab, .chip { transition: transform .12s ease, background-color .15s ease, opacity .15s ease; }
  .btn:active, .icon-btn:active, .send-btn:active, #micBtn:active, .tab:active { transform: scale(.96); }
}

/* أزرار التفاعل والبلاغ على الرسالة: أهدأ حتى لا تزاحم النص، وتتضح عند اللمس */
@media (hover: none) {
  .msg .meta .act, .msg .meta .del { opacity: .55; font-size: 13px; }
  .msg .meta .act:active, .msg .meta .del:active { opacity: 1; }
}

/* أشرطة تمرير رفيعة بلون الثيم بدل الشريط الأبيض العريض */
#messages, .users-panel #userList, .modal-body, .dm-dock .dm-body, .rail {
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--text) 22%, transparent) transparent;
}
#messages::-webkit-scrollbar { width: 6px; }
#messages::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--text) 22%, transparent); border-radius: 6px; }
#messages::-webkit-scrollbar-track { background: transparent; }

/* تحديد النص ومؤشر لوحة المفاتيح بلون الموقع */
::selection { background: color-mix(in srgb, var(--primary) 38%, transparent); }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
input:focus-visible, textarea:focus-visible, select:focus-visible { outline-offset: 0; }
