:root {
  --bg: #faf7f2;
  --surface: #ffffff;
  --text: #2b2620;
  --muted: #6f665b;
  --line: #e7dfd3;
  --accent: #b5561c;
  --accent-soft: #fbeee4;
  --alert-bg: #fdf1ee;
  --alert-line: #e9b7a8;
  --serif: "Source Serif 4", Georgia, serif;
  --deva: "Noto Serif Devanagari", "Source Serif 4", serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1916;
    --surface: #24211d;
    --text: #ece5da;
    --muted: #a99f92;
    --line: #3a352e;
    --accent: #e48a4f;
    --accent-soft: #3a2a1f;
    --alert-bg: #3a2420;
    --alert-line: #7a4335;
  }
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 18px/1.6 var(--serif); }
.wrap { max-width: 44rem; margin: 0 auto; padding: 2.5rem 1rem 3rem; }
a { color: var(--accent); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.brand .deva { font-family: var(--deva); color: var(--accent); font-size: 1.1rem; margin: 0; }
.brand h1 { font-size: 2.2rem; line-height: 1.15; margin: .1rem 0 .6rem; }
.tagline { color: var(--muted); margin: 0 0 1.5rem; }

.ask textarea {
  width: 100%; padding: .8rem .9rem; font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; resize: vertical;
}
.ask textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.hint { color: var(--muted); font-size: .85rem; margin: .4rem 0 0; font-family: var(--deva); }
.hint em { font-family: var(--serif); }
.row { display: flex; align-items: center; gap: 1rem; margin-top: .6rem; }
.ask button[type=submit] {
  font: inherit; font-weight: 600; padding: .5rem 1.4rem; border: 0; border-radius: 999px;
  background: var(--accent); color: #fff; cursor: pointer;
}
.htmx-indicator { display: none; color: var(--muted); }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: inline; }
.examples { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .9rem; }
.examples button {
  font: 15px var(--serif); padding: .25rem .75rem; border-radius: 999px; cursor: pointer;
  background: var(--accent-soft); color: var(--text); border: 1px solid var(--line);
}

#results { margin-top: 2rem; }
.notice { color: var(--muted); }
.crisis { background: var(--alert-bg); border: 1px solid var(--alert-line); border-radius: 10px; padding: .2rem 1rem; margin-bottom: 1.2rem; }

.answer { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: .6rem 1.2rem; margin-bottom: 1.8rem; }
.answer .pending { color: var(--muted); font-style: italic; }
.answer .streaming { white-space: pre-wrap; }
.answer .gist, .answer .gist p { font-size: 1.08rem; line-height: 1.55; }
.answer .gist p { margin: .6rem 0; }
.answer .sources { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; margin: .2rem 0 .7rem; color: var(--muted); font-size: .9rem; }
.answer .chip { display: inline-block; padding: .15rem .6rem; border: 1px solid var(--line); border-radius: 999px; background: var(--accent-soft); color: var(--accent); text-decoration: none; font-size: .85rem; line-height: 1.5; vertical-align: baseline; }
.answer .chip:hover { border-color: var(--accent); }
.answer .full-answer { border-top: 1px solid var(--line); padding: .5rem 0 .3rem; }
.answer .full-answer summary { cursor: pointer; color: var(--accent); font-weight: 600; padding: .2rem 0; }
.answer .full-answer[open] summary { margin-bottom: .2rem; }
.cite {
  display: inline-block; min-width: 1.3em; padding: 0 .3em; margin: 0 .1em; border-radius: 999px;
  font-size: .75em; text-align: center; text-decoration: none; vertical-align: .15em;
  background: var(--accent-soft); color: var(--accent); border: 1px solid var(--line);
}

