:root {
  --paper: #f3eee4;
  --paper-deep: #ebe4d6;
  --ink: #1c1610;
  --ink-soft: #3f382f;
  --ink-mute: #6e655a;
  --rule: #d6cdbe;
  --saffron: #8c4316;
  --saffron-dim: #b36a36;
  --focus: #e8d7c0;
  --card: rgba(255, 252, 246, 0.72);
  --draft: #faf6ef;
}

* { box-sizing: border-box; }

html {
  font-size: 18px;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(ellipse at top, #f7f2ea 0%, var(--paper) 42%, var(--paper-deep) 100%);
  color: var(--ink);
  font-family: "Source Serif 4", "Palatino Linotype", Palatino, "Iowan Old Style", serif;
  line-height: 1.55;
  text-rendering: optimizeLegibility;
  font-kerning: normal;
}

.page {
  max-width: 40rem;
  margin: 0 auto;
  padding: 2.5rem 1.15rem 5rem;
}

.mast {
  text-align: center;
  padding: 1rem 0 2.5rem;
}

.mast.compact {
  padding-bottom: 1.25rem;
}

.brand {
  font-family: "Cormorant Garamond", "Source Serif 4", serif;
  font-size: clamp(2rem, 6vw, 2.75rem);
  font-weight: 500;
  letter-spacing: 0.12em;
  margin: 0 0 0.75rem;
}

.chapter-title {
  font-family: "Cormorant Garamond", "Source Serif 4", serif;
  font-size: clamp(1.55rem, 4.5vw, 2rem);
  font-weight: 500;
  margin: 0.35rem 0 0.4rem;
}

.trail {
  margin: 0;
  font-size: 0.95rem;
  letter-spacing: 0.06em;
  color: var(--saffron);
}

.crumb {
  margin: 0 0 0.5rem;
  font-size: 0.82rem;
}

.crumb a {
  color: var(--ink-mute);
  text-decoration: none;
  border-bottom: 1px solid transparent;
}

.crumb a:hover {
  color: var(--saffron);
  border-bottom-color: var(--saffron-dim);
}

.ornament {
  display: block;
  width: 2.5rem;
  height: 1px;
  background: var(--saffron-dim);
  margin: 1.1rem auto 1.2rem;
  border: 0;
}

.note, .source-note, .site-foot {
  margin: 0 auto;
  max-width: 28rem;
  font-size: 0.82rem;
  line-height: 1.55;
  color: var(--ink-mute);
  text-align: center;
}

.source-note {
  margin-top: 2.5rem;
  max-width: 34rem;
}

.section-label {
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-mute);
  font-weight: 600;
  margin: 0 0 0.85rem;
}

.chapters {
  list-style: none;
  margin: 0;
  padding: 0;
}

.chapters li {
  margin: 0 0 0.65rem;
}

.chapters a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem 1.1rem;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 0.55rem;
  color: var(--ink);
  text-decoration: none;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.chapters a:hover {
  border-color: var(--saffron-dim);
  background: #fffdf8;
}

.badge {
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--saffron);
  border: 1px solid var(--saffron-dim);
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
  flex-shrink: 0;
}

.site-foot {
  margin-top: 3rem;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem 1.25rem;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 0 1rem;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 1rem;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.88rem;
  color: var(--ink-soft);
  cursor: pointer;
  user-select: none;
}

.toggle input {
  accent-color: var(--saffron);
  width: 1rem;
  height: 1rem;
}

.jump {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--ink-soft);
}

.jump input {
  width: 5.5rem;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--rule);
  border-radius: 0.35rem;
  background: #fffdf8;
  font: inherit;
  color: var(--ink);
}

.jump button,
.nav-btn {
  font: inherit;
  font-size: 0.85rem;
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--rule);
  border-radius: 0.4rem;
  background: #fffdf8;
  color: var(--ink-soft);
  cursor: pointer;
}

.jump button:hover,
.nav-btn:hover:not(:disabled) {
  border-color: var(--saffron-dim);
  color: var(--saffron);
}

.nav-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.screen-meta {
  margin: 0 0 1.25rem;
  font-size: 0.82rem;
  color: var(--ink-mute);
  text-align: center;
}

.verses {
  display: flex;
  flex-direction: column;
  gap: 1.35rem;
}

.verse {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 0.65rem;
  padding: 1.1rem 1.05rem 1.15rem;
}

.verse-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
}

.verse-num a {
  color: var(--saffron);
  text-decoration: none;
  font-size: 0.9rem;
  letter-spacing: 0.04em;
  font-weight: 600;
}

.speaker {
  margin: 0;
  font-size: 0.78rem;
  color: var(--ink-mute);
  font-style: italic;
}

.deva {
  font-family: "Noto Serif Devanagari", "Noto Sans Devanagari", serif;
  font-size: 1.22rem;
  line-height: 1.7;
  margin: 0 0 0.55rem;
  white-space: pre-line;
  color: var(--ink);
}

.iast {
  margin: 0 0 0.75rem;
  font-size: 0.92rem;
  line-height: 1.55;
  color: var(--ink-soft);
  white-space: pre-line;
  font-style: italic;
}

.iast.hidden {
  display: none;
}

.slot-label {
  display: block;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-mute);
  margin: 0.85rem 0 0.3rem;
}

.other,
.helper {
  margin: 0 0 0.35rem;
  font-size: 0.98rem;
  color: var(--ink-soft);
  line-height: 1.55;
}

.helper-empty {
  margin: 0.85rem 0 0;
  font-size: 0.78rem;
  color: var(--ink-mute);
  font-style: italic;
}

.draft {
  width: 100%;
  min-height: 4.5rem;
  margin-top: 0.25rem;
  padding: 0.65rem 0.7rem;
  border: 1px solid var(--rule);
  border-radius: 0.4rem;
  background: var(--draft);
  color: var(--ink);
  font: inherit;
  font-size: 0.95rem;
  line-height: 1.5;
  resize: vertical;
}

.draft:focus {
  outline: 2px solid var(--focus);
  border-color: var(--saffron-dim);
}

.draft-status {
  margin: 0.3rem 0 0;
  font-size: 0.72rem;
  color: var(--ink-mute);
  min-height: 1em;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 1.75rem;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
}

.pager-label {
  font-size: 0.85rem;
  color: var(--ink-mute);
  text-align: center;
}

.error {
  padding: 1.25rem;
  border: 1px solid #c9a090;
  border-radius: 0.5rem;
  background: #faf0ea;
  color: #5a2e1e;
}

@media (max-width: 540px) {
  html { font-size: 17px; }
  .page { padding: 1.5rem 0.9rem 4rem; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .jump { width: 100%; }
  .jump input { flex: 1; width: auto; }
  .pager { flex-direction: column; }
  .nav-btn { width: 100%; }
  .deva { font-size: 1.12rem; }
}
