:root {
  color-scheme: light;
  --bg: #f7f7f4;
  --ink: #18211f;
  --muted: #68716e;
  --line: #d8ddd8;
  --panel: #ffffff;
  --panel-strong: #eef4f0;
  --topbar-bg: rgba(247, 247, 244, 0.94);
  --teal: #126b63;
  --teal-dark: #0c4944;
  --red: #9b2f2f;
  --gold: #b58518;
  --verse-hover: #f7d59a;
  --description: #2d3532;
  --text-flow: #505552;
  --marker: #3f4643;
  --commentary: #596460;
  --commentary-strong: #444a47;
  --toggle-track: #cfd8d4;
  --toggle-knob: #ffffff;
  --active-ink: #ffffff;
  --shadow: 0 16px 40px rgba(24, 33, 31, 0.08);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111513;
  --ink: #edf2ef;
  --muted: #a2aea9;
  --line: #303a36;
  --panel: #1b211f;
  --panel-strong: #242e2a;
  --topbar-bg: rgba(17, 21, 19, 0.94);
  --teal: #58c9bc;
  --teal-dark: #8fe1d7;
  --red: #e58a8a;
  --gold: #e0b85d;
  --verse-hover: #614a25;
  --description: #c7d0cc;
  --text-flow: #dce4e0;
  --marker: #aab5b0;
  --commentary: #c0cac5;
  --commentary-strong: #edf2ef;
  --toggle-track: #404b47;
  --toggle-knob: #ffffff;
  --active-ink: #101513;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button {
  font: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 28px;
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

html[data-header-sticky="false"] .topbar {
  position: static;
}

.eyebrow,
.chapter-meta {
  margin: 0 0 4px;
  color: var(--teal);
  font-size: 0.85rem;
  font-weight: 700;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 1.9rem;
  line-height: 1.1;
}

.nav-selectors,
.chapter-nav,
.reader-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.nav-selectors {
  gap: 10px;
}

.nav-selectors label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.nav-selectors select {
  min-width: 92px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  font-weight: 800;
}

.nav-selectors .header-toggle {
  align-self: end;
  display: flex;
  align-items: center;
  color: var(--ink);
  font-size: 0.9rem;
}

#bookSelect {
  min-width: 136px;
}

.intro-toggle {
  min-height: 36px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  border-radius: 8px;
  padding: 6px 12px;
}

.intro-toggle.active {
  border-color: var(--teal);
  background: var(--teal);
  color: var(--active-ink);
}

.reader-toggle {
  min-height: 36px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  font-weight: 700;
  user-select: none;
}

.reader-toggle input {
  appearance: none;
  width: 38px;
  height: 22px;
  margin: 0;
  border-radius: 999px;
  background: var(--toggle-track);
  position: relative;
  cursor: pointer;
}

.reader-toggle input::before {
  content: "";
  position: absolute;
  top: 3px;
  right: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--toggle-knob);
  transition: transform 140ms ease;
}

.reader-toggle input:checked {
  background: var(--teal);
}

.reader-toggle input:checked::before {
  transform: translateX(-16px);
}

.layout {
  display: block;
  width: min(1380px, 100%);
  margin: 0 auto;
  padding: 22px 28px 36px;
}

.reader {
  min-width: 0;
  max-width: 960px;
  margin: 0 auto;
}

.chapter-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
}

.chapter-head h2 {
  margin: 0;
  font-size: 1.55rem;
}

