:root {
  --bg: #fdf6e3;
  --text: #2b2620;
  --muted: #8b8174;
  --rule: #e6dfd2;
  --current-bg: #f3e6c4;
  --current-bar: #b07a1e;
  --pause-bg: #f7efdb;
  --player-bg: rgba(253, 246, 227, 0.94);
  --greek: "EB Garamond", "Gentium Book Plus", "Noto Serif", "Times New Roman", serif;
  color-scheme: light;  /* native controls (the book list, scrollbars) follow the theme */
}
/* The font for the Greek (the Aa menu). Garamond runs small, so the text is set about 10%
   larger for it; the others take that back with --font-scale. */
:root[data-font="gentium"] { --greek: "Gentium Book Plus", "GFS Didot", "Noto Serif", "Times New Roman", serif; --font-scale: 0.91; }
:root[data-font="didot"] { --greek: "GFS Didot", "Gentium Book Plus", "Noto Serif", "Times New Roman", serif; --font-scale: 0.91; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1d1a16;
    --text: #e9e2d6;
    --muted: #8f8577;
    --rule: #34302a;
    --current-bg: #3d3220;
    --current-bar: #d9a441;
    --pause-bg: #2c271e;
    --player-bg: rgba(29, 26, 22, 0.94);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #1d1a16;
  --text: #e9e2d6;
  --muted: #8f8577;
  --rule: #34302a;
  --current-bg: #3d3220;
  --current-bar: #d9a441;
  --pause-bg: #2c271e;
  --player-bg: rgba(29, 26, 22, 0.94);
}

* { box-sizing: border-box; }
html { scroll-padding-top: 4rem; scroll-padding-bottom: 120px; overflow-x: clip; }
/* Feel like an app on phones: no double-tap zoom (pinch zoom is off in the viewport tag). */
body { touch-action: manipulation; -webkit-text-size-adjust: 100%; }
/* No blue box flashing over whatever is tapped. */
html { -webkit-tap-highlight-color: transparent; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--greek);
  font-size: 23px;  /* EB Garamond runs small */
  line-height: 1.55;
}
main {
  font-size: calc(var(--text-scale, 1) * var(--font-scale, 1) * 1em);  /* the reader's Text size */
  max-width: 44rem;
  margin: 0 auto;
  padding: 1.5rem 16px 9rem;
}

/* Title bar, always at the top of the viewport. */
#topbar {
  position: sticky;
  top: 0;
  padding-top: env(safe-area-inset-top);  /* below the notch in the installed app */
  z-index: 4;
  background: var(--player-bg);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--rule);
}
.topbar-inner {
  max-width: 44rem;
  margin: 0 auto;
  padding: 0.45rem 16px;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.eyebrow { color: var(--muted); letter-spacing: 0.06em; font-size: 0.85em; white-space: nowrap;
           min-width: 0; overflow: hidden; text-overflow: ellipsis; }
/* Book picker: a button and a short menu under it (a native select fills a phone's
   screen with its list). */
#book-picker { position: relative; min-width: 0; }
#book-picker[hidden] { display: none; }
#book-select {
  min-width: 0;
  max-width: 100%;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font: inherit;
  font-size: 1.05em;
  color: var(--text);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0.1rem 0.3rem;
  cursor: pointer;
}
#book-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#book-select svg { flex: none; color: var(--muted); }
#book-select:hover, #book-select:focus-visible, #book-select[aria-expanded="true"] { border-color: var(--rule); outline: none; }
#book-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 7;
  min-width: 11rem;
  max-width: calc(100vw - 32px);
  max-height: min(50vh, 24rem);
  max-height: min(50dvh, 24rem);
  overflow-y: auto;
  overscroll-behavior: contain;
  margin: 0;
  padding: 0.3rem 0;
  list-style: none;
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 10px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.14);
  font-size: 16px;
}
#book-menu a {
  display: block;
  padding: 0.45rem 0.9rem;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#book-menu a:hover, #book-menu a:focus-visible { background: var(--current-bg); outline: none; }
