/* ============================================================
   بكالوري v3.3 — Design System
   "الفضاء الدافي" — Warm Space
   ============================================================ */

/* ============================================================
   1. DESIGN TOKENS
   ============================================================ */
:root{
  /* Colors — Dark (default) */
  --bg:         #0a0a0c;
  --bg-2:       #0f0f13;
  --bg-3:       #131318;
  --surface:    #16161c;
  --surface-2:  #1d1d25;
  --surface-3:  #26262f;
  --overlay:    rgba(0, 0, 0, 0.72);

  --border:     #27272f;
  --border-2:   #383842;
  --border-3:   #4d4d59;

  --text:       #f5f2ed;
  --text-2:     #a8a29a;
  --text-3:     #6b665e;
  --text-4:     #45413b;

  --primary:       #4a7ab5;
  --primary-h:     #6b9bd4;
  --primary-soft:  #142235;
  --primary-glow:  rgba(74, 122, 181, 0.25);

  --accent:        #e67e4f;
  --accent-h:      #d6693a;
  --accent-soft:   #2d1a11;
  --accent-glow:   rgba(230, 126, 79, 0.3);

  --teal:          #3ba7b8;
  --teal-h:        #5ec4d4;
  --teal-soft:     #0e2528;

  --success:       #6ba87a;
  --success-h:     #85be93;
  --success-soft:  #14261a;
  --warn:          #d9a04a;
  --warn-soft:     #2d2113;
  --danger:        #d6685c;
  --danger-h:      #e07e72;
  --danger-soft:   #2d1412;
  --info:          #6b9bd4;
  --info-soft:     #142235;

  --font-body:     "IBM Plex Sans Arabic", system-ui, -apple-system, sans-serif;
  --font-display:  "Almarai", "IBM Plex Sans Arabic", system-ui, sans-serif;
  --font-mono:     ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --t-xs:   12px;
  --t-sm:   13.5px;
  --t-base: 15px;
  --t-md:   16px;
  --t-lg:   18px;
  --t-xl:   22px;
  --t-2xl:  28px;
  --t-3xl:  36px;
  --t-4xl:  48px;
  --t-5xl:  64px;

  --s-1:  4px;
  --s-2:  8px;
  --s-3:  12px;
  --s-4:  16px;
  --s-5:  20px;
  --s-6:  24px;
  --s-8:  32px;
  --s-10: 40px;
  --s-12: 56px;
  --s-16: 80px;
  --s-20: 120px;

  --r-xs:   4px;
  --r-sm:   8px;
  --r-md:   12px;
  --r-lg:   16px;
  --r-xl:   20px;
  --r-2xl:  28px;
  --r-full: 999px;

  --sh-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
  --sh-sm: 0 2px 8px -2px rgba(0, 0, 0, 0.4);
  --sh-md: 0 8px 20px -6px rgba(0, 0, 0, 0.5);
  --sh-lg: 0 20px 40px -12px rgba(0, 0, 0, 0.6);
  --sh-glow-primary: 0 0 40px -10px var(--primary-glow);
  --sh-glow-accent:  0 0 40px -10px var(--accent-glow);

  --ease-cinema: cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-snap:   cubic-bezier(0.4, 0, 0.2, 1);
  --dur-fast:    180ms;
  --dur-base:    300ms;
  --dur-slow:    600ms;

  --topbar-h:     64px;
  --bottom-nav-h: 64px;
  --sidebar-w:    300px;
  --container:    1200px;

  --z-topbar:  50;
  --z-sidebar: 90;
  --z-overlay: 80;
  --z-modal:   150;
  --z-toast:   200;
}

html[data-theme="light"]{
  --bg:         #f5f2eb;
  --bg-2:       #ede9df;
  --bg-3:       #e5e0d3;
  --surface:    #ffffff;
  --surface-2:  #f9f6ef;
  --surface-3:  #ede8dc;
  --overlay:    rgba(10, 10, 12, 0.5);

  --border:     #e0d9c9;
  --border-2:   #c9bfa9;
  --border-3:   #a89e88;

  --text:       #1a1815;
  --text-2:     #4d4740;
  --text-3:     #7a736a;
  --text-4:     #a8a19a;

  --primary:       #1e3a5f;
  --primary-h:     #142a47;
  --primary-soft:  #dde6f0;
  --primary-glow:  rgba(30, 58, 95, 0.15);

  --accent:        #c4522a;
  --accent-h:      #a03f1e;
  --accent-soft:   #f5ded1;
  --accent-glow:   rgba(196, 82, 42, 0.2);

  --teal:          #1e8a9c;
  --teal-h:        #167080;
  --teal-soft:     #d4eef2;

  --success:       #4a7c59;
  --success-soft:  #dce8df;
  --warn:          #b8761c;
  --warn-soft:     #f4e4c8;
  --danger:        #a8442e;
  --danger-soft:   #f0dbd4;
  --info:          #2563eb;
  --info-soft:     #dbeafe;

  --sh-xs: 0 1px 2px rgba(26, 24, 21, 0.04);
  --sh-sm: 0 2px 6px -2px rgba(26, 24, 21, 0.08);
  --sh-md: 0 8px 20px -6px rgba(26, 24, 21, 0.1);
  --sh-lg: 0 20px 40px -12px rgba(26, 24, 21, 0.15);
}

/* ============================================================
   2. RESET
   ============================================================ */
