/* Authenticated library flow — Figma nodes 117:12854 through 117:16643 */
.library-app-page {
  min-width: 320px;
  min-height: 100vh;
  color: var(--brand);
  background: var(--surface);
}

.library-app-page [hidden] { display: none !important; }
.library-app-page button,
.library-app-page input { font-family: var(--font-body); }
.library-app-page a { text-decoration: none; }
.library-app-page button:focus-visible,
.library-app-page a:focus-visible,
.library-app-page input:focus-visible { outline: 3px solid rgba(212, 134, 11, 0.32); outline-offset: 3px; }

.library-app {
  width: calc(100% - 320px);
  min-height: 100vh;
  margin-right: 320px;
  background: var(--surface);
  transition: width .28s ease, margin .28s ease;
}

.sidebar-collapsed .library-app { width: calc(100% - 88px); margin-right: 88px; }

.library-header {
  position: sticky;
  z-index: 900;
  top: 0;
  width: 100%;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  background: rgba(255,255,255,.98);
  border-bottom: .8px solid rgba(27,67,50,.10);
  transition: box-shadow .2s ease;
}

.library-header.is-scrolled { box-shadow: 0 12px 30px rgba(27,67,50,.07); }
.library-header-title { text-align: start; }
.library-header-title h1 { max-width: 520px; margin: 0; overflow: hidden; color: var(--brand); font-size: 20px; font-weight: 700; line-height: 30px; text-overflow: ellipsis; white-space: nowrap; }
.library-header-title p { margin: 0; color: var(--muted-brand); font-size: 13px; line-height: 18px; }
.library-header-actions { display: flex; align-items: center; gap: 16px; direction: var(--doc-flip); }
.library-avatar,
.library-language,
.library-back-link { display: inline-flex; align-items: center; justify-content: center; color: var(--brand); background: var(--surface); border: 1px solid var(--brand); }
/* في القائمة، الزرّ يقع في زاوية بطاقة موضعها نسبيّ. هنا لا بطاقة، فيجلس بين
   أزرار الترويسة كأيّ عنصر آخر بدل أن يطفو فوقها. */
.library-header-actions .library-save { position: static; }
.library-avatar { width: 38px; height: 38px; color: var(--surface); background: var(--brand); border: 0; border-radius: 50%; font-size: 15px; font-weight: 700; }
.library-language { min-width: 105px; height: 48px; padding-inline: 24px; border-radius: 12px; font-size: 16px; }
.library-back-link { min-height: 40px; padding: 8px 17px; border-color: var(--muted-brand); border-radius: 12px; font-size: 15px; white-space: nowrap; }

.library-index-main { width: min(1088px, calc(100% - 64px)); margin: 0 auto; padding: 32px 0 96px; }
.library-index-hero { min-height: 0; display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(260px, .9fr); align-items: stretch; gap: 24px; margin-bottom: 20px; direction: var(--doc-dir); }
.library-index-hero-copy { display: flex; flex-direction: column; justify-content: center; align-items: flex-start; text-align: start; }
.library-index-hero-copy > span { margin-bottom: 8px; color: var(--accent); font-size: 14px; }
.library-index-hero h2 { max-width: 610px; margin: 0 0 6px; color: var(--brand); font-size: 24px; font-weight: 700; line-height: 1.3; }
.library-index-hero p { max-width: 620px; margin: 0; color: var(--muted-brand); font-size: 15px; line-height: 22px; }
/* الإطار كان ٩٦ بكسل: أقصر من عمود النصّ إلى جانبه، فيبدو شريطًا معلّقًا لا صورة.
   والارتفاع يبقى محدَّدًا — `height: 100%` بلا ارتفاع صفٍّ محدَّد يعود إلى نسبة الصورة
   الطبيعية فيقفز الشريط إلى ٢٩١ بكسل على الحاسوب و٥٦٣ على اللوح. */
.library-index-hero figure { width: 100%; height: 132px; margin: 0; overflow: hidden; background: var(--canvas); border-radius: 16px; }
/* القصّ من وسط الصورة كان يقع على الفازة ويأكل اليد والدفتر، وهما موضوعها. */
.library-index-hero img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 70%; }

.library-discovery { margin-bottom: 32px; }
.library-index-search { width: min(640px, 100%); margin: 0 0 32px auto; }
.library-index-search label { display: block; margin-bottom: 8px; color: var(--muted-brand); font-size: 15px; }
.library-index-search > div { position: relative; }
.library-index-search input { width: 100%; height: 54px; padding: 12px 52px 12px 18px; color: var(--brand); background: var(--surface); border: 1px solid rgba(27,67,50,.18); border-radius: 16px; outline: 0; font-size: 16px; }
.library-index-search input::placeholder { color: var(--muted-brand); }
.library-index-search input:focus { border-color: var(--brand); box-shadow: 0 0 0 4px rgba(27,67,50,.08); }
.library-index-search img { position: absolute; top: 18px; right: 18px; width: 19px; height: 19px; object-fit: contain; opacity: .66; }

/* التصفية عمودٌ إلى جانب النتائج لا صفَّان فوقها: ستة عشر خيارًا في سطرين
   أفقيَّين يُمرَّران جانبيًّا تخفي أكثرها عن القارئ. */
