/* Fonts: the same set as the Shnayim Mikra and Zohar apps (licenses in fonts/). */
@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: 'SBL Hebrew'; src: url('fonts/SBL_Hbrw.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%; }
@font-face { font-family: 'Noto Rashi Hebrew'; src: url('fonts/NotoRashiHebrew.ttf') format('truetype'); font-weight: 100 900; font-display: swap; }

:root {
  --bg: #f4f1e8; --paper: #fbf9f3; --ink: #1c1a16; --mute: #7d7668; --line: #e2dccc;
  --gold: #2f5f8f; --targ: #2f6b4f; --accent: #8a2f2f; --mark: #e8d9a866; --chipbg: #ece7d8;
  --tabbg: #f4f1e8ee;
  --hfont: 'SBL Hebrew', 'Taamey Frank', 'Noto Serif Hebrew', 'Times New Roman', serif;
  --cfont: var(--hfont);
  --fs: 23px;
  color-scheme: light;
}
:root[data-font="noto"] { --hfont: 'Noto Serif Hebrew', 'SBL Hebrew', serif; }
:root[data-font="keter"] { --hfont: 'Keter YG', 'SBL Hebrew', serif; }
:root[data-font="shofar"] { --hfont: 'Shofar', 'SBL Hebrew', serif; }
:root[data-font="cardo"] { --hfont: 'Cardo', 'SBL Hebrew', serif; }
:root[data-font="frankruhl"] { --hfont: 'Frank Ruhl Libre', 'SBL Hebrew', serif; }
:root[data-font="frank"] { --hfont: 'Taamey Frank', 'SBL Hebrew', serif; }
:root[data-font="ezra"] { --hfont: 'Ezra SIL', 'SBL Hebrew', serif; }
:root[data-font="david"] { --hfont: 'David Libre', 'SBL Hebrew', serif; }
:root[data-cfont="rashi"] { --cfont: 'Noto Rashi Hebrew', var(--hfont); }
:root[data-theme="dark"] {
  --bg: #14161a; --paper: #1b1e23; --ink: #e9e3d3; --mute: #978f7e; --line: #2e3138;
  --gold: #8fb6dc; --targ: #8cc9a8; --accent: #e09a8a; --mark: #5a4e2a66; --chipbg: #262a31; --tabbg: #14161aee;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14161a; --paper: #1b1e23; --ink: #e9e3d3; --mute: #978f7e; --line: #2e3138;
    --gold: #8fb6dc; --targ: #8cc9a8; --accent: #e09a8a; --mark: #5a4e2a66; --chipbg: #262a31; --tabbg: #14161aee;
    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(--gold); }
.ltr { direction: ltr; unicode-bidi: isolate; text-align: left; }
main, #top { max-width: 780px; margin: 0 auto; padding-inline: 16px; }
#top { display: flex; align-items: baseline; justify-content: space-between; padding-block: 12px 4px; }
#top h1 { margin: 0; font-family: var(--hfont); color: var(--accent); font-size: 28px; 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: 12px; 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; }
.btn.bad { color: #b3263e; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
input { font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 7px 9px; min-width: 0; }
label.line { display: flex; gap: 8px; align-items: center; margin: 8px 0; }
.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; }
.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); }
.commlist label.line { font-size: 14px; margin: 5px 0; }
.commlist label.line small { color: var(--mute); }

/* the day */
.kicker { color: var(--gold); font-size: 13px; margin-bottom: 4px; }
h2.sec { font-family: var(--hfont); font-size: 27px; margin: 0; font-weight: normal; line-height: 1.3; }
.meta { color: var(--mute); font-size: 13px; margin-top: 4px; }
.links { display: flex; gap: 6px; flex-wrap: wrap; margin: 12px 0 6px; }
.links a { font-size: 13px; text-decoration: none; padding: 5px 10px; border-radius: 8px; background: var(--chipbg); border: 1px solid var(--line); }
.status { font-size: 13px; padding: 7px 10px; border-radius: 10px; background: var(--chipbg); margin-top: 10px; }
.status.ok { color: var(--targ); }