*,
*::before,
*::after{
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html{
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  tab-size: 4;
}

html, body{
  overflow-x: hidden;
  width: 100%;
  max-width: 100vw;
}

body{
  font-family: var(--font-body);
  font-size: var(--t-base);
  font-weight: 400;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  letter-spacing: 0;
  transition:
    background var(--dur-base) var(--ease-cinema),
    color var(--dur-base) var(--ease-cinema);
}

img, svg, canvas, video{
  display: block;
  max-width: 100%;
}

a{
  color: inherit;
  text-decoration: none;
  transition: opacity var(--dur-fast) var(--ease-cinema);
}

button, input, select, textarea{
  font: inherit;
  color: inherit;
}

button{
  background: none;
  border: 0;
  cursor: pointer;
  font-weight: 500;
}

input, textarea, select{
  outline: none;
}

ul, ol{
  list-style: none;
}

::selection{
  background: var(--teal);
  color: #000;
}

::-webkit-scrollbar{
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-track{
  background: transparent;
}
::-webkit-scrollbar-thumb{
  background: var(--border-2);
  border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover{
  background: var(--border-3);
}

:focus-visible{
  outline: 2px solid var(--primary);
  outline-offset: 3px;
  border-radius: var(--r-xs);
}

/* ============================================================
   3. TYPOGRAPHY
   ============================================================ */
h1, h2, h3, h4, h5, h6{
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.15;
  color: var(--text);
}

h1{ font-size: var(--t-3xl); }
h2{ font-size: var(--t-2xl); }
h3{ font-size: var(--t-xl); }
h4{ font-size: var(--t-lg); }
h5{ font-size: var(--t-md); }
h6{ font-size: var(--t-sm); }

p{
  color: var(--text-2);
  line-height: 1.8;
}

small{
  font-size: var(--t-xs);
}

code{
  font-family: var(--font-mono);
  font-size: 0.9em;
  padding: 2px 6px;
  background: var(--surface-2);
  border-radius: var(--r-xs);
}

.eyebrow{
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.22em;
  color: var(--text-3);
  display: inline-block;
  text-transform: uppercase;
  line-height: 1;
}

.display{
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
}

.muted{ color: var(--text-2); }
.dim{ color: var(--text-3); }
.t-xs{ font-size: var(--t-xs); }
.t-sm{ font-size: var(--t-sm); }
.t-lg{ font-size: var(--t-lg); }

.truncate{
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ============================================================
   4. LAYOUT
   ============================================================ */
.container{
  width: 100%;
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 var(--s-4);
}
@media (min-width: 768px){
  .container{ padding: 0 var(--s-6); }
}

.container-narrow{
  max-width: 720px;
}
.container-md{
  max-width: 900px;
}

.app{
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.main{
  flex: 1;
  padding: var(--s-6) 0 calc(var(--bottom-nav-h) + var(--s-6));
}
@media (min-width: 769px){
  .main{
    padding: var(--s-8) 0 var(--s-12);
  }
}

.page{
  animation: pageIn var(--dur-base) var(--ease-cinema);
}
@keyframes pageIn{
  from{ opacity: 0; transform: translateY(8px); }
  to{ opacity: 1; transform: none; }
}

/* ============================================================
   5. BUTTONS
   ============================================================ */
.btn{
  position: relative;
  overflow: hidden;
  isolation: isolate;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  padding: 10px 22px;
  border-radius: var(--r-full);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14px;
  line-height: 1;
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--dur-base) var(--ease-cinema);
  min-height: 42px;
  user-select: none;
}

.btn:disabled{
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.btn svg{
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.btn svg:last-child{
  transition: transform var(--dur-base) var(--ease-cinema);
}
html[dir="rtl"] .btn:hover svg:last-child{
  transform: translateX(-3px);
}
html[dir="ltr"] .btn:hover svg:last-child{
  transform: translateX(3px);
}

.btn-primary::after,
.btn-accent::after,
.btn-success::after{
  content: "";
  position: absolute;
  top: 0;
  inset-inline-start: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: inset-inline-start 700ms var(--ease-cinema);
  pointer-events: none;
}

.btn-primary:hover::after,
.btn-accent:hover::after,
.btn-success:hover::after{
  inset-inline-start: 100%;
}

.btn-primary{
  background: linear-gradient(180deg, #ffffff, #f0ece4);
  color: #0a0a0c;
  box-shadow:
    inset 0 -2px 0 rgba(0, 0, 0, 0.08),
    0 4px 12px -4px rgba(255, 255, 255, 0.15);
}
.btn-primary:hover{
  background: transparent;
  color: var(--text);
  box-shadow: inset 0 0 0 1.5px var(--text);
}

.btn-secondary{
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.04),
    0 1px 2px rgba(0, 0, 0, 0.2);
}
.btn-secondary:hover{
  background: var(--surface-2);
  border-color: var(--border-2);
  transform: translateY(-1px);
}

.btn-ghost{
  background: transparent;
  color: var(--text-2);
}
.btn-ghost:hover{
  color: var(--text);
  background: color-mix(in srgb, var(--text) 8%, transparent);
}

.btn-accent{
  background: linear-gradient(180deg, var(--accent), var(--accent-h));
  color: #fff;
  box-shadow:
    inset 0 -2px 0 rgba(0, 0, 0, 0.15),
    0 8px 24px -8px var(--accent-glow);
}
.btn-accent:hover{
  box-shadow:
    inset 0 -2px 0 rgba(0, 0, 0, 0.15),
    0 12px 40px -8px var(--accent-glow);
  transform: translateY(-1px);
}

.btn-danger{
  background: linear-gradient(180deg, var(--danger), color-mix(in srgb, var(--danger) 85%, black));
  color: #fff;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.15);
}
.btn-danger:hover{
  transform: translateY(-1px);
  filter: brightness(1.08);
}

.btn-success{
  background: linear-gradient(180deg, var(--success), color-mix(in srgb, var(--success) 85%, black));
  color: #fff;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.15);
}
.btn-success:hover{
  transform: translateY(-1px);
  filter: brightness(1.08);
}

.btn-sm{
  padding: 7px 16px;
  font-size: 13px;
  min-height: 36px;
}
.btn-sm svg{
  width: 14px;
  height: 14px;
}
.btn-lg{
  padding: 14px 30px;
  font-size: 15px;
  min-height: 52px;
}
.btn-lg svg{
  width: 18px;
  height: 18px;
}
.btn-block{
  width: 100%;
}
.btn:active:not(:disabled){
  transform: translateY(1px) scale(0.99);
}

.icon-btn{
  width: 42px;
  height: 42px;
  padding: 0;
  border-radius: var(--r-full);
  display: grid;
  place-items: center;
  color: var(--text-2);
  transition: all 250ms var(--ease-cinema);
  position: relative;
  flex-shrink: 0;
  cursor: pointer;
}
.icon-btn:hover{
  background: var(--surface-2);
  color: var(--text);
  transform: scale(1.06);
}
.icon-btn:active{
  transform: scale(0.96);
}
.icon-btn svg{
  width: 20px;
  height: 20px;
}

/* ============================================================
   6. FORMS
   ============================================================ */
.field{
  margin-bottom: var(--s-4);
}

.field label{
  display: block;
  font-size: var(--t-sm);
  font-weight: 600;
  margin-bottom: var(--s-2);
  color: var(--text);
}

.field-hint{
  font-size: var(--t-xs);
  color: var(--text-3);
  margin-top: 6px;
  line-height: 1.5;
}

.input,
.select,
.textarea{
  width: 100%;
  padding: 11px 16px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--text);
  font-size: var(--t-sm);
  font-family: var(--font-body);
  transition: all var(--dur-fast) var(--ease-cinema);
  min-height: 44px;
  line-height: 1.5;
}

.input:hover,
.select:hover,
.textarea:hover{
  border-color: var(--border-2);
}

.input:focus,
.select:focus,
.textarea:focus{
  border-color: var(--primary);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.input::placeholder,
.textarea::placeholder{
  color: var(--text-3);
}

.textarea{
  min-height: 110px;
  resize: vertical;
  line-height: 1.7;
  padding: 12px 16px;
}

.select{
  cursor: pointer;
  padding-inline-end: 40px;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236b665e' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: left 14px center;
}

.input[type="checkbox"],
.input[type="radio"]{
  width: auto;
  min-height: 0;
  height: 18px;
  accent-color: var(--primary);
  cursor: pointer;
}

/* ============================================================
   7. CARD
   ============================================================ */
.card{
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s-5);
  transition:
    border-color var(--dur-base) var(--ease-cinema),
    transform var(--dur-base) var(--ease-cinema),
    box-shadow var(--dur-base) var(--ease-cinema);
}

.card-hover{
  cursor: pointer;
}
.card-hover:hover{
  border-color: var(--border-2);
  transform: translateY(-2px);
  box-shadow: var(--sh-md);
}

.card-head{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  margin-bottom: var(--s-4);
}

.card-title{
  font-family: var(--font-display);
  font-size: var(--t-md);
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: var(--s-2);
  color: var(--text);
}
.card-title svg{
  width: 18px;
  height: 18px;
  color: var(--primary);
  flex-shrink: 0;
}

/* ============================================================
   8. TAGS
   ============================================================ */
.tag{
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: var(--r-full);
  font-size: 11.5px;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--text-2);
  border: 1px solid var(--border);
  white-space: nowrap;
  line-height: 1.3;
}
.tag svg{
  width: 12px;
  height: 12px;
}

.tag-primary{
  background: var(--primary-soft);
  color: var(--primary);
  border-color: transparent;
}
.tag-accent{
  background: var(--accent-soft);
  color: var(--accent);
  border-color: transparent;
}
.tag-teal{
  background: var(--teal-soft);
  color: var(--teal);
  border-color: transparent;
}
.tag-success{
  background: var(--success-soft);
  color: var(--success);
  border-color: transparent;
}
.tag-warn{
  background: var(--warn-soft);
  color: var(--warn);
  border-color: transparent;
}
.tag-danger{
  background: var(--danger-soft);
  color: var(--danger);
  border-color: transparent;
}

/* ============================================================
   9. PROGRESS
   ============================================================ */
.progress{
  height: 4px;
  background: var(--surface-3);
  border-radius: var(--r-full);
  overflow: hidden;
}

.progress > span{
  display: block;
  height: 100%;
  background: var(--primary);
  border-radius: var(--r-full);
  transition: width var(--dur-slow) var(--ease-cinema);
}

.progress.lg{
  height: 6px;
}

/* ============================================================
   10. GRID
   ============================================================ */
.grid{
  display: grid;
  gap: var(--s-4);
}
.grid-2{ grid-template-columns: repeat(2, 1fr); }
.grid-3{ grid-template-columns: repeat(3, 1fr); }
.grid-4{ grid-template-columns: repeat(4, 1fr); }

@media (max-width: 900px){
  .grid-4{ grid-template-columns: repeat(2, 1fr); }
  .grid-3{ grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 520px){
  .grid-2,
  .grid-3,
  .grid-4{ grid-template-columns: 1fr; }
}

/* ============================================================
   11. TOPBAR
   ============================================================ */
.topbar{
  position: sticky;
  top: 0;
  z-index: var(--z-topbar);
  height: var(--topbar-h);
  background: color-mix(in srgb, var(--bg) 75%, transparent);
  backdrop-filter: blur(20px) saturate(1.6);
  -webkit-backdrop-filter: blur(20px) saturate(1.6);
  border-bottom: 1px solid transparent;
  transition: all var(--dur-base) var(--ease-cinema);
}

.topbar.scrolled{
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  border-bottom-color: var(--border);
}

.topbar-inner{
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 var(--s-4);
  height: 100%;
  display: flex;
  align-items: center;
  gap: var(--s-2);
}
@media (min-width: 768px){
  .topbar-inner{ padding: 0 var(--s-6); }
}

.brand{
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 17px;
  letter-spacing: -0.02em;
  cursor: pointer;
  flex-shrink: 0;
}

.brand-mark{
  width: 32px;
  height: 32px;
  flex-shrink: 0;
}

.topbar-spacer{
  flex: 1;
}

.search-pill{
  display: none;
  align-items: center;
  gap: var(--s-2);
  padding: 8px 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  color: var(--text-3);
  font-size: var(--t-sm);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-cinema);
  min-width: 280px;
  min-height: 40px;
}
.search-pill:hover{
  border-color: var(--border-2);
  color: var(--text-2);
}
.search-pill svg{
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}
.search-pill kbd{
  margin-inline-start: auto;
  font-family: var(--font-body);
  font-size: 10.5px;
  padding: 2px 7px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: var(--r-xs);
  color: var(--text-3);
}
@media (min-width: 900px){
  .search-pill{ display: flex; }
}

.has-badge{
  position: relative;
}
.badge{
  position: absolute;
  top: 6px;
  inset-inline-start: 6px;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  min-width: 18px;
  height: 18px;
  border-radius: var(--r-full);
  display: grid;
  place-items: center;
  padding: 0 5px;
  border: 2px solid var(--bg);
  font-family: var(--font-body);
  line-height: 1;
}

.avatar{
  width: 38px;
  height: 38px;
  border-radius: var(--r-full);
  background: var(--primary);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
  overflow: hidden;
  cursor: pointer;
  border: 1.5px solid var(--border-2);
  transition: border-color var(--dur-fast) var(--ease-cinema);
  font-family: var(--font-display);
}
.avatar:hover{
  border-color: var(--primary);
}
.avatar img{
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.avatar.lg{
  width: 80px;
  height: 80px;
  font-size: 30px;
}
.avatar.sm{
  width: 32px;
  height: 32px;
  font-size: 12px;
}

/* ============================================================
   12. SIDEBAR
   ============================================================ */
.overlay{
  position: fixed;
  inset: 0;
  background: var(--overlay);
  z-index: var(--z-overlay);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-base) var(--ease-cinema);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.overlay.show{
  opacity: 1;
  pointer-events: auto;
}

.sidebar{
  position: fixed;
  top: 0;
  inset-inline-end: 0;
  height: 100dvh;
  width: var(--sidebar-w);
  max-width: 88vw;
  background: var(--surface);
  border-inline-start: 1px solid var(--border);
  z-index: var(--z-sidebar);
  transform: translateX(100%);
  transition: transform var(--dur-slow) var(--ease-cinema);
  display: flex;
  flex-direction: column;
  box-shadow: var(--sh-lg);
}
html[dir="rtl"] .sidebar{
  transform: translateX(-100%);
}
.sidebar.open{
  transform: translateX(0) !important;
}

.sidebar-head{
  padding: var(--s-5);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: var(--s-3);
  flex-shrink: 0;
}

.sidebar-user{
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: var(--s-3);
}
.sidebar-user .info{
  min-width: 0;
  flex: 1;
}
.sidebar-user .name{
  font-weight: 600;
  font-size: var(--t-sm);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
  line-height: 1.3;
}
.sidebar-user .sub{
  font-size: var(--t-xs);
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.sidebar-nav{
  flex: 1;
  overflow-y: auto;
  padding: var(--s-3) var(--s-2);
  overscroll-behavior: contain;
}

.nav-item{
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: 11px 14px;
  border-radius: var(--r-sm);
  color: var(--text-2);
  font-size: var(--t-sm);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-cinema);
  margin-bottom: 2px;
  border: 1px solid transparent;
  position: relative;
}
.nav-item:hover{
  background: var(--surface-2);
  color: var(--text);
}
.nav-item.active{
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
}
.nav-item svg{
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}
.nav-item .badge{
  margin-inline-start: auto;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--r-full);
  border: 0;
  position: static;
  min-width: 0;
  height: auto;
}

.nav-section{
  padding: var(--s-4) var(--s-3) var(--s-2);
  font-size: 10.5px;
  font-weight: 800;
  color: var(--text-3);
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.sidebar-foot{
  padding: var(--s-3);
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex-shrink: 0;
}

.foot-link{
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: 10px 14px;
  border-radius: var(--r-sm);
  font-size: var(--t-xs);
  color: var(--text-2);
  transition: all var(--dur-fast) var(--ease-cinema);
}
.foot-link:hover{
  background: var(--surface-2);
  color: var(--text);
}
.foot-link svg{
  width: 15px;
  height: 15px;
  color: var(--text-3);
  flex-shrink: 0;
}

/* ============================================================
   13. BOTTOM NAV
   ============================================================ */
.bottom-nav{
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 40;
  height: var(--bottom-nav-h);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(20px) saturate(1.6);
  -webkit-backdrop-filter: blur(20px) saturate(1.6);
  border-top: 1px solid var(--border);
  display: none;
  padding-bottom: env(safe-area-inset-bottom);
}
@media (max-width: 768px){
  .bottom-nav{ display: flex; }
}

.bottom-nav .inner{
  display: flex;
  width: 100%;
  height: 100%;
  max-width: 500px;
  margin: 0 auto;
}

.bn-item{
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--text-3);
  font-size: 10.5px;
  font-weight: 600;
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease-cinema);
  min-width: 0;
  font-family: var(--font-body);
  padding: 8px 4px;
}
.bn-item svg{
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}
.bn-item.active{
  color: var(--primary);
}
.bn-item.active svg{
  filter: drop-shadow(0 0 8px var(--primary-glow));
}

/* ============================================================
   14. PAGE HEAD
   ============================================================ */
.page-head{
  margin-bottom: var(--s-6);
}
.page-head .eyebrow{
  margin-bottom: 10px;
}
.page-head .title{
  font-family: var(--font-display);
  font-size: var(--t-2xl);
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 4px;
  color: var(--text);
}
.page-head .sub{
  color: var(--text-2);
  font-size: var(--t-sm);
}
@media (max-width: 520px){
  .page-head .title{
    font-size: var(--t-xl);
  }
}

.section{
  margin-bottom: var(--s-10);
}
.section-head{
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--s-3);
  margin-bottom: var(--s-5);
}
.section-title{
  font-family: var(--font-display);
  font-size: var(--t-xl);
  font-weight: 800;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: var(--s-2);
  color: var(--text);
}
.section-title svg{
  width: 22px;
  height: 22px;
  color: var(--primary);
}

/* ============================================================
   15. SUBJECT CARD (Editorial)
   ============================================================ */
.sc{
  position: relative;
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  cursor: pointer;
  transition: all 500ms var(--ease-cinema);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-height: 230px;
  isolation: isolate;
}

.sc-num{
  position: absolute;
  top: -16px;
  inset-inline-end: 20px;
  font-family: var(--font-display);
  font-size: 96px;
  font-weight: 800;
  color: var(--c);
  opacity: 0.07;
  line-height: 1;
  pointer-events: none;
  letter-spacing: -0.05em;
  transition: all 600ms var(--ease-cinema);
  z-index: 0;
}
.sc:hover .sc-num{
  opacity: 0.12;
  transform: translateY(-8px) scale(1.05);
}

.sc::after{
  content: "";
  position: absolute;
  bottom: -40%;
  inset-inline-start: -20%;
  width: 70%;
  height: 70%;
  background: var(--c);
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0;
  transition: opacity 600ms var(--ease-cinema);
  pointer-events: none;
  z-index: -1;
}
.sc:hover::after{
  opacity: 0.18;
}

.sc::before{
  content: "";
  position: absolute;
  top: 0;
  inset-inline: 0;
  height: 3px;
  background: var(--c);
  transform: scaleX(0);
  transform-origin: right;
  transition: transform 500ms var(--ease-cinema);
  z-index: 1;
}
html[dir="rtl"] .sc::before{ transform-origin: left; }
.sc:hover::before{ transform: scaleX(1); }

.sc:hover{
  border-color: var(--c);
  transform: translateY(-5px);
  box-shadow: 0 20px 40px -20px color-mix(in srgb, var(--c) 50%, transparent);
}

.sc-top{
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
  z-index: 2;
}

.sc-icon{
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--c, var(--primary)) 15%, transparent);
  color: var(--c, var(--primary));
  flex-shrink: 0;
  transition: all 500ms var(--ease-cinema);
}
.sc-icon svg{ width: 26px; height: 26px; }
.sc:hover .sc-icon{
  transform: rotate(-4deg) scale(1.06);
  background: color-mix(in srgb, var(--c, var(--primary)) 22%, transparent);
}

