/* ==========================================================================
   RAKEEZ X — نظام التصميم
   عربي أولًا، RTL، ومصمم ليُستعمل بإبهام واحد والمعلّم واقف بين طلابه.
   ========================================================================== */
/* Brand typography: T3 hierarchy on the existing offline-safe font stack. */
.brand-lockup { display:inline-flex; align-items:center; gap:9px; min-inline-size:0; color:var(--brand-text); letter-spacing:normal; direction:rtl; }
.brand-lockup__icon { display:block; inline-size:36px; block-size:36px; flex:none; }
.brand-lockup__copy { display:flex; flex-direction:column; gap:3px; }
.brand-lockup__name { white-space:nowrap; font-family:var(--font); line-height:1.5; }
.brand-lockup__name strong { font-size:23px; font-weight:800; }
.brand-lockup__name > span { font-size:20px; font-weight:500; }
.brand-lockup__signature { align-self:flex-start; font:600 8px/1.3 var(--font); letter-spacing:1.6px; color:var(--text-3); }
.brand-wordmark-secondary { font-size:.88em; font-style:normal; font-weight:500; }
.brand-lockup__icon--app { inline-size:80px; block-size:80px; }
.brand-lockup--prominent { gap:16px; max-inline-size:100%; }
.brand-lockup--prominent .brand-lockup__icon--app { inline-size:104px; block-size:104px; }
.brand-lockup--prominent .brand-lockup__name strong { font-size:32px; }
.brand-lockup--prominent .brand-lockup__name > span { font-size:27px; }
.brand-lockup__caption { margin-top:7px; color:var(--text-2); font-size:15px; font-weight:500; line-height:1.5; overflow-wrap:anywhere; }
.brand-lockup--prominent .brand-lockup__copy { min-inline-size:0; }
.sidebar__brand .brand-lockup__icon--app { inline-size:56px; block-size:56px; }
.home-pwa-brand-icon { display:block; inline-size:56px; block-size:56px; flex:none; }
@media (max-width: 599px) {
  .brand-lockup--prominent { gap:12px; }
  .brand-lockup--prominent .brand-lockup__icon--app { inline-size:80px; block-size:80px; }
  .brand-lockup--prominent .brand-lockup__name strong { font-size:27px; }
  .brand-lockup--prominent .brand-lockup__name > span { font-size:23px; }
}
.auth-brand { padding-block:4px 20px; }
.auth-brand p { margin-block:8px 0; color:var(--text-2); font-size:14px; }
.boot__mark { display:flex; flex-direction:column; align-items:center; gap:12px; }
.mobile-brand { display:none; }
@media (max-width: 899px) {
  .mobile-brand { display:flex; min-inline-size:0; }
  .desktop-home-title { display:none; }
  .mobile-brand .brand-lockup__name strong { font-size:21px; }
  .mobile-brand .brand-lockup__name > span { font-size:18px; }
}
@media print { .brand-lockup { color:#0F5132; } .brand-lockup__signature { color:#52666b; } }

/* ---------- 1. الرموز (tokens) ---------- */
:root {
  color-scheme: light dark;

  /* الخط */
  --font: "IBM Plex Sans Arabic", "Noto Sans Arabic", "Segoe UI", Tahoma, Arial, sans-serif;
  --font-num: "IBM Plex Sans Arabic", "Noto Sans Arabic", "Segoe UI", Tahoma, Arial, sans-serif;

  /* سلم الكتابة — خط النظام الآمن الحالي دون أي اعتماد شبكي */
  --fs-xs: 12px;
  --fs-sm: 14px;
  --fs-body: 16px;
  --fs-section: 18px;
  --fs-page: 24px;
  --fs-display: 32px;
  --fw-medium: 500;
  --fw-semibold: 650;
  --fw-bold: 750;
  --fw-heavy: 850;
  --lh-tight: 1.3;
  --lh-body: 1.6;
  --lh-relaxed: 1.75;

  /* المقاسات */
  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-8: 32px; --sp-10: 40px; --sp-12: 48px;

  --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-xl: 22px; --r-full: 999px;

  /* أحجام الأيقونات القياسية (Semantic Icon Tokens) */
  --icon-inline:  15px;
  --icon-compact: 18px;
  --icon-control: 20px;
  --icon-status:  24px;
  --icon-hero:    36px;

  /* أصغر هدف لمس مقبول بإبهام */
  --tap: 44px;

  --shadow-1: 0 1px 2px rgb(15 23 42 / .06), 0 1px 3px rgb(15 23 42 / .08);
  --shadow-2: 0 4px 12px rgb(15 23 42 / .08), 0 2px 4px rgb(15 23 42 / .06);
  --shadow-3: 0 12px 32px rgb(15 23 42 / .16), 0 4px 8px rgb(15 23 42 / .08);

  --ease: cubic-bezier(.2, .8, .3, 1);
  --motion-fast: 120ms;
  --motion-base: 180ms;

  /* ألوان — الوضع الفاتح */
  --bg:        #f8fafc;
  --bg-elev:   #ffffff;
  --bg-sunk:   #eef0f3;
  --border:    #e2e8f0;
  --border-strong: #cbd1da;

  --text:      #15253D;
  --text-2:    #334155;
  --text-3:    #64748b;
  --text-1:    var(--text);
  --t-1:       var(--text);
  --t-3:       var(--text-3);

  --brand:     #18A878;
  --brand-ink: #06231f;
  --brand-text:#0f7655;
  --brand-soft:#e8f6f1;
  --brand-border:#9edbc7;
  --brand-hover: #25b98a;
  --brand-active: #13936a;

  /* Semantic action colors stay separate from status/navigation colors. */
  --action-primary: var(--brand);
  --action-primary-hover: var(--brand-hover);
  --action-primary-active: var(--brand-active);
  --action-primary-ink: #06231f;
  --action-focus-ring: color-mix(in srgb, var(--brand) 34%, transparent);
  --action-disabled-bg: var(--bg-sunk);
  --action-disabled-ink: var(--text-3);
  --action-disabled-border: var(--border-strong);
  
  --x-purple:       #7857E8;
  --x-purple-hover: #6549c4;
  --x-purple-soft:  #f2effc;

  --ok:        #15803d;
  --ok-soft:   #dcfce7;
  --ok-border: #86efac;
  --warn:      #b45309;
  --warn-soft: #fef3c7;
  --warn-border:#fcd34d;
  --danger:    #dc2626;
  --danger-soft:#fee2e2;
  --danger-border:#fca5a5;
  --info:      #2563eb;
  --info-soft: #dbeafe;
  --info-border:#93c5fd;

  /* أسماء دلالية مشتركة للأسطح والحدود */
  --surface-page: var(--bg);
  --surface-raised: var(--bg-elev);
  --surface-subtle: var(--bg-sunk);
  --border-subtle: var(--border);
  --border-emphasis: var(--border-strong);

  /* حالات الحضور */
  --present:   var(--ok);      --present-soft: var(--ok-soft);
  --absent:    var(--danger);  --absent-soft:  var(--danger-soft);
  --late:      var(--warn);    --late-soft:    var(--warn-soft);
  --excused:   var(--info);    --excused-soft: var(--info-soft);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:        #0f1216;
    --bg-elev:   #171b21;
    --bg-sunk:   #0a0d10;
    --border:    #272d36;
    --border-strong: #3a424e;

    --text:      #eef1f5;
    --text-2:    #a3adba;
    --text-3:    #94a3b8;

    --brand:     #18A878;
    --brand-ink: #06231f;
    --brand-text:#5eead4;
    --brand-soft:#123734;
    --brand-border:#296158;
    --brand-hover: #5eead4;
    
    --x-purple:       #8b5cf6;
    --x-purple-hover: #a78bfa;
    --x-purple-soft:  #2e1065;

    --ok:        #4ade80;  --ok-soft:     #10301c; --ok-border: #166534;
    --warn:      #fbbf24;  --warn-soft:   #34250a; --warn-border: #854d0e;
    --danger:    #f87171;  --danger-soft: #3a1414; --danger-border: #7f1d1d;
    --info:      #93c5fd;  --info-soft:   #11224a; --info-border: #1e3a8a;

    --present: #4ade80; --present-soft: #10301c;
    --absent:  #f87171; --absent-soft:  #3a1414;
    --late:    #fbbf24; --late-soft:    #34250a;
    --excused: var(--info); --excused-soft: var(--info-soft);

    --shadow-1: 0 1px 2px rgb(0 0 0 / .4);
    --shadow-2: 0 4px 12px rgb(0 0 0 / .45);
    --shadow-3: 0 12px 32px rgb(0 0 0 / .6);
  }
}

:root[data-theme="dark"] {
  --bg:        #0f1216;
  --bg-elev:   #171b21;
  --bg-sunk:   #0a0d10;
  --border:    #272d36;
  --border-strong: #3a424e;

  --text:      #eef1f5;
  --text-2:    #a3adba;
  --text-3:    #94a3b8;

  --brand:     #18A878;
  --brand-ink: #06231f;
  --brand-text:#5eead4;
  --brand-soft:#123734;
  --brand-border:#296158;
  --brand-hover: #5eead4;
  
  --x-purple:       #8b5cf6;
  --x-purple-hover: #a78bfa;
  --x-purple-soft:  #2e1065;

  --ok:        #4ade80;  --ok-soft:     #10301c; --ok-border: #166534;
  --warn:      #fbbf24;  --warn-soft:   #34250a; --warn-border: #854d0e;
  --danger:    #f87171;  --danger-soft: #3a1414; --danger-border: #7f1d1d;
  --info:      #93c5fd;  --info-soft:   #11224a; --info-border: #1e3a8a;

  --present: #4ade80; --present-soft: #10301c;
  --absent:  #f87171; --absent-soft:  #3a1414;
  --late:    #fbbf24; --late-soft:    #34250a;
  --excused: var(--info); --excused-soft: var(--info-soft);

  --shadow-1: 0 1px 2px rgb(0 0 0 / .4);
  --shadow-2: 0 4px 12px rgb(0 0 0 / .45);
  --shadow-3: 0 12px 32px rgb(0 0 0 / .6);
}

/* ---------- 2. إعادة الضبط ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }

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

body {
  font-family: var(--font);
  font-size: 16px;
  line-height: var(--lh-body);
  color: var(--text);
  background: var(--bg);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

img, svg { display: block; max-width: 100%; }

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

button:disabled,
input:disabled,
select:disabled,
textarea:disabled,
[aria-disabled="true"] {
  cursor: not-allowed;
}

input:disabled,
select:disabled,
textarea:disabled {
  color: var(--action-disabled-ink);
  background: var(--action-disabled-bg);
  border-color: var(--action-disabled-border);
  opacity: .78;
}

button { cursor: pointer; background: none; border: none; padding: 0; }

a { color: var(--brand-text); text-underline-offset: 3px; }

/* نطاقات الوقت: البداية أولًا في RTL، وكل HH:MM معزول للقراءة اللاتينية السليمة. */
.time-range { direction: rtl; display: inline-flex; align-items: baseline; white-space: nowrap; }
.time-range__token { direction: ltr; unicode-bidi: isolate; }
.time-range__dash { direction: ltr; flex: none; }

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px var(--action-focus-ring);
  border-radius: var(--r-sm);
}

