/* ==========================================================================
   التنقل الجديد: قائمة جانبية للحاسبة، شريط سفلي للموبايل، قائمة «حسابي»،
   زر الإضافة العائم، الناشرين، البروفايل والتقييم
   ========================================================================== */

:root { --side-w: 268px; --side-gap: 14px; --star: #F59E0B; }
[data-mode="dark"] { --star: #FBBF24; }

/* ---------- القائمة الجانبية (الحاسبة) ---------- */
.sidebar {
  position: fixed; z-index: 25; top: var(--side-gap); bottom: var(--side-gap); inset-inline-start: var(--side-gap);
  width: var(--side-w); display: flex; flex-direction: column; gap: 14px;
  padding: 18px 12px 12px; border-radius: 26px; overflow-y: auto; overscroll-behavior: contain;
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  -webkit-backdrop-filter: blur(14px) saturate(1.3); backdrop-filter: blur(14px) saturate(1.3);
  box-shadow: var(--shadow);
}
.sidebar .brand { padding: 2px 8px 4px; min-width: 0; }
.sidebar .brand > span:last-child { overflow: hidden; text-overflow: ellipsis; }
.sidebar .search-trigger { width: 100%; margin: 0; justify-content: flex-start; padding-inline: 14px 10px; }
.sidebar .search-trigger-text { display: inline; flex: 1; text-align: start; }
.sidebar .search-trigger .kbd { display: inline-flex; }

.side-nav { display: grid; gap: 4px; }
.side-link {
  position: relative; display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 0 14px;
  border-radius: 15px; color: var(--muted); font-weight: 500;
  transition: background .2s, color .2s, box-shadow .2s;
}
.side-link:hover { background: var(--surface-2); color: var(--text); }
.side-link .icon { flex: none; transition: transform .4s var(--spring); }
.side-link:hover .icon { transform: scale(1.08); }
.side-link.active {
  background: var(--grad); color: #fff; font-weight: 600;
  box-shadow: 0 10px 22px -10px color-mix(in srgb, var(--grad-a) 75%, transparent);
}
[data-mode="dark"] .side-link.active { background: var(--grad-dark); }
.side-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-sep { height: 1px; margin: 8px 12px; border: 0; background: var(--border); }

.side-foot { margin-top: auto; }
.user-card {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px; min-height: 64px;
  border: 0; border-radius: 18px; background: var(--surface-2); color: var(--text);
  text-align: start; font: inherit; cursor: pointer; transition: background .2s, box-shadow .2s;
}
.user-card:hover, .user-card[aria-expanded="true"] { background: var(--primary-soft); }
.user-card.active { box-shadow: inset 0 0 0 2px var(--primary); }
.user-card-text { display: grid; justify-items: start; gap: 2px; flex: 1; min-width: 0; line-height: 1.35; }
.user-card-text strong { max-width: 100%; font-size: .94rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-card-caret { color: var(--muted); transform: rotate(90deg); transition: transform .2s var(--ease); }
.user-card[aria-expanded="true"] .user-card-caret { transform: rotate(-90deg); }

.app-area { padding-inline-start: calc(var(--side-w) + var(--side-gap)); }
.mobilebar, .bottomnav { display: none; }

/* الشاشات المتوسطة: القائمة تصير شريط أيقونات */
@media (min-width: 761px) and (max-width: 1100px) {
  :root { --side-w: 84px; }
  .sidebar { padding-inline: 10px; align-items: stretch; }
  .sidebar .brand { justify-content: center; padding: 2px 0 4px; }
  .sidebar .brand > span:last-child, .side-label, .user-card-text, .user-card-caret,
  .sidebar .search-trigger-text, .sidebar .search-trigger .kbd { display: none; }
  .sidebar .search-trigger { justify-content: center; padding: 0; }
  .side-link { justify-content: center; padding: 0; }
  .user-card { justify-content: center; padding: 8px; }
}

/* ---------- الموبايل: شريط علوي صغير + شريط سفلي بخمسة أزرار ---------- */
@media (max-width: 760px) {
  .sidebar { display: none; }
  .app-area { padding: 0; }
  .mobilebar { display: block; }
  .mobilebar .topbar-in { justify-content: center; min-height: 52px; }

  .bottomnav {
    display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); align-items: end;
    overflow: visible;
  }
  .bottomnav :is(a, button) {
    display: grid; justify-items: center; align-content: center; gap: 2px; min-height: 56px; padding: 6px 2px;
    border: 0; border-radius: 16px; background: transparent; color: var(--muted);
    font: inherit; font-size: .74rem; font-weight: 500; cursor: pointer;
    transition: color .2s, background .2s;
  }
  .bottomnav span { white-space: nowrap; }
  .bn-account .avatar { box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px transparent; transition: box-shadow .2s; }
  .bn-account.active, .bn-account[aria-expanded="true"] { color: var(--primary); font-weight: 600; }
  .bn-account.active .avatar, .bn-account[aria-expanded="true"] .avatar { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--primary); }

  /* زر البحث: دائري وبارز في الوسط */
  .bottomnav .bn-search { position: relative; min-height: 56px; padding: 0; }
  .bn-search-circle {
    display: grid; place-items: center; width: 60px; height: 60px; margin-top: -30px;
    border-radius: 50%; background: var(--grad); color: #fff;
    box-shadow: 0 0 0 5px color-mix(in srgb, var(--surface) 92%, transparent),
                0 12px 26px -8px color-mix(in srgb, var(--grad-a) 75%, transparent);
    transition: transform .35s var(--spring);
  }
  [data-mode="dark"] .bn-search-circle { background: var(--grad-dark); }
  .bn-search:active .bn-search-circle { transform: scale(.92); }
}

/* ---------- قائمة «حسابي» ---------- */
.menu-layer { position: fixed; inset: 0; z-index: 70; }
.account-menu {
  position: fixed; display: grid; gap: 2px; min-width: 260px; max-height: calc(100dvh - 32px); overflow-y: auto;
  padding: 8px; border-radius: 22px; background: var(--surface);
  box-shadow: 0 24px 60px rgba(10, 24, 22, .24), 0 0 0 1px var(--border);
  transform-origin: bottom right; animation: menu-in .18s var(--ease) both;
}
.menu-layer.closing { pointer-events: none; }
.menu-layer.closing .account-menu { animation: menu-out .14s ease forwards; }
.menu-head { display: flex; align-items: center; gap: 12px; padding: 8px 10px 12px; margin-bottom: 4px; border-bottom: 1px solid var(--border); }
.menu-head-text { display: grid; gap: 4px; min-width: 0; line-height: 1.35; }
.menu-head-text strong { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-head-text > span { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.menu-head .handle, .profile-meta .handle { color: var(--muted); font-size: .84rem; direction: ltr; }
.menu-item {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 48px; padding: 0 12px;
  border: 0; border-radius: 14px; background: transparent; color: var(--text);
  font: inherit; font-weight: 500; text-align: start; cursor: pointer; transition: background .15s, color .15s;
}
.menu-item .icon { color: var(--muted); transition: color .15s; }
.menu-item:hover, .menu-item:focus-visible { background: var(--surface-2); outline: none; }
.menu-item:focus-visible { box-shadow: inset 0 0 0 2px var(--primary); }
.menu-item.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.menu-item.active .icon { color: var(--primary); }
.menu-item.danger, .menu-item.danger .icon { color: var(--danger); }
.menu-item.danger:hover { background: var(--danger-soft); }
.menu-sep { height: 1px; margin: 4px 8px; background: var(--border); }
.menu-mobile-only { display: none; }

@media (max-width: 760px) {
  .menu-layer { background: rgba(10, 20, 18, .45); animation: fade .18s ease both; }
  .menu-layer.closing { animation: fade-out .14s ease forwards; }
  .account-menu {
    inset-inline: 10px; bottom: calc(10px + env(safe-area-inset-bottom)); top: auto;
    min-width: 0; padding: 10px; border-radius: 26px; animation-name: sheet-in;
  }
  .menu-layer.closing .account-menu { animation-name: sheet-out; }
  .menu-mobile-only { display: contents; }
  .menu-item { min-height: 52px; }
}
@keyframes menu-in { from { opacity: 0; transform: translateY(6px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes menu-out { to { opacity: 0; transform: translateY(4px) scale(.98); } }
@keyframes sheet-in { from { transform: translateY(105%); } to { transform: none; } }
@keyframes sheet-out { to { transform: translateY(105%); } }

/* ---------- زر الإضافة العائم ---------- */
.fab {
  position: fixed; z-index: 30; inset-inline-end: 28px; bottom: 28px;
  display: inline-flex; align-items: center; gap: 8px; height: 58px; padding-inline: 18px 24px;
  border: 0; border-radius: 999px; background: var(--grad); color: #fff;
  font: inherit; font-weight: 700; cursor: pointer;
  box-shadow: 0 14px 30px -10px color-mix(in srgb, var(--grad-a) 80%, transparent);
  transition: transform .3s var(--spring), box-shadow .2s;
}
[data-mode="dark"] .fab { background: var(--grad-dark); }
.fab:hover { transform: translateY(-3px); box-shadow: 0 18px 36px -12px color-mix(in srgb, var(--grad-a) 85%, transparent); }
.fab:active { transform: scale(.95); }
.fab:focus-visible { outline: 3px solid var(--primary); outline-offset: 3px; }
@media (max-width: 760px) {
  .fab { width: 56px; height: 56px; padding: 0; justify-content: center; inset-inline-end: 16px; bottom: calc(96px + env(safe-area-inset-bottom)); }
  .fab-label { display: none; }
  .container { padding-bottom: 170px; }
}

/* ---------- الرتب ---------- */
.role-chip { font-size: .76rem; padding: 1px 10px; }
.role-user { background: var(--surface-2); color: var(--muted); box-shadow: inset 0 0 0 1px var(--border); }
.role-pub { background: color-mix(in srgb, var(--star) 18%, var(--surface)); color: var(--warn); }
.role-admin { background: var(--primary-soft); color: var(--primary); }

/* ---------- بطاقة الملخص: الناشر والتقييم ---------- */
.row-card { display: grid; grid-template-columns: minmax(0, 1fr); }
.row-foot {
  display: flex; align-items: center; gap: 8px 12px; flex-wrap: wrap;
  padding: 0 18px 14px; margin-top: -4px;
}
.author-link {
  display: inline-flex; align-items: center; gap: 8px; min-height: 36px; max-width: 100%; padding-inline: 4px 12px;
  border-radius: 999px; background: var(--surface-2); color: var(--text); font-size: .86rem; font-weight: 600;
  transition: background .2s, color .2s;
}
.author-link span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.author-link:hover { background: var(--primary-soft); color: var(--primary); }
.rating-badge { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-size: .86rem; }
.rating-badge .icon { color: var(--star); }
.rating-badge b { color: var(--text); font-weight: 700; }
.rating-badge.none .icon { color: var(--border-strong); }
.row-actions { display: inline-flex; align-items: center; gap: 2px; margin-inline-start: auto; }
.rate-btn {
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 14px;
  border: 0; border-radius: 999px; background: var(--surface-2); color: var(--text);
  font: inherit; font-size: .86rem; font-weight: 600; cursor: pointer; transition: background .2s, transform .12s var(--ease);
}
.rate-btn .icon { color: var(--star); }
.rate-btn:hover { background: color-mix(in srgb, var(--star) 16%, var(--surface)); }
.rate-btn:active { transform: scale(.96); }
.rate-btn.rated { background: color-mix(in srgb, var(--star) 14%, var(--surface)); }
.row-actions .icon-btn { width: 40px; height: 40px; }

.summary-by { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 12px; }

/* اختيار النجوم */
.star-intro { text-align: center; color: var(--muted); }
.star-group { display: flex; justify-content: center; gap: 4px; margin: 6px 0 2px; }
.star-pick {
  display: grid; place-items: center; width: 54px; height: 54px; padding: 0;
  border: 0; border-radius: 16px; background: transparent; color: var(--border-strong);
  cursor: pointer; transition: color .15s, transform .3s var(--spring), background .15s;
}
.star-pick:hover { transform: scale(1.14); }
.star-pick.on { color: var(--star); }
.star-pick:focus-visible { outline: 0; background: var(--surface-2); box-shadow: inset 0 0 0 2px var(--primary); }
.star-caption { text-align: center; font-weight: 700; min-height: 1.7em; }
.star-caption:empty { visibility: hidden; }

/* ---------- الترتيب والتحميل التدريجي ---------- */
.sort-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.sort-bar h2 { font-size: 1.15rem; }
.seg { display: inline-flex; gap: 4px; padding: 4px; border-radius: 999px; background: var(--surface-2); flex: none; }
.seg button {
  min-height: 40px; padding: 0 16px; border: 0; border-radius: 999px; background: transparent;
  color: var(--muted); font: inherit; font-size: .9rem; font-weight: 600; cursor: pointer; transition: background .2s, color .2s, box-shadow .2s;
}
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--primary); box-shadow: var(--shadow); }
.paged { display: grid; gap: 12px; }
.list-count { color: var(--muted); font-size: .88rem; margin: 0; }
.list-count:empty { display: none; }
.more-wrap { display: flex; justify-content: center; padding-top: 4px; }
.sentinel { height: 1px; }
@media (max-width: 760px) {
  .sort-bar .seg { width: 100%; }
  .sort-bar .seg button { flex: 1; }
}

/* ---------- البروفايل ---------- */
.profile-card {
  display: flex; align-items: center; gap: 20px; flex-wrap: wrap; overflow: hidden; padding: 28px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--grad-a) 14%, var(--surface)),
                                      color-mix(in srgb, var(--grad-b) 8%, var(--surface)) 70%);
}
.profile-card .hero-orb { opacity: .18; }
.profile-card > :not(.hero-orb) { position: relative; }
.profile-card .avatar { box-shadow: 0 0 0 4px var(--surface), 0 10px 24px rgba(15, 60, 55, .16); }
.profile-info { display: grid; gap: 6px; flex: 1; min-width: 200px; }
.profile-info h1 { overflow-wrap: anywhere; }
.profile-meta { display: flex; align-items: center; gap: 8px 14px; flex-wrap: wrap; color: var(--muted); font-size: .9rem; }
.profile-meta .joined { display: inline-flex; align-items: center; gap: 6px; }
.profile-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.pub-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.profile-list { display: grid; gap: 14px; }
.avatar-edit { display: grid; justify-items: center; gap: 6px; }
.link-btn {
  min-height: 40px; padding: 0 10px; border: 0; background: transparent; border-radius: 10px;
  color: var(--primary); font: inherit; font-size: .9rem; font-weight: 600; cursor: pointer;
}
.link-btn:hover { background: var(--surface-2); }
.danger-link { color: var(--danger); }
.current-file {
  display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 14px; padding-inline: 14px 8px;
  border-radius: 14px; background: var(--surface-2); color: var(--muted);
}
.current-file-name { flex: 1; min-width: 0; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 760px) {
  .profile-card { padding: 22px 18px; justify-content: center; text-align: center; }
  .profile-info { justify-items: center; }
  .profile-meta { justify-content: center; }
  .profile-actions { width: 100%; }
  .profile-actions .btn { flex: 1; }
  .pub-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .pub-stats .stat { padding: 12px; }
  .pub-stats .stat small, .pub-stats .tile-icon { display: none; }
}

/* ---------- الناشرين ---------- */
.publisher-grid { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.publisher-card {
  display: grid; justify-items: center; align-content: start; gap: 8px; padding: 26px 16px 20px; text-align: center;
  transition: transform .22s var(--ease), box-shadow .22s var(--ease);
}
.publisher-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lift); }
.publisher-card .avatar { box-shadow: 0 0 0 4px var(--primary-soft); }
.publisher-name { font-weight: 700; font-size: 1.04rem; overflow-wrap: anywhere; }
.publisher-stats { display: flex; align-items: center; justify-content: center; gap: 6px 12px; flex-wrap: wrap; color: var(--muted); font-size: .86rem; }
.rank {
  position: absolute; top: 12px; inset-inline-start: 12px; min-width: 34px; padding: 2px 8px;
  border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: .8rem; font-weight: 700;
}
.rank-1 { background: color-mix(in srgb, var(--star) 24%, var(--surface)); color: var(--warn); }
.rank-2, .rank-3 { background: var(--primary-soft); color: var(--primary); }