#book-menu [aria-selected="true"] a { color: var(--current-bar); font-weight: 600; }
#to-start {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font: 13px system-ui, sans-serif;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 0.25rem 0.7rem;
  cursor: pointer;
}
#to-start:hover { color: var(--text); border-color: var(--current-bar); }
/* Theme switch: automatic (follows the system) -> light -> dark. */
#theme {
  display: grid;
  place-items: center;
  width: 1.85rem;
  height: 1.85rem;
  padding: 0;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 50%;
  cursor: pointer;
}
#theme:hover { color: var(--text); border-color: var(--current-bar); }
/* The bars and their controls, at the reader's Interface size. */
#topbar, #player { zoom: var(--ui-scale, 1); }

/* Text size menu (Aa): text and interface, each stepped smaller or larger. */
#size-picker { position: relative; flex: none; }
#size-button {
  height: 1.85rem;
  padding: 0 0.45rem;
  font: 15px var(--greek);
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 0.95rem;
  cursor: pointer;
}
#size-button:hover, #size-button[aria-expanded="true"] { color: var(--text); border-color: var(--current-bar); }
#size-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 7;
  display: grid;
  gap: 0.4rem;
  padding: 0.6rem 0.75rem;
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 10px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.14);
  font: 14px system-ui, sans-serif;
  color: var(--muted);
  white-space: nowrap;
}
#size-menu[hidden] { display: none; }
.size-row { display: grid; grid-template-columns: 5.2rem 2rem 3.2rem 2rem; align-items: center; }
.font-row { display: flex; align-items: center; gap: 0.3rem; margin-top: 0.15rem; }
.font-row .size-name { width: 5.2rem; flex: none; }
.font-choice {
  padding: 0.2rem 0.5rem;
  font-size: 17px;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 6px;
  cursor: pointer;
}
.font-choice[data-font="garamond"] { font-family: "EB Garamond", serif; }
.font-choice[data-font="gentium"] { font-family: "Gentium Book Plus", serif; font-size: 15.5px; }
.font-choice[data-font="didot"] { font-family: "GFS Didot", serif; font-size: 15.5px; }
.font-choice:hover { color: var(--text); border-color: var(--current-bar); }
.font-choice[aria-pressed="true"] { color: var(--text); border-color: var(--current-bar); background: var(--current-bg); }
.size-value { text-align: center; font-variant-numeric: tabular-nums; color: var(--text); }
.size-step {
  width: 2rem;
  height: 2rem;
  display: grid;
  place-items: center;
  padding: 0;
  font: 18px system-ui, sans-serif;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 50%;
  cursor: pointer;
}
.size-step:hover:not(:disabled) { color: var(--text); border-color: var(--current-bar); }
.size-step:disabled { opacity: 0.35; cursor: default; }
#theme svg { display: none; }
#theme[data-mode="auto"] .th-auto, #theme[data-mode="light"] .th-light, #theme[data-mode="dark"] .th-dark { display: block; }
.credits { text-align: center; margin-bottom: 1rem; }

#verses { list-style: none; margin: 0; padding: 0; }
.credit { margin: 0.4rem 0 0; color: var(--muted); font-family: system-ui, sans-serif; font-size: 12px; }
body:not(.show-translation) #translation-credit { display: none; }
body:not(.show-modern) #modern-credit { display: none; }

/* Murray's English, one passage (~5 lines) after the verses it translates. */
.trans {
  margin: -0.2rem 0 1.2rem calc(3rem + 3px + 0.75rem);
  padding: 0.35rem 0.8rem;
  border-left: 2px solid var(--rule);
  font-family: Georgia, "Iowan Old Style", "Times New Roman", serif;
  font-size: 0.78em;
  line-height: 1.55;
  color: var(--muted);
  cursor: pointer;
  transition: border-color 120ms ease, color 120ms ease;
}
.trans .lines { font-family: system-ui, sans-serif; font-size: 11px; margin-right: 0.4rem; opacity: 0.8; }
.trans.active { border-left-color: var(--current-bar); color: var(--text); }
body:not(.show-translation) .trans { display: none; }

