/* guest.css — واجهة وضع الضيف ونافذة الدخول + تحسينات الحركة والأداء */

/* إظهار/إخفاء حسب حالة المصادقة (html[data-ui] يُضبط من auth.js قبل أي رسم) */
html[data-ui="guest"] [data-user-only] { display: none !important; }
html[data-ui="user"]  [data-guest-only] { display: none !important; }
html:not([data-ui]) [data-user-only] { display: none !important; }

.top-login {
    border: 0; border-radius: 999px; padding: 8px 16px; font: inherit; font-weight: 800; font-size: .86em;
    color: #fff; background: linear-gradient(135deg, #e5214a, #ff8a3d); cursor: pointer;
    transition: transform .15s ease, opacity .15s ease; touch-action: manipulation;
}
.top-login:active { transform: scale(.95); opacity: .9; }

/* نافذة الدخول (Bottom Sheet) */
.auth-modal { z-index: 20000; }
.auth-box { max-height: 92dvh; overflow-y: auto; overscroll-behavior: contain; padding-bottom: calc(var(--safe-bottom, 0px) + 12px); }
.auth-box .auth-container { max-width: none; padding: 0 18px 8px; animation: none; }
.auth-reason { margin: 0; padding: 0 18px 12px; color: var(--text2, #bbb); font-size: .92em; line-height: 1.7; }
.auth-reason:empty { display: none; }
.auth-reason b { color: var(--text, #fff); }
.auth-box .auth-tab.active { color: var(--text, #fff); }
.auth-guest-note { text-align: center; margin: 10px 0 0; font-size: .82em; color: var(--muted, #888); }

/* بطاقة الضيف في صفحة «أنا» */
.me-guest { text-align: center; }
.me-guest .btn-primary, .me-guest .btn-secondary { width: 100%; max-width: 320px; margin: 8px auto 0; display: block; }
.me-guest-t { color: var(--text2, #bbb); line-height: 1.8; margin: 6px 18px 14px; }
.me-avatar-guest { background: var(--card2, #222) center / 52% no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='1.8' stroke-linecap='round'%3E%3Ccircle cx='12' cy='8' r='4'/%3E%3Cpath d='M4 21a8 8 0 0 1 16 0'/%3E%3C/svg%3E"); }
.top-avatar.is-guest { background: var(--card2, #222) center / 60% no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='1.8' stroke-linecap='round'%3E%3Ccircle cx='12' cy='8' r='4'/%3E%3Cpath d='M4 21a8 8 0 0 1 16 0'/%3E%3C/svg%3E"); }

/* لوحات «سجّل الدخول» داخل الدردشة الخاصة */
.guest-pane { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 36px 24px; text-align: center; color: var(--text2, #bbb); line-height: 1.8; }
.guest-pane .btn-primary { min-width: 180px; }

/* حالة إرسال الرسائل (Optimistic UI) */
.chat-msg.pending .chat-bubble { opacity: .65; }
.chat-msg.failed .chat-bubble { outline: 1px solid #ff453a; }
.chat-state { font-size: .72em; color: var(--muted, #888); margin-inline-start: 6px; }
.chat-msg.failed .chat-state { color: #ff453a; cursor: pointer; text-decoration: underline; }
.chat-older { display: block; margin: 8px auto; padding: 6px 14px; border-radius: 999px; border: 0; background: var(--card2, #222); color: var(--text2, #bbb); font: inherit; font-size: .8em; }

/* بانر الاتصال */
#net-banner { position: fixed; top: calc(env(safe-area-inset-top, 0px) + 6px); left: 50%; transform: translate(-50%, -140%); z-index: 25000; padding: 6px 14px; border-radius: 999px; background: #3a3a3c; color: #fff; font-size: .8em; font-weight: 700; transition: transform .25s ease; pointer-events: none; }
html.offline #net-banner { transform: translate(-50%, 0); }

/* ---------- الأداء والحركة ---------- */
/* احترام «تقليل الحركة» في النظام */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}
/* استجابة اللمس: لا تأخير 300ms ولا تحديد نص غير مقصود على عناصر التحكم */
button, [role="button"], .bnav-btn, .sh-act, .row-btn { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
/* الأقسام المخفية لا تُحسب في التخطيط/الرسم لكن تحتفظ بحالتها */
.page[hidden] { display: none !important; }
.sh-item, .dm-row, .chat-msg { contain: layout style paint; }
.chat-msg, .dm-row { content-visibility: auto; contain-intrinsic-size: auto 56px; }
.sh-item video, .sh-item img.sh-media { will-change: auto; background: #000; }
/* منع وميض الخلفية أثناء الانتقال */
html, body { background: var(--bg, #000); }

/* ---------- وسائط الدردشة: صور وصوت وملصقات ---------- */
.chat-input-row.has-media { position: relative; align-items: center; gap: 4px; }
.cm-btn { flex: none; width: 38px; height: 38px; border: 0; border-radius: 50%; background: transparent; color: var(--text2, #bbb); display: grid; place-items: center; cursor: pointer; touch-action: manipulation; }
.cm-btn:active { background: var(--card2, #222); }
.cm-img { display: block; max-width: min(240px, 62vw); max-height: 300px; border-radius: 12px; object-fit: cover; cursor: zoom-in; background: var(--card2, #222); }
.cm-sticker { font-size: 64px; line-height: 1.1; padding: 2px 6px; }
.chat-bubble:has(.cm-sticker) { background: transparent !important; box-shadow: none !important; }
.cm-audio { display: flex; align-items: center; gap: 8px; min-width: 170px; padding: 2px 0; }
.cm-play { flex: none; width: 34px; height: 34px; border: 0; border-radius: 50%; background: var(--accent, #e5214a); color: #fff; display: grid; place-items: center; cursor: pointer; }
.cm-bar { flex: 1; height: 4px; border-radius: 4px; background: rgba(127,127,127,.35); overflow: hidden; }
.cm-bar i { display: block; height: 100%; width: 0; background: currentColor; }
.cm-time { font-size: .74em; min-width: 32px; text-align: end; opacity: .8; }
.cm-stickers { position: absolute; bottom: calc(100% + 6px); inset-inline: 8px; z-index: 30; display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; padding: 8px; border-radius: 16px; background: var(--card, #1b1b1f); box-shadow: 0 6px 20px rgba(0,0,0,.4); }
.cm-stk { border: 0; background: transparent; font-size: 28px; padding: 4px; border-radius: 10px; cursor: pointer; }
.cm-stk:active { background: var(--card2, #222); }
.cm-recbar { position: absolute; inset: 0; display: flex; align-items: center; gap: 10px; padding: 0 12px; background: var(--card, #1b1b1f); border-radius: inherit; z-index: 5; }
.cm-recbar .btn-primary, .cm-recbar .btn-secondary { padding: 6px 14px; margin: 0; width: auto; }
.cm-recbar b { flex: 1; font-variant-numeric: tabular-nums; }
.cm-dot { width: 10px; height: 10px; border-radius: 50%; background: #ff453a; animation: cmPulse 1s ease-in-out infinite; }
@keyframes cmPulse { 50% { opacity: .25; } }
.cm-viewer { position: fixed; inset: 0; z-index: 30000; background: rgba(0,0,0,.94); display: grid; place-items: center; }
.cm-viewer img { max-width: 100%; max-height: 100%; object-fit: contain; }
.cm-x { position: absolute; top: calc(env(safe-area-inset-top, 0px) + 12px); inset-inline-end: 14px; width: 40px; height: 40px; border: 0; border-radius: 50%; background: rgba(255,255,255,.15); color: #fff; font-size: 18px; }
.cm-sheet { position: fixed; inset: 0; z-index: 25000; background: rgba(0,0,0,.6); display: flex; align-items: flex-end; justify-content: center; }
.cm-sheet-box { width: 100%; max-width: 480px; background: var(--card, #1b1b1f); border-radius: 20px 20px 0 0; padding: 14px 14px calc(env(safe-area-inset-bottom, 0px) + 14px); display: flex; flex-direction: column; gap: 10px; }
.cm-prev { width: 100%; max-height: 46vh; object-fit: contain; border-radius: 12px; background: #000; }
.cm-cap { width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line, #333); background: var(--card2, #222); color: inherit; font: inherit; }
.cm-status { min-height: 1.2em; font-size: .85em; color: var(--text2, #bbb); }
.cm-actions { display: flex; gap: 8px; } .cm-actions button { flex: 1; margin: 0; }

/* رسالة خطأ تشغيل الفيديو */
.sh-err { position: absolute; z-index: 1; inset-inline: 84px; top: 42%; transform: translateY(-50%);   /* يترك أعمدة الأزرار الجانبية حرّة */ padding: 14px 16px; border: 0; border-radius: 14px; background: rgba(0,0,0,.72); color: #fff; font: inherit; font-size: .92em; line-height: 1.7; text-align: center; cursor: pointer; }

/* ============================================================
   الفيديوهات القصيرة بملء الشاشة (Edge-to-edge)
   كل فيديو = شاشة كاملة بالضبط، فلا يظهر أي جزء من الفيديو التالي.
   الشريطان العلوي والسفلي يطفوان فوق الفيديو.
   ============================================================ */
.page-shorts {
    position: fixed; top: 0; bottom: 0; left: 0; right: 0;
    width: 100%; max-width: var(--maxw); margin: 0 auto;
    height: auto; z-index: 1; animation: none;
}
.sh-feed { height: 100%; padding-bottom: 0; }
.sh-item, .sh-sk { height: 100%; }
/* عناصر الواجهة فوق الفيديو تبقى فوق الشريط السفلي العائم */
.sh-side { bottom: calc(var(--nav-h) + var(--safe-bottom) + 18px); }
.sh-info { bottom: calc(var(--nav-h) + var(--safe-bottom) + 6px); }
.sh-bar  { bottom: calc(var(--nav-h) + var(--safe-bottom) - 12px); }
.sh-sound { top: calc(var(--top-h) + var(--safe-top) + 8px); }
.sh-full  { inset-inline-end: 66px; }
.sh-item::after { height: 55%; }

/* الشريط العلوي شفاف فوق الفيديو */
html[data-tab="shorts"] .topbar {
    background: linear-gradient(rgba(0,0,0,.55), rgba(0,0,0,0));
    border-bottom: 0; -webkit-backdrop-filter: none; backdrop-filter: none; color: #fff;
}
html[data-tab="shorts"] .topbar .icon-btn, html[data-tab="shorts"] .topbar .top-avatar { color: #fff; }

/* وضع ملء الشاشة: الفيديو وحده */
html.sh-immersive .topbar, html.sh-immersive .bottom-nav, html.sh-immersive .sh-side, html.sh-immersive .sh-info, html.sh-immersive .sh-bar { opacity: 0; pointer-events: none; transition: opacity .2s ease; }
html.sh-immersive .sh-item::after { opacity: 0; }
html.sh-immersive .sh-sound, html.sh-immersive .sh-full { top: calc(var(--safe-top) + 12px); }

/* زر Google */
.btn-google { width: 100%; display: flex; align-items: center; justify-content: center; gap: 10px; padding: 12px 14px; margin: 0 0 4px; border-radius: 14px; border: 1px solid #dadce0; background: #fff; color: #3c4043; font: inherit; font-weight: 700; cursor: pointer; touch-action: manipulation; transition: transform .12s ease, opacity .12s ease; }
.btn-google:active { transform: scale(.98); }
.btn-google:disabled { opacity: .6; }
.auth-or { display: flex; align-items: center; gap: 10px; margin: 12px 0; color: var(--muted, #888); font-size: .82em; }
.auth-or::before, .auth-or::after { content: ''; flex: 1; height: 1px; background: var(--line, rgba(127,127,127,.3)); }

/* مؤشر التحميل (loader.js) */
.lt-loader { position: absolute; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center; pointer-events: none; opacity: 0; transition: opacity .18s ease; }
.lt-loader.on { opacity: 1; }
.lt-loader canvas { display: block; }          /* بلا filter: يعيد رسم الـ canvas المتحرك كل إطار */
.lt-loader.lt-dim { background: rgba(0,0,0,.55); }
.sh-item > .lt-loader { z-index: 2; }


/* ============================================================
   أداء الفيديو: لا ضبابية (backdrop-filter) فوق الفيديو أو معاينة الكاميرا
   قياسنا: وجودها خفّض ترميز الفيديو من 28.5 إلى 22.9 إطاراً/ث، وهي تُعيد تمويه كل إطار فيديو خلفها أثناء التشغيل.
   نستبدلها بخلفيات شبه معتمة تُشبهها بصرياً.
   ============================================================ */
html[data-tab="shorts"] .bottom-nav {
    -webkit-backdrop-filter: none !important; backdrop-filter: none !important;
    background: rgba(24, 24, 29, .86) !important;
}
html[data-tab="shorts"] .topbar, html[data-tab="shorts"] .notification, html[data-tab="shorts"] .modal-overlay, html[data-tab="shorts"] .modal-box,
.sh-sound, .sh-full, .sh-x, .sh-flip, .sh-gal, .sh-modes, .sh-rec, .sh-rec * , .sh-item *, .page-shorts * {
    -webkit-backdrop-filter: none !important; backdrop-filter: none !important;
}
.sh-sound, .sh-full, .sh-x, .sh-flip, .sh-gal, .sh-modes { background-color: rgba(20, 20, 24, .62); }


/* ============================================================
   الشريط السفلي: وضوح الأيقونات في الوضعين الفاتح والداكن
   (على قسم الفيديو الشريط داكن دائماً → الأيقونات فاتحة دائماً؛ كانت داكنة على داكن في الوضع الفاتح فتختفي)
   ============================================================ */
html[data-tab="shorts"] .bottom-nav .bnav-btn:not(.active):not(.bnav-center) { color: rgba(255, 255, 255, .82) !important; }
html[data-tab="shorts"] .bottom-nav .bnav-btn:not(.active) svg, html[data-tab="shorts"] .bottom-nav .bnav-btn:not(.active) span { filter: none; text-shadow: none; }
/* باقي الأقسام في الوضع الفاتح: أوضح قليلاً من 62% */
:root[data-theme="light"] .bottom-nav .bnav-btn:not(.active) { color: rgba(11, 11, 18, .80); }
html[data-theme="light"]:not([data-tab="shorts"]) .bottom-nav { background-color: rgba(255, 255, 255, .62); }

/* ============================================================
   أزرار التفاعل (إعجاب/تعليق/مشاركة): أعلى قليلاً وتتكيّف مع حجم الهاتف
   ============================================================ */
.sh-side { bottom: calc(var(--nav-h) + var(--safe-bottom) + 60px); }
@media (max-height: 700px) { .sh-side { bottom: calc(var(--nav-h) + var(--safe-bottom) + 38px); gap: 10px; } .sh-side .sh-act svg { width: 26px; height: 26px; } }
@media (min-height: 860px) { .sh-side { bottom: calc(var(--nav-h) + var(--safe-bottom) + 76px); } }

/* ============================================================
   ظهور الفيديو/الصورة تدريجياً (بدل ظهور مفاجئ أو شاشة فارغة)
   ============================================================ */
.sh-item video, .sh-item img.sh-media { opacity: 0; transition: opacity .45s ease; }
.sh-item video.vis, .sh-item img.sh-media.vis { opacity: 1; }
.sh-poster { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .4s ease; pointer-events: none; background: transparent; }
.sh-poster.wide { object-fit: contain; }
.sh-poster.ld { opacity: 1; }
@media (prefers-reduced-motion: reduce) { .sh-item video, .sh-item img.sh-media, .sh-poster { transition: none; } }
/* الوضع الداكن على باقي الأقسام: أيقونات غير النشطة أوضح من 62% */
html:not([data-theme="light"]):not([data-tab="shorts"]) .bottom-nav .bnav-btn:not(.active):not(.bnav-center) { color: rgba(255, 255, 255, .80); }


/* ============================================================
   المشاهدات + ملف المستخدم
   ============================================================ */
.sh-viewer { z-index: 10500; }
.sh-user { cursor: pointer; }
.sh-views { display: flex; align-items: center; gap: 5px; margin-top: 6px; font-size: .78em; font-weight: 800; opacity: .92; }
.sh-views svg { width: 16px; height: 16px; }
.mv-views { position: absolute; bottom: 5px; inset-inline-end: 6px; display: flex; align-items: center; gap: 3px; color: #fff; font-size: .72em; font-weight: 800; text-shadow: 0 1px 4px rgba(0,0,0,.8); }
.mv-views svg { width: 13px; height: 13px; }
.up-body { overflow-y: auto; padding: 4px 16px 18px; display: flex; flex-direction: column; gap: 12px; }
.up-top { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.up-av { width: 96px; height: 96px; }
.up-actions .btn-primary, .up-actions .btn-secondary { width: 100%; margin: 0; }
.up-h { font-weight: 900; font-size: .95em; display: flex; align-items: center; gap: 6px; }

/* ============================================================
   شاشة البداية (Lottie) + انيميشن رفع المنشور
   ============================================================ */
#boot { background: #000; }
#boot-lottie { position: absolute; inset: 0; width: 100%; height: 100%; }
#boot-lottie svg { width: 100% !important; height: 100% !important; display: block; }
.boot-brand {
    position: relative; z-index: 1; direction: ltr; font-family: 'Cairo', system-ui, sans-serif; font-weight: 900; font-size: 2.1rem;
    letter-spacing: .32em; padding-inline-start: .32em; color: #fff; text-shadow: 0 0 22px rgba(229, 33, 74, .75), 0 2px 10px rgba(0, 0, 0, .5);
    -webkit-user-select: none; user-select: none; animation: brandIn .7s var(--ease-ios, ease) both;
}
@keyframes brandIn { from { opacity: 0; transform: scale(.94); } to { opacity: 1; transform: none; } }

.sh-upl { position: fixed; inset: 0; z-index: 970; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
    background: rgba(0, 0, 0, .84); animation: fadeIn .2s ease both; }
.sh-upl-box { position: relative; width: min(82vw, 380px); aspect-ratio: 1; }
.sh-upl-anim { position: absolute; inset: 0; }
.sh-upl-anim svg { width: 100% !important; height: 100% !important; display: block; }
.sh-upl-pct { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; direction: ltr; color: #fff; font-family: 'Cairo', system-ui, sans-serif;
    font-weight: 900; text-shadow: 0 2px 14px rgba(0, 0, 0, .55); pointer-events: none; font-variant-numeric: tabular-nums; }
.sh-upl-pct b { font-size: 3.6rem; line-height: 1; }
.sh-upl-pct span { font-size: 1.6rem; margin-inline-start: 4px; align-self: center; opacity: .9; }
.sh-upl-txt { min-height: 1.4em; color: #fff; font-weight: 800; font-size: .95em; text-align: center; text-shadow: 0 1px 6px rgba(0, 0, 0, .6); }

/* ظهور الفيديو أسرع (كان 450ms فيبدو التطبيق بطيئاً) */
.sh-item video, .sh-item img.sh-media { transition: opacity .18s ease; }
.sh-poster { transition: opacity .15s ease; }

/* ============================================================
   شاشة «ابدأ الآن» (أسلوب تطبيقات الجوال: شعار + اسم + زر سفلي) — داكنة دائماً
   ============================================================ */
.welcome { position: fixed; inset: 0; z-index: 29000; color: #fff; color-scheme: dark; overflow: hidden;
    background: radial-gradient(120% 70% at 50% 0%, #2a0810 0%, #12040a 50%, #050102 100%); transition: opacity .28s ease, transform .28s ease; }
.welcome.out { opacity: 0; transform: scale(1.02); pointer-events: none; }
.wl-bg { position: absolute; inset: 0; opacity: .38; mix-blend-mode: screen; }
.wl-bg svg { width: 100% !important; height: 100% !important; display: block; }
.wl-inner { position: relative; z-index: 1; max-width: var(--maxw, 520px); height: 100%; margin: 0 auto; display: flex; flex-direction: column; justify-content: space-between;
    padding: calc(env(safe-area-inset-top, 0px) + 24px) 24px calc(env(safe-area-inset-bottom, 0px) + 22px); }
.wl-center { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 14px; padding-bottom: 8vh; animation: wlUp .6s var(--ease-ios, ease) both; }
.wl-mark { border-radius: 26%; filter: drop-shadow(0 12px 30px rgba(255, 40, 40, .45)); }
.wl-word { direction: ltr; font-family: 'Cairo', system-ui, sans-serif; font-weight: 900; font-size: 2.6rem; letter-spacing: .16em; padding-inline-start: .16em; line-height: 1.1; }
.wl-tag { margin-top: 24px; font-weight: 900; font-size: 1.75rem; line-height: 1.55; }
.wl-tag em { font-style: normal; background: linear-gradient(90deg, #ff7aa8, #ffb27a); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.wl-bottom { animation: wlUp .6s .12s var(--ease-ios, ease) both; }
.wl-cta { width: 100%; min-height: 54px; border: 0; border-radius: 16px; background: linear-gradient(135deg, #ff4d73, #e5214a 55%, #ff6a3d); color: #fff; font-family: inherit; font-weight: 900; font-size: 1.05rem;
    box-shadow: 0 10px 26px rgba(229, 33, 74, .45), inset 0 1px 0 rgba(255, 255, 255, .35); transition: transform .2s var(--ease-spring, ease); }
.wl-cta:active { transform: scale(.97); }
.wl-login { margin-top: 20px; text-align: center; font-weight: 800; font-size: .92rem; }
.wl-login a, .wl-legal a { color: #fff; text-decoration: underline; text-underline-offset: 3px; }
.wl-legal { margin-top: 22px; text-align: center; font-size: .74rem; font-weight: 600; color: rgba(255, 255, 255, .6); line-height: 1.9; }
@keyframes wlUp { from { opacity: 0; transform: translate3d(0, 16px, 0); } to { opacity: 1; transform: none; } }
@media (max-height: 600px) { .wl-word { font-size: 2rem; } .wl-tag { font-size: 1.35rem; margin-top: 12px; } .wl-mark { width: 72px; height: 72px; } }
@media (prefers-reduced-motion: reduce) { .wl-center, .wl-bottom { animation: none; } }
.boot-mark { position: relative; z-index: 1; margin-bottom: 4px; filter: drop-shadow(0 10px 24px rgba(229, 33, 74, .55)); animation: brandIn .7s var(--ease-ios, ease) both; }

/* ============================================================
   واجهة المراسلة (Messenger): خلفية سوداء، فقاعات زرقاء للمرسَل ورمادية للمستلَم، صورة المحاور بجانب آخر رسالة
   اللون الأزرق متغيّر واحد: --msg-out (غيّره هنا لتغيير هوية الدردشة كلها)
   ============================================================ */
.page-chat { background: #000; color: #fff; color-scheme: dark; --msg-out: #e5214a; --msg-in: #2d2e34; --msg-accent: #ff4d73;
    --bg: #000; --card: #15161b; --card2: #26272e; --line: rgba(255, 255, 255, .09); --line2: rgba(255, 255, 255, .16); --text: #fff; --text2: #c9cad2; --muted: #8a8b99; }
.page-chat .chat-messages { background: transparent; border: 0; padding: 8px 6px; gap: 2px; }
.page-chat .chat-msg { gap: 8px; margin-top: 7px; align-items: flex-end; }
.page-chat .chat-msg.after-run { margin-top: 1px; }
.page-chat .chat-av { width: 30px; height: 30px; flex: none; }
.page-chat .chat-msg.in-run .chat-av { visibility: hidden; }
.page-chat .chat-bubble { background: var(--msg-in); border: 0; border-radius: 20px; padding: 8px 13px; max-width: 76%; color: #fff; }
.page-chat .chat-msg.mine .chat-bubble { background: var(--msg-out); }
.page-chat .chat-msg:not(.mine).after-run .chat-bubble { border-start-start-radius: 5px; }
.page-chat .chat-msg:not(.mine).in-run .chat-bubble { border-end-start-radius: 5px; }
.page-chat .chat-msg.mine.after-run .chat-bubble { border-start-end-radius: 5px; }
.page-chat .chat-msg.mine.in-run .chat-bubble { border-end-end-radius: 5px; }
.page-chat .chat-text { color: #fff; font-size: .94em; }
.page-chat .chat-name { color: var(--msg-accent); }
.page-chat .chat-msg.after-run:not(.mine) .chat-name { display: none; }
.page-chat .chat-meta { font-size: .62em; color: rgba(255, 255, 255, .55); }
.page-chat .chat-msg.mine .chat-meta { color: rgba(255, 255, 255, .72); }
.page-chat .chat-msg.in-run .chat-time, .page-chat #dm-messages .chat-msg.in-run:not(.failed):not(.pending) .chat-meta { display: none; }
.page-chat .chat-bubble:has(.cm-sticker) { background: transparent; }
.page-chat .chat-empty { color: var(--muted); }
/* حقل الكتابة: أيقونات زرقاء + كبسولة رمادية */
.page-chat .chat-input-row { gap: 4px; margin-top: 6px; background: #000; }
.page-chat .chat-input-row input { background: var(--msg-in); border: 0; border-radius: 22px; min-height: 42px; color: #fff; padding: 0 16px; }
.page-chat .chat-input-row input::placeholder { color: var(--muted); }
.page-chat .cm-btn { color: var(--msg-accent); }
.page-chat .chat-send { background: transparent; color: var(--msg-accent); width: 42px; height: 42px; }
.page-chat .chat-send svg { width: 22px; height: 22px; }
.page-chat .chat-note { color: var(--pink2); }
/* رأس المحادثة الخاصة */
.page-chat .dm-head { gap: 8px; padding: 6px 0 10px; border-bottom: 1px solid var(--line); }
.page-chat .dm-head button { width: 38px; height: 38px; border-radius: 50%; background: transparent; color: var(--msg-accent); padding: 0; }
.page-chat .dm-head button svg { width: 22px; height: 22px; }
.page-chat .dm-head button.dm-av { width: 42px; height: 42px; flex: none; }
.page-chat .dm-head button.dm-av svg { width: 100%; height: 100%; }
.dm-title { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.page-chat .dm-title b { flex: none; font-size: 1em; font-weight: 900; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dm-title small { color: #5bd987; font-size: .7em; font-weight: 800; min-height: 1em; }
/* قائمة الأصدقاء */
.page-chat .dm-row { background: transparent; border: 0; border-radius: 16px; padding: 8px 6px; min-height: 66px; }
.page-chat .dm-row.friend:active { background: var(--card2); }
.page-chat .dm-row.unread .dm-dot { background: var(--msg-accent); box-shadow: 0 0 10px var(--msg-accent); }
.page-chat .dm-add input { background: var(--msg-in); }
.page-chat .chat-tabs button { background: var(--card2); color: var(--text2); }
.page-chat .chat-tabs button.active { background: #fff; color: #000; }

/* ============================================================
   القصص (Stories)
   ============================================================ */
.stories-strip { display: flex; gap: 14px; overflow-x: auto; padding: 8px 14px 6px; flex-shrink: 0; scrollbar-width: none; scroll-snap-type: x proximity; }
.stories-strip::-webkit-scrollbar { display: none; }
.st-item { flex: none; width: 66px; display: flex; flex-direction: column; align-items: center; gap: 5px; background: none; border: 0; padding: 0; color: var(--text2); scroll-snap-align: start; }
.st-ring { position: relative; width: 64px; height: 64px; border-radius: 50%; padding: 3px; display: grid; place-items: center; background: var(--card2); }
.st-ring.new { background: conic-gradient(from 200deg, #ff4d73, #e5214a, #ff8a3d, #ffc107, #ff4d73); }
.st-ring.seen { background: rgba(255, 255, 255, .22); }
.st-ring.none { background: transparent; box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .26); }
.st-av { width: 100%; height: 100%; border-radius: 50%; overflow: hidden; border: 3px solid #000; background: #000; display: block; }
.st-av svg { width: 100%; height: 100%; display: block; }
.st-plus { position: absolute; inset-inline-end: -3px; bottom: -3px; width: 24px; height: 24px; border-radius: 50%; background: var(--msg-out); border: 2px solid #000; display: grid; place-items: center; color: #fff; font-style: normal; }
.st-plus svg { width: 13px; height: 13px; }
.st-nm { font-size: .68em; font-weight: 800; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.st-view { position: fixed; inset: 0; z-index: 965; background: #000; color: #fff; user-select: none; -webkit-user-select: none; touch-action: manipulation; }
.st-view::before, .st-view::after { content: ''; position: absolute; left: 0; right: 0; z-index: 1; pointer-events: none; }
.st-view::before { top: 0; height: 130px; background: linear-gradient(rgba(0, 0, 0, .6), transparent); }
.st-view::after { bottom: 0; height: 160px; background: linear-gradient(transparent, rgba(0, 0, 0, .65)); }
.st-media { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.st-img, .st-vid { width: 100%; height: 100%; object-fit: contain; background: #000; }
.st-bars { position: absolute; z-index: 2; top: calc(env(safe-area-inset-top, 0px) + 8px); inset-inline: 8px; display: flex; gap: 4px; }
.st-bar { flex: 1; height: 3px; border-radius: 3px; background: rgba(255, 255, 255, .32); overflow: hidden; }
.st-bar i { display: block; height: 100%; width: 0; background: #fff; }
.st-head { position: absolute; z-index: 3; top: calc(env(safe-area-inset-top, 0px) + 20px); inset-inline: 10px; display: flex; align-items: center; gap: 10px; }
.st-h-av { width: 38px; height: 38px; border-radius: 50%; overflow: hidden; flex: none; border: 1.5px solid #fff; }
.st-h-av svg { width: 100%; height: 100%; display: block; }
.st-h-t { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; text-shadow: 0 1px 6px rgba(0, 0, 0, .7); }
.st-h-t b { font-size: .92em; font-weight: 900; }
.st-h-t small { font-size: .72em; font-weight: 700; opacity: .85; }
.st-btn { width: 40px; height: 40px; border: 0; border-radius: 50%; background: rgba(0, 0, 0, .4); color: #fff; display: grid; place-items: center; padding: 0; }
.st-btn svg { width: 20px; height: 20px; }
.st-cap { position: absolute; z-index: 3; inset-inline: 18px; bottom: calc(env(safe-area-inset-bottom, 0px) + 28px); margin: 0; text-align: center; font-weight: 700; line-height: 1.7; text-shadow: 0 1px 8px #000; word-break: break-word; }
.st-comp { position: fixed; inset: 0; z-index: 960; background: rgba(0, 0, 0, .88); display: flex; align-items: center; justify-content: center; padding: 14px; }
.st-comp-box { width: 100%; max-width: 400px; background: #15161b; border: 1px solid rgba(255, 255, 255, .1); border-radius: 24px; padding: 14px; display: flex; flex-direction: column; gap: 10px; color: #fff; }
.st-comp-media { border-radius: 18px; overflow: hidden; background: #000; aspect-ratio: 9 / 13; max-height: 54dvh; display: flex; }
.st-comp-media img, .st-comp-media video { width: 100%; height: 100%; object-fit: contain; }
.st-note { min-height: 1.2em; text-align: center; font-size: .8em; font-weight: 700; color: #ff7a7a; margin: 0; }
.st-comp-act { display: flex; gap: 8px; } .st-comp-act button { flex: 1; margin: 0; }
.st-comp-box small { text-align: center; color: #8a8b99; font-weight: 700; font-size: .74em; }

/* ============================================================
   ملف الشخص: أزرار الصداقة والمراسلة والإبلاغ
   ============================================================ */
.up-actions { display: flex; flex-direction: column; gap: 8px; }
.up-row { display: flex; gap: 8px; } .up-row > * { flex: 1; width: auto !important; margin: 0 !important; }
.up-row2 { display: flex; justify-content: center; gap: 18px; }
.up-link { background: none; border: 0; padding: 8px 6px; color: var(--text2); font-weight: 800; font-size: .84em; text-decoration: underline; text-underline-offset: 3px; }
.up-link.danger { color: var(--pink2, #ff5c7c); }
.up-rep { z-index: 10600; }
.up-reasons { padding: 4px 16px 16px; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; }
.up-reason { min-height: 48px; border-radius: 14px; background: var(--card2); border: 1px solid var(--line2); font-weight: 800; color: var(--text); text-align: start; padding: 0 14px; }
.up-reason:disabled { opacity: .5; }

/* داخل محادثة خاصة: تختفي التبويبات وشريط القصص لتأخذ المحادثة الشاشة كاملة */
.page-chat.dm-open .chat-title, .page-chat.dm-open .stories-strip { display: none; }

.chat-title { padding: 10px 16px 2px; flex-shrink: 0; }
.chat-title h2 { font-size: 1.35rem; font-weight: 900; display: flex; align-items: center; gap: 6px; }
.boot-mark { border-radius: 26%; }
.st-av.guest { display: grid; place-items: center; background: var(--card2); color: var(--muted); }
.st-av.guest svg { width: 55%; height: 55%; }