/* ---------- الأخبار والمواد: أزرار التعديل ---------- */
.news-tools { display: flex; gap: 2px; margin: -8px; margin-inline-start: 0; }
.news-tools .card-del { margin: 0; }

/* ---------- لوحة التحكم: الرتب ---------- */
.user-link { color: inherit; }
.user-link:hover { color: var(--primary); text-decoration: underline; }
.cell-tools { display: flex; align-items: center; justify-content: flex-end; gap: 6px; }
.role-btn {
  display: inline-flex; align-items: center; gap: 6px; min-height: 38px; padding: 0 12px;
  border: 0; border-radius: 999px; background: var(--primary-soft); color: var(--primary);
  font: inherit; font-size: .84rem; font-weight: 600; white-space: nowrap; cursor: pointer; transition: background .2s, color .2s;
}
.role-btn:hover { background: color-mix(in srgb, var(--primary) 22%, var(--surface)); }
.role-btn.on { background: var(--surface-2); color: var(--muted); }
.role-btn.on:hover { background: var(--danger-soft); color: var(--danger); }

@media (prefers-reduced-motion: reduce) {
  .account-menu, .menu-layer, .fab, .side-link .icon, .bn-search-circle, .star-pick { animation: none !important; transition: none !important; }
}

/* اسم المنصة يظهر في الشريط العلوي للموبايل */
.mobilebar .brand > span:last-child { display: inline; max-width: 60vw; overflow: hidden; text-overflow: ellipsis; }

