/* ==========================================================================
   الحيوية: تدرّجات لونية، حركة هادئة، تفاعل مع المؤشر
   تُحمَّل بعد style.css. كل حركة هنا تتوقف لمن فعّل «تقليل الحركة» في جهازه.
   ========================================================================== */

:root {
  --grad-a: #0F766E; --grad-b: #0E7490; --orb: #5EEAD4;
  --grad: linear-gradient(120deg, var(--grad-a), var(--grad-b));
  --grad-dark: linear-gradient(120deg, color-mix(in srgb, var(--grad-a) 78%, #000), color-mix(in srgb, var(--grad-b) 78%, #000));
  --icon-on: #FFFFFF;
  --spring: cubic-bezier(.34, 1.56, .64, 1);
}
:root[data-theme="lilac"] { --grad-a: #6D28D9; --grad-b: #BE185D; --orb: #F0ABFC; }
:root[data-theme="rose"]  { --grad-a: #BE185D; --grad-b: #C2410C; --orb: #FDBA74; }
:root[data-theme="sand"]  { --grad-a: #B45309; --grad-b: #A16207; --orb: #FDE68A; }
:root[data-mode="dark"] { --icon-on: rgba(0, 0, 0, .78); }

/* الخلفية تتحرك ببطء شديد كأنها تتنفس */
body::before { inset: -12%; animation: drift 28s ease-in-out infinite alternate; will-change: transform; }
@keyframes drift {
  0%   { transform: translate3d(0, 0, 0) scale(1); }
  50%  { transform: translate3d(-3%, 2%, 0) scale(1.06); }
  100% { transform: translate3d(2%, -2%, 0) scale(1.02); }
}

/* ---------- الترحيب: لوحة ملوّنة حيّة ---------- */
.hero {
  position: relative; overflow: hidden; isolation: isolate;
  display: grid; gap: 18px; padding: 28px;
  background: var(--grad); color: #fff;
  box-shadow: 0 18px 40px -12px color-mix(in srgb, var(--grad-a) 55%, transparent);
}
[data-mode="dark"] .hero { background: var(--grad-dark); box-shadow: 0 18px 40px -16px rgba(0, 0, 0, .6); }
.hero p, .hero .hero-date { color: rgba(255, 255, 255, .9); }
.hero-orb {
  position: absolute; z-index: -1; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle at 30% 30%, color-mix(in srgb, var(--orb) 80%, #fff), transparent 70%);
  opacity: .45;
  animation: float 9s ease-in-out infinite;
}
.hero-orb.o1 { width: 220px; height: 220px; top: -90px; inset-inline-start: -50px; }
.hero-orb.o2 { width: 150px; height: 150px; bottom: -70px; inset-inline-end: 18%; opacity: .3; animation-duration: 12s; animation-delay: -4s; }
.hero-orb.o3 {
  width: 70px; height: 70px; top: 22px; inset-inline-end: 8%; opacity: .4; animation-duration: 7s; animation-delay: -2s;
  background: none; border: 3px solid rgba(255, 255, 255, .55);
}
@keyframes float {
  0%, 100% { transform: translate3d(0, 0, 0); }
  50%      { transform: translate3d(10px, -14px, 0) scale(1.05); }
}
.hero-top { display: flex; align-items: center; gap: 18px; }
.hero .avatar { box-shadow: 0 0 0 4px rgba(255, 255, 255, .35), 0 10px 24px rgba(0, 0, 0, .18); }
.hero-hello { display: grid; gap: 2px; min-width: 0; }
.hero-date { font-size: .88rem; font-weight: 500; }
.hero h1 { font-size: 1.75rem; line-height: 1.35; color: #fff; }
.hero-name { display: inline-block; animation: name-in .7s var(--spring) .15s both; }
@keyframes name-in { from { opacity: 0; transform: translateY(10px) scale(.9); } to { opacity: 1; transform: none; } }
.hero-tip { font-size: .95rem; max-width: 60ch; }
.hero-tip b { font-weight: 700; color: #fff; }
.hero-stats { display: flex; flex-wrap: wrap; gap: 10px; }
.hero-stat {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 16px; border-radius: 999px;
  background: rgba(255, 255, 255, .16); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .24);
  font-size: .92rem; color: #fff;
}
.hero-stat b { font-size: 1.15rem; font-weight: 700; font-variant-numeric: tabular-nums; min-width: 1ch; }
.hero-search { box-shadow: 0 10px 26px rgba(0, 0, 0, .14); }
.hero-search:hover { transform: translateY(-1px); }

/* ---------- البطاقات والأيقونات تتبع لون المظهر المختار ----------
   بدل ألوان ثابتة (أزرق، برتقالي…) تتعارض مع الوردي أو الرملي.
   لون المادة يبقى ظاهراً في الشارة الصغيرة فقط. */
:is(.tile, .stat, .mini-item, .row-card, .subject, .empty) {
  --tint: var(--primary-soft); --tint-fg: var(--primary);
}
.tile { background: linear-gradient(135deg, color-mix(in srgb, var(--primary) 7%, var(--surface)), var(--surface)); }
.subject { background: linear-gradient(180deg, color-mix(in srgb, var(--primary) 8%, var(--surface)), var(--surface) 60%); }
.stat { background: linear-gradient(160deg, color-mix(in srgb, var(--primary) 8%, var(--surface)), var(--surface) 62%); }

/* أيقونة ناعمة بلون المظهر، وتمتلئ بالتدرّج عند المرور */
:is(.tile, .subject, .row-main, .stat, .empty) .tile-icon, .mini-icon {
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--grad-a) 15%, var(--surface)),
    color-mix(in srgb, var(--grad-b) 11%, var(--surface)));
  color: var(--primary);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--primary) 12%, transparent),
              0 6px 14px -6px color-mix(in srgb, var(--grad-a) 35%, transparent);
  transition: transform .45s var(--spring), color .25s, box-shadow .25s;
}
[data-mode="dark"] :is(.tile, .subject, .row-main, .stat, .empty) .tile-icon,
[data-mode="dark"] .mini-icon {
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--primary) 20%, var(--surface)),
    color-mix(in srgb, var(--primary) 10%, var(--surface)));
}
.tile:hover .tile-icon, .subject:hover .tile-icon, .row-card:hover .tile-icon, .mini-item:hover .mini-icon {
  transform: rotate(-8deg) scale(1.1);
  background: var(--grad); color: #fff;
  box-shadow: 0 10px 20px -6px color-mix(in srgb, var(--grad-a) 55%, transparent);
}
[data-mode="dark"] :is(.tile:hover .tile-icon, .subject:hover .tile-icon, .row-card:hover .tile-icon, .mini-item:hover .mini-icon) {
  background: var(--grad-dark);
}