.sc-badge{
  font-size: 10.5px;
  padding: 3px 9px;
}
.sc-badge svg{ width: 11px; height: 11px; }

.sc-body{
  flex: 1;
  position: relative;
  z-index: 2;
  min-width: 0;
}
.sc-name{
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
  margin-bottom: 6px;
  line-height: 1.2;
}
.sc-desc{
  font-size: 12.5px;
  color: var(--text-3);
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.sc-progress{
  position: relative;
  z-index: 2;
}
.sc-foot{
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  font-size: 11.5px;
  color: var(--text-2);
  font-weight: 600;
}
.sc-pct{
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 14px;
  color: var(--c);
  letter-spacing: -0.02em;
}

@media (max-width: 900px){
  .sc-num{ font-size: 76px; top: -12px; }
}
@media (max-width: 520px){
  .sc{ min-height: 200px; padding: 20px; }
  .sc-num{ font-size: 64px; }
  .sc-name{ font-size: 16px; }
}

/* ============================================================
   16. LESSON ROW
   ============================================================ */
.lesson-row{
  display: flex;
  align-items: center;
  gap: var(--s-4);
  padding: var(--s-4);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  cursor: pointer;
  transition: all var(--dur-base) var(--ease-cinema);
  margin-bottom: var(--s-2);
}
.lesson-row:hover{
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 4%, var(--surface));
  transform: translateX(-4px);
}
html[dir="rtl"] .lesson-row:hover{
  transform: translateX(4px);
}

