/* =====================================================================
   «إتقان» — نظام التصميم
   هوية الشعار: كحلي عميق + بيج رملي، مع لمسة سماوية فيروزية مستوحاة من رسم الذرة في الشعار.
   كل الألوان متغيرات على :root، وتُعاد تعريفها للوضع الليلي.
   ===================================================================== */
:root {
  /* الخلفيات والأسطح */
  --bg: #f4f2ec;
  --bg-2: #ebe7dc;
  --glow-1: rgba(197, 190, 151, .42);
  --glow-2: rgba(120, 166, 214, .20);
  --pattern: rgba(22, 39, 79, .045);
  --surface: #ffffff;
  --surface-2: #f8f6f0;
  --surface-3: #f0ede3;
  --glass: rgba(255, 255, 255, .82);
  /* النصوص */
  --ink: #121a33;
  --ink-2: #4c5571;
  --ink-3: #747c93;
  /* الحدود */
  --line: #e6e2d6;
  --line-2: #d5cfbb;
  /* الهوية */
  --brand: #1e3577;
  --brand-2: #142650;
  --brand-3: #2f4f9f;
  --brand-soft: #e9edf8;
  --brand-tint: #f3f5fb;
  --on-brand: #ffffff;
  --sand: #c5be97;
  --sand-2: #e4dcb6;
  --sand-ink: #6b6235;
  --sand-soft: #f5f1e2;
  --accent: #0d6f86;
  --accent-soft: #e2f1f5;
  /* الحالات */
  --on-ok: #ffffff;
  --ok: #1a7343;
  --ok-2: #239157;
  --ok-soft: #e4f4ea;
  --warn: #8f5a00;
  --warn-soft: #fbf0d8;
  --bad: #b3261e;
  --bad-soft: #fce8e6;
  --info-soft: #e2f1f5;
  /* الشريط العلوي لصفحة الدخول */
  --hero-1: #1a2d63;
  --hero-2: #0f1c40;
  --on-hero: #ffffff;
  --on-hero-2: #d9dcea;
  /* الأيقونات */
  --ic-navy-1: #4a6cc7; --ic-navy-2: #172a5c;
  --ic-teal-1: #3cc2cf; --ic-teal-2: #0b5c70;
  --ic-gold-1: #f6ecc4; --ic-gold-2: #b5a464;
  --ic-green-1: #57cf92; --ic-green-2: #146a42;
  --ic-rose-1: #f59a8f; --ic-rose-2: #a32d25;
  --ic-g-1: #ffffff; --ic-g-2: #e6dfc0;
  --ic-d-1: #2a4486; --ic-d-2: #142650;
  --ic-a-1: #f8edc0; --ic-a-2: #cbb56a;
  --ic-cast: rgba(10, 22, 55, .38);
  --ic-glyph-shadow: rgba(5, 12, 35, .45);
  /* المقاسات والظلال */
  --radius: 16px;
  --radius-sm: 11px;
  --radius-xs: 8px;
  --shadow-sm: 0 1px 2px rgba(18, 28, 60, .06);
  --shadow: 0 1px 2px rgba(18, 28, 60, .05), 0 4px 14px rgba(18, 28, 60, .06);
  --shadow-lg: 0 2px 6px rgba(18, 28, 60, .06), 0 18px 44px rgba(18, 28, 60, .14);
  --ring: 0 0 0 3px rgba(47, 79, 159, .28);
  --ease: cubic-bezier(.2, .7, .2, 1);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1020; --bg-2: #0f1529; --glow-1: rgba(197, 190, 151, .10); --glow-2: rgba(80, 130, 210, .16); --pattern: rgba(200, 210, 240, .035);
    --surface: #141b2f; --surface-2: #19213a; --surface-3: #1f2944; --glass: rgba(16, 22, 40, .82);
    --ink: #e9ecf5; --ink-2: #aab2c8; --ink-3: #828aa2; --line: #273150; --line-2: #34406a;
    --brand: #a8bcf2; --brand-2: #cdd8f7; --brand-3: #7d97e0; --brand-soft: #1f2a4f; --brand-tint: #182140; --on-brand: #0b1020;
    --sand: #d7cfa5; --sand-2: #8d845b; --sand-ink: #e1d7a8; --sand-soft: #262517; --accent: #6fd3e3; --accent-soft: #12303a;
    --on-ok: #0d2418; --ok: #66d396; --ok-2: #4fc584; --ok-soft: #133523; --warn: #ebbb57; --warn-soft: #382c12; --bad: #ff8f86; --bad-soft: #3f1d1b; --info-soft: #12303a;
    --hero-1: #121d40; --hero-2: #070c1b; --on-hero: #ffffff; --on-hero-2: #c4c9dc;
    --ic-navy-1: #6787e0; --ic-navy-2: #253c80; --ic-teal-1: #4fd2de; --ic-teal-2: #11667a; --ic-gold-1: #f6ecc4; --ic-gold-2: #a8975a;
    --ic-green-1: #62d89c; --ic-green-2: #167449; --ic-rose-1: #ffa69c; --ic-rose-2: #aa342c;
    --ic-cast: rgba(0, 0, 0, .6); --ic-glyph-shadow: rgba(0, 0, 0, .5);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3); --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 18px rgba(0, 0, 0, .25);
    --shadow-lg: 0 2px 6px rgba(0, 0, 0, .35), 0 20px 48px rgba(0, 0, 0, .45); --ring: 0 0 0 3px rgba(168, 188, 242, .35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b1020; --bg-2: #0f1529; --glow-1: rgba(197, 190, 151, .10); --glow-2: rgba(80, 130, 210, .16); --pattern: rgba(200, 210, 240, .035);
  --surface: #141b2f; --surface-2: #19213a; --surface-3: #1f2944; --glass: rgba(16, 22, 40, .82);
  --ink: #e9ecf5; --ink-2: #aab2c8; --ink-3: #828aa2; --line: #273150; --line-2: #34406a;
  --brand: #a8bcf2; --brand-2: #cdd8f7; --brand-3: #7d97e0; --brand-soft: #1f2a4f; --brand-tint: #182140; --on-brand: #0b1020;
  --sand: #d7cfa5; --sand-2: #8d845b; --sand-ink: #e1d7a8; --sand-soft: #262517; --accent: #6fd3e3; --accent-soft: #12303a;
  --on-ok: #0d2418; --ok: #66d396; --ok-2: #4fc584; --ok-soft: #133523; --warn: #ebbb57; --warn-soft: #382c12; --bad: #ff8f86; --bad-soft: #3f1d1b; --info-soft: #12303a;
  --hero-1: #121d40; --hero-2: #070c1b; --on-hero: #ffffff; --on-hero-2: #c4c9dc;
  --ic-navy-1: #6787e0; --ic-navy-2: #253c80; --ic-teal-1: #4fd2de; --ic-teal-2: #11667a; --ic-gold-1: #f6ecc4; --ic-gold-2: #a8975a;
  --ic-green-1: #62d89c; --ic-green-2: #167449; --ic-rose-1: #ffa69c; --ic-rose-2: #aa342c;
  --ic-cast: rgba(0, 0, 0, .6); --ic-glyph-shadow: rgba(0, 0, 0, .5);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3); --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 18px rgba(0, 0, 0, .25);
  --shadow-lg: 0 2px 6px rgba(0, 0, 0, .35), 0 20px 48px rgba(0, 0, 0, .45); --ring: 0 0 0 3px rgba(168, 188, 242, .35);
  color-scheme: dark;
}