/* ---------- إضاءة ناعمة تتبع المؤشر فوق البطاقات ---------- */
.tile, .mini-item { position: relative; }
:is(.tile, .subject, .row-card, .mini-item, .stat, .news)::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: radial-gradient(240px circle at var(--mx, 50%) var(--my, 50%),
    color-mix(in srgb, var(--tint-fg, var(--primary)) 14%, transparent), transparent 70%);
  opacity: 0; transition: opacity .3s;
}
:is(.tile, .subject, .row-card, .mini-item, .stat, .news):hover::after { opacity: 1; }
.tile:hover, .subject:hover { transform: translateY(-4px); }
.tile:hover, .subject:hover, .row-card:hover, .mini-item:hover {
  box-shadow: 0 20px 40px -14px color-mix(in srgb, var(--tint-fg, var(--primary)) 40%, transparent), var(--shadow);
}

/* ---------- بطاقة المادة: علامة كبيرة باهتة في الخلفية ---------- */
.subject-mark {
  position: absolute; inset-inline-end: -26px; bottom: -30px; color: var(--tint-fg); opacity: .08;
  transform: rotate(-12deg); transition: transform .6s var(--spring), opacity .3s; pointer-events: none;
}
.subject:hover .subject-mark { transform: rotate(-4deg) scale(1.08); opacity: .14; }
.subject-link > :not(.subject-mark, .ripple) { position: relative; }

