/* Chitas and Rambam. Phone first; wider screens and print further down. */
@font-face { font-family: "Frank Ruhl Libre"; src: url(fonts/FrankRuhlLibre-400.woff2) format("woff2"); font-weight: 400; font-display: block; }
@font-face { font-family: "Frank Ruhl Libre"; src: url(fonts/FrankRuhlLibre-500.woff2) format("woff2"); font-weight: 500; font-display: block; }
@font-face { font-family: "Frank Ruhl Libre"; src: url(fonts/FrankRuhlLibre-700.woff2) format("woff2"); font-weight: 700; font-display: block; }
@font-face { font-family: "Noto Serif Hebrew"; src: url(fonts/NotoSerifHebrew-400.woff2) format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Noto Rashi Hebrew"; src: url(fonts/NotoRashiHebrew-400.woff2) format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Seferlines Serif"; src: url(fonts/SeferlinesSerif-Caption-400.woff2) format("woff2"); font-weight: 400; font-display: block; }
@font-face { font-family: "Seferlines Serif"; src: url(fonts/SeferlinesSerif-Caption-600.woff2) format("woff2"); font-weight: 600; font-display: block; }
@font-face { font-family: "Seferlines Serif Text"; src: url(fonts/SeferlinesSerif-Text-400.woff2) format("woff2"); font-weight: 400; font-display: block; }
@font-face { font-family: "Seferlines Serif Text"; src: url(fonts/SeferlinesSerif-Text-600.woff2) format("woff2"); font-weight: 600; font-display: block; }
@font-face { font-family: "Seferlines Serif Text"; src: url(fonts/SeferlinesSerif-Italic-400.woff2) format("woff2"); font-weight: 400; font-style: italic; font-display: block; }

:root {
  --scale: 1;
  --he: "Frank Ruhl Libre", "Taamey Frank CLM", "SBL Hebrew", "Times New Roman", serif;
  --rashi-font: var(--he);
  --mikra: "Noto Serif Hebrew", "Taamey Frank CLM", "SBL Hebrew", serif;
  --en: "Seferlines Serif", Georgia, "Times New Roman", serif;
  --en-text: "Seferlines Serif Text", Georgia, "Times New Roman", serif;

  /* paper and ink: warm off-white, near-black (15:1), gloss 7:1, secondary 5.6:1; one accent, used only for verse and halachah numbers */
  --bg: #f6f1e7; --ink: #1f1b16; --gloss: #544e46; --muted: #675f54; --faint: #857d70; --rule: #e3dccd; --rule-strong: #cbc2b0;
  --accent: #8a2c1c; --accent-soft: #efe4da; --press: #ede6d8;

  --he-size: calc(1.5rem * var(--scale));
  --en-size: calc(0.83rem * var(--scale));
  --rashi-he: calc(1.14rem * var(--scale));
  --rashi-en: calc(0.95rem * var(--scale));
  --rambam-he: calc(1.38rem * var(--scale));
  --chunk-min: 4.6rem;
  --measure: 40rem;
  --pad: 1.15rem;
  --head-h: calc(6.25rem + env(safe-area-inset-top, 0px));
}
html[data-theme="dark"] {
  --bg: #181715; --ink: #ddd5c6; --gloss: #aaa192; --muted: #9b9284; --faint: #7a7366; --rule: #2c2a26; --rule-strong: #3e3a33;
  --accent: #d09a84; --accent-soft: #2a211d; --press: #22201d;
}
@media (prefers-color-scheme: dark) {
  html[data-theme="auto"] {
    --bg: #181715; --ink: #ddd5c6; --gloss: #aaa192; --muted: #9b9284; --faint: #7a7366; --rule: #2c2a26; --rule-strong: #3e3a33;
    --accent: #d09a84; --accent-soft: #2a211d; --press: #22201d;
  }
}
html[data-rashifont="script"] { --rashi-font: "Noto Rashi Hebrew", var(--he); }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: var(--head-h); }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--en); font-size: 1rem; line-height: 1.5;
  font-kerning: normal; text-rendering: optimizeLegibility; -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[lang="he"] { font-family: var(--he); }
.skip { position: absolute; left: -999px; top: 0; background: var(--bg); padding: .6rem 1rem; z-index: 30; }
.skip:focus { left: .5rem; }

/* ---------- masthead ---------- */
/* A thin strip holds the notch; the tools row sticks just below it. The logo and quote scroll away. */
.safe-fill { position: sticky; top: 0; z-index: 11; height: env(safe-area-inset-top, 0px); background: var(--bg); pointer-events: none; }
.masthead { background: var(--bg); }
.brand-band { display: flex; flex-direction: column; align-items: center; text-align: center; padding: .85rem var(--pad) .9rem; }
.brand { display: flex; align-items: center; justify-content: center; height: 2rem; text-decoration: none; color: inherit; }
.brand img, .brand svg { display: block; }
.brand .dark { display: none; }
html[data-theme="dark"] .brand .light { display: none; }
html[data-theme="dark"] .brand .dark { display: block; }
@media (prefers-color-scheme: dark) {
  html[data-theme="auto"] .brand .light { display: none; }
  html[data-theme="auto"] .brand .dark { display: block; }
}
.brand-sig { display: flex; align-items: center; justify-content: center; }
.brand-sig svg, .brand-sig img { height: 1.85rem; width: auto; }
.brand-tag { margin: .22rem 0 0; max-width: 100%; font-family: var(--en); font-weight: 400; font-style: normal; font-size: clamp(.55rem, 2.5vw, .7rem); line-height: 1.25; letter-spacing: .04em; padding-left: .04em; color: var(--muted); white-space: nowrap; }
.motto { margin: .55rem 0 0; max-width: 22.75rem; font-family: var(--en-text); font-style: italic; font-size: .72rem; line-height: 1.45; color: var(--gloss); }
.motto-cite { margin: .35rem 0 0; font-family: var(--en-text); font-style: normal; font-size: .62rem; line-height: 1.4; color: var(--muted); }
@media (max-width: 359px) {
  .motto { max-width: none; }
}
@media (min-width: 40rem) {
  .brand { height: 2.25rem; }
  .brand-sig svg, .brand-sig img { height: 2.15rem; }
  .brand-band { padding: 1.1rem var(--pad) 1rem; }
  .brand-tag { font-size: .7rem; letter-spacing: .055em; padding-left: .055em; }
  .motto { font-size: .8rem; max-width: 36rem; line-height: 1.48; }
  .motto-cite { font-size: .68rem; }
}
@media (min-width: 60rem) {
  .brand-sig svg, .brand-sig img { height: 2.25rem; }
  .brand-tag { font-size: .74rem; letter-spacing: .06em; padding-left: .06em; }
  .motto { font-size: .84rem; max-width: 40rem; }
}