/* Polylas's modern Greek, one line per verse. */
.verse .mt {
  grid-column: 2;
  margin-top: 0.15rem;
  font-size: 0.8em;
  line-height: 1.45;
  color: color-mix(in srgb, var(--current-bar) 55%, var(--muted));
}
.verse.current .mt { color: color-mix(in srgb, var(--current-bar) 75%, var(--text)); }
body:not(.show-modern) .verse .mt { display: none; }

/* Murray's English for a single line (where split), under the verse. */
.verse .en {
  grid-column: 2;
  margin-top: 0.15rem;
  font-family: Georgia, "Iowan Old Style", "Times New Roman", serif;
  font-size: 0.74em;
  line-height: 1.45;
  color: var(--muted);
}
.verse.current .en { color: color-mix(in srgb, var(--text) 70%, var(--muted)); }
body:not(.show-translation) .verse .en { display: none; }
.verse {
  display: grid;
  grid-template-columns: 3rem 1fr;
  column-gap: 0.75rem;
  margin-bottom: 0.7rem;
  padding: 0.25rem 0.6rem 0.3rem 0;
  border-left: 3px solid transparent;
  border-radius: 0 4px 4px 0;
  cursor: pointer;
  transition: background-color 120ms ease;
}
.verse:hover { background: color-mix(in srgb, var(--current-bg) 35%, transparent); }
.verse { position: relative; }
.verse .seek-icon {
  position: absolute;
  left: 0.2rem;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  color: var(--muted);
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease;
}
.verse:not(.untimed):hover .seek-icon { opacity: 0.85; }
@media (hover: none) { .verse .seek-icon { display: none; } }
.verse .num {
  text-align: right;
  color: var(--muted);
  font-size: 0.7em;
  padding-top: 0.35em;
  font-variant-numeric: tabular-nums;
  user-select: none;
}
.verse .num.hidden { visibility: hidden; }
.verse.title { font-style: italic; color: var(--muted); margin-bottom: 1.4rem; }
.verse .para {
  grid-column: 2;
  margin-top: 0.15rem;
  color: var(--muted);
  font-size: 0.8em;
  line-height: 1.45;
}
.verse.current .para { color: color-mix(in srgb, var(--text) 70%, var(--muted)); }
body.hide-paraphrase .verse .para { display: none; }
body.hide-paraphrase .verse { margin-bottom: 0.35rem; }
.w { border-radius: 3px; transition: background-color 80ms ease; }
.w.linked {
  background: color-mix(in srgb, var(--current-bar) 22%, transparent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--current-bar) 22%, transparent);
}
/* Only where there is real hover: on touch a tap would leave the tint stuck. */
@media (hover: hover) {
  .w[data-gloss]:hover {
    background: color-mix(in srgb, var(--current-bar) 22%, transparent);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--current-bar) 22%, transparent);
  }
}

.w { cursor: pointer; }
.w.selected { background: color-mix(in srgb, var(--current-bar) 30%, transparent); border-radius: 3px;
              box-shadow: 0 0 0 2px color-mix(in srgb, var(--current-bar) 30%, transparent); }

