/* ==========================================================================
   RAKEEZ X — نظام التصميم
   عربي أولًا، RTL، ومصمم ليُستعمل بإبهام واحد والمعلّم واقف بين طلابه.
   ========================================================================== */
/* Approved outlined A1 lockups; Product typography and runtime remain native. */
.brand-lockup { display:inline-flex; flex-direction:column; min-inline-size:0; inline-size:216px; max-inline-size:100%; direction:rtl; }
.brand-lockup__image { display:block; inline-size:100%; block-size:auto; }
.brand-lockup__image--dark { display:none; }
[data-theme="dark"] .brand-lockup__image--light { display:none; }
[data-theme="dark"] .brand-lockup__image--dark { display:block; }
.brand-wordmark-secondary { font-size:.88em; font-style:normal; font-weight:500; }
.brand-lockup--prominent { inline-size:345px; }
.brand-lockup__caption { margin-top:7px; color:var(--text-2); font-size:15px; font-weight:500; line-height:1.5; overflow-wrap:anywhere; }
.sidebar__brand .brand-lockup { inline-size:245px; max-inline-size:calc(100% + 26px); flex-shrink:0; margin-inline:-13px; }
.home-pwa-brand-mark { display:block; inline-size:52px; block-size:52px; flex:none; border-radius:12px; overflow:hidden; }
.home-pwa-brand-icon { display:block; inline-size:100%; block-size:100%; object-fit:contain; }
.auth-brand { padding-block:4px 20px; }
.auth-brand p { margin-block:8px 0; color:var(--text-2); font-size:14px; }
.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 { inline-size:clamp(199px, calc(22.5vw + 127px), 220px); }
}

/* ---------- 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:        #f4f7f5;
  --bg-elev:   #ffffff;
  --bg-sunk:   #edf3ef;
  --border:    #dce7e1;
  --border-strong: #bfd2c8;

  --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);
}

:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:        #0d1511;
    --bg-elev:   #14201a;
    --bg-sunk:   #0a100d;
    --border:    #26372e;
    --border-strong: #3c5247;

    --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:        #0d1511;
  --bg-elev:   #14201a;
  --bg-sunk:   #0a100d;
  --border:    #26372e;
  --border-strong: #3c5247;

  --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;
  overflow-x: clip;
}

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 {
  box-sizing: border-box;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: max(var(--sp-5), env(safe-area-inset-top)) var(--sp-6) max(var(--sp-5), env(safe-area-inset-bottom));
}
:root[data-theme="light"] .boot { background: #f8fafc; }
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) .boot { background: #f8fafc; }
}
.boot__composition {
  --boot-identity-scale: 1.12;
  --boot-lockup-width: calc(216px * var(--boot-identity-scale));
  --boot-lockup-crop-width: calc(var(--boot-lockup-width) * 196 / 345);
  display: flex;
  flex-direction: column;
  align-items: center;
  inline-size: min(280px, 100%);
  min-inline-size: 0;
  text-align: center;
}
.boot__mark {
  position: relative;
  inline-size: var(--boot-lockup-crop-width);
  block-size: calc(var(--boot-lockup-width) * 56 / 345);
  flex: none;
  overflow: hidden;
  line-height: 0;
}
.boot__mark .brand-lockup {
  position: absolute;
  inset-block-start: 0;
  inset-inline-start: 0;
  inline-size: var(--boot-lockup-width);
  max-inline-size: none;
}
.boot__msg {
  max-inline-size: 100%;
  margin-block-start: 14px;
  color: var(--text-3);
  font-size: 16px;
  font-weight: var(--fw-medium);
  line-height: 1.6;
  white-space: nowrap;
}
.boot__progress {
  width: 28px;
  height: 3px;
  margin-block-start: 10px;
  flex: none;
  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;
}

/* ---------- 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;
  min-height: 100dvh;
}

.app-status-strip {
  display: none;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
  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); }
.app-status-strip__support {
  display: none;
  align-items: center;
  min-height: 44px;
  margin-inline-start: var(--sp-1);
  padding-inline: var(--sp-2);
  color: inherit;
  border-radius: var(--r-sm);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.app-status-strip.is-error .app-status-strip__support,
.app-status-strip.is-blocked .app-status-strip__support,
.app-status-strip.is-rejected .app-status-strip__support { display: inline-flex; }
.app-status-strip.is-blocked { background: var(--warn-soft); color: var(--warn); border-color: var(--warn-border); }
.app-status-strip.is-rejected { background: var(--danger-soft); color: var(--danger); border-color: var(--danger-border); }
.app-status-strip__support:hover { background: color-mix(in srgb, currentColor 8%, transparent); }

/* شريط علوي */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-3) clamp(var(--sp-4), 3vw, var(--sp-6));
  padding-top: calc(var(--sp-3) + env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg-elev) 91%, transparent);
  backdrop-filter: saturate(160%) blur(16px);
  border-bottom: 1px solid var(--border);
  min-height: 64px;
}
.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 {
  width: min(100%, 1240px);
  padding: clamp(var(--sp-4), 2.6vw, var(--sp-8));
  margin-inline: auto;
}
.page--wide { max-width: 1240px; }

