/* ==========================================================================
   ChatApp — استایل اصلی
   بدون هیچ CDN یا فونت اینترنتی. تنها فونت: NotoSansArabic (محلی)
   ========================================================================== */

@font-face {
  font-family: "NotoArabic";
  src: url("../fonts/NotoSansArabic-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "NotoArabic";
  src: url("../fonts/NotoSansArabic-Medium.ttf") format("truetype");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "NotoArabic";
  src: url("../fonts/NotoSansArabic-Bold.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* ------------------------------------------------------------- متغیرها */
:root {
  /* پشتهٔ فونت: فونت فارسی اول می‌ماند تا متن فارسی درست رندر شود؛ بعد از آن
     فونت‌های ایموجی رنگی و نمادها می‌آیند تا آیکون‌های یونیکد/ایموجی (📊 ⚙ ⋮ ✕ …)
     در سرصفحه‌ها، تاگل‌ها و منوها هیچ‌وقت به‌شکل مربع خالی (tofu) دیده نشوند.
     همهٔ این فونت‌ها از خود سیستم‌عامل می‌آیند؛ هیچ CDN یا فایل اینترنتی لازم نیست. */
  --font: "NotoArabic", "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji",
    "Segoe UI Symbol", "Segoe UI", Tahoma, system-ui, sans-serif;
  /* برای عناصر فقط-آیکون: فونت‌های ایموجی پیش از «Segoe UI Symbol» می‌آیند تا
     ایموجی‌های دارای U+FE0F (⚙️ ℹ️ ⚡️ ⚠️ ☀️ 🎙️ …) واقعاً با شکل ایموجی رندر شوند
     و متن‌نما (مربع/گلیف تک‌رنگ نامناسب) نشوند. نمادهایی که در فونت ایموجی نیستند
     (⋮ ✕ ☰ ★ ➤ ✓) از «Segoe UI Symbol» می‌آیند و رنگ پوسته را از color می‌گیرند. */
  --font-emoji: "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji",
    "Segoe UI Symbol", "NotoArabic", "Segoe UI", Tahoma, system-ui, sans-serif;

  --bg: #f4f6fb;
  --bg-grad-1: #eef2ff;
  --bg-grad-2: #f7f9fc;
  --surface: #ffffff;
  --surface-2: #f7f8fc;
  --surface-3: #eef1f8;
  --line: #e2e6f0;
  --line-strong: #cdd4e4;

  --text: #101a2e;
  --text-dim: #5a6885;
  --text-faint: #8b97ad;

  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef0ff;
  --accent-contrast: #ffffff;
  --accent-grad: linear-gradient(135deg, #5b54f0 0%, #4f46e5 55%, #4338ca 100%);

  --ok: #16a34a;
  --ok-soft: #e7f8ee;
  --warn: #d97706;
  --warn-soft: #fef4e5;
  --danger: #dc2626;
  --danger-soft: #fdecec;

  --bubble-me: linear-gradient(135deg, #5b54f0, #4f46e5);
  --bubble-me-text: #ffffff;
  --bubble-them: #ffffff;
  --bubble-them-text: #101a2e;

  --radius-xl: 22px;
  --radius-lg: 16px;
  --radius: 12px;
  --radius-sm: 9px;

  --shadow-xs: 0 1px 2px rgba(16, 26, 46, .06);
  --shadow-sm: 0 2px 8px rgba(16, 26, 46, .07);
  --shadow: 0 8px 28px rgba(16, 26, 46, .10);
  --shadow-lg: 0 20px 50px rgba(16, 26, 46, .16);

  --header-h: 64px;
  --ring: 0 0 0 3px rgba(79, 70, 229, .22);
}

[data-theme="dark"] {
  --bg: #0b1120;
  --bg-grad-1: #0e1526;
  --bg-grad-2: #080d18;
  --surface: #141c2f;
  --surface-2: #1a2340;
  --surface-3: #202b4a;
  --line: #26314e;
  --line-strong: #35436a;

  --text: #eef2fb;
  --text-dim: #a3b0cb;
  --text-faint: #7383a3;

  --accent: #7c7bff;
  --accent-hover: #918fff;
  --accent-soft: #1e2450;
  --accent-contrast: #0b1120;
  --accent-grad: linear-gradient(135deg, #6f6bf5 0%, #5b54f0 60%, #4f46e5 100%);

  --ok: #34d399;
  --ok-soft: #10291f;
  --warn: #fbbf24;
  --warn-soft: #2b2109;
  --danger: #f87171;
  --danger-soft: #2c1417;

  --bubble-me: linear-gradient(135deg, #5b54f0, #4a41d6);
  --bubble-me-text: #ffffff;
  --bubble-them: #1a2340;
  --bubble-them-text: #eef2fb;

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-sm: 0 2px 10px rgba(0, 0, 0, .35);
  --shadow: 0 10px 30px rgba(0, 0, 0, .45);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, .6);
  --ring: 0 0 0 3px rgba(124, 123, 255, .28);
}

/* ---------------------------------------------------------------- پایه */
*, *::before, *::after { box-sizing: border-box; }

html {
  height: 100%;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.75;
  color: var(--text);
  background: var(--bg);
  background-image:
    radial-gradient(1100px 480px at 100% -10%, var(--bg-grad-1), transparent 60%),
    radial-gradient(900px 420px at 0% 0%, var(--bg-grad-2), transparent 55%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-wrap: break-word;
}

body.no-scroll { overflow: hidden; }

h1, h2, h3, h4, p, figure { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
img { max-width: 100%; display: block; }

a {
  color: var(--accent);
  text-decoration: none;
  transition: color .15s ease;
}
a:hover { color: var(--accent-hover); text-decoration: underline; text-underline-offset: 3px; }

button, input, textarea, select {
  font: inherit;
  color: inherit;
}

::selection { background: var(--accent); color: #fff; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* اسکرول‌بار */
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 99px;
  border: 2px solid transparent;
  background-clip: content-box;
}
*::-webkit-scrollbar-thumb:hover { background: var(--text-faint); background-clip: content-box; }

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.hidden, [hidden] { display: none !important; }

/* --------------------------------------------------------------- دکمه‌ها */
.btn {
  --btn-bg: var(--surface);
  --btn-fg: var(--text);
  --btn-bd: var(--line-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border: 1px solid var(--btn-bd);
  border-radius: var(--radius);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.4;
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  transition: background .15s ease, border-color .15s ease, transform .08s ease, box-shadow .15s ease, color .15s ease;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] {
  opacity: .55;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  --btn-bg: var(--accent);
  --btn-fg: var(--accent-contrast);
  --btn-bd: transparent;
  background: var(--accent-grad);
  box-shadow: 0 4px 14px rgba(79, 70, 229, .3);
}
[data-theme="dark"] .btn-primary { --btn-fg: #fff; }
.btn-primary:hover {
  background: var(--accent-hover);
  filter: brightness(1.05);
  box-shadow: 0 6px 20px rgba(79, 70, 229, .38);
}

.btn-ghost {
  --btn-bg: transparent;
  --btn-bd: transparent;
  --btn-fg: var(--text-dim);
}
.btn-ghost:hover { background: var(--surface-3); color: var(--text); }

.btn-outline {
  --btn-bg: transparent;
  --btn-bd: var(--line-strong);
  --btn-fg: var(--text-dim);
}
.btn-outline:hover { --btn-fg: var(--text); border-color: var(--accent); color: var(--accent); }

.btn-danger {
  --btn-bg: var(--danger-soft);
  --btn-bd: transparent;
  --btn-fg: var(--danger);
}
.btn-danger:hover { background: var(--danger); color: #fff; }

.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: var(--radius-sm); }
.btn-lg { padding: 13px 26px; font-size: 15px; border-radius: var(--radius-lg); }
.btn-block { width: 100%; }

.btn-icon {
  padding: 0;
  width: 40px;
  height: 40px;
  min-width: 40px;
  min-height: 40px;
  border-radius: 50%;
  flex: 0 0 auto;
  font-family: var(--font-emoji);
  font-size: 17px;
  line-height: 1;
}
.btn-icon.btn-sm { width: 32px; height: 32px; min-width: 32px; min-height: 32px; }

.btn .spinner { width: 16px; height: 16px; border-width: 2px; }

/* ---------------------------------------------------------------- فرم‌ها */
.field { margin-bottom: 16px; }

.label {
  display: block;
  margin-bottom: 7px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-dim);
}

.input, .textarea, .select {
  display: block;
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.input::placeholder, .textarea::placeholder { color: var(--text-faint); }
.input:hover, .textarea:hover, .select:hover { border-color: var(--text-faint); }
.input:focus, .textarea:focus, .select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--ring);
}
.input:disabled, .textarea:disabled {
  background: var(--surface-3);
  color: var(--text-faint);
  cursor: not-allowed;
}

.textarea { resize: vertical; min-height: 92px; }

.select {
  appearance: none;
  -webkit-appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--text-dim) 50%),
    linear-gradient(135deg, var(--text-dim) 50%, transparent 50%);
  background-position: calc(14px) calc(50% + 1px), calc(19px) calc(50% + 1px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-left: 34px;
}

.hint {
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-faint);
  line-height: 1.65;
}

.error-text {
  margin-top: 6px;
  font-size: 12.5px;
  color: var(--danger);
  min-height: 0;
}

.form-error {
  padding: 10px 14px;
  margin-bottom: 14px;
  border-radius: var(--radius);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 13px;
  border: 1px solid transparent;
}

.form-ok {
  padding: 10px 14px;
  margin-bottom: 14px;
  border-radius: var(--radius);
  background: var(--ok-soft);
  color: var(--ok);
  font-size: 13px;
}

.check {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13.5px;
  color: var(--text-dim);
  cursor: pointer;
}
.check input { width: 17px; height: 17px; accent-color: var(--accent); cursor: pointer; }

/* ---------------------------------------------------------------- کارت */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
}

.card-pad { padding: 26px; }

/* ---------------------------------------------------------------- بج */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: 99px;
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1.8;
  background: var(--surface-3);
  color: var(--text-dim);
  white-space: nowrap;
}
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-accent { background: var(--accent-soft); color: var(--accent); }

.badge-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 99px;
  background: var(--accent);
  color: #fff;
  font-size: 11.5px;
  font-weight: 700;
  line-height: 1;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: 0 0 auto;
  background: var(--text-faint);
}
.dot-online { background: var(--ok); box-shadow: 0 0 0 3px rgba(22, 163, 74, .18); }

/* -------------------------------------------------------------- آواتار */
.avatar {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
  font-size: 15px;
  user-select: none;
  overflow: hidden;
}
.avatar-sm { width: 34px; height: 34px; font-size: 13px; }
.avatar-lg { width: 60px; height: 60px; font-size: 22px; }
.avatar-grad {
  background: var(--accent-grad);
  color: #fff;
}

/* --------------------------------------------------------------- اسپینر */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2.5px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  vertical-align: middle;
  opacity: .8;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-block {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 48px 20px;
  color: var(--text-faint);
  font-size: 14px;
}

/* ---------------------------------------------------------------- توست */
.toast-wrap {
  position: fixed;
  z-index: 200;
  inset-inline-end: 18px;
  bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: min(380px, calc(100vw - 36px));
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  font-size: 13.5px;
  line-height: 1.6;
  pointer-events: auto;
  animation: toast-in .22s cubic-bezier(.22, 1, .36, 1);
}
.toast.is-out { animation: toast-out .18s ease forwards; }
.toast-ok { border-color: transparent; background: var(--ok); color: #fff; }
.toast-err { border-color: transparent; background: var(--danger); color: #fff; }
.toast-info { border-inline-start: 3px solid var(--accent); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(12px) scale(.97); }
  to { opacity: 1; transform: none; }
}
@keyframes toast-out {
  to { opacity: 0; transform: translateY(8px) scale(.97); }
}

/* --------------------------------------------------------------- خالی */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 56px 24px;
  text-align: center;
  color: var(--text-faint);
}
.empty-icon {
  display: grid;
  place-items: center;
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: var(--surface-3);
  font-family: var(--font-emoji);
  font-size: 28px;
  line-height: 1;
  margin-bottom: 4px;
}
.empty-title { font-size: 15px; font-weight: 500; color: var(--text-dim); }
.empty-text { font-size: 13px; max-width: 320px; line-height: 1.8; }

/* --------------------------------------------------------------- مودال */
.modal-back {
  position: fixed;
  inset: 0;
  z-index: 150;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(8, 12, 24, .55);
  backdrop-filter: blur(3px);
  animation: fade-in .16s ease;
}

.modal {
  width: 100%;
  max-width: 460px;
  max-height: min(88vh, 720px);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: modal-in .2s cubic-bezier(.22, 1, .36, 1);
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
}
.modal-head h3 { font-size: 15.5px; font-weight: 700; }
.modal-body { padding: 22px; overflow-y: auto; }
.modal-foot {
  display: flex;
  gap: 10px;
  justify-content: flex-start;
  padding: 16px 22px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
}

@keyframes fade-in { from { opacity: 0; } }
@keyframes modal-in {
  from { opacity: 0; transform: translateY(14px) scale(.97); }
  to { opacity: 1; transform: none; }
}

/* ============================================================ صفحه‌ی ورود */
.auth-wrap {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 18px;
  gap: 18px;
}

.auth-card {
  width: 100%;
  max-width: 430px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  padding: 34px 30px 30px;
  animation: modal-in .3s cubic-bezier(.22, 1, .36, 1);
}

.auth-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  margin-bottom: 26px;
  text-align: center;
}
.auth-logo {
  display: grid;
  place-items: center;
  width: 62px;
  height: 62px;
  border-radius: 19px;
  background: var(--accent-grad);
  color: #fff;
  font-size: 27px;
  box-shadow: 0 10px 26px rgba(79, 70, 229, .34);
}
.auth-title { font-size: 20px; font-weight: 700; letter-spacing: -.2px; }
.auth-sub { font-size: 13.5px; color: var(--text-dim); line-height: 1.8; }

.auth-foot {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  font-size: 12.5px;
  color: var(--text-faint);
  text-align: center;
  line-height: 1.9;
}

.code-input {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 19px;
  letter-spacing: 4px;
  text-align: center;
  text-transform: uppercase;
  direction: ltr;
}

.page-foot {
  font-size: 12px;
  color: var(--text-faint);
  text-align: center;
  line-height: 1.9;
}

/* ======================================================== پوسته‌ی چت */
.chat-shell {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 900px;
  margin: 0 auto;
  background: var(--surface);
  border-inline: 1px solid var(--line);
  box-shadow: 0 0 60px rgba(16, 26, 46, .06);
}

.chat-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  min-height: var(--header-h);
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  z-index: 5;
}
.chat-head-main { flex: 1 1 auto; min-width: 0; }
.chat-head-title {
  font-size: 15px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  line-height: 1.4;
}
.chat-head-sub {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-faint);
  line-height: 1.6;
  margin-top: 1px;
}
.chat-head-actions { display: flex; align-items: center; gap: 4px; }