.lesson-num{
  width: 38px;
  height: 38px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: var(--t-sm);
  color: var(--text-2);
  flex-shrink: 0;
  transition: all var(--dur-base) var(--ease-cinema);
}

.lesson-row.done .lesson-num{
  background: var(--success-soft);
  color: var(--success);
}

.lesson-info{
  flex: 1;
  min-width: 0;
}
.lesson-title{
  font-weight: 600;
  font-size: var(--t-sm);
  margin-bottom: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}
.lesson-desc{
  font-size: var(--t-xs);
  color: var(--text-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ============================================================
   17. CONTENT ITEM
   ============================================================ */
.ci{
  display: flex;
  gap: var(--s-4);
  padding: var(--s-4);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  cursor: pointer;
  transition: all var(--dur-base) var(--ease-cinema);
  align-items: center;
}

.ci:hover{
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 4%, var(--surface));
}

.ci-thumb{
  width: 46px;
  height: 46px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  display: grid;
  place-items: center;
  color: var(--primary);
  flex-shrink: 0;
}
.ci-thumb svg{
  width: 22px;
  height: 22px;
}

.ci-body{
  flex: 1;
  min-width: 0;
}
.ci-title{
  font-weight: 600;
  font-size: var(--t-sm);
  margin-bottom: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}
.ci-desc{
  font-size: var(--t-xs);
  color: var(--text-2);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.6;
}
.ci-meta{
  font-size: 11px;
  color: var(--text-3);
  margin-top: 6px;
  display: flex;
  gap: var(--s-2);
  flex-wrap: wrap;
  align-items: center;
}

/* ============================================================
   18. STAT CARD
   ============================================================ */
.stat{
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s-5);
  transition: all var(--dur-base) var(--ease-cinema);
  position: relative;
  overflow: hidden;
}