/* شريط التنقل السفلي (جوال) */
.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);
  box-shadow: 0 -8px 28px rgb(15 35 25 / .07);
}
.tabbar__item {
  display: grid; place-items: center; gap: 2px;
  padding: var(--sp-2) var(--sp-1);
  min-height: 62px;
  color: var(--text-3);
  font-size: 11px; font-weight: 600;
  text-decoration: none;
  transition: color .15s var(--ease), background .15s var(--ease);
}
.tabbar__item svg { width: 22px; height: 22px; }
.tabbar__item:hover { color: var(--text-2); background: color-mix(in srgb, var(--brand-soft) 38%, transparent); }
.tabbar__item[aria-current="page"] {
  color: var(--brand-text);
  background: linear-gradient(to top, color-mix(in srgb, var(--brand-soft) 78%, transparent), transparent 88%);
}
.tabbar__item:focus-visible { outline-offset: -4px; }

/* تنقّل الإسناد السياقي: يظل داخل الصفحة ولا يغيّر معنى الشريط الرئيسي. */
.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: 5px;
  padding: 18px 14px;
  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);
  min-height: 76px;
  padding: 4px 2px var(--sp-5);
  font-size: 22px; font-weight: 800; color: var(--brand);
  letter-spacing: -.5px;
}
.sidebar__section-label {
  margin: 15px 12px 4px;
  color: var(--text-3);
  font-size: 11px;
  font-weight: var(--fw-bold);
  letter-spacing: .01em;
}
.sidebar__brand + .sidebar__section-label { margin-top: 0; }
.sidebar__item {
  position: relative;
  display: flex; align-items: center; gap: var(--sp-3);
  min-height: 46px;
  padding: 10px 12px;
  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), transform .15s var(--ease);
}
.sidebar__item svg { width: 20px; height: 20px; flex: none; }
.sidebar__item:hover { background: var(--bg-sunk); color: var(--text); transform: translateX(-2px); }
.sidebar__item[aria-current="page"] {
  background: var(--brand-soft); color: var(--brand-text);
  font-weight: var(--fw-bold);
}
.sidebar__item[aria-current="page"]::before {
  content: "";
  position: absolute;
  inset-block: 10px;
  inset-inline-start: 0;
  width: 3px;
  border-radius: var(--r-full);
  background: var(--brand);
}
.sidebar__item:focus-visible { outline-offset: 1px; }
.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); }
}

@media (max-width: 899px) {
  .topbar {
    min-height: 62px;
    padding: 7px 12px;
    padding-block-start: calc(7px + env(safe-area-inset-top));
  }
  .page { padding: 20px 14px 34px; }
}

@media (max-width: 360px) {
  .topbar { gap: 5px; padding-inline: 8px; }
  .page { padding-inline: 10px; }
  .tabbar__item { font-size: 10px; }
}