#card {
  position: fixed;
  z-index: 5;
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 10px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.14);
  padding: 1rem 1.1rem 1.1rem;
  overflow-y: auto;
  font-size: calc(18.5px * var(--text-scale, 1) * var(--font-scale, 1));
  line-height: 1.45;
}
#card-close {
  position: absolute; top: 0.4rem; right: 0.5rem;
  border: 0; background: transparent; color: var(--muted);
  font-size: 22px; line-height: 1; cursor: pointer; padding: 0.2rem 0.4rem;
}
#card-close:hover { color: var(--text); }
#card h2 { margin: 0 1.5rem 0.2rem 0; font-weight: 400; font-size: 1.6em; }
#card .gloss-line { color: var(--muted); margin: 0 0 0.8rem; }
#card .token + .token { border-top: 1px solid var(--rule); margin-top: 0.8rem; padding-top: 0.8rem; }
#card .form { color: var(--muted); font-size: 0.85em; margin-bottom: 0.2rem; }
#card .lemma { font-size: 1.25em; }
#card .lemma a {
  font-family: system-ui, sans-serif; font-size: 12px; margin-left: 0.5rem;
  color: var(--current-bar); text-decoration: none; vertical-align: middle;
}
#card .lemma a:hover { text-decoration: underline; }
#card .definition { margin-top: 0.15rem; font-family: system-ui, sans-serif; font-size: 14.5px; }
#card .morph { display: flex; flex-wrap: wrap; gap: 0.3rem; margin: 0.45rem 0; }
#card .morph span {
  font-family: system-ui, sans-serif; font-size: 12.5px;
  padding: 0.12rem 0.5rem; border-radius: 999px;
  background: color-mix(in srgb, var(--current-bg) 70%, transparent);
}
#card .role { font-size: 0.92em; }
#card .role code { font-size: 11px; color: var(--muted); margin-left: 0.3rem; }
#card .note { font-size: 0.85em; color: var(--muted); font-style: italic; margin-top: 0.4rem; }
#card .label { font-family: system-ui, sans-serif; font-size: 11px; letter-spacing: 0.06em;
               text-transform: uppercase; color: var(--muted); margin-right: 0.35rem; }

/* Wide screens: card in the right-hand margin beside the text column (which stays put),
   centred vertically in the space above the player. */
@media (min-width: 76rem) {
  #card {
    top: calc(50vh - 3.75rem);
    transform: translateY(-50%);
    right: 1.25rem;
    width: clamp(14rem, calc((100vw - 44rem) / 2 - 2.5rem), 22rem);
    max-height: calc(100vh - 11rem);
  }
}
/* Narrower screens: card floating above the selected word's line (placed by placeCard). */
@media (max-width: 75.99rem) {
  #card { width: min(22rem, calc(100vw - 16px)); }
}

/* Scholia: the ancient notes on the current verse. */
#scholia {
  position: fixed;
  z-index: 3;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 10px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.1);
  font-size: calc(18px * var(--text-scale, 1) * var(--font-scale, 1));
  line-height: 1.5;
}
#scholia[hidden] { display: none; }
.sch-head {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.55rem 0.6rem 0.45rem 1rem;
  border-bottom: 1px solid var(--rule);
}
.sch-title { font-size: 1.1em; }
#scholia-line { font-family: system-ui, sans-serif; font-size: 12.5px; color: var(--current-bar);
                font-variant-numeric: tabular-nums; }
#scholia-close {
  margin-left: auto;
  border: 0; background: transparent; color: var(--muted);
  font-size: 22px; line-height: 1; cursor: pointer; padding: 0 0.3rem;
}
#scholia-close:hover { color: var(--text); }
#scholia-body { flex: 1; min-height: 0; overflow-y: auto; padding: 0.3rem 1.35rem 0.6rem 1rem; }
/* Scrolling panels: a thin scrollbar in the theme's colours, with its own gutter (classic
   scrollbars) and room in the padding for overlay ones, so it never covers the counts. */