.verses { list-style: none; padding: 0; margin: 0; display: grid; gap: 1rem; }
.verse { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 1rem 1.2rem; }
.verse:target { outline: 2px solid var(--accent); }
.verse-head { display: flex; align-items: baseline; gap: .6rem; flex-wrap: wrap; }
.num {
  display: inline-grid; place-items: center; width: 1.6rem; height: 1.6rem; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent); font-size: .85rem; font-weight: 600;
}
.ref { font-weight: 600; }
.speaker { color: var(--muted); font-size: .9rem; }
.sanskrit { font-family: var(--deva); font-size: 1.15rem; line-height: 1.8; margin: .6rem 0 .2rem; }
.iast { color: var(--muted); font-style: italic; font-size: .95rem; margin: 0 0 .6rem; }
.translation p { margin: .1rem 0 0; }
.translation.alt { margin-top: .6rem; color: var(--muted); font-size: .95rem; }
.translation .label { font-size: .75rem; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.translation[lang=hi] p { font-family: var(--deva); }
.caution { color: var(--muted); font-size: .88rem; border-left: 3px solid var(--line); padding-left: .7rem; margin: .7rem 0 0; }

.more-verses { margin-top: 1.2rem; }
.more-verses summary { cursor: pointer; color: var(--muted); padding: .3rem 0; }
.more-verses[open] summary { margin-bottom: .8rem; }

footer { margin-top: 3rem; color: var(--muted); font-size: .9rem; border-top: 1px solid var(--line); padding-top: 1rem; }

.texts { margin-top: .7rem; font-size: .95rem; }
.texts summary { cursor: pointer; color: var(--muted); }
.texts-chosen { color: var(--text); }
.texts[open] { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: .5rem .9rem .7rem; }
.texts[open] summary { margin-bottom: .4rem; }
.texts fieldset { border: 0; padding: 0; margin: .5rem 0 0; display: flex; flex-wrap: wrap; gap: .2rem 1rem; }
.texts legend { font-size: .75rem; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); padding: 0; margin-bottom: .1rem; width: 100%; }
.texts label { display: inline-flex; align-items: center; gap: .35rem; cursor: pointer; }
.texts .texts-all { font-weight: 600; }
.texts .n, .text-filter .n { color: var(--muted); font-size: .8em; }
.texts input { accent-color: var(--accent); }
.texts-none { color: var(--accent); margin: .5rem 0 0; }

.text-filter { display: flex; flex-wrap: wrap; gap: .4rem; margin: 0 0 1rem; }
.text-filter button {
  font: 15px var(--serif); padding: .25rem .75rem; border-radius: 999px; cursor: pointer;
  background: var(--surface); color: var(--text); border: 1px solid var(--line);
}
.text-filter button.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.verse[hidden] { display: none; }

.offtopic { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: .2rem 1.2rem; }
.offtopic p:first-child { margin-top: .8rem; }

/* Verse cards start compact (first line of the Sanskrit and one translation);
   "Full verse" shows the rest. */
.verse:not(.open) .full { display: none; }
.verse:not(.open) .sanskrit { margin-bottom: .4rem; }
.expand {
  font: 14px var(--serif); margin-top: .6rem; padding: .15rem .7rem; border-radius: 999px; cursor: pointer;
  background: none; color: var(--accent); border: 1px solid var(--line);
}
.verse.open .expand { color: var(--muted); }

/* Reader */
nav.site { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: .5rem; margin-bottom: 1.5rem; font-size: .95rem; }
nav.site .home { color: var(--text); text-decoration: none; font-weight: 600; }
nav.site .home .deva { font-family: var(--deva); color: var(--accent); margin-right: .3rem; }
nav.site .links a { margin-left: 1rem; }
.reader h1 { font-size: 1.9rem; line-height: 1.2; margin: .2rem 0 .3rem; }
.reader h2 { font-size: 1rem; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); margin: 2rem 0 .6rem; }
.crumbs { color: var(--muted); font-size: .9rem; margin: 0; }
.title-hi { font-family: var(--deva); color: var(--accent); margin: 0 0 1rem; }
.continue a { display: inline-block; background: var(--accent-soft); border: 1px solid var(--line); border-radius: 999px; padding: .3rem .9rem; text-decoration: none; }

