/* ===== آنتانو — استایل کلی (فارسی / راست‌چین / واکنش‌گرا) ===== */

:root {
  --bg: #0d1017;
  --panel: #151a24;
  --panel-2: #1b2130;
  --border: #262e40;
  --text: #e8ebf2;
  --muted: #8b93a7;
  --accent: #2dd4bf;          /* فیروزه‌ای — رنگ امضای آنتانو */
  --accent-dark: #14b8a6;
  --accent-soft: rgba(45, 212, 191, 0.12);
  --danger: #f87171;
  --gold: #fbbf24;
  --radius: 14px;
  --font: "Vazirmatn", Tahoma, sans-serif;
}

/* تم روشن */
:root[data-theme="light"] {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --panel-2: #eef1f7;
  --border: #d9deea;
  --text: #1a2130;
  --muted: #5c6577;
  --accent: #0d9488;
  --accent-dark: #0f766e;
  --accent-soft: rgba(13, 148, 136, 0.12);
  --danger: #dc2626;
  --gold: #b8860b;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  direction: rtl;
  line-height: 1.9;
}

button { font-family: var(--font); cursor: pointer; }
input, textarea, select { font-family: var(--font); }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; }

/* ================= صفحات ورود / ثبت‌نام / خرید ================= */

.auth-body {
  min-height: 100vh;
  display: flex;
  padding: 20px;
  overflow-y: auto;
  background:
    radial-gradient(600px 300px at 85% 10%, rgba(45,212,191,0.10), transparent),
    radial-gradient(500px 300px at 10% 90%, rgba(99,102,241,0.08), transparent),
    var(--bg);
}
/* margin:auto وسط‌چین می‌کند ولی وقتی محتوا بلندتر از صفحه شد، بالای آن بریده و
   غیرقابل‌اسکرول نمی‌شود (رفع باگِ align-items:center در موبایل) */
.auth-card { margin: auto; }

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 36px 30px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.45);
}

.logo {
  text-align: center;
  margin-bottom: 8px;
  font-size: 34px;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: 1px;
}
.logo small { display: block; font-size: 13px; color: var(--muted); font-weight: 400; letter-spacing: 4px; }

.auth-card h2 { text-align: center; font-size: 18px; font-weight: 600; margin: 14px 0 24px; color: var(--text); }

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field input {
  width: 100%;
  padding: 12px 14px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 15px;
  transition: border-color .2s;
}
.field input:focus { outline: none; border-color: var(--accent); }
.field input.ltr { direction: ltr; text-align: left; }

.btn-primary {
  width: 100%;
  padding: 13px;
  background: var(--accent);
  color: #06251f;
  border: none;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 700;
  transition: background .2s;
}
.btn-primary:hover { background: var(--accent-dark); }
.btn-primary:disabled { opacity: .5; cursor: wait; }

.or-divider { display: flex; align-items: center; gap: 10px; margin: 16px 0; color: var(--muted); font-size: 13px; }
.or-divider::before, .or-divider::after { content: ""; flex: 1; height: 1px; background: var(--border, rgba(128,128,128,.25)); }
.btn-guest {
  width: 100%;
  padding: 13px;
  background: transparent;
  color: var(--accent);
  border: 1.5px solid var(--accent);
  border-radius: 10px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: background .2s, color .2s;
}
.btn-guest:hover { background: var(--accent); color: #06251f; }
.guest-note { text-align: center; font-size: 12px; color: var(--muted); margin: 8px 0 0; }

.auth-links { margin-top: 18px; text-align: center; font-size: 13.5px; color: var(--muted); }
.auth-links a { color: var(--accent); text-decoration: none; }
.auth-links a:hover { text-decoration: underline; }

.error-box {
  background: rgba(248,113,113,0.1);
  border: 1px solid rgba(248,113,113,0.35);
  color: var(--danger);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13.5px;
  margin-bottom: 16px;
}

/* ---- صفحه خرید اشتراک ---- */
.plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 18px 0; }
.plan {
  display: block;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 10px;
  text-align: center;
  color: inherit;
  text-decoration: none;
  transition: transform .12s, border-color .12s, box-shadow .12s;
}
a.plan:hover, a.plan:active { border-color: var(--accent); transform: translateY(-2px); box-shadow: 0 8px 22px rgba(0,0,0,0.25); }
.plan.best { border-color: var(--gold); }
.plan .stars { font-size: 18px; color: var(--gold); }
.plan h3 { font-size: 14px; margin: 5px 0 2px; }
.plan .price { font-size: 18px; font-weight: 800; color: var(--accent); margin: 2px 0 6px; }
.plan p { font-size: 12px; color: var(--muted); line-height: 1.7; margin: 0; }
.plan .buy-hint { display: block; margin-top: 7px; font-size: 11.5px; color: var(--accent); font-weight: 600; }
.contact-box {
  background: var(--accent-soft);
  border: 1px solid rgba(45,212,191,0.3);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  font-size: 14.5px;
}
.wide { max-width: 760px; }
.tg-btn {
  display: inline-block; margin-top: 12px; padding: 10px 22px;
  background: var(--accent); color: #06251f; font-weight: 800; font-size: 14.5px;
  border-radius: 12px; text-decoration: none; transition: background .12s, transform .12s;
}
.tg-btn:hover { background: var(--accent-dark); transform: translateY(-1px); }