.chat-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 20px 18px 8px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  background:
    radial-gradient(700px 300px at 50% 0%, var(--accent-soft), transparent 70%),
    var(--surface);
}

.chat-foot {
  border-top: 1px solid var(--line);
  background: var(--surface);
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom, 0px));
}

.chat-notice {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  margin: 0 0 8px;
  border-radius: var(--radius);
  background: var(--warn-soft);
  color: var(--warn);
  font-size: 12.5px;
  line-height: 1.7;
}
.chat-notice.danger { background: var(--danger-soft); color: var(--danger); }

/* --------- تاریخ ---------- */
.day-sep {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 14px 0 10px;
  color: var(--text-faint);
  font-size: 11.5px;
  user-select: none;
}
.day-sep::before, .day-sep::after {
  content: "";
  flex: 1 1 auto;
  height: 1px;
  background: var(--line);
}
.day-sep span {
  padding: 3px 12px;
  border-radius: 99px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}

/* --------- پیام ---------- */
.msg {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin-top: 2px;
  animation: msg-in .22s cubic-bezier(.22, 1, .36, 1);
}
.msg.first { margin-top: 12px; }
/* نسخهٔ ۲.۱۰: چیدمان تلگرامی در RTL — حباب «خودی» سمت راست (flex-start)
   و حباب طرف مقابل سمت چپ (flex-end). قبلاً برعکس بود. */