.stat::before{
  content: "";
  position: absolute;
  top: 0;
  inset-inline: 0;
  height: 2px;
  background: var(--c, var(--primary));
  opacity: 0;
  transition: opacity var(--dur-base) var(--ease-cinema);
}
.stat:hover::before{
  opacity: 1;
}

.stat:hover{
  border-color: var(--border-2);
  transform: translateY(-3px);
}

.stat-icon{
  width: 40px;
  height: 40px;
  border-radius: var(--r-sm);
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--c, var(--primary)) 15%, transparent);
  color: var(--c, var(--primary));
  margin-bottom: var(--s-4);
}
.stat-icon svg{
  width: 20px;
  height: 20px;
}

.stat-label{
  font-size: var(--t-xs);
  color: var(--text-2);
  margin-bottom: 6px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.stat-value{
  font-family: var(--font-display);
  font-size: var(--t-3xl);
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.stat-value small{
  font-size: var(--t-md);
  font-weight: 500;
  color: var(--text-3);
  margin-inline-start: 2px;
}

/* ============================================================
   19. EMPTY STATE
   ============================================================ */
.empty-state{
  position: relative;
  text-align: center;
  padding: 80px 24px;
  max-width: 520px;
  margin: 0 auto;
  overflow: hidden;
}

.empty-state-orb{
  position: absolute;
  top: 20%;
  left: 50%;
  transform: translateX(-50%);
  width: 260px;
  height: 260px;
  border-radius: 50%;
  background: var(--primary);
  filter: blur(100px);
  opacity: 0.12;
  pointer-events: none;
  z-index: 0;
  animation: orbPulse 6s ease-in-out infinite;
}
@keyframes orbPulse{
  0%, 100%{ opacity: 0.08; transform: translateX(-50%) scale(1); }
  50%{ opacity: 0.18; transform: translateX(-50%) scale(1.1); }
}

.empty-state-content{
  position: relative;
  z-index: 1;
}

.empty-state-icon{
  width: 88px;
  height: 88px;
  border-radius: 24px;
  background: linear-gradient(135deg, var(--surface-2), var(--surface-3));
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  margin: 0 auto 28px;
  color: var(--primary);
  position: relative;
  box-shadow:
    0 20px 40px -20px var(--primary-glow),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
}
.empty-state-icon::after{
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 30px;
  background: var(--primary);
  filter: blur(24px);
  opacity: 0.2;
  z-index: -1;
}
.empty-state-icon svg{
  width: 40px;
  height: 40px;
}

.empty-state h3{
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 10px;
  color: var(--text);
}

.empty-state p{
  font-size: 15px;
  color: var(--text-2);
  line-height: 1.7;
  margin-bottom: 28px;
  max-width: 380px;
  margin-left: auto;
  margin-right: auto;
}

/* ============================================================
   20. BUBBLES
   ============================================================ */
.bubble{
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
  filter: blur(80px);
}

.bubble-primary{
  background: radial-gradient(circle at 30% 30%, var(--primary), transparent 70%);
  opacity: 0.25;
  animation: bubbleFloat 12s ease-in-out infinite;
}
.bubble-accent{
  background: radial-gradient(circle at 30% 30%, var(--accent), transparent 70%);
  opacity: 0.2;
  animation: bubbleFloat 15s ease-in-out infinite reverse;
}
.bubble-teal{
  background: radial-gradient(circle at 30% 30%, var(--teal), transparent 70%);
  opacity: 0.18;
  animation: bubbleFloat 18s ease-in-out infinite;
}

@keyframes bubbleFloat{
  0%, 100%{ transform: translate(0, 0) scale(1); }
  33%{ transform: translate(20px, -30px) scale(1.1); }
  66%{ transform: translate(-15px, 20px) scale(0.95); }
}

.bubble-dot{
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--teal);
  opacity: 0.4;
  pointer-events: none;
  animation: dotFloat 8s ease-in-out infinite;
}
@keyframes dotFloat{
  0%, 100%{ transform: translateY(0); opacity: 0.3; }
  50%{ transform: translateY(-20px); opacity: 0.7; }
}

/* ============================================================
   21. TOAST
   ============================================================ */
#toast-area{
  position: fixed;
  bottom: calc(var(--bottom-nav-h) + 16px);
  left: 50%;
  transform: translateX(-50%);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  max-width: 92vw;
  align-items: center;
}
@media (min-width: 769px){
  #toast-area{ bottom: 24px; }
}