.library-browse { display: grid; grid-template-columns: 248px minmax(0, 1fr); gap: 28px; align-items: start; }
.library-filter-rail { position: sticky; top: 24px; display: grid; gap: 14px; padding: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; }
.library-filter-group { border: 0; }
.library-filter-group + .library-filter-group { padding-top: 14px; border-top: 1px solid var(--line); }
.library-filter-group summary { display: flex; align-items: center; justify-content: space-between; color: var(--brand); font-size: 16px; font-weight: 700; cursor: pointer; list-style: none; }
.library-filter-group summary::-webkit-details-marker { display: none; }
/* علامةٌ تدور مع الفتح، مرسومة بالحدود فتتبع اتجاه الصفحة بلا محرف مرآوي. */
.library-filter-group summary::after { width: 7px; height: 7px; content: ""; border-left: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-45deg); opacity: .6; transition: transform .2s ease; }
.library-filter-group[open] summary::after { transform: rotate(135deg); }

.library-type-filters,
.library-topic-filters { display: grid; gap: 4px; margin: 12px 0 0; padding: 0; background: transparent; }
.library-type-filters button,
.library-topic-filters button { min-height: 40px; display: flex; align-items: center; justify-content: flex-start; gap: 10px; width: 100%; padding: 8px 12px; color: var(--muted-brand); background: transparent; border: 0; border-radius: 10px; font-size: 15px; text-align: start; }
.library-type-filters button:hover,
.library-topic-filters button:hover { background: rgba(27, 67, 50, .06); }
/* كانت الأيقونات رموزًا هندسية من الخطّ — ☰ ▭ ▣ ▤ ♫ ▧ ▯ — تتبدّل بتبدّل الخطّ ولا
   تدلّ على نوع المادة. صارت رسومًا متجهة بخطّ `currentColor`، فتتبع لون الزرّ في
   حالتَي السكون والتفعيل معًا، وهو ما تعجز عنه صورة ثابتة. */
.library-type-filters button svg {
  flex: 0 0 18px;
  width: 18px;
  height: 18px;
  opacity: .8;
}

.library-type-filters button.is-active svg { opacity: 1; }
.library-type-filters button.is-active,
.library-topic-filters button.is-active { color: var(--surface); background: var(--brand); font-weight: 700; }

.library-clear { display: block; width: 100%; margin: 4px 0 0; padding: 10px; color: #d94e2e; background: transparent; border: 1px solid rgba(217, 78, 46, .35); border-radius: 10px; font-size: 15px; font-weight: 600; }

/* البطاقة كلها تفتح مادتها، لا زرُّها وحده. المؤشّر يقول ذلك، والنقر نفسه في
   library.js: الرابط هنا موضوع داخل البطاقة وهو نفسه عنصر مُموضَع، فأيّ عنصر زائف
   يُمَدّ منه يقع على الزرّ لا على البطاقة. */
.library-card-item,
.library-media-item,
.library-book-item,
.library-question-item,
/* المقالات والصوتيات كانتا خارج القائمة، وهما ما سُئل عنهما بالاسم. */
.library-article-item,
.library-audio-item { position: relative; cursor: pointer; }

.library-card-item:hover,
.library-media-item:hover,
.library-book-item:hover,
.library-question-item:hover,
.library-article-item:hover,
.library-audio-item:hover { border-color: var(--muted-brand); }

/* ملاحظة البطاقة التي لا ملفّ لها: تحلّ محلّ ▶ والمدّة، فلا تَعِد البطاقة بتشغيل. */
.library-missing-file { display: block; margin-top: 6px; color: var(--muted-brand); font-size: 12px; }

/* زرّ الحفظ في زاوية البطاقة على كل الأنواع. البطاقة نفسها `position: relative`
   أصلًا لأنها كلّها قابلة للنقر، فيقع الزرّ داخلها لا فوق ما جاورها. */
.library-save {
  position: absolute;
  inset-block-start: 10px;
  z-index: 2;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  color: var(--brand);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
}

/* نصّ الزرّ لقارئ الشاشة: الأيقونة وحدها لا تقول «حفظ» ولا «محفوظة». */
.library-save .sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* بعض البطاقات عليها `direction: ltr` لترتيب الصورة قبل النصّ، فكان `inset-inline-end`
   يُحسب على اتجاهها لا اتجاه الصفحة ويقع الزرّ حيث يبدأ النصّ العربي. الموضع يتبع
   اتجاه المستند وحده. */
[dir="rtl"] .library-save { left: 10px; right: auto; }
[dir="ltr"] .library-save { right: 10px; left: auto; }

/* والمساحة تُحجز في الطرف الذي يقف فيه الزرّ فعلًا، لا في «نهاية» البطاقة المنطقية:
   «مناسب لمستواك» كانت تُقرأ «سب لمستواك». */
[dir="rtl"] .library-article-item > div,
[dir="rtl"] .library-audio-item > div,
[dir="rtl"] .library-question-item > div { padding-left: 42px; }

[dir="ltr"] .library-article-item > div,
[dir="ltr"] .library-audio-item > div,
[dir="ltr"] .library-question-item > div { padding-right: 42px; }

.library-save:hover { border-color: var(--brand); }
.library-save[aria-pressed="true"] { color: var(--surface); background: var(--brand); border-color: var(--brand); }
.library-save[disabled] { opacity: .55; cursor: progress; }

/* بطاقات الصور تُغطّي زاويتها، فالزرّ يحتاج أرضيةً تفصله عن الصورة تحته. */
.library-card-item .library-save,
.library-short-item .library-save { box-shadow: 0 1px 6px rgba(0, 0, 0, .18); }

.library-results { display: flex; flex-direction: column; gap: 32px; }
.library-results-section > header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.library-results-section > header h2 { margin: 0; color: var(--brand); font-size: 24px; font-weight: 700; }
.library-results-section > header button { color: var(--brand); background: transparent; border: 0; font-size: 14px; }

.library-featured-book { min-height: 260px; display: grid; grid-template-columns: minmax(0,1fr) minmax(340px, .86fr); overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: 22px; }
.library-featured-book figure { min-height: 260px; margin: 0; overflow: hidden; }
.library-featured-book img { width: 30%; height: 100%; object-fit: cover; }
.library-featured-book > div { display: flex; flex-direction: column; align-items: flex-start; justify-content: center; padding: 30px; }
.library-featured-book span { align-self: flex-start; padding: 7px 13px; color: var(--accent); background: rgba(212,134,11,.14); border-radius: 999px; font-size: 13px; }
.library-featured-book h3 { margin: 12px 0 8px; color: var(--brand); font-size: 24px; font-weight: 700; line-height: 1.45; }
.library-featured-book p { margin: 0 0 18px; color: var(--muted-brand); font-size: 15px; line-height: 25px; }

/* Marks a card the member's assessment level matches; it sits inside cards with very
   different backgrounds, so it carries its own surface rather than inheriting one. */
.library-level-badge { align-self: flex-start; width: fit-content; margin-bottom: 6px; padding: 4px 11px; color: var(--brand); background: rgba(255, 255, 255, .92); border-radius: 999px; font-size: 12px; font-weight: 600; }
.library-short-item .library-level-badge { position: absolute; top: 8px; right: 8px; z-index: 1; }

.library-card-grid,
.library-media-grid,
.library-book-grid,
.library-short-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 16px; }
.library-card-item { position: relative; min-height: 270px; display: flex; flex-direction: column; justify-content: flex-end; overflow: hidden; padding: 18px; color: var(--surface); background: var(--brand); border-radius: 18px; }
.library-card-item::after { position: absolute; inset: 0; content: ""; background: linear-gradient(180deg, transparent 22%, rgba(8,34,24,.92)); }
.library-card-item img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
/* زرّ الحفظ مُموضَع في زاوية البطاقة، وهذه القاعدة كانت تغلبه بالتخصيص فتردّه إلى
   التدفّق فيقع فوق تسمية النوع. */