.skip-link {
  position: fixed;
  inset-block-start: var(--sp-2);
  inset-inline-start: var(--sp-2);
  z-index: 2000;
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--r-md);
  background: var(--action-primary);
  color: var(--action-primary-ink);
  font-weight: var(--fw-bold);
  text-decoration: none;
}
.skip-link:not(:focus-visible) {
  clip-path: inset(50%);
  inline-size: 1px;
  block-size: 1px;
  padding: 0;
  overflow: hidden;
  white-space: nowrap;
}
.skip-link:focus-visible { outline: 2px solid var(--text); outline-offset: 3px; }

/* الأرقام تبقى لاتينية ومحاذاة أفقيًا لسهولة قراءة الدرجات */
.num, input[type="number"], .tabular {
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
  direction: ltr;
  unicode-bidi: isolate;
}

/* ---------- 3. شاشة الإقلاع ---------- */
.boot {
  min-height: 100dvh;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: var(--sp-3);
}
.boot::after {
  content: '';
  width: 28px;
  height: 3px;
  border-radius: var(--r-full);
  background: linear-gradient(90deg, var(--brand) 0 45%, var(--brand-soft) 45% 100%);
  background-size: 220% 100%;
  animation: boot-progress 1.1s var(--ease) infinite;
}
.boot__mark {
  font-size: 40px; font-weight: 800; letter-spacing: -.5px;
  color: var(--brand);
}
.boot__msg { color: var(--text-3); font-size: 14px; }