.toolbar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 10; background: var(--bg); border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.bar { display: grid; grid-template-columns: auto 1fr auto; align-items: center; max-width: 52rem; margin: 0 auto; padding: 0 .25rem; height: 3.25rem; }
.bar-start { display: flex; align-items: center; gap: .25rem; min-width: 2.75rem; flex: none; }
.daypick { grid-column: 2; display: flex; align-items: center; justify-content: center; min-width: 0; }
.nav-btn { width: 2.75rem; height: 2.75rem; display: grid; place-items: center; color: var(--ink); flex: none; border-radius: 2px; }
.nav-btn svg { width: 1.35rem; height: 1.35rem; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.nav-btn:disabled { color: var(--rule-strong); }
.nav-btn:not(:disabled):active, .date-btn:active { background: var(--press); }
.aa { grid-column: 3; font-family: var(--en-text); font-size: 1.05rem; letter-spacing: .01em; }
.date-btn { flex: 1 1 auto; min-width: 0; height: 2.75rem; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.15; padding: 0 .25rem; border-radius: 2px; }
.date-en { font-size: .9rem; font-weight: 600; letter-spacing: .005em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.date-he { font-size: .92rem; color: var(--muted); }

.tabs { display: flex; justify-content: center; gap: 0; max-width: 52rem; margin: 0 auto; }
.tab { flex: 1 1 0; max-width: 12rem; height: 2.75rem; display: flex; align-items: center; justify-content: center; gap: .45rem; color: var(--muted);
  position: relative; font-size: .88rem; }
.tab-he { font-size: 1.12rem; font-weight: 500; }
.tab[aria-pressed="true"] { color: var(--ink); }
@media (max-width: 479px) {
  .tab { flex-direction: column; gap: 0; height: 3rem; line-height: 1.1; font-size: .76rem; }
  .tab-he { font-size: 1.05rem; }
}
.tab[aria-pressed="true"]::after { content: ""; position: absolute; left: 30%; right: 30%; bottom: -1px; height: 1px; background: var(--ink); }
/* how far through this text: a hairline under the tools row */
.progress { position: absolute; left: 0; right: 0; bottom: -1px; height: 1px; background: var(--faint); transform-origin: left; transform: scaleX(0); pointer-events: none; }
@media (max-width: 359px) { .today-pre { display: none; } }
@media (max-width: 400px) { html:has(#marksBtn:not([hidden])) .today-pre { display: none; } }
@media (max-width: 400px) { html:not(:has(#marksBtn:not([hidden]))) .date-wd { display: none; } }
@media (min-width: 40rem) {
  .bar { padding: 0 .6rem; }
}

/* ---------- page ---------- */
main { display: block; max-width: calc(var(--measure) + 2 * var(--pad)); margin: 0 auto; padding: 0 var(--pad) 2rem; min-height: 100vh; outline: none; }
html:not(.ready) main { visibility: hidden; }
html[data-tab="chumash"] .part.rambam, html[data-tab="rambam"] .part.chumash,
html[data-tab="tanya"] .part.chumash, html[data-tab="tanya"] .part.rambam,
html[data-tab="chumash"] .part.tanya, html[data-tab="rambam"] .part.tanya { display: none; }
html:not([data-tab="shnayim"]) .part.shnayim, html[data-tab="shnayim"] .part.chumash, html[data-tab="shnayim"] .part.tanya,
html[data-tab="shnayim"] .part.rambam, html[data-tab="shnayim"] .daynav, html[data-tab="shnayim"] .away { display: none; }
html:not([data-tab="chassidus"]) .part.chassidus, html[data-tab="chassidus"] .part:not(.chassidus) { display: none; }
.ch-maamar { margin: 2.2rem 0 .6rem; text-align: center; }
.ch-maamar:first-child { margin-top: .4rem; }
.ch-title-he { font-family: var(--he); font-weight: 600; font-size: calc(var(--rambam-he) * 1.08); margin: 0; line-height: 1.5; }
.ch-title-en { margin: .15rem 0 0; font-size: .86rem; color: var(--muted); font-family: var(--en-text); font-style: italic; }
.ch-sub { font-family: var(--he); font-weight: 600; font-size: var(--rambam-he); text-align: center; margin: 1.6rem 0 .4rem; }
.chseg.pstart { margin-top: 1.1rem; }
.ch-unv { margin: .35rem 0 .2rem; font-size: .8rem; line-height: 1.45; color: var(--muted); font-family: var(--en-text); text-align: left; }
.ch.unv .e { border-bottom: 1px dotted var(--muted); }
.ch-unv-l { font-weight: 600; font-style: normal; }
.ch-none { margin: 1.2rem auto; max-width: 32rem; text-align: center; color: var(--muted); font-family: var(--en-text); }

.away { margin: 1rem 0 0; font-size: .85rem; color: var(--muted); text-align: center; }
.linkish { color: var(--accent); text-decoration: underline; text-underline-offset: .18em; text-decoration-thickness: 1px; min-height: 2.75rem; padding: 0 .25rem; }

.part-head { position: relative; text-align: center; padding: 2rem 0 1.5rem; border-bottom: 1px solid var(--rule); margin-bottom: .5rem; }
.dayline { margin: 0 0 1.35rem; display: flex; flex-direction: column; gap: .1rem; }
.dl-he { font-size: 1rem; color: var(--muted); }
.dl-en { font-size: .88rem; color: var(--muted); font-style: italic; font-family: var(--en-text); }
.kicker-he { margin: 0 0 .2rem; font-size: 1.02rem; color: var(--muted); }
.title { margin: 0; font-weight: 700; font-size: calc(2.15rem * var(--scale)); line-height: 1.15; letter-spacing: 0; }
.subtitle { margin: .35rem 0 0; font-size: calc(1.25rem * var(--scale)); color: var(--muted); font-weight: 400; }
.en-title { margin: .7rem auto 0; font-size: .95rem; color: var(--ink); max-width: 30rem; font-family: var(--en-text); }
.jump { display: flex; justify-content: center; gap: .25rem; margin-top: 1rem; direction: rtl; flex-wrap: wrap; }
.jump a { min-height: 2.75rem; min-width: 2.75rem; padding: 0 .75rem; display: inline-flex; align-items: center; font-size: 1.05rem; color: var(--ink);
  text-decoration: underline; text-decoration-color: var(--rule-strong); text-underline-offset: .3em; text-decoration-thickness: 1px; }
.jump a:hover { text-decoration-color: var(--accent); }

/* pasuk and halachah */
.pasuk, .halacha { position: relative; padding: 1.1rem 0 1.15rem; border-bottom: 1px solid var(--rule); }
.pasuk:last-child, .perek .halacha:last-child { border-bottom: 0; }
.num { display: flex; justify-content: flex-start; align-items: baseline; gap: .5rem; flex-direction: row-reverse; margin-bottom: .2rem; line-height: 1; }
.num-he { font-size: 1.08rem; font-weight: 700; color: var(--accent); }
.num-en { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* interlinear lines: Hebrew chunk on top, English under it, as wide as the Hebrew */
.il { text-align: right; line-height: 1; }
.ch { display: inline-block; vertical-align: top; text-align: center; min-width: max(var(--chunk-min), calc(var(--en-size) * var(--lw, 0) * .54)); margin: 0 0 .95rem .62rem; }
.ch .h { display: block; white-space: nowrap; font-family: var(--he); font-size: var(--he-size); line-height: 1.4; font-weight: 400; color: var(--ink); }
/* Torah pesukim (Chumash and Shnayim Mikra): --mikra is Noto Serif Hebrew, which has the taamim glyphs. Frank Ruhl Libre does not. */
.il.torah .ch .h,
.sm-he {
  font-family: var(--mikra);
  line-height: 1.9;
  padding-top: .12em;
  overflow: visible;
}
.il.torah .ch.long .h { line-height: 1.9; }

.ch .e { display: block; width: 0; min-width: 100%; margin-top: .12rem; font-family: var(--en); font-size: var(--en-size); line-height: 1.3; color: var(--gloss);
  hyphens: manual; overflow-wrap: normal; }
.rambam-il .ch .h, .tanya-il .ch .h { font-size: var(--rambam-he); }
.ch.long { display: block; min-width: 0; margin-left: 0; }
.ch.long .h { white-space: normal; line-height: 1.55; }
.ch.long .e { width: auto; text-align: left; margin-top: .25rem; }
.ch.cite .h { font-size: calc(var(--he-size) * .62); color: var(--muted); }
.rambam-il .ch.cite .h { font-size: calc(var(--rambam-he) * .66); }
.ch.cite .e { font-size: calc(var(--en-size) * .92); color: var(--muted); }

/* Rashi */
.rashi { margin: .75rem 0 0; padding: .45rem 1rem .1rem 0; border-right: 1px solid var(--rule-strong); }
.rashi + .rashi { margin-top: .5rem; }
.rashi-he { margin: 0; font-family: var(--rashi-font); font-size: var(--rashi-he); line-height: 1.62; text-align: right; }
.rashi-he .dh-he { font-weight: 700; font-family: var(--he); }
html[data-rashifont="script"] .rashi-he .dh-he { font-family: var(--he); }
.rashi-he .cite { font-size: .72em; color: var(--muted); }
.rashi-en { margin: .4rem 0 .5rem; font-family: var(--en-text); font-size: var(--rashi-en); line-height: 1.55; color: var(--ink); text-align: left; max-width: 36rem; margin-left: auto; }
.rashi-en .dh-en { font-style: italic; }
.r-il .ch .h { font-family: var(--rashi-font); font-size: var(--rashi-he); }
.r-il .ch.dh .h { font-weight: 700; font-family: var(--he); }
.r-il .ch .e { font-size: calc(var(--en-size) * .93); }
.r-il .ch { min-width: max(var(--chunk-min), calc(var(--en-size) * .95 * var(--lw, 0) * .54)); }
.r-il .ch.cite .h { font-size: calc(var(--rashi-he) * .7); }
.r-il { padding-top: .1rem; }
html[data-rashi="flow"] .r-inter, html[data-rashi="inter"] .r-flow { display: none; }
html[data-rambam="flow"] .m-inter, html[data-rambam="inter"] .m-flow,
html[data-tanya="flow"] .y-inter, html[data-tanya="inter"] .y-flow { display: none; }
.tseg:last-child { border-bottom: 0; }
.tseg .il { margin-top: 0; }
.rambam-he { margin: 0; font-family: var(--he); font-size: calc(var(--he-size) * .86); line-height: 1.7; text-align: right; }
.rambam-he .cite { font-size: .72em; color: var(--muted); }
.rambam-en { margin: .5rem 0 .2rem; font-family: var(--en-text); font-size: calc(var(--en-size) * 1.08); line-height: 1.6; color: var(--ink); text-align: left; max-width: 38rem; margin-left: auto; }

/* perek dividers */
.perek-mark { display: flex; align-items: baseline; justify-content: center; gap: .6rem; margin: 1.6rem 0 .3rem; color: var(--muted); font-size: 1.05rem; }
.perek-mark .pm-en { font-size: .85rem; font-style: italic; font-family: var(--en-text); }
.perek { padding-top: .5rem; }
.perek-head { margin: 1.6rem 0 .1rem; text-align: center; font-weight: 400; display: flex; flex-direction: column; align-items: center; gap: .1rem; }
.perek-head .ph-he { font-size: calc(1.55rem * var(--scale)); font-weight: 700; }
.perek-head .ph-en { font-size: .88rem; font-style: italic; font-family: var(--en-text); color: var(--muted); }
.perek-head::after { content: ""; width: 2.5rem; height: 1px; background: var(--rule-strong); margin-top: .6rem; }

.pending { margin: .2rem 0 .3rem; font-size: .82rem; color: var(--muted); font-style: italic; font-family: var(--en-text); text-align: left; }

.nhe { font-size: 1.05rem; color: var(--ink); }
.nhe-in { font-size: 1.05em; }

/* day navigation at the end */
.daynav { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; margin: 2.5rem 0 0; padding-top: 1.25rem; border-top: 1px solid var(--rule); }
.dn { display: flex; flex-direction: column; gap: .1rem; padding: .7rem .2rem; min-height: 3.5rem; text-align: left; }
.dn.next { text-align: right; grid-column: 2; }
.dn-l { font-size: .85rem; font-style: italic; font-family: var(--en-text); color: var(--muted); }
.dn-d { font-size: 1rem; color: var(--ink); }
.dn.prev .dn-d::before { content: "‹ "; color: var(--muted); }
.dn.next .dn-d::after { content: " ›"; color: var(--muted); }

.colophon { max-width: calc(var(--measure) + 2 * var(--pad)); margin: 0 auto; padding: 1.5rem var(--pad) calc(2.5rem + env(safe-area-inset-bottom)); font-size: .78rem; line-height: 1.5; color: var(--muted); border-top: 1px solid var(--rule); }
.colophon p { margin: 0 0 .5rem; }

/* ---------- sheets (date picker, settings) ---------- */
.sheet { border: 0; padding: 0 0 calc(1rem + env(safe-area-inset-bottom)); margin: auto 0 0; width: 100%; max-width: 100%; max-height: 88vh; background: var(--bg); color: var(--ink);
  border-top: 1px solid var(--rule-strong); box-shadow: 0 -1px 0 var(--rule), 0 -6px 18px rgba(30,22,12,.07); }
.sheet::backdrop { background: rgba(20, 17, 12, .38); }
.sheet[open] { animation: rise .18s ease-out; }
@keyframes rise { from { transform: translateY(12px); opacity: .6; } to { transform: none; opacity: 1; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: .4rem .35rem 0 var(--pad); }
.sheet-head h2 { margin: 0; font-size: 1.05rem; font-weight: 600; letter-spacing: .01em; }
.close { width: 2.75rem; height: 2.75rem; display: grid; place-items: center; position: relative; color: var(--muted); }
.close svg { width: .95rem; height: .95rem; stroke: currentColor; stroke-width: 1.25; fill: none; stroke-linecap: round; position: relative; z-index: 1; }
.sheet-sub { margin: 0 var(--pad) .5rem; font-size: .82rem; color: var(--muted); }
.days { list-style: none; margin: 0; padding: 0; }
.day { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .6rem var(--pad); min-height: 3.6rem; text-align: left; border-top: 1px solid var(--rule); position: relative; }
.day[aria-current="date"] { background: var(--press); }
.day[aria-current="date"]::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 2px; background: var(--ink); }
.day-l, .day-r { display: flex; flex-direction: column; gap: .1rem; }
.day-r { align-items: flex-end; text-align: right; }
.day-name { font-size: 1rem; font-weight: 600; }
.today-tag { margin-left: .45rem; font-size: .85rem; font-weight: 400; font-style: italic; font-family: var(--en-text); color: var(--muted); }
.day-date, .day-rm { font-size: .8rem; color: var(--muted); }
.day-he { font-size: 1.05rem; }
.opt { padding: .7rem var(--pad); border-top: 1px solid var(--rule); }
.opt-l { display: block; font-size: .85rem; color: var(--muted); margin-bottom: .45rem; }
.seg { display: flex; border: 1px solid var(--rule-strong); border-radius: 3px; overflow: hidden; }
.seg button { flex: 1 1 0; min-height: 2.75rem; padding: .3rem .4rem; font-size: .88rem; line-height: 1.2; color: var(--ink); }
.seg button + button { border-left: 1px solid var(--rule-strong); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.seg button:disabled { color: var(--faint); }
.seg .size-now { font-variant-numeric: tabular-nums; color: var(--muted); cursor: default; }
.seg .size-now:disabled { color: var(--muted); }
.a-s { font-size: .85rem; } .a-l { font-size: 1.25rem; }
.opt-foot { margin: .2rem var(--pad) .2rem; font-size: .78rem; color: var(--muted); }

/* ---------- tablet ---------- */
@media (min-width: 700px) {
  :root { --he-size: calc(1.8rem * var(--scale)); --en-size: calc(.86rem * var(--scale)); --rashi-he: calc(1.35rem * var(--scale)); --rashi-en: calc(1.02rem * var(--scale));
          --rambam-he: calc(1.6rem * var(--scale)); --chunk-min: 5.4rem; --pad: 2rem; --measure: 44rem; }
  .bar { padding: 0 .75rem; }
  .date-btn { flex: 0 1 auto; min-width: 15rem; flex-direction: row; gap: .75rem; }
  .date-en { font-size: .95rem; }
  .date-he { font-size: 1rem; }
  .part-head { padding: 2.75rem 0 2rem; }
  .title { font-size: calc(2.7rem * var(--scale)); }
  .ch { margin-left: .85rem; margin-bottom: 1.05rem; }
  /* verse numbers sit in the right margin, like a printed Chumash */
  .pasuk, .halacha { padding-right: 3rem; }
  .num { position: absolute; right: 0; top: 1.45rem; flex-direction: column; align-items: center; gap: .3rem; width: 2.2rem; }
  .num-he { font-size: 1.2rem; }
  .sheet { width: 26rem; max-width: calc(100vw - 2rem); margin: auto; border: 1px solid var(--rule-strong); max-height: 80vh; box-shadow: 0 10px 28px rgba(30,22,12,.10); }
}
/* ---------- desktop ---------- */
@media (min-width: 1100px) {
  :root { --he-size: calc(2rem * var(--scale)); --en-size: calc(.9rem * var(--scale)); --rashi-he: calc(1.45rem * var(--scale)); --rashi-en: calc(1.06rem * var(--scale));
          --rambam-he: calc(1.8rem * var(--scale)); --chunk-min: 5.8rem; --measure: 50rem; }
  .pasuk, .halacha { padding-right: 3.5rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
@media (hover: hover) {
  .nav-btn:not(:disabled):hover, .date-btn:hover, .tab:hover, .day:hover, .dn:hover, .close:hover { background: var(--press); }
  .seg button:not([aria-pressed="true"]):not(:disabled):hover { background: var(--press); }
}

/* ---------- print (US Letter) ---------- */
@page { size: Letter; margin: .48in .48in .58in; }
@media print {
  :root, html[data-theme], html[data-theme="dark"], html[data-theme="auto"] {
    --bg: #fff; --ink: #161412; --gloss: #3a3732; --muted: #4f4b44; --faint: #6a655c;
    --rule: #c8c2b6; --rule-strong: #a8a090; --accent: #222; --accent-soft: #eee; --press: #fff;
    --he-size: 12pt; --en-size: 8.7pt; --rashi-he: 9.6pt; --rashi-en: 8.5pt; --rambam-he: 11.6pt;
    --chunk-min: 36pt; --scale: 1;
  }
  html, body { background: #fff !important; color: #161412 !important; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .safe-fill, .masthead, .toolbar, .daynav, .away, .skip, .jump, dialog,
  .a2hs-banner, .toast, .lib-open, .coach, footer.colophon { display: none !important; }
  #app { display: none !important; }
  #printRoot, #printRoot[hidden] { display: block !important; background: #fff; color: #161412; }
  #printRoot .part { display: block !important; }
  /* always the word-by-word lines in print, even if the screen is set to paragraphs */
  #printRoot .r-flow, #printRoot .m-flow, #printRoot .y-flow { display: none !important; }
  #printRoot .r-inter, #printRoot .m-inter, #printRoot .y-inter { display: block !important; }
  .print-root { max-width: none; padding: 0; margin: 0; }
  .print-banner { text-align: center; margin: 0 0 9pt; padding: 0 0 7pt; border-bottom: .5pt solid #888; }
  .print-banner .pb-kicker { margin: 0; font-family: var(--en); font-size: 7.5pt; letter-spacing: .12em; text-transform: uppercase; color: #444; }
  .print-banner .pb-he { margin: 3pt 0 0; font-size: 11pt; font-weight: 500; }
  .print-banner .pb-en { margin: 1pt 0 0; font-family: var(--en-text); font-size: 8pt; font-style: italic; color: #333; }
  .print-day + .print-day { break-before: page; }
  .print-day-head { text-align: center; margin: 0 0 8pt; padding: 0 0 5pt; break-after: avoid; }
  .print-day:only-of-type .print-day-head { display: none; }
  .print-day:only-of-type .dayline { display: none; }
  .print-day-head .pd-he { margin: 0; font-size: 10pt; font-weight: 500; }
  .print-day-head .pd-en { margin: 1pt 0 0; font-family: var(--en-text); font-size: 8pt; font-style: italic; color: #333; }
  .print-colophon { margin: 14pt 0 0; padding-top: 6pt; border-top: .4pt solid #bbb; text-align: center; font-family: var(--en-text); font-size: 7.5pt; font-style: italic; color: #555; break-inside: avoid; }
  #printRoot .part {
    margin: 0 0 11pt; padding: 0;
    direction: rtl;
    column-count: 2; column-gap: .22in; column-rule: .35pt solid #c4beb2;
    column-fill: auto;
    orphans: 2; widows: 2;
  }
  #printRoot .en-title, #printRoot .pending, #printRoot .sm-src, #printRoot .hy-note,
  #printRoot .ph-en, #printRoot .am-en, #printRoot .pm-en, #printRoot .dl-en, #printRoot .e { direction: ltr; unicode-bidi: isolate; }
  #printRoot .part + .part { margin-top: 12pt; padding-top: 8pt; border-top: .5pt solid #9a9488; }
  .part-head, .aliyah-mark, .ch-maamar, .hy-note, .sm-src, .src { column-span: all; }
  .part-head { padding: 0 0 6pt !important; margin: 0 0 7pt !important; break-after: avoid; text-align: center; }
  .dayline { display: none !important; }
  .print-entry, .print-entry-row { display: none !important; }
  .kicker-he { font-size: 8pt; margin: 0 0 2pt; }
  .title { font-size: 13.5pt !important; margin: 0 !important; }
  .subtitle { font-size: 10pt; }
  .en-title { font-size: 8.5pt; margin: 2pt 0 0; }
  .dayline { margin: 0 0 3pt; }
  .dl-he { font-size: 8pt; }
  .dl-en { font-size: 7.5pt; }
  .pasuk, .halacha { padding: 4pt 16pt 5pt 0; break-inside: auto; }
  .sm-pasuk { padding: 4pt 16pt 5pt 0; break-inside: avoid; }
  .sm-first, .sm-second, .sm-onk { break-inside: avoid; }
  .num { position: absolute; right: 0; top: 5pt; flex-direction: column; align-items: center; gap: 1pt; width: 14pt; }
  .num-he { font-size: 8.5pt; }
  .num-en { font-size: 5.5pt; }
  .ch { break-inside: avoid; margin: 0 0 3.5pt 4.5pt; }
  .e { font-size: var(--en-size); }
  .rashi { break-inside: avoid; padding-right: 6pt; margin-top: 3pt; }
  .rashi-en { font-size: var(--rashi-en); max-width: none; }
  .perek-head { break-after: avoid; margin-top: 8pt; }
  .perek-mark, .aliyah-mark, .ch-maamar { break-after: avoid; margin-top: 8pt; margin-bottom: 4pt; }
  .aliyah-mark .am-he { font-size: 11pt; }
  .aliyah-mark .am-en { font-size: 8pt; }
  .sm-il .ch { margin-bottom: 5pt; }
  .sm-second { margin-top: 3pt; padding-top: 3pt; }
  .sm-he { font-size: 11.5pt; }
  .sm-onk { font-size: 9pt; margin-top: 3pt; }
  .ar-box { break-inside: avoid; border-color: #bbb; padding: 5pt 7pt; margin: 5pt 0 3pt; }
  .hy-note { font-size: 8pt; margin: 2pt 0 6pt; }
  .t-cycle, .al-list, .al-end, .sm-resume, .day-resume, .stop-mark, .stopped::before { display: none !important; }
  .colophon { border: 0; padding: 10pt 0 0; font-size: 7.5pt; break-inside: avoid; }
}

@media print and (prefers-color-scheme: dark) {
  :root, html[data-theme], html[data-theme="dark"], html[data-theme="auto"] {
    --bg: #fff; --ink: #161412; --gloss: #3a3732; --muted: #4f4b44; --faint: #6a655c;
    --rule: #c8c2b6; --rule-strong: #a8a090; --accent: #222; --accent-soft: #eee; --press: #fff;
  }
}
.colophon a { color: inherit; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2px; text-decoration-color: var(--rule); }
.colophon a:hover { text-decoration-color: currentColor; }
@media screen { .colophon a { display: inline-block; padding: 13px 0; margin: -13px 0; } }
.print-root { display: none !important; }


/* a quiet label where Rashi begins (once per run of Rashi comments) */
.rashi-label { display: flex; flex-direction: row-reverse; align-items: baseline; gap: .4rem; margin: 0 0 .3rem; line-height: 1; color: var(--muted); }
.rashi-label .rl-he { font-family: var(--he); font-size: .9rem; font-weight: 500; }
.rashi-label .rl-en { font-family: var(--en-text); font-style: italic; font-size: .8125rem; color: var(--gloss); }
@media print { .rashi-label { margin-bottom: 1.5pt; } .rashi-label .rl-he { font-size: 7.8pt; } .rashi-label .rl-en { font-size: 7pt; } }

/* ---------- Shnayim Mikra ---------- */
.sm-resume { margin: 1.1rem 0 0; display: flex; flex-direction: column; align-items: center; gap: 0; }
.sm-resume[hidden] { display: none; }
.sm-resume .linkish { font-family: var(--en-text); font-size: .98rem; }
.resume-at { font-size: .82rem; font-style: italic; font-family: var(--en-text); color: var(--muted); margin-top: -.35rem; }
.al-list { list-style: none; margin: 1.3rem auto 0; padding: 0; max-width: 24rem; border-top: 1px solid var(--rule); text-align: left; }
.al-list li { border-bottom: 1px solid var(--rule); }
.al-row { width: 100%; min-height: 2.9rem; display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: .75rem; padding: .2rem .35rem; text-align: left; }
.al-he { order: 3; font-size: 1.1rem; text-align: right; color: var(--ink); min-width: 4.2rem; }
.al-en { order: 1; display: flex; align-items: baseline; gap: .6rem; line-height: 1.25; flex-wrap: wrap; }
.al-name { font-family: var(--en-text); font-size: .95rem; color: var(--ink); }
.al-range { font-size: .78rem; color: var(--muted); }
.al-state { order: 2; justify-self: end; font-family: var(--en-text); font-style: italic; font-size: .8rem; color: var(--muted); }
.al-list li.done .al-name, .al-list li.done .al-he { color: var(--muted); }
.al-list li.done .al-state::before { content: ""; display: inline-block; width: .55rem; height: .3rem; border: solid currentColor; border-width: 0 0 1px 1px; transform: translateY(-.2rem) rotate(-45deg); margin-right: .4rem; }
.aliyah-mark { display: flex; flex-direction: column; align-items: center; gap: .05rem; margin: 2.2rem 0 .2rem; padding-bottom: .7rem; border-bottom: 1px solid var(--rule-strong); }
.aliyah-mark .am-he { font-size: calc(1.4rem * var(--scale)); font-weight: 700; }
.aliyah-mark .am-en { font-size: .85rem; font-style: italic; font-family: var(--en-text); color: var(--muted); }
.sm-pasuk, .stoppable { cursor: pointer; -webkit-tap-highlight-color: transparent; }
.sm-pasuk .num { margin-bottom: .35rem; }
.stop-btn { display: inline-flex; flex-direction: row-reverse; align-items: center; gap: .55rem; min-height: 2.75rem; min-width: 2.75rem; margin: -.8rem 0 -.6rem; padding: 0 0 0 .25rem; }
.stop-mark { display: none; font-family: var(--en-text); font-style: italic; font-size: .8rem; color: var(--accent); }
.sm-pasuk.stopped .stop-mark, .stoppable.stopped .stop-mark { display: inline; }
.sm-pasuk.stopped::before, .stoppable.stopped::before { content: ""; position: absolute; right: -.7rem; top: 1.1rem; bottom: 1.15rem; width: 2px; background: var(--accent); opacity: .55; }
.il.torah .ch .h, .sm-il .ch .h, .sm-he { font-family: var(--mikra); }
.sm-il .ch .h { line-height: 1.9; padding-top: .12em; }
.sm-he { margin: 0; font-size: calc(var(--he-size) * .92); line-height: 1.9; text-align: right; color: var(--ink); padding-top: .12em; }
.sm-second { margin-top: .55rem; padding-top: .55rem; border-top: 1px dotted var(--rule-strong); }
.sm-il .ch { margin-bottom: .8rem; }
.sm-onk { margin: .65rem 0 0; font-family: var(--he); font-size: calc(var(--he-size) * .7); line-height: 1.8; color: var(--gloss); text-align: right; }
.onk-l { font-size: .78em; color: var(--muted); font-weight: 500; margin-left: .2rem; }
.sm-onk .var { font-size: .85em; color: var(--muted); }
.kri { font-size: .9em; color: var(--muted); }
.pet { font-family: var(--he); font-size: .75em; color: var(--muted); }
.al-end { display: flex; flex-direction: column; align-items: center; gap: 0; padding: 1.4rem 0 .6rem; }
.done-btn { min-height: 2.75rem; padding: 0 1.2rem; border: 1px solid var(--rule-strong); border-radius: 2px; font-family: var(--en-text); font-size: .95rem; color: var(--ink); }
.al-end.done .done-btn { border-color: transparent; color: var(--muted); font-style: italic; cursor: default; }
.al-end .undo { font-size: .82rem; color: var(--muted); }
.al-end .undo[hidden] { display: none; }
.sm-src { margin: 2rem 0 0; font-size: .8rem; color: var(--muted); font-style: italic; font-family: var(--en-text); text-align: center; }
@media (hover: hover) { .done-btn:not([aria-pressed="true"]):hover, .al-row:hover { background: var(--press); } }
@media (max-width: 380px) { .tab-en-x { display: none; } }
@media (min-width: 700px) {
  .stop-btn { flex-direction: column; gap: .3rem; margin: 0; padding: 0; min-height: 2.75rem; }
  .stop-mark { position: absolute; left: 0; top: -1.15rem; white-space: nowrap; font-size: .78rem; }
  .sm-pasuk.stopped::before, .stoppable.stopped::before { right: -.55rem; }
}
.tnum { position: static !important; width: auto !important; margin: 0; display: block; }
.tnum .stop-btn { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); margin: 0; padding: 0; }
.tseg.stopped .tnum .stop-btn, .tnum .stop-btn:focus-visible { position: static; width: auto; height: auto; overflow: visible; clip: auto; min-height: 2rem; margin: -.5rem 0 .1rem; }
.tnum .stop-mark { position: static !important; }
.day-resume { margin-top: .9rem; }
@media print { .stop-mark, .day-resume, .sm-resume, .al-list, .al-end { display: none !important; } .stopped::before { display: none !important; } }
.chseg .ch.dh .h { font-weight: 700; }

/* ---------- CR6: Kitzur, Mishnayos, Tehillim and the "More" section menu ---------- */
html:not([data-tab="kitzur"]) .part.kitzur, html[data-tab="kitzur"] .part:not(.kitzur),
html:not([data-tab="mishnah"]) .part.mishnah, html[data-tab="mishnah"] .part:not(.mishnah),
html:not([data-tab="tehillim"]) .part.tehillim, html[data-tab="tehillim"] .part:not(.tehillim) { display: none; }
.more-caret { width: .8rem; height: .8rem; fill: none; stroke: currentColor; stroke-width: 1.6; margin-inline-start: -.2rem; }
@media (max-width: 479px) { .more-caret { display: none; } }
.sec-list { list-style: none; margin: 0; padding: 0 var(--pad) .6rem; }
.sec-list li + li { border-top: 1px solid var(--rule); }
.sec-item { display: grid; grid-template-columns: 1fr auto; align-items: baseline; gap: .1rem .8rem; width: 100%; text-align: left; padding: .85rem 0; min-height: 3.2rem; color: var(--ink); }
.sec-item[aria-current="true"] .sec-en { font-weight: 600; }
.sec-en { font-size: 1rem; grid-column: 1; grid-row: 1; }
.sec-he { font-family: var(--he); font-size: 1.12rem; direction: rtl; grid-column: 2; grid-row: 1; }
.sec-sub { grid-column: 1 / -1; font-size: .84rem; color: var(--muted); }
.t-cycle { max-width: 20rem; margin: .9rem auto .2rem; }
.t-letter { text-align: center; }
.ar-box { margin: .9rem 0 .4rem; padding: .7rem .9rem; border: 1px solid var(--rule-strong); border-radius: 3px; font-size: .92rem; }
.ar-l { font-weight: 600; margin: 0 0 .3rem; }
.ar-src { display: block; margin-top: .4rem; font-size: .82rem; color: var(--muted); font-style: normal; }
.sm-src { font-size: .82rem; color: var(--muted); margin: 2rem 0 0; line-height: 1.5; }
.rashi.bart { margin-top: .5rem; }
/* Hayom Yom */
html:not([data-tab="hayomyom"]) .part.hayomyom, html[data-tab="hayomyom"] .part:not(.hayomyom) { display: none; }
.hy-note { margin: .4rem auto 1rem; max-width: 34rem; text-align: center; color: var(--muted); font-family: var(--en-text); font-size: .9rem; font-style: italic; }
/* Hayom Yom tab: five tabs on a phone, keep the label on one line */
.tab-en { white-space: nowrap; }
@media (max-width: 420px) { #tab-hayomyom .tab-en { letter-spacing: -.015em; } }

/* a brief, quiet mark after jumping to a saved place */
.mark-flash { animation: mark-flash 1.5s ease-out; border-radius: 6px; }
@keyframes mark-flash {
  0% { background-color: var(--accent-soft); }
  100% { background-color: transparent; }
}
@media (prefers-reduced-motion: reduce) { .mark-flash { animation: none; background-color: var(--accent-soft); } }

/* Ein Yaakov */
html:not([data-tab="einyaakov"]) .part.einyaakov, html[data-tab="einyaakov"] .part:not(.einyaakov) { display: none; }
html:not([data-tab="amudyomi"]) .part.amudyomi, html[data-tab="amudyomi"] .part:not(.amudyomi) { display: none; }
details.by-box { margin: .85rem 0 0; padding: .15rem 0 .2rem; }
details.by-box > summary.tact { list-style: none; cursor: pointer; display: flex; flex-direction: row-reverse; align-items: center; justify-content: flex-start; gap: .55rem; min-height: 2.75rem; width: 100%; padding: .45rem .85rem; box-sizing: border-box; color: var(--muted); }
details.by-box > summary.tact::-webkit-details-marker, details.by-box > summary.tact::marker { display: none; content: ''; }
details.by-box > summary.tact .open-hint { font-family: var(--en-text); font-size: .75rem; color: var(--muted); margin-inline-end: auto; }
details.by-box[open] > summary.tact .open-hint { display: none; }
details.by-box .by-body { padding: .35rem .15rem .4rem; }
details.by-box .by-comment + .by-comment { margin-top: 1.1rem; padding-top: .9rem; border-top: 1px solid var(--rule); }
details.by-box .by-lemma { display: flex; flex-direction: row-reverse; align-items: baseline; justify-content: flex-start; flex-wrap: wrap; gap: .15rem .7rem; margin: 0 0 .55rem; color: var(--muted); }
details.by-box .by-lemma-he { font-family: var(--he); font-size: .95rem; font-weight: 500; }
details.by-box .by-lemma-en { font-family: var(--en-text); font-style: italic; font-size: .8125rem; color: var(--gloss, var(--muted)); }

/* Amud Yomi: quiet Rashi under each Gemara segment, like Bartenura */
.amud-unit + .amud-unit { margin-top: 1.15rem; padding-top: 1rem; border-top: 1px solid var(--rule); }
.ay-note { margin: 0 0 1rem; font-family: var(--en-text); font-size: .875rem; color: var(--muted); text-align: left; max-width: 36rem; margin-left: auto; }
.ay-hadran { display: flex; flex-direction: column; align-items: flex-end; gap: .2rem; margin: 1.1rem 0 1.25rem; padding: .7rem 0; border-top: 1px solid var(--rule-strong); border-bottom: 1px solid var(--rule-strong); }
.ay-hadran-he { font-family: var(--he); font-size: 1.05rem; font-weight: 500; }
.ay-hadran-en { font-family: var(--en-text); font-size: .8125rem; color: var(--muted); text-align: left; width: 100%; }
h3.ay-mishnah-lab { display: flex; flex-direction: row-reverse; align-items: baseline; justify-content: flex-start; gap: .6rem; margin: 1.2rem 0 .7rem; font-weight: 500; }
h3.ay-mishnah-lab .ph-he { font-family: var(--he); font-size: 1.05rem; }
h3.ay-mishnah-lab .ph-en { font-family: var(--en-text); font-size: .875rem; color: var(--muted); }

/* Self-paced seforim: contents and unit views, no daily track */
html[data-mode="self"] #app > .away,
html[data-mode="self"] #app > .daynav { display: none; }
html:not([data-tab="likutei-moharan"]) .part.likutei-moharan, html[data-tab="likutei-moharan"] .part:not(.likutei-moharan),
html:not([data-tab="sefer-hamiddos"]) .part.sefer-hamiddos, html[data-tab="sefer-hamiddos"] .part:not(.sefer-hamiddos) { display: none; }
.sp-toc { margin: .4rem 0 2rem; }
.sp-group { margin: 1.5rem 0 .35rem; text-align: center; font-weight: 400; display: flex; flex-direction: column; align-items: center; gap: .1rem; }
.sp-group-he { font-family: var(--he); font-size: calc(1.35rem * var(--scale)); font-weight: 700; }
.sp-group-en { font-size: .88rem; font-style: italic; font-family: var(--en-text); color: var(--muted); }
.sp-list { margin: .2rem 0 .85rem; padding: 0; display: grid; gap: .45rem; }
.sp-note { margin: 1.6rem auto 0; max-width: 32rem; text-align: center; }
.sp-back { margin-top: .85rem; display: flex; justify-content: center; }
.sp-pager { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; margin: 2.5rem 0 0; padding-top: 1.25rem; border-top: 1px solid var(--rule); }
.sp-continue { margin-top: 1rem; }
@media (max-width: 360px) {
  html[data-mode="self"] .date-en { font-size: .8rem; letter-spacing: 0; }
}
