/* Fonts: the free set of the other pivotalapps readers (licenses in fonts/); no SBL Hebrew here. */
@font-face { font-family: 'Taamey Frank'; src: url('fonts/TaameyFrankCLM-Medium.ttf') format('truetype'); font-display: swap; }
@font-face { font-family: 'Noto Serif Hebrew'; src: url('fonts/NotoSerifHebrew.ttf') format('truetype'); font-weight: 100 900; font-display: swap; }
@font-face { font-family: 'Keter YG'; src: url('fonts/KeterYG-Medium.ttf') format('truetype'); font-display: swap; }
@font-face { font-family: 'Shofar'; src: url('fonts/ShofarRegular.ttf') format('truetype'); font-display: swap; }
@font-face { font-family: 'Cardo'; src: url('fonts/Cardo-Regular.ttf') format('truetype'); font-display: swap; }
@font-face { font-family: 'Frank Ruhl Libre'; src: url('fonts/FrankRuhlLibre.ttf') format('truetype'); font-weight: 300 900; font-display: swap; }
@font-face { font-family: 'David Libre'; src: url('fonts/DavidLibre-Regular.ttf') format('truetype'); font-display: swap; }
@font-face { font-family: 'Ezra SIL'; src: url('fonts/EzraSIL.ttf') format('truetype'); font-display: swap; size-adjust: 86%; }

