/* Look of the Arabic library only (design "B: modern and calm"). Every rule is scoped to :root[data-lib="arabic"],
   so the other libraries are untouched. Font: IBM Plex Sans Arabic (SIL Open Font License), served from /static/fonts. */
@font-face { font-family: "Plex Arabic"; font-weight: 400; font-display: swap; src: url(fonts/plex-arabic-arabic-400.woff2) format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF, U+200C-200F; }
@font-face { font-family: "Plex Arabic"; font-weight: 500; font-display: swap; src: url(fonts/plex-arabic-arabic-500.woff2) format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF, U+200C-200F; }
@font-face { font-family: "Plex Arabic"; font-weight: 700; font-display: swap; src: url(fonts/plex-arabic-arabic-700.woff2) format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF, U+200C-200F; }
@font-face { font-family: "Plex Arabic"; font-weight: 400; font-display: swap; src: url(fonts/plex-arabic-latin-400.woff2) format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+2190-21FF; }
@font-face { font-family: "Plex Arabic"; font-weight: 500; font-display: swap; src: url(fonts/plex-arabic-latin-500.woff2) format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+2190-21FF; }
@font-face { font-family: "Plex Arabic"; font-weight: 700; font-display: swap; src: url(fonts/plex-arabic-latin-700.woff2) format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+2190-21FF; }

:root[data-lib="arabic"], :root[data-lib="arabic"] body {
  --bg: #f5f7f8; --bg-2: #eef2f3; --bg-3: #e2e8ea; --panel: #ffffff; --card: #ffffff;
  --text: #14201f; --text-2: #5f6b6a; --line: #e4e9ea;
  --accent: #0f766e; --accent-2: #14b8a6; --accent-ink: #ffffff; --accent-soft: #e6f5f2;
  --sand: #fff6e6; --sand-ink: #8a5a00; --rose: #fdeef0; --rose-ink: #9b2c45;
  --radius: 16px; --shadow: 0 1px 2px rgba(0,0,0,.04), 0 10px 30px -18px rgba(15,60,58,.35);
  --bar: rgba(245,247,248,.9); --solid: #14201f; --on-solid: #ffffff; --hero: #0f766e; --mark: #fff3a3;
  color-scheme: light;
}
/* Dark mode: follows the device unless the student picked light or dark (data-theme on <html>). */
:root[data-lib="arabic"][data-theme="dark"], :root[data-lib="arabic"][data-theme="dark"] body {
  --bg: #0e1615; --bg-2: #15201f; --bg-3: #1f2c2b; --panel: #15201f; --card: #15201f;
  --text: #e6efed; --text-2: #9db0ad; --line: #24332f;
  --accent: #2dd4bf; --accent-2: #2dd4bf; --accent-ink: #062b27; --accent-soft: #10302c;
  --sand: #2c2414; --sand-ink: #f2c46d; --rose: #33171e; --rose-ink: #f39bb0;
  --bar: rgba(14,22,21,.88); --solid: #2dd4bf; --on-solid: #062b27; --hero: #0f5f58; --mark: #5b4d00;
  --good: #5fd08a; --good-soft: #10301d; --ever: #b9a4ff; --ever-soft: #251d40; --warn: #ffbf5a; --warn-soft: #3a2a0c;
    --shadow: none; color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root[data-lib="arabic"]:not([data-theme="light"]), :root[data-lib="arabic"]:not([data-theme="light"]) body {
    --bg: #0e1615; --bg-2: #15201f; --bg-3: #1f2c2b; --panel: #15201f; --card: #15201f;
    --text: #e6efed; --text-2: #9db0ad; --line: #24332f;
    --accent: #2dd4bf; --accent-2: #2dd4bf; --accent-ink: #062b27; --accent-soft: #10302c;
    --sand: #2c2414; --sand-ink: #f2c46d; --rose: #33171e; --rose-ink: #f39bb0;
    --bar: rgba(14,22,21,.88); --solid: #2dd4bf; --on-solid: #062b27; --hero: #0f5f58; --mark: #5b4d00;
    --good: #5fd08a; --good-soft: #10301d; --ever: #b9a4ff; --ever-soft: #251d40; --warn: #ffbf5a; --warn-soft: #3a2a0c;
    --shadow: none; color-scheme: dark;
  }
}
:root[data-lib="arabic"] body { background: var(--bg); color: var(--text); font: 15.5px/1.7 "Plex Arabic", "Segoe UI", Tahoma, sans-serif; }
:root[data-lib="arabic"] button, :root[data-lib="arabic"] input, :root[data-lib="arabic"] select { font-family: inherit; }