#scholia-body, #card {
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--muted) 55%, transparent) transparent;
  scrollbar-gutter: stable;
}
#scholia .note { color: var(--muted); font-style: italic; }
.sch-src { margin-top: 0.4rem; }
.sch-src summary {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.25rem 0;
  font-family: system-ui, sans-serif;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.sch-src summary::-webkit-details-marker { display: none; }
.sch-src summary::before { content: "▸"; font-size: 16px; line-height: 1; transition: transform 120ms ease; }
.sch-src[open] summary::before { transform: rotate(90deg); }
.sch-src summary:hover { color: var(--text); }
.siglum {
  font-family: var(--greek);
  font-size: 16.5px;
  font-weight: 700;
  color: var(--current-bar);
  min-width: 1.1em;
}
.sch-src .count {
  margin-left: auto;
  font-size: 11.5px;
  padding: 0 0.45rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--current-bg) 70%, transparent);
}
.sch { margin: 0.2rem 0 0.65rem; }
.sch .lemma { font-weight: 700; }
.sch .range {
  float: right;
  margin-left: 0.4rem;
  font-family: system-ui, sans-serif;
  font-size: 11px;
  color: var(--muted);
}
.sch-credit {
  margin: 0;
  padding: 0.4rem 1rem 0.55rem;
  border-top: 1px solid var(--rule);
  font-family: system-ui, sans-serif;
  font-size: 11px;
  color: var(--muted);
}

/* Wide screens: in the left-hand margin, like the scholia around the text of a manuscript. */
@media (min-width: 90rem) {
  #scholia {
    top: 4.25rem;
    bottom: 8rem;
    left: 1.25rem;
    width: clamp(16rem, calc((100vw - 44rem) / 2 - 5rem), 26rem);
  }
}
/* Narrower (no room for a column): no toggle; a button on each verse with scholia opens
   them in a popup. */
.sch-btn { display: none; }
@media (max-width: 89.99rem) {
  .toggle:has(#show-scholia) { display: none; }
  .verse:has(.sch-btn) { padding-right: 2.1rem; }
  .sch-btn {
    position: absolute;
    right: 0.15rem;
    top: 0.3rem;
    display: grid;
    place-items: center;
    width: 1.9rem;
    height: 1.9rem;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--muted);
    opacity: 0.55;
    cursor: pointer;
  }
  .verse.current .sch-btn, .sch-btn:hover { opacity: 1; color: var(--current-bar); }
  /* The page behind the popup doesn't scroll, so only the popup has a scrollbar. */
  html:has(body.scholia-popup) { overflow: hidden; }
  body.scholia-popup::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 5;
    background: rgba(0, 0, 0, 0.4);
  }
  body.scholia-popup #scholia {
    z-index: 6;
    top: 50%;
    left: 50%;
    width: min(40rem, calc(100vw - 32px));
    max-height: min(70vh, 36rem);
    max-height: min(70dvh, 36rem);
    transform: translate(-50%, -50%);
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.3);
  }
}

#gloss {
  position: absolute;
  z-index: 10;
  max-width: min(22rem, calc(100vw - 16px));
  padding: 0.3rem 0.6rem;
  border-radius: 6px;
  background: var(--text);
  color: var(--bg);
  font-size: 0.85em;
  line-height: 1.35;
  pointer-events: none;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
}
#gloss.none { opacity: 0.75; font-style: italic; }
.verse.current { background: var(--current-bg); border-left-color: var(--current-bar); }
.verse.current .num { color: var(--current-bar); visibility: visible; }
.verse.current.pausing { background: var(--pause-bg); }
.verse.current.held { background: var(--current-bg); box-shadow: inset 0 -2px 0 var(--current-bar); }
.verse.untimed { cursor: default; }

#player {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: var(--player-bg);
  backdrop-filter: blur(6px);
  border-top: 1px solid var(--rule);
  padding: 0.6rem 16px calc(0.6rem + env(safe-area-inset-bottom));
  /* Above the focused-mode animations, and on its own layer: iOS otherwise drops a
     blurred fixed bar while the lines beneath it animate. */
  z-index: 4;
  transform: translateZ(0);
}
#player audio { display: none; }