/* ================= صفحه چت ================= */

.chat-page { display: flex; height: 100vh; height: 100dvh; overflow: hidden; }

#sidebar {
  width: 280px;
  min-width: 280px;
  background: var(--panel);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: transform .25s ease;
  z-index: 30;
}

.side-top { padding: 16px 14px 10px; }
#newChat {
  width: 100%;
  padding: 11px;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px dashed rgba(45,212,191,0.5);
  border-radius: 10px;
  font-size: 14.5px;
  font-weight: 600;
}
#newChat:hover { background: rgba(45,212,191,0.2); }

#convList { flex: 1; overflow-y: auto; padding: 6px 10px; }
.conv {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 9px 12px;
  border-radius: 9px;
  font-size: 13.5px;
  color: var(--muted);
  cursor: pointer;
  margin-bottom: 3px;
}
.conv:hover { background: var(--panel-2); color: var(--text); }
.conv.active { background: var(--panel-2); color: var(--accent); }
.conv .t { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.conv .del, .conv .ren { background: none; border: none; color: var(--muted); font-size: 13px; opacity: 0; padding: 2px; }
.conv:hover .del, .conv:hover .ren, .conv.active .del, .conv.active .ren { opacity: 1; }
.conv .del:hover { color: var(--danger); }
.conv .ren:hover { color: var(--accent); }

.conv.search-hit { display: block; }
.conv.search-hit .t { display: block; white-space: normal; margin-bottom: 3px; color: var(--text); font-weight: 600; }
.hit-snip {
  font-size: 12px; color: var(--muted); line-height: 1.6;
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.conv-empty { padding: 14px 12px; font-size: 13px; color: var(--muted); text-align: center; }

.side-bottom { border-top: 1px solid var(--border); padding: 12px 14px; }
.user-box { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; font-size: 14px; }
.badge {
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 20px;
}
.side-link {
  display: block;
  width: 100%;
  text-align: right;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 13.5px;
  padding: 7px 4px;
  text-decoration: none;
}
.side-link:hover { color: var(--text); }
.side-link.danger:hover { color: var(--danger); }

main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: rgba(13,16,23,0.8);
  backdrop-filter: blur(8px);
}
#menuBtn { display: none; background: none; border: none; color: var(--text); font-size: 22px; }
header h1 { font-size: 18px; font-weight: 700; color: var(--accent); }
header h1 span { font-size: 11px; color: var(--muted); letter-spacing: 3px; margin-right: 6px; }
.limit-note { margin-right: auto; font-size: 12px; color: var(--muted); }

#messages { flex: 1; overflow-y: auto; padding: 24px 16px; }
.msgs-inner, .msg { max-width: 820px; margin-inline: auto; }

#welcome { text-align: center; color: var(--muted); padding-top: 12vh; }
#welcome .big { font-size: 42px; margin-bottom: 12px; }
#welcome h2 { color: var(--text); font-size: 22px; margin-bottom: 8px; }
#welcome p { font-size: 14px; max-width: 460px; margin-inline: auto; }

.msg { display: flex; gap: 12px; margin-bottom: 22px; }
.msg .avatar {
  width: 36px; height: 36px; min-width: 36px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  background: var(--panel-2);
  border: 1px solid var(--border);
}
.msg.assistant .avatar { background: var(--accent-soft); border-color: rgba(45,212,191,0.35); }

.bubble { flex: 1; min-width: 0; }
.msg.user .md {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 15px;
}
.msg.assistant .md { font-size: 15.5px; word-break: break-word; }

.md h1, .md h2, .md h3 { margin: 14px 0 8px; color: var(--accent); font-size: 1.05em; }
.md p { margin-bottom: 10px; }
.md ul, .md ol { margin: 8px 24px 12px 0; }
.md li { margin-bottom: 4px; }
.md code {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1px 6px;
  font-size: 13px;
  direction: ltr;
  display: inline-block;
}
.md pre {
  background: #0a0d13;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  overflow-x: auto;
  direction: ltr;
  text-align: left;
  margin: 10px 0;
}
.md pre code { background: none; border: none; padding: 0; }
.md table { border-collapse: collapse; margin: 10px 0; width: 100%; font-size: 14px; }
.md th, .md td { border: 1px solid var(--border); padding: 7px 10px; }
.md th { background: var(--panel-2); }
.md blockquote { border-right: 3px solid var(--accent); padding-right: 12px; color: var(--muted); margin: 10px 0; }

.typing { color: var(--muted); font-size: 14px; }
.typing::after { content: ""; animation: dots 1.2s infinite; }
@keyframes dots { 0% { content: ""; } 33% { content: "."; } 66% { content: ".."; } 100% { content: "..."; } }

.actions { display: flex; gap: 6px; margin-top: 8px; }
.act {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  padding: 4px 11px;
  border-radius: 20px;
  transition: all .15s;
}
.act:hover { color: var(--accent); border-color: var(--accent); }

footer { padding: 12px 16px 14px; border-top: 1px solid var(--border); }
.inputbar {
  max-width: 820px;
  margin-inline: auto;
  display: flex;
  gap: 10px;
  align-items: flex-end;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 10px 12px;
  transition: border-color .2s;
}
.inputbar:focus-within { border-color: var(--accent); }
#input {
  flex: 1;
  background: none;
  border: none;
  resize: none;
  color: var(--text);
  font-size: 15px;
  line-height: 1.8;
  max-height: 160px;
}
#input:focus { outline: none; }
#send {
  background: var(--accent);
  color: #06251f;
  border: none;
  border-radius: 10px;
  padding: 9px 20px;
  font-size: 14.5px;
  font-weight: 700;
}
#send:hover { background: var(--accent-dark); }
#send:disabled { opacity: .5; cursor: wait; }
.hint { text-align: center; font-size: 11.5px; color: var(--muted); margin-top: 8px; }