:root {
  --bg: #f5f0e6; --paper: #fcfaf4; --ink: #1d1a17; --mute: #7c7467; --line: #e3dccb;
  --gold: #8a6a1f; --blue: #2f5f8f; --targ: #2f6b4f; --accent: #6a2e4f; --chipbg: #eee8d9; --tabbg: #f5f0e6ee;
  --soft: #f7f1e4; --hot: #ffe9a8; --flame: #e8a33a;
  --hfont: 'Taamey Frank', 'Noto Serif Hebrew', 'Times New Roman', serif;
  --efont: Georgia, 'Times New Roman', serif;
  --fs: 22px;
  color-scheme: light;
}
:root[data-font="noto"] { --hfont: 'Noto Serif Hebrew', 'Taamey Frank', serif; }
:root[data-font="keter"] { --hfont: 'Keter YG', 'Taamey Frank', serif; }
:root[data-font="shofar"] { --hfont: 'Shofar', 'Taamey Frank', serif; }
:root[data-font="cardo"] { --hfont: 'Cardo', 'Taamey Frank', serif; }
:root[data-font="frankruhl"] { --hfont: 'Frank Ruhl Libre', 'Taamey Frank', serif; }
:root[data-font="frank"] { --hfont: 'Taamey Frank', 'Noto Serif Hebrew', serif; }
:root[data-font="ezra"] { --hfont: 'Ezra SIL', 'Taamey Frank', serif; }
:root[data-font="david"] { --hfont: 'David Libre', 'Taamey Frank', serif; }
:root[data-theme="dark"] {
  --bg: #1b1722; --paper: #241e2d; --ink: #ebe4d6; --mute: #9a9184; --line: #352d40;
  --gold: #d6b25a; --blue: #8fb6dc; --targ: #8cc9a8; --accent: #d9a3c4; --chipbg: #2e2739; --tabbg: #1b1722ee; --soft: #2a2335; --hot: #4a4120;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1b1722; --paper: #241e2d; --ink: #ebe4d6; --mute: #9a9184; --line: #352d40;
    --gold: #d6b25a; --blue: #8fb6dc; --targ: #8cc9a8; --accent: #d9a3c4; --chipbg: #2e2739; --tabbg: #1b1722ee; --soft: #2a2335; --hot: #4a4120;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font: 15px/1.45 -apple-system, 'Segoe UI', Roboto, 'Noto Sans Hebrew', sans-serif; padding: env(safe-area-inset-top, 0px) 0 calc(70px + env(safe-area-inset-bottom, 0px)); min-height: 100vh; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: var(--blue); }
main, #top { max-width: 780px; margin: 0 auto; padding-inline: 16px; }
#top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding-block: 12px 4px; flex-wrap: wrap; }
#top h1 { margin: 0; font-family: var(--hfont); color: var(--accent); font-size: 30px; font-weight: normal; }
#top .sub { color: var(--mute); font-size: 13px; }
.view { display: none; } .view.on { display: block; }

.card { background: var(--paper); border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px; margin: 12px 0; display: block; color: inherit; text-decoration: none; }
.card h3 { margin: 0 0 10px; font-size: 16px; color: var(--accent); display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.card h3 small { color: var(--mute); font-weight: 400; font-size: 12px; }
.fine { color: var(--mute); font-size: 12.5px; line-height: 1.6; }
.btn { border: 1px solid var(--line); background: var(--chipbg); border-radius: 10px; padding: 9px 14px; }
.btn.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn.small { padding: 5px 10px; font-size: 13px; }
.row-label { display: block; color: var(--mute); font-size: 12.5px; margin: 14px 0 6px; }
.seg { display: flex; background: var(--chipbg); border-radius: 10px; padding: 3px; gap: 3px; flex-wrap: wrap; }
.seg button { flex: 1; padding: 8px 4px; border-radius: 8px; font-size: 13.5px; background: none; border: 0; }
.seg button.on { background: var(--paper); box-shadow: 0 1px 3px #0002; font-weight: 600; }
.fonts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
.fonts button { background: var(--chipbg); border: 0; border-radius: 10px; padding: 6px 8px 7px; text-align: center; }
.fonts button.on { background: var(--ink); color: var(--bg); }
.fonts button b { display: block; font-weight: normal; font-size: 22px; line-height: 1.6; }
.fonts button small { display: block; font-size: 11px; opacity: .7; }
.size { display: flex; align-items: center; gap: 10px; }
.size button { background: var(--chipbg); border: 0; border-radius: 10px; padding: 7px 16px; font-family: var(--hfont); font-size: 18px; }
.size span { min-width: 3em; text-align: center; color: var(--mute); }
.loading { text-align: center; color: var(--mute); padding: 40px 0; }

/* the dedication */
.ded { text-align: center; padding: 6px 0 4px; }
.ded .dl { color: var(--mute); font-size: 13px; letter-spacing: .04em; }
.ded .dn { font-family: var(--hfont); font-size: 34px; color: var(--accent); line-height: 1.3; margin: 2px 0; }
.ded .dn .zl { font-size: .6em; color: var(--gold); }
.ded .dnen { font-family: var(--efont); font-size: 17px; color: var(--mute); }
.ded .dy { margin-top: 6px; font-size: 14px; }
.ded .ynext { color: var(--mute); font-size: 13px; margin-top: 4px; line-height: 1.5; }
.ded .ynow { margin: 10px auto 2px; display: inline-block; background: var(--soft); border: 1px solid var(--line); border-radius: 12px; padding: 8px 16px; font-size: 16px; color: var(--accent); font-weight: 600; }
.ded .ynow small { display: block; font-weight: 400; color: var(--mute); font-size: 12.5px; margin-top: 2px; }
.ded.live .dn { text-shadow: 0 0 18px #e8a33a55; }
.ded .ylink { display: inline-block; margin-top: 8px; font-size: 13.5px; text-decoration: none; }
.mem .ded .dn { font-size: 36px; }
@media (max-width: 420px) { .mem .ded .dn { font-size: 32px; } }

/* the book tab */
.partcard { display: flex; align-items: center; gap: 14px; }
.partcard .nm { font-family: var(--hfont); font-size: 24px; flex: 1; min-width: 0; line-height: 1.2; }
.partcard .nm small { display: block; font-family: -apple-system, 'Segoe UI', Roboto, sans-serif; font-size: 12.5px; color: var(--mute); margin-top: 3px; line-height: 1.4; }
.partcard .go { color: var(--mute); font-size: 20px; }
.shab { background: var(--soft); font-size: 14px; }
.shab a { text-decoration: none; font-weight: 600; }
.chgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.chcell { display: block; padding: 10px 12px; border-radius: 12px; background: var(--chipbg); color: var(--ink); text-decoration: none; border: 1px solid transparent; }
.chcell .cn { display: block; font-family: var(--hfont); font-size: 22px; line-height: 1.2; }
.chcell small { display: block; color: var(--mute); font-size: 11.5px; margin-top: 3px; line-height: 1.4; }
.chcell.done { background: color-mix(in srgb, var(--targ) 22%, var(--chipbg)); }
.chcell.done .cn { color: var(--targ); }
.chcell.now { border-color: var(--accent); }
.back { margin-top: 8px; }

/* a chapter */
.chead { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.chead.foot { margin-top: 14px; }
.chead .nav { font-size: 13px; text-decoration: none; color: var(--blue); white-space: nowrap; padding: 4px 8px; border-radius: 8px; background: var(--chipbg); }
h2.sec { font-family: var(--hfont); font-size: 28px; margin: 0; font-weight: normal; line-height: 1.3; text-align: center; flex: 1; }
h2.sec small { display: block; font-size: .6em; color: var(--mute); }
.meta { color: var(--mute); font-size: 13px; margin-top: 4px; text-align: center; }
.chips { display: flex; gap: 8px; justify-content: center; align-items: center; flex-wrap: wrap; margin: 10px 0 2px; font-size: 13px; }
.chipgrp { display: inline-flex; gap: 4px; align-items: center; background: var(--chipbg); border-radius: 999px; padding: 3px 4px 3px 10px; }
.chipgrp .lbl { color: var(--mute); margin-inline-end: 2px; }
.chip { display: inline-block; padding: 5px 12px; border-radius: 999px; background: var(--chipbg); color: var(--mute); cursor: pointer; user-select: none; border: 1px solid transparent; }
.chipgrp .chip { padding: 3px 10px; }
.chip.on { background: var(--paper); color: var(--accent); font-weight: 600; border-color: var(--line); }
.flow { margin-top: 12px; }
.links { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0 4px; }
.links a { font-size: 12.5px; text-decoration: none; padding: 4px 10px; border-radius: 8px; background: var(--chipbg); border: 1px solid var(--line); color: var(--blue); }
.btn.mark { width: 100%; margin-top: 14px; padding: 12px; font-size: 16px; }
.chapter.done .btn.mark { color: var(--targ); }

/* a mishnah */
.ms { padding: 14px 0 6px; border-top: 1px solid var(--line); scroll-margin-top: 20px; border-radius: 10px; transition: background .5s; }
.ms:first-child { border-top: 0; }
.ms.flash { background: var(--hot); }
.mh { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.mh .mn { font-family: var(--hfont); font-size: calc(var(--fs) * .8); color: var(--gold); }
.mh .sef { font-size: 11.5px; text-decoration: none; color: var(--mute); }
.mt { font-family: var(--hfont); font-size: calc(var(--fs) * 1.08); line-height: 1.85; text-align: justify; margin-top: 2px; }
.men { font-family: var(--efont); font-size: calc(var(--fs) * .74); line-height: 1.6; color: var(--ink); opacity: .9; margin-top: 8px; padding-inline-start: .2em; }
.comm { margin: 12px 0 4px; padding: 10px 14px 6px; background: var(--soft); border-radius: 12px; border-inline-start: 3px solid var(--accent); }
.comm .cl { font-size: 12px; color: var(--accent); letter-spacing: .03em; font-weight: 600; margin-bottom: 4px; }
.ce { margin: 0 0 .7em; }
.ce p { margin: 0; }
.ce .che { font-family: var(--hfont); font-size: calc(var(--fs) * .9); line-height: 1.8; text-align: justify; }
.ce .cen { font-family: var(--efont); font-size: calc(var(--fs) * .76); line-height: 1.6; }
.ce .che + .cen { margin-top: .3em; opacity: .85; }
.ce .dh { font-weight: bold; color: var(--accent); }
.ce.note { border-inline-start: 2px dotted var(--gold); padding-inline-start: 10px; margin-inline-start: 2px; }
.ce .nt { display: block; font-size: 11px; color: var(--gold); letter-spacing: .03em; }
.ce .fallback small { color: var(--mute); font-size: 11.5px; font-family: -apple-system, 'Segoe UI', Roboto, sans-serif; }

/* the memorial Tehillim */
.ps { border-top: 1px solid var(--line); padding: 8px 0 4px; }
.ps summary { display: flex; align-items: baseline; gap: 10px; cursor: pointer; list-style: none; padding: 6px 0; }
.ps summary::-webkit-details-marker { display: none; }
.ps summary::before { content: '▸'; color: var(--mute); font-size: 13px; transition: transform .15s; }
.ps[open] summary::before { transform: rotate(90deg); }
:root[dir="rtl"] .ps summary::before { content: '◂'; }
:root[dir="rtl"] .ps[open] summary::before { transform: rotate(-90deg); }
.ps .pn { font-family: var(--hfont); font-size: 22px; color: var(--accent); }
.ps summary small { color: var(--mute); font-family: var(--hfont); font-size: 15px; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vs { display: flex; gap: .6em; align-items: baseline; flex-wrap: wrap; padding: .3em .5em; margin: .1em -.5em; border-radius: 10px; }
.vs .vn { flex: 0 0 auto; font-family: var(--hfont); font-size: calc(var(--fs) * .65); color: var(--gold); min-width: 1.6em; text-align: center; }
.vs .vt { flex: 1 1 20em; font-family: var(--hfont); font-size: calc(var(--fs) * 1.02); line-height: 1.9; }
.vs .en { flex-basis: 100%; font-family: var(--efont); font-size: calc(var(--fs) * .7); line-height: 1.55; opacity: .85; padding-inline-start: 2.4em; }
.vs + .vs { border-top: 1px dotted var(--line); }
.nm119 { font-family: var(--hfont); font-weight: normal; font-size: 30px; color: var(--accent); text-align: center; margin: 18px 0 4px; letter-spacing: .15em; }
.letter { margin-top: 10px; }
.lh { display: flex; align-items: baseline; gap: 10px; margin: 8px 0 2px; }
.lh .big { font-family: var(--hfont); font-size: 30px; color: var(--gold); background: var(--chipbg); border-radius: 10px; padding: 0 12px; line-height: 1.5; }
.lh small { color: var(--mute); font-size: 12.5px; }

#tabs { position: fixed; bottom: 0; inset-inline: 0; display: flex; background: var(--tabbg); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom, 0px); z-index: 10; }
#tabs button { flex: 1; background: none; border: 0; padding: 8px 0 9px; color: var(--mute); font-size: 12px; display: flex; flex-direction: column; align-items: center; gap: 1px; }
#tabs button .i { font-size: 19px; }
#tabs button.on { color: var(--accent); }
#toast { position: fixed; bottom: calc(76px + env(safe-area-inset-bottom, 0px)); left: 50%; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; transition: .2s; background: var(--ink); color: var(--bg); padding: 9px 14px; border-radius: 12px; display: flex; gap: 12px; align-items: center; z-index: 20; }
#toast.on { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
#toast button { background: none; border: 0; color: var(--bg); font-weight: 700; text-decoration: underline; }

@media (min-width: 900px) {
  .card.chapter { padding: 18px 26px; }
}
/* English UI: Latin headings in a Latin serif; the Hebrew text keeps its font. */
:root[lang="en"] #top h1, :root[lang="en"] h2.sec, :root[lang="en"] .partcard .nm, :root[lang="en"] .chcell .cn, :root[lang="en"] .ps .pn { font-family: var(--efont); }
:root[lang="en"] #top h1 { font-size: 26px; }
:root[lang="en"] .chcell .cn { font-size: 18px; }
:root[lang="en"] .partcard .nm { font-size: 20px; }
:root[lang="en"] .mt, :root[lang="en"] .ce .che, :root[lang="en"] .vs .vt { direction: rtl; }
:root[lang="en"] .mh .mn, :root[lang="en"] .vs .vn { font-family: var(--efont); font-size: calc(var(--fs) * .6); }