/* ---------- 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; }

/* ---------- First-run / Auth / Initial Restore ---------- */
.first-run-page {
  position: relative;
  isolation: isolate;
  display: grid;
  place-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  max-width: none;
  padding: max(var(--sp-6), env(safe-area-inset-top)) var(--sp-4) max(var(--sp-6), env(safe-area-inset-bottom));
  overflow: hidden;
}
.first-run-page::before {
  content: '';
  position: absolute;
  z-index: -2;
  inset: 0;
  background: var(--bg);
}
.first-run-orb {
  position: absolute;
  z-index: -1;
  width: clamp(220px, 34vw, 390px);
  aspect-ratio: 1;
  border-radius: 50%;
  pointer-events: none;
}
.first-run-orb--green { inset-block-start: 8%; inset-inline-start: clamp(-270px, -17vw, -120px); background: rgba(36, 164, 105, .14); }
.first-run-orb--blue { inset-block-end: clamp(-250px, -18vw, -120px); inset-inline-end: clamp(-260px, -16vw, -110px); background: rgba(56, 131, 205, .11); }
.first-run-card {
  position: relative;
  width: min(100%, 548px);
  min-width: 0;
  padding: clamp(28px, 5vw, 42px);
  border: 1px solid color-mix(in srgb, var(--brand) 25%, var(--border));
  border-radius: 30px;
  background: linear-gradient(150deg, color-mix(in srgb, var(--brand-soft) 48%, var(--bg-elev)) 0 128px, var(--bg-elev) 240px);
  box-shadow: 0 18px 52px rgba(28, 63, 46, .1);
  overflow: hidden;
}
.first-run-card::before {
  content: '';
  position: absolute;
  inset-block-start: -72px;
  inset-inline-end: -58px;
  width: 180px;
  height: 180px;
  border: 28px solid rgba(21, 152, 94, .14);
  border-radius: 50%;
  pointer-events: none;
}
.first-run-welcome { display: grid; justify-items: center; min-height: min(510px, calc(100dvh - 48px)); text-align: center; }
.first-run-welcome__brand { position: relative; z-index: 1; align-self: start; width: min(100%, 276px); margin-inline: auto; }
.first-run-welcome__copy { align-self: center; max-width: 410px; }
.first-run-welcome__copy h1 { margin: 0; color: var(--text); font-size: clamp(25px, 6vw, 33px); font-weight: 800; line-height: 1.35; letter-spacing: -.025em; text-wrap: balance; }
.first-run-welcome__copy p { margin: 10px 0 0; color: var(--text-2); font-size: clamp(15px, 2.7vw, 17px); line-height: 1.7; }
.first-run-welcome__actions { display: grid; align-self: end; gap: 10px; width: min(100%, 360px); }
.first-run-welcome__actions .btn { min-height: 48px; font-weight: var(--fw-bold); }
.first-run-status { display: grid; justify-items: center; gap: var(--sp-4); min-height: min(470px, calc(100dvh - 48px)); text-align: center; }
.first-run-status__brand { position: relative; z-index: 1; width: min(100%, 210px); }
.first-run-status__spinner { width: 64px; height: 64px; border: 4px solid var(--brand-soft); border-block-start-color: var(--brand); border-radius: 50%; animation: spin .9s linear infinite; }
.first-run-status__icon { display: grid; place-items: center; width: 60px; height: 60px; border-radius: var(--r-xl); background: var(--brand-soft); color: var(--brand-text); }
.first-run-status__icon svg { width: 30px; height: 30px; }
.first-run-status--error .first-run-status__icon { background: var(--danger-soft); color: var(--danger); }
.first-run-eyebrow { margin-bottom: 6px; color: var(--brand-text); font-size: 12px; font-weight: var(--fw-bold); }
.first-run-status__copy { max-width: 410px; }
.first-run-status__copy h1 { margin: 0; font-size: clamp(24px, 5vw, 30px); line-height: 1.4; }
.first-run-status__copy p { margin: 9px 0 0; color: var(--text-2); font-size: 14px; line-height: 1.75; }
.first-run-status__detail { color: var(--text-3); font-size: 12px; }
.first-run-status__actions { display: grid; gap: 9px; width: min(100%, 330px); margin-top: auto; }
.first-run-status__actions .btn { min-height: 44px; }

.sheet:has(.first-run-auth) { max-width: 548px; border: 1px solid color-mix(in srgb, var(--brand) 24%, var(--border)); }
.sheet:has(.first-run-auth) .sheet__head { position: relative; z-index: 1; }
.sheet:has(.first-run-auth) .sheet__title { font-size: clamp(22px, 5vw, 29px); font-weight: 800; }
.sheet:has(.first-run-auth) .sheet__desc { max-width: 42ch; }
.first-run-auth { position: relative; }
.first-run-auth .auth-brand { padding-block: 4px 24px; text-align: center; }
.first-run-auth .auth-brand .brand-lockup { width: min(100%, 240px); margin-inline: auto; }
.first-run-auth form { display: grid; gap: var(--sp-4); }
.first-run-auth__step-title { margin: 0 0 var(--sp-3); font-size: 18px; }
.first-run-auth__otp { min-height: 60px; padding-inline: 22px 10px; text-align: center; font-size: 25px; font-weight: var(--fw-bold); letter-spacing: .58em; font-variant-numeric: tabular-nums; }
.first-run-auth__otp-actions { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); flex-wrap: wrap; }
.first-run-auth__support { justify-self: center; font-size: 12px; }

