/* ═══════════════════════════════════════════════════════════════════════
   הקורא של הספרייה (/sefer/…) — תמיד על רקע לבן, בלי קשר לסגנון האתר שנבחר.
   (העמוד לא טוען את עיצוב האתר ולא את data-tone — הכל כאן.)
   גופנים: assets/css/reader-fonts.css + assets/js/reader-config.js
   ═══════════════════════════════════════════════════════════════════════ */
:root {
  color-scheme: light;
  --rd-bg: #fff; --rd-ink: #16161c; --rd-mut: #6b7280; --rd-line: #e7e9ef; --rd-soft: #f6f7fa;
  --rd-accent: #E70F57; --rd-gold: #9a6a08; --rd-goldbg: #fbf5e4; --rd-goldline: #ecd9a8;
  --rd-font: var(--rd-font-pick, var(--rd-font-default, 'RD Heebo')), 'RD Heebo', 'Heebo', 'Arial Hebrew', Arial, sans-serif;
  --rd-ui: 'Rubik', 'Heebo', 'Arial Hebrew', Arial, sans-serif;
  --rd-size: 1.4rem; --rd-lh: 1.8; --rd-w: 46rem;
}
html.rd { background: #fff !important; color-scheme: light; -webkit-text-size-adjust: 100%; scroll-padding-top: 70px; }
html.rd body.rd-body { margin: 0; background: #fff !important; color: var(--rd-ink); font-family: var(--rd-ui); -webkit-font-smoothing: antialiased; min-height: 100vh; display: flex; flex-direction: column; }
.rd *, .rd *::before, .rd *::after { box-sizing: border-box; }
.rd a { color: inherit; }
.rd [hidden] { display: none !important; }
.rd button { font-family: inherit; }

/* ── סרגל עליון ── */
.rd-top { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 14px; height: 54px; padding: 0 max(14px, calc((100vw - 64rem) / 2)); background: rgba(255,255,255,.96); backdrop-filter: blur(8px); border-bottom: 1px solid var(--rd-line); }
.rd-logo { font-weight: 800; font-size: 1.12rem; color: var(--rd-accent); text-decoration: none; letter-spacing: -.2px; flex: none; }
.rd-nav { display: flex; gap: 16px; align-items: center; overflow: hidden; flex: 1; min-width: 0; }
.rd-nav a { text-decoration: none; color: var(--rd-mut); font-weight: 500; font-size: .92rem; white-space: nowrap; }
.rd-nav a:hover { color: var(--rd-ink); }
.rd-nav .rd-nav-book { overflow: hidden; text-overflow: ellipsis; max-width: 16rem; color: var(--rd-ink); font-weight: 700; }
.rd-tools { display: flex; gap: 4px; flex: none; }
.rd-tb { width: 42px; height: 42px; border: 0; background: transparent; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; color: #3a3f4d; cursor: pointer; position: relative; }
.rd-tb:hover { background: var(--rd-soft); }
.rd-tb[aria-pressed="true"] { color: var(--rd-accent); }
.rd-tb svg { width: 22px; height: 22px; }
.rd-prog { position: sticky; top: 54px; z-index: 29; height: 3px; background: transparent; }
.rd-prog i { display: block; height: 3px; width: 0; background: var(--rd-accent); transition: width .12s linear; }
@media (max-width: 640px) { .rd-nav a:not(.rd-nav-book) { display: none; } .rd-nav .rd-nav-book { max-width: 100%; } }

/* ── מעטפת ── */
.rd-main { width: 100%; max-width: var(--rd-w); margin: 0 auto; padding: 18px 20px 30px; flex: 1; }
.rd-crumbs { font-size: .8rem; color: var(--rd-mut); margin: 4px 0 14px; display: flex; flex-wrap: wrap; gap: 2px 6px; align-items: center; }
.rd-crumbs a { color: var(--rd-mut); text-decoration: none; } .rd-crumbs a:hover { color: var(--rd-accent); }
.rd-crumbs i { font-style: normal; opacity: .5; }
.rd-head { margin: 8px 0 22px; text-align: center; }
.rd-kicker { font-size: .85rem; font-weight: 700; color: var(--rd-gold); letter-spacing: .2px; }
.rd-kicker a { text-decoration: none; }
.rd-head h1 { font-family: var(--rd-font); font-size: clamp(1.9rem, 5.6vw, 2.7rem); line-height: 1.2; margin: 6px 0 4px; font-weight: 700; color: var(--rd-ink); }
.rd-sub { font-family: var(--rd-font); font-size: 1.18rem; color: #444a58; margin: 4px 0 6px; }
.rd-meta { font-size: .82rem; color: var(--rd-mut); }
.rd-head::after { content: ""; display: block; width: 64px; height: 3px; background: var(--rd-goldline); border-radius: 3px; margin: 16px auto 0; }

/* ── הטקסט — מראה ספר (הצדקה, שורה אחרונה במרכז, מילה ראשונה מודגשת) ── */
.rd-text { font-family: var(--rd-font); font-size: var(--rd-size); line-height: var(--rd-lh); color: var(--rd-ink); text-align: justify; text-justify: inter-word; hyphens: none; word-spacing: .02em; font-feature-settings: "kern", "liga"; }
.rd-text p { margin: 0 0 .85em; text-align: justify; text-align-last: right; overflow-wrap: break-word; }
html:not([data-just="plain"]) .rd-text p.rd-c { text-align-last: center; }   /* שורה אחרונה במרכז — רק בפסקאות של כמה שורות (מסומן ב-reader.js) */
html[data-just="plain"] .rd-text p { text-align: right; text-align-last: auto; }
.rd-text p:target, .rd-text p.hl { background: #fff8d9; box-shadow: 0 0 0 6px #fff8d9; border-radius: 4px; }
.rd-dc { font-weight: 700; font-size: 1.28em; }
.rd-n { font-family: var(--rd-ui); font-size: .56em; font-weight: 700; color: var(--rd-gold); background: var(--rd-goldbg); border: 1px solid var(--rd-goldline); border-radius: 7px; padding: .08em .5em; margin-inline-end: .6em; text-decoration: none; vertical-align: .22em; line-height: 1.4; display: inline-block; cursor: pointer; user-select: none; }
.rd-n:hover { background: #f6e9c0; }
.rd-text small { font-size: .8em; color: #4a4f5c; }
.rd-text b { font-weight: 700; }
.rd-h3 { font-family: var(--rd-ui); font-size: .86rem; font-weight: 800; color: var(--rd-gold); margin: 1.9em 0 .8em; padding-bottom: .4em; border-bottom: 2px solid #f5ecd0; text-align: right; letter-spacing: .2px; }
.rd-h3:first-child { margin-top: .4em; }
.rd-hb { font-family: var(--rd-font); font-weight: 700; text-align: center; margin: 1.1em 0 .5em; font-size: 1.02em; line-height: 1.55; font-size: var(--rd-size); }
.rd-text p.rd-tail { text-align: center; text-align-last: center; }

/* ── מעבר בין עמודים ── */
.rd-pn { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; margin: 34px 0 20px; align-items: stretch; }
.rd-pn a { display: flex; align-items: center; gap: 10px; border: 1px solid var(--rd-line); border-radius: 14px; padding: 12px 14px; text-decoration: none; color: var(--rd-ink); font-weight: 700; font-size: .92rem; background: #fff; min-width: 0; }
.rd-pn a span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.rd-pn a i { font-style: normal; color: var(--rd-accent); font-size: 1.2rem; flex: none; }
.rd-pn a:last-child { justify-content: flex-end; }
.rd-pn a:hover { border-color: var(--rd-accent); }
.rd-pn .mid { justify-content: center; color: var(--rd-mut); font-weight: 600; font-size: .82rem; }
@media (max-width: 560px) { .rd-pn { grid-template-columns: 1fr 1fr; } .rd-pn .mid { grid-column: 1 / -1; order: 3; } }

/* ── קריאה ללימוד יומי ── */
.rd-learn { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px; background: #faf7ef; border: 1px solid #ecdcae; border-radius: 16px; padding: 16px 18px; margin: 22px 0; }
.rd-learn b { display: block; font-size: 1.02rem; } .rd-learn span { color: var(--rd-mut); font-size: .9rem; line-height: 1.6; display: block; }
.rd-learn-b { display: flex; flex-wrap: wrap; gap: 8px; }
.rd-btn { display: inline-flex; align-items: center; justify-content: center; background: var(--rd-accent); color: #fff !important; text-decoration: none; font-weight: 800; border-radius: 12px; padding: 12px 22px; border: 2px solid var(--rd-accent); font-size: .96rem; cursor: pointer; }
.rd-btn:hover { filter: brightness(.95); }
.rd-btn-line { background: #fff; color: var(--rd-accent) !important; }
.rd-sibs h2, .rd-toc h2, .rd-cat h2 { font-size: 1.1rem; margin: 26px 0 10px; font-weight: 800; }
.rd-sibs ul { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.rd-sibs a { display: block; border: 1px solid var(--rd-line); border-radius: 22px; padding: 6px 14px; font-weight: 600; font-size: .9rem; text-decoration: none; background: #fff; }
.rd-sibs a:hover { border-color: var(--rd-accent); color: var(--rd-accent); }

/* ── עמוד הספר ── */
.rd-head-book { margin-top: 12px; }
.rd-stats { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px 22px; margin: 14px 0 0; color: var(--rd-mut); font-size: .9rem; }
.rd-stats b { color: var(--rd-ink); }
.rd-about { font-family: var(--rd-font); font-size: 1.12rem; line-height: 1.9; text-align: center; max-width: 38rem; margin: 0 auto 18px; color: #333845; }
.rd-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin: 18px 0 8px; }
.rd-toc-h { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; margin-top: 26px; }
.rd-toc-h h2 { margin: 0; }
.rd-toc-h input, .rd-panel input[type=search] { font: inherit; font-size: .92rem; border: 1px solid var(--rd-line); border-radius: 12px; padding: 9px 14px; min-width: 15rem; background: var(--rd-soft); }
.rd-toc-h input:focus, .rd-panel input:focus { outline: 2px solid #f6c3d3; background: #fff; }
.rd-tree, .rd-grid { list-style: none; margin: 0; padding: 0; }
.rd-nd { margin: 8px 0; }
.rd-nd > details { border: 1px solid var(--rd-line); border-radius: 14px; background: #fff; }
.rd-nd > details > summary { cursor: pointer; font-weight: 800; padding: 12px 16px; list-style: none; display: flex; align-items: center; justify-content: space-between; gap: 10px; border-radius: 14px; }
.rd-nd > details > summary::-webkit-details-marker { display: none; }
.rd-nd > details > summary::before { content: "‹"; font-size: 1.3rem; color: var(--rd-mut); transition: transform .15s; display: inline-block; margin-inline-end: 4px; }
.rd-nd > details[open] > summary::before { transform: rotate(-90deg); }
.rd-nd > details > summary:hover { background: var(--rd-soft); }
.rd-nd > details > summary small { margin-inline-start: auto; color: var(--rd-mut); font-weight: 500; font-size: .78rem; background: var(--rd-soft); border-radius: 10px; padding: 2px 9px; }
.rd-nd > details > ul, .rd-nd > details > .rd-grid { padding: 4px 14px 14px; }
.rd-nd .rd-nd { margin-inline-start: 4px; }
.rd-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); gap: 8px; margin: 8px 0; }
.rd-grid.rd-chips { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 6px; }
.rd-lf a { display: block; border: 1px solid var(--rd-line); border-radius: 11px; padding: 9px 13px; text-decoration: none; background: #fff; height: 100%; }
.rd-lf a:hover { border-color: var(--rd-accent); }
.rd-lf b { font-weight: 700; font-size: .93rem; } .rd-lf span { display: block; color: var(--rd-mut); font-size: .8rem; margin-top: 2px; font-family: var(--rd-font); }
.rd-chips .rd-lf a { padding: 7px 8px; text-align: center; border-radius: 9px; } .rd-chips .rd-lf b { font-size: .84rem; font-weight: 600; }
.rd-lf a.read { background: #f0faf3; border-color: #bfe6c9; } .rd-lf a.read b::after { content: " ✓"; color: #1f9d4a; }
.rd-lf a.cur { border-color: var(--rd-accent); background: #fff1f5; }
.rd-hide { display: none !important; }

/* ── הספרייה ── */
.rd-head-hub h1 { font-family: var(--rd-ui); font-weight: 800; }
.rd-lead { color: #444a58; line-height: 1.8; max-width: 36rem; margin: 6px auto 0; }
.rd-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.rd-card { display: flex; flex-direction: column; gap: 4px; border: 1px solid var(--rd-line); border-radius: 16px; padding: 16px 18px; text-decoration: none; background: #fff; transition: border-color .15s, box-shadow .15s; }
.rd-card:hover { border-color: var(--rd-accent); box-shadow: 0 6px 20px rgba(21,32,58,.07); }
.rd-card b { font-family: var(--rd-font); font-size: 1.3rem; font-weight: 700; }
.rd-card .au { color: var(--rd-gold); font-size: .84rem; font-weight: 600; }
.rd-card .ds { color: #4a4f5c; font-size: .88rem; line-height: 1.65; margin-top: 4px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.rd-card .mt { color: var(--rd-mut); font-size: .78rem; margin-top: auto; padding-top: 8px; }
.rd-card .pg { height: 5px; background: var(--rd-soft); border-radius: 5px; overflow: hidden; margin-top: 6px; } .rd-card .pg i { display: block; height: 5px; background: #1f9d4a; }
.rd-resume { background: #faf7ef; border: 1px solid #ecdcae; border-radius: 14px; padding: 12px 16px; margin: 6px 0 14px; display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; }
.rd-resume a { font-weight: 700; text-decoration: none; background: #fff; border: 1px solid #ecdcae; border-radius: 22px; padding: 6px 14px; font-size: .9rem; }
.rd-resume a:hover { border-color: var(--rd-accent); color: var(--rd-accent); }
.rd-resume > b { font-size: .88rem; }

/* ── ההגדרות ותוכן העניינים הצדדי ── */
.rd-ov { position: fixed; inset: 0; background: rgba(20,22,32,.35); z-index: 60; opacity: 0; pointer-events: none; transition: opacity .18s; }
.rd-ov.on { opacity: 1; pointer-events: auto; }
.rd-panel { position: fixed; z-index: 61; background: #fff; box-shadow: 0 10px 40px rgba(21,32,58,.22); display: flex; flex-direction: column; transition: transform .22s ease; }
.rd-panel.toc { top: 0; bottom: 0; right: 0; width: min(24rem, 92vw); transform: translateX(105%); border-radius: 20px 0 0 20px; }
.rd-panel.set { left: 50%; bottom: 0; width: min(26rem, 100vw); transform: translate(-50%, 105%); border-radius: 22px 22px 0 0; padding: 8px 22px 26px; }
.rd-panel.on.toc { transform: none; } .rd-panel.on.set { transform: translate(-50%, 0); }
@media (min-width: 900px) { .rd-panel.set { top: 62px; bottom: auto; left: max(14px, calc((100vw - 64rem) / 2)); width: 22rem; transform: translateY(-14px); opacity: 0; pointer-events: none; border-radius: 18px; transition: transform .18s, opacity .18s; } .rd-panel.on.set { transform: none; opacity: 1; pointer-events: auto; } }
.rd-ph { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 8px; font-weight: 800; font-size: 1.05rem; }
.rd-ph button { border: 0; background: var(--rd-soft); width: 34px; height: 34px; border-radius: 50%; font-size: 1.1rem; cursor: pointer; }
.rd-panel.toc .rd-pf { padding: 0 16px 10px; } .rd-panel.toc .rd-pf input { width: 100%; }
.rd-pb { overflow-y: auto; padding: 0 12px 24px; flex: 1; overscroll-behavior: contain; }
.rd-pb .rd-nd > details > summary { padding: 9px 12px; font-size: .94rem; }
.rd-pb .rd-grid { grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); }
.rd-pb .rd-lf a { padding: 6px 6px; } .rd-pb .rd-lf span { display: none; }
.rd-set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid #f0f1f5; }
.rd-set-row:last-child { border: 0; }
.rd-set-row > span { font-weight: 700; font-size: .92rem; }
.rd-seg { display: inline-flex; border: 1px solid var(--rd-line); border-radius: 12px; overflow: hidden; }
.rd-seg button { border: 0; background: #fff; padding: 9px 14px; cursor: pointer; font-size: .9rem; font-weight: 600; color: #3a3f4d; border-inline-start: 1px solid var(--rd-line); }
.rd-seg button:first-child { border-inline-start: 0; }
.rd-seg button.on { background: #fff1f5; color: var(--rd-accent); }
.rd-seg button:disabled { opacity: .4; cursor: default; }
.rd-sw { width: 50px; height: 30px; border-radius: 30px; border: 0; background: #d5d8e0; position: relative; cursor: pointer; transition: background .15s; }
.rd-sw::after { content: ""; position: absolute; top: 3px; right: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.25); transition: transform .15s; }
.rd-sw[aria-checked="true"] { background: var(--rd-accent); } .rd-sw[aria-checked="true"]::after { transform: translateX(-20px); }
.rd-fonts { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.rd-fonts button { border: 1px solid var(--rd-line); background: #fff; border-radius: 10px; padding: 7px 12px; cursor: pointer; font-size: 1rem; }
.rd-fonts button.on { border-color: var(--rd-accent); background: #fff1f5; color: var(--rd-accent); }
.rd-toast { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(20px); background: #1e2230; color: #fff; padding: 10px 20px; border-radius: 24px; font-size: .9rem; z-index: 80; opacity: 0; transition: .2s; pointer-events: none; }
.rd-toast.on { opacity: 1; transform: translateX(-50%); }

.rd-foot { border-top: 1px solid var(--rd-line); padding: 18px 20px 30px; text-align: center; color: var(--rd-mut); font-size: .82rem; }
.rd-foot a { color: var(--rd-mut); }
@media print { .rd-top, .rd-prog, .rd-pn, .rd-learn, .rd-sibs, .rd-foot, .rd-crumbs, .rd-n { display: none !important; } .rd-main { max-width: none; padding: 0; } .rd-text { font-size: 13pt; line-height: 1.6; } }
/* פסקה בלי אות — מספר עדין ללחיצה (הדגשה / הערה / חיזוק) */
.rd-n.rd-n0 { background: transparent; border-color: transparent; color: #b9bfca; font-weight: 600; }
.rd-n.rd-n0:hover { border-color: var(--rd-goldline); color: var(--rd-gold); }
.rd-text, .rd-hb { letter-spacing: var(--rd-ls, 0); }