/* ---------- آخر الأخبار والملخصات ---------- */
.mini-item { display: flex; align-items: center; gap: 14px; }
.mini-icon { display: grid; place-items: center; flex: none; width: 42px; height: 42px; border-radius: 13px; }
.mini-text { display: grid; gap: 2px; min-width: 0; }
.mini-item .mini-text > span { color: var(--muted); font-size: .85rem; }

.section-title h2 { display: flex; align-items: center; gap: 10px; }
.section-title h2::before { content: ""; width: 6px; height: 22px; border-radius: 99px; background: var(--grad); }
.page-head h1 { background: linear-gradient(120deg, var(--text) 40%, var(--primary)); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* ---------- الشعار والتنقل ---------- */
.brand-mark {
  background: var(--grad); color: #fff; transition: transform .45s var(--spring);
  box-shadow: 0 8px 18px -6px color-mix(in srgb, var(--grad-a) 60%, transparent);
}
.brand:hover .brand-mark { transform: rotate(-8deg) scale(1.06); }
.nav a.active { background: var(--grad); color: #fff; box-shadow: 0 8px 18px -8px color-mix(in srgb, var(--grad-a) 70%, transparent); }
[data-mode="dark"] .nav a.active { background: var(--grad-dark); }

/* ---------- الأزرار: لمعة تمر عند المرور ---------- */
.btn::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, .35) 50%, transparent 65%);
  transform: translateX(110%); transition: transform .7s var(--ease);
}
.btn:hover::before { transform: translateX(-110%); }
.btn-ghost::before { background: linear-gradient(105deg, transparent 35%, color-mix(in srgb, var(--primary) 14%, transparent) 50%, transparent 65%); }

/* ---------- تموّج عند الضغط ---------- */
:is(.btn, .tile, .subject-link, .row-main, .mini-item, .bottomnav a, .filter, .hero-search) { position: relative; overflow: hidden; }
.ripple {
  position: absolute; border-radius: 50%; pointer-events: none;
  background: currentColor; opacity: .16; transform: scale(0);
  animation: ripple .6s var(--ease) forwards;
}
@keyframes ripple { to { transform: scale(1); opacity: 0; } }