/* ---------- الأساس ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, system-ui, sans-serif;
  font-size: 16px; line-height: 1.75; min-height: 100vh; position: relative; isolation: isolate;
  -webkit-font-smoothing: antialiased;
}
/* خلفية ناعمة: توهج رملي وسماوي مع نقش سداسي خفيف (حلقات البنزين) يتلاشى نحو الأسفل */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(900px 520px at 100% -8%, var(--glow-1), transparent 62%),
    radial-gradient(760px 520px at -6% 4%, var(--glow-2), transparent 60%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
}
body::after {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none; background-color: var(--pattern);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='97' viewBox='0 0 56 97'%3E%3Cpath d='M28 1 54 16v30L28 61 2 46V16zM28 61v36M2 16 0 15M54 16l2-1' fill='none' stroke='%23000' stroke-width='1.1'/%3E%3C/svg%3E") 0 0 / 56px 97px,
    linear-gradient(180deg, #000 0%, transparent 55%);
  -webkit-mask-composite: source-in; mask-composite: intersect;
}
::selection { background: var(--sand-2); color: var(--ink); }
a { color: var(--brand); text-decoration: none; text-underline-offset: 3px; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.45; margin: 0 0 .5rem; letter-spacing: 0; }
h1 { font-size: 1.7rem; font-weight: 700; }
h2 { font-size: 1.18rem; font-weight: 700; }
h3 { font-size: 1.02rem; font-weight: 600; }
.ltr { direction: ltr; unicode-bidi: isolate; display: inline-block; }
.muted { color: var(--ink-2); }
.small { font-size: .875rem; }
.ic { flex: none; display: inline-block; vertical-align: middle; color: var(--ic-glyph-shadow); overflow: visible; }
.li { flex: none; display: inline-block; vertical-align: middle; }
.ic-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ic-shadow { fill: var(--ic-cast); }
.ic-gs { opacity: .55; }
.ic-navy-1 { stop-color: var(--ic-navy-1); } .ic-navy-2 { stop-color: var(--ic-navy-2); }
.ic-teal-1 { stop-color: var(--ic-teal-1); } .ic-teal-2 { stop-color: var(--ic-teal-2); }
.ic-gold-1 { stop-color: var(--ic-gold-1); } .ic-gold-2 { stop-color: var(--ic-gold-2); }
.ic-green-1 { stop-color: var(--ic-green-1); } .ic-green-2 { stop-color: var(--ic-green-2); }
.ic-rose-1 { stop-color: var(--ic-rose-1); } .ic-rose-2 { stop-color: var(--ic-rose-2); }
.ic-g-1 { stop-color: var(--ic-g-1); } .ic-g-2 { stop-color: var(--ic-g-2); }
.ic-d-1 { stop-color: var(--ic-d-1); } .ic-d-2 { stop-color: var(--ic-d-2); }
.ic-a-1 { stop-color: var(--ic-a-1); } .ic-a-2 { stop-color: var(--ic-a-2); }
/* عنوان مع أيقونة */
.ttl { display: flex; align-items: center; gap: .6rem; }
.ttl > .ic { margin-block: -.25rem; }

/* ---------- الترويسة ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; background: var(--glass);
  -webkit-backdrop-filter: saturate(1.4) blur(14px); backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--line); box-shadow: 0 1px 0 rgba(255, 255, 255, .04), 0 6px 24px rgba(18, 28, 60, .05);
}
.topbar::after { /* خيط رملي رفيع أسفل الترويسة */
  content: ""; position: absolute; inset-inline: 0; bottom: -1px; height: 2px;
  background: linear-gradient(90deg, transparent, var(--sand) 25%, var(--brand-3) 50%, var(--sand) 75%, transparent); opacity: .55;
}
.topbar-inner {
  max-width: 1200px; margin: 0 auto; padding: .55rem 16px 0;
  display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "brand user" "nav nav"; align-items: center; gap: .35rem 1rem;
}
.brand { grid-area: brand; display: flex; align-items: center; gap: .7rem; font-weight: 700; color: var(--ink); min-width: 0; font-size: 1.12rem; }
.brand:hover { text-decoration: none; }
.brand img {
  width: 46px; height: 46px; object-fit: contain; flex: none; border-radius: 13px; padding: 2px;
  background: linear-gradient(160deg, #fffdf6, #efe9d3); box-shadow: 0 1px 2px rgba(18, 28, 60, .12), inset 0 0 0 1px rgba(197, 190, 151, .6);
}
.brand > span { min-width: 0; line-height: 1.35; }
.brand em { font-style: normal; font-weight: 600; color: var(--brand); font-size: .86em; margin-inline-start: .15rem; }
.brand small { display: block; font-weight: 400; color: var(--ink-2); font-size: .76rem; line-height: 1.4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav {
  grid-area: nav; display: flex; gap: .3rem; overflow-x: auto; scrollbar-width: none; padding: .35rem 2px .5rem; margin-inline: -2px;
}
.nav::-webkit-scrollbar { display: none; }
.nav a {
  display: inline-flex; align-items: center; gap: .5rem; padding: .32rem .8rem .32rem .9rem; border-radius: 999px; white-space: nowrap;
  color: var(--ink-2); font-weight: 500; font-size: .95rem; border: 1px solid transparent;
  transition: background-color .18s var(--ease), color .18s var(--ease), border-color .18s var(--ease), box-shadow .18s var(--ease);
}
.nav a .ic { transition: transform .18s var(--ease); }
.nav a:hover { background: var(--surface-3); color: var(--ink); text-decoration: none; }
.nav a:hover .ic { transform: translateY(-1px) scale(1.06); }
.nav a.active {
  background: linear-gradient(180deg, var(--brand-3), var(--brand)); color: var(--on-brand); font-weight: 600;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .25) inset, 0 4px 12px rgba(30, 53, 119, .28);
}
.userbox { grid-area: user; display: flex; gap: .55rem; align-items: center; font-size: .9rem; min-width: 0; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; flex: none; display: grid; place-items: center; font-weight: 700; color: #142650; font-size: 1rem;
  background: radial-gradient(circle at 35% 30%, #fffaf0 0%, #e8dfb8 45%, #b9ad78 100%);
  box-shadow: 0 2px 6px rgba(18, 28, 60, .18), inset 0 -2px 3px rgba(0, 0, 0, .12), inset 0 0 0 1px rgba(255, 255, 255, .5);
}
.who { display: grid; line-height: 1.3; min-width: 0; }
.who b { font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 14rem; }
.who span { font-size: .76rem; color: var(--ink-2); }
#logout { padding: .35rem .75rem; min-height: 36px; font-size: .88rem; }

main { max-width: 1200px; margin: 0 auto; padding: 1.5rem 16px 3rem; }
.crumbs { font-size: .88rem; color: var(--ink-2); margin-bottom: .9rem; display: flex; flex-wrap: wrap; gap: .1rem .35rem; align-items: center; }
.crumbs a { color: var(--ink-2); padding: .05rem .5rem; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); }
.crumbs a:hover { color: var(--brand); border-color: var(--line-2); text-decoration: none; }

/* ---------- البطاقات والشبكات ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.15rem 1.25rem; box-shadow: var(--shadow);
}
.card + .card { margin-top: 1rem; }
.grid > .card + .card, .grid2 > .card + .card, .as-add > .card + .card { margin-top: 0; }
.card > h2:first-child, .card > .ttl:first-child { margin-bottom: .8rem; }
.grid { display: grid; gap: 1rem; }
.grid.kpi { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.grid.cards { grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); }
.kpi .card {
  padding: 1rem 1.1rem; display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "ic value" "ic label"; align-items: center; column-gap: .85rem;
  position: relative; overflow: hidden; transition: transform .18s var(--ease), box-shadow .18s var(--ease);
}

.kpi .card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.kpi .card > .ic { grid-area: ic; }
.kpi .value { grid-area: value; font-size: 1.75rem; font-weight: 700; line-height: 1.15; font-variant-numeric: tabular-nums; color: var(--brand-2); }
.kpi .label { grid-area: label; color: var(--ink-2); font-size: .88rem; line-height: 1.45; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: .6rem 1rem; flex-wrap: wrap; margin: 2rem 0 .85rem; }
.section-title > h2 { margin: 0; }
.see-all { display: inline-flex; align-items: center; gap: .25rem; font-weight: 500; font-size: .92rem; }
.hero { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.35rem; }
.hero p { margin: .25rem 0 0; }
.hero h1 { margin-bottom: .25rem; }
.hero-ic { display: flex; gap: .9rem; align-items: flex-start; min-width: 0; }
.hero-ic > .ic { margin-top: .1rem; }
.hero-ic > div { min-width: 0; }

/* لافتة رئيسية بلون الهوية (الصفحة الرئيسية وصفحة التدريب) */
.banner {
  position: relative; overflow: hidden; border-radius: calc(var(--radius) + 4px); padding: 1.6rem 1.6rem 1.5rem; margin-bottom: 1.35rem;
  background:
    radial-gradient(520px 260px at 0% 0%, rgba(197, 190, 151, .35), transparent 65%),
    radial-gradient(420px 260px at 100% 120%, rgba(110, 170, 225, .28), transparent 60%),
    linear-gradient(135deg, var(--hero-1), var(--hero-2));
  color: var(--on-hero); box-shadow: var(--shadow-lg); border: 1px solid rgba(255, 255, 255, .06);
}
.banner::before { /* نقش سداسي داخل اللافتة */
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .5; background-color: rgba(255, 255, 255, .07);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='97' viewBox='0 0 56 97'%3E%3Cpath d='M28 1 54 16v30L28 61 2 46V16zM28 61v36M2 16 0 15M54 16l2-1' fill='none' stroke='%23000' stroke-width='1.1'/%3E%3C/svg%3E") 0 0 / 56px 97px,
    linear-gradient(270deg, #000, transparent 70%);
  -webkit-mask-composite: source-in; mask-composite: intersect;
}
.banner > * { position: relative; }
.banner h1 { color: var(--on-hero); font-size: 1.9rem; }
.banner .muted, .banner p { color: var(--on-hero-2); }
.banner .eyebrow { display: inline-flex; align-items: center; gap: .4rem; font-size: .8rem; font-weight: 600; color: #f1e9c6; background: rgba(197, 190, 151, .16);
  border: 1px solid rgba(197, 190, 151, .35); padding: .1rem .7rem; border-radius: 999px; margin-bottom: .55rem; }
.banner .btn, .banner button { background: rgba(255, 255, 255, .1); color: #fff; border-color: rgba(255, 255, 255, .25); box-shadow: none; }
.banner .btn:hover, .banner button:hover { background: rgba(255, 255, 255, .18); border-color: rgba(255, 255, 255, .45); }
.banner .btn.primary, .banner button.primary {
  background: linear-gradient(180deg, #f3ecca, #cfc394); color: #142650; border-color: rgba(255, 255, 255, .55);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .7) inset, 0 6px 16px rgba(0, 0, 0, .25);
}
.banner .btn.primary:hover { background: linear-gradient(180deg, #f8f2d8, #d8cda0); }
.banner .small.muted { color: #b9bfd6; }
.banner-mark { width: 74px; height: 74px; border-radius: 20px; padding: 4px; flex: none;
  background: linear-gradient(160deg, #fffdf6, #e9e1c4); box-shadow: 0 8px 22px rgba(0, 0, 0, .3), inset 0 0 0 1px rgba(255, 255, 255, .7); }

.chapter-card { display: flex; flex-direction: column; gap: .7rem; color: var(--ink); transition: transform .18s var(--ease), box-shadow .18s var(--ease), border-color .18s var(--ease); }
.chapter-card:hover { text-decoration: none; border-color: var(--line-2); transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.chapter-card:hover .ch-ic .ic { transform: rotate(-4deg) scale(1.05); }
.ch-head { display: flex; align-items: center; gap: .85rem; }
.ch-head h3 { margin: 0; font-size: 1.05rem; line-height: 1.5; }
.ch-ic { position: relative; flex: none; display: inline-grid; }
.ch-ic .ic { transition: transform .2s var(--ease); }
.chapter-num {
  width: 2.2rem; height: 2.2rem; border-radius: 10px; background: var(--brand-soft); color: var(--brand-2); display: inline-grid; place-items: center; font-weight: 700;
}
.ch-ic .chapter-num {
  position: absolute; inset-inline-end: -6px; bottom: -4px; width: 1.45rem; height: 1.45rem; border-radius: 50%; font-size: .78rem; line-height: 1;
  background: var(--surface); color: var(--brand-2); border: 2px solid var(--sand); box-shadow: var(--shadow-sm);
}
.ch-kicker { display: block; font-size: .76rem; color: var(--sand-ink); font-weight: 600; line-height: 1.3; }
.meta-row { display: flex; gap: .4rem; flex-wrap: wrap; font-size: .85rem; color: var(--ink-2); align-items: center; }

/* ---------- الشارات ---------- */
.badge {
  display: inline-flex; align-items: center; gap: .3rem; padding: .08rem .6rem; border-radius: 999px; font-size: .79rem; line-height: 1.6;
  font-weight: 500; background: var(--surface-3); color: var(--ink-2); border: 1px solid var(--line); white-space: nowrap;
}
.badge.ok { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 22%, transparent); }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 22%, transparent); }
.badge.bad { background: var(--bad-soft); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 22%, transparent); }
.badge.info { background: var(--info-soft); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 22%, transparent); }
.badge.brand { background: var(--brand-soft); color: var(--brand-2); border-color: color-mix(in srgb, var(--brand) 20%, transparent); }

/* ---------- شريط التقدم ---------- */
.bar { height: 9px; background: var(--surface-3); border-radius: 99px; overflow: hidden; box-shadow: inset 0 1px 2px rgba(18, 28, 60, .08); }
.bar > span {
  display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--brand-3), var(--brand));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35); transition: width .3s var(--ease);
}
.bar.ok > span { background: linear-gradient(90deg, var(--ok-2), var(--ok)); }
.progress-line { display: grid; grid-template-columns: 1fr auto; gap: .3rem .75rem; align-items: center; font-size: .9rem; }
.progress-line .bar { grid-column: 1 / -1; }
.levels { display: grid; gap: .75rem; }

/* ---------- قوائم الأهداف ---------- */
.lesson { margin-top: 1rem; }
.lesson-head { display: flex; justify-content: space-between; gap: .75rem; flex-wrap: wrap; align-items: center; }
.lesson-head h2 { margin: 0; }
.obj-list { list-style: none; margin: .75rem 0 0; padding: 0; }
.obj-list li {
  display: grid; grid-template-columns: auto 1fr auto; gap: .75rem; align-items: center; padding: .65rem .6rem;
  border-top: 1px solid var(--line); border-radius: var(--radius-xs); transition: background-color .15s var(--ease);
}
.obj-list li:hover { background: var(--brand-tint); }
.obj-code {
  font-size: .76rem; color: var(--ink-2); direction: ltr; font-variant-numeric: tabular-nums; font-weight: 500;
  background: var(--surface-3); border: 1px solid var(--line); border-radius: 6px; padding: 0 .4rem; display: inline-block; line-height: 1.7;
}
.obj-list .obj-text { color: var(--ink); font-weight: 500; }
.obj-list .obj-text:hover { color: var(--brand); }
.obj-badges { display: flex; gap: .3rem; flex-wrap: wrap; justify-content: flex-end; }

/* ---------- الأزرار ---------- */
button, .btn {
  font: inherit; font-weight: 500; cursor: pointer; border-radius: var(--radius-sm); border: 1px solid var(--line-2); background: var(--surface); color: var(--ink);
  padding: .45rem 1rem; display: inline-flex; align-items: center; justify-content: center; gap: .45rem; line-height: 1.5; min-height: 40px; text-align: center;
  box-shadow: var(--shadow-sm); -webkit-tap-highlight-color: transparent;
  transition: background-color .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease), box-shadow .15s var(--ease), transform .12s var(--ease);
}
button:hover, .btn:hover { border-color: var(--brand-3); color: var(--brand-2); text-decoration: none; background: var(--brand-tint); }
button:active:not(:disabled), .btn:active { transform: translateY(1px); box-shadow: none; }
button.primary, .btn.primary {
  background: linear-gradient(180deg, var(--brand-3), var(--brand)); border-color: var(--brand); color: var(--on-brand); font-weight: 600;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .22), 0 4px 12px rgba(30, 53, 119, .25);
}
button.primary:hover, .btn.primary:hover { background: linear-gradient(180deg, var(--brand), var(--brand-2)); color: var(--on-brand); border-color: var(--brand-2); }
button.ok, .btn.ok {
  background: linear-gradient(180deg, var(--ok-2), var(--ok)); border-color: var(--ok); color: var(--on-ok); font-weight: 600;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .2), 0 4px 12px rgba(26, 115, 67, .2);
}
button.ok:hover { background: var(--ok); color: var(--on-ok); border-color: var(--ok); }
button.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 35%, transparent); background: var(--surface); }
button.danger:hover { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
button:disabled { opacity: .55; cursor: not-allowed; }
button:disabled:hover { transform: none; }
button:focus-visible, .btn:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: 2px solid var(--brand-3); outline-offset: 2px; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface-3); padding: 3px; gap: 3px; }
.seg button { border: 0; border-radius: 8px; background: transparent; box-shadow: none; min-height: 34px; padding: .25rem .8rem; color: var(--ink-2); }
.seg button:hover { background: var(--surface); }
.seg button + button { border-inline-start: 0; }
.seg button.on { background: var(--surface); color: var(--brand-2); font-weight: 600; box-shadow: var(--shadow); }

