:root {
  --bg: #f7f1e5;
  --body-grad-start: #fff8ea;
  --body-grad-mid: #f2e4cd;
  --body-grad-end: #e8d8bd;
  --ink: #2b1f14;
  --muted: #6b5540;
  --line: #d8c7ad;
  --card: #fffaf2;
  --accent: #6f2f20;
  --surface: #f3e6d0;
}

:root[data-theme="candana"] {
  --bg: #f8f3ea;
  --body-grad-start: #fffaf2;
  --body-grad-mid: #f2e9dc;
  --body-grad-end: #e8dcc8;
  --ink: #2f2418;
  --muted: #6c5a45;
  --line: #dacbb4;
  --card: #fffaf3;
  --accent: #7b4f2f;
  --surface: #f1e7d9;
}

:root[data-theme="tulasi"] {
  --bg: #f3f5ec;
  --body-grad-start: #fbfcf7;
  --body-grad-mid: #eef3e7;
  --body-grad-end: #e2ead8;
  --ink: #253023;
  --muted: #52644e;
  --line: #c9d2be;
  --card: #f9fcf4;
  --accent: #4f6846;
  --surface: #eaf1df;
}

:root[data-theme="lotus"] {
  --bg: #f8f1ef;
  --body-grad-start: #fff9f8;
  --body-grad-mid: #f3e7e4;
  --body-grad-end: #e8d8d5;
  --ink: #322225;
  --muted: #72565d;
  --line: #dbc3c0;
  --card: #fff9f8;
  --accent: #7a3f46;
  --surface: #f3e5e3;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background: radial-gradient(circle at 10% 10%, var(--body-grad-start), var(--body-grad-mid) 56%, var(--body-grad-end) 100%);
  color: var(--ink);
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, serif;
  line-height: 1.5;
}

body.search-open {
  overflow: hidden;
}

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

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, color-mix(in srgb, var(--bg) 92%, #fff 8%), color-mix(in srgb, var(--bg) 78%, #fff 22%));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
}

.page-progress {
  position: sticky;
  top: 54px;
  z-index: 18;
  height: 5px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 65%, #fff 35%);
}

#page-progress-fill {
  display: block;
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 70%, #fff 30%), var(--accent));
}

.site-title {
  font-size: 1.35rem;
  text-decoration: none;
  font-weight: 700;
  color: var(--ink);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.theme-label {
  font-size: 0.9rem;
  color: var(--muted);
}

select,
button {
  font: inherit;
}

select,
.ghost-button {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  color: var(--ink);
  padding: 6px 10px;
}

.ghost-button.disabled {
  pointer-events: none;
  opacity: 0.45;
}

.page-shell {
  max-width: 980px;
  margin: 0 auto;
  padding: 18px clamp(14px, 3vw, 28px) 42px;
}

h1 {
  margin: 0 0 12px;
}

.breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.95rem;
}

.breadcrumbs .sep {
  opacity: 0.6;
}

.verse-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: color-mix(in srgb, var(--card) 88%, #fff 12%);
  padding: 14px;
}

.verse-meta {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
}

.ref-pill {
  grid-column: 2;
  justify-self: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  padding: 4px 10px;
  font-weight: 600;
  text-align: center;
}

.prabhupada-quote-meta {
  grid-column: 3;
  justify-self: end;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px 6px 6px;
  border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--line) 78%);
  border-radius: 999px;
  background: color-mix(in srgb, var(--card) 60%, var(--surface) 40%);
  box-shadow: 0 6px 16px rgba(42, 24, 14, 0.08);
}

.prabhupada-quote-avatar {
  width: 44px;
  height: 44px;
  border-radius: 999px;
  object-fit: cover;
  object-position: center top;
  border: 1px solid color-mix(in srgb, var(--accent) 20%, var(--line) 80%);
  flex-shrink: 0;
}

.quote-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0.02em;
}

.quote-badge-mark {
  font-size: 1.5rem;
  line-height: 1;
}

.quote-badge-count {
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
}

.verse-section {
  border-top: 1px solid var(--line);
  margin-top: 14px;
  padding-top: 12px;
}

.verse-section h2 {
  margin: 0 0 8px;
  font-size: 1.2rem;
  color: var(--accent);
  text-align: center;
}

