/* نجوا — پوستهٔ فارسی، راست‌به‌چپ. پالتِ «سبزِ نازرو روی سرمه‌ای» (هم‌ریختِ بی‌سیمِ نازرو). */
:root {
  color-scheme: dark;
  /* توکن‌های مرجع */
  --gold:       #76b900;
  --gold2:      #5a8c00;
  --bg:         #0a1018;
  --panel:      #0e1b30;
  --panel2:     #12233d;
  --line:       rgba(120,150,190,.22);
  --line2:      rgba(120,150,190,.14);
  --text:       #e8f0fa;
  --muted:      #8fb0d8;
  --muted2:     #6a85a8;
  --green:      #5fd08a;
  --red:        #e06060;
  --blue:       #5aa0ff;
  --radius:     14px;
  /* هم‌نام‌های سازگاری: قواعدِ موجودِ نجوا که هنوز از این توکن‌ها استفاده می‌کنند
     اکنون به مقادیرِ مرجع نگاشته می‌شوند تا کلِ اپ یک‌جا هم‌ریخت شود. */
  --bg-2:       #0e1b30;
  --olive:      #223a5a;   /* مرزها/پرکردنِ ملایمِ سرمه‌ای (جای زیتونیِ قبلی) */
  --olive-lt:   #2f5286;
  --olive-dk:   #0c1830;   /* نوارِ بالا/کشو */
  --amber:      #76b900;   /* CTA اکنون سبز است */
  --amber-lt:   #9be000;
  --danger:     #e06060;
  --ok:         #5fd08a;
  font-family: 'Vazirmatn', 'Noto Sans Arabic', 'Inter', 'Tahoma', system-ui, sans-serif;
}
* { box-sizing: border-box; }
/* اصلاحِ ریشه‌ای: صفتِ [hidden] باید همیشه بر هر display: کلاسی غلبه کند.
   (بدونِ این، پوشش‌های position:fixed مانندِ اسکنر/کشو/مودال روی صفحه می‌مانند.) */
[hidden] { display: none !important; }
/* قفلِ پنجرهٔ اپ: کلِ صفحه جابه‌جا/کشیده/زوم نمی‌شود (اندروید). فقط نواحیِ درون‌اسکرول
   (جریان/فهرست‌ها) اسکرول می‌کنند و کششِ‌بیش‌ازحدشان به بدنه سرایت نمی‌کند. */