.toast{
  background: var(--text);
  color: var(--bg);
  padding: 12px 20px;
  border-radius: var(--r-full);
  font-size: var(--t-sm);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: var(--s-2);
  box-shadow: var(--sh-lg);
  animation: toastIn var(--dur-base) var(--ease-cinema);
  pointer-events: auto;
  max-width: 100%;
  line-height: 1.4;
}
.toast svg{
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}
.toast.success{ background: var(--success); color: #fff; }
.toast.error{ background: var(--danger); color: #fff; }
.toast.info{ background: var(--primary); color: #fff; }

@keyframes toastIn{
  from{ opacity: 0; transform: translateY(16px) scale(0.95); }
  to{ opacity: 1; transform: none; }
}

/* ============================================================
   22. MODAL
   ============================================================ */
.modal-bg{
  position: fixed;
  inset: 0;
  background: var(--overlay);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: var(--z-modal);
  display: none;
  align-items: center;
  justify-content: center;
  padding: var(--s-4);
}
.modal-bg.show{
  display: flex;
  animation: fadeIn var(--dur-fast) var(--ease-cinema);
}

.modal{
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  width: 100%;
  max-width: 520px;
  max-height: 90dvh;
  overflow-y: auto;
  box-shadow: var(--sh-lg);
  animation: modalIn var(--dur-base) var(--ease-cinema);
  overscroll-behavior: contain;
}
.modal.lg{ max-width: 720px; }
.modal.sm{ max-width: 420px; }

@keyframes fadeIn{
  from{ opacity: 0; }
  to{ opacity: 1; }
}

@keyframes modalIn{
  from{ opacity: 0; transform: translateY(24px) scale(0.96); }
  to{ opacity: 1; transform: none; }
}

.modal-head{
  padding: var(--s-5) var(--s-6);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
  border-radius: var(--r-xl) var(--r-xl) 0 0;
}
.modal-head h3{
  font-family: var(--font-display);
  font-size: var(--t-lg);
  font-weight: 700;
}

.modal-body{
  padding: var(--s-6);
}

.modal-foot{
  padding: var(--s-4) var(--s-6);
  border-top: 1px solid var(--border);
  display: flex;
  gap: var(--s-2);
  justify-content: flex-start;
  position: sticky;
  bottom: 0;
  background: var(--surface);
  border-radius: 0 0 var(--r-xl) var(--r-xl);
}

/* ============================================================
   23. BREADCRUMB
   ============================================================ */
.crumb{
  display: flex;
  align-items: center;
  gap: var(--s-2);
  font-size: var(--t-xs);
  color: var(--text-3);
  margin-bottom: var(--s-4);
  flex-wrap: wrap;
  line-height: 1.5;
}
.crumb a{
  color: var(--text-2);
  cursor: pointer;
}
.crumb a:hover{
  color: var(--primary);
}
.crumb svg{
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

/* ============================================================
   24. VIDEO
   ============================================================ */
.video-wrap{
  position: relative;
  width: 100%;
  padding-top: 56.25%;
  background: #000;
  border-radius: var(--r-md);
  overflow: hidden;
  margin: var(--s-3) 0;
}
.video-wrap iframe,
.video-wrap video{
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* ============================================================
   25. FILE ROW
   ============================================================ */
.file-row{
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-2);
}

.file-ext{
  width: 46px;
  height: 46px;
  border-radius: var(--r-sm);
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 11px;
  background: var(--danger-soft);
  color: var(--danger);
  flex-shrink: 0;
  letter-spacing: 0.02em;
}
.file-ext.generic{
  background: var(--primary-soft);
  color: var(--primary);
}

.file-info{
  flex: 1;
  min-width: 0;
}
.file-name{
  font-weight: 600;
  font-size: var(--t-sm);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}
.file-meta{
  font-size: var(--t-xs);
  color: var(--text-3);
}

/* ============================================================
   26. HERO CTA
   ============================================================ */
.hero-cta{
  position: relative;
  padding: var(--s-10) var(--s-6);
  border-radius: var(--r-2xl);
  background: var(--surface);
  border: 1px solid var(--border);
  overflow: hidden;
  text-align: center;
  margin-bottom: var(--s-10);
}

.hero-cta-glow{
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 600px;
  height: 600px;
  background: var(--accent);
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.1;
  pointer-events: none;
}

.hero-cta-content{
  position: relative;
  z-index: 1;
  max-width: 600px;
  margin: 0 auto;
}
.hero-cta .eyebrow{ margin-bottom: 16px; }
.hero-cta-title{
  font-family: var(--font-display);
  font-size: clamp(28px, 5vw, 48px);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.05;
  margin-bottom: 16px;
  color: var(--text);
}
.hero-cta-desc{
  font-size: var(--t-md);
  color: var(--text-2);
  margin-bottom: 28px;
  line-height: 1.7;
}

/* ============================================================
   27. EXAM
   ============================================================ */
.exam-bar{
  position: sticky;
  top: var(--topbar-h);
  z-index: 20;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s-3) var(--s-4);
  margin-bottom: var(--s-5);
  display: flex;
  align-items: center;
  gap: var(--s-3);
  box-shadow: var(--sh-sm);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.exam-bar .timer{
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: var(--t-md);
  color: var(--primary);
  font-family: var(--font-mono);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  background: var(--primary-soft);
  border-radius: var(--r-full);
}
.exam-bar .timer.warn{
  color: var(--warn);
  background: var(--warn-soft);
}
.exam-bar .timer.danger{
  color: var(--danger);
  background: var(--danger-soft);
  animation: pulse 1s ease-in-out infinite;
}
@keyframes pulse{
  0%, 100%{ opacity: 1; }
  50%{ opacity: 0.6; }
}

.q-block{
  padding: var(--s-5);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  margin-bottom: var(--s-4);
}

.q-head{
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--s-3);
  font-size: var(--t-xs);
  font-weight: 600;
  color: var(--text-2);
}

.q-text{
  font-weight: 600;
  font-size: var(--t-md);
  margin-bottom: var(--s-4);
  line-height: 1.7;
  color: var(--text);
}

.opt{
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: 12px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-cinema);
  margin-bottom: var(--s-2);
  background: var(--surface);
}

.opt:hover{
  border-color: var(--border-2);
  background: var(--surface-2);
}

.opt.selected{
  border-color: var(--primary);
  background: var(--primary-soft);
}

.opt.correct{
  border-color: var(--success);
  background: var(--success-soft);
}

.opt.wrong{
  border-color: var(--danger);
  background: var(--danger-soft);
}

.opt-radio{
  width: 20px;
  height: 20px;
  border-radius: var(--r-full);
  border: 2px solid var(--border-2);
  flex-shrink: 0;
  display: grid;
  place-items: center;
  transition: all var(--dur-fast) var(--ease-cinema);
  position: relative;
}

.opt.selected .opt-radio{ border-color: var(--primary); }
.opt.selected .opt-radio::after{
  content: "";
  width: 10px;
  height: 10px;
  border-radius: var(--r-full);
  background: var(--primary);
}

.opt.correct .opt-radio{ border-color: var(--success); }
.opt.correct .opt-radio::after{
  content: "";
  width: 10px;
  height: 10px;
  border-radius: var(--r-full);
  background: var(--success);
}

.opt.wrong .opt-radio{ border-color: var(--danger); }
.opt.wrong .opt-radio::after{
  content: "";
  width: 10px;
  height: 10px;
  border-radius: var(--r-full);
  background: var(--danger);
}

.opt-label{
  flex: 1;
  font-size: var(--t-sm);
  font-weight: 500;
  color: var(--text);
  line-height: 1.5;
}

.result-hero{
  text-align: center;
  padding: var(--s-10) var(--s-6);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-2xl);
  box-shadow: var(--sh-md);
  position: relative;
  overflow: hidden;
}
.result-hero::before{
  content: "";
  position: absolute;
  top: 0;
  inset-inline: 0;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--primary), transparent);
}

.result-score{
  font-family: var(--font-display);
  font-size: clamp(56px, 10vw, 88px);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.05em;
  color: var(--primary);
  font-variant-numeric: tabular-nums;
  margin: var(--s-5) 0 var(--s-3);
}
.result-score span{
  font-size: 0.4em;
  color: var(--text-3);
  font-weight: 600;
  margin-inline-start: 4px;
}

.result-pct{
  font-size: var(--t-xl);
  font-weight: 700;
  color: var(--text);
  font-family: var(--font-display);
}

.result-stats{
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--s-3);
  margin-top: var(--s-8);
  text-align: center;
}
@media (max-width: 520px){
  .result-stats{ grid-template-columns: 1fr; }
}

.result-stat-value{
  font-family: var(--font-display);
  font-size: var(--t-2xl);
  font-weight: 800;
  line-height: 1;
  margin-bottom: 6px;
  font-variant-numeric: tabular-nums;
}
.result-stat-label{
  font-size: var(--t-xs);
  color: var(--text-3);
  font-weight: 600;
}

/* ============================================================
   28. BADGES
   ============================================================ */
.badge-card{
  text-align: center;
  padding: var(--s-6) var(--s-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  transition: all var(--dur-base) var(--ease-cinema);
}
.badge-card.locked{
  opacity: 0.42;
  filter: grayscale(1);
}
.badge-card:not(.locked):hover{
  border-color: var(--primary);
  transform: translateY(-3px);
}

.badge-icon{
  width: 64px;
  height: 64px;
  border-radius: var(--r-full);
  margin: 0 auto var(--s-4);
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--primary), var(--teal));
  color: #fff;
  box-shadow: var(--sh-md);
}
.badge-icon svg{
  width: 28px;
  height: 28px;
}
.badge-card.locked .badge-icon{
  background: var(--surface-3);
  color: var(--text-3);
  box-shadow: none;
}

