/* ==========================================================================
   مكتبة العالم | WORLD LIBRARY
   هوية بصرية مستقلة — كل الأصناف تبدأ بـ wl-
   ========================================================================== */

.wl-root {
  /* ---- لوحة ألوان هادئة على العين ---- */
  --wl-bg: #0c152c;
  --wl-bg-2: #121c38;
  --wl-panel: rgba(30, 44, 80, 0.78);
  --wl-panel-2: rgba(38, 54, 96, 0.80);
  --wl-panel-solid: #1a2748;
  --wl-line: rgba(160, 184, 232, 0.16);
  --wl-line-2: rgba(138, 109, 255, 0.26);
  --wl-gold: #e9c98b;
  --wl-gold-soft: rgba(233, 201, 139, 0.14);
  --wl-blue: #7a95ff;
  --wl-cyan: #7ddbff;
  --wl-purple: #9880ff;
  --wl-text: #f1f4fc;
  --wl-dim: #b4c0d8;
  --wl-faint: #8796b5;
  --wl-danger: #f77289;

  --wl-r-lg: 18px;
  --wl-r-md: 14px;
  --wl-r-sm: 11px;
  --wl-sidebar-w: 244px;
  --wl-pad: 22px;

  --wl-shadow: 0 14px 34px rgba(2, 6, 16, 0.5);
  --wl-glow-blue: 0 0 34px rgba(106, 135, 255, 0.16);
  --wl-glow-purple: 0 0 34px rgba(138, 109, 255, 0.16);

  position: fixed;
  inset: 0;
  /* فوق مودال الميزات (9999) والأومنيبوكس (11000) والطبقات الجذرية (12000) */
  z-index: 12400;
  display: none;
  direction: rtl;
  background:
    radial-gradient(1100px 620px at 78% -10%, rgba(106, 135, 255, 0.16), transparent 68%),
    radial-gradient(900px 540px at 14% 0%, rgba(138, 109, 255, 0.14), transparent 70%),
    linear-gradient(180deg, #121c36 0%, var(--wl-bg) 42%, #0a1326 100%);
  color: var(--wl-text);
  font-family: 'IBM Plex Sans Arabic', 'Cairo', 'Tajawal', system-ui, -apple-system, sans-serif;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

.wl-root.is-open { display: block; }

/* أثناء الكتابة على الموبايل: لا ترسم المشهد الثقيل خلف الحقل */
@media (max-width: 767px), (orientation: landscape) and (max-height: 540px) {
  .wl-root.wl-kb-open {
    position: absolute;
    height: 100%;
    min-height: 100dvh;
  }
  .wl-root.wl-kb-open .wl-hero-scene,
  .wl-root.wl-kb-open .wl-sky { display: none; }
  .wl-root.wl-kb-open .wl-hero {
    min-height: 0;
    background: var(--wl-bg);
  }
  .wl-root.wl-kb-open .wl-mobile-head {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
}

.wl-root *, .wl-root *::before, .wl-root *::after { box-sizing: border-box; }

.wl-root button {
  font-family: inherit;
  color: inherit;
  cursor: pointer;
  border: 0;
  background: none;
}

.wl-root :focus-visible {
  outline: 2px solid rgba(106, 135, 255, 0.7);
  outline-offset: 2px;
}

body.wl-locked { overflow: hidden; }

/* لا يظهر أي عنصر من المنصة فوق مكتبة العالم */
body.wl-locked .bahthy-pwa-install-banner,
body.wl-locked .floating-copilot,
body.wl-locked #modal,
body.wl-locked #modal.modal { display: none !important; }

/* قارئ الكتب والتنبيهات يبقيان فوق مكتبة العالم */
body.wl-locked .pdf-viewer-overlay { z-index: 12600 !important; }
body.wl-locked .toast { z-index: 12800 !important; }
body.wl-locked .source-text-extract-overlay { z-index: 12700 !important; }
body.wl-locked .points-confirm-overlay { z-index: 12900 !important; }

.wl-ic { width: 18px; height: 18px; flex: 0 0 auto; }

/* شعار المنصة */
.wl-logo {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  flex: 0 0 auto;
  border-radius: 16px;
  border: 1px solid var(--wl-gold-soft);
  background: radial-gradient(circle at 32% 26%, rgba(233, 201, 139, 0.16), rgba(138, 109, 255, 0.08));
  box-shadow: 0 0 22px rgba(233, 201, 139, 0.12);
}

.wl-logo img { width: 34px; height: 34px; object-fit: contain; display: block; }
.wl-logo--sm { width: 34px; height: 34px; border-radius: 11px; }
.wl-logo--sm img { width: 22px; height: 22px; }

/* ---------------------------------------------------------------- السماء */
.wl-sky { position: absolute; inset: 0; pointer-events: none; }

.wl-sky::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(1.2px 1.2px at 12% 18%, rgba(255,255,255,.34) 50%, transparent 51%),
    radial-gradient(1px 1px at 27% 62%, rgba(255,255,255,.24) 50%, transparent 51%),
    radial-gradient(1.4px 1.4px at 44% 12%, rgba(233,201,139,.30) 50%, transparent 51%),
    radial-gradient(1px 1px at 61% 74%, rgba(255,255,255,.20) 50%, transparent 51%),
    radial-gradient(1.3px 1.3px at 78% 30%, rgba(138,109,255,.34) 50%, transparent 51%),
    radial-gradient(1px 1px at 88% 66%, rgba(255,255,255,.22) 50%, transparent 51%);
  background-size: 520px 520px;
  opacity: .6;
}

/* ---------------------------------------------------------------- الهيكل */
.wl-shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr var(--wl-sidebar-w);
  height: 100%;
  min-height: 100%;
}

/* شريط التمرير العمودي ظاهر في المحتوى والقائمة — القضبان الأفقية للرفوف مخفية */
.wl-rail {
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.wl-rail::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

.wl-main,
.wl-sidebar {
  scrollbar-width: thin;
  scrollbar-color: rgba(233, 201, 139, 0.5) rgba(255, 255, 255, 0.05);
}

.wl-main::-webkit-scrollbar,
.wl-sidebar::-webkit-scrollbar {
  width: 10px;
}

.wl-main::-webkit-scrollbar-track,
.wl-sidebar::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.04);
  border-radius: 999px;
}

