/* ====== زر المدير العائم ====== */
.fab{position:fixed;right:18px;bottom:calc(22px + env(safe-area-inset-bottom));width:64px;height:64px;border-radius:50%;
  overflow:hidden;border:2px solid rgba(255,255,255,.25);box-shadow:0 10px 30px #8f6bff77,0 0 0 6px rgba(143,107,255,.12);
  background:#12142a;z-index:40;cursor:pointer;padding:0;margin:0;min-height:0;transition:transform .2s}
.fab:active{transform:scale(.93)}
.fab video,.fab img{width:100%;height:100%;object-fit:cover;object-position:center 15%;display:block}
.fab .dot{position:absolute;top:4px;left:4px;width:14px;height:14px;border-radius:50%;background:#ff4d6a;border:2px solid #07080f;display:none}
.fab.unread .dot{display:block}
.fab[hidden]{display:none}

/* ====== شاشة المحادثة ====== */
.chat{position:fixed;left:0;right:0;top:0;height:var(--vvh,100dvh);z-index:50;display:flex;flex-direction:column;
  background:radial-gradient(420px 360px at 90% 5%,#6d4bff66,transparent 70%),radial-gradient(380px 360px at 0% 95%,#00d4ff33,transparent 70%),#07080f;
  transform:translateY(100%);transition:transform .32s cubic-bezier(.2,.8,.2,1);visibility:hidden}
.chat.open{transform:none;visibility:visible}
.gl{background:#15172a;border:1px solid rgba(255,255,255,.12)}
.ch-head.gl{background:#14152b}
.ch-foot.gl{background:#0f1120}
.ch-head{direction:ltr;display:flex;align-items:center;gap:10px;padding:calc(10px + env(safe-area-inset-top)) 12px 10px;border-width:0 0 1px}
.ch-btn{width:40px;height:40px;border-radius:50%;display:grid;place-items:center;flex:none;padding:0;margin:0;min-height:0;box-shadow:none;background:rgba(255,255,255,.06);border:1px solid rgba(255,255,255,.12)}
.ch-btn svg,.ch-pill svg,.ch-ic svg{width:20px;height:20px;stroke:#eef0ff;fill:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
.ch-av{width:42px;height:42px;border-radius:50%;overflow:hidden;border:2px solid #8f6bff88;flex:none}
.ch-av img{width:100%;height:100%;object-fit:cover;object-position:center 15%}
.ch-who{direction:rtl;text-align:left;min-width:0}
.ch-who b{display:block;font-size:17px}
.ch-who span{font-size:12px;opacity:.6}
.ch-who span.typing{color:#4ef0a8;opacity:1}
.ch-pill{margin-left:auto;display:flex;border-radius:999px;overflow:hidden}
.ch-pill button{background:none;border:0;box-shadow:none;width:46px;height:40px;min-height:0;margin:0;padding:0;display:grid;place-items:center;border-radius:0}

.ch-search{display:none;padding:8px 12px 0}
.ch-search.on{display:flex;gap:8px;align-items:center}
.ch-search input{margin:0;padding:10px 14px;border-radius:14px}
.ch-search small{white-space:nowrap;opacity:.6;font-size:12px}

.ch-spend{display:flex;gap:8px;padding:8px 12px 0;font-size:11.5px}
.ch-spend div{padding:5px 10px;border-radius:999px}
.ch-spend b{color:#ffd27a}
.ch-pin{margin:8px 12px 0;padding:9px 12px;border-radius:14px;font-size:13px;display:none;gap:8px;align-items:center;border-color:#ffd27a44;cursor:pointer}
.ch-pin.on{display:flex}
.ch-pin span{overflow:hidden;white-space:nowrap;text-overflow:ellipsis}

.ch-list{flex:1;min-height:0;overflow-y:auto;overscroll-behavior:contain;padding:12px 12px 8px;display:flex;flex-direction:column;gap:6px;-webkit-overflow-scrolling:touch}
.ch-empty{margin:auto;text-align:center;opacity:.6;font-size:14px;line-height:1.8}
.ch-day{align-self:center;font-size:11px;opacity:.6;padding:3px 10px;border-radius:999px;margin:6px 0}
.mrow{display:flex;gap:6px;align-items:flex-end;max-width:86%;touch-action:pan-y;transition:transform .18s}
.mrow.me{align-self:flex-end}
.mrow.mg{align-self:flex-start}
.mrow .mini{width:26px;height:26px;border-radius:50%;overflow:hidden;flex:none}
.mrow .mini img{width:100%;height:100%;object-fit:cover;object-position:center 15%}
.bub{padding:9px 12px 6px;border-radius:18px;font-size:15px;line-height:1.6;white-space:pre-wrap;word-break:break-word;user-select:none;-webkit-user-select:none;-webkit-touch-callout:none;position:relative}
.me .bub{background:linear-gradient(135deg,#ff6a88d0,#8f6bffd0);border-bottom-left-radius:6px}
.mg .bub{background:rgba(255,255,255,.07);border:1px solid rgba(255,255,255,.12);border-bottom-right-radius:6px}
.bub .meta{display:flex;gap:6px;align-items:center;justify-content:flex-end;font-size:10.5px;opacity:.6;margin-top:2px;direction:ltr}
.bub .star{color:#ffd27a;opacity:1}
.bub .q{border-right:3px solid #fff;background:rgba(0,0,0,.2);border-radius:8px;padding:4px 8px;font-size:12.5px;margin-bottom:5px;opacity:.9;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:240px;cursor:pointer}
.bub .listen{display:inline-flex;align-items:center;gap:5px;font-size:12px;color:#b9a8ff;margin-top:4px;background:none;border:0;box-shadow:none;padding:2px 0;min-height:0;width:auto;font-weight:500}
.bub .listen svg{width:14px;height:14px;fill:#b9a8ff}
.bub mark{background:#ffd27a;color:#07080f;border-radius:3px}
.mrow.fail .bub{box-shadow:0 0 0 1.5px #ff4d6a}
.retry{display:block;font-size:12.5px;color:#fff;background:rgba(0,0,0,.28);border:0;box-shadow:none;padding:6px 10px;min-height:0;width:auto;margin:6px 0 2px;border-radius:10px;font-weight:700;opacity:1}
.mrow.flash .bub{box-shadow:0 0 0 2px #ffd27a}
.swipe-ic{position:absolute;left:-30px;top:50%;margin-top:-11px;width:22px;height:22px;opacity:0;stroke:#eef0ff;fill:none;stroke-width:2}

.typing-row .bub{padding:13px 15px}
.typing-row i{display:inline-block;width:7px;height:7px;border-radius:50%;background:#cfc4ff;margin:0 2px;animation:blink 1.2s infinite}
.typing-row i:nth-child(2){animation-delay:.2s}.typing-row i:nth-child(3){animation-delay:.4s}
@keyframes blink{0%,80%,100%{opacity:.25}40%{opacity:1}}

.to-end{position:absolute;left:14px;bottom:150px;width:40px;height:40px;border-radius:50%;display:none;place-items:center;padding:0;min-height:0;margin:0;box-shadow:0 6px 18px rgba(0,0,0,.4)}
.to-end.on{display:grid}
.to-end svg{width:18px;height:18px;stroke:#eef0ff;fill:none;stroke-width:2.4;stroke-linecap:round}

.ch-quick{display:flex;align-items:center;gap:7px;padding:4px 12px 8px;overflow-x:auto;scrollbar-width:none}
.ch-quick::-webkit-scrollbar{display:none}
.ch-quick .arrow{width:34px;height:34px;border-radius:50%;display:grid;place-items:center;flex:none;padding:0;min-height:0;margin:0;box-shadow:none}
.ch-quick .arrow svg{width:16px;height:16px;stroke:#eef0ff;fill:none;stroke-width:2.4;stroke-linecap:round;transition:transform .2s}
.ch-quick.open .arrow svg{transform:scaleX(-1)}
.chip{white-space:nowrap;padding:7px 13px;border-radius:999px;font-size:13px;width:auto;min-height:0;margin:0;box-shadow:none;color:#eef0ff;font-weight:500;display:none}
.ch-quick.open .chip{display:inline-block;animation:slidein .2s ease-out}
@keyframes slidein{from{opacity:0;transform:translateX(12px)}to{opacity:1;transform:none}}

.ch-reply{display:none;margin:0 12px 6px;padding:8px 10px;border-radius:12px;font-size:13px;align-items:center;gap:8px;border-right:3px solid #8f6bff}
.ch-reply.on{display:flex}
.ch-reply span{flex:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;opacity:.85}
.ch-reply button{width:28px;height:28px;padding:0;min-height:0;margin:0;background:none;border:0;box-shadow:none;font-size:18px;color:#eef0ff}

.ch-foot{direction:ltr;display:flex;gap:8px;align-items:flex-end;padding:8px 10px calc(10px + env(safe-area-inset-bottom));border-width:1px 0 0}
.ch-ic{width:42px;height:42px;display:grid;place-items:center;flex:none;background:none;border:0;box-shadow:none;padding:0;margin:0;min-height:0}
.ch-ic svg{width:25px;height:25px;stroke-width:1.8}
.ch-in{direction:rtl;flex:1;margin:0;min-height:42px;max-height:130px;resize:none;padding:10px 14px;border-radius:22px;font:inherit;font-size:16px;line-height:1.4;color:#fff;background:#1c1f33;contain:layout paint;border:1px solid rgba(255,255,255,.14);outline:none}
.ch-send{width:44px;height:44px;border-radius:50%;display:grid;place-items:center;flex:none;padding:0;margin:0;min-height:0;background:#3b8cf0;box-shadow:0 6px 18px #3b8cf066}
.ch-send svg{width:20px;height:20px;stroke:#fff;fill:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
.ch-send .s{display:none}
.ch-send.text .m{display:none}.ch-send.text .s{display:block}

/* لوحة الضغطة المطولة وأي لوحة من تحت */
.sheet-bg{position:fixed;inset:0;z-index:60;background:rgba(0,0,0,.45);display:none;align-items:flex-end}
.sheet-bg.on{display:flex}
.sheet{width:100%;border-radius:24px 24px 0 0;padding:10px 12px calc(16px + env(safe-area-inset-bottom));background:#15172a;border:1px solid rgba(255,255,255,.1);animation:up .22s ease-out}
@keyframes up{from{transform:translateY(40px);opacity:.5}to{transform:none;opacity:1}}
.sheet .grab{width:40px;height:5px;border-radius:9px;background:rgba(255,255,255,.25);margin:0 auto 10px}
.sheet .prev{font-size:13px;opacity:.7;padding:4px 8px 10px;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}
.sheet .act{display:flex;align-items:center;gap:12px;width:100%;background:none;border:0;box-shadow:none;color:#eef0ff;font-weight:500;font-size:16px;padding:13px 10px;border-radius:12px;margin:0;min-height:0;text-align:right}
.sheet .act:active{background:rgba(255,255,255,.06)}
.sheet .act.red{color:#ff8fa3}
.sheet .list{max-height:55vh;overflow:auto}
.sheet .item{padding:10px;border-bottom:1px solid rgba(255,255,255,.07);font-size:14px;line-height:1.6;cursor:pointer}
.sheet .item small{display:block;opacity:.55;font-size:11px}
.sheet h3{font-size:16px;padding:4px 8px 8px}

.toast{position:fixed;left:50%;top:calc(130px + env(safe-area-inset-top));transform:translateX(-50%);z-index:70;padding:10px 16px;border-radius:14px;background:#22253d;border:1px solid rgba(255,255,255,.14);font-size:14px;display:none;max-width:86vw;text-align:center}
.toast.on{display:block;animation:up .2s ease-out}

@media (prefers-reduced-motion:reduce){.chat{transition:none}.fab video{display:none}}

/* ====== المرحلة الثانية ====== */
/* المرفقات قبل الإرسال */
.ch-files{display:none;gap:8px;padding:0 12px 8px;overflow-x:auto}
.ch-files.on{display:flex}
.fchip{position:relative;flex:none;width:64px;height:64px;border-radius:14px;overflow:hidden;background:rgba(255,255,255,.08);border:1px solid rgba(255,255,255,.14);display:grid;place-items:center;font-size:10.5px;text-align:center;padding:4px;word-break:break-all}
.fchip img{position:absolute;inset:0;width:100%;height:100%;object-fit:cover}
.fchip button{position:absolute;top:2px;left:2px;width:20px;height:20px;border-radius:50%;padding:0;min-height:0;margin:0;background:rgba(0,0,0,.7);box-shadow:none;font-size:12px;line-height:1;color:#fff}
/* المرفقات داخل الرسالة */
.atts{display:flex;flex-wrap:wrap;gap:6px;margin-bottom:6px}
.atts img{width:180px;max-width:100%;max-height:220px;object-fit:cover;border-radius:12px;display:block;cursor:pointer;background:rgba(0,0,0,.2)}
.atts .doc{display:flex;align-items:center;gap:8px;padding:8px 10px;border-radius:12px;background:rgba(0,0,0,.22);font-size:13px;cursor:pointer;max-width:240px}
.atts .doc b{overflow:hidden;white-space:nowrap;text-overflow:ellipsis}
.voice{display:flex;align-items:center;gap:8px;margin-bottom:4px}
.voice button{width:34px;height:34px;border-radius:50%;padding:0;min-height:0;margin:0;background:rgba(255,255,255,.2);box-shadow:none;display:grid;place-items:center;flex:none}
.voice button svg{width:15px;height:15px;fill:#fff}
.voice .wave{flex:1;height:22px;min-width:110px;background:repeating-linear-gradient(90deg,rgba(255,255,255,.55) 0 3px,transparent 3px 6px);-webkit-mask:linear-gradient(transparent 20%,#000 20% 80%,transparent 80%);border-radius:4px;opacity:.8}
.voice-t{font-size:13px;opacity:.85}
/* بطاقة الأرقام */
.card2{margin-top:6px;padding:10px 12px;border-radius:14px;background:rgba(0,0,0,.22);border:1px solid rgba(255,255,255,.1);min-width:220px}
.card2 h4{font-size:12.5px;opacity:.75;font-weight:500;margin-bottom:6px}
.card2 .st{display:flex;flex-wrap:wrap;gap:16px;margin-bottom:6px}
.card2 .st b{display:block;font-size:21px;line-height:1.2}
.card2 .st span{font-size:11px;opacity:.65}
.card2 .bars{display:flex;gap:5px;align-items:flex-end;height:44px;margin-top:4px}
.card2 .bars i{flex:1;border-radius:5px 5px 2px 2px;background:linear-gradient(#8f6bff,#ff6a88);min-height:3px}
.card2 .bl{display:flex;gap:5px;font-size:9.5px;opacity:.55;margin-top:3px}.card2 .bl span{flex:1;text-align:center}
.card2 p{font-size:12px;opacity:.7;margin-top:6px}
.reminder .bub{background:rgba(255,210,122,.1);border-color:#ffd27a55}
/* تسجيل الصوت */
.ch-rec{display:none;align-items:center;gap:10px;margin:0 12px 6px;padding:10px 12px;border-radius:16px;font-size:14px}
.ch-rec.on{display:flex}
.rec-dot{width:10px;height:10px;border-radius:50%;background:#ff4d6a;animation:blink 1s infinite}
.rec-hint{flex:1;font-size:12px;opacity:.6;text-align:center}
.rec-x,.rec-go{display:none;width:auto;min-height:0;margin:0;padding:7px 12px;border-radius:12px;font-size:14px;box-shadow:none}
.rec-x{background:rgba(255,77,106,.15)}
.ch-rec.locked .rec-x,.ch-rec.locked .rec-go{display:block}
.ch-rec.locked .rec-hint{visibility:hidden}
.ch-send.rec{transform:scale(1.25);background:#ff4d6a;box-shadow:0 0 0 10px rgba(255,77,106,.15)}
.ch-send{transition:transform .15s}
/* اختيار الايجنت بالـ @ */
.ch-mention{display:none;margin:0 12px 6px;border-radius:16px;padding:6px;max-height:220px;overflow:auto}
.ch-mention.on{display:block}
.ch-mention button{display:block;width:100%;text-align:right;background:none;border:0;box-shadow:none;color:#eef0ff;font-weight:500;font-size:15px;padding:10px 12px;border-radius:10px;margin:0;min-height:0}
.ch-mention button:active{background:rgba(255,255,255,.08)}
.bub .at{color:#b9a8ff;font-weight:700}
.me .bub .at{color:#fff;text-decoration:underline}
/* لوحة + */
.attach-grid{display:flex;justify-content:space-around;padding:8px 0 6px}
.attach-grid button{width:auto;background:none;border:0;box-shadow:none;color:#eef0ff;font-weight:500;font-size:13px;padding:0;margin:0;min-height:0;display:flex;flex-direction:column;align-items:center;gap:7px}
.attach-grid i{display:grid;place-items:center;width:62px;height:62px;border-radius:50%;background:rgba(255,255,255,.08);font-style:normal;font-size:26px}
/* شاشة القفل */
.lock{position:fixed;inset:0;z-index:100;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:16px;padding:30px;text-align:center;
  background:radial-gradient(500px 400px at 80% 10%,#6d4bff77,transparent 70%),#07080f}
.lock[hidden]{display:none}
.lock .av{margin:0 auto}
.lock button{max-width:280px}
.sheet .row2{display:flex;align-items:center;gap:8px;padding:10px;border-bottom:1px solid rgba(255,255,255,.07);font-size:14px;line-height:1.6}
.sheet .row2 span{flex:1}
.sheet .row2 small{display:block;opacity:.55;font-size:11px}
.sheet .row2 button{width:auto;padding:6px 10px;margin:0;min-height:0;background:rgba(255,77,106,.14);box-shadow:none;color:#ff8fa3;font-size:13px;border-radius:10px}
.sheet .addrow{display:flex;gap:8px;padding:10px 4px 0}
.sheet .addrow input{margin:0}
.sheet .addrow button{width:auto;padding:0 18px;margin:0}
.sheet .tog{display:flex;align-items:center;justify-content:space-between;width:100%;background:none;border:0;box-shadow:none;color:#eef0ff;font-weight:500;font-size:16px;padding:13px 10px;margin:0;min-height:0}
.sheet .tog i{font-style:normal;font-size:13px;padding:4px 10px;border-radius:999px;background:rgba(255,255,255,.1)}
.sheet .tog i.on{background:#2ee88f33;color:#2ee88f}
.sheet .help{font-size:13px;opacity:.75;line-height:1.8;padding:4px 10px 8px}

/* استجابة سريعة للضغط */
.chat button,.fab{touch-action:manipulation;-webkit-tap-highlight-color:transparent}
.chat button:active{opacity:.7}