.library-card-item > *:not(img):not(.library-save) { position: relative; z-index: 1; }
.library-card-item small { opacity: .8; }
.library-card-item h3 { margin: 7px 0 13px; color: var(--surface); font-size: 16px; line-height: 25px; }
.library-card-item a { align-self: flex-start; padding: 8px 15px; color: var(--brand); background: var(--surface); border-radius: 999px; font-size: 13px; }

.library-media-item { display: flex; flex-direction: column; gap: 12px; }
.library-media-thumb { position: relative; height: 190px; overflow: hidden; background: var(--canvas); border-radius: 16px; }
.library-media-thumb img { width: 100%; height: 100%; object-fit: cover; }
.library-media-thumb i { position: absolute; top: 50%; left: 50%; width: 48px; height: 48px; display: grid; place-items: center; color: var(--surface); background: rgba(27,67,50,.88); border-radius: 50%; transform: translate(-50%,-50%); font-style: normal; }
.library-media-thumb time { position: absolute; bottom: 8px; left: 8px; padding: 3px 8px; color: var(--surface); background: rgba(27,67,50,.88); border-radius: 999px; font-size: 12px; }
.library-media-item h3 { margin: 0; color: var(--brand); font-size: 16px; font-weight: 700; line-height: 25px; }
.library-media-item p { margin: 0; color: var(--muted-brand); font-size: 13px; line-height: 20px; }

.library-book-item figure { height: 160px; margin: 0 0 12px; overflow: hidden; background: var(--canvas); border-radius: 16px; }
.library-book-item img { width: 100%; height: 100%; object-fit: cover; }
.library-book-item h3 { min-height: 50px; margin: 0 0 10px; color: var(--brand); font-size: 16px; line-height: 24px; }
.library-book-item a { display: inline-flex; min-height: 38px; align-items: center; justify-content: center; padding: 7px 16px; color: var(--brand); border: 1px solid rgba(27,67,50,.28); border-radius: 11px; font-size: 13px; }

.library-audio-list { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 12px; }
.library-audio-item { min-height: 86px; display: grid; grid-template-columns: 64px minmax(0,1fr) 38px; align-items: center; gap: 12px; padding: 12px 10px; direction: var(--doc-flip); border: 1px solid rgba(27,67,50,.14); border-radius: 16px; }
.library-audio-item img { width: 64px; height: 64px; object-fit: cover; border-radius: 12px; }
.library-audio-item div { direction: var(--doc-dir); text-align: start; }
.library-audio-item h3 { margin: 0 0 4px; color: var(--brand); font-size: 14px; line-height: 20px; }
/* وصف المادة الصوتية كان 10px بتباين 2.6:1 — أصغر نصّ في المكتبة وأضعفه. */
.library-audio-item small { color: var(--muted-brand); font-size: 13px; line-height: 18px; }
.library-audio-item button { width: 36px; height: 36px; color: var(--surface); background: var(--brand); border: 0; border-radius: 50%; }