/* جدول الحسابات يتسع بجانب القائمة الجانبية بدون تمرير أفقي */
@media (min-width: 761px) {
  table.users th, table.users td { padding-inline: 10px; }
  table.users td.num { white-space: normal; min-width: 72px; }
  .role-btn { padding: 0 10px; }
}

/* ---------- زر الثيم في الهيدر ونافذة الاختيار (لكل الثيمات) ---------- */
.theme-group-color { grid-template-columns: 1fr; }
.side-top { display: flex; align-items: center; gap: 6px; }
.side-top .brand { flex: 1; min-width: 0; }
.mobilebar .topbar-in { position: relative; }
.mobilebar .theme-trigger { position: absolute; inset-inline-end: 8px; top: 50%; margin-top: -22px; }
@media (min-width: 761px) and (max-width: 1100px) {
  .side-top { flex-direction: column; }
}

/* ---------- التبليغات: تبويبات الشعب A-E ---------- */
.section-tabs {
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px;
  margin-bottom: 16px;
}
.section-tab {
  position: relative; display: flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 6px 10px; border-radius: var(--r-md, 12px);
  background: var(--surface); color: var(--muted); text-decoration: none;
  box-shadow: inset 0 0 0 1px var(--border);
  transition: background .2s ease, color .2s ease, box-shadow .2s ease;
}
.section-tab b { font-family: var(--mono, inherit); font-size: 1.15rem; font-weight: 700; }
.section-tab:hover { color: var(--text); box-shadow: inset 0 0 0 1px var(--border-strong); }
.section-tab.active { background: var(--primary-soft); color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }
.section-tab.mine::after {
  content: "شعبتك"; position: absolute; top: -10px; inset-inline-start: 50%; transform: translateX(50%);
  padding: 1px 8px; border-radius: 6px; font-size: .74rem; font-weight: 600; line-height: 1.5;
  background: var(--primary); color: var(--on-primary, #fff); white-space: nowrap;
}
.section-count {
  min-width: 22px; padding: 0 6px; border-radius: 999px; font-size: .75rem; line-height: 20px; text-align: center;
  background: var(--surface-2); color: var(--muted);
}
.section-tab.active .section-count { background: var(--primary); color: var(--on-primary, #fff); }
.section-note {
  display: flex; align-items: center; gap: 8px; margin: 0 0 16px; padding: 10px 14px;
  border-radius: var(--r-md, 12px); background: var(--surface-2); color: var(--muted);
  box-shadow: inset 0 0 0 1px var(--border);
}
.section-note.warn { background: var(--warn-soft); color: var(--warn); }
.section-note .icon { flex: none; }
.section-chip { font-weight: 600; }
.section-select { min-width: 84px; }
@media (max-width: 760px) {
  .section-tabs { gap: 6px; }
  .section-tab { min-height: 44px; padding: 4px; flex-direction: column; gap: 2px; }
  .section-count { min-width: 18px; line-height: 16px; font-size: .68rem; }
}

/* الرئيسية: خمس بطاقات (للمدير) — الثالثة والرابعة صغار، والخامسة بعرض كامل */
.bento-5 .tile:nth-child(3), .bento-5 .tile:nth-child(4) {
  grid-column: span 1; flex-direction: column; align-items: flex-start; justify-content: center; gap: 10px;
}
.bento-5 .tile:nth-child(3) .tile-text > span, .bento-5 .tile:nth-child(4) .tile-text > span,
.bento-5 .tile:nth-child(3) .tile-arrow, .bento-5 .tile:nth-child(4) .tile-arrow { display: none; }
.bento-5 .tile:nth-child(3) .tile-meta, .bento-5 .tile:nth-child(4) .tile-meta { position: absolute; top: 16px; inset-inline-end: 16px; }
.bento-5 .tile:nth-child(5) { grid-column: 1 / -1; }
@media (max-width: 760px) {
  .bento-5 .tile:nth-child(3), .bento-5 .tile:nth-child(4) { grid-column: span 1; }
}

/* ---------- الدعم: أيقونة وشارة الرسائل الجديدة ---------- */
.support-badge {
  position: absolute; top: 6px; inset-inline-start: 30px;
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  display: grid; place-items: center;
  background: var(--danger); color: #fff; font-size: .7rem; font-weight: 700; line-height: 1;
  box-shadow: 0 0 0 2px var(--surface);
}
.support-badge[hidden] { display: none; }
.support-trigger { position: relative; }
.support-trigger .support-badge { top: 2px; inset-inline-start: auto; inset-inline-end: 2px; }
.mobilebar .support-trigger { position: absolute; inset-inline-end: 58px; top: 50%; margin-top: -22px; }
.sidebar .support-trigger { display: none; }

/* ---------- الدعم: المحادثة ---------- */
.page-chat { display: flex; flex-direction: column; }
.chat {
  display: flex; flex-direction: column; padding: 0; overflow: hidden;
  height: calc(100dvh - 210px); min-height: 380px;
}
.chat-list {
  flex: 1; overflow-y: auto; overscroll-behavior: contain;
  display: flex; flex-direction: column; gap: 10px; padding: 18px 16px;
}
.chat-list:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.chat-msg {
  max-width: min(78%, 520px); display: grid; gap: 4px;
  padding: 9px 13px 7px; border-radius: 14px; line-height: 1.7;
  overflow-wrap: anywhere;
}
.chat-msg.mine {
  align-self: flex-end; background: var(--primary-soft); color: var(--text);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--primary) 35%, transparent);
  border-end-end-radius: 4px;
}
.chat-msg.theirs {
  align-self: flex-start; background: var(--surface-2); color: var(--text);
  box-shadow: inset 0 0 0 1px var(--border);
  border-end-start-radius: 4px;
}
.chat-who { font-size: .76rem; font-weight: 700; color: var(--primary); }
.chat-text { margin: 0; white-space: pre-wrap; }
.chat-time { font-size: .72rem; color: var(--muted); justify-self: end; }
.chat-img { display: block; margin: 2px -5px 0; border-radius: 10px; overflow: hidden; }
.chat-img img { display: block; width: 100%; max-height: 320px; object-fit: cover; background: var(--surface); }
.chat-empty { margin: auto; display: grid; justify-items: center; gap: 10px; text-align: center; color: var(--muted); max-width: 34ch; }
.chat-empty p { margin: 0; }
.chat-empty-icon {
  width: 56px; height: 56px; display: grid; place-items: center; border-radius: 14px;
  background: var(--primary-soft); color: var(--primary);
}
.chat-compose { border-top: 1px solid var(--border); padding: 10px; display: grid; gap: 8px; background: var(--surface); }
.chat-row { display: flex; align-items: flex-end; gap: 8px; }
textarea.input.chat-input { flex: 1; height: 44px; min-height: 44px; max-height: 160px; resize: none; padding-block: 9px; line-height: 1.6; overflow-y: hidden; }
/* زر «ملخص جديد» العائم يختفي بصفحة المحادثة حتى ما يغطي زر الإرسال */
body:has(.page-chat) .fab { display: none; }
.chat-attach { flex: none; width: 44px; height: 44px; }
.chat-send { flex: none; min-height: 44px; }
.chat-send .icon { transform: scaleX(-1); }
.chat-preview { position: relative; width: max-content; }
.chat-preview[hidden] { display: none; }
.chat-preview img { display: block; max-width: 140px; max-height: 110px; border-radius: 10px; box-shadow: inset 0 0 0 1px var(--border); }
.chat-preview-x {
  position: absolute; top: -8px; inset-inline-end: -8px; width: 28px; height: 28px; min-height: 0;
  border-radius: 50%; background: var(--surface-2); box-shadow: 0 0 0 1px var(--border-strong);
}
.chat-peer { display: flex; align-items: center; gap: 12px; margin: 6px 0 14px; }
.chat-peer-text { display: grid; gap: 2px; min-width: 0; }
.chat-peer-text > span { display: flex; align-items: center; gap: 8px; }

/* صندوق الدعم (المدير) */
.thread { display: flex; align-items: center; gap: 12px; padding: 14px 16px; color: var(--text); text-decoration: none; }
.thread-text { flex: 1; min-width: 0; display: grid; gap: 4px; }
.thread-top { display: flex; align-items: center; gap: 8px; min-width: 0; }
.thread-top strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread-time { margin-inline-start: auto; font-size: .78rem; color: var(--muted); white-space: nowrap; }
.thread-last { display: flex; align-items: center; gap: 4px; color: var(--muted); font-size: .9rem; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.thread-last b { color: var(--text); font-weight: 600; }
.thread.unread .thread-last { color: var(--text); font-weight: 600; }
.thread-unread {
  flex: none; min-width: 24px; height: 24px; padding: 0 7px; border-radius: 999px;
  display: grid; place-items: center; background: var(--primary); color: var(--on-primary, #fff); font-size: .78rem; font-weight: 700;
}

@media (max-width: 760px) {
  .chat { height: calc(100dvh - 250px); min-height: 320px; }
  .chat-msg { max-width: 86%; }
  .chat-send-label { display: none; }
  .chat-send { width: 44px; padding: 0; justify-content: center; }
}
@media (min-width: 761px) and (max-width: 1100px) {
  .side-link .support-badge { inset-inline-start: auto; inset-inline-end: 8px; top: 4px; }
}
.section-note.mine-section { color: var(--text); }
.section-note.mine-section .icon { color: var(--primary); }
.section-note.mine-section b { color: var(--primary); }

/* ---------- المراحل والشعب ---------- */
.subject-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-top: auto; }
.stage-chip { font-size: .74rem; padding: 2px 9px; background: var(--primary-soft); color: var(--primary); box-shadow: none; }
.stage-chip.general { background: var(--surface-2); color: var(--muted); }
.stage-filter { margin: 0 0 14px; overflow-x: auto; scrollbar-width: none; }
.stage-filter::-webkit-scrollbar { display: none; }
.stage-filter .seg { width: max-content; min-width: 100%; }
.stage-filter .seg button { white-space: nowrap; }
.ann-nav { margin-bottom: 4px; }
/* شريط المراحل ينسحب بمكانه: بدون هذا، عنصر الشبكة ياخذ عرض الأزرار كلها ويوسّع الصفحة بالموبايل */
.ann-nav, .stage-filter { min-width: 0; max-width: 100%; }
.placement-select { min-width: 170px; }

.stages-card { display: grid; gap: 12px; }
.stages-card .sort-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.stages-hint { margin: 0; font-size: .9rem; }
.stages-list { display: grid; gap: 10px; }
.stage-row {
  display: grid; gap: 10px; padding: 12px 14px; border-radius: var(--r-md, 12px);
  background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--border);
}
.stage-row-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.stage-row-head strong { font-size: 1.02rem; }
.stage-counts { font-size: .82rem; }
.stage-tools { margin-inline-start: auto; display: flex; gap: 4px; }
.stage-tools .icon-btn { position: static; }
.section-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.section-pill {
  display: inline-flex; align-items: center; border-radius: 999px; overflow: hidden;
  background: var(--surface); box-shadow: inset 0 0 0 1px var(--border-strong);
}
.section-pill button { border: 0; background: none; color: var(--text); cursor: pointer; min-height: 36px; }
.section-pill-name { display: inline-flex; align-items: center; gap: 6px; padding: 0 6px 0 12px; font-weight: 700; }
.section-pill-name small {
  min-width: 18px; padding: 0 5px; border-radius: 999px; font-size: .7rem; line-height: 18px; text-align: center;
  background: var(--primary-soft); color: var(--primary);
}
.section-pill-x { display: grid; place-items: center; width: 34px; color: var(--muted) !important; }
.section-pill-x:hover { color: var(--danger) !important; background: var(--danger-soft); }
.section-pill-name:hover { background: var(--primary-soft); }
.section-pill button:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.btn.btn-sm { min-height: 36px; padding: 0 12px; font-size: .88rem; gap: 6px; }

/* إنشاء الحساب: المرحلة والشعبة جنب بعض */
.placement-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.placement-pick[hidden] { display: none; }
.placement-pick .field { margin: 0; }

/* صفحة الدخول: عنوان الترحيب والمميزات بنص اللوحة (مو لازگة بالأسفل) */
@media (min-width: 761px) {
  .auth-art-title { margin-top: auto; }
  .auth-feats { margin-bottom: auto; }
}

/* ---------- الدعم: خيارات الرسالة والإعدادات ---------- */
.chat-msg { position: relative; }
.chat-foot { display: flex; align-items: center; justify-content: flex-end; gap: 4px; }
.chat-more {
  display: grid; place-items: center; width: 26px; height: 26px; margin-inline-end: -6px;
  border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer;
  opacity: .55; transition: opacity .15s ease, background .15s ease;
}
.chat-msg:hover .chat-more, .chat-more:focus-visible, .chat-more[aria-expanded="true"] { opacity: 1; }
.chat-more:hover, .chat-more[aria-expanded="true"] { background: var(--surface); color: var(--text); }
.chat-more:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.chat-actions { display: flex; flex-wrap: wrap; gap: 6px; padding-top: 6px; margin-top: 2px; border-top: 1px solid var(--border); }
.chat-actions[hidden] { display: none; }
.chat-act {
  display: inline-flex; align-items: center; gap: 5px; min-height: 32px; padding: 0 10px;
  border: 0; border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; font-size: .84rem; cursor: pointer;
  box-shadow: inset 0 0 0 1px var(--border);
}
.chat-act:hover { box-shadow: inset 0 0 0 1px var(--border-strong); }
.chat-act.danger { color: var(--danger); }
.chat-act.danger:hover { background: var(--danger-soft); }
.chat-msg.deleted { opacity: .75; }
.chat-deleted { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-style: italic; }
.chat-editbar {
  display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 10px;
  background: var(--primary-soft); color: var(--primary); font-size: .88rem; font-weight: 600;
}
.chat-editbar[hidden] { display: none; }
.chat-editbar .chat-act { margin-inline-start: auto; }
.chat-attach:disabled { opacity: .35; cursor: not-allowed; }
.chat-peer { flex-wrap: wrap; }
.chat-peer .chat-settings-btn { margin-inline-start: auto; }
.chat-settings-btn { min-height: 40px; gap: 6px; }
.chat-settings { display: grid; gap: 12px; }
.chat-pref { align-items: flex-start; gap: 10px; }
.chat-pref span { display: grid; gap: 2px; }
.chat-pref small { color: var(--muted); font-size: .82rem; }
.chat-settings-note { margin: 0; font-size: .86rem; }
.chat-danger { display: grid; gap: 8px; padding-top: 12px; border-top: 1px solid var(--border); }
.chat-danger p { margin: 0; font-size: .86rem; }
.chat-danger .btn { justify-self: start; }
@media (hover: none) { .chat-more { opacity: .9; } }

/* ---------- شارات العدد (طلبات + بلاغات) ---------- */
.count-badge {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; margin-inline-start: auto;
  display: inline-grid; place-items: center; flex: none;
  background: var(--danger); color: #fff; font-size: .7rem; font-weight: 700; line-height: 1;
}
.count-badge[hidden] { display: none; }
@media (min-width: 761px) and (max-width: 1100px) {
  .side-link .count-badge { position: absolute; top: 4px; inset-inline-end: 6px; }
}

/* ---------- الحساب المعلّق ---------- */
.pending-page { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.pending-wrap { width: min(560px, 100%); display: grid; gap: 16px; }
.pending-card { display: grid; justify-items: center; text-align: center; gap: 10px; padding: 28px 22px; background: rgba(12, 12, 14, .86); }
.pending-card .brand-mark.has-eye { width: 84px; height: 84px; }
.pending-card h1 { margin: 4px 0 0; font-size: 1.5rem; }
.pending-card p { margin: 0; max-width: 46ch; }
.pending-where { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.pending-where b { color: var(--primary); }
.pending-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 6px; }
.pending-hint { font-size: .84rem; }
.pending-chat-title { font-size: 1.05rem; margin: 6px 0 8px; }
.pending-chat .chat { height: 380px; min-height: 0; }

/* ---------- طلبات الانضمام ---------- */
.request-card { display: flex; align-items: center; gap: 14px; padding: 14px 16px; flex-wrap: wrap; }
.request-text { flex: 1; min-width: 180px; display: grid; gap: 3px; }
.request-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: .86rem; }
.request-actions { display: flex; gap: 8px; }
.request-reject { color: var(--danger); }
.approval-toggle { display: flex; align-items: flex-start; gap: 10px; padding: 14px 16px; margin-bottom: 14px; }
.approval-toggle span { display: grid; gap: 2px; }
.approval-toggle small { color: var(--muted); }
.pending-chip { font-size: .72rem; padding: 1px 8px; margin-top: 2px; justify-self: start; text-decoration: none; }

/* ---------- التبليغات: مرفق + منو شاف + لكل المرحلة ---------- */
.section-chip.whole { background: var(--primary-soft); color: var(--primary); display: inline-flex; align-items: center; gap: 4px; }
.ann-image { display: block; margin-top: 10px; border-radius: 12px; overflow: hidden; max-width: 520px; box-shadow: inset 0 0 0 1px var(--border); }
.ann-image img { display: block; width: 100%; max-height: 420px; object-fit: contain; background: var(--surface-2); }
.ann-file { margin-top: 10px; justify-self: start; max-width: 100%; }
.ann-file span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reads-btn {
  margin-top: 10px; justify-self: start; width: fit-content; display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 0 12px;
  border: 0; border-radius: 10px; background: var(--surface-2); color: var(--muted); font: inherit; font-size: .86rem; cursor: pointer;
  box-shadow: inset 0 0 0 1px var(--border);
}
.reads-btn:hover { color: var(--text); box-shadow: inset 0 0 0 1px var(--border-strong); }
.reads-bar { width: 70px; height: 5px; border-radius: 99px; background: var(--border); overflow: hidden; }
.reads-fill { display: block; height: 100%; background: var(--primary); border-radius: 99px; }
.reads-view { display: grid; gap: 16px; }
.reads-group h3 { font-size: 1rem; margin: 0 0 8px; }
.reads-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; max-height: 260px; overflow-y: auto; }
.reads-person { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 10px; background: var(--surface-2); }
.reads-person small { margin-inline-start: auto; }

