/* الدردشة: الفقاعات، البصمة، الصورة لمرة وحدة */
.chat { display: flex; flex-direction: column; height: calc(100dvh - 32px); overflow: hidden; border-radius: var(--r-xl); }
.chat-h { display: flex; align-items: center; gap: 6px; padding: 8px 10px; border-bottom: 1px solid var(--edge); background: rgba(0,0,0,.25); }
.chat-h .who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.chat-h .who > span { display: grid; line-height: 1.3; min-width: 0; }
.chat-h small { color: var(--muted); font-size: 12px; }
.chat-h small.typing { color: var(--ok); font-weight: 600; }
.msgs { flex: 1; overflow-y: auto; padding: 16px 14px; display: flex; flex-direction: column; gap: 6px; }
.msg {
  position: relative; max-width: min(78%, 440px); padding: 8px 12px 5px; border-radius: 18px; align-self: flex-start;
  background: linear-gradient(160deg, var(--glass-3), var(--glass)); border: 1px solid var(--edge);
  box-shadow: var(--depth-sm); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-end-end-radius: 6px;
}
.msg.me {
  align-self: flex-end; color: #fff; border-color: rgba(255,120,135,.35); border-end-end-radius: 18px; border-end-start-radius: 6px;
  background: linear-gradient(165deg, rgba(255,84,104,.9), rgba(229,38,58,.85) 45%, rgba(142,14,31,.9));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.3), 0 10px 22px -12px var(--red-glow);
}
.msg p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg img { border-radius: 12px; max-height: 320px; object-fit: cover; margin: 2px 0 4px; }
.msg small { display: flex; gap: 4px; justify-content: flex-end; align-items: center; font-size: 11px; opacity: .78; }
.msg.deleted { opacity: .65; font-style: italic; }
.msg .more { position: absolute; top: 50%; transform: translateY(-50%); inset-inline-start: -38px; opacity: 0; pointer-events: none; width: 32px; height: 32px; transition: opacity .12s; }
.msg.sel .more, .msg .more:focus-visible { opacity: 1; pointer-events: auto; }
@media (hover: hover) { .msg:hover .more { opacity: 1; pointer-events: auto; } }
.msg.sel { outline: 1px solid rgba(255,255,255,.35); }
.tick { font-style: normal; letter-spacing: -2px; }
.tick.read { color: #7CF0FF; text-shadow: 0 0 6px rgba(124,240,255,.6); }
.empty-chat { margin: auto; color: var(--muted); padding: 8px 16px; border-radius: 999px; font-size: 14px; background: var(--glass); border: 1px solid var(--edge); }
.chat-note { text-align: center; color: var(--muted); font-size: 13px; padding: 10px; }

/* البصمة */
.voice { display: flex; align-items: center; gap: 10px; min-width: 210px; padding: 2px 0; }
.voice .play { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: rgba(255,255,255,.18); flex-shrink: 0; }
.msg.them .voice .play { background: linear-gradient(180deg, var(--red-hi), var(--red)); color: #fff; }
.voice .wave { flex: 1; height: 28px; display: flex; align-items: center; gap: 2px; direction: ltr; }
.voice .wave i { flex: 1; border-radius: 2px; background: currentColor; opacity: .35; }
.voice .wave i.on { opacity: 1; }
.voice .len { font-size: 12px; font-variant-numeric: tabular-nums; min-width: 34px; }

/* صورة لمرة وحدة */
.once { display: flex; align-items: center; gap: 10px; padding: 6px 2px; font-weight: 600; }
.once .ring1 { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; border: 2px dashed currentColor; font-size: 13px; }
button.once:hover { opacity: .85; }
.once.done { opacity: .7; font-weight: 400; }
.once-view { position: fixed; inset: 0; z-index: 85; background: #000; display: grid; place-items: center; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.once-view img { max-width: 100%; max-height: 100%; object-fit: contain; pointer-events: none; }
.once-view .bar { position: absolute; top: calc(12px + env(safe-area-inset-top)); inset-inline: 12px; display: flex; align-items: center; gap: 10px; color: #fff; }

/* شريط الكتابة والتسجيل */
.composer-bar { display: flex; align-items: flex-end; gap: 6px; padding: 10px; border-top: 1px solid var(--edge); background: rgba(0,0,0,.25); }
.composer-bar textarea { border-radius: 24px; min-height: 46px; max-height: 140px; padding: 11px 16px; line-height: 1.45; }
.composer-bar .icon-btn { height: 46px; width: 46px; }
.send {
  width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0; color: #fff;
  background: linear-gradient(180deg, var(--red-hi), var(--red) 50%, var(--red-deep));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.4), inset 0 -3px 0 rgba(0,0,0,.25), 0 8px 18px -6px var(--red-glow);
}
.send svg.flip { transform: scaleX(-1); }
.rec-bar { display: flex; align-items: center; gap: 10px; flex: 1; min-height: 46px; padding: 0 14px; border-radius: 24px; background: rgba(0,0,0,.4); border: 1px solid rgba(229,38,58,.45); }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--red); box-shadow: 0 0 10px var(--red); animation: blink 1s infinite; }
.rec-time { font-variant-numeric: tabular-nums; font-weight: 600; }
@keyframes blink { 50% { opacity: .25; } }
.blocked-bar { padding: 14px; text-align: center; color: var(--muted); border-top: 1px solid var(--edge); display: grid; gap: 8px; justify-items: center; }

.img-send { display: grid; gap: 14px; }
.img-send img { border-radius: var(--r-md); max-height: 50dvh; object-fit: contain; background: #000; width: 100%; }

@media (max-width: 760px) {
  .chat { height: 100dvh; border-radius: 0; border: 0; }
  .chat-h { padding-top: calc(8px + env(safe-area-inset-top)); }
  .composer-bar, .blocked-bar { padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
}

/* الروابط داخل الرسائل */
.msg .lnk { color: inherit; text-decoration: underline; word-break: break-all; }
.sh-link { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 12px; background: rgba(0,0,0,.25); border: 1px solid var(--edge); font-weight: 600; }

/* الموقع */
.map { position: relative; display: block; overflow: hidden; border-radius: 12px; background: #1a1a20; direction: ltr; max-width: 100%; }
.map img { position: absolute; width: 256px; height: 256px; max-width: none; filter: invert(1) hue-rotate(180deg) brightness(.85) contrast(.9) saturate(.6); }
.map-pin { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -92%); color: var(--red-hi); filter: drop-shadow(0 3px 4px rgba(0,0,0,.7)); }
.map-pin svg { fill: var(--red); stroke: #fff; }
.osm { position: absolute; right: 4px; bottom: 2px; font-size: 9px; color: rgba(255,255,255,.7); text-shadow: 0 1px 2px #000; }
.msg.has-loc { padding: 5px 5px 4px; }
.msg.has-loc small { padding: 0 6px; }
.loc { display: grid; gap: 6px; color: inherit; }
.loc-cap { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 0 6px; font-weight: 600; }
.loc-cap small { opacity: .75; font-weight: 400; font-size: 12px; }
.loc.live .map { box-shadow: 0 0 0 2px var(--red), 0 0 18px var(--red-glow); }
.loc-acts { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 4px 2px; }
.live-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--red-hi); box-shadow: 0 0 0 0 var(--red-glow); animation: ping 1.4s infinite; }
@keyframes ping { 0% { box-shadow: 0 0 0 0 rgba(255,84,104,.7); } 100% { box-shadow: 0 0 0 10px rgba(255,84,104,0); } }
.loc-prev { display: grid; gap: 6px; justify-items: center; min-height: 60px; }
.loc-prev .spin { display: inline-block; vertical-align: middle; width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--edge-hi); border-top-color: var(--red-hi); animation: spin .8s linear infinite; }
.live-pick { display: grid; gap: 8px; padding: 14px; border-radius: var(--r-lg); background: rgba(0,0,0,.3); border: 1px solid var(--edge); }
.live-pick .seg { margin: 4px 0; justify-self: start; }
.live-banner { position: fixed; z-index: 58; top: calc(10px + env(safe-area-inset-top)); inset-inline: 0; margin: auto; width: max-content; display: flex; align-items: center; gap: 10px; padding: 6px 8px 6px 14px; border-radius: 999px;
  background: linear-gradient(180deg, rgba(60,10,18,.92), rgba(25,5,10,.95)); border: 1px solid rgba(229,38,58,.5); box-shadow: var(--depth); font-size: 14px; font-weight: 600; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (max-width: 760px) { .live-banner { top: auto; bottom: calc(96px + env(safe-area-inset-bottom)); } }

/* البحث بالدردشة */
.chat-find { position: relative; display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--edge); background: rgba(0,0,0,.3); color: var(--muted); }
.chat-find input { min-height: 38px; padding: 6px 12px; border-radius: 999px; }
.chat-find small { white-space: nowrap; }
.find-res { position: absolute; z-index: 6; top: 100%; inset-inline: 8px; margin-top: 6px; max-height: 50dvh; overflow-y: auto; border-radius: 18px;
  background: linear-gradient(160deg, rgba(40,40,48,.96), rgba(18,18,22,.97)) !important; }
.find-res .row + .row { border-top: 1px solid var(--edge); }
.snip { white-space: normal !important; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.6; }
/* بدون padding أو حدود حتى الحروف العربية تبقى متصلة */
mark { background: rgba(255, 214, 107, .32); color: inherit; padding: 0; text-decoration: underline 2px rgba(255,214,107,.8); text-underline-offset: 4px; }
.msg.flash { animation: flash 2s ease-out; }
@keyframes flash { 0%, 30% { box-shadow: 0 0 0 3px var(--gold), 0 0 26px rgba(245,196,81,.6); } 100% { box-shadow: var(--depth-sm); } }
.msgs-wrap { position: relative; flex: 1; min-height: 0; display: flex; }
.msgs-wrap .msgs { flex: 1; }
.to-latest { position: absolute; z-index: 4; bottom: 14px; left: 14px; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; color: var(--ink);
  background: linear-gradient(180deg, rgba(60,60,70,.95), rgba(25,25,30,.95)); border: 1px solid var(--edge-hi); box-shadow: var(--depth); }
.to-latest svg { transform: rotate(90deg); }
.to-latest .badge { position: absolute; top: -6px; right: -4px; }
.spin { display: inline-block; vertical-align: middle; width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--edge-hi); border-top-color: var(--red-hi); animation: spin .8s linear infinite; }

/* الرد على رسالة */
.quote { display: grid; gap: 1px; width: 100%; text-align: start; margin: 2px 0 6px; padding: 6px 10px; border-radius: 10px;
  background: rgba(0,0,0,.25); border-inline-start: 3px solid var(--red-hi); font-size: 13px; line-height: 1.45; }
.msg.me .quote { background: rgba(0,0,0,.2); border-inline-start-color: #fff; }
.quote b { font-size: 12px; }
.quote span { opacity: .85; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.reply-bar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-top: 1px solid var(--edge); background: rgba(0,0,0,.35); border-inline-start: 3px solid var(--red-hi); }
.reply-bar .row-main small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* التفاعلات */
.msg.has-reacts { margin-bottom: 14px; }
.reacts { position: absolute; bottom: -14px; inset-inline-start: 10px; display: flex; gap: 3px; z-index: 2; }
.msg.me .reacts { inset-inline-start: auto; inset-inline-end: 10px; }
.rc { display: inline-flex; align-items: center; gap: 2px; padding: 1px 6px; border-radius: 999px; font-size: 13px; line-height: 1.5;
  background: linear-gradient(180deg, rgba(55,55,64,.98), rgba(28,28,34,.98)); border: 1px solid var(--edge-hi); box-shadow: 0 3px 8px rgba(0,0,0,.5); color: var(--ink); }
.rc small { font-size: 11px; font-weight: 700; }
.rc.mine { border-color: var(--red-hi); box-shadow: 0 0 0 1px var(--red-hi), 0 3px 8px rgba(0,0,0,.5); }
.react-pick { display: flex; justify-content: space-between; gap: 4px; padding: 6px; border-radius: 999px; background: rgba(0,0,0,.35); border: 1px solid var(--edge); }
.react-pick button { font-size: 26px; width: 46px; height: 46px; border-radius: 50%; transition: transform .12s; }
.react-pick button:hover { transform: scale(1.2); }
.react-pick button.on { background: rgba(229,38,58,.3); box-shadow: 0 0 0 2px var(--red-hi); }
.msg .more { inset-inline-start: auto; inset-inline-end: -38px; }
.msg.me .more { inset-inline-end: auto; inset-inline-start: -38px; }

/* المجموعات */
.sys-msg { align-self: center; margin: 6px 0; padding: 4px 14px; border-radius: 999px; font-size: 12px; color: var(--muted); background: rgba(0,0,0,.35); border: 1px solid var(--edge); text-align: center; max-width: 85%; }
.gname { display: block; font-size: 12px; margin-bottom: 2px; color: hsl(var(--h) 80% 72%); }
.chat-h button.who { text-align: start; color: inherit; }
.g-info { display: grid; justify-items: center; gap: 4px; text-align: center; }
.g-info h2 { margin: 6px 0 0; }
.g-info-av { position: relative; }
.g-av-edit { position: absolute; bottom: -4px; left: -4px; width: 32px; height: 32px; cursor: pointer; }
.g-members { max-height: 40dvh; overflow-y: auto; }
.g-members .row { padding: 8px 4px; }
.pick-list { max-height: 42dvh; overflow-y: auto; }
.pick-list .row { border-radius: 12px; }
.pick-list .row.on { background: rgba(229,38,58,.14); }
.pick-list .row.on .tick-pick, .gift-list .row.on .tick-pick { opacity: 1; }
.tick-pick { opacity: 0; color: var(--red-hi); font-style: normal; font-weight: 700; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips:empty { display: none; }
.chip { padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: rgba(229,38,58,.2); border: 1px solid rgba(229,38,58,.4); }
.g-tag-s { font-size: 12px; opacity: .8; }

/* الإبلاغ */
.reasons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.reason { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--edge); background: rgba(0,0,0,.25); font-weight: 500; font-size: 14px; cursor: pointer; }
.reason input { width: auto; box-shadow: none; accent-color: var(--red); }
.reason:has(input:checked) { border-color: var(--red-hi); background: rgba(229,38,58,.14); }
@media (max-width: 420px) { .reasons { grid-template-columns: 1fr; } }