/* ---------- النماذج ---------- */
label { display: block; font-size: .88rem; color: var(--ink-2); margin-bottom: .3rem; font-weight: 500; }
input, select, textarea {
  font: inherit; width: 100%; padding: .55rem .8rem; border: 1px solid var(--line-2); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink);
  min-height: 42px; transition: border-color .15s var(--ease), box-shadow .15s var(--ease), background-color .15s var(--ease);
}
input:hover, select:hover, textarea:hover { border-color: color-mix(in srgb, var(--brand-3) 45%, var(--line-2)); }
input:focus, select:focus, textarea:focus { border-color: var(--brand-3); box-shadow: var(--ring); outline: none; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; }
input::placeholder, textarea::placeholder { color: var(--ink-3); opacity: .85; }
input[type="checkbox"], input[type="radio"] { width: 1.1rem; height: 1.1rem; min-height: 0; accent-color: var(--brand); padding: 0; box-shadow: none; }
input[type="file"] { padding: .5rem; background: var(--surface-2); border-style: dashed; cursor: pointer; }
input[type="file"]::file-selector-button {
  font: inherit; font-weight: 500; border: 1px solid var(--line-2); border-radius: 8px; background: var(--surface); color: var(--brand-2); padding: .3rem .8rem; margin-inline-end: .6rem; cursor: pointer;
}
select {
  appearance: none; -webkit-appearance: none; padding-inline-start: .8rem; padding-inline-end: 2.2rem; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-2) 50%), linear-gradient(135deg, var(--ink-2) 50%, transparent 50%);
  background-position: left 1rem center, left calc(1rem + 5px) center; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat;
}
textarea { min-height: 4.5rem; resize: vertical; line-height: 1.7; }
.form-grid { display: grid; gap: .8rem; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.field { margin-bottom: .85rem; }
.filters { display: grid; gap: .7rem; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); align-items: end; }

