:root {
  --bg: #ffffff;
  --fg: #111111;
  --muted: #555555;
  --line: #d6d6d6;
  --accent: #2b2b2e;
  --danger: #a4161a;
  --ok: #1b6b2f;
  font-size: 18px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--fg); }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* Top bar */
#bar {
  display: flex; align-items: center; gap: .25rem;
  padding: .4rem .5rem; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: var(--bg); z-index: 2;
}
.brand { font-weight: 700; background: none; border: 0; padding: .5rem; margin-right: auto; }
nav { display: flex; gap: 0; }
nav button, .exit { background: none; border: 0; padding: .55rem .5rem; min-height: 44px; }
.exit { font-size: 1.2rem; min-width: 44px; border-radius: 8px; }
.exit:active, .icon:active { background: var(--line); }

main { max-width: 40rem; margin: 0 auto; padding: 1rem; outline: none; }
h1 { font-size: 1.5rem; margin: .4rem 0 1rem; }
h2 { font-size: 1.15rem; margin: 1.6rem 0 .4rem; }
p { margin: .5rem 0; }
.muted { color: var(--muted); font-size: .9rem; }
.mono { font-family: ui-monospace, monospace; word-break: break-all; }
.warn { color: var(--danger); }
.ok { color: var(--ok); font-weight: 600; }
.hint { background: #fff6d6; border: 1px solid #e8d48a; padding: .7rem; border-radius: 8px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

input[type="search"] {
  width: 100%; padding: .8rem; margin: .5rem 0 .8rem;
  border: 2px solid var(--line); border-radius: 10px; background: var(--bg);
}

.big {
  display: block; width: 100%; text-align: start;
  padding: .9rem 1rem; margin: .5rem 0; min-height: 52px;
  border: 0; border-radius: 10px; background: var(--accent); color: #fff; font-weight: 600;
}
.danger { background: var(--danger); }
.small { padding: .5rem .8rem; min-height: 44px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
.back { background: none; border: 0; padding: .5rem 0; min-height: 44px; color: var(--muted); }

.list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.list li { border-bottom: 1px solid var(--line); }
.row {
  display: flex; align-items: center; gap: .75rem; width: 100%;
  padding: .9rem .25rem; min-height: 60px; background: none; border: 0; text-align: start;
}
.row.static { cursor: default; }
.row .label { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.row .meta { color: var(--muted); font-size: .9rem; white-space: nowrap; }
.native { font-size: 1.1rem; }
.sub { color: var(--muted); font-size: .85rem; }
.empty { padding: 1rem .25rem; color: var(--muted); }
ul.plain, ol.plain { padding-inline-start: 1.3rem; }
ul.plain li, ol.plain li { margin: .4rem 0; }

.progress { margin: .6rem 0 1rem; }
.bar { height: 14px; background: var(--line); border-radius: 7px; overflow: hidden; }
.fill { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.ptext { font-size: .9rem; color: var(--muted); }

.nowplaying {
  position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); z-index: 3;
  padding: .8rem 1.3rem; border: 0; border-radius: 999px; background: var(--accent); color: #fff; font-weight: 600;
}

/* Main screen: language dropdown + player */
.player.main .ptop { align-items: center; gap: .25rem; }
.ptop .grow { flex: 1; }
.lang-select { display: inline-flex; align-items: center; gap: .5rem; max-width: 70vw; min-height: 48px; padding: .5rem .9rem;
  border: 2px solid var(--line); border-radius: 12px; background: var(--bg); font-size: 1.15rem; font-weight: 600; }
.lang-select span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.caret { color: var(--muted); font-size: .9rem; }
.trackbar { display: flex; align-items: center; justify-content: center; gap: 1.2rem; margin-bottom: .8rem; }
.counter { color: var(--muted); font-variant-numeric: tabular-nums; min-width: 4.5rem; text-align: center; }
.play, .skip { flex: none; }
.big-icon { font-size: 1.4rem; }
.icon:disabled { opacity: .3; }
.pill.ok { color: var(--ok); display: inline-flex; align-items: center; }
.save-pill:disabled { opacity: .7; }
.sheet-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 10; display: flex; align-items: flex-start; justify-content: center; }
.sheet { background: var(--bg); width: 100%; max-width: 32rem; max-height: 100%; height: 100dvh; display: flex; flex-direction: column; }
@media (min-width: 600px) { .sheet { height: auto; max-height: 85vh; margin-top: 5vh; border-radius: 14px; } }
.sheet-head { display: flex; gap: .4rem; align-items: center; padding: .6rem; border-bottom: 1px solid var(--line); padding-top: max(.6rem, env(safe-area-inset-top)); }
.sheet-search { flex: 1; padding: .8rem; font-size: 1.1rem; border: 2px solid var(--line); border-radius: 10px; background: var(--bg); margin: 0; }
.sheet-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; -webkit-overflow-scrolling: touch; }
.sheet-list li { border-bottom: 1px solid var(--line); }
.sheet-item { display: block; width: 100%; text-align: start; padding: .95rem 1rem; min-height: 56px; background: none; border: 0; font-size: 1.2rem; }
.sheet-item.on { font-weight: 700; background: color-mix(in srgb, var(--accent) 10%, transparent); }

/* Choosing languages */
.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin: .4rem 0; }
.chip { border: 0; border-radius: 999px; padding: .45rem .8rem; min-height: 40px; background: var(--accent); color: #fff; font-weight: 600; }
.row.pick .tick { width: 1.6rem; height: 1.6rem; flex: none; border: 2px solid var(--line); border-radius: 6px; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; }
.row.pick.on .tick { background: var(--accent); border-color: var(--accent); color: #fff; }
.big:disabled { opacity: .45; cursor: default; }

/* Collections and reading */
nav button.on { text-decoration: underline; text-underline-offset: 6px; text-decoration-thickness: 2px; }
.collection { margin: 1.6rem 0 0; }
.collection h2 { margin: 0 0 .2rem; }
.credit { color: var(--muted); font-size: .8rem; margin: .1rem 0 .6rem; }
.save { display: block; width: 100%; text-align: start; padding: .75rem 1rem; min-height: 48px; margin: .4rem 0 .8rem;
  border: 2px solid var(--accent); border-radius: 10px; background: var(--bg); color: var(--accent); font-weight: 600; }
.big.alt { background: var(--bg); color: var(--accent); border: 2px solid var(--accent); }
.readbar { display: flex; align-items: center; gap: .4rem; }
.readbar .grow { flex: 1; }
.reader { font-size: calc(1.05rem * var(--read-scale, 1)); line-height: 1.65; overflow-wrap: anywhere; }
.reader h2 { font-size: 1.2em; margin: 1.4em 0 .4em; }
.reader p { margin: .7em 0; }
.reader .verses sup { font-size: .65em; color: var(--muted); font-weight: 600; margin-inline-start: .15em; }
.reader img { display: block; max-width: 100%; height: auto; margin: 1em auto; border: 1px solid var(--line); }
.reader .credit { margin-top: 2em; }

/* Player: a blank page with only the audio controls. */
body.player-mode #bar { display: none; }
body.player-mode main { max-width: none; padding: 0; }
.player {
  min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column;
  padding: env(safe-area-inset-top) 1rem env(safe-area-inset-bottom);
}
.ptop { display: flex; justify-content: space-between; padding-top: .5rem; }
.icon { background: none; border: 0; font-size: 1.3rem; min-width: 48px; min-height: 48px; border-radius: 10px; color: var(--muted); }
.pmid { flex: 1; display: flex; flex-direction: column; justify-content: center; width: 100%; max-width: 30rem; margin: 0 auto; padding-bottom: 12vh; }
.seek { width: 100%; height: 44px; accent-color: var(--accent); margin: 0; }
.times { display: flex; justify-content: space-between; color: var(--muted); font-size: .9rem; font-variant-numeric: tabular-nums; }
.controls { display: flex; align-items: center; justify-content: center; gap: 1.5rem; margin: 1.8rem 0; }
.play {
  width: 88px; height: 88px; border-radius: 50%; border: 0;
  background: var(--accent); color: #fff; font-size: 2rem; line-height: 1;
}
.skip { background: none; border: 2px solid var(--line); border-radius: 999px; padding: .7rem .9rem; min-width: 72px; min-height: 52px; font-weight: 600; }
.settings { display: flex; justify-content: center; gap: .75rem; flex-wrap: wrap; }
.pill { background: var(--bg); border: 2px solid var(--line); border-radius: 999px; padding: .6rem 1.1rem; min-height: 48px; font-weight: 600; }

@media (max-width: 420px) {
  nav button { padding: .55rem .35rem; font-size: .9rem; }
  .brand { font-size: .95rem; padding: .5rem .3rem; }
}
@media (max-width: 360px) {
  :root { font-size: 16px; }
  .controls { gap: .9rem; }
}

/* Option 1: quiet player */
.player.main .ptop { display: grid; grid-template-columns: 48px 1fr 48px; align-items: center; }
.icon { display: inline-flex; align-items: center; justify-content: center; }
.lang-title { justify-self: center; display: inline-flex; align-items: center; gap: .3rem; max-width: 100%; min-height: 40px; padding: .35rem .8rem;
  background: #ececee; border: 0; border-radius: 8px; font-size: 1rem; font-weight: 600; color: var(--fg); }
.lang-title span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lang-title svg { color: var(--muted); flex: none; }
.lang-title:active { background: #dcdce0; }
.tool:active, .controls.quiet .icon:active { background: var(--line); }
.seek.thin { -webkit-appearance: none; appearance: none; height: 28px; background: transparent; --fill: 0%; }
.seek.thin::-webkit-slider-runnable-track { height: 3px; border-radius: 2px; background: linear-gradient(to right, var(--fg) var(--fill), var(--line) var(--fill)); }
.seek.thin::-moz-range-track { height: 3px; border-radius: 2px; background: var(--line); }
.seek.thin::-moz-range-progress { height: 3px; border-radius: 2px; background: var(--fg); }
.seek.thin::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; margin-top: -5.5px; border-radius: 50%; background: var(--fg); border: 0; }
.seek.thin::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--fg); border: 0; }
.player.main .times { font-size: .78rem; color: var(--muted); margin-top: -.2rem; }
.controls.quiet { gap: .6rem; margin: 1.6rem 0 0; color: var(--muted); }
.controls.quiet .icon { min-width: 52px; min-height: 52px; border-radius: 50%; color: var(--muted); }
.controls.quiet .icon[hidden] { display: inline-flex; visibility: hidden; }
.controls.quiet .play { width: 76px; height: 76px; display: inline-flex; align-items: center; justify-content: center; background: var(--fg); color: var(--bg); margin: 0 .4rem; }
.tools { display: flex; justify-content: center; gap: 2.2rem; padding: 0 0 max(1.4rem, env(safe-area-inset-bottom)); color: var(--muted); }
.tool { position: relative; display: inline-flex; align-items: center; justify-content: center; min-width: 48px; min-height: 48px; border-radius: 50%;
  background: none; border: 0; color: var(--muted); }
.tool.active, .tool.done { color: var(--ok); }
.tool.active { color: var(--fg); }
.speed-label { font-size: .95rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.tool-select { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; font-size: 16px; }
.tool-badge { position: absolute; top: 4px; right: 0; font-size: .62rem; font-weight: 700; color: var(--fg); }