/* ---------- 4. هيكل التطبيق ---------- */
.app-shell { min-height: 100dvh; }

.layout {
  display: grid;
  grid-template-columns: 1fr;
  min-height: 100dvh;
}

.main {
  padding-bottom: calc(var(--tap) + env(safe-area-inset-bottom) + var(--sp-6));
  min-width: 0;
}

.app-status-strip {
  display: none;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: 36px;
  padding: 6px var(--sp-4);
  border-bottom: 1px solid var(--border);
  background: var(--bg-sunk);
  color: var(--text-2);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
}
.app-status-strip.is-visible { display: flex; }
.app-status-strip.is-offline { background: var(--warn-soft); color: var(--warn); border-color: var(--warn-border); }
.app-status-strip.is-error { background: var(--danger-soft); color: var(--danger); border-color: var(--danger-border); }
.app-status-strip svg { width: var(--icon-compact); height: var(--icon-compact); }

/* شريط علوي */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4);
  padding-top: calc(var(--sp-3) + env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
  min-height: 56px;
}
.topbar__title {
  font-size: var(--fs-section); font-weight: var(--fw-bold); letter-spacing: -.2px;
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.topbar__sub {
  display: block; font-size: 12.5px; font-weight: 500; color: var(--text-3);
  letter-spacing: 0;
}
.topbar__actions { display: flex; align-items: center; gap: var(--sp-1); }

.iconbtn {
  width: var(--tap); height: var(--tap);
  display: grid; place-items: center;
  border-radius: var(--r-md);
  color: var(--text-2);
  transition: background var(--motion-fast) var(--ease), color var(--motion-fast) var(--ease), transform var(--motion-fast) var(--ease);
}
.iconbtn:hover { background: var(--bg-sunk); color: var(--text); }
.iconbtn:active { transform: scale(.94); }
.iconbtn svg { width: 21px; height: 21px; }
.iconbtn[disabled], .iconbtn[aria-disabled="true"] { color: var(--action-disabled-ink); opacity: .55; pointer-events: none; transform: none; }

/* المحتوى */
.page { padding: var(--sp-4); max-width: 900px; margin-inline: auto; }
.page--wide { max-width: 1200px; }

/* شريط التنقل السفلي (جوال) */
.tabbar {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 40;
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  background: color-mix(in srgb, var(--bg-elev) 92%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar__item {
  display: grid; place-items: center; gap: 2px;
  padding: var(--sp-2) var(--sp-1);
  min-height: var(--tap);
  color: var(--text-3);
  font-size: 11px; font-weight: 600;
  text-decoration: none;
  transition: color .15s var(--ease);
}
.tabbar__item svg { width: 22px; height: 22px; }
.tabbar__item[aria-current="page"] { color: var(--brand-text); }

/* تنقّل الإسناد السياقي: يظل داخل الصفحة ولا يغيّر معنى الشريط الرئيسي. */
.teaching-tabs {
  display: flex; gap: var(--sp-2); overflow-x: auto; overscroll-behavior-inline: contain;
  padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border);
  background: var(--bg-elev); scrollbar-width: thin;
}
.teaching-tabs__item {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: var(--sp-2);
  min-height: var(--tap); padding-inline: var(--sp-3); border-radius: var(--r-md);
  color: var(--text-2); text-decoration: none; font-size: 13px; font-weight: 650;
  white-space: nowrap;
}
.teaching-tabs__item svg { width: 18px; height: 18px; }
.teaching-tabs__item:hover { background: var(--bg-sunk); color: var(--text); }
.teaching-tabs__item[aria-current="page"] { background: var(--brand-soft); color: var(--brand-text); }

/* سطح المكتب: قائمة جانبية.
   القائمة أول عنصر في الصفحة، فتقع في العمود الأول — وهو اليمين في الاتجاه
   العربي. لا تضف order هنا وإلا انتقلت لليسار وأخذ المحتوى عرض القائمة. */
.sidebar {
  display: none;
  flex-direction: column;
  gap: var(--sp-1);
  padding: var(--sp-4) var(--sp-3);
  border-inline-start: 1px solid var(--border);
  background: var(--bg-elev);
  position: sticky; top: 0; height: 100dvh;
}
.sidebar__brand {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3) var(--sp-5);
  font-size: 22px; font-weight: 800; color: var(--brand);
  letter-spacing: -.5px;
}
.sidebar__item {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3);
  border-radius: var(--r-md);
  color: var(--text-2); text-decoration: none;
  font-size: 15px; font-weight: 600;
  transition: background .15s var(--ease), color .15s var(--ease);
}
.sidebar__item svg { width: 20px; height: 20px; flex: none; }
.sidebar__item:hover { background: var(--bg-sunk); color: var(--text); }
.sidebar__item[aria-current="page"] {
  background: var(--brand-soft); color: var(--brand-text);
}
.sidebar__spacer { flex: 1; }

