:root {
  --bg: #f4f1ec;
  --surface: #fff;
  --ink: #1c1917;
  --muted: #78716c;
  --line: #ebe6dd;
  --accent: #0f766e;
  --accent-soft: #ccfbf1;
  --danger: #b91c1c;
  --shadow: 0 1px 2px rgba(28, 25, 23, 0.06);
  --radius: 14px;
  --font-ui: "Source Sans 3", "Segoe UI", ui-sans-serif, system-ui, sans-serif;
  --font-read: "Literata", "Iowan Old Style", "Palatino Linotype", Palatino, serif;
  --font-size: 19px;
  --line-height: 1.65;
  --measure: 42rem;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
  --hl-amber: #fde68a;
  --hl-green: #bbf7d0;
  --hl-blue: #bfdbfe;
  --hl-pink: #fbcfe8;
}

html[data-theme="dark"] {
  --bg: #121416;
  --surface: #1c1f24;
  --ink: #e8e6e3;
  --muted: #9a9590;
  --line: #2e333a;
  --accent: #2dd4bf;
  --accent-soft: #134e4a;
  --danger: #f87171;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  --hl-amber: #854d0e;
  --hl-green: #166534;
  --hl-blue: #1e3a8a;
  --hl-pink: #9d174d;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font-ui);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 10% -10%, color-mix(in srgb, var(--accent) 12%, transparent), transparent),
    radial-gradient(900px 500px at 100% 0%, color-mix(in srgb, var(--accent) 8%, transparent), transparent),
    var(--bg);
  min-height: 100vh;
  line-height: 1.4;
  color-scheme: light;
  padding-top: var(--safe-top);
}

html[data-theme="dark"] body {
  color-scheme: dark;
}

body.font-sans {
  --font-read: "Source Sans 3", "Segoe UI", ui-sans-serif, system-ui, sans-serif;
}

.muted {
  color: var(--muted);
}

.loading-msg {
  padding: 2rem 1rem;
  text-align: center;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.55rem 0.75rem;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  flex-wrap: nowrap;
}

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: 999px;
  padding: 0.45rem 0.85rem;
  font-size: 0.9rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  box-shadow: var(--shadow);
  min-height: 40px;
}

.btn:active {
  transform: scale(0.98);
}

.btn.ghost {
  background: transparent;
  box-shadow: none;
  max-width: min(46vw, 14rem);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn.icon {
  width: 2.25rem;
  height: 2.25rem;
  min-height: 2.25rem;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  font-size: 1rem;
  font-weight: 500;
}

.btn.primary {
  background: var(--accent);
  border-color: transparent;
  color: #fff;
}

html[data-theme="dark"] .btn.primary {
  color: #042f2e;
}

.btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.select {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: 999px;
  padding: 0.35rem 0.7rem;
  font-size: 0.8rem;
  font-weight: 600;
  font-family: inherit;
  max-width: 5.8rem;
  min-height: 2.25rem;
}

.reader-wrap {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 1rem 1.1rem calc(5.5rem + var(--safe-bottom));
}

.reader.parallel {
  display: grid;
  gap: 1.25rem;
}

@media (min-width: 860px) {
  .reader.parallel {
    grid-template-columns: 1fr 1fr;
    max-width: calc(var(--measure) * 1.85);
    margin-left: auto;
    margin-right: auto;
  }
  .reader-wrap:has(.reader.parallel) {
    max-width: calc(var(--measure) * 1.85);
  }
}

.pane-label {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 0.5rem;
}

.chapter-title {
  font-family: var(--font-read);
  font-size: 1.35rem;
  font-weight: 600;
  margin: 0 0 1rem;
}

.verses {
  font-family: var(--font-read);
  font-size: var(--font-size);
  line-height: var(--line-height);
  hyphens: auto;
  -webkit-hyphens: auto;
}

.verse {
  display: block;
  margin: 0 0 0.35em;
  padding: 0.15em 0.25em;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.verse:hover,
.verse:focus-visible {
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  outline: none;
}

.verse .vn {
  font-family: var(--font-ui);
  font-size: 0.72em;
  font-weight: 700;
  color: var(--accent);
  margin-right: 0.35em;
  vertical-align: super;
  line-height: 1;
}

.verse.hl-amber { background: var(--hl-amber); }
.verse.hl-green { background: var(--hl-green); }
.verse.hl-blue { background: var(--hl-blue); }
.verse.hl-pink { background: var(--hl-pink); }

.verse.has-note::after {
  content: "✎";
  font-size: 0.7em;
  margin-left: 0.25em;
  color: var(--muted);
}

.chapter-nav {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(0.75rem + var(--safe-bottom));
  z-index: 15;
  display: flex;
  gap: 0.4rem;
  padding: 0.35rem;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}

.chapter-nav .btn {
  min-width: 2.6rem;
}

.sheet {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.sheet[hidden] {
  display: none !important;
}

.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
}

.sheet-panel {
  position: relative;
  width: min(100%, 560px);
  max-height: min(88vh, 720px);
  background: var(--surface);
  border-radius: 18px 18px 0 0;
  border: 1px solid var(--line);
  border-bottom: none;
  display: flex;
  flex-direction: column;
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.12);
  animation: sheet-up 0.22s ease;
}

.sheet-panel.tall {
  max-height: min(92vh, 820px);
}

@keyframes sheet-up {
  from { transform: translateY(18px); opacity: 0.6; }
  to { transform: translateY(0); opacity: 1; }
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--line);
}