/* ---------- البلاغات ---------- */
.report-btn { color: var(--muted); }
.report-btn:hover { color: var(--danger); }
.report-reasons { display: grid; gap: 6px; }
.report-reason { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; cursor: pointer;
  background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--border); }
.report-reason:has(input:checked) { box-shadow: inset 0 0 0 1px var(--primary); background: var(--primary-soft); }
.reports-card, .stats-card { display: grid; gap: 12px; }
.reports-card .sort-bar, .stats-card .sort-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.reports-card h2, .stats-card h2 { display: inline-flex; align-items: center; gap: 6px; }
.reports-list { display: grid; gap: 10px; }
.report-item { display: grid; gap: 6px; padding: 12px 14px; border-radius: 12px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--border); }
.report-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.report-meta { margin: 0; font-size: .84rem; }
.report-note { margin: 0; padding: 8px 10px; border-radius: 8px; background: var(--surface); font-size: .9rem; }
.report-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.reports-empty { margin: 0; }

/* ---------- الإحصائيات ---------- */
.stats-body { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 16px; }
.stx-stages { display: grid; gap: 10px; align-content: start; }
.stx-stages > p { margin: 0; font-size: .86rem; }
.stx-stage { padding: 10px 12px; border-radius: 12px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--border); display: grid; gap: 8px; }
.stx-stage-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.stx-num { color: var(--primary); font-weight: 700; font-family: var(--mono, inherit); }
.stx-sections { display: flex; flex-wrap: wrap; gap: 6px; }
.stx-sec { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; padding: 2px 10px; border-radius: 999px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--border); font-size: .84rem; }
.stx-sec.empty { opacity: .55; }
.stx-sec small { color: var(--warn); }
.stx-top h3 { font-size: 1rem; margin: 0 0 8px; }
.top-list { margin: 0; padding-inline-start: 22px; display: grid; gap: 8px; }
.top-list li { display: grid; gap: 2px; }
.top-title { font-weight: 600; }
.top-list .chip { justify-self: start; }
@media (max-width: 760px) { .stats-body { grid-template-columns: 1fr; } }