/* ---------- الإحصاءات في لوحة التحكم ---------- */
.stat-value { background: linear-gradient(120deg, var(--text) 30%, var(--tint-fg)); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* ---------- الهاتف ---------- */
@media (max-width: 760px) {
  .hero { padding: 22px 18px; gap: 16px; }
  .hero h1 { font-size: 1.4rem; }
  .hero-top { gap: 14px; }
  .hero-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .hero-stat { justify-content: center; gap: 6px; padding: 6px 8px; font-size: .82rem; }
  .hero-stat .icon { display: none; }
  .hero-orb.o1 { width: 160px; height: 160px; }
  .bottomnav a .icon { transition: transform .45s var(--spring); }
  .bottomnav a.active { background: var(--grad); color: #fff; }
  [data-mode="dark"] .bottomnav a.active { background: var(--grad-dark); }
  .bottomnav a.active .icon { transform: translateY(-2px) scale(1.12); }
}
@media (max-width: 420px) {
  .hero-top .avatar { width: 52px; height: 52px; }
}

@media (prefers-reduced-motion: reduce) {
  body::before, .hero-orb, .hero-name { animation: none; }
  .btn::before { display: none; }
}

/* ==========================================================================
   خط العناوين، صفحة الدخول، الأغلفة، ترتيب بينتو، الانتقالات، الرسومات
   ========================================================================== */

h1, h2, h3, .brand, .hero-stat b, .stat-value, .auth-art-title {
  font-family: "Alexandria", "Noto Sans Arabic", system-ui, sans-serif;
  letter-spacing: 0;
}
h1 { font-weight: 700; }
h2, h3 { font-weight: 600; }

/* الرسائل والقصاصات تظهر فوق قارئ الملازم أيضاً */
#toast-root { z-index: 80; }
.confetti { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 90; pointer-events: none; }

/* ---------- صفحة الدخول: لوحة ملوّنة + النموذج ---------- */
.auth { padding: 24px 16px; }
.auth-shell {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 440px);
  width: 100%; max-width: 980px; border-radius: 32px; overflow: hidden;
  background: var(--surface); box-shadow: var(--shadow-lift);
  animation: rise .45s var(--ease) both;
}
.auth-shell .auth-card { max-width: none; border: 0; border-radius: 0; box-shadow: none; animation: none; padding: 34px 32px 28px; }
.auth-art {
  position: relative; overflow: hidden; isolation: isolate;
  display: flex; flex-direction: column; gap: 22px; padding: 36px 34px;
  background: var(--grad); color: #fff;
}
[data-mode="dark"] .auth-art { background: var(--grad-dark); }
.auth-art .hero-orb.o1 { width: 300px; height: 300px; top: auto; bottom: -120px; inset-inline-start: -90px; }
.auth-art .hero-orb.o2 { top: -50px; bottom: auto; inset-inline-end: -40px; }
.auth-art .hero-orb.o3 { top: auto; bottom: 34%; inset-inline-end: 12%; }
.auth-art-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.05rem; }
.auth-art .brand-mark { background: rgba(255, 255, 255, .2); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .3); }
.auth-art-title { font-size: 2.1rem; line-height: 1.35; font-weight: 700; margin-top: auto; text-wrap: balance; }
.auth-art-title span { display: block; color: color-mix(in srgb, var(--orb) 55%, #fff); }
.auth-feats { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.auth-feats li {
  display: flex; align-items: center; gap: 14px; padding: 12px 14px; border-radius: 18px;
  background: rgba(255, 255, 255, .12); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .18);
  animation: rise .5s var(--ease) both;
}
.auth-feats li:nth-child(2) { animation-delay: .08s; }
.auth-feats li:nth-child(3) { animation-delay: .16s; }
.auth-feats li > span:last-child { display: grid; line-height: 1.5; }
.auth-feats strong { font-weight: 700; }
.auth-feats li > span:last-child > span { font-size: .88rem; color: rgba(255, 255, 255, .9); }
.auth-feat-icon {
  display: grid; place-items: center; flex: none; width: 42px; height: 42px; border-radius: 13px;
  background: rgba(255, 255, 255, .95); color: var(--grad-a);
}
@media (max-width: 820px) {
  .auth { padding: 0; place-items: stretch; }
  .auth-shell { grid-template-columns: 1fr; border-radius: 0; max-width: none; min-height: 100dvh; box-shadow: none; }
  .auth-art { padding: 24px 20px 56px; gap: 14px; }
  .auth-art-title { font-size: 1.45rem; margin-top: 0; }
  .auth-feats { display: none; }
  .auth-shell .auth-card { margin-top: -32px; border-radius: 28px 28px 0 0; padding: 26px 20px 28px; position: relative; }
}

/* ---------- ترتيب بينتو للرئيسية ---------- */
.bento { grid-template-columns: repeat(4, minmax(0, 1fr)); grid-auto-rows: minmax(118px, auto); }
.bento .tile { grid-column: span 2; }
.bento .tile-big { grid-row: span 2; flex-direction: column; align-items: flex-start; gap: 14px; padding: 24px; }
.bento-4 .tile:nth-child(3), .bento-4 .tile:nth-child(4) {
  grid-column: span 1; flex-direction: column; align-items: flex-start; justify-content: center; gap: 10px;
}
.bento-4 .tile:nth-child(3) .tile-text > span, .bento-4 .tile:nth-child(4) .tile-text > span,
.bento-4 .tile:nth-child(3) .tile-arrow, .bento-4 .tile:nth-child(4) .tile-arrow { display: none; }
.bento-4 .tile:nth-child(3) .tile-meta, .bento-4 .tile:nth-child(4) .tile-meta { position: absolute; top: 16px; inset-inline-end: 16px; }
.tile-big .tile-icon { width: 66px; height: 66px; border-radius: 20px; }
.tile-big .tile-text strong { font-size: 1.4rem; }
.tile-big .tile-meta { position: absolute; top: 22px; inset-inline-end: 22px; }
.tile-big .tile-arrow {
  margin-top: auto; align-self: flex-end; width: 44px; height: 44px; display: grid; place-items: center;
  border-radius: 50%; background: var(--surface); box-shadow: var(--shadow);
}
.tile-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.tile-chips .chip { background: var(--surface); box-shadow: inset 0 0 0 1px var(--border); color: var(--text); }
@media (max-width: 760px) {
  .bento { grid-template-columns: 1fr 1fr; grid-auto-rows: auto; }
  .bento .tile, .bento .tile-big { grid-column: span 2; grid-row: auto; }
  .bento-4 .tile:nth-child(3), .bento-4 .tile:nth-child(4) { grid-column: span 1; }
  .bento .tile-big { padding: 20px; }
  .tile-big .tile-text strong { font-size: 1.2rem; }
  .bento .tile-meta { display: inline-flex; }
}

/* ---------- غلاف الملزمة ---------- */
.cover {
  position: relative; flex: none; display: grid; place-items: center;
  width: 62px; height: 82px; border-radius: 10px; overflow: hidden;
  background: linear-gradient(160deg, color-mix(in srgb, var(--grad-a) 16%, var(--surface)), color-mix(in srgb, var(--grad-b) 10%, var(--surface)));
  color: var(--primary);
  box-shadow: 0 8px 18px -8px color-mix(in srgb, var(--grad-a) 45%, transparent), inset 0 0 0 1px var(--border);
  transition: transform .45s var(--spring), box-shadow .3s;
}
.cover img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: top;
  opacity: 0; transition: opacity .4s ease;
}
.cover.cover-ready img { opacity: 1; }
.cover.cover-ready .cover-icon { opacity: 0; }
.cover-badge {
  position: absolute; bottom: 5px; inset-inline-start: 5px; z-index: 1;
  padding: 0 6px; border-radius: 6px; font: 700 .62rem/1.6 system-ui, sans-serif; letter-spacing: .3px;
  background: var(--grad); color: #fff;
}
.cover-pdf:not(.cover-ready):not(.cover-failed)::before {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(100deg, transparent 30%, rgba(255, 255, 255, .45) 50%, transparent 70%);
  background-size: 200% 100%; animation: shimmer 1.3s linear infinite;
}
.row-card:hover .cover { transform: rotate(-4deg) scale(1.06); }

/* ---------- انتقالات الصفحات ---------- */
#view { view-transition-name: page; }
::view-transition-old(page) { animation: vt-out .18s ease both; }
::view-transition-new(page) { animation: vt-in .32s var(--ease) both; }
::view-transition-group(subject-title) { animation-duration: .38s; animation-timing-function: var(--ease); }
@keyframes vt-out { to { opacity: 0; transform: translateY(-6px); } }
@keyframes vt-in { from { opacity: 0; transform: translateY(12px); } }

/* ---------- هيكل التحميل بشكل الصفحة ---------- */
.skeleton-wrap .skeleton:first-child { width: auto; }
.skeleton.sk-head { height: 56px; width: 45%; max-width: 360px; }
.skeleton.sk-hero { height: 250px; }
.sk-bento { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); grid-auto-rows: 118px; gap: 14px; }
.sk-bento .skeleton { height: auto; grid-column: span 2; }
.sk-bento .sk-big { grid-row: span 2; }
.sk-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.skeleton.sk-card { height: 170px; }
.skeleton.sk-row { height: 114px; }
.skeleton.sk-news { height: 130px; }
.sk-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.skeleton.sk-stat { height: 116px; }
.skeleton.sk-table { height: 280px; }
@media (max-width: 760px) {
  .sk-bento { grid-template-columns: 1fr; grid-auto-rows: 100px; }
  .sk-bento .skeleton { grid-column: auto; }
  .sk-stats { grid-template-columns: 1fr 1fr; }
  .skeleton.sk-hero { height: 300px; }
}