/* استعلام الوسائط بعد قواعد القائمة الأساسية، وإلا غلبَته قاعدة display:none */
@media (min-width: 900px) {
  .layout { grid-template-columns: 248px 1fr; }
  .sidebar { display: flex; }
  .tabbar { display: none; }
  .main { padding-bottom: var(--sp-8); }
}

/* ---------- 5. البطاقات ---------- */
.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
}
.surface {
  background: var(--surface-raised);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
}
.surface--compact { padding: var(--sp-3) var(--sp-4); }
.surface--flat { box-shadow: none; }
.surface__section { padding: var(--sp-4); }
.surface__section + .surface__section { border-block-start: 1px solid var(--border-subtle); }
.card--pad { padding: var(--sp-4); }
.card + .card { margin-top: var(--sp-3); }

.section { margin-block: var(--sp-6); }
.section:first-child { margin-block-start: 0; }
.section__head {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-3); margin-bottom: var(--sp-3);
}
.section__title { font-size: 15px; font-weight: 700; color: var(--text-2); }

/* ---------- 6. الأزرار ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--sp-2);
  min-height: var(--tap);
  padding-inline: var(--sp-5);
  border-radius: var(--r-md);
  font-size: 15px; font-weight: 650;
  border: 1px solid transparent;
  transition: background .15s var(--ease), color .15s var(--ease),
              transform .08s var(--ease), border-color .15s var(--ease),
              box-shadow .15s var(--ease), opacity .15s var(--ease);
  text-decoration: none;
  white-space: nowrap;
}
.btn svg { width: 18px; height: 18px; flex: none; }
.btn:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px var(--action-focus-ring);
}
.btn:active:not([disabled]):not([aria-disabled="true"]) { transform: scale(.97); }
.btn[disabled],
.btn[aria-disabled="true"] {
  background: var(--action-disabled-bg);
  color: var(--action-disabled-ink);
  border-color: var(--action-disabled-border);
  box-shadow: none;
  cursor: not-allowed;
  opacity: .72;
  pointer-events: none;
  transform: none;
}

.btn--primary { background: var(--action-primary); color: var(--action-primary-ink); }
.btn.btn--primary:hover { background-color: var(--action-primary-hover); }
.btn--primary:active:not([disabled]):not([aria-disabled="true"]) { background: var(--action-primary-active); }

.btn--ghost { background: var(--bg-elev); color: var(--text); border-color: var(--border-strong); }
.btn--ghost:hover { background: var(--bg-sunk); }

.btn--quiet { background: transparent; color: var(--text-2); }
.btn--quiet:hover { background: var(--bg-sunk); color: var(--text); }

.btn--danger { background: var(--danger-soft); color: var(--danger); }
.btn--danger:hover { background: var(--danger); color: #fff; }
.btn--info { background: var(--info-soft); color: var(--info); border-color: var(--info-border); }
.btn--info:hover { background: var(--info); color: #fff; }

.btn--block { width: 100%; }
.btn--sm { min-height: 34px; padding-inline: var(--sp-3); font-size: 13.5px; border-radius: var(--r-sm); }
.btn--lg { min-height: 54px; font-size: 17px; border-radius: var(--r-lg); }

.btn-row { display: flex; gap: var(--sp-2); flex-wrap: wrap; }

/* زر عائم */
.fab {
  position: fixed;
  inset-inline-end: var(--sp-4);
  bottom: calc(var(--tap) + env(safe-area-inset-bottom) + var(--sp-4));
  z-index: 35;
  height: 56px; padding-inline: var(--sp-5);
  display: inline-flex; align-items: center; gap: var(--sp-2);
  background: var(--brand); color: var(--brand-ink);
  border-radius: var(--r-full);
  box-shadow: var(--shadow-3);
  font-weight: 700; font-size: 15px;
}
.fab svg { width: 20px; height: 20px; }
.fab:active { transform: scale(.95); }
@media (min-width: 900px) {
  .fab { bottom: var(--sp-6); }
}