.chapter-controls {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.chapter-nav {
  justify-content: flex-end;
}

.chapter-nav-button {
  width: 38px;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  font-size: 1.18rem;
  font-weight: 800;
  line-height: 1;
}

.chapter-nav-button.annotation-panel-toggle {
  color: var(--muted);
}

.chapter-nav-button.annotation-panel-toggle.active {
  border-color: var(--teal);
  color: var(--teal-dark);
}

.chapter-nav-button:hover:not(:disabled),
.chapter-nav-button:focus-visible {
  border-color: var(--teal);
  color: var(--teal-dark);
  outline: none;
}

.chapter-nav-button:disabled {
  cursor: not-allowed;
  opacity: 0.46;
}

.description {
  max-width: 920px;
  padding: 18px 0 4px;
  color: var(--description);
  line-height: 1.75;
}

.description.collapsed {
  display: none;
}

.annotation-panel.collapsed {
  display: none;
}

.description p {
  margin-bottom: 12px;
}

.intro-toggle {
  margin-top: 14px;
}

.annotation-panel {
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.annotation-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 8px;
}

.annotation-tab {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px 10px;
  background: var(--panel-strong);
  color: var(--muted);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 800;
  white-space: nowrap;
}

.annotation-tab.active,
.annotation-tab:hover,
.annotation-tab:focus-visible {
  border-color: var(--teal);
  color: var(--teal-dark);
  outline: none;
}

.annotation-list {
  display: grid;
  gap: 6px;
}

.annotation-item {
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

.annotation-item:first-child {
  border-top: 0;
}

.annotation-item-title {
  display: block;
  width: 100%;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
  line-height: 1.5;
  text-align: start;
}

.annotation-item-title:hover,
.annotation-item-title:focus-visible {
  color: var(--teal-dark);
  outline: none;
}

.annotation-refs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.annotation-refs button {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 700;
}

.annotation-refs button:hover,
.annotation-refs button:focus-visible {
  color: var(--teal-dark);
  outline: none;
}

.annotation-body {
  margin-top: 8px;
  color: var(--commentary);
  font-size: 0.92rem;
  line-height: 1.7;
}

.annotation-body p {
  margin-bottom: 8px;
}

.verses {
  padding-top: 16px;
}

.inline-next-chapter {
  display: inline;
  border: 0;
  border-bottom: 1px solid transparent;
  margin-inline-start: 0.28em;
  padding: 0 0.08em;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 0.58em;
  font-weight: 800;
  line-height: inherit;
}

.inline-next-chapter:hover,
.inline-next-chapter:focus-visible {
  color: var(--teal);
  outline: none;
}

.text-flow {
  color: var(--text-flow);
  font-family: "Times New Roman", "Noto Serif Hebrew", serif;
  font-size: 1.72rem;
  font-weight: 700;
  line-height: 1.58;
}

.verse-segment {
  display: inline;
  cursor: pointer;
  border-radius: 0;
  padding: 0 0.14em;
}

.verse-segment:hover,
.verse-segment:focus-visible {
  background: var(--verse-hover);
  outline: none;
}

.verse-segment[aria-expanded="true"] {
  background: var(--verse-hover);
}

.verse-segment.verse-highlight {
  background: var(--verse-hover);
}

.verse-marker {
  display: inline;
  color: var(--marker);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 0.78em;
  font-weight: 800;
  margin-inline: 0 0.25em;
}

.paragraph-heading {
  display: block;
  margin: 0 0 0.1em;
  color: var(--commentary-strong);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 0.72em;
  font-weight: 800;
  line-height: 1.2;
  text-align: center;
}

.verse-text {
  display: inline;
}

.inline-commentary {
  display: inline;
  color: var(--commentary);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 0.72em;
  font-weight: 500;
  line-height: inherit;
}

.inline-commentary p {
  display: inline;
  margin: 0;
}

.inline-commentary .verse,
.inline-commentary b {
  display: inline;
  color: var(--commentary-strong);
  font-family: "Times New Roman", "Noto Serif Hebrew", serif;
  font-size: 1.36em;
  font-weight: 800;
}

.inline-commentary .text {
  display: inline;
  color: var(--commentary);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 1em;
  font-weight: 500;
}

.empty {
  color: var(--muted);
  padding: 12px 0;
}

@media (max-width: 980px) {
  .topbar,
  .chapter-head {
    align-items: stretch;
    flex-direction: column;
  }

  .chapter-controls {
    justify-content: flex-start;
  }

  .layout {
    padding-inline: 16px;
  }
}

@media (max-width: 560px) {
  .topbar {
    padding: 14px 16px;
  }

  .text-flow {
    font-size: 1.36rem;
    line-height: 1.55;
  }
}