/* ---- اعلان کوتاه ---- */
#toast {
  position: fixed;
  bottom: 90px;
  right: 50%;
  transform: translateX(50%);
  background: var(--panel-2);
  border: 1px solid var(--accent);
  color: var(--text);
  padding: 9px 20px;
  border-radius: 30px;
  font-size: 13.5px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s;
  z-index: 100;
}
#toast.show { opacity: 1; }

/* ---- پنجره حافظه ---- */
#memOverlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 16px;
}
#memOverlay.show { display: flex; }
.mem-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  width: 100%;
  max-width: 560px;
  max-height: 75vh;
  display: flex;
  flex-direction: column;
}
.mem-panel header { border: none; padding: 16px 20px 8px; }
.mem-panel h3 { color: var(--accent); font-size: 16px; }
.mem-panel .close { margin-right: auto; background: none; border: none; color: var(--muted); font-size: 20px; }
.mem-list { overflow-y: auto; padding: 8px 20px 20px; }
.mem-item {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13.5px;
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
}
.mem-item button { background: none; border: none; color: var(--danger); font-size: 13px; }
.mem-empty { color: var(--muted); font-size: 13.5px; text-align: center; padding: 20px; }

/* ================= پنل مدیریت ================= */

.admin-body { padding: 24px 16px 60px; max-width: 1050px; margin-inline: auto; }
.admin-body h1 { color: var(--accent); font-size: 22px; margin-bottom: 4px; }
.admin-body .sub { color: var(--muted); font-size: 13.5px; margin-bottom: 24px; }
.admin-body .sub a { color: var(--accent); }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 22px;
}
.card h2 { font-size: 16px; margin-bottom: 14px; color: var(--text); }