html, body {
  margin: 0; position: fixed; inset: 0; width: 100%; height: 100%;
  overflow: hidden; overscroll-behavior: none; touch-action: manipulation;
}
body {
  background: radial-gradient(1200px 700px at 50% -10%, #132743, var(--bg) 60%);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  user-select: none; -webkit-user-select: none;
}
/* نواحیِ اسکرول‌پذیر: کششِ‌بیش‌ازحد در خودشان مهار می‌شود (به پنجره سرایت نمی‌کند). */
.feed, .archive-list, .members-list, .discover-list, .rpane, .modal, .modal-card,
.hint-overlay, .hint-card, .lb-stage { overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }

/* نوارِ بالا */
#topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; padding-top: calc(10px + env(safe-area-inset-top));
  background: var(--olive-dk); border-bottom: 2px solid var(--olive);
  position: sticky; top: 0; z-index: 20;
}
#topbar[hidden] { display: none; }
.topbar-title { flex: 1; display: flex; align-items: center; gap: 8px; font-weight: 700; }
.icon-btn { background: none; border: none; color: var(--text); font-size: 22px; cursor: pointer; }
/* چیپِ اتصال — قرصِ خط‌دار با رنگِ وضعیت (هم‌ریختِ .net-chip مرجع) */
.chip { font-size: 12.5px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line); background: transparent; color: var(--muted); white-space: nowrap; }
.chip-off { color: #f4c430; border-color: rgba(244,196,48,.5); }
.chip-lan { color: var(--blue); border-color: rgba(90,160,255,.45); }
.chip-net { color: var(--green); border-color: rgba(95,208,138,.45); }
.chip-local { color: var(--green); border-color: rgba(95,208,138,.35); }   /* روی دستگاه (محلی‌نخست) */
.chip-pending { color: #f4c430; border-color: rgba(244,196,48,.5); }
.chip-pending[hidden] { display: none; }
/* دکمهٔ اضطراری — نگه‌داشتنی: نوارِ رنگی از راست پر می‌شود تا وقتی که فعال شود
   (جلوگیری از فشارِ تصادفی + بازخوردِ دیداریِ «تا کِی نگه دارم»). */
.sos-btn {
  position: relative; overflow: hidden;
  background: #b3161d; color: #fff; border: 1px solid #e5484d; font-weight: 800;
  padding: 6px 12px; border-radius: 10px; cursor: pointer; touch-action: none;
  transition: transform .1s; font-size: 13px; flex: none;
}
.sos-btn .sos-lbl { position: relative; z-index: 1; white-space: nowrap; }
.sos-btn .sos-fill { position: absolute; inset: 0; z-index: 0; background: #ff3b2f; transform-origin: right; transform: scaleX(0); }
.sos-btn.arming .sos-fill { transform: scaleX(1); transition: transform 1.1s linear; }  /* پر‌شدن هم‌زمان با شمارشِ ۱٫۱ ثانیه‌ای نگه‌داشتن */
.sos-btn:active { transform: scale(.97); }
.sos-btn.fired { animation: sosFired .3s 2; }
@keyframes sosFired { 50% { background: #fff; color: #b3161d; } }
@media (prefers-reduced-motion: reduce) { .sos-btn.arming .sos-fill { transition: none; } }

/* صفحه‌ها */
.screen { padding: 18px; max-width: 640px; margin: 0 auto; }
.brand { text-align: center; margin: 24px 0 8px; }
.brand h1 { margin: 12px 0 2px; font-size: 34px; }
.tagline { color: var(--muted); margin: 0; }

/* زبانه‌ها */
.tabs { display: flex; gap: 8px; margin: 20px 0 12px; }
.tab {
  flex: 1; padding: 10px; border: 1px solid var(--olive); background: transparent;
  color: var(--muted); border-radius: 10px; cursor: pointer; font-family: inherit; font-size: 15px;
}
.tab.active { background: var(--panel); border-color: var(--gold); color: var(--gold); font-weight: 800; }

.pane { display: flex; flex-direction: column; gap: 14px; margin-top: 8px; }
.pane[hidden] { display: none; }   /* پنِ غیرفعال (فرمِ پیوستن/مدیر) باید پنهان شود */
label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); }
input {
  padding: 12px; border-radius: 10px; border: 1px solid var(--olive);
  background: var(--panel); color: var(--text); font-family: inherit; font-size: 16px;
}
input:focus { outline: 2px solid var(--amber); }
.hint { color: var(--muted); font-size: 13px; margin: 0; }

.btn-primary {
  background: linear-gradient(var(--amber-lt), var(--amber)); color: #3a2a08;
  border: none; padding: 13px; border-radius: 12px; font-weight: 800; font-size: 16px;
  cursor: pointer; font-family: inherit;
}
.btn-primary.sm { padding: 8px 12px; font-size: 14px; }
.btn-ghost {
  background: transparent; color: var(--gold); border: 1px solid var(--line);
  padding: 11px; border-radius: 12px; cursor: pointer; font-family: inherit; font-size: 15px;
  transition: border-color .12s, color .12s;
}
.btn-ghost:hover { border-color: var(--gold); color: var(--gold2); }

/* گروه‌ها */
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; gap: 8px; }
.section-head h2 { margin: 0; }
.section-actions { display: flex; gap: 8px; align-items: center; }
.g-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; cursor: pointer; }
.g-sub { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.g-badge.pub { color: var(--green); border: 1px solid rgba(95,208,138,.4); background: transparent; }
.g-badge.priv { color: var(--gold); border: 1px solid rgba(118,185,0,.4); background: transparent; }
.g-count { font-size: 11px; color: var(--muted); }
/* انتخابِ نوعِ کانال (خصوصی/همگانی) */
.vis-pick { display: flex; gap: 10px; }
.vis-opt { flex: 1; border: 1px solid var(--line); border-radius: 12px; padding: 12px; cursor: pointer; text-align: center; transition: border-color .12s, background .12s; }
.vis-opt.active { border-color: var(--gold); background: rgba(118,185,0,.08); }
.vis-opt .vt { font-weight: 700; font-size: 14px; }
.vis-opt .vh { font-size: 10.5px; color: var(--muted); margin-top: 3px; line-height: 1.5; }
/* فهرستِ کشفِ کانال‌های همگانی */
.discover-list { display: flex; flex-direction: column; gap: 8px; max-height: 50vh; overflow: auto; }
.disc-row { display: flex; align-items: center; gap: 10px; padding: 10px; border: 1px solid var(--line); border-radius: 11px; background: var(--panel); }
.disc-row .g-ico { font-size: 22px; }
.disc-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.disc-sub { font-size: 11px; color: var(--muted); }
.groups { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.group-card {
  display: flex; align-items: center; gap: 12px; padding: 14px;
  background: var(--panel); border: 1px solid var(--olive); border-radius: var(--radius); cursor: pointer;
}
.group-card .g-ico { font-size: 26px; }
.group-card .g-name { font-weight: 700; flex: 1; }
.group-card .g-badge { font-size: 11px; padding: 3px 8px; border-radius: 999px; background: var(--olive-dk); color: var(--muted); }
.group-card.archived { opacity: .6; }
.empty { color: var(--muted); text-align: center; margin-top: 40px; }

/* اتاق + جریانِ پیام */
#roomScreen { display: flex; flex-direction: column; height: calc(100% - 58px); padding: 0; max-width: 720px; }
#roomScreen[hidden] { display: none; }   /* غلبه بر [hidden] هنگامِ نمایشِ صفحه‌های دیگر */
.feed { flex: 1; overflow-y: auto; padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; }
/* حبابِ دوستونی: نشانگرِ فرستنده + حباب. پیامِ خودم به سمتِ مقابل می‌چسبد. */
.msg { display: flex; gap: 10px; max-width: 82%; }
.msg.mine { margin-inline-start: auto; flex-direction: row-reverse; }
.msg .who { width: 34px; height: 34px; border-radius: 10px; background: var(--panel2); border: 1px solid var(--line2); display: flex; align-items: center; justify-content: center; font-size: 17px; flex: none; }
.bubble { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 9px 13px; min-width: 0; }
.msg.mine .bubble { border-color: rgba(95,208,138,.32); background: #0f2136; }
.bubble .name { font-size: 11.5px; color: var(--muted); margin-bottom: 3px; }
.bubble .name b { color: var(--text); font-weight: 600; }
.bubble .body { font-size: 14px; line-height: 1.6; white-space: pre-wrap; word-break: break-word; }
.bubble .time { font-size: 10.5px; color: var(--muted2); }
/* پابرگِ حباب: آیکونِ ترجمه + زمان */
.bubble-foot { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.msg-tr { border: none; background: transparent; color: var(--muted); font-size: 14px; line-height: 1; padding: 2px; cursor: pointer; border-radius: 6px; opacity: .75; }
.msg-tr:hover { opacity: 1; background: rgba(118,185,0,.12); }
.msg-tr.busy { opacity: .5; animation: trpulse 1s infinite; }
.msg-tr.done { color: var(--green); opacity: 1; }
.msg.mine .bubble-foot { flex-direction: row-reverse; }
/* خطِ ترجمهٔ نتیجه زیرِ پیام */
.msg-tr-out { margin-top: 6px; padding-top: 6px; border-top: 1px dashed var(--line); }
.msg-tr-src { font-size: 12px; color: var(--muted); margin-bottom: 3px; }
.msg-tr-txt { font-size: 14px; line-height: 1.6; color: #d6eefb; }
.msg-tr-txt .tr-badge { color: var(--blue); }
/* صوت (کلیپِ PTT) — نوارِ پخش + مدت */
.voice-clip { display: flex; align-items: center; gap: 8px; margin-top: 2px; }
.voice-clip .voice-audio { flex: 1; min-width: 0; height: 38px; max-width: 240px; }
.voice-dur { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
/* عکس/ویدیو درون‌خطی */
.bubble img.att { max-width: 240px; max-height: 220px; border-radius: 10px; margin-top: 2px; display: block; }
.bubble video.att { max-width: 260px; max-height: 240px; border-radius: 10px; margin-top: 2px; }
/* فایل */
.file-att { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; margin-top: 2px; text-decoration: none; color: inherit; }
.file-att .fi { font-size: 22px; flex: none; }
.file-att .fn { font-size: 12.5px; font-weight: 600; display: block; }
.file-att .fs { font-size: 11px; color: var(--muted); }
/* موقعیت — نقشهٔ کوچکِ تک‌سنجاق */
.loc-att { display: block; border: 1px solid var(--line); border-radius: 12px; margin-top: 2px; overflow: hidden; max-width: 240px; background: var(--panel2); }
.loc-att .loc-mini { display: block; width: 100%; height: 120px; background: #0a1524; }
.loc-att .loc-info { display: flex; align-items: center; gap: 10px; padding: 8px 10px; }
.loc-att .loc-info > span { display: flex; flex-direction: column; min-width: 0; }
.loc-att .fn { font-size: 12.5px; font-weight: 600; }
.loc-att .fs { font-size: 11px; color: var(--muted); }
.loc-att .loc-open { font-size: 11px; color: var(--gold); font-weight: 700; margin-top: 2px; }
.loc-att:hover { border-color: var(--gold); }

/* نمای تمام‌صفحهٔ موقعیت (نقشهٔ رصد + سنجاق) */
.locview { position: fixed; inset: 0; z-index: 92; background: #0a1524; display: flex; flex-direction: column; }
.locview[hidden] { display: none; }
.locview-bar { display: flex; align-items: center; gap: 10px; padding: 10px 14px; padding-top: calc(10px + env(safe-area-inset-top)); background: var(--olive-dk); border-bottom: 1px solid var(--line); }
.locview-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.locview-title { font-weight: 700; font-size: 15px; }
.locview-coords { font-size: 12px; color: var(--muted); }
.locview-map { flex: 1; width: 100%; display: block; background: #0a1524; touch-action: none; min-height: 0; }
/* ترجمهٔ متنِ رسیده — ردیفِ کاملِ آبی‌رنگ */
.msg.translated { display: block; max-width: 82%; align-self: center; background: #12233d; border: 1px solid #2f5a70; color: #d6eefb; font-style: italic; padding: 8px 12px; border-radius: 12px; }
.msg.translated .who { display: inline; width: auto; height: auto; background: none; border: none; font-size: 12px; color: var(--blue); }
/* خطِ اعلامِ اضطراری در جریان */
.sos-line { display: flex; align-items: center; gap: 8px; align-self: center; max-width: 94%; background: rgba(224,96,96,.12); border: 1px solid rgba(224,96,96,.5); color: #ffb3b3; border-radius: 999px; padding: 6px 14px; font-size: 12.5px; }
.sos-line-ico { font-size: 15px; }
.sos-line-txt b { color: #ffd6d6; }
.mesh-box { margin: 10px 0; padding: 10px; border: 1px solid #2f5a70; border-radius: 10px; background: #16242e; }
.mesh-box .mesh-t { font-weight: 600; margin-bottom: 4px; }
.mesh-box .mesh-peers { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 999px; background: #223a4a; color: #bfe3f5; text-align: center; }

/* دکمهٔ PTT — گِردِ بزرگِ سبز با هالهٔ «آماده» + حالتِ کهربایی (اتصال) + سرخِ ضربان‌دار (پخش).
   هم‌ریختِ .ptt-big در بی‌سیمِ نازرو. */
.ptt-wrap { padding: 14px 18px 8px; padding-bottom: calc(8px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; align-items: center; gap: 4px; position: relative; }
.ptt {
  --ptt-size: clamp(120px, 32vw, 200px);
  position: relative; width: var(--ptt-size); height: var(--ptt-size); border-radius: 50%; border: none; flex: none;
  color: #08120a; cursor: pointer; font-family: inherit; user-select: none; -webkit-user-select: none; touch-action: none;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  background: radial-gradient(circle at 50% 30%, #9be000 0%, var(--gold) 46%, var(--gold2) 74%, #3f6600 100%);
  box-shadow:
    0 0 0 6px rgba(118,185,0,.16),
    0 0 34px rgba(118,185,0,.28),
    0 12px 30px rgba(0,0,0,.5),
    inset 0 3px 6px rgba(255,255,255,.4),
    inset 0 -10px 18px rgba(46,72,0,.5);
  transition: transform .1s ease, box-shadow .18s ease, background .18s ease;
  animation: pttready 2.6s ease-in-out infinite;
}
.ptt::before { content: ""; position: absolute; inset: 10px; border-radius: 50%; border: 2px solid rgba(255,255,255,.28); pointer-events: none; }
.ptt .ptt-ico { color: #123; line-height: 0; transition: transform .12s; filter: drop-shadow(0 2px 2px rgba(0,0,0,.25)); }
.ptt .ptt-lbl { font-weight: 800; font-size: 14px; letter-spacing: .02em; text-shadow: 0 1px 1px rgba(255,255,255,.25); }
.ptt:hover { filter: brightness(1.05); }
.ptt:active { transform: scale(.96); }
@keyframes pttready {
  0%,100% { box-shadow: 0 0 0 6px rgba(118,185,0,.16),0 0 34px rgba(118,185,0,.26),0 12px 30px rgba(0,0,0,.5),inset 0 3px 6px rgba(255,255,255,.4),inset 0 -10px 18px rgba(46,72,0,.5); }
  50%     { box-shadow: 0 0 0 10px rgba(118,185,0,.10),0 0 44px rgba(118,185,0,.40),0 12px 30px rgba(0,0,0,.5),inset 0 3px 6px rgba(255,255,255,.4),inset 0 -10px 18px rgba(46,72,0,.5); }
}
/* اتصال/گرم‌شدنِ میکروفون — کهربایی */
.ptt.arming { color: #3a2a00; animation: none;
  background: radial-gradient(circle at 50% 30%, #ffe6a0 0%, #f4c430 44%, #c99400 72%, #7a5a00 100%);
  box-shadow: 0 0 0 8px rgba(244,196,48,.18),0 0 34px rgba(244,196,48,.34),0 12px 30px rgba(0,0,0,.5),inset 0 3px 6px rgba(255,255,255,.4);
}
.ptt.arming::before { border-color: rgba(255,255,255,.45); }
.ptt.arming .ptt-ico { color: #5a3d00; }
/* در حالِ صحبت — سرخِ ضربان‌دار */
.ptt.live { color: #2a0606; animation: pttpulse .95s ease-in-out infinite;
  background: radial-gradient(circle at 50% 30%, #ffbcbc 0%, #ff7676 42%, var(--red) 70%, #a83030 100%);
}
.ptt.live::before { border-color: rgba(255,255,255,.5); }
.ptt.live .ptt-ico { color: #5a0d0d; transform: scale(1.06); }
@keyframes pttpulse {
  0%,100% { box-shadow: 0 0 0 8px rgba(224,96,96,.28),0 0 30px rgba(224,96,96,.5),0 12px 30px rgba(0,0,0,.5),inset 0 3px 6px rgba(255,255,255,.4); }
  50%     { box-shadow: 0 0 0 20px rgba(224,96,96,.08),0 0 46px rgba(224,96,96,.65),0 12px 30px rgba(0,0,0,.5),inset 0 3px 6px rgba(255,255,255,.4); }
}
@media (prefers-reduced-motion: reduce) { .ptt, .ptt.live { animation: none; } }
/* نشانِ هدفون روی دکمهٔ صحبت وقتی هدفون/هندزفری وصل است */
body.handsfree .ptt::after { content: "🎧"; position: absolute; top: 10px; inset-inline-end: 14px; font-size: 15px; opacity: .9; }

/* کشو */
.drawer {
  position: fixed; top: 0; right: 0; height: 100%; width: 260px; z-index: 40;
  background: var(--olive-dk); border-left: 2px solid var(--olive);
  padding: 16px; padding-top: calc(16px + env(safe-area-inset-top));
  display: flex; flex-direction: column; gap: 6px;
}
.drawer[hidden] { display: none; }
.drawer-head { font-size: 20px; font-weight: 800; margin-bottom: 12px; }
.drawer-item { text-align: right; background: none; border: none; color: var(--text); padding: 12px 8px; border-radius: 8px; cursor: pointer; font-family: inherit; font-size: 15px; }
.drawer-item:hover { background: var(--olive); }
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 30; }

/* پنجرهٔ ماژولار */
.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,.6); padding: 20px; }
.modal[hidden] { display: none; }
.modal-card { background: var(--bg-2); border: 1px solid var(--olive); border-radius: var(--radius); padding: 20px; width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 14px; }
.modal-card h3 { margin: 0; }
.qr-box { display: flex; justify-content: center; padding: 12px; background: #fff; border-radius: 12px; }
.code-big { font-size: 30px; font-weight: 800; letter-spacing: 4px; text-align: center; color: var(--amber-lt); direction: ltr; }

/* توست */
.toast { position: fixed; bottom: 24px; right: 50%; transform: translateX(50%); background: var(--olive); color: var(--text); padding: 12px 18px; border-radius: 10px; z-index: 60; box-shadow: 0 6px 20px rgba(0,0,0,.4); max-width: 90%; text-align: center; }
.toast.err { background: var(--danger); }

/* پیوندِ کوچک + نگارش */
.link-btn { background: none; border: none; color: var(--muted); text-decoration: underline; cursor: pointer; font-family: inherit; font-size: 13px; margin-top: 18px; display: block; width: 100%; }
.drawer-ver { margin-top: auto; color: var(--muted); font-size: 12px; padding: 8px; direction: rtl; }

/* زبانه‌های اتاق */
.room-tabs { display: flex; gap: 4px; padding: 6px 8px 0; background: var(--olive-dk); border-bottom: 1px solid var(--olive); }
.rtab { flex: 1; padding: 9px 4px; border: none; background: transparent; color: var(--muted); border-radius: 8px 8px 0 0; cursor: pointer; font-family: inherit; font-size: 14px; }
.rtab.active { background: var(--panel); color: var(--gold); font-weight: 800; border-bottom: 2px solid var(--gold); }
.rpane { flex: 1; overflow: hidden; display: flex; flex-direction: column; min-height: 0; }
.rpane[hidden] { display: none; }   /* پنهان‌سازیِ پنِ غیرفعال باید بر display:flex غلبه کند */
#feedPane { display: flex; position: relative; }
#feedPane[hidden] { display: none; }

/* دکمهٔ رفتن به تازه‌ترین پیام (پایین-چپ، پیام‌رسان‌وار) */
.scroll-last {
  position: absolute; bottom: 14px; left: 14px; z-index: 5;
  width: 46px; height: 46px; border-radius: 50%; border: 1px solid var(--olive-lt);
  background: var(--olive); color: var(--amber-lt); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 14px rgba(0,0,0,.5); font-family: inherit;
  transition: opacity .16s, transform .16s;
}
.scroll-last[hidden] { display: none; }
.scroll-last .sl-arrow { font-size: 24px; line-height: 1; font-weight: 800; }
.scroll-last:active { transform: scale(.92); }
.scroll-last .sl-badge {
  position: absolute; top: -6px; right: -6px; min-width: 20px; height: 20px; padding: 0 5px;
  border-radius: 999px; background: var(--danger); color: #fff; font-size: 12px; font-weight: 800;
  display: flex; align-items: center; justify-content: center; direction: ltr; box-shadow: 0 2px 6px rgba(0,0,0,.5);
}
.scroll-last .sl-badge[hidden] { display: none; }

/* نویسندهٔ پیامِ متنی */
.text-bar { display: flex; gap: 8px; padding: 8px 12px; background: var(--olive-dk); border-top: 1px solid var(--olive); }
.text-bar input { flex: 1; padding: 10px 12px; border-radius: 999px; border: 1px solid var(--olive); background: var(--panel); color: var(--text); font-family: inherit; font-size: 15px; }
.text-send { width: 44px; border: none; border-radius: 50%; background: linear-gradient(var(--amber-lt), var(--amber)); color: #3a2a08; font-size: 18px; cursor: pointer; font-family: inherit; transform: scaleX(-1); }
.text-send:active { transform: scaleX(-1) scale(.92); }
.msg.pending { opacity: .6; }
.msg.pending::after { content: ' ⏳'; font-size: 11px; }

/* نقشه */
.map-wrap { position: relative; flex: 1; min-height: 240px; display: flex; }
.mini-map { width: 100%; flex: 1; min-height: 240px; display: block; background: #0a1524; touch-action: none; }
/* کنترل‌های روی نقشه (بزرگ‌نمایی/چرخش/بازگشت) */
.map-ctl { position: absolute; top: 10px; left: 10px; display: flex; flex-direction: column; gap: 6px; z-index: 2; }
.map-btn {
  width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--olive-lt);
  background: rgba(20,27,48,.82); color: var(--text); font-size: 20px; line-height: 1;
  cursor: pointer; font-family: inherit; display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(2px); box-shadow: 0 2px 8px rgba(0,0,0,.4);
}
.map-btn:active { transform: scale(.94); background: var(--olive); }
.map-bar { display: flex; align-items: center; gap: 12px; padding: 10px 14px; background: var(--olive-dk); flex-wrap: wrap; }
.map-legend { display: flex; gap: 16px; align-items: center; padding: 6px 14px 10px; background: var(--olive-dk); font-size: 12px; color: var(--muted); }
.map-legend span { display: inline-flex; align-items: center; gap: 5px; }
.map-legend .lg-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.map-legend .lg-pin { font-size: 12px; font-style: normal; }
.chk { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 14px; flex-direction: row; }
.chk input { width: auto; }

/* بایگانی */
.archive-list { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.arc-row { background: var(--panel); border: 1px solid var(--olive); border-radius: 12px; padding: 10px 12px; }
.arc-head { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.arc-head b { color: var(--amber-lt); }
.arc-img { max-width: 100%; border-radius: 8px; }
.arc-vid { max-width: 100%; border-radius: 8px; }

/* اعضا */
.members-list { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.mem-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--panel); border: 1px solid var(--olive); border-radius: 10px; padding: 10px 12px; }
.mem-name { font-weight: 600; }
.mem-tag { font-size: 11px; padding: 2px 6px; border-radius: 999px; background: var(--olive); color: var(--amber-lt); }
.mem-tag.mute-tag { background: #5a2020; color: #ffb0b0; }
.mem-btns { display: flex; gap: 6px; flex-wrap: wrap; }

/* نوارِ رسانه */
/* نوارِ رسانه: هر ۷ نماد باید در عرضِ صفحه جا شوند (روی گوشیِ باریک هم). */
.media-bar { display: flex; align-items: center; gap: 2px; padding: 6px 6px; background: var(--olive-dk); border-top: 1px solid var(--olive); justify-content: space-between; }
.media-bar .icon-btn { flex: 1 1 0; min-width: 0; font-size: 19px; padding: 7px 0; border-radius: 10px; text-align: center; }
.media-bar .icon-btn.on { background: var(--olive); }
.media-bar .icon-btn.live { box-shadow: 0 0 0 2px var(--amber) inset; }
.media-bar .icon-btn.locked { opacity: .6; position: relative; }
.media-bar .icon-btn.locked::after { content: '🔒'; position: absolute; top: -3px; left: -3px; font-size: 12px; filter: drop-shadow(0 1px 1px #000); }

/* پنجرهٔ ترجمهٔ زندهٔ گفتار (نمایان اما قفل) */
.tr-lock, .tr-unlock { font-size: 20px; }
.tr-select {
  padding: 12px; border-radius: 10px; border: 1px solid var(--olive);
  background: var(--panel); color: var(--text); font-family: inherit; font-size: 16px;
}
.tr-switch { flex-direction: row; align-items: center; gap: 8px; color: var(--text); font-size: 15px; }
.tr-switch input { width: auto; }
.tr-locked-note {
  background: #3a2a12; border: 1px solid var(--amber); color: var(--amber-lt);
  border-radius: 10px; padding: 10px 12px; font-size: 13px; line-height: 1.7;
}
.tr-live { display: flex; align-items: center; gap: 8px; color: var(--ok); font-size: 14px; }
.tr-live[hidden] { display: none; }
.tr-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 0 rgba(76,154,42,.7); animation: trpulse 1.4s infinite; }
@keyframes trpulse { 0% { box-shadow: 0 0 0 0 rgba(76,154,42,.6);} 70% { box-shadow: 0 0 0 8px rgba(76,154,42,0);} 100% { box-shadow: 0 0 0 0 rgba(76,154,42,0);} }
.ptt-hint { display: none; }
.sos-loc { font-size: 12px; direction: ltr; color: #ffb0b0; margin-top: 4px; }
.msg.sos.resolved { opacity: .5; }
.sos-ack { margin-top: 6px; }

/* پویشگرِ رمزینهٔ اتاق (تمیز، بدونِ کنترلِ پخشِ سرگردان) */
.scan-overlay { position: fixed; inset: 0; z-index: 70; background: #05070c; display: flex; flex-direction: column; align-items: center; }
.scan-overlay[hidden] { display: none; }   /* [hidden] باید بر display:flex غلبه کند */
.scan-topbar {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px; color: #fff;
  background: linear-gradient(#000a, transparent); position: relative; z-index: 2;
}
.scan-title { font-weight: 700; font-size: 16px; }
.scan-close {
  width: 38px; height: 38px; border-radius: 50%; border: 1px solid #ffffff44;
  background: #ffffff1a; color: #fff; font-size: 18px; cursor: pointer; line-height: 1;
}
.scan-stage { position: relative; flex: 1; width: 100%; display: flex; align-items: center; justify-content: center; overflow: hidden; }
/* کنترل‌های بومیِ ویدیو را کاملاً پنهان کن تا آیکونِ پخشِ سرگردان دیده نشود */
.scan-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #05070c; pointer-events: none; }
.scan-video::-webkit-media-controls, .scan-video::-webkit-media-controls-start-playback-button,
.scan-video::-webkit-media-controls-play-button, .scan-video::-webkit-media-controls-panel { display: none !important; -webkit-appearance: none; }
.scan-frame { position: relative; width: 240px; height: 240px; border-radius: 18px; box-shadow: 0 0 0 3000px rgba(0,0,0,.5); }
.sc-corner { position: absolute; width: 30px; height: 30px; border: 4px solid var(--amber-lt); }
.sc-corner.tl { top: -2px; right: -2px; border-left: 0; border-bottom: 0; border-radius: 0 14px 0 0; }
.sc-corner.tr { top: -2px; left: -2px; border-right: 0; border-bottom: 0; border-radius: 14px 0 0 0; }
.sc-corner.bl { bottom: -2px; right: -2px; border-left: 0; border-top: 0; border-radius: 0 0 14px 0; }
.sc-corner.br { bottom: -2px; left: -2px; border-right: 0; border-top: 0; border-radius: 0 0 0 14px; }
.scan-hint { color: #fff; text-align: center; padding: 14px 20px 4px; font-size: 15px; }
.scan-overlay .btn-ghost { margin: 4px 0 calc(20px + env(safe-area-inset-bottom)); }
.join-hint { line-height: 1.9; background: var(--panel); border: 1px solid var(--olive); border-radius: 12px; padding: 10px 12px; }

/* پوششِ دوربین */
.cam-overlay { position: fixed; inset: 0; z-index: 65; background: #000; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; }
.cam-overlay[hidden] { display: none; }
.cam-video { width: 100%; max-width: 480px; max-height: 70vh; object-fit: cover; background: #000; }
.cam-controls { display: flex; gap: 16px; padding: 12px; align-items: center; justify-content: center; }
.cam-shot { width: 72px; height: 72px; border-radius: 50%; border: 4px solid #fff; background: radial-gradient(circle at 50% 30%, var(--gold), var(--gold2)); color: #0a1018; font-size: 30px; cursor: pointer; display: flex; align-items: center; justify-content: center; box-shadow: 0 4px 16px rgba(0,0,0,.5); }
.cam-shot:active { transform: scale(.94); }
.cam-shot:disabled { opacity: .5; }

/* پخشِ زندهٔ ویدیوی رسیده */
.live-in { position: fixed; bottom: 90px; left: 12px; z-index: 55; background: #000; border: 2px solid var(--amber); border-radius: 12px; padding: 6px; display: flex; flex-direction: column; gap: 6px; max-width: 180px; }
.live-in[hidden] { display: none; }
.live-in img { width: 160px; border-radius: 8px; display: block; }
.live-who { color: var(--amber-lt); font-size: 12px; }

/* دکمهٔ موقعیتِ زنده (روشن) */
.map-bar .btn-ghost.on { background: var(--danger); color: #fff; border-style: solid; border-color: #ff8a70; }

/* ── پوششِ تمام‌صفحهٔ اعلامِ اضطراری (سرخِ هشداردهنده + نقشهٔ زندهٔ فردِ در خطر) ── */
.sos-layer {
  position: fixed; inset: 0; z-index: 80; overflow: hidden;
  display: flex; flex-direction: column;
  background: transparent; pointer-events: none;   /* حالتِ نوارِ خلاصه: اتاق زیرش کار می‌کند */
}
.sos-layer[hidden] { display: none; }
/* حالتِ آژیرِ تمام‌صفحه (اعلامِ دیده‌نشدهٔ یک هم‌تیمی) */
.sos-layer.full { background: #2a0606; pointer-events: auto; animation: sosflash 1s ease-in-out infinite; }
@keyframes sosflash {
  0%, 100% { background: #2a0606; }
  50%      { background: #5c0f0f; }
}
/* نقشهٔ زندهٔ فردِ در خطر — فقط در حالتِ تمام‌صفحه دیده می‌شود */
.sos-map { position: absolute; inset: 0; width: 100%; height: 100%; display: none; background: #0a1524; touch-action: none; }
.sos-layer.full .sos-map { display: block; }
/* پنلِ اطلاعات: در حالتِ تمام‌صفحه روی نقشه؛ در حالتِ نوار، فقط ته‌صفحه */
.sos-panel {
  position: relative; z-index: 2; margin-top: auto; pointer-events: auto;
  display: flex; flex-direction: column; gap: 10px;
  padding: 12px 16px; padding-bottom: calc(14px + env(safe-area-inset-bottom));
}
.sos-layer.full .sos-panel {
  padding-top: 16px;
  background: linear-gradient(to top, rgba(30,3,3,.94) 55%, rgba(30,3,3,.2) 100%);
}
.sos-alarm-inner {
  background: rgba(120,12,12,.82); border: 2px solid #ff6a5a; border-radius: 16px;
  padding: 16px; text-align: center; color: #fff;
  box-shadow: 0 0 34px rgba(255,60,47,.5); backdrop-filter: blur(3px);
}
.sos-siren-ico { font-size: 46px; line-height: 1; animation: sosshake .7s ease-in-out infinite; }
@keyframes sosshake {
  0%, 100% { transform: rotate(-9deg) scale(1); }
  50%      { transform: rotate(9deg) scale(1.12); }
}
.sos-title { font-size: 26px; font-weight: 900; letter-spacing: 1px; margin-top: 4px; }
.sos-who { font-size: 18px; font-weight: 700; color: #ffd9d2; margin-top: 2px; }
.sos-note { font-size: 14px; color: #ffe9e4; margin-top: 6px; }
.sos-loc { font-size: 13px; direction: ltr; color: #ffc7bf; margin-top: 8px; }
.sos-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.sos-big {
  border: none; border-radius: 12px; padding: 14px; font-family: inherit; font-size: 16px; font-weight: 800; cursor: pointer;
  background: #fff; color: #7a0e0e;
}
.sos-big.ghost { background: transparent; color: #ffd9d2; border: 1px solid #ff8a70; }
.sos-big:active { transform: scale(.97); }
/* نوارِ خلاصهٔ اعلام‌های جاری (اعلامِ خودم / دیده‌شده‌ها) */
.sos-banner { display: flex; flex-direction: column; gap: 6px; }
.sos-banner-row {
  display: flex; align-items: center; gap: 8px;
  background: rgba(70,8,8,.85); border: 1px solid #b6483a; border-radius: 10px; padding: 8px 10px; color: #ffdad3;
}
.sos-dot { font-size: 16px; }
.sos-banner-txt { flex: 1; font-size: 13px; }
.sos-mini {
  border: none; border-radius: 8px; padding: 6px 10px; font-family: inherit; font-size: 13px; font-weight: 700; cursor: pointer;
  background: #ffffff22; color: #fff;
}
.sos-mini.danger { background: var(--danger); color: #fff; }
.sos-mini:active { transform: scale(.94); }

/* ── نوربخشِ عکسِ تمام‌صفحه (lightbox) ─────────────────────────────────────────── */
.lightbox { position: fixed; inset: 0; z-index: 90; background: rgba(3,7,13,.94); display: none; flex-direction: column; touch-action: none; user-select: none; }
.lightbox.open { display: flex; }
.lb-toolbar { display: flex; gap: 8px; justify-content: flex-end; align-items: center; padding: 10px 14px; padding-top: calc(10px + env(safe-area-inset-top)); background: linear-gradient(180deg, rgba(3,7,13,.7), transparent); }
.lb-btn { width: 42px; height: 42px; border-radius: 12px; border: 1px solid var(--line); background: rgba(14,27,48,.9); color: var(--text); display: flex; align-items: center; justify-content: center; font-size: 20px; line-height: 1; text-decoration: none; cursor: pointer; }
.lb-btn:hover { border-color: var(--gold); color: var(--gold2); }
.lb-stage { flex: 1; position: relative; overflow: hidden; display: flex; align-items: center; justify-content: center; min-height: 0; padding: 12px; }
.lb-img { max-width: 100%; max-height: 100%; border-radius: 8px; }

/* ── راهنمای نخستین اجرا ──────────────────────────────────────────────────── */
.hint-overlay { position: fixed; inset: 0; z-index: 95; background: rgba(4,9,16,.86); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; padding: 18px; overflow: auto; }
.hint-overlay[hidden] { display: none; }
.hint-card { width: min(440px,100%); background: linear-gradient(180deg,#0f1d33,#0b1728); border: 1px solid var(--line); border-radius: 18px; padding: 22px; max-height: 92vh; overflow: auto; }
.hint-card h3 { margin: 0 0 14px; font-size: 19px; }
.hint-item { display: flex; gap: 12px; align-items: flex-start; padding: 9px 0; }
.hint-item .hi { width: 44px; height: 44px; border-radius: 12px; background: var(--panel2); border: 1px solid var(--line2); display: flex; align-items: center; justify-content: center; font-size: 22px; flex: none; }
.hint-item .ht { font-size: 13.5px; font-weight: 700; }
.hint-item .hb { font-size: 12.5px; color: var(--muted); line-height: 1.7; margin-top: 2px; }
.hint-card .btn-primary { width: 100%; margin-top: 14px; }

/* ── مدیریتِ کاربران + مجوزها ──────────────────────────────────── */
.user-list { display: flex; flex-direction: column; gap: 6px; max-height: 55vh; overflow-y: auto; padding: 4px 0; }
.user-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; }
.user-row span { flex: 1; font-size: 14px; font-weight: 600; }
.user-actions { display: flex; gap: 6px; }
.user-actions button { font-size: 12px; padding: 5px 10px; border-radius: 8px; border: 1px solid var(--line2); background: var(--panel); color: var(--text); cursor: pointer; }
.user-actions button:active { opacity: .7; }
.user-actions .btn-danger { background: #b91c1c; color: #fff; border-color: #b91c1c; }
.perm-toggle { display: flex; align-items: center; gap: 10px; padding: 11px 14px; background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; font-size: 14px; cursor: pointer; }
.perm-toggle input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--accent); cursor: pointer; flex: none; }