/* Media bar: volume, previous / play-pause / next, line box and timeline. */
.playback { flex: none; display: inline-flex; align-items: center; gap: 0.45rem; }
.transport {
  max-width: 44rem;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-family: system-ui, sans-serif;
  font-size: 14px;
  color: var(--muted);
}
.tbtn {
  flex: none;
  width: 2.1rem;
  height: 2.1rem;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--rule);
  border-radius: 50%;
  background: var(--bg);
  color: var(--muted);
  cursor: pointer;
}
.tbtn:hover { color: var(--text); border-color: var(--current-bar); }
.tbtn.play { width: 2.7rem; height: 2.7rem; color: var(--bg); background: var(--current-bar); border-color: var(--current-bar); }
.tbtn.play:hover { color: var(--bg); filter: brightness(1.08); }
.tbtn.bare { border-color: transparent; background: transparent; }
.play .icon-pause, body.playing .play .icon-play { display: none; }
body.playing .play .icon-pause { display: block; }

.timeline { flex: 1; min-width: 9rem; display: flex; align-items: center; gap: 0.45rem; }
.time { font-variant-numeric: tabular-nums; font-size: 12.5px; min-width: 2.6rem; text-align: center; }

/* Range inputs (seek and volume): thin track filled up to the thumb (--pct). */
#seek, #volume {
  --pct: 0%;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(to right, var(--current-bar) var(--pct), var(--rule) var(--pct));
  cursor: pointer;
  margin: 0;
}
#seek { flex: 1; min-width: 0; }
#volume { width: 4.5rem; }
#seek::-webkit-slider-thumb, #volume::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 13px; height: 13px; border-radius: 50%;
  background: var(--current-bar); border: 2px solid var(--bg);
  box-shadow: 0 0 0 1px var(--current-bar);
}
#seek::-moz-range-thumb, #volume::-moz-range-thumb {
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--current-bar); border: 2px solid var(--bg);
  box-shadow: 0 0 0 1px var(--current-bar);
}
#seek:focus-visible, #volume:focus-visible { outline: 2px solid var(--current-bar); outline-offset: 4px; }

.volume { flex: none; display: inline-flex; align-items: center; gap: 0.1rem; }
#mute .vol-x, body.muted #mute .vol-waves { display: none; }
body.muted #mute .vol-x { display: inline; }

.controls {
  max-width: 56rem;
  margin: 0.45rem auto 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.35rem 0.9rem;
  font-family: system-ui, sans-serif;
  font-size: 13px;
  color: var(--muted);
}

/* Narrow screens: volume, the play buttons (centred) and the line on one row, the timeline below. */
@media (max-width: 600px) {
  .transport { display: grid; grid-template-columns: 1fr auto 1fr; row-gap: 0.35rem; }
  .volume { justify-self: start; }
  #position { justify-self: end; }
  .timeline { grid-column: 1 / -1; }
}

#position {
  width: 6.5rem;
  padding: 0.2rem 0.3rem;
  text-align: center;
  font: inherit;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: text;
}
#position:hover { border-color: var(--rule); }
#position:focus { outline: none; border-color: var(--current-bar); color: var(--text); background: var(--bg); }
#position.invalid { border-color: #c0392b; }
.toggle { display: flex; align-items: center; gap: 0.35rem; cursor: pointer; }

/* Focused mode: only the current verse (large, centred) and its neighbours, in exactly
   the space between the bars: the page never scrolls. The current verse is always shown
   whole; a long neighbour is cut off at the edge rather than pushing it out of view.
   (--topbar-h and --player-h are the bars' heights, kept up to date by app.js.) */
