/* ============================================================
   SaudTube — نظام تصميم فاتح راقٍ هادئ
   Mobile-first لآيفون كبير · خطوط عربية كبيرة · تباين واضح
   ============================================================ */

:root {
  /* الألوان: أبيض دافئ + أزرق بترولي هادئ واحد */
  --bg: #f8f7f4;              /* خلفية بيضاء دافئة */
  --surface: #ffffff;         /* أسطح البطاقات */
  --surface-2: #f1efe9;       /* سطح ثانوي */
  --border: #e7e4dc;          /* حدود ناعمة */
  --border-strong: #d8d4c9;
  --text: #1f2328;            /* نص أساسي داكن واضح */
  --text-soft: #545a63;
  --text-mute: #878d96;
  --accent: #196a75;          /* أزرق بترولي هادئ */
  --accent-hover: #124f58;
  --accent-soft: #e6f0f1;     /* لمسة الأكسنت الفاتحة */
  --accent-ink: #0d3a41;
  --green: #2f8a63;           /* أخضر حكيم لحالة "شوهد" */
  --green-soft: #e8f3ee;
  --danger: #c04545;
  --danger-soft: #fbeceb;

  /* ظلال ناعمة دافئة */
  --shadow-sm: 0 1px 2px rgba(60, 55, 40, .05), 0 1px 4px rgba(60, 55, 40, .05);
  --shadow: 0 4px 18px rgba(60, 55, 40, .09);
  --shadow-lg: 0 16px 44px rgba(50, 45, 35, .14);

  --radius: 20px;
  --radius-sm: 14px;
  --radius-xs: 10px;

  /* أحجام خطوط كبيرة (نظر ضعيف) */
  --fs-body: 18px;
  --fs-small: 16px;
  --fs-title: 24px;
  --fs-page: 30px;

  --tap: 52px; /* أدنى ارتفاع لمس مريح */
}

/* ---------- الأساس ---------- */
* { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Cairo', -apple-system, 'Segoe UI', Tahoma, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: var(--fs-body);
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  min-height: 100dvh;
}
a { color: inherit; text-decoration: none; touch-action: manipulation; }
button { touch-action: manipulation; }
img, svg, video { display: block; max-width: 100%; }

/* إبراز التركيز للوصولية */
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 8px; }