.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row input, .row select {
  padding: 9px 12px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--text);
  font-size: 14px;
}
.row button {
  padding: 9px 18px;
  background: var(--accent);
  color: #06251f;
  border: none;
  border-radius: 9px;
  font-weight: 700;
  font-size: 14px;
}

#newCodes {
  width: 100%;
  margin-top: 12px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--accent);
  font-size: 12px;
  padding: 10px;
  direction: ltr;
  min-height: 80px;
  display: none;
}

table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th, table.data td { border-bottom: 1px solid var(--border); padding: 8px 10px; text-align: right; }
table.data th { color: var(--muted); font-weight: 600; }
table.data td.ltr { direction: ltr; text-align: left; font-size: 11.5px; }
.tag { padding: 2px 9px; border-radius: 20px; font-size: 11.5px; }
.tag.ok { background: rgba(45,212,191,0.13); color: var(--accent); }
.tag.no { background: rgba(139,147,167,0.15); color: var(--muted); }
.mini {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 7px;
  padding: 3px 10px;
  font-size: 12px;
  margin-inline-start: 4px;
}
.mini:hover { color: var(--accent); border-color: var(--accent); }
.mini.danger:hover { color: var(--danger); border-color: var(--danger); }
.table-wrap { overflow-x: auto; }

.stat-tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.stile {
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 12px; padding: 14px 10px; text-align: center;
}
.stile b { display: block; font-size: 22px; color: var(--accent); margin-bottom: 4px; }
.stile span { font-size: 12px; color: var(--muted); }
@media (max-width: 560px) {
  .stat-tiles { grid-template-columns: repeat(2, 1fr); }
}

/* ================= واکنش‌گرایی (موبایل) ================= */

@media (max-width: 768px) {
  #sidebar {
    position: fixed;
    top: 0; bottom: 0; right: 0;
    transform: translateX(100%);
    box-shadow: -10px 0 40px rgba(0,0,0,0.5);
  }
  #sidebar.open { transform: translateX(0); }
  #menuBtn { display: block; }
  .limit-note { display: none; }
  #messages { padding: 16px 10px; }
  .msg .avatar { width: 30px; height: 30px; min-width: 30px; font-size: 15px; }
  .auth-card { padding: 28px 20px; }
  #sideBackdrop {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 25;
    display: none;
  }
  #sideBackdrop.show { display: block; }
}

/* ================= لوگو ================= */

.logo-sm { width: 34px; height: 34px; border-radius: 50%; }
.logo-lg { width: 110px; height: 110px; border-radius: 50%; margin-bottom: 14px; box-shadow: 0 8px 30px rgba(251,191,36,0.25); }
.logo-auth { display: block; width: 90px; height: 90px; border-radius: 50%; margin: 0 auto 10px; box-shadow: 0 8px 30px rgba(251,191,36,0.25); }
.msg .avatar img { width: 100%; height: 100%; border-radius: 9px; object-fit: cover; }

/* ================= نوار ابزار و انتخابگر مدل ================= */

.toolbar { max-width: 820px; margin: 0 auto 8px; display: flex; align-items: center; gap: 8px; }
.tool-chip {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 13px;
}
.tool-chip:hover { color: var(--accent); border-color: var(--accent); }
select.tool-chip { cursor: pointer; -webkit-appearance: none; appearance: none; }
select.tool-chip option { background: var(--panel); color: var(--text); }