html:has(body.focused) { overflow: hidden; }
body.focused .credits { display: none; }
body.focused main {
  height: calc(100vh - var(--topbar-h, 3rem) - var(--player-h, 7rem));
  height: calc(100svh - var(--topbar-h, 3rem) - var(--player-h, 7rem));  /* phones: toolbars shown */
  display: flex;
  flex-direction: column;
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
}
body.focused #verses {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto minmax(0, 1fr);
  overflow-y: clip;
  overflow-x: visible;  /* the step buttons sit in the left margin */
}
body.focused #verses > li:not(.f-cur):not(.f-prev):not(.f-next) { display: none; }
body.focused #verses > li.trans { display: none; }
body.focused .verse.f-prev { grid-row: 1; align-self: end; }
body.focused .verse.f-cur { grid-row: 2; }
body.focused .verse.f-next { grid-row: 3; align-self: start; }
body.focused .verse { transition: opacity 200ms ease; }
/* The neighbours are context only: no hover, highlight or clicks. */
body.focused .verse.f-prev,
body.focused .verse.f-next { opacity: 0.4; pointer-events: none; }
body.focused .verse.f-cur { font-size: 1.3em; margin: 1.4rem 0; padding-top: 0.5rem; padding-bottom: 0.6rem; }
body.focused .verse.f-cur .num { visibility: visible; }
/* Phones: sit the verse lower, leaving room for a word's card above it. */
@media (max-width: 600px) {
  body.focused #verses { grid-template-rows: minmax(0, 3fr) auto minmax(0, 2fr); }
}

/* Focused mode: previous / play-pause / next, stacked at the left of the reading area.
   They stay put while the verses change beside them. */
#focus-controls { display: none; }
body.focused main { position: relative; }
body.focused #focus-controls {
  position: absolute;
  left: calc(16px - 3rem);
  top: 50%;
  transform: translateY(-50%);
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 16px;
}
#focus-controls button {
  width: 2.1rem;
  height: 2.1rem;
  display: grid;
  place-items: center;
  border: 1px solid var(--rule);
  border-radius: 50%;
  background: var(--bg);
  color: var(--muted);
  cursor: pointer;
  padding: 0;
}
#focus-controls button:hover { color: var(--text); border-color: var(--current-bar); }
#fc-play { color: var(--current-bar); }
#fc-play .icon-pause, body.playing #fc-play .icon-play { display: none; }
body.playing #fc-play .icon-pause { display: block; }
body.focused .verse.f-cur .seek-icon { display: none; }
/* Too narrow for the left margin: the controls take a gutter of their own, and the
   verses (and their highlight) start to the right of it. */
@media (max-width: 52rem) {
  body.focused #focus-controls { left: 8px; }
  body.focused #verses { padding-left: 2.1rem; }
}
/* Phones: no buttons (the media bar and swipes step verses), so no gutter either. */
@media (max-width: 600px) {
  body.focused #focus-controls { display: none; }
  body.focused #verses { padding-left: 0; }
}

@media (max-width: 520px) {
  body { font-size: 21px; }
  .topbar-inner { gap: 0.4rem; }
  .to-start-text { display: none; }  /* icon only */
  #to-start { padding: 0; width: 1.85rem; height: 1.85rem; justify-content: center; flex-shrink: 0; }
  #theme, #home { flex-shrink: 0; }
  /* iPhones zoom in on any text box under 16px when it's tapped. */
  input, select, textarea { font-size: 16px !important; }
  .trans { margin-left: calc(2.2rem + 3px + 0.5rem); }
  .verse { grid-template-columns: 2.2rem 1fr; column-gap: 0.5rem; }
  .verse:not(.untimed):hover .num { visibility: hidden; }  /* narrow column: the icon takes its place */
}

/* Back to the library. */
#home {
  display: grid;
  place-items: center;
  color: var(--muted);
  border-radius: 6px;
  padding: 0.15rem;
}
#home:hover { color: var(--text); }

/* Only the controls a text has data for: a library text without a recording keeps the
   position box (for jumping to a line or section). */