/* ---------- 7. الحقول ---------- */
.field { display: block; margin-bottom: var(--sp-4); }
.field__label {
  display: block; margin-bottom: var(--sp-2);
  font-size: 13.5px; font-weight: 650; color: var(--text-2);
}
.field__hint { margin-top: var(--sp-2); font-size: 12.5px; color: var(--text-3); line-height: 1.5; }
.field__error { margin-top: var(--sp-2); font-size: 12.5px; color: var(--danger); font-weight: 600; }

.input, .select, .textarea {
  width: 100%;
  min-height: var(--tap);
  padding: var(--sp-3);
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.input:hover, .select:hover, .textarea:hover { border-color: var(--border-emphasis); }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--brand-text);
  box-shadow: 0 0 0 3px var(--action-focus-ring);
}
.textarea { min-height: 130px; resize: vertical; line-height: 1.7; }
.select { appearance: none; padding-inline-end: var(--sp-8);
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
                    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(var(--sp-4) - 3px) calc(50% + 2px), calc(var(--sp-4) + 2px) calc(50% + 2px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

/* محدد المادة في إنشاء الفصل — فهرس قابل للبحث، لا قائمة طويلة مفتوحة دائمًا. */
.subject-picker { position: relative; }
.subject-picker__trigger {
  width: 100%; min-height: var(--tap); padding: var(--sp-3);
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  color: var(--text); background: var(--bg-elev);
  border: 1px solid var(--border-strong); border-radius: var(--r-md);
  text-align: start;
}
.subject-picker__trigger:hover { border-color: var(--border-emphasis); }
.subject-picker__trigger:focus-visible {
  outline: none; border-color: var(--brand-text); box-shadow: 0 0 0 3px var(--action-focus-ring);
}
.subject-picker__trigger svg { width: 18px; height: 18px; color: var(--text-3); }
.subject-picker__menu {
  margin-top: var(--sp-2); padding: var(--sp-2);
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--shadow-2);
}
.subject-picker__menu[hidden], .subject-picker__custom[hidden] { display: none !important; }
.subject-picker__search { margin-bottom: var(--sp-2); }
.subject-picker__options { max-height: min(42dvh, 320px); overflow-y: auto; overscroll-behavior: contain; }
.subject-picker__group-label {
  padding: var(--sp-2) var(--sp-2) var(--sp-1); color: var(--text-3);
  font-size: 12px; font-weight: 700;
}
.subject-picker__group { display: grid; gap: 2px; }
.subject-picker__option, .subject-picker__custom-action {
  width: 100%; min-height: var(--tap); padding: var(--sp-2) var(--sp-3);
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2);
  border-radius: var(--r-md); color: var(--text); text-align: start;
}
.subject-picker__option:hover, .subject-picker__option:focus-visible,
.subject-picker__custom-action:hover, .subject-picker__custom-action:focus-visible {
  background: var(--bg-sunk); outline: none;
}
.subject-picker__custom-action {
  margin-top: var(--sp-2); justify-content: flex-start; color: var(--brand-text); font-weight: 700;
  border-top: 1px solid var(--border); border-radius: 0 0 var(--r-md) var(--r-md);
}
.subject-picker__custom-action svg { width: 17px; height: 17px; }
.subject-picker__empty { padding: var(--sp-4); color: var(--text-3); text-align: center; font-size: 13px; }
.subject-picker__custom { margin-top: var(--sp-2); display: grid; gap: var(--sp-2); }
.subject-picker__custom .btn { justify-self: start; }
.input::placeholder, .textarea::placeholder { color: var(--text-3); }