/* ---------- خفة الموبايل ----------
   تمويه الخلفية (backdrop-filter) فوگ خلفية متحركة ينعاد حسابه كل إطار ويثقل كرت الشاشة بالتلفون،
   فنشيله بالأجهزة اللمسية والشاشات الصغيرة. الأشرطة أصلاً ألوانها شبه معتمة. */
@media (hover: none), (max-width: 760px) {
  *, *::before, *::after { -webkit-backdrop-filter: none !important; backdrop-filter: none !important; }
  :root[data-theme] :is(.topbar-in, .bottomnav) { background: color-mix(in srgb, var(--surface) 96%, transparent); }
}

/* ---------- نبذة البروفايل + علامة «أنت» ---------- */
.profile-bio { margin: 10px 0 0; max-width: 60ch; color: var(--text-2, var(--muted)); line-height: 1.7; white-space: pre-line; overflow-wrap: anywhere; }
.profile-bio-add { margin-top: 8px; display: inline-flex; align-items: center; gap: 6px; }
.bio-input { min-height: 84px; resize: vertical; }
.bio-count { display: block; margin-top: -6px; font-size: .8rem; color: var(--muted); text-align: end; font-variant-numeric: tabular-nums; }
.me-chip { margin-inline-start: 6px; font-size: .72rem; padding: 1px 8px; }