.msg.me { justify-content: flex-start; }
.msg.them { justify-content: flex-end; }

@keyframes msg-in {
  from { opacity: 0; transform: translateY(7px); }
  to { opacity: 1; transform: none; }
}

.bubble {
  position: relative;
  max-width: min(78%, 560px);
  padding: 9px 14px 7px;
  border-radius: 18px;
  font-size: 14.5px;
  line-height: 1.85;
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: var(--shadow-xs);
}
.msg.them .bubble {
  background: var(--bubble-them);
  color: var(--bubble-them-text);
  border: 1px solid var(--line);
  border-end-end-radius: 6px;
}
.msg.me .bubble {
  background: var(--bubble-me);
  color: var(--bubble-me-text);
  border-end-start-radius: 6px;
  border: 1px solid transparent;
}

/* متن پیام: جهت هر پاراگراف از روی محتوای خودش تعیین می‌شود
   تا پیام انگلیسی وسط گفتگوی فارسی درست بچیند */
.bubble-text {
  display: block;
  white-space: pre-wrap;
  word-break: break-word;
  unicode-bidi: plaintext;
}

.bubble-meta {
  display: flex;
  align-items: center;
  gap: 5px;
  justify-content: flex-end;
  margin-top: 2px;
  font-size: 10.5px;
  line-height: 1.5;
  opacity: .68;
  user-select: none;
}
.msg.me .bubble-meta { color: #eaf0ff; }
[data-theme="dark"] .msg.them .bubble-meta { color: var(--text-faint); }

.tick { display: inline-flex; align-items: center; font-size: 12px; letter-spacing: -2px; }
/* نسخهٔ ۲.۱۰: تیک دوم خوانده‌شده — آبی واتساپ */
.tick.read { color: #34b7f1; opacity: 1; }
.tick.read { opacity: 1; }

.msg-sys {
  align-self: center;
  max-width: min(88%, 520px);
  margin: 10px 0;
  padding: 8px 16px;
  border-radius: 99px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text-faint);
  font-size: 12px;
  line-height: 1.8;
  text-align: center;
}

/* --------- تایپینگ ---------- */
.typing-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 26px;
  padding: 2px 6px;
  font-size: 12px;
  color: var(--text-faint);
  transition: opacity .2s ease;
  opacity: 0;
}
.typing-row.on { opacity: 1; }

.typing-dots { display: inline-flex; gap: 3px; align-items: center; }
.typing-dots i {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--text-faint);
  animation: blink 1.3s infinite ease-in-out;
}
.typing-dots i:nth-child(2) { animation-delay: .18s; }
.typing-dots i:nth-child(3) { animation-delay: .36s; }
@keyframes blink {
  0%, 60%, 100% { opacity: .28; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

/* --------- نوار نوشتن ---------- */
.composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 6px 6px 6px 8px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  background: var(--surface-2);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.composer:focus-within {
  border-color: var(--accent);
  box-shadow: var(--ring);
  background: var(--surface);
}

.composer-input {
  flex: 1 1 auto;
  min-width: 0;
  max-height: 148px;
  padding: 9px 8px;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 14.5px;
  line-height: 1.8;
  resize: none;
  outline: none;
  overflow-y: auto;
}
.composer-input::placeholder { color: var(--text-faint); }

.composer-send {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 50%;
  background: var(--accent-grad);
  color: #fff;
  font-size: 18px;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .15s ease, opacity .15s ease;
  box-shadow: 0 3px 12px rgba(79, 70, 229, .34);
}
.composer-send:hover:not(:disabled) { transform: scale(1.06); }
.composer-send:active:not(:disabled) { transform: scale(.95); }
.composer-send:disabled {
  opacity: .4;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.composer-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 4px 0;
  font-size: 11px;
  color: var(--text-faint);
  user-select: none;
}
.counter.warn { color: var(--warn); font-weight: 500; }
.counter.over { color: var(--danger); font-weight: 700; }

/* --------- دکمه‌ی پرش به آخر ---------- */
.jump-latest {
  position: absolute;
  inset-inline-start: 50%;
  transform: translateX(-50%) translateY(6px);
  bottom: 14px;
  z-index: 4;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 15px;
  border-radius: 99px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--accent);
  font-size: 12.5px;
  font-weight: 500;
  box-shadow: var(--shadow);
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
}
.jump-latest.show { opacity: 1; pointer-events: auto; transform: translateX(-50%) translateY(0); }

/* --------- کد بازیابی ---------- */
.code-box {
  display: inline-block;
  padding: 10px 20px;
  border-radius: var(--radius);
  background: var(--surface-3);
  border: 1px dashed var(--line-strong);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 4px;
  direction: ltr;
  unicode-bidi: embed;
  color: var(--text);
  user-select: all;
  cursor: copy;
}

/* کلید دو مرحله‌ای در پنجره‌ی تأیید: طولانی است و باید بشکند */
.code-box-wrap {
  display: block;
  font-size: 15px;
  letter-spacing: 1px;
  line-height: 1.8;
  word-break: break-all;
  text-align: center;
}

/* فهرست کدهای بازیابی */
.code-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 6px;
}
.code-list .code-box {
  display: block;
  padding: 8px 10px;
  font-size: 15px;
  letter-spacing: 2px;
  text-align: center;
}