.badge-card h4{
  font-size: var(--t-md);
  margin-bottom: 4px;
}
.badge-card p{
  font-size: var(--t-xs);
  color: var(--text-3);
}

/* ============================================================
   29. CALENDAR ROW
   ============================================================ */
.cal-row{
  display: flex;
  gap: var(--s-4);
  padding: var(--s-4);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  margin-bottom: var(--s-3);
  align-items: center;
  transition: all var(--dur-base) var(--ease-cinema);
}
.cal-row:hover{
  border-color: var(--border-2);
  background: var(--surface-2);
}

.cal-date{
  min-width: 60px;
  text-align: center;
  background: var(--surface-2);
  border-radius: var(--r-sm);
  padding: 8px 6px;
  flex-shrink: 0;
}
.cal-date .d{
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 800;
  color: var(--primary);
  line-height: 1;
}
.cal-date .m{
  font-size: 11px;
  color: var(--text-3);
  font-weight: 600;
  margin-top: 4px;
}

/* ============================================================
   30. ADMIN TABS
   ============================================================ */
.admin-tabs{
  display: flex;
  gap: 6px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.admin-tabs::-webkit-scrollbar{
  display: none;
}

.admin-tab{
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: var(--r-full);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 250ms var(--ease-cinema);
  border: 1px solid transparent;
  flex-shrink: 0;
  font-family: var(--font-body);
}
.admin-tab svg{
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}
.admin-tab:hover{
  background: var(--surface-2);
  color: var(--text);
}
.admin-tab.active{
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 12px -4px var(--primary-glow);
}

@media (max-width: 640px){
  .admin-tab span{ display: none; }
  .admin-tab{ padding: 10px; }
  .admin-tab svg{ width: 18px; height: 18px; }
}

/* ============================================================
   31. UTILITIES
   ============================================================ */
.flex{ display: flex; }
.flex-col{ flex-direction: column; }
.flex-wrap{ flex-wrap: wrap; }
.items-center{ align-items: center; }
.items-start{ align-items: flex-start; }
.items-end{ align-items: flex-end; }
.justify-between{ justify-content: space-between; }
.justify-center{ justify-content: center; }

.gap-1{ gap: var(--s-1); }
.gap-2{ gap: var(--s-2); }
.gap-3{ gap: var(--s-3); }
.gap-4{ gap: var(--s-4); }
.gap-5{ gap: var(--s-5); }

.mt-2{ margin-top: var(--s-2); }
.mt-3{ margin-top: var(--s-3); }
.mt-4{ margin-top: var(--s-4); }
.mt-6{ margin-top: var(--s-6); }
.mt-8{ margin-top: var(--s-8); }

.mb-2{ margin-bottom: var(--s-2); }
.mb-3{ margin-bottom: var(--s-3); }
.mb-4{ margin-bottom: var(--s-4); }
.mb-6{ margin-bottom: var(--s-6); }

.w-full{ width: 100%; }
.text-center{ text-align: center; }
.hidden{ display: none !important; }

.divider{
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border-2), transparent);
  margin: var(--s-6) 0;
  border: 0;
}

.fade-up{
  opacity: 0;
  transform: translateY(24px);
  transition:
    opacity 700ms var(--ease-cinema),
    transform 700ms var(--ease-cinema);
}
.fade-up.visible{
  opacity: 1;
  transform: none;
}

.sk{
  background: linear-gradient(
    90deg,
    var(--surface-2) 0%,
    var(--surface-3) 50%,
    var(--surface-2) 100%
  );
  background-size: 200% 100%;
  animation: sk 1.4s infinite;
  border-radius: var(--r-sm);
}
@keyframes sk{
  0%{ background-position: 200% 0; }
  100%{ background-position: -200% 0; }
}

/* ============================================================
   32. REDUCED MOTION
   ============================================================ */