/* ---------- رسمة الصفحة الفارغة ---------- */
.empty { border: 0; background: linear-gradient(180deg, color-mix(in srgb, var(--primary) 6%, var(--surface)), var(--surface)); box-shadow: var(--shadow); }
.empty-art { position: relative; width: 180px; height: 135px; margin-bottom: 4px; }
.empty-art svg { width: 100%; height: 100%; display: block; overflow: visible; }
.ea-blob { fill: color-mix(in srgb, var(--primary) 12%, transparent); }
.ea-sheet { fill: var(--surface); stroke: color-mix(in srgb, var(--primary) 30%, transparent); stroke-width: 1.5; }
.ea-back { fill: color-mix(in srgb, var(--grad-b) 14%, var(--surface)); }
.ea-spark { fill: var(--grad-b); opacity: .7; transform-box: fill-box; transform-origin: center; animation: twinkle 2.4s ease-in-out infinite; }
.ea-spark.s2 { fill: var(--grad-a); animation-delay: -1.2s; }
.ea-dot { fill: color-mix(in srgb, var(--primary) 40%, transparent); }
@keyframes twinkle { 50% { transform: scale(.6) rotate(45deg); opacity: .35; } }
.empty-art-icon {
  position: absolute; top: 50%; left: 50%; margin: -26px 0 0 -22px;
  display: grid; place-items: center; width: 52px; height: 52px; border-radius: 16px;
  background: var(--grad); color: #fff; box-shadow: 0 10px 22px -8px color-mix(in srgb, var(--grad-a) 60%, transparent);
  animation: float 6s ease-in-out infinite;
}
[data-mode="dark"] .empty-art-icon { background: var(--grad-dark); }