/* ========================================================= پنل مدیریت */
.admin-shell {
  display: grid;
  grid-template-columns: 356px 1fr;
  height: 100dvh;
  background: var(--surface);
}

/* --------- ستون گفتگوها ---------- */
.side {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-inline-end: 1px solid var(--line);
  background: var(--surface-2);
}

.side-head {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.side-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.side-brand-name {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.4;
}
.side-brand-sub { font-size: 11.5px; color: var(--text-faint); line-height: 1.6; }
.side-brand-text { flex: 1 1 auto; min-width: 0; }
.side-brand-actions { display: flex; align-items: center; gap: 1px; flex: 0 0 auto; }
.side-foot {
  padding: 9px 14px;
  border-top: 1px solid var(--line);
  background: var(--surface);
  font-size: 11.5px;
  color: var(--text-faint);
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  min-width: 34px;
  min-height: 34px;
  flex: 0 0 auto;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-dim);
  font-family: var(--font-emoji);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  transition: background .14s ease, color .14s ease;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn.active { background: var(--accent-soft); color: var(--accent); }

.side-search { position: relative; }
.side-search .input { padding-inline-start: 38px; font-size: 13px; padding-block: 9px; }
.side-search .search-ico {
  position: absolute;
  inset-inline-start: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-faint);
  font-family: var(--font-emoji);
  font-size: 15px;
  line-height: 1;
  pointer-events: none;
}

.filters {
  display: flex;
  gap: 5px;
  padding: 10px 12px;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  scrollbar-width: none;
}
.filters::-webkit-scrollbar { display: none; }

.chip {
  padding: 5px 12px;
  min-height: 32px;
  border: 1px solid var(--line-strong);
  border-radius: 99px;
  background: var(--surface);
  color: var(--text-dim);
  font-family: var(--font);
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1.6;
  white-space: nowrap;
  cursor: pointer;
  transition: all .14s ease;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip.on {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.chip .n {
  display: inline-block;
  margin-inline-start: 5px;
  padding: 0 5px;
  border-radius: 99px;
  background: rgba(255, 255, 255, .22);
  font-size: 10.5px;
  font-weight: 700;
}
.chip:not(.on) .n { background: var(--surface-3); color: var(--text-faint); }

.conv-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.conv-item {
  display: flex;
  gap: 11px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: background .13s ease;
  border-inline-start: 3px solid transparent;
}
.conv-item:hover { background: var(--surface-3); }
.conv-item.active {
  background: var(--accent-soft);
  border-inline-start-color: var(--accent);
}
.conv-item.unread { background: var(--surface); }
.conv-item.unread .conv-name { font-weight: 700; }

.conv-main { flex: 1 1 auto; min-width: 0; }
.conv-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.conv-name {
  font-size: 13.5px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.conv-time { font-size: 10.5px; color: var(--text-faint); flex: 0 0 auto; }
.conv-preview {
  margin-top: 2px;
  font-size: 12.5px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.7;
}
.conv-preview .me-prefix { color: var(--text-faint); }
.conv-tags { display: flex; gap: 5px; margin-top: 5px; flex-wrap: wrap; }

/* --------- ستون گفتگو ---------- */
.thread {
  position: relative;
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  background: var(--surface);
}

.thread-head {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 18px;
  min-height: var(--header-h);
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.thread-head-main { flex: 1 1 auto; min-width: 0; }
.thread-name {
  font-size: 14.5px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.thread-sub {
  font-size: 11.5px;
  color: var(--text-faint);
  margin-top: 1px;
  display: flex;
  gap: 6px;
  align-items: center;
}

.thread-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 18px 20px 6px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  background: var(--surface);
}

.thread-foot {
  border-top: 1px solid var(--line);
  background: var(--surface);
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px));
}

.thread-note {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 16px;
  background: var(--warn-soft);
  border-top: 1px solid transparent;
  font-size: 12px;
  color: var(--warn);
  line-height: 1.7;
}

/* --------- پنل کنار (جزئیات) ---------- */
.details {
  width: 300px;
  flex: 0 0 auto;
  border-inline-start: 1px solid var(--line);
  background: var(--surface-2);
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.details h4 {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--text-faint);
  margin-bottom: 9px;
}
.detail-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 0;
  font-size: 12.5px;
  border-bottom: 1px dashed var(--line);
}
.detail-row:last-child { border-bottom: 0; }
.detail-row dt { color: var(--text-faint); flex: 0 0 auto; }
.detail-row dd { margin: 0; text-align: end; word-break: break-word; min-width: 0; }

.thread-wrap { display: flex; min-width: 0; flex: 1 1 auto; min-height: 0; }
.thread-inner { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; min-width: 0; }

#messages { display: flex; flex-direction: column; gap: 3px; }
.details-pad { display: flex; flex-direction: column; gap: 18px; }

/* --------- حالت خالی ---------- */
.thread-empty {
  flex: 1 1 auto;
  display: grid;
  place-items: center;
  padding: 40px;
  text-align: center;
  color: var(--text-faint);
  background:
    radial-gradient(600px 300px at 50% 30%, var(--accent-soft), transparent 70%),
    var(--surface);
}
.thread-empty-inner { max-width: 340px; }
.thread-empty h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.thread-empty p { font-size: 13px; line-height: 1.9; }
.thread-empty .kbd-hint { margin-top: 18px; font-size: 11.5px; }

kbd {
  display: inline-block;
  min-width: 20px;
  padding: 1px 6px;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--surface);
  font-family: var(--font);
  font-size: 11px;
  text-align: center;
  color: var(--text-dim);
}

