/* Fonts: the same set as the Shnayim Mikra app (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: #f7f1e3; --paper: #fbf7ec; --ink: #1d1a14; --mute: #8a7f6a; --line: #e4dac3;
  --gold: #9a6b12; --targ: #2f6b4f; --accent: #7a3e12; --mark: #f1d98c66; --chipbg: #efe5cd;
  --tabbg: #f7f1e3ee;
  --hfont: 'SBL Hebrew', 'Taamey Frank', 'Noto Serif Hebrew', 'Times New Roman', serif;
  --tfont: 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-tfont="rashi"] { --tfont: 'Noto Rashi Hebrew', var(--hfont); }
:root[data-theme="dark"] {
  --bg: #16130f; --paper: #1d1914; --ink: #ece3cf; --mute: #9c907a; --line: #332c22;
  --gold: #d8a948; --targ: #8cc9a8; --accent: #e3a066; --mark: #6b551f66; --chipbg: #2a241b; --tabbg: #16130fee;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #16130f; --paper: #1d1914; --ink: #ece3cf; --mute: #9c907a; --line: #332c22;
    --gold: #d8a948; --targ: #8cc9a8; --accent: #e3a066; --mark: #6b551f66; --chipbg: #2a241b; --tabbg: #16130fee;
    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(--gold); 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); }

/* 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); }
.text h4.work:first-child { border-top: 0; margin-top: .2em; }
.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; }
.ar small { font-size: 1em; }
.ar i[data-value]::after { content: ' [' attr(data-value) ']'; font-style: normal; font-size: .6em; 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; }
.tr { font-family: var(--tfont); font-size: calc(var(--fs) * .72); line-height: 1.75; color: var(--targ); margin: .15em 0 .2em; }
:root[data-tfont="rashi"] .tr { font-size: calc(var(--fs) * .76); }
.tr small { font-size: 1em; color: var(--mute); }
.en { font-family: Georgia, 'Times New Roman', serif; font-size: calc(var(--fs) * .66); line-height: 1.6; color: var(--mute); margin: .15em 0 .3em; }
.en small { font-variant: small-caps; font-size: 1em; }
.en sup.footnote-marker { color: var(--accent); cursor: pointer; padding: 0 .15em; font-family: -apple-system, sans-serif; }
.en i.footnote { display: none; }
.en i.footnote.open { display: block; font-style: normal; font-size: .92em; background: var(--chipbg); border-radius: 8px; padding: 5px 9px; margin: 4px 0; }
.btn.mark { width: 100%; margin-top: 14px; padding: 12px; font-size: 16px; }
.btn.mark.on { background: var(--ink); color: var(--bg); }
.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); }
.vol h3 { margin-top: 4px; }
.secrow { display: flex; gap: 10px; align-items: center; padding: 9px 2px; border-top: 1px solid var(--line); text-decoration: none; color: inherit; }
.secrow .nm { font-family: var(--hfont); font-size: 21px; flex: 1; min-width: 0; }
.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 .bar { flex: 0 0 48px; height: 5px; border-radius: 3px; background: var(--line); overflow: hidden; align-self: center; }
.secrow .bar i { display: block; height: 100%; background: var(--targ); }
.srcrow { display: grid; grid-template-columns: auto 1fr 2fr 1.4fr auto; gap: 6px; align-items: center; margin: 6px 0; }
@media (max-width: 560px) { .srcrow { grid-template-columns: auto 1fr auto; } .srcrow input[data-k=url], .srcrow input[data-k=q] { grid-column: 2 / 4; } }
.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/Aramaic 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 { font-family: Georgia, 'Times New Roman', var(--hfont), serif; }
:root[lang="en"] .amud { 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; }