.library-article-list,
.library-question-list { display: grid; gap: 12px; }
.library-article-item { min-height: 128px; display: grid; grid-template-columns: 160px minmax(0,1fr); align-items: center; gap: 24px; padding: 12px; direction: var(--doc-flip); border: 1px solid var(--line); border-radius: 16px; }
.library-article-item img { width: 160px; height: 104px; object-fit: cover; border-radius: 12px; }
.library-article-item div { direction: var(--doc-dir); text-align: start; }
.library-article-item h3 { margin: 0 0 7px; color: var(--brand); font-size: 18px; }
.library-article-item p { margin: 0 0 6px; color: var(--muted-brand); font-size: 14px; line-height: 22px; }
.library-article-item a { color: var(--muted-brand); font-size: 12px; }

.library-short-item { position: relative; height: 290px; display: flex; flex-direction: column; justify-content: flex-end; overflow: hidden; padding: 14px; border-radius: 18px; }
.library-short-item::after { position: absolute; inset: 0; content: ""; background: linear-gradient(180deg,transparent 30%,rgba(8,34,24,.92)); }
.library-short-item img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.library-short-item > *:not(img):not(.library-save) { position: relative; z-index: 1; }
.library-short-item i { position: absolute; z-index: 2; top: 50%; left: 50%; width: 42px; height: 42px; display: grid; place-items: center; color: var(--brand); background: var(--surface); border-radius: 50%; transform: translate(-50%,-50%); font-style: normal; }
.library-short-item h3 { margin: 0; color: var(--surface); font-size: 15px; line-height: 22px; }
.library-short-item time { color: rgba(255,255,255,.92); font-size: 12px; }

.library-question-item { display: grid; grid-template-columns: 28px minmax(0,1fr); gap: 14px; padding: 18px 22px; border: 1px solid var(--line); border-radius: 16px; }
.library-question-item i { width: 20px; height: 20px; display: grid; place-items: center; color: var(--accent); border: 1px solid var(--accent); border-radius: 50%; font-style: normal; font-size: 12px; }
.library-question-item h3 { margin: 0 0 6px; color: var(--brand); font-size: 16px; }
.library-question-item p { margin: 0 0 7px; color: var(--muted-brand); font-size: 13px; line-height: 20px; }
.library-question-item a { color: var(--brand); font-size: 12px; text-decoration: underline; }

.library-no-results { width: min(600px,100%); margin: 24px 0 0 auto; padding: 40px; border: 1px solid rgba(27,67,50,.14); border-radius: 22px; text-align: start; }
.library-no-results h2 { margin: 0 0 6px; font-size: 24px; }
.library-no-results p { margin: 0 0 18px; color: var(--muted-brand); }
.library-no-results > div { display: flex; gap: 10px; }

/* Shared content pages */
.library-detail-main { width: min(1088px, calc(100% - 48px)); display: grid; grid-template-columns: 300px minmax(0,1fr); grid-template-areas: "aside content"; gap: 24px; margin: 0 auto; padding: 48px 0 96px; direction: var(--doc-flip); }
.library-content-aside { grid-area: aside; display: flex; flex-direction: column; gap: 16px; direction: var(--doc-dir); }
.library-detail-content { grid-area: content; min-width: 0; direction: var(--doc-dir); text-align: start; }
.library-meta-card,
.library-practice-card,
.library-review-card { padding: 24px; border-radius: 20px; }
.library-meta-card { border: 1px solid rgba(27,67,50,.14); }
.library-meta-card dl { display: grid; gap: 16px; margin: 0; }
.library-meta-card dl > div { display: grid; gap: 3px; }
.library-meta-card dt { color: var(--muted-brand); font-size: 14px; font-weight: 600; }
.library-meta-card dd { margin: 0; color: var(--brand); font-size: 15px; }
.library-practice-card { display: grid; gap: 8px; background: var(--canvas); }
.library-practice-card span { color: var(--muted-brand); font-size: 15px; font-weight: 700; }
.library-practice-card .btn { min-height: 44px; display: grid; place-items: center; font-size: 15px; }
.library-review-card { background: var(--canvas); border: 1px solid var(--line); }
.library-review-card strong { display: block; margin-bottom: 5px; font-size: 15px; }
.library-review-card p { margin: 0; color: var(--muted-brand); font-size: 13px; line-height: 21px; }
.library-aside-back { min-height: 44px; display: grid; place-items: center; color: var(--brand); border: 1px solid rgba(27,67,50,.18); border-radius: 12px; font-size: 15px; }

.library-detail-tags { display: flex; flex-direction: row-reverse; justify-content: flex-start; align-items: center; gap: 8px; margin-bottom: 32px; }
.library-detail-tags span { padding: 8px 16px; color: var(--brand); background: rgba(27,67,50,.1); border-radius: 999px; font-size: 13px; font-weight: 700; }
.library-detail-tags small { color: var(--muted-brand); font-size: 13px; }
.library-detail-hero { margin-bottom: 32px; }
.detail-question-box { padding: 24px 32px; background: var(--canvas); border-radius: 20px; }
.detail-question-box span { display: block; margin-bottom: 10px; font-size: 15px; font-weight: 700; }
.detail-question-box h2 { margin: 0; color: var(--brand); font-size: 28px; font-weight: 700; line-height: 42px; }