/* --------- منوی کشویی ---------- */
/* لایه‌بندی (بالاترین به پایین‌ترین): toast 200 > modal-back 150 > menu 120 >
   side 90 > scrim 85 > details 80. پس منو همیشه روی پنل‌های کناری می‌افتد و
   مودال/توست روی منو؛ هیچ پنلی روی منو نمی‌افتد. */
.menu {
  position: fixed;
  z-index: 120;
  min-width: 200px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  animation: modal-in .14s ease;
}
.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 36px;
  padding: 9px 12px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.6;
  text-align: start;
  cursor: pointer;
  transition: background .12s ease;
}
/* آیکون/ایموجی هر آیتم منو داخل نخستین <span> است؛ اندازه‌اش جدا از متن
   تعیین می‌شود تا ایموجی دیده شود و اندازهٔ متن فارسی منو تغییر نکند. */
.menu-item > span:first-child {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  min-width: 22px;
  font-family: var(--font-emoji);
  font-size: 17px;
  line-height: 1;
}
.menu-item:hover { background: var(--surface-3); }
.menu-item.danger { color: var(--danger); }
.menu-item.danger:hover { background: var(--danger-soft); }
.menu-sep { height: 1px; margin: 5px 8px; background: var(--line); }

/* ------------------------------------------------------------ ریسپانسیو */
@media (max-width: 1080px) {
  .details { position: fixed; inset-block: 0; inset-inline-end: 0; z-index: 80; box-shadow: var(--shadow-lg); }
}

@media (max-width: 900px) {
  .admin-shell { grid-template-columns: 1fr; }
  .side {
    position: fixed;
    inset-block: 0;
    inset-inline-start: 0;
    width: min(360px, 88vw);
    z-index: 90;
    transform: translateX(0);
    transition: transform .22s cubic-bezier(.22, 1, .36, 1);
    box-shadow: var(--shadow-lg);
  }
  html[dir="rtl"] .side.closed { transform: translateX(102%); }
  html[dir="ltr"] .side.closed { transform: translateX(-102%); }
  .side-scrim {
    position: fixed;
    inset: 0;
    z-index: 85;
    background: rgba(8, 12, 24, .45);
    animation: fade-in .16s ease;
  }
  .thread-head .menu-toggle { display: grid; }
}

@media (min-width: 901px) {
  .menu-toggle { display: none !important; }
  .side-scrim { display: none !important; }
  .side { position: static !important; transform: none !important; box-shadow: none; }
}

@media (max-width: 640px) {
  body { font-size: 14.5px; }
  .chat-shell { border-inline: 0; box-shadow: none; }
  .chat-head { padding: 10px 12px; min-height: 58px; }
  .chat-body { padding: 14px 12px 6px; }
  .bubble { max-width: 86%; font-size: 14px; }
  .auth-card { padding: 26px 20px 22px; border-radius: var(--radius-lg); }
  .thread-body { padding: 14px 12px 6px; }
  .thread-foot { padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px)); }
  .details { width: 100%; }
  .modal-foot { flex-direction: column-reverse; }
  .modal-foot .btn { width: 100%; }
}

/* ------------------------------------------------------- کاهش انیمیشن */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}

/* -------------------------------------------------------------- چاپ */
/* ============================================================ ابزارهای کوچک */
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-20 { margin-top: 20px; }
.mb-4 { margin-bottom: 4px; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.mb-20 { margin-bottom: 20px; }
.text-sm { font-size: 12.5px; }
.text-xs { font-size: 11.5px; }
.text-dim { color: var(--text-dim); }
.text-faint { color: var(--text-faint); }
.text-danger { color: var(--danger); }
.text-center { text-align: center; }
.stack-row { display: flex; gap: 8px; align-items: center; }
.stack-row > * { flex: 1 1 auto; }
.stack-row > .shrink { flex: 0 0 auto; }

/* ============================================================ صفحه‌ی اول */
.landing-card { max-width: 470px; }
.landing-points {
  display: grid;
  gap: 9px;
  margin-top: 22px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}
.landing-point {
  display: flex;
  gap: 11px;
  align-items: flex-start;
  font-size: 12.5px;
  line-height: 1.85;
  color: var(--text-dim);
}
.landing-point .ico {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  margin-top: 1px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13px;
}
.landing-point b { color: var(--text); font-weight: 600; }

/* ================================================== نسخه ۲: اجزای تازه */
.row { display: flex; align-items: center; }
.row.gap-6 { gap: 6px; }
.row.gap-6 > .input { flex: 1 1 auto; min-width: 0; }
.badge-soft {
  background: var(--surface-3);
  color: var(--text-dim);
  border-color: transparent;
}
.badge-warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge-danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.btn-block { width: 100%; justify-content: center; }
.btn-mini {
  height: 28px;
  padding: 0 9px;
  font-size: 11.5px;
  border-radius: 8px;
  gap: 4px;
}
.btn-soft {
  background: var(--surface-3);
  border-color: transparent;
  color: var(--text-dim);
}
.btn-soft:hover { background: var(--accent-soft); color: var(--accent); }

/* ------------------------------------------------------------ پیوست‌ها */
.attach-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 12px 0;
  border-top: 1px dashed var(--line);
}
.attach-item {
  position: relative;
  display: flex;
  gap: 8px;
  align-items: center;
  width: 190px;
  max-width: 100%;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.attach-thumb {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface-3);
  display: grid;
  place-items: center;
  font-size: 17px;
}
.attach-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.attach-thumb-zip { color: var(--accent); }
.attach-meta { flex: 1 1 auto; min-width: 0; }
.attach-name {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  direction: ltr;
  text-align: right;
}
.attach-sub { font-size: 10.5px; color: var(--text-faint); margin-top: 2px; }
.attach-remove {
  position: absolute;
  top: -7px;
  inset-inline-end: -7px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--danger);
  font-size: 11px;
  line-height: 1;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.attach-progress-bar {
  position: absolute;
  inset-inline: 0;
  bottom: 0;
  height: 3px;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  background: var(--surface-3);
  overflow: hidden;
}
.attach-progress-fill {
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.15s ease;
}

.att-image { display: block; margin-bottom: 6px; max-width: 260px; }
.att-img {
  display: block;
  max-width: 100%;
  max-height: 240px;
  border-radius: 10px;
  cursor: zoom-in;
  border: 1px solid rgba(0, 0, 0, 0.06);
}
.att-file {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  margin-bottom: 4px;
  border-radius: var(--radius-sm);
  background: rgba(127, 127, 127, 0.12);
  text-decoration: none;
  color: inherit;
}
.att-file:hover { background: rgba(127, 127, 127, 0.2); }
.att-file-icon { font-family: var(--font-emoji); font-size: 19px; line-height: 1; }
.att-file-info { min-width: 0; }
.att-file-name {
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
  direction: ltr;
  text-align: right;
}
.att-file-size { font-size: 10.5px; opacity: 0.72; margin-top: 2px; }
.composer-attach {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  min-width: 34px;
  min-height: 34px;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--text-dim);
  font-family: var(--font-emoji);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