@media (prefers-reduced-motion: reduce){
  *,
  *::before,
  *::after{
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ============================================================
   33. PRINT
   ============================================================ */
@media print{
  .topbar,
  .sidebar,
  .bottom-nav,
  .overlay,
  #toast-area,
  .modal-bg{
    display: none !important;
  }
  .main{ padding: 0; }
  body{ background: #fff; color: #000; }
}

/* ============================================================
   34. RESPONSIVE HELPERS
   ============================================================ */
@media (max-width: 640px){
  .hide-mobile{ display: none !important; }
  .section{ margin-bottom: var(--s-8); }
}

@media (min-width: 769px){
  .hide-desktop{ display: none !important; }
}

/* ============================================================
   35. MOBILE FIXES (إصلاحات الموبايل)
   ============================================================ */
@media (max-width: 768px){
  .container{
    padding: 0 16px !important;
  }

  .main{
    padding: 16px 0 calc(var(--bottom-nav-h) + 24px) !important;
  }

  section[style*="min-height:70dvh"]{
    min-height: auto !important;
    padding: 40px 0 60px !important;
  }

  section .display[style*="clamp"]{
    font-size: clamp(32px, 11vw, 52px) !important;
    line-height: 1.05 !important;
    letter-spacing: -0.03em !important;
    margin: 16px 0 20px !important;
    word-break: break-word !important;
  }

  section p[style*="font-size:var(--t-lg)"]{
    font-size: 15px !important;
    line-height: 1.7 !important;
    margin-bottom: 28px !important;
    padding: 0 4px;
  }

  section .eyebrow{
    font-size: 10px !important;
    letter-spacing: 0.18em !important;
  }

  section .flex.gap-3{
    gap: 10px !important;
    padding: 0 8px;
  }

  section .btn-lg{
    padding: 12px 24px !important;
    font-size: 14px !important;
    min-height: 46px !important;
    flex: 1;
    min-width: 0;
  }

  .bubble{
    filter: blur(60px) !important;
    opacity: 0.15 !important;
  }
  .bubble-primary{ width: 300px !important; height: 300px !important; }
  .bubble-accent{ width: 250px !important; height: 250px !important; }
  .bubble-teal{ width: 200px !important; height: 200px !important; }
  .bubble-dot{ width: 4px !important; height: 4px !important; }

  .grid-4{
    grid-template-columns: 1fr !important;
    gap: 12px !important;
    margin-top: 40px !important;
  }
  .grid-4 .card{
    padding: 16px !important;
  }

  .page-head{
    margin-bottom: 20px !important;
  }
  .page-head .title{
    font-size: 22px !important;
    line-height: 1.2 !important;
  }
  .page-head .sub{
    font-size: 13px !important;
  }

  .topbar-inner{
    padding: 0 12px !important;
    gap: 4px !important;
  }
  .brand span{
    font-size: 15px !important;
  }
  .brand-mark{
    width: 28px !important;
    height: 28px !important;
  }
  .icon-btn{
    width: 38px !important;
    height: 38px !important;
  }
  .icon-btn svg{
    width: 18px !important;
    height: 18px !important;
  }
  .avatar{
    width: 34px !important;
    height: 34px !important;
    font-size: 12px !important;
  }

  .sidebar{
    width: 85vw !important;
  }

  .stat{
    padding: 16px !important;
  }
  .stat-value{
    font-size: 28px !important;
  }

  .card{
    padding: 16px !important;
  }
  .card-title{
    font-size: 15px !important;
  }

  .sc{
    min-height: 180px !important;
    padding: 20px !important;
    gap: 16px !important;
  }
  .sc-num{
    font-size: 64px !important;
    top: -10px !important;
    inset-inline-end: 14px !important;
  }
  .sc-icon{
    width: 44px !important;
    height: 44px !important;
    border-radius: 12px !important;
  }
  .sc-icon svg{
    width: 22px !important;
    height: 22px !important;
  }
  .sc-name{
    font-size: 16px !important;
  }
  .sc-desc{
    font-size: 12px !important;
  }

  .lesson-row{
    padding: 12px !important;
    gap: 10px !important;
  }
  .lesson-num{
    width: 32px !important;
    height: 32px !important;
    font-size: 12px !important;
  }
  .lesson-title{
    font-size: 13px !important;
  }
  .lesson-desc{
    font-size: 11px !important;
  }

  .ci{
    padding: 12px !important;
    gap: 10px !important;
  }
  .ci-thumb{
    width: 38px !important;
    height: 38px !important;
  }
  .ci-thumb svg{
    width: 18px !important;
    height: 18px !important;
  }

  .empty-state{
    padding: 50px 16px !important;
  }
  .empty-state-icon{
    width: 72px !important;
    height: 72px !important;
    border-radius: 20px !important;
  }
  .empty-state-icon svg{
    width: 32px !important;
    height: 32px !important;
  }
  .empty-state h3{
    font-size: 18px !important;
  }
  .empty-state p{
    font-size: 13px !important;
  }

  .result-hero{
    padding: 32px 20px !important;
  }
  .result-score{
    font-size: 56px !important;
  }
  .result-stats{
    grid-template-columns: 1fr !important;
    gap: 16px !important;
  }

  .modal-bg{
    padding: 12px !important;
    align-items: flex-end !important;
  }
  .modal{
    max-height: 92dvh !important;
    border-radius: 20px 20px 0 0 !important;
  }
  .modal-head{
    padding: 16px 20px !important;
  }
  .modal-body{
    padding: 20px !important;
  }
  .modal-foot{
    padding: 16px 20px !important;
    flex-direction: column !important;
  }
  .modal-foot .btn{
    width: 100% !important;
  }

  .admin-tabs{
    padding: 4px !important;
    gap: 4px !important;
  }
  .admin-tab{
    padding: 8px 12px !important;
    font-size: 12px !important;
  }
  .admin-tab svg{
    width: 14px !important;
    height: 14px !important;
  }

  .section{
    margin-bottom: 32px !important;
  }
  .section-title{
    font-size: 18px !important;
  }
  .section-title svg{
    width: 20px !important;
    height: 20px !important;
  }

  .search-pill{
    display: none !important;
  }

  .divider{
    margin: 32px 0 !important;
  }

  #toast-area{
    bottom: calc(var(--bottom-nav-h) + 12px) !important;
    max-width: 90vw !important;
  }
  .toast{
    font-size: 13px !important;
    padding: 10px 16px !important;
  }
}

@media (max-width: 380px){
  section .display[style*="clamp"]{
    font-size: 30px !important;
  }
  .sc-name{
    font-size: 15px !important;
  }
  .icon-btn{
    width: 36px !important;
    height: 36px !important;
  }
  .icon-btn svg{
    width: 17px !important;
    height: 17px !important;
  }
}

* {
  max-width: 100%;
}

img, svg, video, iframe{
  max-width: 100%;
  height: auto;
}

@media (max-width: 768px){
  section[style*="position:relative"]{
    overflow: hidden !important;
  }
}

/* ============================================================
   END
   ============================================================ */
/* ============================================================
   BOOKS SECTION — v4.0
   ============================================================ */

/* ----- Books Grid ----- */
.books-grid{
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 20px;
}

@media (max-width: 640px){
  .books-grid{
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
}

/* ----- Book Card ----- */
.book-card{
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  cursor: pointer;
  transition: all 500ms var(--ease-cinema);
  display: flex;
  flex-direction: column;
  isolation: isolate;
}

.book-card::before{
  content: "";
  position: absolute;
  top: 0;
  inset-inline: 0;
  height: 3px;
  background: var(--primary);
  transform: scaleX(0);
  transform-origin: right;
  transition: transform 500ms var(--ease-cinema);
  z-index: 2;
}

html[dir="rtl"] .book-card::before{ transform-origin: left; }
.book-card:hover::before{ transform: scaleX(1); }

.book-card:hover{
  border-color: var(--primary);
  transform: translateY(-5px);
  box-shadow: 0 20px 40px -20px var(--primary-glow);
}

/* Book Cover */
.book-cover{
  position: relative;
  width: 100%;
  aspect-ratio: 3/4;
  background: linear-gradient(135deg, var(--surface-2), var(--surface-3));
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.book-cover img{
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 600ms var(--ease-cinema);
}

.book-card:hover .book-cover img{
  transform: scale(1.05);
}

.book-cover-placeholder{
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  color: var(--primary);
  opacity: 0.4;
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--primary) 10%, transparent),
    color-mix(in srgb, var(--primary) 5%, transparent));
}

.book-cover-placeholder svg{
  width: 48px;
  height: 48px;
}

/* Book Info */
.book-info{
  padding: 14px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.book-title{
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  line-height: 1.3;
  color: var(--text);
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.book-author{
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  color: var(--text-3);
  font-weight: 500;
}

.book-author svg{
  width: 12px;
  height: 12px;
}

.book-desc{
  font-size: 12px;
  color: var(--text-2);
  line-height: 1.6;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ============================================================
   BOOK DETAIL PAGE
   ============================================================ */
.book-detail{
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 40px;
  align-items: start;
  margin-bottom: 40px;
}

@media (max-width: 768px){
  .book-detail{
    grid-template-columns: 1fr;
    gap: 24px;
  }
}

.book-detail-cover{
  position: relative;
  width: 100%;
  aspect-ratio: 3/4;
  background: linear-gradient(135deg, var(--surface-2), var(--surface-3));
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 20px 40px -20px rgba(0, 0, 0, 0.3);
}

.book-detail-cover img{
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.book-detail-cover .book-cover-placeholder svg{
  width: 64px;
  height: 64px;
}

.book-detail-info{
  padding-top: 8px;
}

@media (max-width: 768px){
  .book-detail-cover{
    max-width: 220px;
    margin: 0 auto;
  }
  .book-detail-info{
    text-align: center;
  }
  .book-detail-info .flex.gap-2{
    justify-content: center;
  }
}

/* ============================================================
   POSTS WITH MEDIA — Enhancement
   ============================================================ */
.card img{
  max-width: 100%;
  height: auto;
}

.card iframe{
  border: 0;
}

/* ============================================================
   MOBILE FIXES for Books
   ============================================================ */
@media (max-width: 520px){
  .book-info{ padding: 10px 12px 14px; }
  .book-title{ font-size: 13.5px; }
  .book-desc{ font-size: 11px; }
  .book-author{ font-size: 10.5px; }
  .book-detail{ gap: 20px; }
  .book-detail-cover{ max-width: 180px; }
}

/* ============================================================
   END — BOOKS
   ============================================================ */