[data-theme="dark"] .first-run-card { box-shadow: 0 22px 58px rgba(0, 0, 0, .32); }
[data-theme="dark"] .first-run-orb--green { background: rgba(36, 164, 105, .09); }
[data-theme="dark"] .first-run-orb--blue { background: rgba(56, 131, 205, .08); }
[data-theme="dark"] .first-run-card::before { border-color: rgba(21, 152, 94, .11); }

@media (max-width: 420px) {
  .first-run-page { padding-inline: 14px; }
  .first-run-card { min-height: calc(100dvh - 28px); padding: 26px 20px; border-radius: 24px; }
  .first-run-welcome__brand { width: min(100%, 244px); }
  .first-run-welcome__copy h1 { font-size: 25px; }
  .first-run-auth__otp { padding-inline: 16px 5px; font-size: 23px; letter-spacing: .48em; }
  .sheet:has(.first-run-auth) { max-height: calc(var(--visible-viewport-height, 100dvh) - 12px); }
}

@media (max-width: 340px) {
  .first-run-card { padding-inline: 17px; }
  .first-run-welcome__brand { width: min(100%, 226px); }
}

@media (prefers-reduced-motion: reduce) {
  .first-run-status__spinner { animation: none; }
}

/* ---------- 12. الطبقة المنبثقة ---------- */
.sheet-backdrop {
  position: fixed; inset: var(--visible-viewport-top, 0px) 0 auto; height: var(--visible-viewport-height, 100dvh); 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: calc(var(--visible-viewport-height, 100dvh) - 12px);
  display: flex; flex-direction: column; overflow: hidden;
  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); }