/* ---------- بوت التحقق بتليگرام ---------- */
.tg-verify { display: grid; gap: 14px; }
.tg-head { display: grid; justify-items: center; gap: 6px; text-align: center; }
.tg-head h1, .tg-head h2 { margin: 0; font-size: 1.25rem; }
.tg-head p { margin: 0; max-width: 42ch; line-height: 1.7; }
.tg-icon { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 14px;
  background: var(--primary-soft); color: var(--primary); box-shadow: inset 0 0 0 1px var(--border-strong); }
.tg-steps { margin: 0; padding-inline-start: 22px; display: grid; gap: 6px; line-height: 1.7; }
.tg-steps li::marker { color: var(--primary); font-weight: 700; }
.tg-open { justify-content: center; text-decoration: none; }
.tg-code { text-align: center; font-size: 1.6rem; letter-spacing: .45em; font-variant-numeric: tabular-nums; padding-inline-start: .45em; }
.tg-wait { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 0; font-size: .9rem; }
.tg-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); animation: tg-pulse 1.2s ease-in-out infinite; }
@keyframes tg-pulse { 0%, 100% { opacity: .25; transform: scale(.8); } 50% { opacity: 1; transform: scale(1.15); } }
.tg-links { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.tg-links .link-btn[disabled] { opacity: .6; cursor: default; }
@media (prefers-reduced-motion: reduce) { .tg-dot { animation: none; } }
.tg-status p { margin: 0; }
.tg-status { display: grid; gap: 6px; }
.tg-state { display: flex; align-items: center; gap: 8px; }
.tg-state-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.tg-state.on .tg-state-dot { background: var(--ok); box-shadow: 0 0 0 4px var(--ok-soft); }
.tg-state.bad .tg-state-dot { background: var(--danger); box-shadow: 0 0 0 4px var(--danger-soft); }
.tg-state.wait .tg-state-dot { background: var(--warn); animation: tg-pulse 1.2s ease-in-out infinite; }
.tg-open-block { display: grid; gap: 8px; }
.tg-manual { border-radius: 10px; padding: 8px 12px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--border); }
.tg-manual summary { cursor: pointer; font-size: .9rem; color: var(--muted); }
.tg-manual p { margin: 8px 0 6px; font-size: .9rem; }
.tg-msg { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tg-msg code { flex: 1; min-width: 0; padding: 8px 10px; border-radius: 8px; background: var(--bg); overflow-wrap: anywhere; font-size: .9rem; }

/* ---------- خانات الناشرين: بطاقات مربعة ---------- */
.publisher-grid { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.pub-tile { position: relative; display: flex; flex-direction: column; gap: 0; padding: 0; overflow: hidden; text-align: center; }
.pub-tile-media {
  display: grid; place-items: center; aspect-ratio: 1 / 1; width: 100%;
  background: linear-gradient(160deg, var(--primary-soft), var(--surface-2));
  border-bottom: 1px solid var(--border); overflow: hidden;
}
.pub-tile-media img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .35s var(--ease); }
.pub-tile:hover .pub-tile-media img { transform: scale(1.04); }
.pub-tile .rank { z-index: 1; background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(4px); }
.pub-tile-body { display: grid; justify-items: center; gap: 4px; padding: 12px 12px 14px; }
.pub-tile-owner { color: var(--muted); font-size: .84rem; overflow-wrap: anywhere; }
@media (max-width: 520px) {
  .publisher-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .pub-tile .avatar { width: 64px !important; height: 64px !important; }
  .pub-tile-body { padding: 10px 8px 12px; }
  .pub-tile .publisher-name { font-size: .95rem; }
}

/* صفحة الخانة */
.pub-hero { display: grid; grid-template-columns: 200px 1fr; gap: 22px; align-items: start; padding: 20px; }
.pub-hero-media { border-radius: 16px; border: 1px solid var(--border); }
.pub-hero-info { display: grid; gap: 10px; min-width: 0; }
.pub-hero-info h1 { margin: 0; font-size: clamp(1.4rem, 3vw, 1.9rem); overflow-wrap: anywhere; }
.pub-owner { display: inline-flex; align-items: center; gap: 8px; color: var(--text); font-weight: 600; justify-self: start; }
.pub-owner:hover { color: var(--primary); }
.pub-about { margin: 0; color: var(--text); line-height: 1.8; max-width: 70ch; }
.pub-rating { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.profile-page-link { justify-self: start; margin-top: 4px; }
@media (max-width: 640px) {
  .pub-hero { grid-template-columns: 1fr; justify-items: center; text-align: center; padding: 16px; }
  .pub-hero-media { width: min(220px, 70vw); }
  .pub-hero-info { justify-items: center; }
  .pub-owner, .profile-page-link { justify-self: center; }
  .pub-rating { justify-content: center; }
}

/* اختيار صورة الخانة: مربع بدل دائرة */
.page-pick-box {
  display: grid; place-items: center; width: 120px; height: 120px; border-radius: 16px; overflow: hidden;
  border: 2px dashed var(--border); background: var(--surface-2); color: var(--muted);
  transition: transform .2s var(--ease), border-color .2s var(--ease);
}
.page-pick:hover .page-pick-box { transform: scale(1.03); border-color: var(--primary); }
.page-pick-box.has-img { border-style: solid; border-color: var(--primary); }
.page-pick-box img { width: 100%; height: 100%; object-fit: cover; display: block; }
.page-pick:focus-within .page-pick-box { outline: 3px solid var(--primary); outline-offset: 3px; }

/* ---------- محاضرات المادة ---------- */
.lecture { display: grid; gap: 10px; }
.lecture-head { display: flex; align-items: flex-start; gap: 12px; }
.lecture-num {
  flex: none; display: grid; place-items: center; width: 38px; height: 38px; border-radius: 11px;
  background: var(--primary-soft); color: var(--primary); font-weight: 800; font-variant-numeric: tabular-nums;
}
.lecture-text { flex: 1; min-width: 0; display: grid; gap: 2px; }
.lecture-text h3 { margin: 0; font-size: 1.05rem; overflow-wrap: anywhere; }
.lecture-date { font-size: .82rem; }
.lecture-body { margin: 0; color: var(--muted); line-height: 1.75; }
.lecture .file-link { justify-self: start; max-width: 100%; }
.lecture .file-link span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- التبليغات: تبويب «العامة» و«الشعبة» ---------- */
.section-tabs.ann-kinds { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 18px; }
.ann-kind { flex-direction: row !important; gap: 8px !important; min-height: 48px; }
.ann-kind b { font-size: .98rem; }
.announcement.general { border-inline-start: 4px solid var(--primary); }

/* زر تبديل اللغة */
.lang-trigger { font: 800 .85rem/1 system-ui, "Segoe UI", sans-serif; letter-spacing: .02em; min-width: 40px; }
.lang-trigger[lang="ar"] { font-size: 1.05rem; }
/* بالإنكليزي (LTR): الأسهم اللي مرسومة للعربي تنقلب حتى تأشر لقدّام */
:root[dir="ltr"] .icon[data-i="chevron"] svg { transform: scaleX(-1); }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- الدعم: منو مستلم المحادثة ---------- */
.sup-agent { display: flex; align-items: center; gap: 12px; margin: 4px 0 12px; padding: 10px 14px;
  background: var(--surface); border: 1px solid var(--border); border-inline-start: 4px solid var(--primary);
  border-radius: var(--r-md); box-shadow: var(--shadow); }
.sup-agent-text { display: grid; gap: 1px; min-width: 0; line-height: 1.35; }
.sup-agent-label { font-size: .76rem; color: var(--muted); font-weight: 600; }
.sup-agent-text strong { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.sup-agent.waiting, .sup-claim.waiting { border-inline-start-color: var(--warn); color: var(--text); font-size: .9rem; }
.sup-dot { flex: none; width: 9px; height: 9px; border-radius: 50%; background: var(--warn); animation: sup-pulse 1.8s ease-out infinite; }
@keyframes sup-pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--warn) 55%, transparent); } 70%, 100% { box-shadow: 0 0 0 8px transparent; } }
.sup-claim { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: -4px 0 12px; padding: 10px 14px;
  border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--border); border-inline-start: 4px solid var(--primary); font-size: .9rem; }