.model-wrap { position: relative; }
#modelPanel {
  display: none;
  position: absolute;
  bottom: calc(100% + 8px);
  right: 0;
  width: 260px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px;
  box-shadow: 0 15px 50px rgba(0,0,0,0.5);
  z-index: 40;
}
#modelPanel.show { display: block; }
.model-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13.5px;
  cursor: pointer;
  color: var(--text);
}
.model-item:hover { background: var(--panel-2); }
.model-item.all { border-bottom: 1px solid var(--border); border-radius: 8px 8px 0 0; color: var(--accent); font-weight: 600; }
.model-item input { accent-color: var(--accent); width: 16px; height: 16px; }
.model-hint { font-size: 11.5px; color: var(--muted); padding: 8px 10px 2px; }

/* ================= چیپ فایل‌های پیوست ================= */

#chips { max-width: 820px; margin: 0 auto 6px; display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  background: var(--accent-soft);
  border: 1px solid rgba(45,212,191,0.35);
  color: var(--accent);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 12.5px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.chip .x { cursor: pointer; font-weight: 700; opacity: .7; }
.chip .x:hover { opacity: 1; color: var(--danger); }

/* ================= دکمه‌های نوار ورودی تلگرامی ================= */

.icon-btn {
  background: none;
  border: none;
  font-size: 20px;
  padding: 6px;
  border-radius: 10px;
  opacity: .75;
  transition: all .15s;
  line-height: 1;
}
.icon-btn:hover { opacity: 1; background: var(--panel-2); }
.icon-btn.on { opacity: 1; background: var(--accent-soft); box-shadow: 0 0 0 1px var(--accent) inset; }
.icon-btn.rec { opacity: 1; background: rgba(248,113,113,0.15); box-shadow: 0 0 0 1px var(--danger) inset; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { transform: scale(1.12); } }

#send {
  border-radius: 50%;
  width: 42px;
  height: 42px;
  min-width: 42px;
  padding: 0;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: scaleX(-1); /* جهت فلش برای راست‌چین */
}

@media (max-width: 768px) {
  .icon-btn { font-size: 18px; padding: 5px 3px; }
  .toolbar { padding-inline: 2px; }
}


/* ---------- پنجره سند و لینک‌های دانلود ---------- */
#docOverlay { position: fixed; inset: 0; background: rgba(0,0,0,0.6); display: none;
  align-items: center; justify-content: center; z-index: 50; padding: 16px; }
#docOverlay.show { display: flex; }
.doc-form { padding: 6px 20px 20px; }
.doc-row { display: flex; flex-wrap: wrap; gap: 10px; }
.doc-field { flex: 1; min-width: 130px; margin-bottom: 10px; }
.doc-field label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 5px; }
.doc-field input, .doc-field select, .doc-field textarea {
  width: 100%; padding: 9px 11px; background: var(--panel-2);
  border: 1px solid var(--border); border-radius: 9px; color: var(--text); font-size: 14px; }
.doc-field textarea { resize: vertical; }
.dl-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.dl-link { background: var(--accent-soft); border: 1px solid rgba(45,212,191,0.4);
  color: var(--accent); border-radius: 20px; padding: 6px 16px; font-size: 13px; text-decoration: none; }
.dl-link:hover { background: rgba(45,212,191,0.25); }
.dl-note { font-size: 12px; color: var(--muted); width: 100%; }
.md a { color: var(--accent); }
.tool-chip.on { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }

/* دکمه توقف چت */
#send.stop { background: var(--danger); transform: scaleX(1); font-size: 15px; }
#send.stop:hover { background: #ef4444; }


/* ---------- اصلاحات موبایل: نوار پیام همیشه دیده شود ---------- */
footer { padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px)); }

@media (max-width: 768px) {
  .toolbar {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 2px;
    margin-bottom: 6px;
  }
  .toolbar::-webkit-scrollbar { display: none; }
  .tool-chip { white-space: nowrap; font-size: 12px; padding: 5px 11px; flex-shrink: 0; }
  footer { padding: 6px 8px calc(8px + env(safe-area-inset-bottom, 0px)); }
  .hint { display: none; }
  .inputbar { padding: 7px 9px; border-radius: 14px; }
  #send { width: 38px; height: 38px; min-width: 38px; }
  #messages { padding: 14px 10px 8px; }
  #modelPanel { bottom: calc(100% + 6px); left: 0; right: auto; max-width: calc(100vw - 24px); }
}