/* Top bar: logo, name with the dedication under it, search */
:root[data-lib="arabic"] .topbar { height: 72px; background: var(--bar); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid transparent; gap: 14px; padding: 0 24px; }
:root[data-lib="arabic"] .brand { gap: 12px; }
:root[data-lib="arabic"] .brand-mark { width: 42px; height: 42px; border-radius: 13px; background: var(--accent); color: #fff; font: 700 23px/1 "Plex Arabic", sans-serif; }
:root[data-lib="arabic"] .brand-text { display: flex; flex-direction: column; min-width: 0; }
:root[data-lib="arabic"] .brand-name { font-size: 17px; font-weight: 700; letter-spacing: 0; line-height: 1.35; }
:root[data-lib="arabic"] .brand-name b { font-weight: 700; }
.brand-sub { font-size: 14px; font-weight: 500; color: var(--accent); margin-inline-start: 6px; }
.brand-sub i { font-style: normal; color: var(--text-2); font-weight: 400; margin-inline-end: 2px; }
:root[data-lib="arabic"] .brand-tag { font-size: 12.5px; color: var(--text-2); line-height: 1.5; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
:root[data-lib="arabic"] .search { max-width: 520px; margin-inline-start: auto; margin-inline-end: 0; }
:root[data-lib="arabic"] .search input { height: 44px; border: 1px solid var(--line); border-left: 0; border-radius: 0 14px 14px 0; background: var(--card); font-size: 14.5px; }
:root[data-lib="arabic"] .search input:focus { border-color: var(--accent-2); }
:root[data-lib="arabic"] .search button { width: 54px; border: 1px solid var(--line); border-right: 0; border-radius: 14px 0 0 14px; background: var(--card); color: var(--accent); }
:root[data-lib="arabic"] .icon-btn:hover { background: var(--bg-3); }
:root[data-lib="arabic"] .sidebar { top: 72px; height: calc(100vh - 72px); background: var(--bg); border-left: 1px solid var(--line); }
:root[data-lib="arabic"] .sidebar a { border-radius: 12px; }
:root[data-lib="arabic"] .sidebar a.active, :root[data-lib="arabic"] .sidebar a:hover { background: var(--accent-soft); color: var(--accent); }
:root[data-lib="arabic"] main { padding: 8px 28px 70px; max-width: 1280px; margin: 0 auto; }

/* Home: welcome card + the three levels */
.ar-hero { display: grid; grid-template-columns: 1.25fr 1fr; gap: 20px; margin: 12px 0 34px; }
.ar-welcome { background: var(--hero); color: #fff; border-radius: 28px; padding: 38px 40px 32px; position: relative; overflow: hidden; }
.ar-welcome::after { content: "ض"; position: absolute; left: -6px; bottom: -78px; font: 700 260px/1 "Plex Arabic", sans-serif; color: rgba(255,255,255,.08); pointer-events: none; }
.ar-welcome h1 { font-size: 36px; line-height: 1.35; margin: 0 0 10px; }
.ar-welcome p { opacity: .88; margin: 0 0 22px; max-width: 470px; }
.ar-search { display: flex; background: var(--card); border-radius: 16px; padding: 6px; max-width: 540px; position: relative; z-index: 1; }
.ar-search input { flex: 1; min-width: 0; border: 0; background: none; font: inherit; color: var(--text); padding: 0 14px; outline: 0; }
.ar-search button { border: 0; background: var(--solid); color: var(--on-solid); font: 500 15px "Plex Arabic", sans-serif; padding: 11px 22px; border-radius: 12px; cursor: pointer; }
.ar-pills { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; position: relative; z-index: 1; }
.ar-pills span { background: rgba(255,255,255,.15); padding: 3px 12px; border-radius: 999px; font-size: 13px; }
.ar-install { margin-top: 14px; position: relative; z-index: 1; display: inline-flex; align-items: center; gap: 8px; background: var(--card); color: var(--accent); border: 0; border-radius: 12px; padding: 8px 16px; font: 500 14px "Plex Arabic", sans-serif; cursor: pointer; }
.ar-ios-tip { margin-top: 12px; font-size: 13px; opacity: .9; position: relative; z-index: 1; }
.ar-levels { display: grid; gap: 12px; align-content: start; }
.ar-level { display: flex; align-items: center; gap: 16px; background: var(--card); border: 1px solid var(--line); border-radius: 22px; padding: 16px 20px; transition: transform .2s, border-color .2s; }
.ar-level:hover { transform: translateX(-4px); border-color: var(--accent-2); }
.ar-level.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.ar-level .ic { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; flex: none; }
.ar-level .ic svg { width: 26px; height: 26px; }
.ar-level .ic.ba { background: var(--accent-soft); color: var(--accent); }
.ar-level .ic.ma { background: var(--sand); color: var(--sand-ink); }
.ar-level .ic.phd { background: var(--rose); color: var(--rose-ink); }
.ar-level h3 { margin: 0; font-size: 18px; }
.ar-level small { color: var(--text-2); font-size: 13px; }
.ar-level .go { margin-inline-start: auto; color: var(--text-2); font-size: 20px; }

.ar-sec { display: flex; align-items: center; gap: 10px; margin: 6px 0 16px; flex-wrap: wrap; }
.ar-sec h2 { font-size: 22px; margin: 0; }
.ar-pill { background: var(--accent-soft); color: var(--accent); font-size: 13px; padding: 2px 11px; border-radius: 999px; font-weight: 500; }
.ar-sec .more { margin-inline-start: auto; color: var(--accent); font-weight: 500; font-size: 14px; }

.ar-courses { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.ar-course { display: block; background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 18px; transition: box-shadow .2s, border-color .2s, transform .2s; }
.ar-course:hover { box-shadow: 0 18px 40px -22px rgba(15,118,110,.5); border-color: transparent; transform: translateY(-2px); }
.ar-course .top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.ar-course h3 { margin: 0; font-size: 16.5px; line-height: 1.45; }
.ar-course .n { font-size: 12.5px; color: var(--accent); font-weight: 700; white-space: nowrap; }
.ar-course p { margin: 0 0 12px; color: var(--text-2); font-size: 13.5px; line-height: 1.65; height: 44px; overflow: hidden; }
.ar-meter { height: 6px; border-radius: 9px; background: var(--accent-soft); overflow: hidden; }
.ar-meter i { display: block; height: 100%; background: var(--accent-2); border-radius: 9px; }

/* Course page header */
.ar-course-head { background: var(--card); border: 1px solid var(--line); border-radius: 24px; padding: 22px 26px; margin: 10px 0 18px; }
.ar-crumb { font-size: 13.5px; color: var(--text-2); margin-bottom: 6px; }
.ar-crumb a { color: var(--accent); font-weight: 500; }
.ar-course-head h1 { font-size: 26px; margin: 0 0 4px; }
.ar-course-head .code { color: var(--text-2); font-size: 13px; margin-bottom: 10px; }
.ar-course-head p { margin: 0; color: var(--text-2); font-size: 14.5px; line-height: 1.85; }

:root[data-lib="arabic"] .chips { gap: 8px; }
:root[data-lib="arabic"] .chip { border-radius: 999px; background: var(--card); border: 1px solid var(--line); padding: 6px 14px; font-weight: 500; }
:root[data-lib="arabic"] .chip:hover { border-color: var(--accent-2); background: var(--card); }
:root[data-lib="arabic"] .chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
:root[data-lib="arabic"] .filters select { border-radius: 10px; background: var(--card); }

/* Lecture cards */
:root[data-lib="arabic"] .grid { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; }
.ar-card { display: block; background: var(--card); border: 1px solid var(--line); border-radius: 20px; overflow: hidden; min-width: 0; transition: transform .2s, box-shadow .2s; }
.ar-card:hover { transform: translateY(-4px); box-shadow: 0 20px 40px -24px rgba(0,0,0,.35); }
.ar-card .thumb { border-radius: 0; }
.ar-card:hover .thumb img { transform: none; }
.ar-step { position: absolute; top: 10px; right: 10px; background: var(--card); color: var(--accent); font-weight: 700; font-size: 12.5px; padding: 2px 10px; border-radius: 999px; box-shadow: 0 1px 4px rgba(0,0,0,.2); }
:root[data-lib="arabic"] .ar-card .dur { left: 10px; bottom: 10px; right: auto; border-radius: 8px; padding: 1px 8px; }
.ar-card .b { padding: 12px 14px 14px; }
.ar-card .title { font-size: 14.5px; font-weight: 500; line-height: 1.6; }
.ar-card .ch { font-size: 12.5px; color: var(--text-2); margin-top: 4px; display: flex; align-items: center; gap: 3px; }
.ar-card .ch .verified svg { width: 14px; height: 14px; }
.ar-card .m { display: flex; gap: 12px; font-size: 12px; color: var(--text-2); margin-top: 6px; }
.ar-card .m svg { width: 14px; height: 14px; vertical-align: -2px; margin-inline-end: 3px; }

/* Watch, search and channel pages */
:root[data-lib="arabic"] .player { border-radius: 20px; }
:root[data-lib="arabic"] .box, :root[data-lib="arabic"] .panel, :root[data-lib="arabic"] .moment, :root[data-lib="arabic"] .cardbox { background: var(--card); border: 1px solid var(--line); border-radius: 20px; }
:root[data-lib="arabic"] .tabs button.on { color: var(--accent); border-bottom-color: var(--accent); }
:root[data-lib="arabic"] .btn { border-radius: 12px; background: var(--card); }
:root[data-lib="arabic"] .btn:hover { border-color: var(--accent-2); background: var(--card); }
:root[data-lib="arabic"] .badge { border-radius: 999px; padding: 2px 9px; }

/* Progress, buttons, watched badge, lesson navigation */
.ar-prog { display: flex; align-items: center; gap: 12px; margin-top: 14px; font-size: 13px; color: var(--text-2); }
.ar-prog .ar-meter { flex: 1; max-width: 320px; }
.ar-course.started .ar-prog { margin-top: 0; }
.ar-course.started .ar-prog span { color: var(--accent); font-weight: 500; white-space: nowrap; }
.ar-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.ar-btn { display: inline-flex; align-items: center; gap: 6px; height: 38px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--text); font: 500 14px "Plex Arabic", sans-serif; cursor: pointer; white-space: nowrap; }
.ar-btn svg { width: 17px; height: 17px; }
.ar-btn:hover { border-color: var(--accent-2); }
.ar-btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.ar-btn.on { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.ar-watchbar { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.ar-lesson { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 14px; padding: 12px 14px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; font-size: 14px; }
.ar-lesson > a:first-child { color: var(--text-2); }
.ar-lesson > a:first-child b { color: var(--accent); }
.ar-lesson .sp { flex: 1; }
.ar-seen { position: absolute; bottom: 10px; right: 10px; display: inline-flex; align-items: center; gap: 4px; background: var(--accent); color: var(--accent-ink); font-size: 12px; font-weight: 500; padding: 1px 9px 1px 8px; border-radius: 999px; }
.ar-seen svg { width: 14px; height: 14px; }
.ar-card.seen .thumb img { opacity: .72; }
.theme-btn { flex: none; color: var(--text-2); }
:root[data-lib="arabic"] mark { background: var(--mark); }
/* Pull-to-refresh circle (installed app only) */
.ptr { position: fixed; top: calc(-44px + env(safe-area-inset-top)); left: 50%; z-index: 60; width: 40px; height: 40px; border-radius: 50%; background: var(--card); color: var(--text-2); box-shadow: 0 4px 16px rgba(0,0,0,.18); display: grid; place-items: center; transform: translate(-50%, 0); opacity: 0; transition: opacity .15s; pointer-events: none; }
.ptr.show { opacity: 1; }
.ptr.ready { color: var(--accent); }
.ptr.spin svg { animation: ptr-spin .8s linear infinite; }
@keyframes ptr-spin { to { transform: rotate(360deg); } }

.ar-foot { margin-top: 56px; padding-top: 22px; border-top: 1px solid var(--line); text-align: center; color: var(--text-2); font-size: 13.5px; }
.ar-foot .dua { color: var(--accent); font-weight: 500; margin-bottom: 4px; }
.ar-foot .ar-index { margin-top: 8px; }
.ar-foot .ar-index a { color: var(--accent); font-weight: 500; }

/* Bottom navigation (phones only) */
.bnav { display: none; }
@media (max-width: 800px) {
  :root[data-lib="arabic"] .topbar { height: auto; flex-wrap: wrap; padding: 10px 14px; gap: 8px 10px; }
  :root[data-lib="arabic"] #menuBtn { display: none; }
  :root[data-lib="arabic"] .brand { flex: 1; min-width: 0; white-space: normal; align-items: flex-start; }
  :root[data-lib="arabic"] .brand-name { display: block; font-size: 16px; }
  :root[data-lib="arabic"] .brand-tag { font-size: 12px; white-space: normal; }
  .theme-btn { margin-inline-start: auto; }
  .ar-lesson .sp { flex-basis: 100%; height: 0; }
  .brand-sub { display: block; margin: 0; font-size: 12.5px; line-height: 1.5; }
  .brand-sub i { display: none; }
  :root[data-lib="arabic"] .brand-mark { width: 38px; height: 38px; font-size: 21px; border-radius: 12px; }
  :root[data-lib="arabic"] .topbar .search { order: 3; flex-basis: 100%; max-width: none; display: none; }
  :root[data-lib="arabic"] body.search-open .topbar .search { display: flex; }
  :root[data-lib="arabic"] .sidebar { position: fixed; top: 0; bottom: 0; right: 0; left: auto; height: auto; width: min(86vw, 340px); z-index: 40; padding-bottom: 90px; box-shadow: -10px 0 40px rgba(0,0,0,.18); }
  :root[data-lib="arabic"] main { padding: 6px 16px 96px; }
  .ar-hero { grid-template-columns: 1fr; margin-top: 4px; gap: 12px; }
  .ar-welcome { padding: 26px 22px 24px; border-radius: 22px; }
  .ar-welcome h1 { font-size: 26px; }
  .ar-search button { padding: 10px 16px; }
  .ar-level { padding: 13px 16px; border-radius: 18px; }
  .ar-level .ic { width: 44px; height: 44px; }
  .ar-courses { grid-template-columns: 1fr 1fr; gap: 10px; }
  .ar-course { padding: 14px; border-radius: 16px; }
  .ar-course h3 { font-size: 15px; }
  .ar-course p { display: none; }
  .ar-course-head { padding: 18px; border-radius: 20px; }
  .ar-course-head h1 { font-size: 22px; }
  :root[data-lib="arabic"] .grid { grid-template-columns: 1fr; gap: 14px; }
  :root[data-lib="arabic"] .bnav { display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 45; justify-content: space-around; background: var(--card); border-top: 1px solid var(--line); padding: 6px 0 calc(6px + env(safe-area-inset-bottom)); }
  .bnav a, .bnav button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 12px; color: var(--text-2); background: none; border: 0; padding: 4px 0; cursor: pointer; }
  .bnav svg { width: 22px; height: 22px; }
  .bnav .on { color: var(--accent); }
  :root[data-lib="arabic"] .toast { bottom: 84px; }
}
@media (max-width: 380px) { .ar-courses { grid-template-columns: 1fr; } }