.sup-claim.mine { border-inline-start-color: var(--ok); }
.sup-claim.mine > .icon { color: var(--ok); }
.sup-claim > span:not([class]) { flex: 1; min-width: 180px; }
.sup-close-btn { background: var(--ok); color: #fff; margin-inline-start: auto; }
.sup-close-btn:hover { background: color-mix(in srgb, var(--ok) 85%, #000); }
.sup-state { flex: none; font-size: .72rem; font-weight: 700; padding: 1px 8px; border-radius: 999px; white-space: nowrap; }
.sup-state.waiting { background: var(--warn-soft); color: var(--warn); }
.sup-state.mine { background: var(--ok-soft); color: var(--ok); }
.sup-state.other { background: var(--surface-2); color: var(--muted); box-shadow: inset 0 0 0 1px var(--border); direction: ltr; }
.thread.waiting { box-shadow: inset 3px 0 0 var(--warn), var(--shadow); }
.chat-who-tag { margin-inline-start: 6px; font-size: .68rem; font-weight: 700; padding: 0 6px; border-radius: 999px; background: var(--primary-soft); color: var(--primary); }
.chat-locked { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 0; padding: 14px; color: var(--muted); font-size: .9rem; border-top: 1px solid var(--border); }
@media (prefers-reduced-motion: reduce) { .sup-dot { animation: none; } }

/* تنبيه تغيير اسم المستخدم (مرة وحدة بالشهر) */
.username-note { margin: -4px 0 4px; padding: 10px 12px; border-radius: 10px; font-size: .9rem; line-height: 1.6;
  color: var(--text); background: color-mix(in srgb, var(--primary) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--primary) 40%, transparent); }

/* ربط تليگرام من صفحة التبليغات */
.tg-ann-card { display: flex; align-items: center; gap: 14px; padding: 14px 16px; margin-block-end: 14px;
  border: 1px solid color-mix(in srgb, var(--primary) 30%, transparent); border-radius: var(--r-md, 12px);
  background: color-mix(in srgb, var(--primary) 8%, var(--surface, transparent)); }
.tg-ann-icon { flex: none; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px;
  background: color-mix(in srgb, var(--primary) 16%, transparent); color: var(--primary); }
.tg-ann-text { flex: 1; min-width: 0; display: grid; gap: 2px; line-height: 1.6; }
.tg-ann-text span { color: var(--muted); font-size: .92rem; }
.tg-ann-card .btn { flex: none; }
.tg-link-modal { display: grid; gap: 14px; }
@media (max-width: 560px) {
  .tg-ann-card { flex-wrap: wrap; }
  .tg-ann-card .btn { width: 100%; justify-content: center; }
}

/* ---------- شارات الأخبار والتبليغات بالشريط السفلي و«حسابي» ---------- */
.bottomnav a, .bottomnav .bn-account { position: relative; }
.bottomnav :is(a, .bn-account) .count-badge { position: absolute; top: 2px; inset-inline-end: 50%; margin-inline-end: -26px; min-width: 16px; height: 16px; font-size: .62rem; padding: 0 4px; }

/* ---------- بطاقة «خبر جديد / تبليغ عام جديد» ---------- */
.feed-card {
  position: fixed; z-index: 9000; top: 16px; left: 50%; width: min(460px, calc(100vw - 24px));
  display: flex; align-items: center; gap: 12px; padding: 12px 12px 12px 14px; direction: rtl;
  border-radius: 16px; background: var(--surface); color: var(--text);
  border: 1px solid color-mix(in srgb, var(--primary) 40%, var(--border));
  box-shadow: 0 18px 50px rgba(0, 0, 0, .35), 0 0 0 4px color-mix(in srgb, var(--primary) 10%, transparent);
  transform: translate(-50%, -140%); opacity: 0; transition: transform .45s cubic-bezier(.2, 1.3, .4, 1), opacity .3s;
}
.feed-card.in { transform: translate(-50%, 0); opacity: 1; }
.feed-card.out { transform: translate(-50%, -140%); opacity: 0; }
.feed-card-icon { flex: none; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px;
  background: var(--primary-soft); color: var(--primary); animation: feed-ring 1.2s ease-in-out 2; }
.feed-card-text { flex: 1; min-width: 0; display: grid; gap: 2px; line-height: 1.5; }
.feed-card-text b { font-size: .95rem; }
.feed-card-text span { color: var(--muted); font-size: .88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.feed-card-go { flex: none; padding-inline: 16px; }
.feed-card-x { flex: none; }
@keyframes feed-ring { 0%, 100% { transform: rotate(0); } 20% { transform: rotate(-14deg); } 40% { transform: rotate(12deg); } 60% { transform: rotate(-8deg); } 80% { transform: rotate(5deg); } }
@media (max-width: 760px) { .feed-card { top: 10px; } .feed-card-go { padding-inline: 12px; } }
@media (prefers-reduced-motion: reduce) { .feed-card, .feed-card.in, .feed-card.out { transition: opacity .2s; } .feed-card-icon { animation: none; } }

/* ---------- زر التحديث: يبين بس لمن المنصة مفتوحة من الشاشة الرئيسية ---------- */
.refresh-trigger { display: none; }
html.is-standalone .refresh-trigger { display: inline-grid; }
html.is-reloading .refresh-trigger .icon { animation: ptr-spin .7s linear infinite; }
.ptr { position: fixed; z-index: 9500; top: 8px; left: 50%; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%;
  background: var(--surface); color: var(--primary); box-shadow: 0 8px 24px rgba(0, 0, 0, .3); pointer-events: none; opacity: 0; }
.ptr.ready { background: var(--primary); color: var(--on-primary); }
.ptr-text { position: absolute; top: 52px; white-space: nowrap; font-size: .78rem; font-weight: 600; color: var(--text);
  background: var(--surface); padding: 3px 10px; border-radius: 999px; box-shadow: var(--shadow); }
.ptr .ptr-text { transform: none; }
html.is-reloading .ptr .icon { animation: ptr-spin .7s linear infinite; }
@keyframes ptr-spin { to { transform: rotate(360deg); } }

/* ---------- تعليمات المنصة ---------- */
.guide-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.guide-card { padding: 0; overflow: hidden; display: grid; }
.guide-video { background: #000; display: grid; place-items: center; }
.guide-video video { display: block; width: 100%; max-height: 72vh; background: #000; }
.guide-card.tall .guide-video video { width: auto; max-width: 100%; aspect-ratio: 9 / 16; height: min(72vh, 640px); }
.guide-text { padding: 14px 18px 18px; display: grid; gap: 6px; }
.guide-text h2 { margin: 0; font-size: 1.05rem; display: flex; align-items: center; gap: 8px; }
.guide-text h2 .icon { color: var(--primary); }
.guide-text p { margin: 0; line-height: 1.7; }
.guide-time { justify-self: start; font-variant-numeric: tabular-nums; }
@media (max-width: 900px) { .guide-grid { grid-template-columns: 1fr; } .guide-card.tall .guide-video video { height: min(70vh, 560px); } }

/* ---------- المساعدة بمكان واضح ---------- */
.help-pill {
  display: inline-flex; align-items: center; gap: 6px; flex: none; text-decoration: none;
  padding: 6px 12px; border-radius: 999px; font-weight: 700; font-size: .85rem;
  background: var(--primary); color: var(--on-primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 22%, transparent);
  animation: help-glow 2.8s ease-in-out infinite;
}
.help-pill:hover { filter: brightness(1.08); }
.help-pill .icon { display: grid; }
.help-pill-side { display: flex; justify-content: center; margin: 0 0 10px; padding: 10px 14px; border-radius: 12px; font-size: .92rem; }
/* الشريط الفوگاني بالتلفون: الشعار وزر المساعدة يمين، والأزرار الصغيرة يسار (بدون تداخل) */
.mobilebar .topbar-in { justify-content: flex-start; gap: 6px; }
.mobilebar :is(.theme-trigger, .support-trigger) { position: static; margin: 0; inset: auto; }
.mobilebar .help-pill { margin-inline-end: auto; }
@media (max-width: 430px) { .mobilebar .brand > span:last-child { display: none; } }
.sidebar .help-pill:not(.help-pill-side) { display: none; }
.mobilebar .help-pill-side { display: none; }
@keyframes help-glow { 0%, 100% { box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 22%, transparent); } 50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--primary) 8%, transparent); } }
/* عنصر المساعدة بالقائمة الجانبية: مميز */
.side-link[data-nav="guide"] { border: 1px dashed color-mix(in srgb, var(--primary) 55%, transparent); }
.side-link[data-nav="guide"] .icon { color: var(--primary); }
/* بطاقة المساعدة بالرئيسية */
.help-card { display: flex; align-items: center; gap: 14px; padding: 16px 18px; position: relative;
  border: 1px solid color-mix(in srgb, var(--primary) 45%, var(--border)) !important;
  background: linear-gradient(120deg, color-mix(in srgb, var(--primary) 12%, var(--surface)), var(--surface)) !important; }
.help-card-icon { flex: none; display: grid; place-items: center; width: 54px; height: 54px; border-radius: 14px; background: var(--primary-soft); color: var(--primary); }
.help-card-text { flex: 1; min-width: 0; display: grid; gap: 4px; line-height: 1.6; }
.help-card-text strong { font-size: 1.05rem; }
.help-card-text span { color: var(--muted); font-size: .92rem; }
.help-card .btn { flex: none; }
.help-card-x { flex: none; }
@media (max-width: 640px) {
  .help-card { display: grid; grid-template-columns: auto 1fr; padding: 14px; padding-inline-end: 40px; }
  .help-card .btn { grid-column: 1 / -1; justify-content: center; }
  .help-card-x { position: absolute; top: 8px; inset-inline-end: 8px; }
  .help-pill { padding: 6px 10px; font-size: .8rem; }
}
@media (prefers-reduced-motion: reduce) { .help-pill { animation: none; } }

/* ---------- رجوع / تقدّم / تحديث (وضع الشاشة الرئيسية) ---------- */
.navc {
  position: fixed; z-index: 25; inset-inline-start: 12px; bottom: calc(92px + env(safe-area-inset-bottom));
  display: flex; gap: 2px; padding: 4px; border-radius: 999px; direction: rtl;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border: 1px solid var(--border); box-shadow: 0 10px 28px rgba(0, 0, 0, .28);
}
html[dir="ltr"] .navc { direction: ltr; }
.navc-btn {
  width: 40px; height: 40px; border: 0; border-radius: 50%; display: grid; place-items: center; cursor: pointer;
  background: transparent; color: var(--text); -webkit-tap-highlight-color: transparent;
}
.navc-btn:active { background: var(--primary-soft); color: var(--primary); transform: scale(.92); }
.navc-btn:disabled { opacity: .3; cursor: default; }
.navc-btn:disabled:active { background: transparent; transform: none; }
@media (min-width: 761px) { .navc { bottom: 20px; inset-inline-start: auto; inset-inline-end: 50%; transform: translateX(-50%); } html[dir="ltr"] .navc { transform: translateX(50%); } }
/* زر التحديث صار بالشريط الصغير، فما نكرره بالشريط الفوگاني بالتلفون */
html.is-standalone :is(.mobilebar, .side-top) .refresh-trigger { display: none; }
body:has(.modal) .navc, body:has(.menu-layer) .navc { display: none; }

/* ---------- صفحة الملخصات: أزرار المواد بسطر واحد يتمرر بالتلفون ---------- */
@media (max-width: 640px) {
  .summary-stage-list { min-width: 0; }
  .summary-stage-list .sort-bar { flex-wrap: wrap; }
  .summary-stage-list .filters { flex: 1 1 100%; width: 100%; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 4px;
    max-width: 100%; min-width: 0; scroll-snap-type: x proximity; }
  .summary-stage-list .filters::-webkit-scrollbar { display: none; }
  .summary-stage-list .filters .filter { flex: none; white-space: nowrap; scroll-snap-align: start; }
}

/* ---------- نسيت كلمة المرور ---------- */
.forgot-links { display: flex; justify-content: center; margin-top: 12px; }
.forgot-link { font-size: .92rem; }
.forgot-intro { display: grid; justify-items: center; text-align: center; gap: 6px; margin-bottom: 14px; }
.forgot-intro strong { font-size: 1.1rem; }
.forgot-intro p { margin: 0; line-height: 1.7; }
.forgot-intro .btn { margin-top: 6px; }
.forgot-icon { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center;
  background: var(--primary-soft); color: var(--primary); }