/* ---------- پیشنهادهای شروع گفتگو ---------- */
.sugg { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 20px; }
.sug {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 20px;
  padding: 8px 16px;
  font-size: 13px;
  transition: all .15s;
}
.sug:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }

/* ---------- حالت کشویی مدل‌ها ---------- */
.model-item .mname { flex: 1; cursor: pointer; padding: 2px 0; }
.model-item .mname:hover { color: var(--accent); }


/* ---------- چشم گذرواژه ---------- */
.pw-wrap { position: relative; }
.pw-wrap input { padding-left: 40px; }
.pw-toggle {
  position: absolute; left: 8px; top: 50%; transform: translateY(-50%);
  background: none; border: none; font-size: 16px; opacity: .65; padding: 4px;
}
.pw-toggle:hover { opacity: 1; }

/* ---------- نسخه ---------- */
.ver-line { text-align: center; font-size: 11px; color: var(--muted); padding-top: 8px; opacity: .8; direction: rtl; }

/* ---------- بنر اطلاع‌رسانی ---------- */
#announce {
  display: flex; align-items: center; gap: 10px;
  background: linear-gradient(90deg, rgba(45,212,191,0.12), rgba(251,191,36,0.10));
  border-bottom: 1px solid rgba(45,212,191,0.3);
  padding: 9px 16px; font-size: 13.5px;
}
#announce span { flex: 1; }
#announce button { background: none; border: none; color: var(--muted); font-size: 15px; }
#announce button:hover { color: var(--danger); }

/* ---------- جستجوی گفتگوها ---------- */
#convSearch {
  width: 100%; margin-top: 8px; padding: 8px 12px;
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 9px; color: var(--text); font-size: 13px;
}
#convSearch:focus { outline: none; border-color: var(--accent); }


/* ---------- نمایش عکس/فایل در چت ---------- */
.msg-media { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.msg-img {
  max-width: 220px; max-height: 220px; border-radius: 12px;
  border: 1px solid var(--border); cursor: zoom-in; object-fit: cover;
}
.msg-file {
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 8px 14px; font-size: 13px; color: var(--accent);
}
.chip-thumb { width: 22px; height: 22px; border-radius: 5px; object-fit: cover; vertical-align: middle; }

/* بزرگ‌نمایی عکس با کلیک */
#imgZoom {
  position: fixed; inset: 0; background: rgba(0,0,0,0.9);
  display: none; align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
#imgZoom.show { display: flex; }
#imgZoom img { max-width: 100%; max-height: 100%; border-radius: 10px; }


/* ---------- پروفایل کاربر ---------- */
.user-box { cursor: pointer; border-radius: 10px; padding: 6px 8px; margin: -6px -8px 10px; transition: background .15s; }
.user-box:hover { background: var(--panel-2); }
.ub-right { display: flex; align-items: center; gap: 8px; min-width: 0; }
.ub-right > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-avatar {
  width: 30px; height: 30px; min-width: 30px; border-radius: 50%;
  object-fit: cover; background: var(--panel-2); border: 1px solid var(--border);
  display: inline-flex; align-items: center; justify-content: center; font-size: 15px;
}
#profileOverlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  display: none; align-items: center; justify-content: center; z-index: 60; padding: 16px;
}
#profileOverlay.show { display: flex; }
.profile-body { padding: 4px 22px 22px; }
.p-ava-wrap { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.profile-avatar {
  width: 74px; height: 74px; min-width: 74px; border-radius: 50%;
  object-fit: cover; background: var(--panel-2); border: 2px solid var(--accent);
  display: flex; align-items: center; justify-content: center; font-size: 34px;
}
.p-info div { font-size: 13.5px; margin-bottom: 7px; color: var(--muted); }
.p-info b { color: var(--text); margin-right: 4px; }
.p-sec { color: var(--accent); font-size: 14px; margin: 16px 0 10px; }
.p-inp {
  width: 100%; padding: 10px 12px; background: var(--panel-2);
  border: 1px solid var(--border); border-radius: 9px; color: var(--text);
  margin-bottom: 8px; direction: ltr; font-size: 14px;
}
.p-inp:focus { outline: none; border-color: var(--accent); }

/* فراموشی رمز */
.forgot { margin-top: 14px; font-size: 13px; color: var(--muted); }
.forgot summary { cursor: pointer; color: var(--accent); }
.forgot p { margin-top: 8px; line-height: 1.9; }


/* ---------- عکس‌های تولیدشده توسط هوش مصنوعی ---------- */
.md img {
  max-width: 100%;
  max-height: 420px;
  border-radius: 14px;
  border: 1px solid var(--border);
  margin: 8px 0;
  cursor: zoom-in;
  display: block;
}


/* ---------- جستجو در جدول‌های پنل ادمین ---------- */
.tbl-search {
  width: 100%; max-width: 360px;
  padding: 9px 13px; margin-bottom: 12px;
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 9px; color: var(--text); font-size: 13.5px;
}
.tbl-search:focus { outline: none; border-color: var(--accent); }

/* عکس تولیدشده */
.gen-img {
  max-width: 100%; max-height: 480px;
  border-radius: 14px; border: 1px solid var(--border);
  margin: 10px 0; cursor: zoom-in; display: block;
}


/* ---------- چرخنده (اسپینر) ---------- */
.spin {
  display: inline-block; width: 14px; height: 14px; min-width: 14px;
  border: 2px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: rot .8s linear infinite;
  vertical-align: middle;
}
@keyframes rot { to { transform: rotate(360deg); } }

/* ---------- ویدیوی تولیدشده ---------- */
.gen-vid {
  max-width: 100%; max-height: 420px;
  border-radius: 14px; border: 1px solid var(--border);
  margin: 10px 0; display: block; background: #000;
}


/* ---------- هشدار اشتراک ---------- */
#subWarn {
  background: rgba(248,113,113,0.12);
  border-bottom: 1px solid rgba(248,113,113,0.4);
  color: #fca5a5; padding: 9px 16px; font-size: 13.5px;
}