.wl-main::-webkit-scrollbar-thumb,
.wl-sidebar::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, rgba(233, 201, 139, 0.72), rgba(233, 201, 139, 0.38));
  border: 2px solid rgba(6, 11, 26, 0.6);
  border-radius: 999px;
}

.wl-main::-webkit-scrollbar-thumb:hover,
.wl-sidebar::-webkit-scrollbar-thumb:hover {
  background: rgba(233, 201, 139, 0.85);
}

/* ============================ 1) القائمة الجانبية ======================== */
.wl-sidebar {
  grid-column: 2;
  grid-row: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px 13px calc(16px + env(safe-area-inset-bottom, 0px));
  border-inline-start: 1px solid var(--wl-line);
  background: linear-gradient(180deg, rgba(18, 28, 52, 0.92), rgba(12, 21, 44, 0.96));
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.wl-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 6px 0 16px;
  border-bottom: 1px solid var(--wl-line);
  text-align: center;
}

.wl-brand-txt { display: flex; flex-direction: column; gap: 3px; }

.wl-brand-title {
  font-size: 1.02rem;
  font-weight: 800;
  color: var(--wl-gold);
  letter-spacing: .005em;
}

.wl-brand-sub {
  font-size: .54rem;
  font-weight: 700;
  letter-spacing: .3em;
  color: var(--wl-faint);
  direction: ltr;
}

.wl-nav { display: flex; flex-direction: column; gap: 3px; }

.wl-nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--wl-r-sm);
  color: var(--wl-dim);
  font-size: .855rem;
  font-weight: 600;
  text-align: right;
  transition: background .18s ease, color .18s ease;
}

.wl-nav-item:hover { background: rgba(138, 109, 255, .1); color: var(--wl-text); }

.wl-nav-item.is-active {
  background: linear-gradient(90deg, rgba(138, 109, 255, .3), rgba(106, 135, 255, .12));
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(138, 109, 255, .26);
}

.wl-nav-item.is-active .wl-ic { color: var(--wl-gold); }
.wl-nav-item span { flex: 1 1 auto; min-width: 0; }

.wl-nav-badge {
  padding: 1px 6px;
  border-radius: 6px;
  background: linear-gradient(135deg, var(--wl-purple), var(--wl-blue));
  color: #fff;
  font-size: .54rem;
  font-weight: 800;
  font-style: normal;
  letter-spacing: .06em;
}

/* بطاقة مساعد المعرفة */
.wl-ai-card {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 13px 12px;
  border: 1px solid rgba(138, 109, 255, .3);
  border-radius: var(--wl-r-md);
  background:
    radial-gradient(130% 110% at 88% 0%, rgba(138, 109, 255, .26), transparent 68%),
    linear-gradient(180deg, rgba(21, 27, 58, .94), rgba(9, 14, 32, .94));
  box-shadow: var(--wl-glow-purple);
  cursor: pointer;
  text-align: right;
  transition: border-color .18s ease, transform .18s ease;
}

.wl-ai-card:hover { border-color: rgba(138, 109, 255, .55); transform: translateY(-2px); }

.wl-ai-card-art { flex: 0 0 auto; }
.wl-robot--sm { width: 48px; height: 48px; }

.wl-ai-card-txt { display: flex; flex-direction: column; gap: 3px; min-width: 0; }

.wl-ai-card-badge {
  align-self: flex-start;
  padding: 1px 7px;
  border-radius: 6px;
  background: linear-gradient(135deg, var(--wl-purple), var(--wl-blue));
  font-size: .52rem;
  font-weight: 800;
  font-style: normal;
  letter-spacing: .12em;
}

.wl-ai-card-txt strong { font-size: .79rem; color: var(--wl-gold); font-weight: 700; }
.wl-ai-card-txt span { font-size: .65rem; color: var(--wl-dim); }
.wl-ai-card-link { color: var(--wl-blue) !important; font-weight: 700; }

/* ============================ 2) المحتوى =============================== */
.wl-main {
  grid-column: 1;
  grid-row: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.wl-topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px var(--wl-pad);
  background: rgba(6, 11, 26, .82);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--wl-line);
}

.wl-topbar-search {
  position: relative;
  flex: 1 1 auto;
  max-width: 580px;
  margin: 0 auto;
}

.wl-topbar-search input {
  width: 100%;
  padding: 10px 42px 10px 16px;
  border: 1px solid var(--wl-line);
  border-radius: 999px;
  background: rgba(255, 255, 255, .04);
  color: var(--wl-text);
  font-family: inherit;
  font-size: 16px;
  -webkit-appearance: none;
  appearance: none;
}

.wl-topbar-search input::placeholder { color: var(--wl-faint); }

.wl-topbar-search input:focus {
  outline: none;
  border-color: rgba(106, 135, 255, .5);
  box-shadow: 0 0 0 3px rgba(106, 135, 255, .1);
}

.wl-topbar-search-ico {
  position: absolute;
  inset-inline-start: 15px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--wl-faint);
  pointer-events: none;
  display: flex;
}

.wl-topbar-actions { display: flex; align-items: center; gap: 8px; }

.wl-icon-btn {
  position: relative;
  display: grid;
  place-items: center;
  width: 37px;
  height: 37px;
  flex: 0 0 auto;
  border: 1px solid var(--wl-line);
  border-radius: 12px;
  background: rgba(255, 255, 255, .035);
  color: var(--wl-dim);
  transition: color .18s ease, border-color .18s ease, background .18s ease;
}

.wl-icon-btn:hover {
  color: #fff;
  border-color: rgba(138, 109, 255, .42);
  background: rgba(138, 109, 255, .1);
}

.wl-icon-btn--ghost { border-color: transparent; background: none; }

/* زر الرجوع للمنصة — واضح ومميّز */
.wl-back {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex: 0 0 auto;
  padding: 9px 15px 9px 13px;
  border: 1px solid rgba(233, 201, 139, .42);
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(233, 201, 139, .18), rgba(138, 109, 255, .12));
  color: var(--wl-gold);
  font-size: .78rem;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: 0 4px 16px rgba(233, 201, 139, .12);
  transition: background .18s ease, border-color .18s ease, transform .18s ease;
}

