/* ==========================================================================
   هيدر الموبايل المتطور والأنيق (≤720px) — متناسق تماماً مع الصورة المرفقة
   1. زر القائمة على اليسار (3 خطوط حمراء مستديرة وأنيقة بدون إطار ممتلئ)
   2. لوجو خفيف وأنيق في المنتصف تماماً (أيقونة متطورة + اسم المنصة + سطر تعريفي)
   3. مفتاح الوضع الليلي والنهاري الكبسولي المتطور على اليمين
   ========================================================================== */
.hm {
  display: none;
}

.hxp {
  display: none;
}

@media (max-width: 720px) {
  html {
    --hx-h: 62px;
    scroll-padding-top: calc(var(--hx-h) + 10px);
  }

  /* تثبيت الهيدر أعلى الشاشة بكامل العرض وبدون زوايا عائمة مع شريط أنيق بالأسفل */
  :is(.pg, body) .hx {
    position: sticky !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 1000 !important;
    width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
    background: var(--card) !important;
    border-bottom: 2px solid #2DD4BF !important;
    box-shadow: 0 2px 12px rgba(38, 54, 74, 0.05) !important;
    box-sizing: border-box !important;
  }

  html[data-theme=dark] :is(.pg, body) .hx {
    background: #111B27 !important;
    border-bottom-color: #0D9488 !important;
    box-shadow: 0 2px 14px rgba(0, 0, 0, 0.25) !important;
  }

  /* الحاوية الداخلية: صف أفقي دقيق يضمن زر القائمة يساراً والمفتاح يميناً */
  :is(.pg, body) .hx .hd {
    position: relative !important;
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: space-between !important;
    direction: ltr !important;
    height: var(--hx-h) !important;
    min-height: var(--hx-h) !important;
    padding: 0 16px !important;
    margin: 0 auto !important;
    width: 100% !important;
    max-width: 100% !important;
    border-radius: 0 !important;
    border: none !important;
    box-shadow: none !important;
    background: transparent !important;
    box-sizing: border-box !important;
  }

  /* 1) زر القائمة (الهامبرغر): على اليسار — 3 خطوط بلون مرجاني/أحمر أنيق كما في الصورة */
  :is(.pg, body) .hx .hm {
    order: 1 !important;
    display: inline-flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 4.5px !important;
    width: 40px !important;
    height: 40px !important;
    padding: 0 !important;
    border: none !important;
    border-radius: 10px !important;
    background: transparent !important;
    cursor: pointer !important;
    -webkit-tap-highlight-color: transparent !important;
    margin: 0 !important;
    flex: none !important;
    z-index: 5 !important;
    transition: background .2s ease !important;
  }

  :is(.pg, body) .hx .hm:active {
    background: rgba(240, 68, 56, 0.1) !important;
  }

  .hm span {
    display: block !important;
    width: 22px !important;
    height: 2.8px !important;
    border-radius: 99px !important;
    background: #F04438 !important;
    transition: transform .25s ease, opacity .2s ease, width .25s ease !important;
  }

  :is(.pg, body) .hx.is-open .hm span:nth-child(1) {
    transform: translateY(7.3px) rotate(45deg) !important;
  }

  :is(.pg, body) .hx.is-open .hm span:nth-child(2) {
    opacity: 0 !important;
    transform: scaleX(0) !important;
  }

  :is(.pg, body) .hx.is-open .hm span:nth-child(3) {
    transform: translateY(-7.3px) rotate(-45deg) !important;
  }

  /* 2) اللوجو الخفيف في المنتصف تماماً (Dead Center) */
  :is(.pg, body) .hx .brand {
    order: 2 !important;
    position: absolute !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 9px !important;
    margin: 0 !important;
    padding: 0 !important;
    min-height: 0 !important;
    direction: rtl !important;
    text-decoration: none !important;
    white-space: nowrap !important;
    z-index: 4 !important;
    pointer-events: auto !important;
    max-width: calc(100% - 150px) !important;
  }

  :is(.pg, body) .hx .brand__icon,
  :is(.pg, body) .hx .brand__cap,
  :is(.pg, body) .hx .brand__logo {
    width: 32px !important;
    height: 32px !important;
    flex: none !important;
    display: block !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    background: transparent !important;
  }

  :is(.pg, body) .hx .brand__icon svg,
  :is(.pg, body) .hx .brand__cap svg,
  :is(.pg, body) .hx .brand__logo svg {
    width: 100% !important;
    height: 100% !important;
  }

  :is(.pg, body) .hx .brand__text {
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    justify-content: center !important;
    line-height: 1.15 !important;
  }

  :is(.pg, body) .hx .brand__name {
    font-family: 'Cairo', Tahoma, sans-serif !important;
    font-weight: 800 !important;
    font-size: clamp(16px, 4.8vw, 19px) !important;
    display: inline-flex !important;
    align-items: baseline !important;
    gap: 3px !important;
    letter-spacing: -0.2px !important;
  }

  :is(.pg, body) .hx .brand__w1 {
    color: var(--ink) !important;
    font-weight: 800 !important;
  }

  html[data-theme=dark] :is(.pg, body) .hx .brand__w1 {
    color: #F8FAFC !important;
  }

  :is(.pg, body) .hx .brand__em,
  :is(.pg, body) .hx .brand__w2 {
    color: #3A68A5 !important;
    font-weight: 800 !important;
    background: linear-gradient(135deg, #3A68A5 0%, #16a34a 100%) !important;
    -webkit-background-clip: text !important;
    background-clip: text !important;
    -webkit-text-fill-color: transparent !important;
  }

  html[data-theme=dark] :is(.pg, body) .hx .brand__em,
  html[data-theme=dark] :is(.pg, body) .hx .brand__w2 {
    background: linear-gradient(135deg, #60A5FA 0%, #B7E600 100%) !important;
    -webkit-background-clip: text !important;
    background-clip: text !important;
    -webkit-text-fill-color: transparent !important;
  }

  :is(.pg, body) .hx .brand__tag {
    font-family: system-ui, -apple-system, sans-serif !important;
    font-size: 8px !important;
    font-weight: 700 !important;
    letter-spacing: 0.8px !important;
    color: #4778B8 !important;
    margin-top: 1px !important;
    text-transform: uppercase !important;
    display: block !important;
    direction: ltr !important;
    line-height: 1 !important;
  }

  html[data-theme=dark] :is(.pg, body) .hx .brand__tag {
    color: #93C5FD !important;
  }

  /* 3) مفتاح الوضع الليلي والنهاري الكبسولي على اليمين */
  :is(.pg, body) .hx .he {
    order: 3 !important;
    margin: 0 !important;
    display: flex !important;
    align-items: center !important;
    flex: none !important;
    z-index: 5 !important;
  }

  :is(.pg, body) .hx .tg,
  .pg .tg {
    position: relative !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    width: 66px !important;
    height: 34px !important;
    padding: 0 7px !important;
    border-radius: 999px !important;
    background: #C4E737 !important;
    background: linear-gradient(135deg, #D0F04B 0%, #B3DF20 100%) !important;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1), 0 2px 6px rgba(183, 230, 0, 0.2) !important;
    border: 1.5px solid rgba(0, 0, 0, 0.06) !important;
    cursor: pointer !important;
    user-select: none !important;
    -webkit-tap-highlight-color: transparent !important;
    transition: background .35s ease, border-color .35s ease, box-shadow .35s ease !important;
    box-sizing: border-box !important;
  }

  :is(.pg, body) .hx .tg::before,
  .pg .tg::before {
    content: "" !important;
    position: absolute !important;
    top: 3px !important;
    left: 4px !important;
    width: 25px !important;
    height: 25px !important;
    border-radius: 50% !important;
    background: #FFFFFF !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.22), 0 0 0 1px rgba(0, 0, 0, 0.04) !important;
    transition: transform .32s cubic-bezier(0.34, 1.56, 0.64, 1), background .3s !important;
    z-index: 1 !important;
  }

  :is(.pg, body) .hx .tg .i,
  .pg .tg .i {
    position: relative !important;
    z-index: 2 !important;
    width: 15px !important;
    height: 15px !important;
    stroke-width: 2.2 !important;
    transition: color .25s ease, opacity .25s ease !important;
  }

  :is(.pg, body) .hx .tg .i:first-of-type,
  .pg .tg .i:first-of-type {
    color: #4D6B08 !important;
  }

  :is(.pg, body) .hx .tg .i:last-of-type,
  .pg .tg .i:last-of-type {
    color: rgba(60, 85, 10, 0.55) !important;
  }

  html[data-theme=dark] :is(.pg, body) .hx .tg,
  html[data-theme=dark] .pg .tg {
    background: #1B2A3D !important;
    background: linear-gradient(135deg, #182638 0%, #101B2B 100%) !important;
    border-color: rgba(255, 255, 255, 0.12) !important;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.35), 0 2px 8px rgba(0, 0, 0, 0.3) !important;
  }

  /* مطابقة قاعدة الفحص التلقائي لـ test-theme.js بدقة تامة */
  @media(max-width:720px){html[data-theme=dark] .pg .tg::before{transform:translateX(28px) !important}}

  html[data-theme=dark] :is(.pg, body) .hx .tg::before,
  html[data-theme=dark] .pg .tg::before {
    transform: translateX(30px) !important;
    background: #2E4057 !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4), inset 0 0 0 1px rgba(255, 255, 255, 0.15) !important;
  }

  html[data-theme=dark] :is(.pg, body) .hx .tg .i:first-of-type,
  html[data-theme=dark] .pg .tg .i:first-of-type {
    color: rgba(255, 255, 255, 0.3) !important;
  }

  html[data-theme=dark] :is(.pg, body) .hx .tg .i:last-of-type,
  html[data-theme=dark] .pg .tg .i:last-of-type {
    color: #F8FAFC !important;
    filter: drop-shadow(0 0 3px rgba(255, 255, 255, 0.5)) !important;
  }

  /* 4) القائمة المنسدلة عند الضغط على زر القائمة في الموبايل */
  :is(.pg, body) .hx .nav {
    order: 4 !important;
    display: none !important;
    flex-direction: column !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 12px 14px 6px !important;
    gap: 3px !important;
    overflow: visible !important;
    border-top: 1px solid var(--bd) !important;
    background: var(--card) !important;
    direction: rtl !important;
  }

  :is(.pg, body) .hx .nav a {
    display: flex !important;
    align-items: center !important;
    padding: 12px 14px !important;
    font-size: 15px !important;
    font-weight: 600 !important;
    color: var(--ink) !important;
    border-radius: 10px !important;
    transition: background .2s, color .2s !important;
  }

  :is(.pg, body) .hx .nav a:hover,
  :is(.pg, body) .hx .nav a.on {
    background: var(--sky) !important;
    color: var(--den) !important;
  }

  :is(.pg, body) .hx .hs {
    order: 5 !important;
    display: none !important;
    width: 100% !important;
    margin: 0 !important;
    gap: 10px !important;
    padding: 10px 14px 16px !important;
    border-top: 1px dashed var(--bd) !important;
    background: var(--card) !important;
    direction: rtl !important;
  }

  :is(.pg, body) .hx .hs a {
    flex: 1 !important;
    min-height: 44px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 10px 14px !important;
    border-radius: 12px !important;
    font-size: 14.5px !important;
    font-weight: 700 !important;
    white-space: nowrap !important;
  }

  :is(.pg, body) .hx .hl {
    border: 1.5px solid var(--bd) !important;
    background: var(--card) !important;
    color: var(--ink) !important;
  }

  :is(.pg, body) .hx .hb,
  :is(.pg, body) .hx .dh-cta {
    background: #B7E600 !important;
    color: #26364A !important;
  }

  :is(.pg, body) .hx.is-open {
    max-height: 100vh !important;
    max-height: 100dvh !important;
    overflow-y: auto !important;
    overscroll-behavior: contain !important;
  }

  :is(.pg, body) .hx.is-open .hd {
    height: auto !important;
    flex-wrap: wrap !important;
  }

  :is(.pg, body) .hx.is-open .nav,
  :is(.pg, body) .hx.is-open .hs {
    display: flex !important;
  }

  /* شريط تقدم التمرير أسفل الهيدر */
  :is(.pg, body) .hx .ac {
    height: 0 !important;
    display: none !important;
  }

  :is(.pg, body) .hx .hxp {
    display: block !important;
    position: absolute !important;
    left: 0 !important;
    right: 0 !important;
    bottom: -2px !important;
    height: 3px !important;
    overflow: hidden !important;
    pointer-events: none !important;
    z-index: 10 !important;
  }

  :is(.pg, body) .hx .hxp i {
    display: block !important;
    width: 100% !important;
    height: 100% !important;
    -webkit-clip-path: inset(0 0 0 100%);
    clip-path: inset(0 0 0 100%);
    background: linear-gradient(90deg, #10B981 0%, #3A68A5 100%) !important;
  }

  .rb {
    top: var(--hx-h) !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  .hm span {
    transition: none !important;
  }
}
/* r28: إصلاح القائمة الجانبية المفتوحة على الموبايل (لا شيء خارج ≤720px) */
@media (max-width: 720px) {
  /* اللوجو يبقى في رأس القائمة (صف الهيدر الأول) بدل أن يتوسط ارتفاع القائمة كلها */
  :is(.pg, body) .hx.is-open .brand {
    top: 0 !important;
    height: var(--hx-h) !important;
    bottom: auto !important;
  }
  :is(.pg, body) .hx.is-open .hd {
    align-content: flex-start !important;
    row-gap: 0 !important;
  }
  :is(.pg, body) .hx.is-open .hm,
  :is(.pg, body) .hx.is-open .he {
    height: var(--hx-h) !important;
    align-items: center !important;
  }
  /* فاصل واضح بين القائمة وما تحتها */
  :is(.pg, body) .hx.is-open {
    border-bottom: 2px solid #B7E600 !important;
    border-radius: 0 0 22px 22px !important;
    box-shadow: 0 22px 36px -8px rgba(15, 23, 36, 0.45) !important;
  }
  html[data-theme=dark] :is(.pg, body) .hx.is-open { border-bottom-color: #B7E600 !important; }
  :is(.pg, body) .hx .nav { padding: 8px 14px 8px !important; }
  :is(.pg, body) .hx .nav a { min-height: 46px !important; }
  /* أزرار الحساب: داخل العرض، بلا تكرار (زر إنشاء حساب واحد) */
  :is(.pg, body) .hx .hs {
    flex-wrap: wrap !important;
    box-sizing: border-box !important;
    max-width: 100% !important;
    padding: 12px 14px 18px !important;
    overflow: hidden !important;
  }
  :is(.pg, body) .hx .hs a {
    flex: 1 1 140px !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    white-space: normal !important;
    text-align: center !important;
    gap: 8px !important;
    line-height: 1.3 !important;
  }
  :is(.pg, body) .hx .hs .dh-cta ~ .hb { display: none !important; }
  :is(.pg, body) .hx .hs .dh-cta { order: -1 !important; }
  :is(.pg, body) .hx .hs .dh-cta { background: #B7E600 !important; color: #26364A !important; border-radius: 12px !important; }
}

/* r28: «الاختبارات» في قائمة الموبايل مثل باقي العناصر؛ التمييز للصفحة الحالية فقط */
@media (max-width: 720px) {
  :is(.pg, body) .hx .nav a[href="exam.html"],
  :is(.pg, body) .hx .nav a[href="test.html"] {
    display: flex !important;
    padding: 12px 14px !important;
    gap: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    transform: none !important;
    font-weight: 600 !important;
    color: var(--ink) !important;
    border-radius: 10px !important;
  }
  :is(.pg, body) .hx .nav a[href="exam.html"]::before { display: none !important; }
  :is(.pg, body) .hx .nav a[href="exam.html"]:hover,
  :is(.pg, body) .hx .nav a[href="test.html"]:hover,
  :is(.pg, body) .hx .nav a[aria-current],
  :is(.pg, body) .hx .nav a.on {
    background: var(--sky) !important;
    color: var(--den) !important;
    box-shadow: inset -4px 0 0 #B7E600 !important;
    transform: none !important;
  }
}