/* ---------- سهمیه‌های پروفایل ---------- */
.p-quotas .q-row { margin-bottom: 10px; font-size: 13px; color: var(--muted); }
.p-quotas .q-row b { color: var(--text); float: left; }
.q-bar { height: 6px; background: var(--panel-2); border-radius: 4px; margin-top: 5px; overflow: hidden; clear: both; }
.q-fill { height: 100%; background: var(--accent); border-radius: 4px; transition: width .3s; }
.q-fill.full { background: var(--danger); }


/* ---------- پنجره ابزار پایان‌نامه و تحلیل آماری ---------- */
#acadOverlay, #statsOverlay, #convertOverlay, #feedbackOverlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  display: none; align-items: center; justify-content: center; z-index: 60; padding: 16px;
}
#acadOverlay.show, #statsOverlay.show, #convertOverlay.show, #feedbackOverlay.show { display: flex; }
/* پنل داخلی این پنجره‌ها باید بلندی‌اش محدود و قابل اسکرول باشد تا همه دکمه‌ها دیده شوند */
#acadOverlay .mem-panel, #statsOverlay .mem-panel, #feedbackOverlay .mem-panel { max-height: 88vh; }
#acadOverlay .doc-form, #statsOverlay .doc-form, #feedbackOverlay .doc-form { overflow-y: auto; }
.acad-tools, #statsTools {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 9px;
  padding: 4px 22px 22px;
}
.acad-t, .stat-t {
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 12px; padding: 13px 10px; color: var(--text);
  font-size: 13.5px; text-align: center; transition: all .15s; line-height: 1.7;
}
.acad-t:hover, .stat-t:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.acad-t b, .stat-t b { display: block; font-size: 15px; margin-bottom: 3px; }
#statsInfo {
  margin: 0 22px 12px; padding: 10px 14px; font-size: 12.5px; color: var(--muted);
  background: var(--panel-2); border: 1px dashed var(--border); border-radius: 10px; line-height: 1.9;
}
#statsUpBtn { margin: 0 22px 12px; }
@media (max-width: 480px) {
  .acad-tools, #statsTools { grid-template-columns: 1fr 1fr; }
}