.detail-media-split { display: grid; grid-template-columns: minmax(0,1fr) 256px; align-items: stretch; gap: 32px; }
.detail-media-split > div:first-child { display: flex; flex-direction: column; align-items: flex-start; justify-content: center; }
.detail-media-split h2,
.detail-video-copy h2 { margin: 0 0 10px; color: var(--brand); font-size: 32px; line-height: 1.35; }
.detail-media-split p,
.detail-video-copy p { margin: 0; color: var(--muted-brand); font-size: 16px; line-height: 28px; }
.detail-media-image { position: relative; height: 256px; overflow: hidden; background: var(--canvas); border-radius: 18px; }
.detail-media-image img { width: 100%; height: 100%; object-fit: cover; }
.detail-media-image.detail-media-video { background: #0c2018; }
.detail-media-image video { display: block; width: 100%; height: 100%; object-fit: contain; background: #0c2018; }
.detail-duration { position: absolute; bottom: 8px; left: 8px; padding: 3px 9px; color: var(--surface); background: rgba(27,67,50,.9); border-radius: 999px; font-size: 12px; pointer-events: none; }
.detail-audio-player { width: 100%; margin-top: 18px; padding: 14px 16px; background: var(--canvas); border-radius: 16px; }
.detail-audio-player audio { display: block; width: 100%; }
.detail-action-row { display: flex; gap: 8px; margin-top: 14px; }
.detail-action-row button,
.detail-action-row a { min-height: 46px; display: inline-flex; align-items: center; justify-content: center; padding: 10px 24px; color: var(--brand); background: var(--surface); border: 1px solid var(--brand); border-radius: 12px; }
.detail-action-row .is-primary { color: var(--surface); background: var(--brand); }

/* Audio detail page (Figma 149:31161) */
.detail-audio-layout { display: grid; grid-template-columns: minmax(0,1fr) 256px; align-items: stretch; gap: 32px; direction: var(--doc-flip); }
.detail-audio-layout > .detail-audio-copy { direction: var(--doc-dir); text-align: start; display: flex; flex-direction: column; align-items: flex-start; justify-content: center; }
.detail-audio-layout > .detail-audio-copy h2 { margin: 0 0 10px; color: var(--brand); font-size: 32px; line-height: 1.35; }
.detail-audio-layout > .detail-audio-copy p { margin: 0; color: var(--muted-brand); font-size: 16px; line-height: 28px; }
.detail-audio-cover { position: relative; height: 256px; margin: 0; overflow: hidden; background: var(--canvas); border-radius: 18px; }
.detail-audio-cover img { width: 100%; height: 100%; object-fit: cover; }
/* نسبة الأبيض على هذه الرقعة كانت ٤ تقريبًا فوق صورة فاتحة؛ رفعُ العتامة يجعلها مقروءة مهما كانت الصورة. */
.detail-audio-cover figcaption { position: absolute; bottom: 8px; left: 8px; padding: 3px 9px; color: var(--surface); background: rgba(8,34,24,.78); border-radius: 999px; font-size: 12px; }

.detail-video-frame { position: relative; height: 420px; overflow: hidden; background: #0c2018; border-radius: 20px; }
.detail-video-frame img { width: 100%; height: 100%; object-fit: cover; filter: brightness(.72); }
.detail-video-frame video { display: block; width: 100%; height: 100%; object-fit: contain; background: #0c2018; }
.detail-video-frame iframe { display: block; width: 100%; height: 100%; border: 0; }
.detail-video-copy { padding-top: 28px; }
/* خارج الإطار المقطوع عمدًا: الرسالة داخله كانت تُقصّ فيبقى القارئ أمام صورة معتمة
   لا تقول له شيئًا. */
.detail-missing-file { display: block; margin: 14px 0 0; color: var(--muted-brand); font-size: 14px; }
.detail-card-layout { display: grid; grid-template-columns: minmax(0,1fr) minmax(320px,.82fr); gap: 32px; }
.detail-card-visual { min-width: 0; }
.detail-card-layout figure { position: relative; height: 270px; margin: 0; overflow: hidden; border-radius: 20px; }
.detail-card-layout figure img { width: 100%; height: 100%; object-fit: cover; }
.detail-card-layout > div:not(.detail-card-visual) { display: flex; flex-direction: column; align-items: flex-start; justify-content: center; }
.detail-card-layout h2 { margin: 0 0 10px; font-size: 30px; line-height: 1.4; }
.detail-card-layout p { margin: 0; color: var(--muted-brand); font-size: 16px; line-height: 28px; }
.detail-card-tags { display: flex; gap: 8px; margin-top: 12px; }
.detail-card-tags span { padding: 7px 14px; background: var(--canvas); border-radius: 999px; font-size: 13px; }
.detail-card-image-button { width: 100%; min-height: 48px; margin-top: 10px; color: var(--brand); background: var(--surface); border: 1px solid var(--brand); border-radius: 12px; }

/* Card zoom controls */
.detail-card-zoom-controls { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.detail-card-zoom-controls button { width: 34px; height: 34px; display: grid; place-items: center; color: var(--brand); background: var(--surface); border: 1px solid rgba(27,67,50,.35); border-radius: 50%; font-size: 18px; line-height: 1; }
.detail-card-zoom-controls button:hover,
.detail-card-zoom-controls button:focus-visible { color: var(--surface); background: var(--brand); border-color: var(--brand); }
.detail-card-zoom-controls button:disabled { opacity: .4; cursor: not-allowed; }
.detail-card-zoom-controls span { min-width: 46px; color: var(--muted-brand); font-size: 14px; font-weight: 700; text-align: center; }
.detail-card-zoom-target { font-size: 1em; transition: font-size .15s ease; }
.detail-card-zoom-target h2 { font-size: 1.875em; margin: 0 0 10px; line-height: 1.4; }
.detail-card-zoom-target p { font-size: 1em; margin: 0; color: var(--muted-brand); line-height: 1.75; }
.detail-card-zoom-target .detail-card-tags { font-size: 1em; }

/* In-page book reader: real, native PDF viewing via an embedded <iframe> (Task 1) */
.library-reader-modal { position: fixed; z-index: 1400; inset: 0; display: grid; place-items: center; padding: 24px; background: rgba(10,29,22,.6); }
.library-reader-panel { width: min(720px,100%); max-height: min(720px,86vh); display: flex; flex-direction: column; overflow: hidden; background: var(--surface); border-radius: 22px; box-shadow: 0 30px 70px rgba(10,29,22,.35); direction: var(--doc-dir); text-align: start; }
.library-reader-panel header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 20px 24px; border-bottom: 1px solid var(--line); }
.library-reader-panel header h2 { margin: 0; overflow: hidden; color: var(--brand); font-size: 20px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.library-reader-panel header button { flex-shrink: 0; width: 38px; height: 38px; display: grid; place-items: center; color: var(--brand); background: var(--canvas); border: 0; border-radius: 50%; font-size: 20px; line-height: 1; }
.library-reader-body { padding: 24px; overflow-y: auto; }
.library-reader-body p { margin: 0 0 20px; color: var(--muted-brand); font-size: 16px; line-height: 32px; }
.library-reader-body p:last-child { margin-bottom: 0; }

.library-pdf-panel { width: min(900px,96vw); max-width: 900px; height: min(880px,92vh); max-height: 92vh; }
.library-pdf-toolbar-actions { display: flex; flex-shrink: 0; align-items: center; gap: 10px; }
.library-pdf-toolbar-actions a { flex-shrink: 0; color: var(--brand); font-size: 14px; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; white-space: nowrap; }
.library-pdf-body { flex: 1; min-height: 0; padding: 0; overflow: hidden; background: #4b5259; }
.library-pdf-body iframe { display: block; width: 100%; height: 100%; border: 0; }

.library-detail-body { display: grid; gap: 26px; }
.library-detail-body > section { scroll-margin-top: 96px; }
.library-detail-body h2,
.library-detail-body h3 { margin: 0 0 8px; color: var(--brand); font-weight: 700; }
.library-detail-body h2 { font-size: 24px; }
.library-detail-body h3 { font-size: 20px; }
.library-detail-body p { margin: 0; color: var(--muted-brand); font-size: 16px; line-height: 29px; }
.detail-quote { padding: 0 18px 0 0; border-right: 3px solid var(--accent); font-weight: 700; }
.detail-copy-row { display: flex; gap: 8px; }
.detail-copy-row button { min-height: 44px; padding: 9px 20px; color: var(--brand); background: var(--surface); border: 1px solid var(--brand); border-radius: 12px; }

.library-related { margin-top: 38px; padding-top: 28px; border-top: 1px solid rgba(27,67,50,.1); }
.library-related h2 { margin: 0 0 16px; font-size: 22px; }
.library-related > div { display: grid; gap: 12px; }
.library-related a { min-height: 62px; display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; gap: 12px; padding: 14px 18px; color: var(--brand); border: 1px solid var(--line); border-radius: 14px; }
.library-related a:first-child { min-height: 100px; align-items: end; }
.library-related a strong { font-size: 16px; }
.library-related a span { color: var(--muted-brand); font-size: 12px; }

.library-lightbox { position: fixed; z-index: 1300; inset: 0; display: grid; place-items: center; padding: 40px; background: rgba(10,29,22,.86); }
.library-lightbox img { max-width: min(1100px,92vw); max-height: 88vh; object-fit: contain; border-radius: 18px; transition: transform .15s ease; }
.library-lightbox > button[data-close-lightbox] { position: fixed; top: 24px; left: 24px; width: 46px; height: 46px; color: var(--brand); background: var(--surface); border: 0; border-radius: 50%; font-size: 26px; }

/* Full-size image lightbox zoom controls (Task 2) — separate from the card-detail zoom controls */
.library-lightbox-zoom-controls { position: fixed; top: 24px; right: 24px; display: flex; align-items: center; gap: 10px; padding: 6px; background: var(--surface); border-radius: 999px; box-shadow: 0 12px 30px rgba(10,29,22,.3); }
.library-lightbox-zoom-controls button { width: 36px; height: 36px; display: grid; place-items: center; color: var(--brand); background: var(--canvas); border: 0; border-radius: 50%; font-size: 18px; line-height: 1; }
.library-lightbox-zoom-controls button:hover,
.library-lightbox-zoom-controls button:focus-visible { color: var(--surface); background: var(--brand); }
.library-lightbox-zoom-controls button:disabled { opacity: .4; cursor: not-allowed; }
.library-lightbox-zoom-controls span { min-width: 44px; color: var(--brand); font-size: 14px; font-weight: 700; text-align: center; }
.library-toast { position: fixed; z-index: 1500; bottom: 24px; left: 24px; max-width: min(420px,calc(100vw - 48px)); padding: 13px 18px; color: var(--surface); background: var(--brand); border-radius: 13px; box-shadow: 0 16px 44px rgba(17,50,37,.2); font-size: 15px; }

/* Published analysis */
.library-analysis-main { width: min(1040px,calc(100% - 64px)); display: grid; grid-template-columns: 260px minmax(0,1fr); grid-template-areas: "aside content"; gap: 24px; margin: 0 auto; padding: 48px 0 96px; direction: var(--doc-flip); }
.analysis-contents-aside { grid-area: aside; position: sticky; top: 96px; align-self: start; display: grid; gap: 16px; direction: var(--doc-dir); }
.analysis-contents-aside nav,
.analysis-contents-aside > div { display: grid; gap: 8px; padding: 22px; border: 1px solid rgba(27,67,50,.14); border-radius: 20px; }
.analysis-contents-aside strong { margin-bottom: 3px; color: var(--muted-brand); font-size: 14px; }
.analysis-contents-aside a { padding: 7px; color: var(--brand); font-size: 14px; }
.analysis-contents-aside button,
.analysis-contents-aside > div a { min-height: 42px; display: grid; place-items: center; color: var(--brand); background: var(--surface); border: 1px solid var(--brand); border-radius: 11px; font-size: 13px; }
.analysis-published-content { grid-area: content; min-width: 0; display: grid; gap: 38px; direction: var(--doc-dir); text-align: start; }
.analysis-published-header > div { display: flex; flex-direction: row-reverse; justify-content: flex-start; align-items: center; gap: 8px; }
.analysis-published-header span { padding: 8px 16px; color: var(--accent); background: rgba(212,134,11,.14); border-radius: 999px; font-size: 13px; }
.analysis-published-header small { color: var(--muted-brand); }
.analysis-published-header h2 { margin: 14px 0 4px; font-size: 38px; line-height: 1.35; }
.analysis-published-header p { margin: 0; color: var(--muted-brand); font-size: 16px; }
.analysis-published-content section { scroll-margin-top: 96px; }
.analysis-published-content h3 { margin: 0 0 9px; font-size: 24px; }
.analysis-published-content p { margin: 0; color: var(--muted-brand); font-size: 16px; line-height: 29px; }
.analysis-summary-box { padding: 24px 30px; background: var(--canvas); border-radius: 20px; }
.analysis-summary-box span { display: block; margin-bottom: 6px; color: var(--muted-brand); font-size: 14px; font-weight: 700; }
.analysis-points { display: grid; gap: 14px; }
.analysis-points article { padding: 16px; border: 1px solid var(--line); border-radius: 14px; }
.analysis-points strong { display: block; margin-bottom: 4px; font-size: 15px; }
.analysis-source > div { display: flex; align-items: center; justify-content: space-between; }
.analysis-source button { color: var(--brand); background: transparent; border: 0; font-size: 13px; }
.analysis-source p { padding: 16px; background: var(--canvas); border-radius: 14px; }
.analysis-wording { padding: 24px; border: 1px solid var(--line); border-radius: 18px; }
.analysis-wording button { min-height: 44px; margin-top: 16px; padding: 8px 18px; color: var(--brand); background: var(--surface); border: 1px solid var(--brand); border-radius: 11px; }
.analysis-references { display: grid; gap: 12px; }
.analysis-references h3 { margin-bottom: 2px; }
.analysis-references a { min-height: 72px; display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 3px 16px; align-items: center; padding: 14px 18px; color: var(--brand); border: 1px solid var(--line); border-radius: 14px; }
.analysis-references a small { color: var(--muted-brand); }
.analysis-references a b { grid-column: 2; grid-row: 1 / span 2; text-decoration: underline; }
.analysis-references > p { font-size: 13px; }
.analysis-training-cta { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 24px; background: var(--canvas); border-radius: 18px; }
.analysis-training-cta div { display: grid; gap: 2px; }
.analysis-training-cta span { color: var(--muted-brand); font-size: 13px; }
.analysis-training-cta .btn { min-width: 150px; }
.analysis-review-note { padding: 22px; background: var(--canvas); border: 1px solid var(--line); border-radius: 18px; }
.analysis-review-note strong { display: block; margin-bottom: 5px; }

@media (max-width: 1199.98px) {
  .library-app,
  .sidebar-collapsed .library-app { width: 100%; margin-right: 0; }
  .library-header-title { margin-left: auto; }
  .library-index-main { width: calc(100% - 48px); }
  .library-index-hero { grid-template-columns: minmax(0,1fr) 330px; }
  .library-card-grid,
  .library-media-grid,
  .library-book-grid,
  .library-short-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .library-audio-list { grid-template-columns: 1fr; }
  .library-detail-main,
  .library-analysis-main { width: calc(100% - 40px); grid-template-columns: 250px minmax(0,1fr); }
  .detail-media-split,
  .detail-audio-layout { grid-template-columns: minmax(0,1fr) 220px; }
}

@media (max-width: 991.98px) {
  /* العمود الجانبي يصير طيًّا فوق النتائج: الشاشة الضيّقة لا تحتمل عمودين. */
  .library-browse { grid-template-columns: minmax(0, 1fr); }
  .library-filter-rail { position: static; }

  .library-header-actions { gap: 8px; }
  .library-language { min-width: 82px; height: 40px; padding-inline: 14px; font-size: 14px; }
  .library-back-link { display: none; }
  .library-index-main { width: calc(100% - 40px); padding-top: 40px; }
  .library-index-hero { grid-template-columns: 1fr; }
  .library-index-hero figure { order: -1; }
  .library-detail-main,
  .library-analysis-main { grid-template-columns: 1fr; grid-template-areas: "content" "aside"; }
  .library-content-aside,
  .analysis-contents-aside { position: static; }
  .detail-video-frame { height: 360px; }
  .library-reader-panel { max-height: 88vh; }
}

@media (max-width: 700px) {
  .library-header-title h1 { max-width: 170px; font-size: 17px; }
  .library-header-title p { display: none; }
  .library-avatar { display: none; }
  .library-index-hero h2 { font-size: 28px; }
  .library-index-hero p { font-size: 15px; line-height: 25px; }
  .library-type-filters button { padding-inline: 18px; }
  .library-card-grid,
  .library-media-grid,
  .library-book-grid,
  .library-short-grid { grid-template-columns: 1fr; }
  .library-featured-book { grid-template-columns: 1fr; }
  .library-featured-book figure { min-height: 220px; }
  .library-article-item { grid-template-columns: 110px minmax(0,1fr); gap: 14px; }
  .library-article-item img { width: 110px; height: 90px; }
  .library-no-results { padding: 28px 22px; }
  .library-no-results > div { flex-direction: column; }
  .library-detail-main,
  .library-analysis-main { width: calc(100% - 32px); padding-top: 28px; }
  .library-detail-tags { margin-bottom: 20px; }
  .detail-question-box { padding: 22px; }
  .detail-question-box h2 { font-size: 24px; line-height: 36px; }
  .detail-media-split,
  .detail-audio-layout,
  .detail-card-layout { grid-template-columns: 1fr; }
  .detail-audio-layout { direction: var(--doc-dir); }
  .detail-media-image,
  .detail-audio-cover { order: -1; }
  .detail-video-frame { height: 250px; }
  .detail-media-split h2,
  .detail-audio-layout h2,
  .detail-video-copy h2 { font-size: 26px; }
  .detail-action-row { flex-wrap: wrap; }
  .library-lightbox { padding: 16px; }
  .analysis-published-header h2 { font-size: 30px; }
  .analysis-training-cta { align-items: stretch; flex-direction: column; }
  .library-reader-modal { padding: 0; }
  .library-reader-panel { width: 100%; max-width: 100%; height: 100%; max-height: 100%; border-radius: 0; }
  .detail-card-zoom-controls { flex-wrap: wrap; }
}

@media (prefers-reduced-motion: reduce) {
  .library-app,
  .library-header,
  .detail-card-zoom-target { transition: none; }
}

/* منتدى الدعاة: ما يرفعه الأعضاء ويعتمده المشرف، في قسم يُعرف باسمه. */
.library-community {
  margin: 48px 0 0;
}

.library-community-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.library-community-heading span {
  color: var(--gold);
  font-size: 14px;
  font-weight: 700;
}

.library-community-heading h2 {
  margin: 4px 0 6px;
  color: var(--brand);
  font-size: 26px;
  font-weight: 700;
}

.library-community-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 24px;
}

.library-community-heading a {
  flex-shrink: 0;
  color: var(--brand);
  font-size: 15px;
  font-weight: 700;
  text-decoration: none;
}

.library-community-heading a:hover {
  text-decoration: underline;
}

.library-community-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.library-community-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 20px;
  background: var(--surface);
  border: 1px solid rgba(27, 67, 50, 0.14);
  border-radius: 18px;
  transition: border-color 0.2s ease, transform 0.2s ease;
}

.library-community-card:hover {
  border-color: var(--brand);
  transform: translateY(-1px);
}

.library-community-card a {
  color: inherit;
  text-decoration: none;
}

.library-community-label {
  display: inline-block;
  padding: 4px 10px;
  background: var(--canvas);
  border-radius: 999px;
  color: var(--brand);
  font-size: 12px;
  font-weight: 700;
}

.library-community-card h3 {
  margin: 10px 0 6px;
  color: var(--brand);
  font-size: 18px;
  font-weight: 700;
  line-height: 28px;
}

.library-community-card p {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 15px;
  line-height: 24px;
}

.library-community-card footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid rgba(27, 67, 50, 0.1);
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 767.98px) {
  .library-community-heading {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* الزائر يقرأ المادة بالواجهة العامة: لا قائمة جانبية تزيح المحتوى عن حافّته،
   ولا ترويسة لاصقة ثانية تحت ترويسة الموقع. */
.library-public-page .library-app,
.library-public-page.sidebar-collapsed .library-app { width: 100%; margin-right: 0; }
.library-public-page .library-header { position: static; }

/* تكبير البطاقة: الصورة تُكبَّر داخل إطارها، والعنوان يبقى بحجمه. */
.detail-card-visual figure[data-card-zoom-target] img { transform: scale(var(--card-zoom, 1)); transition: transform .15s ease; }