.wl-back:hover {
  background: linear-gradient(135deg, rgba(233, 201, 139, .3), rgba(138, 109, 255, .2));
  border-color: rgba(233, 201, 139, .7);
  transform: translateX(3px);
}

.wl-back .wl-ic { width: 17px; height: 17px; stroke-width: 2; }

.wl-back--sm { padding: 7px 12px 7px 10px; font-size: .7rem; gap: 5px; }
.wl-back--sm .wl-ic { width: 15px; height: 15px; }

.wl-has-dot::after {
  content: '';
  position: absolute;
  top: 7px;
  inset-inline-end: 8px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--wl-danger);
  box-shadow: 0 0 0 2px #121c38;
}

.wl-avatar {
  display: grid;
  place-items: center;
  width: 37px;
  height: 37px;
  border-radius: 50%;
  border: 1px solid rgba(233, 201, 139, .34);
  background: radial-gradient(circle at 30% 25%, rgba(233, 201, 139, .24), rgba(138, 109, 255, .14));
  color: var(--wl-gold);
}

/* رأس الموبايل */
.wl-mobile-head {
  display: none;
  position: sticky;
  top: 0;
  z-index: 6;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: calc(max(12px, env(safe-area-inset-top, 0px)) + 6px) 14px 9px;
  background: rgba(6, 11, 26, .93);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--wl-line);
}

.wl-mobile-brand { display: flex; align-items: center; gap: 8px; min-width: 0; }
.wl-mobile-brand span { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.wl-mobile-brand strong { font-size: .82rem; color: var(--wl-gold); font-weight: 800; }
.wl-mobile-brand small { font-size: .44rem; letter-spacing: .24em; color: var(--wl-faint); direction: ltr; }

/* ============================ 3) Hero ================================== */
.wl-hero {
  position: relative;
  display: flex;
  align-items: flex-end;
  min-height: clamp(268px, 33vh, 380px);
  padding: 0 var(--wl-pad) 18px;
  overflow: hidden;
  text-align: center;
  border-bottom: 1px solid var(--wl-line);
}

.wl-hero-scene { position: absolute; inset: 0; pointer-events: none; }

/* صورة المشهد: قاعة مكتبة برفوف على الجهتين وكوكب في المنتصف */
.wl-hero-pic { position: absolute; inset: 0; display: block; }

.wl-hero-pic img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 14%;
  display: block;
}

/* البديل البرمجي — يظهر فقط إذا فشل تحميل الصورة */
.wl-hero-fallback { display: none; position: absolute; inset: 0; }
.wl-hero-scene.is-fallback .wl-hero-pic { display: none; }
.wl-hero-scene.is-fallback .wl-hero-fallback { display: block; }

/* رفوف كتب بمنظور على الجهتين */
.wl-shelf {
  position: absolute;
  top: -10%;
  width: 40%;
  height: 120%;
  background:
    repeating-linear-gradient(90deg,
      rgba(233, 201, 139, .22) 0 5px,
      rgba(150, 108, 60, .15) 5px 9px,
      rgba(8, 13, 28, .96) 9px 13px),
    repeating-linear-gradient(180deg,
      rgba(0, 0, 0, .92) 0 30px,
      rgba(233, 201, 139, .12) 30px 34px);
  opacity: .7;
}