/* MICRO-BATCH 02: N29 choice clarity; N21 profile presentation; N20 viewport geometry. */
.first-run-welcome__actions .btn { display: grid; gap: 4px; padding: 13px 16px; white-space: normal; }
.welcome-option__title { font-size: 17px; font-weight: 700; line-height: 1.5; }
[data-workspace-login] .welcome-option__title { font-size: 20px; font-weight: 800; }
.welcome-option__detail { font-size: 13px; font-weight: 400; line-height: 1.6; }
[data-workspace-demo] .welcome-option__detail { color: var(--text-2); }
.profile-completion { display: grid; gap: 18px; min-height: 0; padding: 28px 32px; text-align: start; background: var(--bg-elev); }
.profile-completion::before { display: none; }
.profile-completion .first-run-status__brand { width: 180px; }
.profile-completion .first-run-status__copy h1 { font-size: 26px; }
.profile-completion .first-run-status__copy p { margin-top: 6px; }
.profile-completion .field { width: 100%; margin: 0; }
.profile-completion .field__hint { display: block; }
.profile-completion .field__label { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.profile-completion .field__label small { font-size: 12px; font-weight: 400; color: var(--text-2); }
.profile-completion input { min-height: 46px; scroll-margin-block: 16px; }
.profile-completion input[type=tel] { direction: ltr; text-align: right; }
.profile-completion .settings-teacher-form { width: 100%; }
.profile-completion .settings-teacher-form button { flex: 1; min-height: 44px; }
.profile-completion .first-run-status__actions { width: 100%; margin-top: 2px; }
.profile-completion .field__error:not([hidden]) { margin: 0; padding: 10px 12px; border: 1px solid var(--danger); border-radius: var(--r-md); background: var(--danger-soft); line-height: 1.7; }
[data-account-profile-required] { display: flex; flex-direction: column; align-items: center; height: var(--visible-viewport-height, 100dvh); min-height: 0; overflow-y: auto; overflow-x: clip; }
[data-account-profile-required] .profile-completion { flex-shrink: 0; margin-block: auto; }
.sheet__head, .sheet__foot { flex-shrink: 0; }
.sheet__body { min-height: 0; overflow-y: auto; overscroll-behavior-y: contain; padding: 2px; }
.sheet__body input, .sheet__body textarea, .sheet__body select { scroll-margin-block: 16px; }
@media(max-width: 420px) {
  .profile-completion { min-height: 0; padding: 22px 18px; gap: 16px; border-radius: 22px; }
  [data-account-profile-required] { padding-block: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-bottom)); }
  .profile-completion .first-run-status__copy h1 { font-size: 24px; }
}
@media(max-height: 500px) {
  [data-account-profile-required] { align-items: start; }
}
/* N37 — signed-out landing presentation; existing app surfaces stay unchanged. */
.page.n37-landing-page::before, .page.n37-landing-page::after { content: none; }
.page.n37-landing-page { padding: 48px 32px; overflow: visible; }
.n37-landing { width: min(100%, 1080px); min-width: 0; }
.n37-landing__brand { margin-block-end: 56px; }
.n37-landing__brand .brand-lockup { inline-size: 252px; }
.n37-landing__body { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); align-items: center; gap: clamp(40px, 6vw, 88px); }
.n37-landing__eyebrow { margin: 0 0 14px; color: var(--brand); font-size: 15px; font-weight: 700; }
.n37-landing__hero h1 { margin: 0; color: var(--text); font-size: clamp(34px, 3.9vw, 52px); font-weight: 800; line-height: 1.35; letter-spacing: -.025em; }
.n37-landing__intro { margin: 20px 0 26px; max-width: 490px; color: var(--text-2); font-size: 17px; line-height: 1.9; }
.n37-landing__actions { display: grid; gap: 10px; max-width: 385px; }
.n37-landing__actions .btn { display: grid; gap: 3px; min-height: 66px; padding: 12px 18px; white-space: normal; text-align: center; }
.n37-landing__actions .welcome-option__title { font-size: 17px; font-weight: 700; line-height: 1.5; }
.n37-landing__actions [data-workspace-login] .welcome-option__title { font-size: 20px; font-weight: 800; }
.n37-landing__actions .welcome-option__detail { font-size: 13px; font-weight: 400; line-height: 1.6; }
.n37-landing__actions [data-workspace-demo] .welcome-option__detail { color: var(--text-2); }
.n37-landing__offline { display: flex; align-items: center; gap: 7px; margin: 16px 0 0; color: var(--text-2); font-size: 12px; line-height: 1.7; }
.n37-landing__offline svg { flex: none; color: var(--brand); }
.n37-landing__benefits { padding: 28px; border: 1px solid var(--border); border-radius: 24px; background: var(--bg-elev); }
.n37-landing__benefits h2 { margin: 0 0 26px; color: var(--text); font-size: 20px; font-weight: 700; }
.n37-landing__list { display: grid; gap: 24px; list-style: none; padding: 0; margin: 0; }
.n37-landing__list li { display: flex; align-items: start; gap: 14px; min-width: 0; }
.n37-landing__icon { display: grid; place-items: center; width: 40px; height: 40px; flex: none; border-radius: 11px; color: var(--brand); background: var(--brand-soft); }
.n37-landing__icon svg { width: 21px; height: 21px; }
.n37-landing__list h3 { margin: 0 0 4px; font-size: 16px; font-weight: 700; color: var(--text); line-height: 1.6; }
.n37-landing__list p { margin: 0; font-size: 14px; line-height: 1.8; color: var(--text-2); }
.n37-landing__signature { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-block-start: 52px; padding-block-start: 18px; border-block-start: 1px solid var(--border); color: var(--text-2); font-size: 11px; line-height: 1.8; }
@media (max-width: 899px) {
  .page.n37-landing-page { padding: 36px 24px; }
  .n37-landing { max-width: 600px; }
  .n37-landing__brand { margin-block-end: 32px; }
  .n37-landing__body { grid-template-columns: minmax(0, 1fr); gap: 32px; }
  .n37-landing__hero h1 { font-size: clamp(32px, 5.5vw, 42px); }
  .n37-landing__intro { max-width: none; }
  .n37-landing__actions { max-width: none; }
  .n37-landing__list { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; }
  .n37-landing__list li { display: grid; gap: 10px; }
  .n37-landing__signature { margin-block-start: 28px; }
}
@media (max-width: 479px) {
  .page.n37-landing-page { padding: max(24px, env(safe-area-inset-top)) 20px max(20px, env(safe-area-inset-bottom)); }
  .n37-landing__brand { margin-block-end: 28px; }
  .n37-landing__brand .brand-lockup { inline-size: 216px; }
  .n37-landing__eyebrow { font-size: 13px; margin-block-end: 10px; }
  .n37-landing__hero h1 { font-size: 32px; }
  .n37-landing__intro { font-size: 15px; line-height: 1.8; margin: 16px 0 20px; }
  .n37-landing__body { gap: 28px; }
  .n37-landing__benefits { padding: 20px; border-radius: 18px; }
  .n37-landing__benefits h2 { font-size: 18px; margin-block-end: 20px; }
  .n37-landing__list { gap: 20px 16px; }
  .n37-landing__list h3 { font-size: 14px; }
  .n37-landing__list p { font-size: 13px; }
}