body.no-audio .playback, body.no-audio .timeline, body.no-audio .volume,
body.no-audio .toggle:has(#focused), body.no-audio .toggle:has(#hold-on-hover), body.no-audio .toggle:has(#follow),
body.no-paraphrase .toggle:has(#show-paraphrase), body.no-modern .toggle:has(#show-modern),
body.no-translation .toggle:has(#show-translation), body.no-scholia .toggle:has(#show-scholia) { display: none; }
body.no-audio.no-paraphrase.no-modern.no-translation.no-scholia .controls { display: none; }
body.no-audio .transport { display: flex; justify-content: center; }
body.no-audio #position { width: 8rem; margin-left: 0; border-color: var(--rule); }
body.no-audio .verse { cursor: auto; }
body.no-audio .verse:hover { background: none; }

/* Prose: a paragraph per speech, the section (Stephanus) that opens it in the margin and
   later ones marked in the text. */
#verses.prose .verse { margin-bottom: 0.9rem; line-height: 1.6; }
#verses.prose .num { visibility: visible; padding-top: 0.45em; }
.speaker { color: var(--muted); font-size: 0.78em; letter-spacing: 0.05em; margin-right: 0.15em; }
.ref-mark {
  font: 11px system-ui, sans-serif;
  color: var(--muted);
  vertical-align: 0.35em;
  padding: 0 0.1em;
  user-select: none;
}

/* Where the position box jumped to. */
@keyframes located { from { background-color: var(--current-bg); } to { background-color: transparent; } }
.located { animation: located 1.8s ease-out; border-radius: 4px; }

/* The library (index.html). */
/* The library is all navigation: it follows the reader's Interface size, not Text. */
.library main { padding-bottom: 4rem; font-size: 1em; }
.library main, .library-tools { zoom: var(--ui-scale, 1); }
.library-tools {
  position: absolute;
  top: calc(0.9rem + env(safe-area-inset-top));
  right: 16px;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.library h1 { font-weight: 400; font-size: 1.6em; margin: 0.6rem 0 0.2rem; text-align: center; }
.library .sub { text-align: center; color: var(--muted); font: 13px system-ui, sans-serif; margin: 0 0 1.5rem; }
.category { margin: 2rem 0 0; }
.category > h2 {
  font: 600 12px system-ui, sans-serif;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--rule);
  padding-bottom: 0.35rem;
  margin: 0 0 0.6rem;
}
.category .empty { color: var(--muted); font: italic 14px system-ui, sans-serif; margin: 0.4rem 0; }
.work { padding: 0.55rem 0; border-bottom: 1px solid color-mix(in srgb, var(--rule) 60%, transparent); }
.work:last-child { border-bottom: none; }
.work-head { display: flex; align-items: baseline; gap: 0.6rem; flex-wrap: wrap; }
.work-title { color: var(--text); text-decoration: none; font-size: 1.15em; }
a.work-title:hover { color: var(--current-bar); }
.work-author { color: var(--muted); font-size: 0.8em; }
.books { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-top: 0.35rem; }
.books a {
  min-width: 1.9rem;
  padding: 0.05rem 0.35rem;
  text-align: center;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.8em;
  border: 1px solid var(--rule);
  border-radius: 6px;
}
.books a:hover { color: var(--text); border-color: var(--current-bar); }
.library .notice { color: var(--muted); font: 14px system-ui, sans-serif; text-align: center; margin-top: 2rem; }
.library .notice code { font-size: 13px; }
/* Verse without a paraphrase under each line: set closer. */
body.no-paraphrase #verses:not(.prose) .verse { margin-bottom: 0.15rem; padding-top: 0.1rem; padding-bottom: 0.1rem; }
/* Without a recording, the line or paragraph the σχόλια panel is showing. */
body.show-scholia .verse.noted, body.scholia-popup .verse.noted { border-left-color: color-mix(in srgb, var(--current-bar) 60%, transparent); background: color-mix(in srgb, var(--current-bg) 40%, transparent); }