/* ---------- پنل نوع محتوا (تیک‌دار) ---------- */
#ctypePanel {
  display: none;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 8px;
}
#ctypePanel.show { display: block; animation: fadeUp .2s ease; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.ctype-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px; font-size: 13px; color: var(--muted);
}
.ctype-head button {
  background: none; border: 1px solid var(--border); color: var(--muted);
  border-radius: 8px; padding: 3px 10px; font-size: 12px;
}
.ctype-head button:hover { color: var(--danger); border-color: var(--danger); }
.ctype-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px;
}
.ctype-grid label {
  display: flex; align-items: center; gap: 7px;
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 9px 11px; font-size: 13px; cursor: pointer;
  transition: all .15s;
}
.ctype-grid label:hover { border-color: var(--accent); }
.ctype-grid input:checked { accent-color: var(--accent); }
.ctype-grid label:has(input:checked) { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

#ctypeDocOpts {
  margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--border);
}
.ctype-opts-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.ctype-opts-row label { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 5px; }
.ctype-opts-row input[type="number"] { width: 58px; padding: 5px 7px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 7px; color: var(--text); }
.ctype-opts-row select { padding: 5px 7px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 7px; color: var(--text); font-size: 12.5px; }
.ctype-opts-row .ck { cursor: pointer; }

#ctypeBtn.on { color: var(--accent); font-weight: 700; font-size: 13px; }

@media (max-width: 480px) {
  .ctype-grid { grid-template-columns: 1fr 1fr; }
}

/* ---------- کتابخانه منابع ---------- */
#refOverlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  display: none; align-items: center; justify-content: center; z-index: 60; padding: 16px;
}
#refOverlay.show { display: flex; }
.ref-panel { max-width: 680px; max-height: 88vh; }
.ref-panel .doc-form { overflow-y: auto; }

.ref-quickadd { margin-bottom: 12px; }
.ref-quickadd label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 5px; }
.ref-quickadd textarea {
  width: 100%; background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 10px; color: var(--text); padding: 9px 11px; font-size: 13px; resize: vertical;
}
.ref-form {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px; margin: 10px 0 16px;
}
.ref-form select, .ref-form input {
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 9px; color: var(--text); padding: 9px 11px; font-size: 13px; width: 100%;
}
.ref-form #refTitle { grid-column: 1 / -1; }
.ref-form #refAuthors { grid-column: 1 / -1; }
.ref-form .btn-primary { grid-column: 1 / -1; }

.ref-listhead {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; flex-wrap: wrap; font-size: 13px; color: var(--muted);
  border-top: 1px dashed var(--border); padding-top: 12px; margin-bottom: 8px;
}
.ref-genbar { display: flex; gap: 6px; align-items: center; }
.ref-genbar select {
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); padding: 5px 8px; font-size: 12.5px;
}
.ref-list { display: flex; flex-direction: column; gap: 7px; margin-bottom: 12px; }
.ref-empty { color: var(--muted); font-size: 13px; text-align: center; padding: 14px; }
.ref-item {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 8px;
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 11px; padding: 10px 12px;
}
.ref-main { flex: 1; min-width: 0; }
.ref-main b { font-size: 13.5px; color: var(--text); }
.ref-badge {
  display: inline-block; font-size: 11px; color: var(--accent);
  background: var(--accent-soft); border-radius: 6px; padding: 1px 7px; margin-inline-end: 6px;
}
.ref-sub { font-size: 12px; color: var(--muted); margin-top: 3px; line-height: 1.7; }
.ref-del { background: none; border: none; color: var(--muted); font-size: 15px; }
.ref-del:hover { color: var(--danger); }
.ref-hit {
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 9px; padding: 8px 11px; margin-top: 6px; cursor: pointer; transition: border-color .15s;
}
.ref-hit:hover { border-color: var(--accent); }
.ref-hit b { font-size: 13px; color: var(--text); }
#refLookupResults, #refImportResults { max-height: 240px; overflow-y: auto; }
#refBibBox label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 5px; }
#refBib {
  width: 100%; background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 10px; color: var(--text); padding: 10px 12px; font-size: 13px; line-height: 2;
}