@media (prefers-reduced-motion: reduce) {
  .ea-spark, .empty-art-icon, .cover-pdf::before { animation: none; }
  ::view-transition-old(page), ::view-transition-new(page), ::view-transition-group(subject-title) { animation: none; }
}

/* ==========================================================================
   صور المواد
   ========================================================================== */

/* أدوات المدير فوق البطاقة: تغيير الصورة + الحذف */
.subject .card-tools {
  position: absolute; top: 10px; inset-inline-end: 10px; z-index: 2;
  display: flex; gap: 6px;
}
.subject .card-tools .card-del { position: static; }
.subject .card-tools .icon-btn {
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  box-shadow: var(--shadow);
}

/* الصورة أعلى البطاقة */
.subject-photo {
  display: block; margin: -20px -20px 0; aspect-ratio: 16 / 9; overflow: hidden;
  border-radius: var(--r-lg) var(--r-lg) 0 0; background: var(--surface-2);
}
.subject-photo img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  transition: transform .6s var(--ease);
}
.subject:hover .subject-photo img { transform: scale(1.06); }
.has-photo .subject-link > .tile-icon {
  margin-top: -44px; box-shadow: 0 0 0 4px var(--surface), 0 8px 18px -6px color-mix(in srgb, var(--grad-a) 45%, transparent);
  background: var(--surface);
}
.has-photo:hover .subject-link > .tile-icon { background: var(--grad); }
[data-mode="dark"] .has-photo:hover .subject-link > .tile-icon { background: var(--grad-dark); }
.subject.has-photo { background: var(--surface); }