::selection { background: var(--accent-soft); color: var(--accent-ink); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---------- الترويسة ---------- */
.header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(248, 247, 244, .88);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  padding: 12px max(18px, env(safe-area-inset-right)) 12px max(18px, env(safe-area-inset-left));
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.brand { display: flex; align-items: center; gap: 12px; font-size: 24px; font-weight: 800; letter-spacing: -.2px; }
.brand .mark {
  display: inline-grid; place-items: center; width: 46px; height: 46px;
  background: linear-gradient(140deg, var(--accent) 0%, #2b8894 100%);
  border-radius: 14px; box-shadow: var(--shadow-sm);
}
.brand .mark svg { width: 22px; height: 22px; fill: #fff; }
.brand b { color: var(--accent); }
.header-actions { display: flex; align-items: center; gap: 10px; }

/* ---------- الأزرار ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  min-height: var(--tap); padding: 12px 22px;
  border-radius: var(--radius-sm);
  font-family: inherit; font-size: 18px; font-weight: 800;
  cursor: pointer; border: 1.5px solid transparent;
  transition: transform .16s ease, box-shadow .16s ease, background .16s ease, color .16s ease, border-color .16s ease;
  white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn svg { width: 21px; height: 21px; flex-shrink: 0; }
.btn-primary { background: var(--accent); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--accent-hover); box-shadow: var(--shadow); }
.btn-ghost { background: var(--surface); color: var(--text-soft); border-color: var(--border-strong); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn-soft { background: var(--accent-soft); color: var(--accent-ink); }
.btn-soft:hover { background: #d9e9ea; }

/* ---------- الحاوية والعناوين ---------- */
.container {
  max-width: 1280px; margin: 0 auto;
  padding: 24px max(18px, env(safe-area-inset-right)) 120px max(18px, env(safe-area-inset-left));
}
.page-title { font-size: var(--fs-page); font-weight: 900; line-height: 1.35; margin-bottom: 4px; }
.page-sub { color: var(--text-soft); font-size: 18px; margin-bottom: 20px; }
.section-title {
  font-size: var(--fs-title); font-weight: 900; margin: 34px 0 16px;
  display: flex; align-items: center; gap: 12px;
}
.section-title svg { width: 26px; height: 26px; stroke: var(--accent); fill: none; stroke-width: 2.2; flex-shrink: 0; }
.section-title .count { font-size: 17px; font-weight: 700; color: var(--text-mute); }

/* ---------- البحث ---------- */
.search-wrap { position: relative; margin-bottom: 18px; }
.search-wrap svg {
  position: absolute; inset-inline-start: 18px; top: 50%; transform: translateY(-50%);
  width: 24px; height: 24px; stroke: var(--text-mute); fill: none; stroke-width: 2.2; pointer-events: none;
}
.search-input {
  width: 100%; min-height: 58px; padding: 14px 56px 14px 48px;
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: 999px; font-family: inherit; font-size: 19px; font-weight: 600;
  color: var(--text); outline: none; transition: border-color .15s, box-shadow .15s;
  box-shadow: var(--shadow-sm);
}
.search-input::placeholder { color: var(--text-mute); font-weight: 500; }
.search-input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.search-clear {
  position: absolute; inset-inline-end: 10px; top: 50%; transform: translateY(-50%);
  width: 40px; height: 40px; border-radius: 50%; border: none; background: var(--surface-2);
  color: var(--text-soft); font-size: 20px; font-weight: 800; cursor: pointer; display: none;
}
.search-wrap.has-value .search-clear { display: block; }

/* ---------- شريط التصنيفات (تمرير أفقي) ---------- */
.cats {
  display: flex; gap: 10px; overflow-x: auto; padding: 4px 2px 10px;
  margin-bottom: 8px; scrollbar-width: none; -webkit-overflow-scrolling: touch;
  scroll-snap-type: x proximity;
}
.cats::-webkit-scrollbar { display: none; }
.cat-chip {
  flex-shrink: 0; scroll-snap-align: start;
  min-height: 48px; display: inline-flex; align-items: center;
  padding: 8px 22px; background: var(--surface); border: 1.5px solid var(--border);
  border-radius: 999px; font-size: 17px; font-weight: 700; color: var(--text-soft);
  cursor: pointer; transition: .15s; box-shadow: var(--shadow-sm);
}
.cat-chip:hover { border-color: var(--accent); color: var(--accent); }
.cat-chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ---------- شريط الترتيب ---------- */
.sort-box {
  display: flex; align-items: center; gap: 9px; min-height: 48px;
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); padding: 6px 16px; color: var(--text-soft); flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}
.sort-box svg { width: 20px; height: 20px; stroke: var(--text-mute); fill: none; stroke-width: 2; }
.sort-box select {
  border: none; background: transparent; font-family: inherit; font-size: 17px;
  font-weight: 700; color: var(--text); cursor: pointer; outline: none; min-height: 44px;
}
.lib-controls { display: flex; flex-direction: column; gap: 6px; margin-bottom: 18px; }

/* ---------- شبكة الكورسات (عمود واحد على الجوال) ---------- */
.grid { display: grid; grid-template-columns: 1fr; gap: 20px; }

/* ---------- بطاقة كورس ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column;
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}
.card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); border-color: var(--border-strong); }
.card:active { transform: scale(.985); }

.card-thumb {
  aspect-ratio: 16 / 9; position: relative; overflow: hidden;
  display: grid; place-items: center;
}
/* زخرفة هادئة داخل الصورة المصغّرة */
.card-thumb::before {
  content: ''; position: absolute; inset: 0;
  background:
    radial-gradient(circle at 82% 18%, rgba(255,255,255,.5) 0, transparent 42%),
    radial-gradient(circle at 12% 88%, rgba(255,255,255,.32) 0, transparent 46%);
}
.card-thumb .play-icon {
  width: 64px; height: 64px; border-radius: 50%;
  background: rgba(255,255,255,.94); display: grid; place-items: center;
  box-shadow: var(--shadow); transition: transform .2s; z-index: 2;
}
.card-thumb .play-icon svg { width: 26px; height: 26px; fill: var(--text); margin-inline-start: 3px; }
.card:hover .play-icon { transform: scale(1.12); }
.card-cat-tag {
  position: absolute; top: 12px; inset-inline-start: 12px; z-index: 2;
  color: #fff; font-size: 14px; font-weight: 800; padding: 6px 15px;
  border-radius: 9px; box-shadow: var(--shadow-sm);
}
.card-duration {
  position: absolute; bottom: 12px; inset-inline-end: 12px; z-index: 2;
  background: rgba(20, 25, 30, .78); color: #fff; font-size: 15px; font-weight: 700;
  padding: 5px 12px; border-radius: 8px;
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}

.card-body { padding: 16px 18px 18px; flex: 1; display: flex; flex-direction: column; gap: 8px; }
.card-title {
  font-size: 20px; font-weight: 800; line-height: 1.55;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-instructor { display: flex; align-items: center; gap: 8px; color: var(--text-soft); font-size: 16px; font-weight: 700; }
.card-instructor svg { width: 17px; height: 17px; fill: var(--text-mute); flex-shrink: 0; }
.card-stats {
  display: flex; align-items: center; gap: 18px; color: var(--text-soft); font-size: 16px;
  margin-top: auto; padding-top: 11px; border-top: 1px solid var(--surface-2);
}
.card-stats .stat { display: flex; align-items: center; gap: 7px; font-weight: 700; }
.card-stats svg { width: 17px; height: 17px; stroke: var(--text-mute); fill: none; stroke-width: 2; flex-shrink: 0; }

/* شريط تقدم المشاهدة */
.progress-bar { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin-top: 8px; }
.progress-fill { height: 100%; background: var(--green); border-radius: 99px; transition: width .3s; }
.progress-label { font-size: 15px; font-weight: 700; color: var(--green); margin-top: 4px; }

/* ---------- قسم "أكمل المشاهدة" ---------- */
.continue-row {
  display: flex; gap: 16px; overflow-x: auto; padding: 4px 2px 14px;
  scrollbar-width: none; -webkit-overflow-scrolling: touch; scroll-snap-type: x proximity;
}
.continue-row::-webkit-scrollbar { display: none; }
.continue-card {
  flex: 0 0 82%; max-width: 380px; scroll-snap-align: start;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow-sm); transition: transform .18s, box-shadow .18s;
}
.continue-card:active { transform: scale(.98); }
.continue-thumb { aspect-ratio: 16/7; position: relative; display: grid; place-items: center; }
.continue-thumb .play-icon {
  width: 54px; height: 54px; border-radius: 50%; background: rgba(255,255,255,.94);
  display: grid; place-items: center; box-shadow: var(--shadow);
}
.continue-thumb .play-icon svg { width: 22px; height: 22px; fill: var(--text); margin-inline-start: 2px; }
.continue-body { padding: 14px 16px 16px; }
.continue-body .t { font-size: 18px; font-weight: 800; line-height: 1.5; margin-bottom: 4px;
  display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.continue-body .m { font-size: 15px; color: var(--text-soft); font-weight: 600; }

/* بانر "تابع من حيث توقفت" (من localStorage) */
.resume-banner {
  display: none; align-items: center; gap: 14px;
  background: linear-gradient(140deg, var(--accent) 0%, #2b8894 100%);
  color: #fff; border-radius: var(--radius); padding: 16px 20px;
  margin-bottom: 22px; box-shadow: var(--shadow);
}
.resume-banner.show { display: flex; }
.resume-banner .ic {
  width: 52px; height: 52px; border-radius: 50%; background: rgba(255,255,255,.18);
  display: grid; place-items: center; flex-shrink: 0;
}
.resume-banner .ic svg { width: 24px; height: 24px; fill: #fff; margin-inline-start: 2px; }
.resume-banner .txt { flex: 1; min-width: 0; }
.resume-banner .txt .a { font-size: 15px; font-weight: 700; opacity: .85; }
.resume-banner .txt .b { font-size: 18px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- عنوان مجموعة تصنيف ---------- */
.cat-group-title {
  font-size: 23px; font-weight: 900; margin: 34px 0 16px;
  display: flex; align-items: center; gap: 12px;
}
.cat-group-title .dot { width: 14px; height: 14px; border-radius: 5px; flex-shrink: 0; }
.cat-group-title .count { font-size: 16px; font-weight: 700; color: var(--text-mute); }

/* ---------- حالة فارغة ---------- */
.empty-state {
  grid-column: 1 / -1; text-align: center; padding: 60px 20px; color: var(--text-mute);
}
.empty-state svg { width: 64px; height: 64px; stroke: var(--border-strong); fill: none; stroke-width: 1.6; margin: 0 auto 16px; }
.empty-state p { font-size: 19px; font-weight: 700; }

/* ---------- شريط المهام الجارية ---------- */
.jobs-bar {
  background: var(--surface); border: 1.5px solid var(--accent-soft);
  border-inline-start: 5px solid var(--accent);
  border-radius: var(--radius-sm); padding: 14px 18px; margin-bottom: 20px;
  display: flex; flex-direction: column; gap: 10px; box-shadow: var(--shadow-sm);
}
.jobs-bar .row { display: flex; align-items: center; gap: 12px; font-size: 17px; color: var(--accent-ink); font-weight: 700; }
.spinner {
  width: 22px; height: 22px; flex-shrink: 0;
  border: 3px solid var(--accent-soft); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
/* شريط تقدم متحرك غير محدد */
.jobs-track { height: 8px; background: var(--accent-soft); border-radius: 99px; overflow: hidden; position: relative; }
.jobs-track::after {
  content: ''; position: absolute; top: 0; bottom: 0; width: 36%;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  border-radius: 99px; animation: slide 1.6s ease-in-out infinite;
}
@keyframes slide {
  0% { inset-inline-start: -36%; }
  100% { inset-inline-start: 100%; }
}

/* ---------- النافذة المنبثقة (إضافة رابط) ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(35, 32, 26, .48);
  -webkit-backdrop-filter: blur(5px); backdrop-filter: blur(5px);
  display: none; align-items: flex-end; justify-content: center; z-index: 100;
}
.modal-overlay.show { display: flex; }
.modal {
  background: var(--surface); border-radius: 26px 26px 0 0;
  padding: 26px 22px calc(26px + env(safe-area-inset-bottom));
  width: 100%; max-width: 560px;
  box-shadow: var(--shadow-lg); animation: sheet .28s cubic-bezier(.2,.9,.3,1);
  max-height: 88dvh; overflow-y: auto;
}
@keyframes sheet { from { transform: translateY(40px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal .grip { width: 48px; height: 5px; border-radius: 99px; background: var(--border-strong); margin: 0 auto 18px; }
.modal h3 { font-size: 24px; font-weight: 900; margin-bottom: 6px; }
.modal > p { color: var(--text-soft); font-size: 17px; margin-bottom: 20px; }
.field { margin-bottom: 18px; }
.field label { display: block; font-size: 17px; font-weight: 800; color: var(--text); margin-bottom: 8px; }
.input, select.input {
  width: 100%; min-height: 56px; padding: 14px 18px;
  background: var(--surface-2); border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); font-family: inherit; font-size: 18px;
  color: var(--text); outline: none; transition: .15s;
  -webkit-appearance: none; appearance: none;
}
select.input {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23545a63' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: left 16px center; padding-inline-end: 18px;
}
.input:focus { border-color: var(--accent); background: #fff; box-shadow: 0 0 0 4px var(--accent-soft); }
.hint { font-size: 16px; color: var(--text-soft); background: var(--surface-2); border-radius: var(--radius-xs); padding: 12px 15px; margin: 0; }
.modal-actions { display: flex; gap: 12px; margin-top: 22px; }
.modal-actions .btn { flex: 1; }

/* ---------- الزر العائم (+) ---------- */
.fab {
  position: fixed; inset-inline-end: max(18px, env(safe-area-inset-right));
  bottom: calc(22px + env(safe-area-inset-bottom)); z-index: 60;
  width: 66px; height: 66px; border-radius: 50%;
  background: var(--accent); color: #fff; border: none; cursor: pointer;
  display: grid; place-items: center;
  box-shadow: 0 8px 26px rgba(25, 106, 117, .42);
  transition: transform .18s, background .18s;
}
.fab:hover { background: var(--accent-hover); transform: scale(1.06); }
.fab:active { transform: scale(.94); }
.fab svg { width: 30px; height: 30px; stroke: #fff; stroke-width: 2.6; fill: none; }

/* ---------- التنبيه العائم (Toast) ---------- */
.toast {
  position: fixed; bottom: calc(104px + env(safe-area-inset-bottom));
  inset-inline-start: 50%; transform: translateX(50%) translateY(20px);
  background: var(--text); color: #fff; font-size: 17px; font-weight: 700;
  padding: 14px 24px; border-radius: 999px; box-shadow: var(--shadow-lg);
  opacity: 0; pointer-events: none; transition: .3s; z-index: 120;
  max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(50%) translateY(0); }

/* ============================================================
   صفحة الكورس
   ============================================================ */
.back-link {
  display: inline-flex; align-items: center; gap: 9px; min-height: 48px;
  color: var(--text-soft); font-size: 17px; font-weight: 700; margin-bottom: 12px;
}
.back-link svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2.4; }
.back-link:hover { color: var(--accent); }

.course-hero {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow-sm); margin-bottom: 26px;
}
.course-hero-art { aspect-ratio: 16 / 7; position: relative; display: grid; place-items: center; }
.course-hero-art::before {
  content: ''; position: absolute; inset: 0;
  background:
    radial-gradient(circle at 84% 14%, rgba(255,255,255,.55) 0, transparent 44%),
    radial-gradient(circle at 10% 90%, rgba(255,255,255,.35) 0, transparent 48%);
}
.course-hero-art .play-icon {
  width: 76px; height: 76px; border-radius: 50%; background: rgba(255,255,255,.94);
  display: grid; place-items: center; box-shadow: var(--shadow); z-index: 2;
}
.course-hero-art .play-icon svg { width: 30px; height: 30px; fill: var(--text); margin-inline-start: 4px; }
.course-hero-body { padding: 22px 20px 24px; }
.course-hero-body h1 { font-size: 27px; font-weight: 900; line-height: 1.45; margin-bottom: 10px; }
.course-instructor { display: flex; align-items: center; gap: 9px; color: var(--text-soft); font-size: 18px; font-weight: 700; margin-bottom: 12px; }
.course-instructor svg { width: 21px; height: 21px; fill: var(--accent); flex-shrink: 0; }
.course-meta { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; color: var(--text-soft); font-size: 17px; font-weight: 600; }
.meta-cat { color: #fff; font-size: 15px; font-weight: 800; padding: 6px 16px; border-radius: 9px; }
.course-progress-wrap { margin-top: 16px; }
.course-tools { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 18px; }
.cat-select {
  min-height: 52px; padding: 10px 18px; background: var(--surface-2);
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  font-family: inherit; font-size: 17px; font-weight: 700; color: var(--text); cursor: pointer;
}

/* قائمة الدروس */
.lessons-list { display: flex; flex-direction: column; gap: 12px; }
.lesson-row {
  display: flex; align-items: center; gap: 15px;
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); padding: 16px 18px; min-height: 76px;
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.lesson-row:hover { border-color: var(--accent); box-shadow: var(--shadow-sm); }
.lesson-row:active { transform: scale(.985); }
.lesson-num {
  display: grid; place-items: center; min-width: 48px; height: 48px; border-radius: 13px;
  background: var(--accent-soft); color: var(--accent); font-weight: 900; font-size: 18px; flex-shrink: 0;
}
.lesson-row.watched { background: #fdfdfb; }
.lesson-row.watched .lesson-num { background: var(--green); color: #fff; }
.lesson-row.watched .lesson-title { color: var(--text-soft); }
.lesson-title { flex: 1; font-size: 18px; font-weight: 700; line-height: 1.55; }
.lesson-dur { color: var(--text-mute); font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; flex-shrink: 0; }
.lesson-play { flex-shrink: 0; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; background: var(--surface-2); }
.lesson-play svg { width: 20px; height: 20px; fill: var(--text-soft); margin-inline-start: 2px; }
.lesson-row:hover .lesson-play { background: var(--accent-soft); }
.lesson-row:hover .lesson-play svg { fill: var(--accent); }

/* ============================================================
   صفحة المشاهدة
   ============================================================ */
.watch-wrap {
  max-width: 1140px; margin: 0 auto;
  padding: 16px max(16px, env(safe-area-inset-right)) 80px max(16px, env(safe-area-inset-left));
}
.player-shell {
  background: #101216; border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow-lg); position: relative;
}
video { width: 100%; display: block; max-height: 62vh; background: #000; }

/* أدوات المشغل: أزرار كبيرة واضحة */
.player-tools {
  display: flex; flex-direction: column; gap: 10px;
  padding: 12px 12px calc(14px + env(safe-area-inset-bottom) * 0); background: #101216;
}
.pt-row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.pt-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 54px; padding: 10px 18px; flex: 1; min-width: 92px;
  background: rgba(255,255,255,.09); border: 1.5px solid rgba(255,255,255,.14);
  color: #fff; border-radius: var(--radius-sm);
  font-family: inherit; font-size: 17px; font-weight: 800; cursor: pointer; transition: .15s;
}
.pt-btn:hover { background: rgba(255,255,255,.18); }
.pt-btn:active { transform: scale(.96); }
.pt-btn svg { width: 22px; height: 22px; flex-shrink: 0; }
.pt-btn.airplay { background: rgba(43, 136, 148, .3); border-color: rgba(94, 190, 202, .5); }
.pt-btn.airplay:hover { background: rgba(43, 136, 148, .48); }

/* مجموعة أزرار السرعة */
.speed-group {
  display: flex; gap: 6px; background: rgba(255,255,255,.07);
  border: 1.5px solid rgba(255,255,255,.12); border-radius: var(--radius-sm); padding: 5px; flex: 1;
}
.speed-group button {
  flex: 1; min-height: 46px; border: none; background: transparent; color: rgba(255,255,255,.75);
  font-family: inherit; font-size: 16px; font-weight: 800; cursor: pointer;
  border-radius: 9px; transition: .15s; direction: ltr;
}
.speed-group button.active { background: #fff; color: #101216; }

/* شريط عنوان الدرس */
.lesson-bar { display: flex; flex-direction: column; gap: 14px; margin: 20px 0; }
.lesson-bar h1 { font-size: 24px; font-weight: 900; line-height: 1.5; }
.lesson-bar .sub { color: var(--text-soft); font-size: 17px; font-weight: 600; margin-top: 2px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.actions .btn { flex: 1; min-width: 150px; }
.btn.is-watched { color: var(--green); border-color: var(--green); background: var(--green-soft); }

/* أزرار السابق / التالي */
.nav-row { display: flex; gap: 12px; margin: 4px 0 28px; }
.nav-row a {
  flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 56px; padding: 12px;
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); font-weight: 800; font-size: 17px; color: var(--text-soft); transition: .15s;
}
.nav-row a svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2.4; }
.nav-row a:hover { border-color: var(--accent); color: var(--accent); }
.nav-row a.disabled { opacity: .35; pointer-events: none; }

/* قائمة بقية الدروس أسفل المشغل */
.playlist-section {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; margin-bottom: 26px; display: none;
}
.playlist-section.show { display: block; }
.playlist-head { padding: 18px 20px 14px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.playlist-head h2 { font-size: 21px; font-weight: 900; }
.playlist-head .count { font-size: 16px; font-weight: 700; color: var(--text-mute); }
.playlist-body { max-height: 460px; overflow-y: auto; padding: 10px; }
.pl-row {
  display: flex; align-items: center; gap: 13px; padding: 13px 14px; min-height: 64px;
  border-radius: var(--radius-xs); transition: background .13s;
}
.pl-row:hover { background: var(--surface-2); }
.pl-row.current { background: var(--accent-soft); }
.pl-row.current .pl-title { color: var(--accent-ink); font-weight: 800; }
.pl-num {
  display: grid; place-items: center; min-width: 42px; height: 42px; border-radius: 11px;
  background: var(--surface-2); color: var(--text-soft); font-weight: 800; font-size: 16px; flex-shrink: 0;
}
.pl-row.current .pl-num { background: var(--accent); color: #fff; }
.pl-row.watched .pl-num { background: var(--green-soft); color: var(--green); }
.pl-title { flex: 1; font-size: 17px; font-weight: 700; line-height: 1.5; }
.pl-dur { color: var(--text-mute); font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; flex-shrink: 0; }
.pl-check { color: var(--green); font-size: 18px; font-weight: 900; flex-shrink: 0; }

/* النص المصاحب */
.transcript-section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.transcript-head {
  padding: 18px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.transcript-head h2 { font-size: 21px; font-weight: 900; }
.transcript-toggle { display: flex; gap: 6px; background: var(--surface-2); padding: 5px; border-radius: var(--radius-xs); }
.transcript-toggle button {
  min-height: 46px; padding: 8px 18px; border: none; background: transparent;
  font-family: inherit; font-size: 16px; font-weight: 800; color: var(--text-soft);
  cursor: pointer; border-radius: 8px; transition: .13s;
}
.transcript-toggle button.active { background: #fff; color: var(--accent); box-shadow: var(--shadow-sm); }
.transcript-body { max-height: 480px; overflow-y: auto; padding: 10px; }
.t-seg { display: flex; gap: 13px; padding: 13px 15px; border-radius: var(--radius-xs); cursor: pointer; transition: background .12s; }
.t-seg:hover { background: var(--surface-2); }
.t-seg.active { background: var(--accent-soft); }
.t-time { color: var(--accent); font-size: 15px; font-weight: 800; min-width: 52px; padding-top: 3px; font-variant-numeric: tabular-nums; direction: ltr; text-align: right; }
.t-text { flex: 1; }
.t-ar { font-size: 19px; font-weight: 600; line-height: 1.85; }
.t-en { font-size: 15.5px; color: var(--text-mute); direction: ltr; text-align: left; margin-top: 4px; display: none; line-height: 1.6; }
.show-en .t-en { display: block; }
.hide-ar .t-ar { display: none; }

/* ============================================================
   صفحة الدخول
   ============================================================ */
.login-page {
  display: flex; align-items: center; justify-content: center; min-height: 100dvh;
  padding: 24px;
  background:
    radial-gradient(circle at 80% 8%, var(--accent-soft) 0, transparent 45%),
    radial-gradient(circle at 8% 92%, #efe9dd 0, transparent 40%),
    var(--bg);
}
.login-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 28px;
  padding: 48px 34px; width: 100%; max-width: 440px;
  box-shadow: var(--shadow-lg); text-align: center;
}
.login-card .mark {
  display: inline-grid; place-items: center; width: 84px; height: 84px;
  background: linear-gradient(140deg, var(--accent) 0%, #2b8894 100%);
  border-radius: 24px; margin-bottom: 20px; box-shadow: 0 10px 28px rgba(25, 106, 117, .32);
}
.login-card .mark svg { width: 40px; height: 40px; fill: #fff; }
.login-card h1 { font-size: 32px; font-weight: 900; margin-bottom: 2px; }
.login-card h1 b { color: var(--accent); }
.welcome { color: var(--text-soft); margin: 12px 0 28px; font-size: 19px; line-height: 1.8; }
.login-card form { text-align: start; }
.login-card .btn-primary { width: 100%; margin-top: 10px; min-height: 58px; font-size: 20px; }
.err {
  background: var(--danger-soft); color: var(--danger);
  padding: 14px 16px; border-radius: var(--radius-xs); margin-bottom: 18px;
  font-size: 17px; font-weight: 700;
}
.login-foot { color: var(--text-mute); font-size: 15px; margin-top: 26px; }

/* ============================================================
   شاشات أوسع (تابلت وكمبيوتر) — تحسين تدريجي
   ============================================================ */
@media (min-width: 560px) {
  .grid { grid-template-columns: repeat(2, 1fr); }
  .continue-card { flex-basis: 46%; }
  .lib-controls { flex-direction: row; align-items: center; justify-content: space-between; }
  .lib-controls .cats { flex: 1; margin-bottom: 0; padding-bottom: 4px; }
  .modal-overlay { align-items: center; padding: 24px; }
  .modal { border-radius: 26px; animation-name: pop; }
  .modal .grip { display: none; }
  @keyframes pop { from { transform: scale(.94); opacity: 0; } to { transform: scale(1); opacity: 1; } }
  .lesson-bar { flex-direction: row; align-items: flex-start; justify-content: space-between; }
  .actions .btn { flex: 0 1 auto; }
  .pt-row { flex-wrap: nowrap; }
  .pt-btn { flex: 0 1 auto; }
  .speed-group { flex: 0 1 auto; min-width: 280px; }
  .course-hero { display: flex; align-items: stretch; }
  .course-hero-art { flex: 0 0 44%; aspect-ratio: auto; min-height: 240px; }
  .course-hero-body { flex: 1; }
}
@media (min-width: 960px) {
  .grid { grid-template-columns: repeat(3, 1fr); }
  .continue-card { flex-basis: 31%; }
  video { max-height: 68vh; }
}
@media (min-width: 1280px) {
  .grid { grid-template-columns: repeat(4, 1fr); }
}

/* ===== العناوين الإنجليزية الثانوية ===== */
.card-title-en, .lesson-title-en, .sub-en, .course-title-en {
  font-family: -apple-system, 'SF Pro Text', 'Segoe UI', sans-serif;
  color: var(--ink-3, #8a8a86);
  font-size: 15px;
  margin-top: 2px;
  text-align: left;
  direction: ltr;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.course-title-en { font-size: 18px; margin-top: 4px; }
.sub-en { font-size: 16px; margin: 2px 0 4px; white-space: normal; }

/* ===== قائمة تحميل النص ===== */
.dl-menu-wrap { position: relative; }
.dl-menu {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  inset-inline-start: 0;
  background: #fff;
  border: 1px solid var(--line, #e8e6e1);
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0,0,0,.12);
  min-width: 260px;
  z-index: 50;
  padding: 8px;
}
.dl-menu.open { display: block; }
.dl-menu .dl-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-3, #8a8a86);
  padding: 10px 12px 4px;
}
.dl-menu a {
  display: block;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 17px;
  font-weight: 600;
  color: var(--ink, #26251f);
  text-decoration: none;
}
.dl-menu a:active, .dl-menu a:hover { background: var(--wash, #f2f0ea); }

/* صورة الكورس الحقيقية داخل البطاقة */
.card-thumb { position: relative; overflow: hidden; }
.card-thumb-img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
}
.card-thumb .card-cat-tag, .card-thumb .play-icon, .card-thumb .card-duration { position: relative; z-index: 2; }
.card-thumb:has(.card-thumb-img) .card-cat-tag { box-shadow: 0 2px 8px rgba(0,0,0,.3); }