.books, .parts { list-style: none; padding: 0; margin: 0; display: grid; gap: .6rem; }
.books a, .parts a {
  display: grid; gap: .1rem; padding: .7rem 1rem; text-decoration: none; color: var(--text);
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
}
.books a:hover, .parts a:hover { border-color: var(--accent); }
.book-title, .part-label { font-weight: 600; }
.book-hi { font-family: var(--deva); color: var(--accent); font-size: .95rem; }
.book-intro { color: var(--muted); font-size: .9rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.part-first { font-family: var(--deva); color: var(--muted); font-size: .95rem; }
.parts a { grid-template-columns: 1fr auto; }
.parts .part-first { grid-column: 1 / -1; }
.start { display: inline-block; font-weight: 600; padding: .45rem 1.3rem; border-radius: 999px; background: var(--accent); color: #fff; text-decoration: none; margin: .4rem .6rem .8rem 0; }
.intro p { margin: .4rem 0 .8rem; }
.source { margin-top: 1.5rem; color: var(--muted); font-size: .9rem; }
.source summary { cursor: pointer; }

.prefs { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin: .6rem 0 1.2rem; font-size: .9rem; }
.pref-group { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.prefs button { font: inherit; padding: .2rem .8rem; background: var(--surface); color: var(--text); border: 0; cursor: pointer; }
.pref-group button + button { border-left: 1px solid var(--line); }
.prefs button[aria-pressed=true] { background: var(--accent-soft); color: var(--accent); }
.pref-iast { border: 1px solid var(--line) !important; border-radius: 999px; }

.rverse { padding: 1.1rem 0; border-bottom: 1px solid var(--line); scroll-margin-top: 1rem; }
.rverse:target { background: var(--accent-soft); border-radius: 10px; padding-left: .8rem; padding-right: .8rem; }
.rverse .verse-head { gap: .8rem; }
.vref { font-weight: 600; text-decoration: none; }
.rverse .share { margin-left: auto; font-size: .85rem; color: var(--muted); }
.rverse .tr { margin: .3rem 0; }
.rverse .tr.t-hi, .rverse p.t-hi { font-family: var(--deva); }
.notes { margin-top: .4rem; font-size: .95rem; }
.notes summary { cursor: pointer; color: var(--accent); font-size: .9rem; }
.notes .context { color: var(--muted); }

body[data-lang=en] .t-hi, body[data-lang=hi] .t-en { display: none; }
body[data-lang=both] .tr.t-hi { color: var(--muted); }
body[data-iast=off] .iast { display: none; }

.pager { display: grid; grid-template-columns: 1fr auto 1fr; gap: .6rem; align-items: center; margin: 1.5rem 0; position: sticky; bottom: 0; background: var(--bg); padding: .6rem 0; border-top: 1px solid var(--line); }
.pager a { text-decoration: none; font-size: .95rem; }
.pager .next { text-align: right; }
.pager .up { color: var(--muted); }
.verse-actions { margin-top: 1.2rem; }
.verse-actions a + a { margin-left: .6rem; }
.read-link { font-size: .85rem; margin-left: auto; color: var(--muted); }

/* Audio episodes */
.listen { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: .4rem 1rem .6rem; margin: 0 0 1.4rem; }
.listen h2 { font-family: var(--deva); font-size: 1.05rem; margin: .4rem 0; color: var(--accent); }
.episode { margin: .5rem 0 .9rem; }
.episode audio { width: 100%; height: 40px; }
.ep-title { font-family: var(--deva); margin: 0 0 .3rem; }
.ep-meta { font-family: var(--deva); color: var(--muted); font-size: .85rem; margin: .25rem 0 0; }
.has-audio { font-size: .85em; }
.series { margin: 1.6rem 0 2rem; }
.series h2 { font-family: var(--deva); margin-bottom: .3rem; }
.series-desc, .lede { font-family: var(--deva); color: var(--muted); }
.subscribe { font-size: .9rem; }
.episodes { list-style: none; padding: 0; }
.episodes .episode { border-top: 1px solid var(--line); padding-top: .7rem; }
