:root {
  --site-font-family: Tahoma, Arial, "Segoe UI", sans-serif;
  --reader-text-size: 1.13rem;
  --reader-line-height: 2.18;
  color-scheme: light;
}

html {
  width: 100%;
  max-width: 100%;
  scroll-behavior: smooth;
  background: #eef1e8;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
html[data-reader-font='system'] { --site-font-family: "Segoe UI", Tahoma, Arial, sans-serif; }
html[data-reader-font='tahoma'] { --site-font-family: Tahoma, Arial, "Segoe UI", sans-serif; }
html[data-reader-font='arial'] { --site-font-family: Arial, Tahoma, "Segoe UI", sans-serif; }
html[data-reader-font='traditional'] { --site-font-family: "Traditional Arabic", "Sakkal Majalla", Tahoma, serif; }
html[data-reader-size='small'] { --reader-text-size: 1rem; --reader-line-height: 2; }
html[data-reader-size='normal'] { --reader-text-size: 1.13rem; --reader-line-height: 2.18; }
html[data-reader-size='large'] { --reader-text-size: 1.32rem; --reader-line-height: 2.25; }
html[data-reader-size='xlarge'] { --reader-text-size: 1.52rem; --reader-line-height: 2.35; }
html[data-theme='dark'] { color-scheme: dark; background: #111713; }

*, *::before, *::after { box-sizing: border-box; }
body {
  width: 100%;
  max-width: 100%;
  min-width: 320px;
  margin: 0;
  overflow-x: clip;
  background: #eef1e8;
  background-image: linear-gradient(180deg, rgba(255,255,255,.62), rgba(255,255,255,0) 280px);
  color: #182119;
  font-family: var(--site-font-family);
  text-rendering: optimizeLegibility;
}
[data-theme='dark'] body { background: #111713; background-image: none; color: #eef5ec; }
button, input, select, textarea { max-width: 100%; min-width: 0; font: inherit; }
button { cursor: pointer; }
a { color: inherit; }
button, a, select { touch-action: manipulation; }
img, svg, video, canvas, iframe { max-width: 100%; height: auto; }
mark { border-radius: 2px; background: #ffe88a; padding-inline: .15em; color: #1d241d; }

.site-shell { min-height: 100vh; padding: 14px; }
.classic-container {
  width: 100%;
  max-width: 1260px;
  margin-inline: auto;
  overflow: hidden;
  border: 1px solid #b5c2a8;
  background: #f5f0dc;
  box-shadow: 0 12px 30px rgba(31,53,34,.12);
}
[data-theme='dark'] .classic-container { border-color: #405a45; background: #213126; box-shadow: 0 16px 38px rgba(0,0,0,.32); }
.top-preferences { display: flex; justify-content: flex-end; border-bottom: 1px solid #c3cfb6; background: #fffef8; padding: 8px 12px; }
[data-theme='dark'] .top-preferences { border-color: #405a45; background: #17221a; }

.site-header { position: relative; border-bottom: 1px solid #c3cfb6; background: #c4b895; }
[data-theme='dark'] .site-header { border-color: #405a45; }
.site-header img { display: block; width: 100%; min-height: 74px; height: auto; object-fit: contain; background: #c4b895; }
.skip-link { position: absolute; top: 8px; right: -999px; z-index: 20; background: #123f2d; padding: 8px 10px; color: #fff; }
.skip-link:focus { right: 8px; }

.legacy-menu {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 2px;
  border-bottom: 2px solid #b9913f;
  background: linear-gradient(to bottom, #307653, #174932);
  padding: 4px;
}
.legacy-menu a {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  border: 1px solid rgba(255,255,255,.15);
  background: rgba(255,255,255,.1);
  padding-inline: 12px;
  color: #fff8d6;
  font-weight: 700;
  text-decoration: none;
}
.legacy-menu a:hover, .legacy-menu a.active { background: #fff8d6; color: #174932; }

.toolbar-row {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid #c3cfb6;
  background: rgba(245,240,220,.95);
  padding: 10px;
  box-shadow: 0 8px 18px rgba(31,53,34,.08);
}
[data-theme='dark'] .toolbar-row { border-color: #405a45; background: rgba(33,49,38,.95); }
.search-box, .reader-search-box {
  display: flex;
  min-width: 0;
  min-height: 40px;
  align-items: center;
  gap: 8px;
  border: 1px solid #c3cfb6;
  background: #fffef8;
  padding: 4px 8px;
  color: #123f2d;
}
.search-box { flex: 1 1 auto; }
[data-theme='dark'] .search-box, [data-theme='dark'] .reader-search-box { border-color: #405a45; background: #17221a; color: #d9ecd8; }
.search-box input, .reader-search-box input { min-width: 0; flex: 1 1 auto; border: 0; outline: 0; background: transparent; color: #182119; }
[data-theme='dark'] .search-box input, [data-theme='dark'] .reader-search-box input { color: #eef5ec; }
.search-submit, .small-button, .secondary-button {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  justify-content: center;
  border: 1px solid #c3cfb6;
  background: #fffef8;
  padding-inline: 12px;
  color: #123f2d;
  font-weight: 700;
  text-decoration: none;
}
.search-submit:hover, .small-button:hover, .secondary-button:hover { background: #eaf2e3; }
[data-theme='dark'] .search-submit, [data-theme='dark'] .small-button, [data-theme='dark'] .secondary-button { border-color: #405a45; background: #17221a; color: #d9ecd8; }
[data-theme='dark'] .search-submit:hover, [data-theme='dark'] .small-button:hover, [data-theme='dark'] .secondary-button:hover { background: #263b2d; }

.reader-preferences { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; }
.theme-choice { display: inline-flex; min-height: 36px; overflow: hidden; border: 1px solid #c3cfb6; background: #fffef8; }
[data-theme='dark'] .theme-choice { border-color: #405a45; background: #17221a; }
.theme-choice button { min-height: 36px; border: 0; background: transparent; padding-inline: 12px; color: #123f2d; font-weight: 700; }
.theme-choice button:hover { background: #eaf2e3; }
.theme-choice button.active { background: #123f2d; color: #fff8d6; }
[data-theme='dark'] .theme-choice button { color: #d9ecd8; }
[data-theme='dark'] .theme-choice button:hover { background: #263b2d; }
[data-theme='dark'] .theme-choice button.active { background: #d9ecd8; color: #123f2d; }
.preference-select { display: inline-flex; min-height: 36px; align-items: center; gap: 6px; border: 1px solid #c3cfb6; background: #fffef8; padding-inline: 8px; color: #123f2d; }
[data-theme='dark'] .preference-select { border-color: #405a45; background: #17221a; color: #d9ecd8; }
.preference-select span { font-size: .875rem; font-weight: 700; }
.preference-select select { height: 32px; border: 0; outline: 0; background: transparent; color: #182119; font-weight: 700; }
[data-theme='dark'] .preference-select select { color: #eef5ec; }
[data-theme='dark'] .preference-select option { background: #17221a; color: #eef5ec; }
.menu-button, .scrim, .close-button { display: none; }

.main-grid { display: grid; grid-template-columns: minmax(0,1fr) 230px; align-items: start; gap: 12px; padding: 12px; direction: ltr; }
.main-grid.reader-mode { grid-template-columns: minmax(0,1fr); }
.main-grid.reader-mode .content-area { grid-column: 1 / -1; }
.content-area { grid-column: 1; grid-row: 1; display: grid; width: 100%; min-width: 0; gap: 12px; direction: rtl; }
.right-index, .old-box { border: 1px solid #c3cfb6; background: #fffef8; box-shadow: 0 4px 10px rgba(31,53,34,.06); }
[data-theme='dark'] .right-index, [data-theme='dark'] .old-box { border-color: #405a45; background: #17221a; }
.right-index { position: sticky; top: 12px; grid-column: 2; grid-row: 1; width: 100%; min-width: 0; max-height: calc(100vh - 24px); overflow: auto; padding: 8px; direction: rtl; }

.box-title, .old-box-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; border-bottom: 1px solid #c3cfb6; background: linear-gradient(to bottom, #eaf2e3, #f5f0dc); padding: 8px 12px; color: #123f2d; }
[data-theme='dark'] .box-title, [data-theme='dark'] .old-box-head { border-color: #405a45; background: linear-gradient(to bottom, #263b2d, #213126); color: #d9ecd8; }
.old-box-head a { color: #2f6678; font-weight: 700; }
[data-theme='dark'] .old-box-head a { color: #9ac8d6; }

.index-link { display: flex; width: 100%; min-height: 38px; align-items: center; justify-content: space-between; gap: 8px; margin-top: 4px; border: 1px solid transparent; padding-inline: 8px; color: #182119; text-align: right; text-decoration: none; }
.index-link:hover, .index-link.active { border-color: #c3cfb6; background: #eaf2e3; color: #123f2d; }
[data-theme='dark'] .index-link { color: #eef5ec; }
[data-theme='dark'] .index-link:hover, [data-theme='dark'] .index-link.active { border-color: #405a45; background: #263b2d; color: #d9ecd8; }
.index-link span { min-width: 0; overflow-wrap: break-word; }
.index-link b { color: #8b342b; }
[data-theme='dark'] .index-link b { color: #e6a090; }
.old-note { margin-top: 10px; border: 1px dashed #c3cfb6; background: #f5f0dc; padding: 10px; color: #63705f; line-height: 1.75rem; }
.old-note strong { color: #123f2d; }
[data-theme='dark'] .old-note { border-color: #405a45; background: #213126; color: #b1bdaf; }
[data-theme='dark'] .old-note strong { color: #d9ecd8; }

.category-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; border-top: 4px solid #246448; background: linear-gradient(to bottom, #fffef8, #f5f0dc); padding: 16px; }
[data-theme='dark'] .category-heading { border-top-color: #91c49c; background: linear-gradient(to bottom, #17221a, #213126); }
.category-heading h1, .category-heading strong { display: block; margin: 0; color: #123f2d; font-size: clamp(1.35rem, 2.4vw, 2rem); line-height: 1.6; }
[data-theme='dark'] .category-heading h1, [data-theme='dark'] .category-heading strong { color: #d9ecd8; }
.category-heading p { margin: 4px 0 0; color: #63705f; line-height: 2rem; }
[data-theme='dark'] .category-heading p { color: #b1bdaf; }
.category-heading > span { flex-shrink: 0; border: 1px solid #c3cfb6; background: #fffef8; padding: 6px 12px; color: #8b342b; font-weight: 700; }
[data-theme='dark'] .category-heading > span { border-color: #405a45; background: #17221a; color: #e6a090; }

.search-results, .catalog, .article-list, .reader { padding-bottom: 10px; }
.result-list, .article-cards { display: grid; gap: 8px; padding: 10px; }
.result-list { max-height: 520px; overflow: auto; }
.result-card, .article-card { display: grid; gap: 6px; border: 1px solid #c3cfb6; background: #f5f0dc; padding: 12px; color: #182119; text-align: right; text-decoration: none; }
.result-card:hover, .article-card:hover { background: #eaf2e3; }
[data-theme='dark'] .result-card, [data-theme='dark'] .article-card { border-color: #405a45; background: #213126; color: #eef5ec; }
[data-theme='dark'] .result-card:hover, [data-theme='dark'] .article-card:hover { background: #263b2d; }
.result-meta, .article-card span { color: #8b342b; font-size: .875rem; font-weight: 700; }
[data-theme='dark'] .result-meta, [data-theme='dark'] .article-card span { color: #e6a090; }
.result-title, .article-card strong { overflow-wrap: break-word; color: #123f2d; line-height: 1.75rem; }
[data-theme='dark'] .result-title, [data-theme='dark'] .article-card strong { color: #d9ecd8; }
.result-page-title { color: #182119; font-weight: 700; line-height: 1.75rem; }
[data-theme='dark'] .result-page-title { color: #eef5ec; }
.result-snippet, .article-card small { color: #63705f; line-height: 2rem; }
[data-theme='dark'] .result-snippet, [data-theme='dark'] .article-card small { color: #b1bdaf; }
.article-cards.compact { grid-template-columns: repeat(2, minmax(0,1fr)); }
.state-line { margin: 0; padding: 20px; color: #63705f; text-align: center; font-weight: 700; }
[data-theme='dark'] .state-line { color: #b1bdaf; }

.catalog-section { padding: 10px; }
.catalog-section h2 { margin: 0 0 6px; border-right: 4px solid #246448; background: #eaf2e3; padding: 6px 10px; color: #123f2d; font-size: 1.02rem; text-align: right; }
[data-theme='dark'] .catalog-section h2 { border-color: #91c49c; background: #263b2d; color: #d9ecd8; }
.classic-table { width: 100%; table-layout: fixed; border-collapse: collapse; border: 1px solid #c3cfb6; direction: rtl; }
.classic-table .title-col { width: auto; }
.classic-table .type-col { width: 7rem; }
.classic-table .pages-col, .classic-table .open-col { width: 5rem; }
.classic-table th { border: 1px solid #c3cfb6; background: linear-gradient(to bottom, #337a56, #1d573d); padding: 8px; color: #fff8d6; text-align: right; font-weight: 700; }
.classic-table td { border: 1px solid #c3cfb6; background: #fffef8; padding: 6px 8px; color: #182119; text-align: right; vertical-align: middle; line-height: 1.5rem; }
.classic-table th:nth-child(3), .classic-table th:nth-child(4), .classic-table td:nth-child(3), .classic-table td:nth-child(4) { text-align: center; }
.classic-table tbody tr:nth-child(odd) td { background: #f5f0dc; }
.classic-table tbody tr:hover td { background: #eaf2e3; }
[data-theme='dark'] .classic-table, [data-theme='dark'] .classic-table th, [data-theme='dark'] .classic-table td { border-color: #405a45; }
[data-theme='dark'] .classic-table td { background: #17221a; color: #eef5ec; }
[data-theme='dark'] .classic-table tbody tr:nth-child(odd) td { background: #213126; }
[data-theme='dark'] .classic-table tbody tr:hover td { background: #263b2d; }
.book-title-cell { text-align: right; }
.book-title { display: block; overflow-wrap: break-word; color: #123f2d; font-weight: 700; line-height: 1.75rem; text-decoration: none; word-break: normal; }
.book-title:hover { text-decoration: underline; }
[data-theme='dark'] .book-title { color: #d9ecd8; }
.open-pill { display: inline-flex; min-width: 48px; min-height: 24px; align-items: center; justify-content: center; border: 1px solid #c3cfb6; background: #fffef8; padding-inline: 8px; color: #123f2d; font-size: .875rem; text-decoration: none; }
.open-pill:hover { background: #eaf2e3; }
[data-theme='dark'] .open-pill { border-color: #405a45; background: #17221a; color: #d9ecd8; }

.reader-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid #c3cfb6; background: #f5f0dc; padding: 12px; }
[data-theme='dark'] .reader-top { border-color: #405a45; background: #213126; }
.reader-title { display: grid; min-width: 0; gap: 4px; }
.reader-title h1 { margin: 0; overflow-wrap: break-word; color: #123f2d; font-size: clamp(1.25rem, 2.2vw, 1.8rem); line-height: 1.7; }
[data-theme='dark'] .reader-title h1 { color: #d9ecd8; }
.reader-title span { color: #63705f; line-height: 1.75rem; }
[data-theme='dark'] .reader-title span { color: #b1bdaf; }
.reader-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.reader-grid { display: grid; grid-template-columns: minmax(0,1fr); gap: 12px; padding: 12px; }
.reader-index { display: none; }
.reader-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; border: 1px solid #c3cfb6; background: #f5f0dc; padding: 10px; }
[data-theme='dark'] .reader-tools { border-color: #405a45; background: #213126; }
.reader-page-status { display: flex; min-width: 220px; flex: 1 1 0; flex-wrap: wrap; align-items: center; column-gap: 12px; row-gap: 4px; line-height: 1.75rem; }
.reader-page-status strong { color: #8b342b; }
[data-theme='dark'] .reader-page-status strong { color: #e6a090; }
.reader-page-status span { min-width: 0; overflow-wrap: break-word; color: #63705f; }
[data-theme='dark'] .reader-page-status span { color: #b1bdaf; }
.page-jump { display: flex; min-height: 40px; align-items: center; gap: 8px; border: 1px solid #c3cfb6; background: #fffef8; padding: 4px 8px; }
[data-theme='dark'] .page-jump { border-color: #405a45; background: #17221a; }
.page-jump label { color: #123f2d; font-weight: 700; }
[data-theme='dark'] .page-jump label { color: #d9ecd8; }
.page-jump input { width: 80px; height: 32px; border: 1px solid #c3cfb6; outline: 0; background: #fff; padding-inline: 8px; color: #182119; text-align: center; }
[data-theme='dark'] .page-jump input { border-color: #405a45; background: #111713; color: #eef5ec; }
.reader-page-map { width: 100%; border: 1px solid #c3cfb6; background: #fffef8; padding: 8px 10px; }
[data-theme='dark'] .reader-page-map { border-color: #405a45; background: #17221a; }
.reader-page-map summary { cursor: pointer; user-select: none; color: #123f2d; font-weight: 700; }
[data-theme='dark'] .reader-page-map summary { color: #d9ecd8; }
.reader-page-map[open] summary { margin-bottom: 8px; border-bottom: 1px solid #c3cfb6; padding-bottom: 8px; }
[data-theme='dark'] .reader-page-map[open] summary { border-color: #405a45; }
.reader-search-box.compact { width: 100%; margin-bottom: 8px; }
.page-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px,1fr)); max-height: 360px; gap: 6px; overflow: auto; padding: 4px; }
.page-list a { display: grid; grid-template-columns: 34px minmax(0,1fr); min-height: 42px; align-items: center; gap: 8px; border: 1px solid #c3cfb6; background: #fffef8; padding: 6px; color: #182119; text-align: right; text-decoration: none; }
.page-list a:hover, .page-list a.active { background: #eaf2e3; color: #123f2d; }
[data-theme='dark'] .page-list a { border-color: #405a45; background: #17221a; color: #eef5ec; }
[data-theme='dark'] .page-list a:hover, [data-theme='dark'] .page-list a.active { background: #263b2d; color: #d9ecd8; }
.page-list b { display: grid; width: 30px; height: 30px; place-items: center; border-radius: 50%; background: #f5f0dc; color: #8b342b; }
[data-theme='dark'] .page-list b { background: #213126; color: #e6a090; }
.page-list span { min-width: 0; overflow-wrap: break-word; font-size: .875rem; line-height: 1.5rem; }
.reader-page { position: relative; min-height: 560px; scroll-margin-top: 74px; border: 1px solid #c3cfb6; background: #fffef8; padding: clamp(14px,2.2vw,30px); }
.reader-page:focus { outline: none; }
[data-theme='dark'] .reader-page { border-color: #405a45; background: #17221a; }
.reader-page h2 { margin: 12px 0 16px; border-bottom: 1px solid #c3cfb6; padding-bottom: 10px; color: #8b342b; font-size: clamp(1.25rem,2.2vw,1.65rem); line-height: 1.7; text-align: center; }
[data-theme='dark'] .reader-page h2 { border-color: #405a45; color: #e6a090; }
.reader-page > .pager { display: none; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 8px; border: 1px solid #c3cfb6; background: #f5f0dc; padding: 8px; color: #123f2d; }
[data-theme='dark'] .pager { border-color: #405a45; background: #213126; color: #d9ecd8; }
.pager.bottom { margin-top: 16px; }
.pager a { display: flex; min-height: 34px; align-items: center; border: 1px solid #c3cfb6; background: #fffef8; padding-inline: 10px; color: #123f2d; font-weight: 700; text-decoration: none; }
[data-theme='dark'] .pager a { border-color: #405a45; background: #17221a; color: #d9ecd8; }
.pager a.disabled { pointer-events: none; opacity: .45; }
.floating-pager { position: fixed; inset: 0; z-index: 30; display: none; pointer-events: none; }
.reader-mode .floating-pager { display: block; }
.floating-page { position: fixed; top: 50%; display: grid; width: 56px; height: 56px; place-items: center; border: 1px solid #c3cfb6; background: rgba(255,254,248,.95); color: #123f2d; font-size: 1.5rem; font-weight: 700; text-decoration: none; pointer-events: auto; transform: translateY(-50%); box-shadow: 0 8px 22px rgba(31,53,34,.2); }
.floating-page:hover { background: #eaf2e3; }
[data-theme='dark'] .floating-page { border-color: #405a45; background: rgba(23,34,26,.95); color: #d9ecd8; }
[data-theme='dark'] .floating-page:hover { background: #263b2d; }
.floating-page-prev { right: 16px; }
.floating-page-next { left: 16px; }
.floating-page.disabled { display: none; }
.floating-page span { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.floating-arrow { direction: ltr; unicode-bidi: isolate; }
.floating-page-prev .floating-arrow::before { content: ">"; }
.floating-page-next .floating-arrow::before { content: "<"; }
.page-scroll-controls { position: fixed; right: 18px; bottom: 20px; z-index: 31; display: grid; gap: 8px; }
.page-scroll-button { display: grid; width: 42px; height: 42px; place-items: center; border: 1px solid #c3cfb6; border-radius: 50%; background: rgba(255,254,248,.96); color: #123f2d; font-size: 1.15rem; font-weight: 800; line-height: 1; box-shadow: 0 6px 18px rgba(31,53,34,.18); }
.page-scroll-button:hover, .page-scroll-button:focus-visible { background: #eaf2e3; outline: 2px solid #b9913f; outline-offset: 2px; }
[data-theme='dark'] .page-scroll-button { border-color: #405a45; background: rgba(23,34,26,.96); color: #d9ecd8; }
[data-theme='dark'] .page-scroll-button:hover, [data-theme='dark'] .page-scroll-button:focus-visible { background: #263b2d; }
.page-body { width: 100%; max-width: 980px; margin-inline: auto; color: #182119; font-size: var(--reader-text-size); line-height: var(--reader-line-height); }
[data-theme='dark'] .page-body { color: #eef5ec; }
.paragraph { margin: 0 0 16px; overflow-wrap: break-word; text-align: justify; }
.subhead { margin: 20px 0 10px; border-right: 4px solid #246448; background: #eaf2e3; padding: 8px 10px; color: #123f2d; font-size: 1.18rem; line-height: 1.75rem; }
[data-theme='dark'] .subhead { border-color: #91c49c; background: #263b2d; color: #d9ecd8; }
.title-block { margin-block: 12px; border: 1px solid #c3cfb6; background: #f5f0dc; padding: 16px; color: #123f2d; font-size: 1.42rem; font-weight: 700; line-height: 2; text-align: center; }
[data-theme='dark'] .title-block { border-color: #405a45; background: #213126; color: #d9ecd8; }
.reader-aia, .article-ayah { color: #22560b; font-family: "Traditional Arabic", Tahoma, serif; font-weight: 700; }
[data-theme='dark'] .reader-aia, [data-theme='dark'] .article-ayah { color: #a8d98e; }
.reader-note { color: #2f6678; font-weight: 700; }
[data-theme='dark'] .reader-note { color: #9ac8d6; }
.reader-side-note { color: #8a6d2c; font-weight: 700; }
.caption { color: #8b342b; text-align: center; font-weight: 700; }
[data-theme='dark'] .caption { color: #e6a090; }
.reader-figure { margin-block: 16px; text-align: center; }
.reader-figure img { display: inline-block; max-width: 100%; max-height: 520px; border: 1px solid #c3cfb6; background: #f5f0dc; object-fit: contain; padding: 4px; }
[data-theme='dark'] .reader-figure img { border-color: #405a45; background: #213126; }
.reader-figure figcaption { margin-top: 8px; color: #8b342b; font-weight: 700; line-height: 1.75rem; }
[data-theme='dark'] .reader-figure figcaption { color: #e6a090; }

.poem-block { width: min(100%,900px); margin: 24px auto; overflow-x: auto; border: 1px solid #c3cfb6; border-top: 3px solid #b9913f; background: linear-gradient(to bottom,#f5f0dc,#fffef8); padding: 16px; }
.js .poem-block.poem-pending { visibility: hidden; }
.poem-block.poem-ready { visibility: visible; }
[data-theme='dark'] .poem-block { border-color: #405a45; border-top-color: #d7bc75; background: linear-gradient(to bottom,#213126,#17221a); }
.poem-line { display: grid; grid-template-columns: 350px 350px; min-width: 760px; min-height: 40px; align-items: center; justify-content: center; gap: 28px; color: #123f2d; font-family: "Traditional Arabic", Tahoma, serif; font-size: 1.38rem; font-weight: 700; text-align: center; }
[data-theme='dark'] .poem-line { color: #d9ecd8; }
.poem-line + .poem-line { border-top: 1px dotted rgba(139,123,71,.4); }
.poem-line span { display: inline-block; width: fit-content; justify-self: center; white-space: nowrap; line-height: 1.9; direction: rtl; unicode-bidi: plaintext; }
.poem-line span:first-child { border-left: 1px solid #c3cfb6; padding-left: 24px; }
[data-theme='dark'] .poem-line span:first-child { border-color: #405a45; }
.poem-line-single { grid-template-columns: minmax(0,1fr); min-width: 0; color: #8b342b; }
[data-theme='dark'] .poem-line-single { color: #e6a090; }
.poem-line-single span:first-child { border-left: 0; padding-left: 0; }

.article-body blockquote, .article-hadith { margin-block: 16px; border-right: 4px solid #b9913f; background: #f7f1d5; padding: 12px 16px; color: #123f2d; font-weight: 700; }
.article-note { margin-block: 16px; border: 1px solid #d8c98b; background: #fff8dc; padding: 10px 14px; color: #70441d; }
.article-benefit { margin-block: 16px; border-right: 4px solid #246448; background: #edf5e5; padding: 10px 14px; color: #123f2d; }
.article-centered { color: #123f2d; text-align: center; font-weight: 700; }
.article-large { font-size: 1.35em; font-weight: 700; }
.article-small { color: #63705f; font-size: .92em; }
.article-code { overflow: auto; border-radius: 4px; background: #172219; padding: 12px; color: #f4f7e8; text-align: left; line-height: 1.75rem; direction: ltr; white-space: pre-wrap; }
.article-body table { display: block; width: 100%; margin-block: 16px; overflow-x: auto; border-collapse: collapse; }
.article-body th, .article-body td { border: 1px solid #c3cfb6; padding: 6px 8px; }
.article-body th { background: #f5f0dc; color: #123f2d; }

.site-shell, .classic-container, .top-preferences, .site-header, .legacy-menu, .toolbar-row, .main-grid, .content-area, .right-index, .old-box, .catalog, .catalog-section, .reader, .reader-grid, .reader-tools, .reader-page, .page-body, .book-title, .result-card, .article-card { min-width: 0; max-width: 100%; }
.page-body, .paragraph, .result-snippet, .reader-title, .reader-page-status, .book-title { overflow-wrap: break-word; word-break: normal; }
.article-code, .page-body pre, .page-body code { max-width: 100%; overflow-x: auto; }
.close-button, .scrim { display: none; }

@media (max-width: 1050px) {
  .main-grid { grid-template-columns: minmax(0,1fr) 210px; }
  .reader-top { flex-direction: column; align-items: flex-start; }
  .reader-actions { justify-content: flex-start; }
}


@media (max-width: 1024px) {
  .poem-block { width: 100%; max-width: 100%; overflow: visible; padding: 10px; }
  .poem-line, .poem-line-single { grid-template-columns: minmax(0,1fr); min-width: 0; gap: 0; font-size: 1.15rem; }
  .poem-line span { display: block; width: 100%; max-width: 100%; padding: 7px 4px; white-space: normal; overflow-wrap: break-word; }
  .poem-line span:first-child { border-left: 0; padding-left: 4px; }
  .poem-line:not(.poem-line-single) span:first-child { border-bottom: 1px dotted rgba(139,123,71,.45); }
}

@media (max-width: 820px) {
  html, body { min-width: 0 !important; overflow-x: hidden !important; }
  body.menu-open { overflow: hidden !important; }
  .site-shell { width: 100%; padding: 0; }
  .classic-container { width: 100%; border-right: 0; border-left: 0; box-shadow: none; }
  .top-preferences { display: block; padding: 8px; }
  .reader-preferences { display: grid; width: 100%; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 7px; }
  .theme-choice { display: flex; width: 100%; grid-column: 1/-1; }
  .theme-choice button { flex: 1 1 0; min-height: 42px; }
  .preference-select { display: grid; min-height: 42px; grid-template-columns: auto minmax(0,1fr); }
  .preference-select select { width: 100%; min-height: 36px; font-size: 16px; }
  .site-header { width: 100%; overflow: hidden; }
  .site-header img { display: block; width: 100%; min-width: 0; max-width: 100%; min-height: 0; height: auto; object-fit: contain; }
  .legacy-menu { display: grid; grid-template-columns: repeat(auto-fit,minmax(135px,1fr)); gap: 3px; overflow: visible; }
  .legacy-menu a { width: 100%; min-width: 0; min-height: 42px; padding: 6px 8px; white-space: normal; text-align: center; line-height: 1.55; }
  .toolbar-row { position: static; display: grid; width: 100%; grid-template-columns: auto minmax(0,1fr) auto; gap: 8px; padding: 8px; }
  .toolbar-row > * { min-width: 0; }
  .search-box { grid-column: auto; width: 100%; min-height: 44px; }
  .search-box input, .reader-search-box input, .page-jump input { font-size: 16px; }
  .small-button, .secondary-button, .search-submit, .menu-button, .close-button { min-height: 42px; }
  .main-grid, .main-grid.reader-mode { display: grid; width: 100%; grid-template-columns: minmax(0,1fr); gap: 10px; padding: 10px; direction: rtl; }
  .content-area { grid-column: 1; width: 100%; }
  .menu-button, .close-button { display: inline-flex; }
  .right-index {
    position: fixed; inset: 0 0 0 auto; z-index: 100; width: min(330px,88vw); max-width: 88vw; height: 100vh; height: 100dvh; max-height: none;
    padding: max(8px,env(safe-area-inset-top)) 8px max(12px,env(safe-area-inset-bottom)); overflow-y: auto; overscroll-behavior: contain;
    transform: translateX(105%); visibility: hidden; pointer-events: none; transition: transform .24s ease,visibility 0s linear .24s; box-shadow: -14px 0 34px rgba(0,0,0,.24);
  }
  body.menu-open .right-index { transform: translateX(0); visibility: visible; pointer-events: auto; transition-delay: 0s; }
  .scrim { position: fixed; inset: 0; z-index: 99; display: block; border: 0; background: rgba(0,0,0,.42); opacity: 0; visibility: hidden; pointer-events: none; transition: opacity .2s ease,visibility 0s linear .2s; }
  body.menu-open .scrim { opacity: 1; visibility: visible; pointer-events: auto; transition-delay: 0s; }
  .category-heading, .reader-top, .reader-tools, .old-box-head { flex-direction: column; align-items: stretch; }
  .category-heading > span { width: 100%; text-align: center; }
  .reader-top, .reader-grid { padding: 10px; }
  .reader-actions, .reader-actions .secondary-button, .page-jump { width: 100%; }
  .reader-page-status { width: 100%; min-width: 0; }
  .page-jump input { flex: 1 1 auto; width: auto; }
  .reader-page { min-height: 0; padding: clamp(12px,3.5vw,22px); }
  .reader-page h2 { margin-top: 0; }
  .floating-page { top: auto; bottom: max(12px,env(safe-area-inset-bottom)); width: 46px; height: 46px; transform: none; border-radius: 999px; font-size: 1.2rem; }
  .floating-page-prev { right: 10px; }
  .floating-page-next { left: 10px; }
  .page-scroll-controls { right: 10px; bottom: calc(max(12px,env(safe-area-inset-bottom)) + 58px); gap: 6px; }
  .page-scroll-button { width: 40px; height: 40px; font-size: 1.05rem; }
  .reader-page { scroll-margin-top: 10px; }
  .reader-figure img { max-height: none; }
  .article-body table { display: block; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .article-cards.compact { grid-template-columns: minmax(0,1fr); }
}

@media (max-width: 680px) {
  .main-grid, .main-grid.reader-mode { padding: 8px; }
  .catalog-section { padding: 8px; overflow: visible; }
  .classic-table, .classic-table tbody, .classic-table tr, .classic-table td { display: block; width: 100%; }
  .classic-table { min-width: 0; border: 0; }
  .classic-table colgroup, .classic-table thead { display: none; }
  .classic-table tbody { display: grid; gap: 9px; }
  .classic-table tr { overflow: hidden; border: 1px solid #c3cfb6; background: #fffef8; }
  [data-theme='dark'] .classic-table tr { border-color: #405a45; background: #17221a; }
  .classic-table td { display: grid; grid-template-columns: 5rem minmax(0,1fr); align-items: start; gap: 10px; border: 0; border-bottom: 1px solid #c3cfb6; background: transparent; padding: 9px 10px; text-align: right; }
  [data-theme='dark'] .classic-table td { border-color: #405a45; background: transparent; }
  .classic-table td:last-child { border-bottom: 0; }
  .classic-table td::before { content: attr(data-label); min-width: 0; color: #8b342b; font-weight: 700; }
  [data-theme='dark'] .classic-table td::before { color: #e6a090; }
  .classic-table .book-title-cell { display: block; }
  .classic-table .book-title-cell::before { display: block; margin-bottom: 5px; }
  .book-title { font-size: 1rem; line-height: 1.9; }
  .open-pill { width: 100%; min-height: 38px; }
}

@media (max-width: 560px) {
  .toolbar-row { grid-template-columns: minmax(0,1fr); }
  .toolbar-row > *, .toolbar-row .small-button, .toolbar-row .secondary-button, .menu-button, .search-box { width: 100%; grid-column: 1; }
  .reader-tools { padding: 8px; }
  .page-jump { display: grid; grid-template-columns: auto minmax(0,1fr) auto; }
  .category-heading, .old-box-head { padding-right: 10px; padding-left: 10px; }
  .result-list, .article-cards { padding: 8px; }
}

@media (max-width: 420px) {
  .reader-preferences { grid-template-columns: minmax(0,1fr); }
  .theme-choice { grid-column: 1; }
  .legacy-menu { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .page-jump { grid-template-columns: auto minmax(0,1fr); }
  .page-jump .search-submit { grid-column: 1/-1; width: 100%; }
  .classic-table td { grid-template-columns: 4.5rem minmax(0,1fr); }
  .floating-page { width: 42px; height: 42px; }
}

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

@media print {
  .top-preferences, .legacy-menu, .toolbar-row, .right-index, .scrim, .floating-pager, .page-scroll-controls { display: none !important; }
  .site-shell, .classic-container, .main-grid, .content-area, .reader-page { width: 100% !important; max-width: none !important; margin: 0 !important; padding: 0 !important; border: 0 !important; box-shadow: none !important; }
}