.section-text {
  white-space: pre-wrap;
  line-height: 1.72;
  font-size: 1.04rem;
  max-width: 72ch;
  margin-left: auto;
  margin-right: auto;
  text-wrap: pretty;
}

.section-verse_text,
.section-iast,
.section-devanagari,
.section-bengali {
  text-align: center;
}

.section-devanagari,
.section-bengali {
  font-size: 1.22em;
  line-height: 2;
  letter-spacing: 0.01em;
  font-weight: 600;
}

.section-verse_text,
.section-iast {
  font-size: 1.11em;
  line-height: 1.85;
  font-style: italic;
  letter-spacing: 0.01em;
  font-weight: 500;
}

.synonyms-list {
  margin: 0 auto;
  padding: 0;
  max-width: 72ch;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: 0.45rem;
  row-gap: 0.35rem;
  line-height: 1.7;
}

.synonyms-item {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.3rem;
}

.synonyms-list .syn-term {
  font-weight: 600;
  color: var(--ink);
}

.synonyms-list .syn-sep {
  color: var(--muted);
}

.synonyms-list .syn-meaning {
  color: var(--ink);
}

.synonyms-list .syn-divider {
  color: var(--muted);
  margin-left: 0.1rem;
}

.summary {
  margin: 0 0 14px;
  color: var(--muted);
}

.index-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 9px;
}

.index-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  padding: 9px 11px;
}

.canto-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.canto-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  padding: 12px;
}

.canto-card a {
  font-weight: 700;
  text-decoration: none;
  color: var(--ink);
}

.canto-card p {
  margin: 7px 0 0;
  color: var(--muted);
}

.footer-links {
  margin: 12px 2px 0;
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

.verse-nav-controls {
  position: sticky;
  top: 62px;
  z-index: 12;
  background: color-mix(in srgb, var(--bg) 92%, #fff 8%);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px;
  backdrop-filter: blur(3px);
}

.verse-nav-controls .ghost-button {
  text-decoration: none;
}

.search-palette[hidden] {
  display: none;
}

.search-palette {
  position: fixed;
  inset: 0;
  z-index: 70;
}

.search-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(26, 17, 10, 0.45);
}

.search-dialog {
  position: absolute;
  top: min(8vh, 70px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  width: min(760px, calc(100vw - 24px));
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.24);
  padding: 12px;
}

.search-dialog-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

#search-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  padding: 10px 12px;
}

.search-help {
  margin: 7px 0 10px;
  font-size: 0.92rem;
  color: var(--muted);
}

.search-results {
  flex: 1 1 auto;
  min-height: 0;
  max-height: min(64vh, 540px);
  overflow: auto;
  display: grid;
  gap: 8px;
}

.search-result-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 9px 11px;
  text-decoration: none;
  color: inherit;
}

.search-result-item strong {
  color: var(--ink);
}

.search-result-item p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

@media (max-width: 780px) {
  .site-header {
    padding: 10px 12px;
    gap: 8px;
  }

  .site-title {
    font-size: 1.1rem;
  }

  .header-actions {
    gap: 6px;
  }

  .page-progress {
    top: 52px;
  }

  .page-shell {
    padding: 14px 12px 92px;
  }

  .verse-nav-controls {
    position: fixed;
    left: 8px;
    right: 8px;
    bottom: max(8px, env(safe-area-inset-bottom));
    top: auto;
    border-radius: 14px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    box-shadow: 0 14px 28px rgba(20, 12, 7, 0.24);
    backdrop-filter: blur(4px);
  }

  .verse-nav-controls .ghost-button,
  .verse-nav-controls .disabled {
    text-align: center;
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .verse-meta {
    grid-template-columns: 1fr;
    justify-items: center;
  }

  .ref-pill,
  .prabhupada-quote-meta {
    grid-column: 1;
    justify-self: center;
  }

  .search-dialog {
    position: fixed;
    inset: max(8px, env(safe-area-inset-top)) 0 0 0;
    transform: none;
    width: 100vw;
    max-height: none;
    border-radius: 16px 16px 0 0;
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
    padding: 12px;
  }

  #search-input {
    min-height: 44px;
    font-size: 1rem;
  }

  .search-results {
    max-height: 64vh;
  }

  .search-result-item {
    min-height: 58px;
    display: block;
  }
}