/* صفحة المادة: الصورة كرأس عريض والعنوان فوقها */
.page-head.subject-banner {
  position: relative; overflow: hidden; isolation: isolate; align-items: flex-end;
  min-height: 220px; padding: 24px; border-radius: var(--r-lg); color: #fff;
  box-shadow: 0 18px 40px -16px rgba(0, 0, 0, .35);
}
.subject-banner-img {
  position: absolute; inset: 0; z-index: -2; width: 100%; height: 100%; object-fit: cover;
  animation: banner-in 1.2s var(--ease) both;
}
.page-head.subject-banner::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: linear-gradient(0deg, rgba(0, 0, 0, .72), rgba(0, 0, 0, .15) 70%);
}
.page-head.subject-banner h1 { color: #fff; background: none; -webkit-background-clip: border-box; background-clip: border-box; }
.page-head.subject-banner p { color: rgba(255, 255, 255, .88); }
@keyframes banner-in { from { transform: scale(1.08); } to { transform: none; } }

/* مربع اختيار الصورة في النموذج */
.cover-pick {
  position: relative; display: grid; place-items: center; aspect-ratio: 16 / 9; width: 100%; user-select: none;
  border-radius: 18px; overflow: hidden; cursor: pointer;
  border: 2px dashed var(--border-strong); background: var(--surface-2); color: var(--muted);
  transition: border-color .2s, color .2s;
}
.cover-pick:hover { border-color: var(--primary); color: var(--primary); }
.cover-pick:focus-within { outline: 3px solid color-mix(in srgb, var(--primary) 55%, transparent); outline-offset: 3px; }
.cover-pick-hint { display: grid; justify-items: center; gap: 6px; font-weight: 600; font-size: .92rem; }
.cover-pick.has-img { border-style: solid; border-color: transparent; }

@media (max-width: 760px) {
  .page-head.subject-banner { min-height: 180px; padding: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  .subject-banner-img { animation: none; }
}

/* ---------- محرر الصورة: تكبير وتحريك واختيار الارتفاع ---------- */
.cover-editor { display: grid; gap: 14px; }
.cover-pick { touch-action: none; }
.cover-pick.has-img { cursor: grab; }
.cover-pick.dragging { cursor: grabbing; }
.crop-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: none; }
.cover-pick.has-img .crop-canvas { display: block; }
.cover-pick.has-img .cover-pick-hint { display: none; }
.crop-hint {
  position: absolute; bottom: 10px; inset-inline-start: 50%; transform: translateX(50%);
  padding: 4px 12px; border-radius: 999px; background: rgba(0, 0, 0, .55); color: #fff;
  font-size: .8rem; white-space: nowrap; pointer-events: none; display: none;
  transition: opacity .2s;
}
.cover-pick.has-img .crop-hint { display: block; }
.cover-pick.dragging .crop-hint { opacity: 0; }
.crop-controls { display: none; gap: 12px; }
.cover-editor.has-img .crop-controls { display: grid; }
.crop-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.crop-label { font-weight: 600; font-size: .9rem; min-width: 92px; }
.crop-zoom { flex: 1; min-width: 120px; accent-color: var(--primary); height: 44px; cursor: pointer; }
.size-opts { display: flex; gap: 6px; flex: 1; }
.size-opt {
  flex: 1; display: grid; justify-items: center; gap: 4px; min-height: 64px; padding: 8px 6px;
  border: 0; border-radius: 14px; cursor: pointer;
  background: var(--surface-2); color: var(--muted); font-weight: 600; font-size: .85rem;
  box-shadow: inset 0 0 0 1px var(--border);
  transition: background .2s, color .2s, box-shadow .2s;
}
.size-opt:hover { color: var(--text); }
.size-opt[aria-pressed="true"] {
  background: var(--primary-soft); color: var(--primary);
  box-shadow: inset 0 0 0 2px var(--primary);
}
.size-shape { width: 42px; border-radius: 5px; background: currentColor; opacity: .55; }
.size-shape.size-sm { aspect-ratio: 21 / 9; }
.size-shape.size-md { aspect-ratio: 16 / 9; }
.size-shape.size-lg { aspect-ratio: 4 / 3; }
.btn-sm { min-height: 44px; padding: 0 16px; font-size: .92rem; justify-self: start; }

/* الارتفاع المختار للصورة في البطاقة وفي صفحة المادة */
.subject-photo.size-sm { aspect-ratio: 21 / 9; }
.subject-photo.size-md { aspect-ratio: 16 / 9; }
.subject-photo.size-lg { aspect-ratio: 4 / 3; }
.page-head.subject-banner.size-sm { min-height: 160px; }
.page-head.subject-banner.size-md { min-height: 230px; }
.page-head.subject-banner.size-lg { min-height: 320px; }
@media (max-width: 760px) {
  .page-head.subject-banner.size-sm { min-height: 130px; }
  .page-head.subject-banner.size-md { min-height: 180px; }
  .page-head.subject-banner.size-lg { min-height: 250px; }
  .crop-label { min-width: 0; width: 100%; }
}

/* ---------- إعدادات المنصة في لوحة التحكم ---------- */
.settings-card { padding: 20px 22px; }
.settings-card .section-title { margin-bottom: 8px; }
.site-form { display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.site-form > .field { flex: 1 1 280px; margin: 0; }
.site-form > .form-actions { margin-top: 31px; }
@media (max-width: 760px) { .site-form > .form-actions { margin-top: 0; width: 100%; } .site-form .btn { width: 100%; } }