.field-row { display: grid; gap: var(--sp-3); grid-template-columns: 1fr 1fr; }
@media (max-width: 520px) { .field-row { grid-template-columns: 1fr; } }

/* ---------- 8. القوائم ---------- */
.list { display: flex; flex-direction: column; gap: var(--sp-2); }

.row {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  text-decoration: none; color: inherit;
  transition: border-color .15s var(--ease), transform .08s var(--ease);
  width: 100%;
  text-align: start;
}
.row:hover { border-color: var(--border-strong); }
.row:active { transform: scale(.995); }
.row__main { flex: 1; min-width: 0; }
.row__title { font-weight: 650; font-size: 15.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row__sub { font-size: 13px; color: var(--text-3); margin-top: 1px; }
.row__end { flex: none; display: flex; align-items: center; gap: var(--sp-2); }
.row__chev { color: var(--text-3); width: 18px; height: 18px; }

/* رقم الكشف */
.rollno {
  flex: none;
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: var(--r-sm);
  background: var(--bg-sunk);
  color: var(--text-2);
  font-size: 13.5px; font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* ---------- 9. الشارات ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px var(--sp-2);
  border-radius: var(--r-full);
  font-size: 12px; font-weight: 700;
  background: var(--bg-sunk); color: var(--text-2);
  white-space: nowrap;
}
.badge--ok      { background: var(--ok-soft);      color: var(--ok); }
.badge--warn    { background: var(--warn-soft);    color: var(--warn); }
.badge--danger  { background: var(--danger-soft);  color: var(--danger); }
.badge--info    { background: var(--info-soft);    color: var(--info); }
.badge--brand   { background: var(--brand-soft);   color: var(--brand-text); }

/* ---------- 10. الشبكة ---------- */
.grid { display: grid; gap: var(--sp-3); }
.grid--2 { grid-template-columns: repeat(2, 1fr); }
.grid--3 { grid-template-columns: repeat(3, 1fr); }
.grid--auto { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
@media (max-width: 560px) { .grid--3 { grid-template-columns: repeat(2, 1fr); } }

/* بلاطة أداة */
.tile {
  display: flex; flex-direction: column; gap: var(--sp-2);
  padding: var(--sp-4);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  text-decoration: none; color: inherit;
  transition: transform .1s var(--ease), border-color .15s var(--ease), box-shadow .15s var(--ease);
  text-align: start;
  min-height: 104px;
}
.tile:hover { border-color: var(--brand); box-shadow: var(--shadow-2); }
.tile:active { transform: scale(.98); }
.tile__icon {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: var(--r-md);
  background: var(--brand-soft); color: var(--brand);
}
.tile__icon svg { width: 21px; height: 21px; }
.tile__title { font-weight: 700; font-size: 15px; }
.tile__sub { font-size: 12.5px; color: var(--text-3); line-height: 1.45; }

/* إحصاءة */
.stat {
  padding: var(--sp-3) var(--sp-4);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.stat__val { font-size: 24px; font-weight: 800; letter-spacing: -.5px; font-variant-numeric: tabular-nums; }
.stat__label { font-size: 12.5px; color: var(--text-3); font-weight: 600; margin-top: 1px; }

/* ---------- 11. الحالة الفارغة ---------- */
.empty {
  display: grid; justify-items: center; gap: var(--sp-3);
  padding: var(--sp-10) var(--sp-4);
  text-align: center;
}
.empty--compact { padding-block: var(--sp-6); }
.empty--error .empty__icon { background: var(--danger-soft); color: var(--danger); }
.empty--offline .empty__icon { background: var(--warn-soft); color: var(--warn); }
.empty--loading .empty__icon { color: var(--brand-text); }
.empty__icon {
  width: 60px; height: 60px;
  display: grid; place-items: center;
  border-radius: var(--r-xl);
  background: var(--bg-sunk); color: var(--text-3);
}
.empty__icon svg { width: 30px; height: 30px; }
.empty__title { font-size: 17px; font-weight: 700; }
.empty__text { font-size: 14px; color: var(--text-3); max-width: 38ch; line-height: 1.6; }

/* ---------- 12. الطبقة المنبثقة ---------- */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 50;
  background: rgb(9 12 16 / .5);
  backdrop-filter: blur(2px);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade .18s var(--ease);
}
.has-modal { overflow: hidden; }
@media (min-width: 700px) { .sheet-backdrop { align-items: center; } }

.sheet {
  background: var(--bg-elev);
  width: 100%; max-width: 560px;
  max-height: 92dvh;
  overflow-y: auto;
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  box-shadow: var(--shadow-3);
  padding: var(--sp-5) var(--sp-4)
           calc(var(--sp-5) + env(safe-area-inset-bottom));
  animation: slideup .24s var(--ease);
}
.sheet:focus { outline: none; }
@media (min-width: 700px) {
  .sheet { border-radius: var(--r-xl); animation: pop .18s var(--ease); }
}
.sheet__head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: var(--sp-3); margin-bottom: var(--sp-4);
}
.sheet__title { font-size: 19px; font-weight: 750; letter-spacing: -.2px; }
.sheet__desc { font-size: 13.5px; color: var(--text-3); margin-top: var(--sp-1); line-height: 1.6; }
.sheet__foot { display: flex; gap: var(--sp-2); margin-top: var(--sp-5); }
.sheet__foot .btn { flex: 1; }

@keyframes fade   { from { opacity: 0 } }
@keyframes slideup{ from { transform: translateY(14px); opacity: 0 } }
@keyframes pop    { from { transform: scale(.97); opacity: 0 } }

/* ---------- 13. التنبيه العابر ---------- */
.toast {
  position: fixed; z-index: 1000;
  inset-inline: var(--sp-4);
  bottom: calc(var(--tap) + env(safe-area-inset-bottom) + var(--sp-4));
  margin-inline: auto; max-width: 400px;
  padding: var(--sp-3) var(--sp-4);
  background: var(--text); color: var(--bg-elev);
  border: 1px solid color-mix(in srgb, currentColor 18%, transparent);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-3);
  font-size: 14px; font-weight: 600;
  text-align: center;
  opacity: 0; transform: translateY(10px);
  visibility: hidden;
  pointer-events: none;
  transition: opacity .2s var(--ease), transform .2s var(--ease);
}
.toast.is-on { opacity: 1; transform: none; visibility: visible; }
.toast.is-danger { background: var(--danger); color: #fff; }
.toast.is-warn { background: var(--warn); color: #fff; }
.toast.is-info { background: var(--info); color: #fff; }

/* ---------- 14. المساعدات ---------- */
.stack   { display: flex; flex-direction: column; }
.stack-2 { gap: var(--sp-2); } .stack-3 { gap: var(--sp-3); }
.stack-4 { gap: var(--sp-4); } .stack-6 { gap: var(--sp-6); }
.hstack  { display: flex; align-items: center; }
.gap-1 { gap: var(--sp-1); } .gap-2 { gap: var(--sp-2); } .gap-3 { gap: var(--sp-3); }
.push   { margin-inline-start: auto; }
.wrap   { flex-wrap: wrap; }

.t-2 { color: var(--text-2); } .t-3 { color: var(--text-3); }
.fs-sm { font-size: 13px; } .fs-md { font-size: 14.5px; }
.fw-7 { font-weight: 700; }
.center { text-align: center; }
.mt-3 { margin-top: var(--sp-3); } .mt-4 { margin-top: var(--sp-4); }
.mt-6 { margin-top: var(--sp-6); } .mb-3 { margin-bottom: var(--sp-3); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hidden { display: none !important; }

.divider { height: 1px; background: var(--border); border: 0; margin-block: var(--sp-4); }

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

.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* أحجام الأيقونات القياسية */
.icon { display: inline-block; vertical-align: middle; flex: none; width: var(--icon-control); height: var(--icon-control); }
.icon--inline  { width: var(--icon-inline); height: var(--icon-inline); display: inline-block; vertical-align: -2.5px; flex: none; }
.icon--compact { width: var(--icon-compact); height: var(--icon-compact); display: inline-block; vertical-align: middle; flex: none; }
.icon--control { width: var(--icon-control); height: var(--icon-control); display: inline-block; vertical-align: middle; flex: none; }
.icon--status  { width: var(--icon-status); height: var(--icon-status); display: inline-block; vertical-align: middle; flex: none; }
.icon--hero    { width: var(--icon-hero); height: var(--icon-hero); display: inline-block; vertical-align: middle; flex: none; }

@media (prefers-reduced-motion: reduce) {
  html:focus-within { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

@keyframes boot-progress {
  from { background-position: 100% 0; }
  to { background-position: -100% 0; }
}

:root { --recess: #d97706; --recess-soft: #fef3c7; }
:root[data-theme="dark"] { --recess: #b45309; --recess-soft: #451a03; }

/* SCHEDULE-UX-01: only compact numeric/time controls are centered. */
.input--center, input.input--center { text-align: center !important; font-variant-numeric: tabular-nums lining-nums; }
.hero__main-row { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); }
