:root {
  color-scheme: light dark;
  --bg: #ffffff;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --rule: #d2d2d7;
  --accent: #0071e3;
  --accent-hover: #0077ed;
  --panel: #f5f5f7;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --text: #f5f5f7;
    --muted: #86868b;
    --rule: #2a2a2c;
    --accent: #2997ff;
    --accent-hover: #4ba6ff;
    --panel: #1d1d1f;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  font-family: "SF Pro Display", "SF Pro Text", -apple-system, BlinkMacSystemFont,
               "Helvetica Neue", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.47059;
  font-weight: 400;
  letter-spacing: -0.022em;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  min-height: 100vh;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

main {
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
  padding: 0 22px;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.15s ease;
}
a:hover { color: var(--accent-hover); text-decoration: underline; }

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 0;
  font-size: 14px;
  border-bottom: 1px solid var(--rule);
}
.brand {
  color: var(--text);
  font-weight: 600;
  font-size: 17px;
  letter-spacing: -0.022em;
}
.brand:hover { text-decoration: none; }
.topbar nav a {
  margin-left: 24px;
  color: var(--text);
  opacity: 0.85;
  font-weight: 400;
}
.topbar nav a:hover { opacity: 1; text-decoration: none; }

/* ---------- Hero quote ---------- */
.card {
  text-align: center;
  padding: 80px 0 48px;
}
.ref {
  margin: 0 0 28px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.quote {
  margin: 0 auto;
  max-width: 22ch;
  font-family: "New York", "Iowan Old Style", "Apple Garamond", "Charter", Georgia, serif;
  font-size: clamp(2rem, 5.4vw, 3.6rem);
  line-height: 1.1;
  font-weight: 500;
  letter-spacing: -0.018em;
  color: var(--text);
}
.cred {
  margin: 36px 0 0;
  color: var(--muted);
  font-size: 14px;
  letter-spacing: -0.01em;
}

.extras {
  margin: 32px auto 0;
  max-width: 640px;
  text-align: center;
  font-size: 14px;
}
.extras summary {
  cursor: pointer;
  color: var(--accent);
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  border-radius: 980px;
}
.extras summary::-webkit-details-marker { display: none; }
.extras summary::after {
  content: "›";
  display: inline-block;
  transform: rotate(90deg);
  transition: transform 0.2s ease;
  font-size: 18px;
  line-height: 0;
}
.extras[open] summary::after { transform: rotate(270deg); }
.extras summary:hover { color: var(--accent-hover); }

.sanskrit, .translit {
  margin: 16px auto 0;
  max-width: 600px;
  font-size: 17px;
  line-height: 1.6;
  color: var(--text);
  white-space: pre-line;
}
.translit {
  color: var(--muted);
  font-style: italic;
  font-size: 15px;
}

/* ---------- Actions ---------- */
.actions {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px 28px;
  padding: 16px 0 12px;
}
.btn {
  font: inherit;
  font-size: 17px;
  letter-spacing: -0.022em;
  font-weight: 400;
  cursor: pointer;
  border: 0;
  background: transparent;
  color: var(--accent);
  padding: 8px 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn:hover { color: var(--accent-hover); text-decoration: none; }
.btn::after {
  content: "›";
  display: inline-block;
  font-size: 20px;
  line-height: 0.5;
  transform: translateY(-1px);
  transition: transform 0.2s ease;
}
.btn:hover::after { transform: translate(2px, -1px); }

.btn.primary {
  color: #fff;
  background: var(--accent);
  border-radius: 980px;
  padding: 12px 22px;
  font-weight: 400;
}
.btn.primary:hover { background: var(--accent-hover); color: #fff; }

.btn.back::after { content: ""; }
.btn.back::before {
  content: "‹";
  display: inline-block;
  font-size: 20px;
  line-height: 0.5;
  transform: translateY(-1px);
  margin-right: 6px;
  transition: transform 0.2s ease;
}
.btn.back:hover::before { transform: translate(-2px, -1px); }

.secondary-actions {
  padding-top: 0;
  padding-bottom: 64px;
  font-size: 15px;
  gap: 10px 22px;
}
.secondary-actions .btn { font-size: 15px; opacity: 0.85; }
.secondary-actions .btn:hover { opacity: 1; }

.chapter-browser {
  max-width: 680px;
  margin: 0 auto 40px;
  padding: 24px 0;
  border-top: 1px solid var(--rule);
  text-align: center;
}
.chapter-browser summary {
  cursor: pointer;
  list-style: none;
  color: var(--accent);
  font-size: 15px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.chapter-browser summary::-webkit-details-marker { display: none; }
.chapter-browser summary::after {
  content: "›";
  display: inline-block;
  transform: rotate(90deg);
  transition: transform 0.2s ease;
  font-size: 18px;
  line-height: 0;
}
.chapter-browser[open] summary::after { transform: rotate(270deg); }
.chapter-list {
  list-style: none;
  padding: 24px 0 0;
  margin: 0;
  text-align: left;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 24px;
}
.chapter-list li { line-height: 1.5; }
.chapter-list a {
  display: block;
  padding: 6px 0;
  color: var(--text);
  font-size: 15px;
}
.chapter-list a:hover { color: var(--accent); text-decoration: none; }
@media (max-width: 640px) {
  .chapter-list { grid-template-columns: 1fr; }
}

/* ---------- Footer ---------- */
.foot {
  text-align: center;
  padding: 40px 0 56px;
  border-top: 1px solid var(--rule);
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
  letter-spacing: -0.01em;
}
.foot p { margin: 6px 0; max-width: 720px; margin-left: auto; margin-right: auto; }
.foot a { color: var(--muted); text-decoration: underline; }
.foot a:hover { color: var(--text); }

/* ---------- About / prose pages ---------- */
.prose {
  max-width: 680px;
  margin: 0 auto;
  padding: 80px 0;
}
.prose h1 {
  font-size: clamp(2.2rem, 5vw, 3.2rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0 0 24px;
}
.prose h2 {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 40px 0 8px;
}
.prose p {
  font-size: 17px;
  line-height: 1.5;
  color: var(--text);
  margin: 12px 0;
}

/* ---------- Mobile ---------- */
@media (max-width: 640px) {
  main { padding: 0 16px; }
  .card { padding: 56px 0 32px; }
  .quote { max-width: 100%; }
  .actions { padding: 12px 0 56px; gap: 10px 24px; }
  .topbar { padding: 12px 0; }
  .topbar nav a { margin-left: 18px; }
}