.composer-attach:hover:not(:disabled) { background: var(--accent-soft); color: var(--accent); }
.composer-attach:disabled { opacity: 0.35; cursor: not-allowed; }
.composer.dropping { outline: 2px dashed var(--accent); outline-offset: -6px; border-radius: var(--radius-lg); }

/* ----------------------------------------------------------- لایت‌باکس */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  padding: 28px;
  background: rgba(9, 12, 20, 0.86);
  backdrop-filter: blur(3px);
}
.lightbox.hidden { display: none; }
.lightbox-img {
  max-width: min(94vw, 1100px);
  max-height: 84vh;
  border-radius: 12px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
  background: #fff;
}
.lightbox-cap {
  margin-top: 12px;
  color: #e6ebf5;
  font-size: 12px;
  text-align: center;
  max-width: 80vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  direction: ltr;
}
.lightbox-close {
  position: absolute;
  top: 18px;
  inset-inline-end: 20px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: 16px;
  cursor: pointer;
}

/* ------------------------------------------------------------ ستاره‌ها */
.stars { display: inline-flex; gap: 2px; align-items: center; line-height: 1; }
.star { color: var(--line-strong); font-size: 13px; }
.star.on { color: #f3b13b; }
.stars-big .star { font-size: 20px; }
.stars-input { display: inline-flex; gap: 6px; direction: ltr; }
.stars-input .star-btn {
  border: none;
  background: transparent;
  font-size: 26px;
  line-height: 1;
  color: var(--line-strong);
  cursor: pointer;
  padding: 0 2px;
  transition: transform 0.12s ease, color 0.12s ease;
}
.stars-input .star-btn.on { color: #f3b13b; }
.stars-input .star-btn:hover { transform: scale(1.12); }
.notice-stars {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  background: var(--warn-soft);
  color: var(--text);
  font-size: 12px;
}
.rating-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.rating-num { font-size: 12px; font-weight: 600; color: var(--text); }
.rating-comment {
  font-size: 12px;
  line-height: 1.8;
  color: var(--text-dim);
  margin: 0;
}

/* --------------------------------------------------- پیام حذف‌شده */
.bubble-deleted {
  font-style: italic;
  opacity: 0.72;
  font-size: 12px;
}
.msg-del {
  position: absolute;
  top: 4px;
  inset-inline-start: -26px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text-faint);
  font-size: 11px;
  line-height: 1;
  display: grid;
  place-items: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.12s ease;
}
.msg:hover .msg-del { opacity: 1; }
.msg-del:hover { color: var(--danger); border-color: var(--danger); }

/* -------------------------------------------------------- برچسب‌ها */
.tag-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text-dim);
  font-size: 11px;
  line-height: 1.7;
  cursor: pointer;
}
.tag-chip:hover { border-color: var(--accent); color: var(--accent); }
.tag-chip.static { cursor: default; }
.tag-x {
  border: none;
  background: transparent;
  color: var(--text-faint);
  font-size: 10px;
  padding: 0;
  line-height: 1;
  cursor: pointer;
}
.tag-x:hover { color: var(--danger); }
.tag-count { font-size: 10px; opacity: 0.7; }
.thread-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 4px;
}
.filters-adv {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}
.filters-adv.hidden { display: none; }
.chip-soft {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 32px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text-dim);
  font-family: var(--font);
  font-size: 12px;
  line-height: 1.6;
  cursor: pointer;
}
.chip-soft.active { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

/* ------------------------------------------------------ داشبورد آمار */
.dash { display: flex; flex-direction: column; gap: 14px; }
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
}
.kpi {
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.kpi-value { font-size: 19px; font-weight: 700; color: var(--text); }
.kpi-label { font-size: 11.5px; color: var(--text-dim); margin-top: 3px; }
.kpi-sub { font-size: 10.5px; color: var(--text-faint); margin-top: 2px; }
.chart-svg { width: 100%; height: auto; display: block; }
.chart-grid { stroke: var(--line); stroke-width: 1; }
.chart-line { fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.chart-line.visitor { stroke: var(--accent); }
.chart-line.admin { stroke: var(--ok); stroke-dasharray: 4 3; }
.chart-label { fill: var(--text-faint); font-size: 9px; font-family: var(--font); }
.chart-legend { display: flex; gap: 14px; font-size: 11px; color: var(--text-dim); }
.chart-legend .lg { display: inline-flex; align-items: center; gap: 5px; }
.chart-legend .lg::before {
  content: "";
  width: 14px;
  height: 2px;
  border-radius: 2px;
  background: var(--accent);
}
.chart-legend .lg.admin::before { background: var(--ok); }

/* ------------------------------------------------------ گزارش رویداد */
.audit-list { display: flex; flex-direction: column; gap: 8px; max-height: 52vh; overflow: auto; }
.audit-row {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.audit-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.audit-time { font-size: 10.5px; color: var(--text-faint); }
.audit-main { font-size: 12px; color: var(--text); margin-top: 5px; }
.audit-detail { font-size: 11.5px; color: var(--text-dim); margin-top: 3px; line-height: 1.7; }

/* ------------------------------------------------------ پاسخ‌های آماده */
.canned-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
  max-height: 46vh;
  overflow: auto;
}
.canned-item {
  display: block;
  width: 100%;
  text-align: right;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  cursor: pointer;
  font-family: inherit;
}
.canned-item:hover { border-color: var(--accent); background: var(--accent-soft); }
.canned-manage { display: flex; align-items: flex-start; gap: 8px; cursor: default; }
.canned-manage:hover { border-color: var(--line); background: var(--surface-2); }
.canned-main { flex: 1 1 auto; min-width: 0; }
.canned-title { font-size: 12px; font-weight: 600; color: var(--text); }
.canned-body {
  font-size: 11.5px;
  color: var(--text-dim);
  margin-top: 3px;
  line-height: 1.75;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ------------------------------------------------------------ مدیران */
.admin-list { display: flex; flex-direction: column; gap: 7px; max-height: 40vh; overflow: auto; }
.admin-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.admin-main { flex: 1 1 auto; min-width: 0; }
.admin-name {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}
.avatar-sm { width: 28px; height: 28px; font-size: 11px; }
.tool-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }

/* ------------------------------------------------------ فهرست فایل‌ها */
.files-list { display: flex; flex-direction: column; gap: 6px; }
.file-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.file-row-ico { font-size: 16px; line-height: 1; }
.file-row-main { flex: 1 1 auto; min-width: 0; }
.file-row-name {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  direction: ltr;
  text-align: right;
}

@media (max-width: 640px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .attach-item { width: 100%; }
  .tool-grid { grid-template-columns: 1fr; }
}

/* ------------------------------------------------- توقف سراسری ارسال پیام */
/* این نوار بین سرصفحه و بدنه‌ی گفتگو می‌نشیند و با پس‌زمینه‌ی ملایم هشدار از
   پیام‌های معمولی جدا می‌شود؛ انیمیشن کوتاه ورود توجه را جلب می‌کند بدون
   اینکه ارتفاع زیادی از صفحه بگیرد. */
.pause-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex: 0 0 auto;
  margin: 8px 14px 0;
  padding: 9px 14px;
  border: 1px solid rgba(217, 119, 6, .18);
  border-radius: var(--radius);
  background: var(--warn-soft);
  color: var(--warn);
  direction: rtl;
  text-align: right;
  font-size: 12.5px;
  line-height: 1.7;
  animation: pause-banner-in .22s cubic-bezier(.22, 1, .36, 1);
}

.pause-banner__text {
  flex: 1 1 auto;
  min-width: 0;
}

/* دکمه‌ی آرام و کم‌رنگ برای اقدام‌های اختیاری داخل نوار (مثلاً بررسی مجدد وضعیت) */
.pause-banner__btn {
  flex: 0 0 auto;
  padding: 3px 10px;
  border: 1px solid currentColor;
  border-radius: 999px;
  background: transparent;
  color: inherit;
  font-family: inherit;
  font-size: 11px;
  line-height: 1.9;
  cursor: pointer;
  opacity: .72;
  transition: opacity .15s ease, background-color .15s ease;
}
.pause-banner__btn:hover { opacity: 1; background: rgba(217, 119, 6, .14); }
.pause-banner__btn:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }

/* در تم تاریک پس‌زمینه‌ی هشدار تیره‌تر است؛ حاشیه کمی روشن‌تر می‌شود تا نوار
   از سطح اطراف جدا بماند و متن زرد روی آن خوانا باشد */
[data-theme="dark"] .pause-banner {
  border-color: rgba(251, 191, 36, .22);
  background: var(--warn-soft);
  color: var(--warn);
}
[data-theme="dark"] .pause-banner__btn:hover { background: rgba(251, 191, 36, .14); }

@keyframes pause-banner-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: none; }
}

/* در عرض کم، متن و دکمه زیر هم می‌آیند تا متن توقف به‌خاطر کمبود فضا نشکند */
@media (max-width: 600px) {
  .pause-banner {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    margin: 6px 10px 0;
    text-align: center;
  }
  .pause-banner__text { text-align: center; }
  .pause-banner__btn { align-self: center; }
}

@media print {
  .chat-foot, .side, .thread-head, .chat-head-actions, .composer { display: none !important; }
  body { background: #fff; }
  .thread-body, .chat-body { overflow: visible; height: auto; }
  .bubble { box-shadow: none; border: 1px solid #ddd !important; color: #000 !important; background: #f7f7f7 !important; }
}

/* ==========================================================================
   ریسپانسیو آیکون‌ها — لایهٔ محافظ (بدون هیچ کتابخانه)
   --------------------------------------------------------------------------
   هدف: هیچ دکمهٔ آیکونی (`.icon-btn`، `.menu-toggle`، `.composer-attach`،
   `.composer-send`، `.chip` و آیکون‌های `.menu-item`) در هیچ عرضی و در هیچ
   سطحی از زوم (Ctrl+- / Ctrl+=) ناپدید، صفرعرض یا بریده نشود.
   همهٔ قواعد این بخش فقط «جمع‌نشدن، اندازه و سرریز» را تنظیم می‌کنند و هیچ‌جا
   `display: none` روی دکمهٔ آیکونی نمی‌گذارند؛ بنابراین ظاهر، رنگ‌ها و تم
   روشن/تاریک موجود دست‌نخورده می‌ماند. این بخش کاملاً افزودنی است و به
   قواعد قبلی فایل دست نمی‌زند.
   ========================================================================== */

/* ۱) دکمه‌های آیکونی در چیدمان flex جمع نمی‌شوند و عرض/ارتفاعشان صفر نمی‌شود.
   `.chip`ها هم در نوار فیلترها فشرده نمی‌شوند (نوار خودش افقی اسکرول دارد). */
.icon-btn,
.menu-toggle,
.btn-icon,
.composer-attach,
.composer-send,
.chip,
.chip-soft,
.tag-chip {
  flex: 0 0 auto;
  flex-shrink: 0;
}
.icon-btn,
.menu-toggle,
.btn-icon,
.composer-attach,
.composer-send {
  white-space: nowrap;
  /* آیکون‌های یونیکد/ایموجی حتماً با شکل ایموجی رندر شوند تا به‌جای گلیف
     تک‌رنگ یا مربع خالی، شکل درست و خوانا داشته باشند */
  font-variant-emoji: emoji;
}
.icon-btn,
.menu-toggle,
.composer-attach { min-width: 34px; min-height: 34px; }
.btn-icon { min-width: 30px; min-height: 30px; }
.composer-send { min-width: 42px; min-height: 42px; }

/* مقیاس‌پذیری نرم با زوم و عرض: با کوچک‌کردن زوم (Ctrl+-) عرض مؤثر پنجره
   بر حسب CSS پیکسل زیاد می‌شود و این clamp اندازهٔ گلیف را کمی بزرگ‌تر می‌کند
   تا آیکون از نظر فیزیکی ریز و ناخوانا نشود؛ در عرض‌های کوچک هم هرگز از
   ۱۵ پیکسل پایین‌تر نمی‌آید (اندازهٔ پایه: ۱۷px برای دکمهٔ آیکونی). */
.icon-btn,
.menu-toggle { font-size: clamp(15px, 0.45vw + 12px, 19px); }
.composer-attach,
.composer-send { font-size: clamp(16px, 0.5vw + 12px, 20px); }

/* آیکون نخست هر آیتم منو و آیکون‌های تزئینی همیشه با فونت ایموجی و اندازهٔ
   پایدار می‌مانند و در چیدمان فشرده نمی‌شوند */
.menu-item > span:first-child {
  flex: 0 0 auto;
  font-variant-emoji: emoji;
  font-size: clamp(15px, 0.4vw + 12.5px, 18px);
}
.empty-icon,
.att-file-icon,
.file-row-ico,
.landing-point .ico,
.side-search .search-ico { font-variant-emoji: emoji; }

/* آیکون‌های کوچک داخل ردیف‌های flex (تیک پیام، حذف برچسب، ستاره، شمارندهٔ
   چیپ) نباید به‌خاطر کمبود فضا له یا صفر شوند */
.chip .n,
.tag-x,
.star-btn,
.tick { flex: 0 0 auto; }

/* ۲) والدین هدر/فوتر/نوار دکمه‌ها هیچ آیکونی را نمی‌برند.
   قبلاً جایی `overflow` روی این‌ها ست نشده بود؛ این قاعده تضمین می‌کند اگر در
   آینده یا در استایل‌های صفحه‌ای مقدار مخفی بگیرند، دکمه‌های آیکونی بریده
   نشوند. نوارهای اقدام هم خودشان جمع نمی‌شوند. */
.chat-head,
.thread-head,
.side-head,
.chat-foot,
.thread-foot,
.composer,
.chat-head-main,
.thread-head-main,
.side-brand,
.chat-head-actions,
.side-brand-actions {
  overflow: visible;
}
.chat-head-actions,
.side-brand-actions {
  flex: 0 0 auto;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-end;
}
/* در عرض‌های خیلی کم، به‌جای بیرون‌زدن، فاصلهٔ افقی خودشان را کم می‌کنند
   (فاصلهٔ پایهٔ `.side-brand-actions` یک‌پیکسلی است و دست‌نخورده می‌ماند) */
.chat-head-actions { column-gap: min(4px, 1vw); }

/* ۳) منوی کشویی و پنل جزئیات در عرض کم از لبهٔ صفحه بیرون نمی‌زنند و
   آیتم‌هایشان (آیکون + متن) بریده نمی‌شوند */
.menu {
  max-width: calc(100vw - 24px);
  max-height: calc(100vh - 24px);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.menu-item { min-height: 36px; }
.details { max-width: calc(100vw - 24px); }

/* ۴) بریک‌پوینت‌های میانی: فقط فاصله‌ها/پدینگ‌ها کم می‌شوند تا دکمه‌های
   آیکونی جا شوند. هیچ دکمه‌ای در هیچ‌کدام از این‌ها پنهان نمی‌شود.
   (بریک‌پوینت‌های موجود 1080/900/640 دست‌نخورده‌اند.) */
@media (max-width: 1280px) {
  .chat-head,
  .thread-head { gap: 10px; }
  .chat-head-actions { column-gap: 2px; }
  .side-brand-actions { column-gap: 0; }
  .side-head { padding: 11px 12px; }
  .side-brand { gap: 8px; margin-bottom: 10px; }
  .composer { gap: 6px; }
  .filters { gap: 4px; padding: 9px 10px; }
  .chip { padding: 5px 10px; }
}

@media (max-width: 1024px) {
  .chat-head,
  .thread-head { gap: 8px; padding-inline: 14px; }
  .chat-head-actions,
  .side-brand-actions { column-gap: 1px; }
  .composer { gap: 5px; padding: 5px 6px; }
  .composer-foot { gap: 6px; }
  .filters { padding: 8px 10px; }
  .chip { padding: 4px 9px; font-size: 12px; }
  .chip-soft { padding: 4px 8px; }
  .filters-adv { gap: 5px; padding: 7px 10px; }
  .details { padding: 14px; gap: 14px; }
}

@media (max-width: 860px) {
  .chat-head,
  .thread-head { gap: 6px; padding-inline: 12px; }
  .chat-head-actions,
  .side-brand-actions { column-gap: 0; }
  .composer { gap: 4px; padding: 5px; }
  .filters { gap: 3px; padding: 8px; }
  .chip { padding: 4px 8px; }
  .chip-soft { padding: 4px 7px; gap: 4px; }
  .filters-adv { gap: 4px; padding: 6px 8px; }
  /* منو در عرض کم باریک‌تر می‌شود ولی هرگز از صفحه بیرون نمی‌زند */
  .menu { min-width: min(180px, calc(100vw - 24px)); }
}

/* ۵) در پنجره‌های بسیار کوچک هم فقط فاصله‌ها باز هم کم می‌شوند؛ هیچ دکمه‌ای
   حذف و هیچ min-width/min-height‌ای صفر نمی‌شود. ترتیب دکمه‌های آیکونی
   (پیوست/پاسخ آماده/صدا/ارسال) دست‌نخورده می‌ماند. */
@media (max-width: 480px) {
  .chat-head,
  .thread-head { gap: 5px; }
  .composer { gap: 3px; padding: 4px; }
  .side-brand { gap: 6px; }
}

/* این بخش هیچ قاعده‌ای از `@media print` و بریک‌پوینت‌های قبلی (1080/900/640)
   را بازنویسی نمی‌کند؛ فقط قواعد محافظ بالا را در انتهای فایل اضافه می‌کند تا
   ترتیب آبشاری موجود حفظ شود. */

/* ==========================================================================
   اصلاح چیدمان ردیف فیلترها — قرارداد ۲.۸، بند ۶ (task-78)
   --------------------------------------------------------------------------
   قاعدهٔ قبلی `.filters` فقط `overflow-x: auto` + `scrollbar-width: none` بود؛
   در نتیجه در عرض کم، چیپ لبهٔ چپ (در RTL) نیمه‌پنهان می‌شد و کاربر فکر می‌کرد
   بریده شده است. حالا:
   • `flex-wrap: wrap` → وقتی جا نیست چیپ‌ها به خط بعد می‌روند؛ هیچ چیپی
     بیرون کادر نمی‌افتد و هیچ چیپی نیمه دیده نمی‌شود.
   • `overflow-x: auto` + `scrollbar-width: thin` تور ایمنی: اگر یک چیپ
     به‌تنهایی از عرض کادر پهن‌تر باشد (زوم خیلی زیاد)، ردیف با اسکرول افقی
     نازک کاملاً دیدنی است، نه بریده.
   • `overflow-y: hidden` مانع نوار عمودی سرگردان می‌شود؛ `scroll-padding-inline`
     تضمین می‌کند اسکرول تا انتها چیپ لبه را کامل نشان دهد.
   • `.filters-adv` که از قبل wrap داشت هم همین تور ایمنی را می‌گیرد.
   فقط چیدمان/سرریز افزوده شده؛ رنگ، فونت، اندازه و پدینگ‌ها دست‌نخورده‌اند و
   بریک‌پوینت‌های موجود (1280/1024/860/480) هم تغییر نمی‌کنند.
   ========================================================================== */
.filters,
.filters-adv {
  flex-wrap: wrap;
  min-width: 0;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
  scroll-padding-inline: 12px;
}

/* WebKit قدیمی که `scrollbar-width` را نمی‌شناسد: نوار پنهان قبلی را به نوار
   نازک ۴ پیکسلی تبدیل می‌کنیم تا «قابل اسکرول بودن» ردیف پیدا باشد (فقط در
   صورت سرریز واقعی ظاهر می‌شود) */
.filters::-webkit-scrollbar,
.filters-adv::-webkit-scrollbar {
  display: block;
  height: 4px;
  background: transparent;
}
.filters::-webkit-scrollbar-thumb,
.filters-adv::-webkit-scrollbar-thumb {
  border-radius: 99px;
  background: var(--line-strong);
}


/* نسخهٔ ۲.۱۰: نشان «ویرایش‌شده» کنار زمان پیام */
.msg-edited {
  font-size: 10px;
  opacity: .72;
  margin-inline-start: 4px;
  white-space: nowrap;
}
