:root {
  --bg-main: #f4efe4;
  --bg-soft: #efe5d2;
  --paper: #fffdf8;
  --ink: #221d15;
  --muted: #6d6252;
  --line: #d9c9af;
  --brand: #245749;
  --brand-strong: #193f35;
  --accent: #bb8533;
  --shadow: 0 22px 48px rgba(34, 29, 21, 0.12);
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: "Source Serif 4", serif;
  color: var(--ink);
  background: linear-gradient(180deg, var(--bg-main) 0%, var(--bg-soft) 100%);
  min-height: 100vh;
}

.backdrop {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 10% 12%, rgba(187, 133, 51, 0.14), transparent 38%),
    radial-gradient(circle at 86% 8%, rgba(36, 87, 73, 0.13), transparent 32%),
    radial-gradient(circle at 50% 100%, rgba(36, 87, 73, 0.08), transparent 34%);
}

.site-header,
.library-layout,
.site-footer,
.noscript-msg {
  width: min(1140px, calc(100% - 2.2rem));
  margin-inline: auto;
}

.site-header {
  position: relative;
  z-index: 1;
  margin-top: 1.5rem;
  margin-bottom: 1rem;
  padding: 1.25rem 0.25rem 0.75rem;
  animation: rise-in 500ms ease-out;
}

.eyebrow {
  margin: 0;
  font-size: 0.84rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--brand);
  font-weight: 700;
}

h1,
h2 {
  font-family: "Marcellus", serif;
}

#book-title {
  margin: 0.35rem 0 0.5rem;
  font-size: clamp(1.9rem, 2.7vw, 2.8rem);
  line-height: 1.18;
}

.book-subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 1.05rem;
  max-width: 72ch;
}

.book-actions {
  display: flex;
  gap: 0.7rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

.library-layout {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(250px, 300px) minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

.chapter-panel,
.reader-panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.chapter-panel {
  padding: 1rem;
  position: sticky;
  top: 1rem;
  max-height: calc(100vh - 2rem);
  overflow: auto;
  animation: rise-in 650ms ease-out;
}

.reader-panel {
  padding: 1.2rem 1.3rem;
  animation: rise-in 760ms ease-out;
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.6rem;
}

.panel-heading h2 {
  margin: 0;
  font-size: 1.2rem;
}

.chapter-count {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.field-label {
  display: block;
  margin-top: 1rem;
  margin-bottom: 0.45rem;
  font-size: 0.88rem;
  color: var(--muted);
}

.search-input {
  width: 100%;
  padding: 0.62rem 0.72rem;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: #fff;
  font: inherit;
}

.search-input:focus {
  outline: 2px solid rgba(36, 87, 73, 0.35);
  border-color: var(--brand);
}

.chapter-list {
  list-style: none;
  margin: 0.8rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.48rem;
}

.chapter-list li {
  animation: rise-in 420ms ease-out both;
}

.chapter-item {
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 0.58rem 0.62rem;
  cursor: pointer;
  color: var(--ink);
  transition: transform 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.chapter-item:hover {
  transform: translateY(-1px);
  border-color: var(--accent);
  box-shadow: 0 8px 16px rgba(34, 29, 21, 0.1);
}

.chapter-item.active {
  border-color: var(--brand);
  box-shadow: inset 0 0 0 1px var(--brand);
  background: linear-gradient(180deg, #fff, #fbf8f0);
}

.chapter-item-title {
  display: block;
  font-weight: 700;
  margin-bottom: 0.12rem;
}

.chapter-item-snippet {
  display: block;
  font-size: 0.86rem;
  color: var(--muted);
}

.no-results {
  margin: 0.35rem 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.reader-tools {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.72rem;
  margin-bottom: 0.9rem;
}

.chapter-position {
  margin: 0;
  font-size: 0.92rem;
  color: var(--muted);
}

.pager-actions {
  display: flex;
  gap: 0.55rem;
  flex-wrap: wrap;
}

.chapter-head h2 {
  margin: 0;
  font-size: clamp(1.35rem, 2vw, 1.72rem);
}

.chapter-meta {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.chapter-content {
  margin-top: 1rem;
}

.chapter-content h3 {
  margin: 1.25rem 0 0.45rem;
  font-family: "Marcellus", serif;
  font-size: 1.12rem;
}

.chapter-content p {
  margin: 0.62rem 0;
  line-height: 1.8;
  font-size: 1.05rem;
}

mark {
  background: rgba(187, 133, 51, 0.28);
  color: inherit;
  padding: 0 0.08em;
  border-radius: 2px;
}

.btn {
  border: 1px solid transparent;
  border-radius: 999px;
  cursor: pointer;
  padding: 0.56rem 0.95rem;
  font: inherit;
  font-size: 0.92rem;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 130ms ease, box-shadow 130ms ease, opacity 130ms ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  transform: none;
}

.btn-primary {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}

.btn-primary:hover {
  box-shadow: 0 10px 24px rgba(36, 87, 73, 0.25);
}

.btn-secondary {
  background: #fff;
  color: var(--ink);
  border-color: var(--line);
}

.site-footer {
  margin: 1.2rem auto 1.8rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.noscript-msg {
  margin: 0 auto 1.2rem;
  color: #8a3f2f;
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 960px) {
  .library-layout {
    grid-template-columns: 1fr;
  }

  .chapter-panel {
    position: static;
    max-height: none;
  }

  .reader-tools {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 620px) {
  .site-header,
  .library-layout,
  .site-footer,
  .noscript-msg {
    width: min(1140px, calc(100% - 1.2rem));
  }

  .reader-panel,
  .chapter-panel {
    padding: 0.9rem;
    border-radius: 14px;
  }

  .chapter-content p {
    font-size: 1rem;
    line-height: 1.72;
  }
}