.wl-shelf--r {
  inset-inline-start: -3%;
  transform: perspective(600px) rotateY(-29deg);
  transform-origin: right center;
  mask-image: linear-gradient(to left, #000 6%, transparent 88%);
  -webkit-mask-image: linear-gradient(to left, #000 6%, transparent 88%);
}

.wl-shelf--l {
  inset-inline-end: -3%;
  transform: perspective(600px) rotateY(29deg);
  transform-origin: left center;
  mask-image: linear-gradient(to right, #000 6%, transparent 88%);
  -webkit-mask-image: linear-gradient(to right, #000 6%, transparent 88%);
}

/* الكرة الأرضية — تظهر كاملة دائماً */
.wl-hero-globe {
  position: absolute;
  top: clamp(4px, 1.2vh, 16px);
  left: 50%;
  transform: translateX(-50%);
  width: min(32vw, 33vh, 300px);
}

.wl-globe-svg { width: 100%; height: auto; display: block; }

.wl-hero-fade {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(58% 46% at 50% 62%, rgba(12, 21, 44, .48), rgba(12, 21, 44, 0) 74%),
    linear-gradient(180deg,
      rgba(12, 21, 44, .18) 0%,
      rgba(12, 21, 44, .08) 30%,
      rgba(12, 21, 44, .50) 74%,
      var(--wl-bg) 100%);
}

.wl-hero-inner {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 740px;
  margin: 0 auto;
  padding-top: min(23vh, 158px);
}

.wl-hero-title {
  margin: 0;
  font-size: clamp(1.6rem, 3.7vw, 2.5rem);
  font-weight: 900;
  line-height: 1.15;
  color: #fff;
  text-shadow:
    0 2px 8px rgba(2, 5, 14, .9),
    0 6px 34px rgba(2, 5, 14, .8),
    0 0 46px rgba(233, 201, 139, .22);
}

.wl-hero-tagline {
  margin: 7px 0 8px;
  font-size: clamp(.9rem, 1.9vw, 1.14rem);
  font-weight: 700;
  color: #e6ecff;
  text-shadow: 0 2px 12px rgba(2, 5, 14, .9);
}

.wl-hero-desc {
  margin: 0 auto;
  max-width: 540px;
  font-size: clamp(.74rem, 1.2vw, .82rem);
  line-height: 1.75;
  color: #b9c4e0;
  text-shadow: 0 2px 10px rgba(2, 5, 14, .9);
}

.wl-hero-search {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  max-width: 580px;
  margin: 14px auto 0;
  padding: 6px 6px 6px 18px;
  border: 1px solid rgba(138, 109, 255, .3);
  border-radius: 999px;
  background: rgba(8, 14, 32, .96);
  box-shadow: 0 10px 34px rgba(2, 6, 16, .5), var(--wl-glow-blue);
  isolation: isolate;
  contain: layout style;
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
}

.wl-hero-search--inline { margin: 0 0 16px; max-width: 100%; }
.wl-hero-search:focus-within { border-color: rgba(138, 109, 255, .62); }

.wl-hero-search input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 10px 4px;
  border: 0;
  background: transparent;
  color: var(--wl-text);
  font-family: inherit;
  font-size: 16px;
  line-height: 1.4;
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
  -webkit-appearance: none;
  appearance: none;
}

.wl-hero-search input:focus { outline: none; }
.wl-hero-search input::placeholder { color: var(--wl-faint); }

.wl-hero-search-btn {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 13px;
  background: linear-gradient(135deg, var(--wl-purple), var(--wl-blue));
  color: #fff;
  box-shadow: 0 8px 20px rgba(106, 135, 255, .32);
  transition: filter .18s ease;
}

.wl-hero-search-btn:hover { filter: brightness(1.08); }
.wl-hero-search-btn:disabled { opacity: .6; cursor: progress; }

/* أدوات البحث */
.wl-tools {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  margin: 12px auto 0;
  max-width: 640px;
}

.wl-tools::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: min(600px, 96%);
  height: 190px;
  transform: translate(-50%, -46%);
  border: 1px solid rgba(233, 201, 139, .13);
  border-radius: 50%;
  pointer-events: none;
}

.wl-tool {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 13px;
  border-radius: 999px;
  color: var(--wl-dim);
  font-size: .76rem;
  font-weight: 600;
  transition: color .18s ease;
}

.wl-tool-ico {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--wl-line);
  background: rgba(255, 255, 255, .045);
  transition: border-color .18s ease, background .18s ease, color .18s ease;
}

.wl-tool:hover, .wl-tool.is-active { color: #fff; }

.wl-tool:hover .wl-tool-ico, .wl-tool.is-active .wl-tool-ico {
  border-color: rgba(138, 109, 255, .5);
  background: rgba(138, 109, 255, .16);
  color: var(--wl-gold);
}

.wl-tool.is-recording .wl-tool-ico {
  border-color: rgba(247, 114, 137, .6);
  background: rgba(247, 114, 137, .18);
  color: #ffd7de;
}

.wl-advanced {
  display: none;
  gap: 10px;
  width: 100%;
  max-width: 580px;
  margin: 14px auto 0;
  padding: 14px;
  border: 1px solid var(--wl-line);
  border-radius: var(--wl-r-md);
  background: rgba(13, 20, 40, .9);
  text-align: right;
}

.wl-advanced.is-open { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.wl-advanced--page { margin: 0 0 14px; max-width: 100%; }

.wl-field { display: flex; flex-direction: column; gap: 6px; font-size: .72rem; color: var(--wl-dim); }

.wl-field select, .wl-field input {
  padding: 9px 11px;
  border: 1px solid var(--wl-line);
  border-radius: 10px;
  background: #101a34;
  color: var(--wl-text);
  font-family: inherit;
  font-size: .81rem;
}

.wl-field select:focus, .wl-field input:focus { outline: none; border-color: rgba(106, 135, 255, .55); }

.wl-keywords {
  display: none;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  max-width: 660px;
  margin: 14px auto 0;
}

.wl-keywords.is-open { display: flex; }

.wl-chip {
  padding: 6px 13px;
  border: 1px solid rgba(233, 201, 139, .2);
  border-radius: 999px;
  background: var(--wl-gold-soft);
  color: var(--wl-gold);
  font-size: .72rem;
  font-weight: 600;
  transition: background .18s ease;
}

.wl-chip:hover { background: rgba(233, 201, 139, .18); }

/* ============================ 4) الإحصائيات ============================ */
.wl-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(158px, 1fr));
  gap: 10px;
  padding: 14px var(--wl-pad);
}

.wl-stat {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 12px 13px;
  border: 1px solid var(--wl-line);
  border-radius: var(--wl-r-md);
  background: linear-gradient(180deg, var(--wl-panel-2), var(--wl-panel));
  box-shadow: var(--wl-shadow);
  transition: border-color .18s ease, transform .18s ease;
}

.wl-stat:hover { border-color: rgba(138, 109, 255, .32); transform: translateY(-2px); }

.wl-stat-ico {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  border-radius: 12px;
  border: 1px solid rgba(138, 109, 255, .26);
  background: rgba(138, 109, 255, .12);
  color: #bcc8ff;
}

.wl-stat-txt { display: flex; flex-direction: column; min-width: 0; }
.wl-stat-num { font-size: 1.12rem; font-weight: 900; color: #fff; line-height: 1.2; }
.wl-stat-lbl {
  font-size: .67rem;
  color: var(--wl-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ============================ الأقسام ================================= */
.wl-section { padding: 2px var(--wl-pad) 20px; }
.wl-section--top { padding-top: 12px; }

.wl-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.wl-section-title { margin: 0; font-size: .97rem; font-weight: 800; }
.wl-section-title span { color: var(--wl-faint); font-size: .72rem; font-weight: 600; }

.wl-link-btn {
  color: var(--wl-blue);
  font-size: .74rem;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.wl-link-btn:hover { color: #9fb2ff; }

.wl-head-actions { display: flex; gap: 14px; }
.wl-count { margin: 0 0 12px; font-size: .74rem; color: var(--wl-faint); }

.wl-note {
  margin: 0;
  padding: 12px 14px;
  border: 1px solid rgba(233, 201, 139, .17);
  border-radius: var(--wl-r-sm);
  background: var(--wl-gold-soft);
  color: var(--wl-gold);
  font-size: .75rem;
  line-height: 1.75;
}

/* ============================ 5) التصنيفات ============================= */
.wl-rail-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.wl-rail {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  gap: 11px;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  padding: 4px 2px 10px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.wl-rail::-webkit-scrollbar { display: none; }

.wl-rail-nav {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1.5px solid rgba(233, 201, 139, .55);
  border-radius: 50%;
  background: linear-gradient(180deg, rgba(28, 38, 68, .98), rgba(10, 16, 34, .98));
  color: var(--wl-gold);
  box-shadow: 0 8px 20px rgba(2, 6, 16, .55), 0 0 0 3px rgba(233, 201, 139, .08);
  transition: color .18s ease, border-color .18s ease, transform .18s ease, background .18s ease;
}

.wl-rail-nav .wl-ic {
  width: 20px;
  height: 20px;
  stroke-width: 2.1;
}

.wl-rail-nav:hover {
  color: #fff;
  border-color: rgba(233, 201, 139, .92);
  transform: scale(1.06);
  background: linear-gradient(180deg, rgba(48, 40, 20, .98), rgba(18, 22, 40, .98));
}

.wl-rail-nav:active { transform: scale(.96); }

/* في RTL: السابق على اليمين (يشير يميناً) والتالي على اليسار (يشير يساراً) */
.wl-rail-nav--prev .wl-ic { transform: scaleX(-1); }

.wl-cat {
  flex: 0 0 auto;
  width: 118px;
  min-height: 118px;
  scroll-snap-align: start;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 8px 11px;
  border: 1px solid var(--wl-line);
  border-radius: var(--wl-r-md);
  background: linear-gradient(180deg, var(--wl-panel-2), var(--wl-panel));
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}

.wl-cat:hover {
  transform: translateY(-4px);
  border-color: rgba(233, 201, 139, .3);
  box-shadow: 0 16px 32px rgba(2, 6, 16, .55);
}

/* صندوق ثابت لكل رمز حتى تتساوى كل البطاقات بصرياً */
.wl-cat-ico {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  margin-bottom: 1px;
  border-radius: 13px;
  border: 1px solid rgba(233, 201, 139, .18);
  background: rgba(233, 201, 139, .07);
  color: var(--wl-gold);
}

.wl-cat-ico .wl-ic {
  width: 26px;
  height: 26px;
  filter: drop-shadow(0 0 9px rgba(233, 201, 139, .26));
}

.wl-cat-name {
  font-size: .78rem;
  font-weight: 700;
  text-align: center;
  line-height: 1.35;
  max-width: 100%;
}

.wl-cat-sub { font-size: .62rem; color: var(--wl-faint); line-height: 1.2; }

.wl-cats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 11px;
}

.wl-cats-grid .wl-cat { width: auto; }

/* ============================ 6) الكتب ================================= */
.wl-book {
  flex: 0 0 auto;
  width: 152px;
  scroll-snap-align: start;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--wl-line);
  border-radius: var(--wl-r-md);
  background: var(--wl-panel-solid);
  overflow: hidden;
  text-align: right;
  cursor: pointer;
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}

.wl-book:hover {
  transform: translateY(-6px);
  border-color: rgba(233, 201, 139, .34);
  box-shadow: 0 20px 40px rgba(2, 6, 16, .62);
}

.wl-book-cover {
  position: relative;
  aspect-ratio: 3 / 4;
  background: linear-gradient(150deg, #22305c, #152040);
  overflow: hidden;
}

.wl-book-cover img { width: 100%; height: 100%; object-fit: cover; object-position: center center; transition: transform .3s ease; }
.wl-book:hover .wl-book-cover img { transform: scale(1.05); }

@media (hover: none) {
  .wl-book:hover { transform: none; box-shadow: none; }
  .wl-book:hover .wl-book-cover img { transform: none; }
  .wl-cat:hover { transform: none; box-shadow: none; }
}

.wl-book-fb {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 5px;
  padding: 12px;
  color: var(--wl-gold);
  font-size: .77rem;
  font-weight: 700;
  text-align: center;
  line-height: 1.5;
}

.wl-book-fb small { color: var(--wl-dim); font-size: .62rem; font-weight: 500; }

.wl-book-src {
  position: absolute;
  top: 7px;
  inset-inline-start: 7px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(4, 8, 20, .85);
  border: 1px solid var(--wl-line);
  font-size: .56rem;
  font-weight: 700;
  color: var(--wl-dim);
}

.wl-book-body { display: flex; flex-direction: column; padding: 10px 11px 11px; }
.wl-book-row { display: flex; align-items: flex-start; gap: 8px; }
.wl-book-txt { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }

.wl-book-fav {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 27px;
  height: 27px;
  border-radius: 50%;
  color: var(--wl-faint);
  transition: color .18s ease, background .18s ease;
}

.wl-book-fav:hover { color: var(--wl-danger); background: rgba(247, 114, 137, .12); }
.wl-book-fav.is-saved { color: var(--wl-danger); }
.wl-book-fav.is-saved .wl-ic { fill: currentColor; }

.wl-book-title {
  font-size: .79rem;
  font-weight: 700;
  line-height: 1.42;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.wl-book-meta, .wl-book-year {
  font-size: .64rem;
  color: var(--wl-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wl-book-read {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin-top: 9px;
  padding: 7px;
  border: 1px solid rgba(138, 109, 255, .3);
  border-radius: 10px;
  background: rgba(138, 109, 255, .13);
  color: #fff;
  font-size: .71rem;
  font-weight: 700;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity .2s ease, transform .2s ease, background .18s ease;
}

.wl-book-read:hover { background: rgba(138, 109, 255, .24); }
.wl-book-read .wl-ic { width: 14px; height: 14px; }
.wl-book:hover .wl-book-read, .wl-book:focus-within .wl-book-read { opacity: 1; transform: none; }

.wl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.wl-grid .wl-book { width: auto; }
.wl-grid .wl-book-read { opacity: 1; transform: none; }
.wl-explore-more { display: flex; justify-content: center; margin: 16px 0 8px; }
.wl-explore-more .wl-link-btn { min-width: 160px; padding: 10px 18px; }
.wl-explore-more { display: flex; justify-content: center; margin: 16px 0 8px; }
.wl-explore-more .wl-link-btn { min-width: 160px; padding: 10px 18px; }

/* ============================ 7) قسم الذكاء ============================ */
.wl-ai {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 22px;
  margin: 0 var(--wl-pad) 26px;
  padding: 22px;
  border: 1px solid rgba(138, 109, 255, .24);
  border-radius: 20px;
  background:
    radial-gradient(80% 130% at 6% 0%, rgba(138, 109, 255, .22), transparent 66%),
    linear-gradient(180deg, rgba(18, 24, 54, .95), rgba(8, 13, 28, .95));
  box-shadow: 0 18px 44px rgba(2, 6, 16, .5), var(--wl-glow-purple);
}

.wl-ai--compact { grid-template-columns: auto 1fr; margin: 0 0 18px; }

.wl-robot { width: 106px; height: 106px; }

.wl-ai-title { margin: 0 0 6px; font-size: 1.06rem; font-weight: 800; color: var(--wl-gold); }
.wl-ai-desc { margin: 0 0 13px; font-size: .81rem; line-height: 1.75; color: var(--wl-dim); }

.wl-ai-btn {
  padding: 10px 26px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--wl-purple), var(--wl-blue));
  color: #fff;
  font-size: .83rem;
  font-weight: 700;
  box-shadow: 0 10px 24px rgba(138, 109, 255, .3);
  transition: filter .18s ease;
}

.wl-ai-btn:hover { filter: brightness(1.08); }

.wl-ai-feats { display: grid; grid-template-columns: repeat(4, minmax(96px, 1fr)); gap: 9px; }

.wl-ai-feat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 13px 10px;
  border: 1px solid var(--wl-line);
  border-radius: 13px;
  background: rgba(255, 255, 255, .035);
  color: var(--wl-dim);
  text-align: center;
  transition: color .18s ease, border-color .18s ease, transform .18s ease;
}

.wl-ai-feat:hover { color: #fff; border-color: rgba(138, 109, 255, .42); transform: translateY(-2px); }
.wl-ai-feat b { font-size: .71rem; font-weight: 700; }
.wl-ai-feat small { font-size: .58rem; color: var(--wl-faint); }
.wl-ai-feat-ico { color: var(--wl-gold); display: flex; }
.wl-ai-feat-ico .wl-ic { width: 21px; height: 21px; }

/* ============================ حالات وقوائم ============================= */
.wl-state {
  flex: 1 1 auto;
  padding: 32px 16px;
  border: 1px dashed var(--wl-line-2);
  border-radius: var(--wl-r-md);
  background: rgba(13, 20, 40, .5);
  color: var(--wl-dim);
  font-size: .82rem;
  text-align: center;
  line-height: 1.85;
}

.wl-spinner {
  display: block;
  width: 26px;
  height: 26px;
  margin: 0 auto 10px;
  border: 3px solid rgba(138, 109, 255, .22);
  border-top-color: var(--wl-purple);
  border-radius: 50%;
  animation: wl-rotate .85s linear infinite;
}

@keyframes wl-rotate { to { transform: rotate(360deg); } }

.wl-page { display: none; }
.wl-page.is-active { display: block; }

.wl-fit { padding-bottom: 8px; }

/* الرئيسية مرتبة بمقاسات مريحة — بدون تصغير JS يقطع المحتوى */
@media (min-width: 1024px) {
  .wl-page[data-wl-view="home"] {
    --wl-fit-gap: clamp(12px, 1.7vh, 22px);
    --wl-fit-pad: clamp(11px, 1.35vh, 16px);
  }

  .wl-page[data-wl-view="home"] .wl-hero {
    min-height: clamp(248px, 34vh, 400px);
    padding-bottom: var(--wl-fit-gap);
  }
  .wl-page[data-wl-view="home"] .wl-hero-inner { padding-top: 0; }
  .wl-page[data-wl-view="home"] .wl-hero-pic img { object-position: center 12%; }

  .wl-page[data-wl-view="home"] .wl-stats { padding: var(--wl-fit-gap) var(--wl-pad); }
  .wl-page[data-wl-view="home"] .wl-stat { padding: var(--wl-fit-pad) 13px; }

  .wl-page[data-wl-view="home"] .wl-section { padding: 2px var(--wl-pad) var(--wl-fit-gap); }
  .wl-page[data-wl-view="home"] .wl-section-head { margin-bottom: 10px; }

  .wl-page[data-wl-view="home"] .wl-book { width: clamp(128px, 10.6vw, 168px); }
  .wl-page[data-wl-view="home"] .wl-book-cover {
    aspect-ratio: auto;
    height: clamp(148px, 20vh, 220px);
  }

  .wl-page[data-wl-view="home"] .wl-ai {
    margin: 0 var(--wl-pad) var(--wl-fit-gap);
    padding: 16px 20px;
  }
}

.wl-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--wl-line);
  border-radius: var(--wl-r-sm);
  background: var(--wl-panel);
  margin-bottom: 9px;
}

.wl-row-ico { color: var(--wl-gold); display: flex; }
.wl-row-main { flex: 1 1 auto; min-width: 0; }
.wl-row-title { font-size: .85rem; font-weight: 700; margin-bottom: 3px; }
.wl-row-meta { font-size: .68rem; color: var(--wl-faint); }

.wl-src-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(196px, 1fr)); gap: 11px; }

.wl-src {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 14px;
  border: 1px solid var(--wl-line);
  border-radius: var(--wl-r-sm);
  background: var(--wl-panel);
  color: var(--wl-gold);
  transition: border-color .18s ease;
}

.wl-src:hover { border-color: rgba(233, 201, 139, .3); }
.wl-src-name { font-size: .85rem; font-weight: 700; color: var(--wl-text); margin-bottom: 3px; }
.wl-src-note { font-size: .68rem; color: var(--wl-faint); line-height: 1.6; }

/* ============================ Bottom Nav =============================== */
.wl-bottom-nav {
  display: none;
  position: fixed;
  inset-inline: 0;
  bottom: 0;
  z-index: 20;
  grid-template-columns: repeat(5, 1fr);
  gap: 0;
  padding: 3px 4px max(3px, env(safe-area-inset-bottom, 0px));
  background: rgba(5, 9, 22, .97);
  border-top: 1px solid var(--wl-line);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.wl-bn-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 3px 2px 2px;
  border-radius: 9px;
  color: var(--wl-faint);
  font-size: .5rem;
  font-weight: 600;
  line-height: 1.15;
  text-align: center;
  transition: color .18s ease, background .18s ease;
}

.wl-bn-item .wl-ic { width: 16px; height: 16px; }

.wl-bn-item.is-active { color: #fff; background: rgba(138, 109, 255, .13); }
.wl-bn-item.is-active .wl-ic { color: var(--wl-gold); }

/* ============================ محادثة المكتبة ============================ */
.wl-chat {
  position: fixed;
  inset: 0;
  z-index: 40;
}

.wl-chat[hidden] { display: none !important; }

.wl-chat-scrim {
  position: absolute;
  inset: 0;
  background: rgba(3, 6, 16, .55);
}

.wl-chat-panel {
  position: absolute;
  top: 16px;
  bottom: 16px;
  right: 16px;
  left: auto;
  width: min(440px, calc(100vw - var(--wl-sidebar-w) - 36px));
  display: flex;
  flex-direction: column;
  border: 1px solid rgba(138, 109, 255, .28);
  border-radius: 20px;
  background:
    radial-gradient(90% 60% at 100% 0%, rgba(138, 109, 255, .18), transparent 62%),
    linear-gradient(180deg, #1a2548 0%, #121c38 100%);
  box-shadow: 0 24px 60px rgba(2, 6, 16, .62), var(--wl-glow-purple);
  overflow: hidden;
}

.wl-chat-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 12px 10px;
  border-bottom: 1px solid var(--wl-line);
}

.wl-chat-head-txt { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.wl-chat-head-txt strong { font-size: .92rem; color: var(--wl-gold); }
.wl-chat-head-txt span { font-size: .68rem; color: var(--wl-dim); }

.wl-chat-pills {
  display: flex;
  gap: 6px;
  padding: 10px 12px 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.wl-chat-pill {
  flex: 0 0 auto;
  padding: 5px 12px;
  border: 1px solid var(--wl-line);
  border-radius: 999px;
  background: rgba(255, 255, 255, .04);
  color: var(--wl-dim);
  font-size: .72rem;
  font-weight: 700;
}

.wl-chat-pill.is-active {
  color: #fff;
  border-color: rgba(138, 109, 255, .5);
  background: rgba(138, 109, 255, .2);
}

.wl-chat-log {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 14px 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.wl-chat-msg {
  max-width: 92%;
  padding: 10px 12px;
  border-radius: 14px;
  font-size: .82rem;
  line-height: 1.75;
  white-space: normal;
}

.wl-chat-msg--bot {
  align-self: flex-start;
  background: rgba(255, 255, 255, .05);
  border: 1px solid var(--wl-line);
  color: var(--wl-text);
}

.wl-chat-msg--user {
  align-self: flex-end;
  background: linear-gradient(135deg, rgba(138, 109, 255, .34), rgba(106, 135, 255, .28));
  border: 1px solid rgba(138, 109, 255, .3);
}

.wl-chat-form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px calc(12px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--wl-line);
}

.wl-chat-form textarea {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 42px;
  max-height: 120px;
  resize: none;
  padding: 10px 12px;
  border: 1px solid var(--wl-line);
  border-radius: 14px;
  background: rgba(255, 255, 255, .04);
  color: var(--wl-text);
  font-family: inherit;
  font-size: 16px;
  line-height: 1.55;
  -webkit-appearance: none;
  appearance: none;
}

.wl-chat-form textarea:focus { outline: none; border-color: rgba(138, 109, 255, .5); }

.wl-chat-send {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border-radius: 13px;
  background: linear-gradient(135deg, var(--wl-purple), var(--wl-blue));
  color: #fff;
}

.wl-chat-send:disabled { opacity: .55; cursor: progress; }

@media (max-width: 767px), (orientation: landscape) and (max-height: 540px) {
  .wl-chat-panel {
    inset: 8px 8px calc(56px + env(safe-area-inset-bottom, 0px));
    width: auto;
    border-radius: 16px;
  }
}

.wl-scrim {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 14;
  background: rgba(3, 6, 16, .7);
}

.wl-scrim.is-open { display: block; }

/* ==========================================================================
   الاستجابة — حاسوب كبير / حاسوب / تابلت أفقي / تابلت عمودي / موبايل
   ========================================================================== */

/* شاشات كبيرة جداً */
@media (min-width: 1600px) {
  .wl-root { --wl-sidebar-w: 282px; --wl-pad: 32px; }
  .wl-hero { min-height: clamp(420px, 46vh, 600px); }
  .wl-book { width: 168px; }
  .wl-grid { grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); }
  .wl-cat { width: 136px; }
}

/* تابلت أفقي 1024 → 1279 */
@media (max-width: 1279px) {
  .wl-root { --wl-sidebar-w: 214px; --wl-pad: 18px; }
  .wl-hero-inner { padding-top: min(22vh, 150px); }
  .wl-ai { grid-template-columns: auto 1fr; row-gap: 18px; }
  .wl-ai-feats { grid-column: 1 / -1; }
}

/* تابلت عمودي 768 → 1023 — قائمة أيقونات فقط */
@media (min-width: 768px) and (max-width: 1023px) {
  .wl-root { --wl-sidebar-w: 74px; }
  .wl-sidebar { padding: 14px 8px; align-items: center; gap: 10px; }
  .wl-brand { border-bottom: 0; padding-bottom: 8px; }
  .wl-brand-txt { display: none; }
  .wl-nav-item { justify-content: center; padding: 11px 0; }
  .wl-nav-item span, .wl-nav-badge { display: none; }
  .wl-nav-item .wl-ic { width: 21px; height: 21px; }
  .wl-ai-card { padding: 10px; justify-content: center; }
  .wl-ai-card-txt { display: none; }
  .wl-robot--sm { width: 40px; height: 40px; }
  .wl-book { width: 126px; }
  .wl-grid { grid-template-columns: repeat(auto-fill, minmax(138px, 1fr)); }
  .wl-ai-feats { grid-template-columns: repeat(4, 1fr); }
}

/* موبايل أقل من 768 */
@media (max-width: 767px), (orientation: landscape) and (max-height: 540px) {
  .wl-root { --wl-pad: 14px; }
  .wl-shell { grid-template-columns: 1fr; }

  .wl-sidebar {
    position: fixed;
    inset-block: 0;
    inset-inline-start: 0;
    z-index: 15;
    width: min(84vw, 296px);
    grid-column: 1;
    transform: translateX(100%);
    transition: transform .26s cubic-bezier(.22, .68, .28, 1);
    border-inline-end: 1px solid var(--wl-line-2);
    padding-top: calc(16px + env(safe-area-inset-top, 0px));
  }

  .wl-root.wl-drawer-open .wl-sidebar { transform: none; }

  .wl-topbar { display: none; }
  .wl-mobile-head { display: flex; }
  .wl-bottom-nav { display: grid; }
  .wl-main { padding-bottom: calc(52px + env(safe-area-inset-bottom, 0px)); }

  .wl-hero {
    min-height: clamp(252px, 40vh, 340px);
    padding: 0 var(--wl-pad) 16px;
  }
  .wl-hero-pic img { object-position: center 20%; }
  .wl-hero-globe { top: 6px; width: min(52vw, 25vh, 200px); }
  .wl-hero-inner { padding-top: min(25vh, 152px); }
  .wl-hero-title { font-size: clamp(1.5rem, 6.6vw, 1.95rem); }
  .wl-hero-tagline { font-size: .82rem; margin: 5px 0 6px; }
  .wl-hero-desc { display: none; }
  .wl-shelf { width: 52%; }

  .wl-hero-search { margin-top: 12px; padding: 5px 5px 5px 15px; }
  .wl-hero-search input { font-size: 16px; padding: 9px 4px; }
  .wl-hero-search-btn { width: 39px; height: 39px; border-radius: 12px; }

  /* أدوات البحث: أربع دوائر بعنوان تحتها */
  .wl-tools { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 15px; }
  .wl-tools::before { display: none; }
  .wl-tool { flex-direction: column; gap: 6px; padding: 4px 2px; font-size: .57rem; }
  .wl-tool-lbl { white-space: nowrap; }
  .wl-tool-ico { width: 42px; height: 42px; }

  .wl-stats { grid-template-columns: repeat(2, 1fr); gap: 8px; padding: 15px var(--wl-pad); }
  .wl-stat { padding: 11px; gap: 9px; border-radius: var(--wl-r-sm); }
  .wl-stat-ico { width: 33px; height: 33px; border-radius: 10px; }
  .wl-stat-ico .wl-ic { width: 16px; height: 16px; }
  .wl-stat-num { font-size: .97rem; }
  .wl-stat-lbl { font-size: .62rem; }

  .wl-section { padding: 2px var(--wl-pad) 20px; }
  .wl-section--top { padding-top: 15px; }
  .wl-section-title { font-size: .88rem; }
  .wl-rail-wrap { gap: 6px; }
  .wl-rail-nav { width: 34px; height: 34px; }
  .wl-rail-nav .wl-ic { width: 16px; height: 16px; }

  /* الاستكشاف: أيقونات دائرية بتمرير أفقي */
  .wl-rail--cats .wl-cat {
    width: 68px;
    padding: 0;
    border: 0;
    background: none;
    gap: 5px;
  }
  .wl-rail--cats .wl-cat-ico {
    width: 54px;
    height: 54px;
    margin-bottom: 0;
    border: 1px solid var(--wl-line);
    border-radius: 17px;
    background: linear-gradient(180deg, var(--wl-panel-2), var(--wl-panel));
  }
  .wl-rail--cats .wl-cat-ico .wl-ic { width: 24px; height: 24px; }
  .wl-rail--cats .wl-cat:hover { transform: none; box-shadow: none; }
  .wl-rail--cats .wl-cat-name { font-size: .62rem; }
  .wl-rail--cats .wl-cat-sub { display: none; }

  .wl-cats-grid { grid-template-columns: repeat(3, 1fr); gap: 9px; }
  .wl-cats-grid .wl-cat { padding: 13px 7px; }

  .wl-book {
    width: 104px;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
  }
  .wl-book-cover { aspect-ratio: 2 / 3; }
  .wl-book-body { padding: 7px 7px 8px; }
  .wl-book-read { opacity: 1; transform: none; padding: 5px; font-size: .62rem; margin-top: 6px; }
  .wl-book-title { font-size: .68rem; -webkit-line-clamp: 2; }
  .wl-book-meta, .wl-book-year { font-size: .58rem; }
  .wl-book-fav { width: 24px; height: 24px; }
  .wl-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .wl-grid .wl-book { width: auto; }

  .wl-ai {
    grid-template-columns: auto 1fr;
    margin: 0 var(--wl-pad) 20px;
    padding: 16px;
    gap: 14px;
    border-radius: 16px;
  }
  .wl-robot { width: 74px; height: 74px; }
  .wl-ai-title { font-size: .93rem; }
  .wl-ai-desc { font-size: .73rem; margin-bottom: 11px; line-height: 1.7; }
  .wl-ai-btn { width: 100%; padding: 10px; font-size: .78rem; }
  .wl-ai-feats { grid-column: 1 / -1; grid-template-columns: repeat(2, 1fr); }
  .wl-ai-feat { padding: 11px 8px; }

  .wl-src-grid { grid-template-columns: 1fr 1fr; }
  .wl-state { padding: 26px 14px; font-size: .78rem; }
}

/* هواتف صغيرة أقل من 400 */
@media (max-width: 399px) {
  .wl-tool { font-size: .52rem; }
  .wl-tool-ico { width: 38px; height: 38px; }
  .wl-stats { grid-template-columns: 1fr 1fr; }
  .wl-book { width: 96px; }
  .wl-book-title { font-size: .64rem; }
  .wl-ai-feats { grid-template-columns: 1fr 1fr; }
  .wl-src-grid { grid-template-columns: 1fr; }
  .wl-bn-item { font-size: .5rem; }
}

/* موبايل أفقي — Hero أقصر حتى لا يغطي الشاشة */
@media (max-width: 900px) and (max-height: 480px) and (orientation: landscape) {
  .wl-hero { min-height: 260px; }
  .wl-hero-globe { top: 4px; width: min(30vw, 40vh, 190px); }
  .wl-hero-inner { padding-top: 120px; }
  .wl-hero-tagline, .wl-hero-desc { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .wl-root * {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}
