@font-face { font-family: 'SBL Hebrew'; src: url('fonts/SBL_Hbrw.ttf') format('truetype'); font-display: swap; }

:root {
  --bg: #f7f1e3; --paper: #fbf7ec; --ink: #1d1a14; --mute: #8a7f6a; --line: #e4dac3;
  --gold: #9a6b12; --gold2: #b8860b; --chipbg: #efe5cd; --barbg: #f7f1e3f2; --btn: #2a2210; --btnink: #f6e7bd;
  --glow: #d08a0c; --halo: rgba(255, 186, 60, .55); --halo2: rgba(255, 160, 30, .22); --said: #7a4e05; --flash: #ffb200;
  --live: #c0392b;
  --hfont: 'SBL Hebrew', 'Taamey Frank', 'Noto Serif Hebrew', 'Times New Roman', serif;
  --ui: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --fs: 30px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #16130f; --paper: #1d1914; --ink: #ece3cf; --mute: #9c907a; --line: #332c22;
  --gold: #d8a948; --gold2: #f0c565; --chipbg: #2a241b; --barbg: #16130ff2; --btn: #f0c565; --btnink: #1d1914;
  --glow: #ffd36a; --halo: rgba(255, 200, 90, .8); --halo2: rgba(255, 170, 40, .38); --said: #fff0c2; --flash: #ffffff;
  --live: #ff6b5b;
  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; --gold2: #f0c565; --chipbg: #2a241b; --barbg: #16130ff2; --btn: #f0c565; --btnink: #1d1914;
    --glow: #ffd36a; --halo: rgba(255, 200, 90, .8); --halo2: rgba(255, 170, 40, .38); --said: #fff0c2; --flash: #ffffff;
    --live: #ff6b5b;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--ui); -webkit-tap-highlight-color: transparent; }
body { min-height: 100dvh; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

/* ---- header: title, nusach, kinds ---- */
#top { position: sticky; top: 0; z-index: 5; background: var(--barbg); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); padding-top: env(safe-area-inset-top, 0px); }
#top .row1 { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px 6px; }
#top h1 { margin: 0; font: 700 20px/1 var(--ui); color: var(--gold); letter-spacing: .02em; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--paper); }
.seg button { padding: 7px 11px; font-size: 13px; color: var(--mute); border-inline-start: 1px solid var(--line); white-space: nowrap; }
.seg button:first-child { border-inline-start: 0; }
.seg button.on { background: var(--chipbg); color: var(--ink); font-weight: 600; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 4px 14px 10px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips button { flex: 0 0 auto; padding: 6px 12px; border-radius: 99px; background: var(--chipbg); color: var(--mute); font-size: 13px; border: 1px solid transparent; }
.chips button.on { color: var(--ink); border-color: var(--gold); font-weight: 600; }

/* ---- the text ---- */
main { padding: 0 16px; max-width: 760px; margin: 0 auto; }
.view { display: none; }
.view.on { display: block; }
.head { padding: 14px 2px 6px; }
.head h2 { margin: 0 0 4px; font: 600 17px/1.3 var(--ui); color: var(--gold2); }
.note { margin: 0 0 10px; font-size: 13px; line-height: 1.45; color: var(--mute); }
#progWrap { height: 3px; background: var(--line); border-radius: 2px; overflow: hidden; }
#prog { height: 100%; width: 0; background: var(--gold); transition: width .3s; box-shadow: 0 0 8px var(--halo); }
#text { font-family: var(--hfont); font-size: var(--fs); line-height: 1.9; text-align: right; padding: 10px 2px 8px; user-select: none; -webkit-user-select: none; }
#text p { margin: 0 0 .7em; }
.w { display: inline-block; padding: 0 .06em; border-radius: .18em; color: var(--ink); opacity: .82; transition: color .35s, text-shadow .5s, opacity .35s; }
.w.said { color: var(--said); opacity: 1; text-shadow: 0 0 1px var(--glow), 0 0 .28em var(--halo), 0 0 .7em var(--halo2); }
.w.now { animation: flare 1.3s ease-out; }
@keyframes flare {
  0% { color: var(--flash); text-shadow: 0 0 .1em var(--flash), 0 0 .5em var(--glow), 0 0 1.2em var(--halo); }
  100% { color: var(--said); text-shadow: 0 0 1px var(--glow), 0 0 .28em var(--halo), 0 0 .7em var(--halo2); }
}
.w.next { box-shadow: 0 .12em 0 0 var(--gold); opacity: 1; }
.r, .v, .n { font-family: var(--hfont); color: var(--mute); }
.r { font-size: .58em; }
.v { font-size: .5em; opacity: .9; }
.n, .nl { font-size: .5em; font-family: var(--ui); }
#text p.rl { font-size: .58em; color: var(--mute); margin: -.3em 0 .9em; }
#text p.nl { font-size: .5em; color: var(--mute); font-family: var(--ui); margin: 0 0 .6em; }
#text.done .w.said { animation: flare 1.4s ease-out; }
.spacer { height: 150px; }

/* ---- the bar ---- */
#bar { position: fixed; inset-inline: 0; bottom: 0; z-index: 6; background: var(--barbg); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-top: 1px solid var(--line); padding: 8px 16px calc(10px + env(safe-area-inset-bottom, 0px)); }
#status { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; font-size: 13px; color: var(--mute); min-height: 18px; max-width: 760px; margin: 0 auto 8px; }
#stLine { flex: 1 1 auto; min-width: 0; line-height: 1.35; }
#heard { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--hfont); font-size: 15px; color: var(--gold2); direction: rtl; text-align: center; }
#heard:empty { display: none; }
#count { flex: 0 0 auto; font-variant-numeric: tabular-nums; }
.ctl { display: flex; align-items: center; justify-content: center; gap: 28px; }
.side { width: 44px; height: 44px; border-radius: 50%; color: var(--mute); display: grid; place-items: center; }
.side:active { background: var(--chipbg); }
.mic { --lvl: 0; width: 66px; height: 66px; border-radius: 50%; background: var(--btn); color: var(--btnink); display: grid; place-items: center; box-shadow: 0 2px 10px rgba(0, 0, 0, .25); transition: background .3s, color .3s; position: relative; }
.mic.on { background: var(--live); color: #fff; }
.mic.on::before { content: ''; position: absolute; inset: -6px; border-radius: 50%; border: 2px solid var(--live); opacity: .6; animation: pulse 1.6s ease-out infinite; }
.mic.on::after { content: ''; position: absolute; inset: calc(-4px - 14px * var(--lvl)); border-radius: 50%; background: var(--live); opacity: calc(.08 + .2 * var(--lvl)); transition: inset .08s, opacity .08s; }
@keyframes pulse { 0% { transform: scale(1); opacity: .6; } 100% { transform: scale(1.35); opacity: 0; } }

/* ---- settings ---- */
#v-settings { padding: 14px 0 160px; }
.card { background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; margin-bottom: 12px; }
.card h3 { margin: 4px 0 8px; font: 600 14px/1.3 var(--ui); color: var(--gold2); }
.card h3 + .seg { margin-bottom: 10px; }
.fine { font-size: 12.5px; line-height: 1.5; color: var(--mute); margin: 8px 2px; }
.row { display: flex; align-items: center; gap: 10px; font-size: 14px; padding: 8px 0 2px; }
.row input { width: 18px; height: 18px; accent-color: var(--gold); }
#fsz span { padding: 7px 14px; font-size: 13px; color: var(--ink); border-inline-start: 1px solid var(--line); }
.back { display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: 10px; color: var(--gold2); font-weight: 600; font-size: 14px; margin-bottom: 6px; }

[dir=ltr] #text { text-align: right; }