/* ---------- صفحة الهدف ---------- */
.obj-header { display: grid; gap: .75rem; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .45rem 1.1rem; margin: 0; }
.kv dt { color: var(--ink-2); font-size: .88rem; font-weight: 500; }
.kv dd { margin: 0; }
.text-compare { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.text-box { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .7rem .9rem; background: var(--surface-2); border-top: 3px solid var(--sand); }
.text-box:last-child { border-top-color: var(--ok); }
.text-box h4 { margin: 0 0 .3rem; font-size: .82rem; color: var(--ink-2); font-weight: 600; }
.notice { border-radius: var(--radius-sm); padding: .65rem .95rem; background: var(--warn-soft); color: var(--warn); font-size: .93rem;
  border: 1px solid color-mix(in srgb, var(--warn) 18%, transparent); border-inline-start: 4px solid var(--warn); }
.notice.info { background: var(--info-soft); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 18%, transparent); border-inline-start-color: var(--accent); }
.notice.ok { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 18%, transparent); border-inline-start-color: var(--ok); }
.notice.bad { background: var(--bad-soft); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 18%, transparent); border-inline-start-color: var(--bad); }
.review-panel { margin-top: 1rem; background: var(--surface-2); box-shadow: none; }

/* ---------- الأسئلة ---------- */
.q { border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; background: var(--surface); box-shadow: var(--shadow-sm); transition: box-shadow .18s var(--ease), border-color .18s var(--ease); }
.q:hover { border-color: var(--line-2); box-shadow: var(--shadow); }
.q + .q { margin-top: .85rem; }
.q-head { display: flex; justify-content: space-between; gap: .5rem; flex-wrap: wrap; align-items: center; margin-bottom: .4rem; }
.q-num { font-weight: 700; color: var(--brand-2); font-size: .9rem; display: inline-flex; align-items: center; gap: .4rem; }
.q-num::before { content: ""; width: .5rem; height: .5rem; border-radius: 50%; background: linear-gradient(180deg, var(--sand-2), var(--sand)); box-shadow: 0 0 0 3px var(--sand-soft); }
.q-stem { font-weight: 500; margin: .2rem 0 .7rem; font-size: 1.02rem; }
.q.excluded { opacity: .6; border-style: dashed; }
.opts { list-style: none; padding: 0; margin: 0; display: grid; gap: .45rem; }
.opt {
  display: flex; gap: .7rem; align-items: center; padding: .55rem .8rem; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2);
  transition: background-color .15s var(--ease), border-color .15s var(--ease), box-shadow .15s var(--ease);
}
button.opt { width: 100%; text-align: start; justify-content: flex-start; font-weight: 400; box-shadow: none; min-height: 44px; }
button.opt:not(.correct):not(.wrong):not(.selected):hover { background: var(--brand-tint); border-color: var(--brand-3); color: var(--ink); }
.opt .letter {
  font-weight: 700; color: var(--brand-2); min-width: 1.75rem; height: 1.75rem; border-radius: 50%; display: inline-grid; place-items: center; flex: none;
  background: var(--surface); border: 1px solid var(--line-2); font-size: .85rem; line-height: 1;
}
.opt.correct { border-color: var(--ok); background: var(--ok-soft); }
.opt.correct .letter { background: var(--ok); color: var(--on-ok); border-color: var(--ok); }
.opt.selected { border-color: var(--brand-3); background: var(--brand-soft); box-shadow: var(--ring); }
.opt.selected .letter { background: var(--brand); color: var(--on-brand); border-color: var(--brand); }
.opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.opt.wrong .letter { background: var(--bad); color: #fff; border-color: var(--bad); }
.answer { margin-top: .7rem; padding: .7rem .95rem; border-radius: var(--radius-sm); background: var(--brand-tint); font-size: .95rem; border: 1px solid var(--brand-soft); border-inline-start: 4px solid var(--brand-3); }
.answer h4 { margin: .45rem 0 .15rem; font-size: .88rem; color: var(--brand-2); }
.answer h4:first-child { margin-top: 0; }
.answer ul, .answer ol { margin: .1rem 0; padding-inline-start: 1.2rem; }
details > summary { cursor: pointer; }
.answer-wrap > summary.btn { list-style: none; }
.answer-wrap > summary.btn::-webkit-details-marker { display: none; }
.data-table, table.list { border-collapse: separate; border-spacing: 0; width: 100%; font-size: .92rem; }
.data-table { border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.data-table th, .data-table td { border-bottom: 1px solid var(--line); border-inline-start: 1px solid var(--line); padding: .45rem .7rem; text-align: start; }
.data-table th:first-child, .data-table td:first-child { border-inline-start: 0; }
.data-table tr:last-child > * { border-bottom: 0; }
.data-table th { background: var(--surface-3); font-weight: 600; }
table.list th, table.list td { padding: .6rem .75rem; text-align: start; border-bottom: 1px solid var(--line); }
table.list th { background: var(--surface-2); font-weight: 600; font-size: .84rem; color: var(--ink-2); white-space: nowrap; }
table.list thead th:first-child { border-start-start-radius: var(--radius-xs); }
table.list thead th:last-child { border-start-end-radius: var(--radius-xs); }
table.list tbody tr { transition: background-color .15s var(--ease); }
table.list tbody tr:hover { background: var(--brand-tint); }
table.list tbody tr:last-child td { border-bottom: 0; }
.table-wrap { overflow-x: auto; }
.q-tools { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: .7rem; padding-top: .7rem; border-top: 1px dashed var(--line); }
.q-tools button { min-height: 36px; padding: .3rem .8rem; font-size: .9rem; }
.checks { list-style: none; padding: 0; margin: .3rem 0 0; font-size: .85rem; display: grid; gap: .1rem; }
.checks li::before { content: "✓ "; color: var(--ok); }
.checks li.fail::before { content: "✗ "; color: var(--bad); }

/* ---------- النافذة المنبثقة ---------- */
dialog {
  border: 1px solid var(--line); border-radius: 20px; padding: 0; width: min(860px, calc(100vw - 24px)); background: var(--surface); color: var(--ink);
  box-shadow: var(--shadow-lg);
}
dialog[open] { animation: pop .18s var(--ease); }
dialog::backdrop { background: rgba(8, 14, 32, .5); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.dlg-head { display: flex; justify-content: space-between; align-items: center; gap: .75rem; padding: .9rem 1.15rem; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.dlg-head h2 { font-size: 1.1rem; }
.dlg-head [data-close] { width: 38px; min-height: 38px; padding: 0; border-radius: 50%; }
.dlg-body { padding: 1.1rem 1.15rem; max-height: 72vh; overflow: auto; }
.dlg-foot { padding: .8rem 1.15rem; border-top: 1px solid var(--line); display: flex; gap: .5rem; justify-content: flex-end; flex-wrap: wrap; background: var(--surface-2); }

/* ---------- الإشعارات والحالات الفارغة ---------- */
.toast {
  position: fixed; bottom: 22px; inset-inline-start: 50%; transform: translateX(50%); background: var(--brand-2); color: var(--surface);
  padding: .65rem 1.2rem; border-radius: 14px; z-index: 50; box-shadow: var(--shadow-lg); max-width: calc(100vw - 32px); font-weight: 500;
  border: 1px solid rgba(255, 255, 255, .12); animation: toast-in .2s var(--ease);
}
.toast::before { content: ""; display: inline-block; width: .55rem; height: .55rem; border-radius: 50%; background: var(--sand); margin-inline-end: .55rem; vertical-align: middle; }
.toast.error { background: var(--bad); color: #fff; }
.toast.error::before { background: #fff; }
.empty { text-align: center; padding: 2rem 1rem; color: var(--ink-2); display: grid; justify-items: center; gap: .6rem; }
.empty > .ic { opacity: .95; }
.footer { text-align: center; color: var(--ink-2); font-size: .84rem; padding: 1.6rem 16px 2rem; }
.footer::before { content: ""; display: block; width: 64px; height: 3px; border-radius: 3px; margin: 0 auto .9rem; background: linear-gradient(90deg, var(--sand), var(--brand-3)); opacity: .7; }

@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes toast-in { from { opacity: 0; transform: translate(50%, 10px); } to { opacity: 1; transform: translate(50%, 0); } }

@media (max-width: 900px) {
  .topbar-inner { padding-top: .45rem; }
}
@media (max-width: 640px) {
  h1 { font-size: 1.35rem; }
  .banner { padding: 1.2rem 1.1rem; }
  .banner h1 { font-size: 1.45rem; }
  .banner-mark { display: none; }
  .obj-list li { grid-template-columns: 1fr; gap: .3rem; }
  .obj-list li > .obj-code { justify-self: start; }
  .obj-badges { justify-content: flex-start; }
  .kv { grid-template-columns: 1fr; }
  .kv dd { margin-bottom: .35rem; }
  .card { padding: 1rem; }
  .kpi .value { font-size: 1.45rem; }
  .grid.kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .7rem; }
  .kpi .card { grid-template-columns: minmax(0, 1fr); grid-template-areas: "ic" "value" "label"; row-gap: .35rem; padding: .85rem; }
  .grid.cards { grid-template-columns: minmax(0, 1fr); }
  .topbar { position: relative; }
  .brand small { display: none; }
  .brand img { width: 40px; height: 40px; }
  .who { display: none; }
  .nav { margin-inline: -16px; padding-inline: 16px; }
  .hero-ic > .ic { width: 40px; height: 40px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* الطباعة: نسخة الطالب دون حلول، ونسخة المعلم بالحلول */
.print-only { display: none; }
@media print {
  body { background: #fff; color: #000; font-size: 12pt; }
  body::before, body::after, .ic, .ic-sprite { display: none !important; }
  .topbar, .no-print, .q-tools, .footer, .crumbs, .seg, .toast { display: none !important; }
  main { max-width: none; padding: 0; }
  .card, .q { box-shadow: none; border-color: #999; break-inside: avoid; background: #fff; }
  .banner { background: #fff; color: #000; box-shadow: none; border: 1px solid #999; }
  .print-only { display: block; }
  body.print-student .answer, body.print-student .teacher-only, body.print-student .opt.correct::after { display: none !important; }
  body.print-student .opt.correct { background: none; border-color: #999; }
  .badge { border: 1px solid #999; background: none !important; color: #000 !important; }
  .opt, .opt .letter, .answer { background: #fff !important; color: #000 !important; border-color: #999 !important; box-shadow: none !important; }
  .q-num::before { display: none; }
  body.print-teacher .opt.correct { border: 1.5pt solid #000 !important; font-weight: 700; }
}

/* ===== منشئ الاختبارات ===== */
.exam-setup { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.chk-grid { display: flex; flex-wrap: wrap; gap: .35rem .9rem; }
label.chk { display: inline-flex; align-items: center; gap: .45rem; color: var(--ink); font-size: .92rem; margin: .2rem 0; cursor: pointer; font-weight: 400;
  padding: .3rem .7rem; border: 1px solid var(--line); border-radius: 999px; background: var(--surface-2); transition: background-color .15s, border-color .15s; }
label.chk:hover { border-color: var(--line-2); background: var(--brand-tint); }
label.chk:has(input:checked) { background: var(--brand-soft); border-color: color-mix(in srgb, var(--brand) 30%, transparent); color: var(--brand-2); font-weight: 500; }
label.chk input { width: auto; }
.exam-actions { position: sticky; top: var(--tb-h, 0px); z-index: 5; background: var(--glass); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  padding: .6rem .75rem; margin: 0 -.75rem; border-radius: var(--radius-sm); border: 1px solid var(--line); box-shadow: var(--shadow); }

/* الورقة: بيضاء دائمًا ومقاسها A4 في المعاينة والطباعة */
.papers { display: grid; gap: 1.25rem; justify-content: center; grid-template-columns: minmax(0, 210mm); }
.set-student, .set-key { display: grid; gap: 1.25rem; min-width: 0; grid-template-columns: minmax(0, 1fr); }
.paper {
  --ink-p: #111; --brand-p: #1f2d6b; --line-p: #222; --soft-p: #eef1f8;
  width: 210mm; max-width: 100%; min-height: 297mm; background: #fff; color: var(--ink-p);
  padding: 12mm 12mm 14mm; box-shadow: 0 2px 12px rgba(0,0,0,.12); border-radius: 4px;
  font-family: "Noto Naskh Arabic", "Amiri", "Traditional Arabic", serif; font-size: 12.5pt; line-height: 1.6;
}
.paper + .paper { margin-top: 0; }
.paper-head {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 6mm;
  border: 1.6pt solid var(--brand-p); border-radius: 3mm; padding: 3.5mm 5mm; position: relative;
}
.paper-head::after { content: ""; position: absolute; inset: 1.2mm; border: .5pt solid var(--brand-p); border-radius: 2mm; pointer-events: none; }
.ph-right, .ph-left { font-family: "Noto Kufi Arabic", "IBM Plex Sans Arabic", sans-serif; font-size: 10.5pt; line-height: 1.85; color: var(--brand-p); font-weight: 500; }
.ph-right .ph-school { font-weight: 800; font-size: 11.5pt; }
.ph-left { text-align: left; }
.ph-left .ph-title { font-weight: 800; font-size: 12pt; }
.ph-left b { color: var(--ink-p); }
.ph-logo img { height: 27mm; width: auto; display: block; }
.paper-info, .paper-score, .answer-grid, .paper-table { border-collapse: collapse; width: 100%; font-size: 11pt; }
.paper-info { margin-top: 3mm; }
.paper-info th, .paper-info td, .paper-score th, .paper-score td, .answer-grid th, .answer-grid td, .paper-table th, .paper-table td {
  border: .7pt solid var(--line-p); padding: 1.4mm 2.5mm; text-align: center;
}
.paper-info th, .paper-score th, .answer-grid th, .paper-table th { background: var(--soft-p); font-family: "Noto Kufi Arabic", sans-serif; font-weight: 700; font-size: 10pt; white-space: nowrap; }
.paper-info td { height: 8mm; text-align: start; }
.paper-info .w-num { width: 28mm; }
.paper-meta { display: grid; grid-template-columns: auto 1fr .8fr; gap: 3mm; align-items: stretch; margin-top: 3mm; }
.model-badge { border: 1.2pt solid var(--brand-p); border-radius: 2mm; padding: 2mm 4mm; display: grid; place-items: center; font-family: "Noto Kufi Arabic", sans-serif; color: var(--brand-p); font-size: 11pt; text-align: center; }
.model-badge b { font-size: 16pt; }
.paper-score .score-box { width: 18mm; height: 9mm; }
.paper-score .score-total { font-weight: 700; font-size: 13pt; width: 14mm; }
.paper-score .sig { width: 60%; }
.paper-instr { margin: 3mm 0 0; padding: 2mm 3mm; border-inline-start: 1.2mm solid var(--brand-p); background: var(--soft-p); font-size: 11pt; }
.paper-q { margin-top: 5mm; }
.q-title { font-family: "Noto Kufi Arabic", sans-serif; font-size: 12pt; color: var(--brand-p); border-bottom: 1pt solid var(--brand-p); padding-bottom: 1mm; margin: 0 0 3mm; display: flex; justify-content: space-between; gap: 4mm; }
.q-title span { color: var(--ink-p); font-weight: 600; font-size: 11pt; }
.paper-mcq, .paper-essay, .key-list { list-style: none; margin: 0; padding: 0; }
.pq { padding: 1.5mm 0 2mm; border-bottom: .4pt dashed #bbb; break-inside: avoid; }
.pq-stem { font-weight: 600; }
.pq-n { display: inline-grid; place-items: center; min-width: 6.5mm; height: 6.5mm; margin-inline-end: 2mm; border: .8pt solid var(--line-p); border-radius: 50%; font-size: 10pt; font-family: "Noto Kufi Arabic", sans-serif; }
.pq-mark { font-weight: 400; font-size: 11pt; color: #444; }
.pq-opts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1mm 5mm; padding-inline-start: 9mm; margin-top: 1mm; }
.pq-opts.stack { grid-template-columns: 1fr; }
.pq-opts b { color: var(--brand-p); }
.paper-table { width: auto; margin: 1.5mm 9mm 1mm 0; }
.answer-grid { margin-bottom: 3mm; table-layout: fixed; }
.answer-grid td { height: 8mm; font-weight: 700; font-size: 12pt; }
.answer-grid.key td { color: var(--brand-p); }
.answer-lines div { border-bottom: .6pt dotted #777; height: 8.5mm; margin-inline-start: 9mm; }
.key-list li { padding: 1.5mm 0; border-bottom: .4pt dashed #bbb; font-size: 11.5pt; list-style: arabic-indic inside; break-inside: avoid; }
.paper-end { margin-top: 6mm; text-align: center; font-family: "Noto Kufi Arabic", sans-serif; color: var(--brand-p); font-size: 11pt; display: flex; justify-content: space-between; gap: 4mm; border-top: 1pt solid var(--brand-p); padding-top: 2mm; }
.set-student .paper:first-child [data-swap] { cursor: pointer; }
.set-student .paper:first-child [data-swap]:hover { background: #fff7d6; }
@media screen and (max-width: 860px) {
  .papers { justify-content: stretch; grid-template-columns: minmax(0, 1fr); }
  .paper { padding: 6mm; font-size: 12pt; min-height: 0; overflow-x: auto; }
  .answer-grid { font-size: 9pt; }
  .answer-grid th, .answer-grid td { padding: 1mm .5mm; }
  .paper-head { grid-template-columns: 1fr; text-align: center; }
  .ph-left { text-align: center; }
  .ph-logo img { margin: 0 auto; height: 22mm; }
  .paper-meta { grid-template-columns: 1fr; }
  .pq-opts { grid-template-columns: 1fr; }
}

@page { size: A4; margin: 10mm 10mm 14mm; }
@page { @bottom-center { content: "صفحة " counter(page) " من " counter(pages); font-size: 9pt; color: #555; } }
@media print {
  body.exam-printing > *:not(main), body.exam-printing main > *:not(#x-output), body.exam-printing #x-output > *:not(.papers) { display: none !important; }
  body.exam-printing { background: #fff; }
  body.exam-printing .paper { width: auto; min-height: 0; padding: 0; box-shadow: none; border-radius: 0; break-after: page; }
  body.exam-printing .papers { display: block; }
  body.xprint-student .set-key, body.xprint-key .set-student { display: none !important; }
  body.exam-printing .set-student .paper:first-child [data-swap]:hover { background: none; }
  .paper-head, .paper-info th, .paper-score th, .answer-grid th, .paper-instr, .paper-table th { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
.answer-grid tr > th:first-child { width: 24mm; }

.date-row { display: flex; flex-wrap: wrap; gap: .4rem; }
.date-row select { width: auto; flex: 1 1 140px; }
.other-input { margin-top: .35rem; }

/* ---------- صفحة الدخول ---------- */
/* قبل الدخول تُخفى الترويسة والقائمة: لا يظهر إلا نموذج الدخول */
body.locked .topbar { display: none; }
body.locked { background: var(--hero-2); }
body.locked::before {
  background:
    radial-gradient(700px 480px at 85% 0%, rgba(214, 196, 130, .22), transparent 62%),
    radial-gradient(640px 520px at 0% 100%, rgba(100, 160, 225, .24), transparent 60%),
    radial-gradient(900px 600px at 50% 40%, rgba(47, 79, 159, .35), transparent 70%),
    linear-gradient(160deg, var(--hero-1), var(--hero-2));
}
body.locked::after {
  background-color: rgba(255, 255, 255, .06);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='97' viewBox='0 0 56 97'%3E%3Cpath d='M28 1 54 16v30L28 61 2 46V16zM28 61v36M2 16 0 15M54 16l2-1' fill='none' stroke='%23000' stroke-width='1.1'/%3E%3C/svg%3E") 0 0 / 56px 97px,
    radial-gradient(circle at 50% 45%, transparent 18%, #000 75%);
  -webkit-mask-composite: source-in; mask-composite: intersect;
}
body.locked .footer { color: var(--on-hero-2); }
body.locked .footer::before { background: linear-gradient(90deg, transparent, var(--sand), transparent); }
body.locked main { padding-top: 0; }
.login-wrap { min-height: calc(100vh - 130px); display: grid; place-items: center; padding: 1.5rem 0 .5rem; }
.login-card {
  width: min(400px, 100%); background: var(--surface); border: 1px solid rgba(255, 255, 255, .5); border-radius: 26px; position: relative;
  box-shadow: 0 2px 4px rgba(0, 0, 0, .08), 0 30px 70px rgba(3, 8, 24, .45), inset 0 1px 0 rgba(255, 255, 255, .6);
  padding: 1.9rem 1.7rem 1.5rem; text-align: center;
}
.login-card::before { /* خيط ذهبي أعلى البطاقة */
  content: ""; position: absolute; inset-inline: 22%; top: -1px; height: 3px; border-radius: 0 0 4px 4px;
  background: linear-gradient(90deg, transparent, var(--sand), transparent);
}
.login-logo { width: 148px; height: auto; margin: 0 auto .9rem; display: block; }
.login-card h1 { font-size: 1.2rem; margin: 0 0 1.2rem; color: var(--brand-2); display: flex; align-items: center; justify-content: center; gap: .5rem; }
.login-card form { text-align: start; }
.login-card .field { margin-bottom: .95rem; }
.login-card label { font-size: .84rem; color: var(--ink-2); font-weight: 500; margin-bottom: .3rem; }
.login-card input { width: 100%; font-size: 1rem; padding: .7rem .9rem; border-radius: 13px; min-height: 50px; background: var(--surface-2); }
.login-card input:focus { background: var(--surface); }
/* حقل مع أيقونة: الأيقونة في بداية السطر (يمين الحقل) */
.in-ic { position: relative; }
.in-ic > .li { position: absolute; right: .9rem; top: 50%; transform: translateY(-50%); color: var(--ink-3); pointer-events: none; transition: color .15s var(--ease); }
.in-ic:focus-within > .li { color: var(--brand-3); }
.login-card .in-ic input { padding-right: 2.7rem; }
/* الحقول اتجاهها LTR (المعرّف وكلمة المرور)، والتلميح العربي يظهر من اليمين ما دام الحقل فارغًا */
.login-card input[dir="ltr"]:placeholder-shown { direction: rtl; text-align: right; }
.pass-wrap { position: relative; }
.pass-wrap input { padding-left: 3.2rem; }
.pass-toggle {
  position: absolute; left: .4rem; top: 50%; transform: translateY(-50%); border: 0; background: transparent; box-shadow: none; min-height: 36px;
  color: var(--ink-3); font-size: .84rem; font-weight: 600; padding: .25rem .5rem; cursor: pointer; border-radius: 9px;
  display: inline-flex; align-items: center; justify-content: center; min-width: 38px;
}
.pass-toggle .li { position: static; transform: none; pointer-events: none; }
.pass-toggle[aria-pressed="true"] { color: var(--brand); }
.pass-toggle:hover { background: var(--brand-soft); color: var(--brand-2); }
.pass-toggle:active:not(:disabled) { transform: translateY(-50%); }
.login-card button.primary, .login-card .primary { width: 100%; padding: .75rem; font-size: 1.05rem; margin-top: .45rem; border-radius: 13px; min-height: 50px; justify-content: center; text-align: center; }
.login-card .notice { text-align: start; }
.login-foot { margin: 1.1rem 0 0; font-size: .78rem; line-height: 1.75; color: var(--ink-2); padding-top: .9rem; border-top: 1px dashed var(--line); }
/* الشعار بألوان داكنة؛ في الوضع الليلي يوضع على خلفية فاتحة ليبقى مقروءًا */
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .login-logo { background: #fbf8f2; border-radius: 18px; padding: .6rem; } }
:root[data-theme="dark"] .login-logo { background: #fbf8f2; border-radius: 18px; padding: .6rem; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .login-card { border-color: var(--line-2); box-shadow: 0 30px 70px rgba(0, 0, 0, .6); } }
:root[data-theme="dark"] .login-card { border-color: var(--line-2); box-shadow: 0 30px 70px rgba(0, 0, 0, .6); }

[hidden] { display: none !important; }

/* ---------- واجهة الطالب ---------- */
.grid2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1rem; margin-top: 1rem; }
@media screen and (max-width: 860px) { .grid2 { grid-template-columns: minmax(0, 1fr); } }
.st-setup { margin-top: 0; }
.st-ch { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 0 .8rem; background: var(--surface-2); transition: background-color .15s var(--ease); }
.st-ch + .st-ch { margin-top: .55rem; }
.st-ch[open] { background: var(--surface); box-shadow: var(--shadow-sm); padding-bottom: .4rem; }
.st-ch summary { cursor: pointer; padding: .65rem 0; list-style: none; display: flex; align-items: center; gap: .6rem; }
.st-ch summary::-webkit-details-marker { display: none; }
.st-ch summary::after {
  content: ""; margin-inline-start: auto; width: .55rem; height: .55rem; border-inline-end: 2px solid var(--ink-2); border-bottom: 2px solid var(--ink-2);
  transform: rotate(45deg); transition: transform .18s var(--ease); flex: none;
}
.st-ch[open] summary::after { transform: rotate(-135deg); }
.st-lesson {
  display: grid; grid-template-columns: auto 1fr 70px 2.6rem; align-items: center; gap: .55rem; padding: .45rem .5rem; cursor: pointer;
  border-radius: var(--radius-xs); margin: 0; color: var(--ink); font-size: .95rem; font-weight: 400;
}
.st-lesson:hover { background: var(--brand-tint); }
.st-lesson:has(input:checked) { background: var(--brand-soft); }
.st-mastery { height: 7px; background: var(--surface-3); border-radius: 4px; overflow: hidden; }
.st-mastery span { display: block; height: 100%; background: linear-gradient(90deg, var(--ok-2), var(--ok)); }
.st-radio { display: flex; gap: .55rem; align-items: center; padding: .45rem .6rem; cursor: pointer; border-radius: var(--radius-xs); color: var(--ink); font-size: .95rem; font-weight: 400; margin: 0 0 .25rem; border: 1px solid transparent; }
.st-radio:hover { background: var(--brand-tint); }
.st-radio:has(input[type="radio"]:checked) { background: var(--brand-soft); border-color: color-mix(in srgb, var(--brand) 25%, transparent); font-weight: 500; }
fieldset.field { border: 0; padding: 0; margin: 0 0 .8rem; }
fieldset.field legend { font-weight: 600; margin-bottom: .4rem; color: var(--ink); }
.st-start { width: 100%; margin-top: .9rem; padding: .75rem; font-size: 1.05rem; min-height: 52px; justify-content: center; }
.st-run { max-width: 780px; margin: 0 auto; }
.st-top { display: flex; align-items: center; justify-content: space-between; gap: .6rem; margin-bottom: .6rem; flex-wrap: wrap; }
.st-top > span:first-child { font-weight: 700; color: var(--brand-2); display: inline-flex; align-items: center; gap: .5rem; }
.st-timer { font-variant-numeric: tabular-nums; color: var(--ink-2); background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: .1rem .75rem; font-size: .9rem; display: inline-flex; align-items: center; gap: .35rem; }
.st-timer::before { content: ""; width: 15px; height: 15px; flex: none; background-color: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='8'/%3E%3Cpath d='M12 7.5V12l3 2'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='8'/%3E%3Cpath d='M12 7.5V12l3 2'/%3E%3C/svg%3E") center / contain no-repeat; }
.st-timer.over { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 35%, transparent); background: var(--warn-soft); }
.st-run > .bar { height: 10px; }
.st-q { margin-top: .9rem; padding: 1.3rem 1.4rem; border-radius: calc(var(--radius) + 2px); }
.st-meta { display: inline-flex; align-items: center; gap: .4rem; font-size: .84rem; color: var(--ink-2); background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: .05rem .7rem; }
.st-stem { font-size: 1.18rem; line-height: 1.95; margin: .7rem 0 1.1rem; font-weight: 500; }
.st-opts { display: grid; gap: .65rem; }
.st-opt {
  padding: .8rem 1rem; font-size: 1.03rem; cursor: pointer; min-height: 58px; border-radius: 14px; background: var(--surface); border: 1.5px solid var(--line-2);
  box-shadow: 0 1px 0 var(--line), var(--shadow-sm); gap: .85rem;
}
.st-opt .letter { width: 2rem; height: 2rem; min-width: 2rem; font-size: .95rem; background: var(--surface-3); }
.st-opt > span:nth-child(2) { flex: 1; }
.st-opt:not([disabled]):hover { border-color: var(--brand-3); background: var(--brand-tint); transform: translateY(-1px); box-shadow: var(--shadow); }
.st-opt:not([disabled]):hover .letter { background: var(--brand); color: var(--on-brand); border-color: var(--brand); }
.st-opt.ok { border-color: var(--ok); background: var(--ok-soft); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 18%, transparent); }
.st-opt.bad { border-color: var(--bad); background: var(--bad-soft); box-shadow: 0 0 0 3px color-mix(in srgb, var(--bad) 15%, transparent); }
.st-opt.dim { opacity: .65; }
.st-opt.chosen { border-color: var(--brand); box-shadow: var(--ring); }
.st-mark { flex: none; width: 1.8rem; height: 1.8rem; border-radius: 50%; display: inline-grid; place-items: center; color: #fff; }
.st-opt.ok .st-mark { background: var(--ok); color: var(--on-ok); }
.st-opt.bad .st-mark { background: var(--bad); color: #fff; }
.st-fb { margin-top: 1.1rem; padding: .9rem 1.05rem; }
.st-fb > strong { display: flex; align-items: center; gap: .55rem; font-size: 1.02rem; }
.st-fb p { margin: .5rem 0 0; color: var(--ink); }
.st-fb ul { color: var(--ink); margin: .4rem 0 0; }
.linklike { border: 0; background: none; color: var(--brand); padding: .3rem 0; cursor: pointer; text-decoration: underline; box-shadow: none; min-height: 0; justify-content: flex-start; }
.linklike:hover { background: none; color: var(--brand-2); }
.st-nav { justify-content: space-between; margin-top: 1.1rem; }
.st-nav button, .st-nav .btn { min-width: 7.5rem; min-height: 46px; }
.st-result { text-align: center; padding: 1.8rem 1.4rem 1.4rem; position: relative; overflow: hidden; }
.st-result::before { content: ""; position: absolute; inset: 0 0 auto; height: 120px; background: radial-gradient(420px 120px at 50% 0%, var(--sand-soft), transparent 75%); pointer-events: none; }
.st-result > * { position: relative; }
.st-result > .ic { display: block; margin: 0 auto .4rem; }
.st-score { font-size: 1.3rem; margin: .4rem 0 .6rem; }
.st-score b { font-size: 2.8rem; color: var(--brand-2); line-height: 1.1; }
.st-radio input, .st-lesson input { width: 1.1rem; flex: none; margin: 0; }
.st-opt[disabled] { color: var(--ink); opacity: 1; cursor: default; }
.st-opt.dim[disabled] { opacity: .6; }
.st-opt.ok .letter { color: var(--on-ok); background: var(--ok); border-color: var(--ok); }
.st-opt.bad .letter { color: #fff; background: var(--bad); border-color: var(--bad); }
.st-readonly { padding: .6rem .8rem; background: var(--surface-2); border-radius: var(--radius-sm); border: 1px solid var(--line); }

/* ---------- إدارة الطلاب ---------- */
.as-add { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1.2rem; }
@media screen and (max-width: 860px) { .as-add { grid-template-columns: minmax(0, 1fr); } }
.as-add > div { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .9rem 1rem; background: var(--surface-2); }
.as-add h3 { margin: .1rem 0 .3rem; font-size: 1rem; display: flex; align-items: center; gap: .5rem; }
.as-add .actions { margin-top: .6rem; }
.as-prev { max-height: 320px; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.as-listhead { display: flex; justify-content: space-between; align-items: center; gap: .8rem; flex-wrap: wrap; margin-bottom: .6rem; }
.as-listhead h2 { margin: 0; }
.as-table input, .as-table select { padding: .35rem .55rem; min-height: 36px; border-radius: 8px; }
.as-table select { padding-inline-end: 2rem; }
.as-acts { flex-wrap: nowrap; }
.as-acts button { white-space: nowrap; min-height: 34px; padding: .25rem .7rem; font-size: .88rem; }
.as-listhead .actions { flex-wrap: wrap; justify-content: flex-end; }
.as-listhead select, .as-listhead input { width: auto; min-width: 8rem; }
.as-table td { vertical-align: middle; }
.st-opt.ok[disabled], .st-opt.bad[disabled] { color: var(--ink); opacity: 1; }
.as-bulk { display: flex; align-items: center; gap: .9rem; flex-wrap: wrap; margin: .3rem 0 .6rem; padding: .55rem .8rem; background: var(--surface-2); border-radius: 12px; }
.as-bulk #as-del-many { margin-inline-start: auto; }
.as-chk { width: 2.4rem; text-align: center; }
.as-chk input { width: 1.1rem; height: 1.1rem; margin: 0; }
.as-table tr.picked td { background: var(--bad-soft); }