.text { margin-top: 10px; }
.text h4.work { font-family: var(--hfont); font-size: calc(var(--fs) * .9); color: var(--accent); font-weight: normal; margin: 1.2em 0 .3em; padding-top: .5em; border-top: 1px solid var(--line); line-height: 1.35; }
.text h4.work:first-child { border-top: 0; margin-top: .2em; }
.text h4.work small { color: var(--mute); font-size: .7em; }
.text h4.part { color: var(--gold); font-size: calc(var(--fs) * .75); letter-spacing: .02em; margin-bottom: 0; border-top: 0; }
.text h4.part + h4.work { border-top: 0; margin-top: .3em; padding-top: 0; }
.seg-p { position: relative; margin: 0 0 .55em; border-radius: 8px; padding: 0 4px; transition: background .2s; }
.seg-p.mark { background: var(--mark); }
.ar { font-family: var(--hfont); font-size: var(--fs); line-height: 1.85; text-align: justify; margin: 0; word-spacing: .04em; }
.ar b { font-weight: bold; }
.ar big { font-size: 1.3em; line-height: 1; }
/* the Rema's glosses */
.ar small { font-size: .86em; }
.ar small small { font-size: .9em; color: var(--mute); }
.amud { display: inline-block; font-family: var(--hfont); font-size: .62em; color: var(--gold); border: 1px solid color-mix(in srgb, var(--gold) 45%, transparent); border-radius: 6px; padding: 0 .35em; margin-inline-end: .35em; vertical-align: .2em; line-height: 1.35; user-select: none; }
/* commentaries beneath a se'if */
.sulam { margin: .3em 0 .7em; padding: .2em .8em .5em; border-inline-start: 3px solid var(--line); background: var(--chipbg); border-radius: 8px 0 0 8px; cursor: auto; }
.sulam .sh { display: flex; justify-content: space-between; align-items: center; font-size: 13px; color: var(--mute); margin: .2em 0 .1em; }
.sulam .sh b { font-weight: 600; }
.sulam .x { background: none; border: 0; color: var(--mute); font-size: 14px; padding: 4px 6px; cursor: pointer; }
.sulam .none { color: var(--mute); font-size: 14px !important; }
.sulam .loading { color: var(--mute); padding: 8px 0; text-align: start; }
.cm { border-top: 1px solid color-mix(in srgb, var(--line) 60%, transparent); }
.cm summary { list-style: none; cursor: pointer; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 14px; color: var(--accent); padding: .45em 0; font-weight: 600; }
.cm summary::-webkit-details-marker { display: none; }
.cm summary small { color: var(--mute); font-weight: 400; font-size: 12px; }
.cm summary::after { content: '›'; color: var(--mute); transform: rotate(90deg); display: inline-block; transition: .15s; }
.cm[open] summary::after { transform: rotate(-90deg); }
.cm p { font-family: var(--cfont); font-size: calc(var(--fs) * .72); line-height: 1.75; margin: .25em 0 .5em; text-align: justify; }
:root[data-cfont="rashi"] .cm p { font-size: calc(var(--fs) * .78); }
.cm p b { color: var(--targ); }
.btn.mark { width: 100%; margin-top: 14px; padding: 12px; font-size: 16px; }
.day.done { border-color: color-mix(in srgb, var(--targ) 50%, var(--line)); }
.day.done .btn.mark { color: var(--targ); }
.loading { text-align: center; color: var(--mute); padding: 40px 0; }
.qbar { height: 9px; border-radius: 6px; background: var(--chipbg); overflow: hidden; border: 1px solid var(--line); }
.qbar > div { height: 100%; background: var(--targ); }

.row-day { display: flex; gap: 10px; align-items: center; padding: 8px 2px; border-top: 1px solid var(--line); text-decoration: none; color: inherit; font-size: 14px; }
.row-day .dt { flex: 0 0 7.5em; color: var(--mute); }
.row-day .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-day .ck { flex: 0 0 1.2em; color: var(--targ); }
.row-day.done .nm { color: var(--mute); }
.row-day.now { background: var(--mark); border-radius: 8px; }
.row-day .go { color: var(--mute); }
.yearbar { display: flex; justify-content: space-between; align-items: center; margin: 10px 0; }
.blk summary { list-style: none; cursor: pointer; }
.blk summary::-webkit-details-marker { display: none; }
.blk .when { color: var(--gold); font-size: 13px; }
.blk .nm { font-family: var(--hfont); font-size: 21px; margin: 2px 0; }
.blk.cur { border-color: var(--gold); }
/* the four parts */
.partcard { display: flex; align-items: center; gap: 14px; }
.partcard .nm { font-family: var(--hfont); font-size: 26px; 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; }
.partcard .pct { color: var(--mute); font-size: 13px; white-space: nowrap; }
.partcard .qbar { width: 64px; }
.partcard .go { color: var(--mute); font-size: 20px; }
.secrow { display: flex; gap: 10px; align-items: center; padding: 9px 2px; border-top: 1px solid var(--line); text-decoration: none; color: inherit; }
.secrow .num { flex: 0 0 3.2em; font-family: var(--hfont); font-size: 19px; color: var(--gold); }
.secrow .nm { font-family: var(--hfont); font-size: 19px; flex: 1; min-width: 0; line-height: 1.3; }
.secrow .info { display: flex; flex-direction: column; align-items: flex-end; text-align: end; flex: 0 0 auto; }
.secrow .pg { color: var(--mute); font-size: 12.5px; white-space: nowrap; }
.secrow .when { color: var(--gold); font-size: 12.5px; white-space: nowrap; }
.secrow.now { background: var(--mark); border-radius: 8px; }
.secrow .ck { flex: 0 0 1.2em; color: var(--targ); text-align: center; }
.secrow.done .nm { color: var(--mute); }
.back { margin-top: 8px; }

#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; }
.owed { display: flex; justify-content: space-between; align-items: center; text-decoration: none; color: var(--accent); background: var(--chipbg); border: 1px solid var(--line); border-radius: 12px; padding: 9px 14px; margin-top: 12px; font-size: 14px; }

/* 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"] .text h4.work, :root[lang="en"] .blk .nm, :root[lang="en"] .secrow .nm, :root[lang="en"] .partcard .nm { font-family: Georgia, 'Times New Roman', var(--hfont), serif; }
:root[lang="en"] .amud, :root[lang="en"] .secrow .num { font-family: Georgia, serif; }
:root[lang="en"] .row-day .dt { flex-basis: 8.6em; white-space: nowrap; }
:root[lang="en"] .blk .row-day .nm { font-size: 17px; }
:root[lang="en"] .secrow .nm { font-size: 17px; }
