/* ==========================================================================
   كتب مقترح — قارئ الكتب
   ========================================================================== */

body.reader-body {
	--rd-bg: #fbf6ec; --rd-fg: #2f2a22; --rd-muted: #81786a; --rd-ui: rgba(251, 246, 236, .94); --rd-line-c: rgba(60, 45, 20, .12); --rd-panel: #fffaf2; --rd-hover: rgba(60, 45, 20, .06); --rd-accent: var(--c-secondary, #c8811f); --rd-mark: #f6d58b;
	margin: 0; background: var(--rd-bg); color: var(--rd-fg); font-family: var(--f-body, 'IBM Plex Sans Arabic', Tahoma, sans-serif); direction: rtl; text-align: right; -webkit-font-smoothing: antialiased; overflow-x: hidden;
	transition: background .25s, color .25s;
}
body.reader-body[data-rd-theme="light"] { --rd-bg: #fff; --rd-fg: #1f2328; --rd-muted: #6b7280; --rd-ui: rgba(255, 255, 255, .94); --rd-line-c: rgba(0, 0, 0, .1); --rd-panel: #fff; --rd-hover: rgba(0, 0, 0, .05); }
body.reader-body[data-rd-theme="gray"] { --rd-bg: #e9e9e6; --rd-fg: #26262a; --rd-muted: #6a6a70; --rd-ui: rgba(233, 233, 230, .94); --rd-line-c: rgba(0, 0, 0, .12); --rd-panel: #f3f3f1; --rd-hover: rgba(0, 0, 0, .06); }
body.reader-body[data-rd-theme="night"] { --rd-bg: #15171c; --rd-fg: #d6d3cc; --rd-muted: #8d8a83; --rd-ui: rgba(21, 23, 28, .94); --rd-line-c: rgba(255, 255, 255, .1); --rd-panel: #1d2027; --rd-hover: rgba(255, 255, 255, .06); --rd-mark: #8a6a1f; }
*, *::before, *::after { box-sizing: border-box; }
.reader-body img, .reader-body svg { max-width: 100%; height: auto; }
.reader-body button, .reader-body input, .reader-body select { font: inherit; color: inherit; }
.reader-body a { color: var(--rd-accent); }
.screen-reader-text { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
.ic { flex: none; }

.rd { --rd-size: 20px; --rd-line: 2; --rd-font: 'Noto Naskh Arabic', 'Amiri', serif; --rd-max: 720px; min-height: 100vh; }
.rd[data-width="narrow"] { --rd-max: 600px; }
.rd[data-width="wide"] { --rd-max: 920px; }

/* شريط التقدم والشريط العلوي */
.rd-progress { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 60; background: transparent; }
.rd-progress span { display: block; height: 100%; width: 0; background: var(--rd-accent); transition: width .2s; }
.rd-top { position: fixed; top: 0; left: 0; right: 0; z-index: 50; display: flex; align-items: center; gap: 10px; padding: 10px clamp(10px, 3vw, 24px); padding-top: max(10px, env(safe-area-inset-top)); background: var(--rd-ui); backdrop-filter: blur(10px); border-bottom: 1px solid var(--rd-line-c); transition: transform .25s; }
.rd-title { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.45; }
.rd-title strong { font-family: var(--f-heading, inherit); font-size: .98rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rd-title small { color: var(--rd-muted); font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rd-tools { display: flex; align-items: center; gap: 4px; }
.rd .rd-btn { width: 40px; height: 40px; flex: none; display: inline-flex; align-items: center; justify-content: center; border-radius: 10px; border: 0; background: transparent; color: var(--rd-fg); cursor: pointer; text-decoration: none; font-weight: 700; }
.rd .rd-btn:hover, .rd .rd-btn[aria-expanded="true"] { background: var(--rd-hover); color: var(--rd-fg); }
.rd .rd-btn--accent { background: var(--rd-accent); color: #fff; }
.rd .rd-btn--accent:hover { background: var(--rd-accent); color: #fff; filter: brightness(.95); }
.rd .rd-btn--sm { width: 34px; height: 34px; }
.rd--calm .rd-top { transform: translateY(-100%); }
.rd--calm .rd-bottom { transform: translateY(100%); }
@media (max-width: 599px) { .rd .rd-hide-sm { display: none; } .rd-tools { gap: 0; } .rd .rd-btn { width: 38px; } }

/* الصفحة */
.rd-main { padding: 92px clamp(18px, 5vw, 40px) 120px; }
.rd-page { max-width: var(--rd-max); margin-inline: auto; font-family: var(--rd-font); font-size: var(--rd-size); line-height: var(--rd-line); overflow-wrap: break-word; transition: max-width .2s; }
.rd[data-align="justify"] .rd-page p { text-align: justify; text-justify: inter-word; }
.rd-page p { margin: 0 0 1em; }
.rd-page h2 { font-family: var(--rd-font); font-size: 1.5em; line-height: 1.5; margin: 0 0 1.1em; padding-bottom: .5em; border-bottom: 1px solid var(--rd-line-c); color: var(--rd-fg); text-align: center; }
.rd-page h3 { font-size: 1.2em; line-height: 1.5; margin: 1.4em 0 .6em; }
.rd-page img { border-radius: 8px; margin: 1em auto; display: block; }
.rd-page blockquote { margin: 1.4em 0; padding: .6em 1.1em; border-inline-start: 3px solid var(--rd-accent); background: var(--rd-hover); border-radius: 0 10px 10px 0; font-style: normal; }
.rd-page ul, .rd-page ol { padding-inline-start: 1.4em; margin: 0 0 1em; }
.rd-page table { width: 100%; border-collapse: collapse; display: block; overflow-x: auto; font-size: .85em; }
.rd-page th, .rd-page td { border: 1px solid var(--rd-line-c); padding: 6px 10px; }
.rd-page pre { overflow-x: auto; font-size: .8em; }
.rd-ch + .rd-ch { margin-top: 3em; }
.rd[data-mode="scroll"] .rd-ch + .rd-ch { padding-top: 2em; border-top: 1px dashed var(--rd-line-c); }
.rd-hit { background: var(--rd-mark); color: inherit; border-radius: 3px; padding: 0 2px; }
.rd-speaking { background: color-mix(in srgb, var(--rd-accent) 16%, transparent); border-radius: 6px; box-shadow: 0 0 0 6px color-mix(in srgb, var(--rd-accent) 16%, transparent); }
.rd-end { max-width: var(--rd-max); margin: 2.5em auto 0; padding: 22px; text-align: center; border: 1px dashed var(--rd-line-c); border-radius: 16px; display: flex; flex-direction: column; align-items: center; gap: 6px; color: var(--rd-muted); }
.rd-end .ic { color: var(--rd-accent); }
.rd-end strong { color: var(--rd-fg); font-size: 1.1rem; }
.rd-end[hidden] { display: none; }
.rd-page--empty { text-align: center; padding-top: 60px; font-family: inherit; font-size: 1.05rem; }

/* الحقوق */
.rd .mq-credit { max-width: var(--rd-max); margin: 3em auto 0; text-align: center; font-size: 13px; color: var(--rd-muted); }
.rd .mq-credit a { color: var(--rd-accent); font-weight: 700; text-decoration: none; }

/* الشريط السفلي */
.rd-bottom { position: fixed; bottom: 0; left: 0; right: 0; z-index: 50; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px clamp(10px, 3vw, 24px); padding-bottom: max(8px, env(safe-area-inset-bottom)); background: var(--rd-ui); backdrop-filter: blur(10px); border-top: 1px solid var(--rd-line-c); transition: transform .25s; }
.rd-nav { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--rd-line-c); background: transparent; border-radius: 10px; padding: 8px 14px; cursor: pointer; font-weight: 600; font-size: .9rem; }
.rd-nav:hover:not(:disabled) { background: var(--rd-hover); }
.rd-nav:disabled { opacity: .35; cursor: default; }
.rd[data-mode="scroll"] .rd-nav { visibility: hidden; }
.rd-status { text-align: center; line-height: 1.4; min-width: 0; }
.rd-status span { display: block; font-weight: 700; font-size: .88rem; }
.rd-status small { color: var(--rd-muted); font-size: .76rem; }
@media (max-width: 479px) { .rd-nav span { display: none; } .rd-nav { padding: 8px 10px; } }

/* اللوحات */
.rd-scrim { position: fixed; inset: 0; z-index: 70; background: rgba(0, 0, 0, .35); }
.rd-panel { position: fixed; z-index: 80; top: 0; bottom: 0; width: min(380px, 92vw); background: var(--rd-panel); color: var(--rd-fg); box-shadow: 0 0 60px rgba(0, 0, 0, .25); overflow-y: auto; padding: 16px 18px 30px; }
.rd-panel--toc { right: 0; }
.rd-panel--settings { left: 0; }
.rd-panel[hidden], .rd-scrim[hidden] { display: none; }
.rd-panel__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.rd-tabs { display: flex; gap: 4px; background: var(--rd-hover); border-radius: 12px; padding: 4px; flex: 1; }
.rd-tabs button { flex: 1; border: 0; background: transparent; padding: 7px 8px; border-radius: 9px; cursor: pointer; font-weight: 600; font-size: .9rem; }
.rd-tabs [aria-selected="true"] { background: var(--rd-bg); box-shadow: 0 2px 6px rgba(0, 0, 0, .08); }
.rd-toc { list-style: none; margin: 0; padding: 0; counter-reset: c; }
.rd-toc li { counter-increment: c; }
.rd-toc button { width: 100%; display: flex; gap: 10px; align-items: center; text-align: right; border: 0; background: transparent; padding: 10px; border-radius: 10px; cursor: pointer; line-height: 1.6; }
.rd-toc button::before { content: counter(c); flex: none; width: 28px; height: 28px; border-radius: 8px; background: var(--rd-hover); display: flex; align-items: center; justify-content: center; font-size: .8rem; }
.rd-toc button:hover { background: var(--rd-hover); }
.rd-toc .is-current button { color: var(--rd-accent); font-weight: 700; }
.rd-toc .is-current button::before { background: var(--rd-accent); color: #fff; }
.rd-marks, .rd-results { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.rd-marks li { display: flex; gap: 4px; align-items: stretch; }
.rd-mark, .rd-results button { flex: 1; text-align: right; border: 1px solid var(--rd-line-c); background: transparent; border-radius: 10px; padding: 10px 12px; cursor: pointer; line-height: 1.6; }
.rd-mark:hover, .rd-results button:hover { background: var(--rd-hover); }
.rd-mark strong, .rd-results strong { display: block; font-size: .82rem; color: var(--rd-accent); }
.rd-mark span, .rd-results span { font-size: .88rem; color: var(--rd-fg); }
.rd-results mark { background: var(--rd-mark); color: inherit; border-radius: 3px; }
.rd-mark__del { width: 36px; border: 1px solid var(--rd-line-c); background: transparent; border-radius: 10px; cursor: pointer; font-size: 1.2rem; color: var(--rd-muted); }
.rd-mark__del:hover { color: #c0392b; }
.rd-empty { color: var(--rd-muted); font-size: .88rem; line-height: 1.8; }
.rd-empty .ic { vertical-align: -2px; }
.rd-find { display: flex; gap: 6px; margin-bottom: 8px; }
.rd-find input { flex: 1; min-width: 0; border: 1.5px solid var(--rd-line-c); background: var(--rd-bg); border-radius: 10px; padding: 8px 12px; outline: 0; }
.rd-find input:focus { border-color: var(--rd-accent); }
.rd-set { padding: 14px 0; border-bottom: 1px solid var(--rd-line-c); }
.rd-set__label { display: flex; justify-content: space-between; font-weight: 700; font-size: .9rem; margin-bottom: 10px; }
.rd-set__label output { color: var(--rd-muted); font-weight: 600; }
.rd-themes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.rd-theme { display: flex; flex-direction: column; align-items: center; gap: 4px; border: 2px solid transparent; border-radius: 12px; padding: 8px 4px; cursor: pointer; font-size: .8rem; }
.rd-theme span { font-family: var(--rd-font); font-size: 1.3rem; line-height: 1.2; }
.rd-theme--light { background: #fff; color: #1f2328; border-color: #e5e7eb; }
.rd-theme--paper { background: #fbf6ec; color: #2f2a22; border-color: #eadfc9; }
.rd-theme--gray { background: #e9e9e6; color: #26262a; border-color: #d4d4cf; }
.rd-theme--night { background: #15171c; color: #d6d3cc; border-color: #2d3038; }
.rd-theme.is-on { border-color: var(--rd-accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--rd-accent) 30%, transparent); }
.rd-stepper { display: flex; align-items: center; gap: 8px; }
.rd-stepper .rd-btn { border: 1px solid var(--rd-line-c); }
.rd-stepper input { flex: 1; accent-color: var(--rd-accent); }
.rd-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.rd-chips button { border: 1.5px solid var(--rd-line-c); background: transparent; border-radius: 10px; padding: 6px 12px; cursor: pointer; font-size: .9rem; }
.rd-chips button.is-on { border-color: var(--rd-accent); color: var(--rd-accent); font-weight: 700; }
.rd-reset { margin-top: 16px; width: 100%; border: 0; background: var(--rd-hover); border-radius: 10px; padding: 10px; cursor: pointer; font-weight: 600; }

/* التنبيهات والاستماع */
.rd-toast { position: fixed; z-index: 65; bottom: 78px; left: 50%; transform: translateX(-50%); width: max-content; max-width: calc(100vw - 24px); display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px 10px; background: var(--rd-fg); color: var(--rd-bg); padding: 10px 14px; border-radius: 14px; box-shadow: 0 14px 40px rgba(0, 0, 0, .25); font-size: .9rem; }
.rd-toast[hidden] { display: none; }
.rd-toast button { border: 0; border-radius: 9px; padding: 6px 12px; cursor: pointer; font-weight: 700; background: rgba(127, 127, 127, .25); color: inherit; }
.rd-toast button[data-rd-resume-yes] { background: var(--rd-accent); color: #fff; }
.rd-toast--note { bottom: 140px; }
.rd-listen { position: fixed; z-index: 55; bottom: 74px; right: 50%; transform: translateX(50%); display: flex; align-items: center; gap: 6px; background: var(--rd-panel); border: 1px solid var(--rd-line-c); border-radius: 14px; padding: 6px 10px; box-shadow: 0 14px 30px rgba(0, 0, 0, .18); }
.rd-listen[hidden] { display: none; }
.rd-listen select { border: 1px solid var(--rd-line-c); background: transparent; border-radius: 8px; padding: 4px; }
.rd-listen small { color: var(--rd-muted); font-size: .75rem; max-width: 140px; line-height: 1.4; }

/* PDF */
.rd--pdf .rd-main { padding: 64px 0 0; }
.rd-pdf { height: calc(100vh - 64px); height: calc(100dvh - 64px); display: flex; flex-direction: column; }
.rd-pdf__frame { flex: 1; width: 100%; border: 0; background: #525659; }
body[data-rd-theme="night"] .rd-pdf__frame { filter: invert(.9) hue-rotate(180deg); }
body[data-rd-theme="paper"] .rd-pdf__frame { filter: sepia(.25); }
.rd-pdf__fallback { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px 14px; padding: 10px 16px; font-size: .88rem; color: var(--rd-muted); border-top: 1px solid var(--rd-line-c); text-align: center; }
.rd-pdf__fallback .ic { display: none; }
.rd-pdf__fallback p { margin: 0; }
.rd-pdf__btns { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.rd-cta { display: inline-flex; align-items: center; gap: 8px; padding: 9px 18px; border-radius: 10px; background: var(--rd-accent); color: #fff !important; font-weight: 700; text-decoration: none; }
.rd-cta--ghost { background: transparent; color: var(--rd-fg) !important; border: 1px solid var(--rd-line-c); }
.rd--pdf .mq-credit { margin: 0; padding: 8px; }
.rd--pdf-mobile .rd-pdf__frame { display: none; }
.rd--pdf-mobile .rd-pdf__fallback { flex: 1; flex-direction: column; font-size: 1rem; border: 0; padding: 30px 24px; }
.rd--pdf-mobile .rd-pdf__fallback .ic { display: block; color: var(--rd-accent); }

/* الطباعة: الكتاب كاملاً دون أدوات */
@media print {
	body.reader-body { background: #fff !important; color: #000 !important; }
	.rd-top, .rd-bottom, .rd-progress, .rd-panel, .rd-scrim, .rd-toast, .rd-listen, .rd-end { display: none !important; }
	.rd-main { padding: 0 !important; }
	.rd-page { max-width: none !important; font-size: 13pt !important; }
	.rd-ch[hidden] { display: block !important; }
	.rd-ch + .rd-ch { page-break-before: always; border: 0 !important; }
	.rd-hit, .rd-speaking { background: none !important; box-shadow: none !important; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