.sheet-head h2 {
  margin: 0;
  font-size: 1.05rem;
}

.sheet-body {
  overflow: auto;
  padding: 0.75rem 1rem calc(1.25rem + var(--safe-bottom));
  -webkit-overflow-scrolling: touch;
}

.book-grid,
.chapter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(7.5rem, 1fr));
  gap: 0.4rem;
}

.chapter-grid {
  grid-template-columns: repeat(auto-fill, minmax(3rem, 1fr));
}

.book-btn,
.chapter-btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  border-radius: 10px;
  padding: 0.65rem 0.5rem;
  font: inherit;
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  text-align: center;
  min-height: 44px;
}

.book-btn.small {
  font-size: 0.8rem;
  padding: 0.5rem 0.4rem;
}

.book-btn.read,
.chapter-btn.read {
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--accent) 55%, transparent);
}

.testament-label {
  grid-column: 1 / -1;
  margin: 0.75rem 0 0.25rem;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.menu-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding-top: 0.25rem;
}

.menu-item {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--ink);
  text-align: left;
  font: inherit;
  font-size: 1rem;
  font-weight: 600;
  padding: 0.85rem 0.5rem;
  border-radius: 10px;
  cursor: pointer;
}

.menu-item:hover,
.menu-item:focus-visible {
  background: var(--accent-soft);
  outline: none;
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.9rem;
}

.form-row label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}

.form-row input,
.form-row textarea,
.form-row select {
  font: inherit;
  font-size: 1rem;
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  min-height: 44px;
}

.form-row textarea {
  min-height: 120px;
  resize: vertical;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.color-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.color-swatch {
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 999px;
  border: 2px solid var(--line);
  cursor: pointer;
}

.color-swatch.amber { background: var(--hl-amber); }
.color-swatch.green { background: var(--hl-green); }
.color-swatch.blue { background: var(--hl-blue); }
.color-swatch.pink { background: var(--hl-pink); }
.color-swatch.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.list-item {
  display: block;
  width: 100%;
  text-align: left;
  appearance: none;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  border-radius: 12px;
  padding: 0.75rem 0.85rem;
  margin-bottom: 0.45rem;
  font: inherit;
  cursor: pointer;
}

.list-item strong {
  display: block;
  margin-bottom: 0.2rem;
}

.list-item .snippet {
  color: var(--muted);
  font-size: 0.9rem;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(4.5rem + var(--safe-bottom));
  transform: translateX(-50%);
  z-index: 50;
  background: var(--ink);
  color: var(--bg);
  padding: 0.55rem 0.95rem;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 600;
  max-width: min(90vw, 24rem);
  text-align: center;
}

.toast[hidden] {
  display: none !important;
}

.about p {
  margin: 0 0 0.75rem;
  line-height: 1.5;
}

.about a {
  color: var(--accent);
}

.progress-bar {
  height: 6px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 0.35rem;
}

.progress-bar > span {
  display: block;
  height: 100%;
  background: var(--accent);
}

.range-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.range-row input[type="range"] {
  flex: 1;
}

.hint {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0 0 0.75rem;
}

.error-banner {
  background: color-mix(in srgb, var(--danger) 12%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--danger) 35%, var(--line));
  color: var(--ink);
  padding: 0.75rem 0.9rem;
  border-radius: 12px;
  margin-bottom: 1rem;
}
