:root {
  --maroon: #8a5300; /* design D: marigold ink (the name is kept) */
  --orange: #f2a20f;
  --header-h: 3.75rem;
  --bar-h: 3.35rem;
  --serif-gu: "Noto Serif Gujarati", "Gujarati Sangam MN", "Gujarati MT", serif;
  --sans-gu: "Mukta Vaani", "Gujarati Sangam MN", "Gujarati MT", system-ui, sans-serif;
  --serif-hi: "Noto Serif Devanagari", "Devanagari Sangam MN", "Kohinoor Devanagari", serif;
  --sans-hi: "Mukta", "Kohinoor Devanagari", "Devanagari Sangam MN", system-ui, sans-serif;
  --serif-en: "Noto Serif", "Noto Serif Devanagari", Georgia, serif;
  --sans-en: "Noto Sans", "Mukta", system-ui, sans-serif;
  --serif: var(--serif-gu);
  --sans: var(--sans-gu);
  --scale: 1;
}
html[lang="hi"] { --serif: var(--serif-hi); --sans: var(--sans-hi); }
html[lang="gu-Latn"], html[lang="hi-Latn"] { --serif: var(--serif-en); --sans: var(--sans-en); }
:root, [data-theme="day"], [data-theme="beige"] {
  color-scheme: light;
  --bg: #fbf8f1;
  --alt-bg: #f6f1e4; /* every second chopai: a slightly different shade of the background */
  --surface: #ffffff;
  --tint: #fbefd6;
  --ink: #1b2233;
  --meaning-ink: #1b2233;
  --muted: #596071;
  --brand: #8a5300;
  --accent-ink: #8a5300;
  --line: #e1dbca;
  --on-brand: #ffffff;
  --mark: #fbefd6;
  --shadow: 0 10px 34px rgb(138 83 0 / .14);
}
[data-theme="beige"] { --bg: #FBF0D9; --alt-bg: #FCF5E6; }
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #16100b;
  --alt-bg: #1c150f;
  --surface: #201812;
  --tint: #33290f;
  --ink: #f4eadf;
  --meaning-ink: #f4eadf;
  --muted: #c4ae99;
  --brand: #f5b13a;
  --accent-ink: #f5b13a;
  --line: #3d2f24;
  --on-brand: #11141b;
  --mark: #33290f;
  --shadow: 0 10px 34px rgb(0 0 0 / .5);
}

* { box-sizing: border-box; }
html {
  scroll-padding-top: calc(var(--header-h) + var(--bar-h) + 1rem);
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 1.0625rem/1.7 var(--sans);
}
h1, h2, h3, p { margin: 0; }
a { color: inherit; }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--orange); outline-offset: 2px; border-radius: 4px; }

.skip {
  position: absolute; left: .75rem; top: -4rem; z-index: 60;
  background: var(--brand); color: var(--on-brand);
  padding: .5rem .9rem; border-radius: .5rem;
}
.skip:focus { top: .6rem; }

/* ---------- Header ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  height: var(--header-h);
  display: flex; align-items: center; gap: .5rem;
  padding: 0 .75rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.logo-link { flex: none; display: block; }
.brand { display: flex; align-items: center; min-width: 0; }
.logo-tile { flex: none; display: grid; place-items: center; border-radius: .5rem; }
[data-theme="dark"] .logo-tile { background: #fff; }
.logo-link img { display: block; height: 2.7rem; width: auto; padding: .1rem; }
.brand-text { line-height: 1.2; min-width: 0; }
/* The two books, side by side beside the logo; the one being read is underlined. */
.book-nav { display: flex; align-items: center; gap: .15rem; min-width: 0; }
.book-link {
  flex: none; padding: 0 .45rem; border-radius: .4rem;
  font: 600 1.05rem/1.65 var(--serif); color: var(--muted);
  text-decoration: none; white-space: nowrap;
}
.book-link-main { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.book-link:hover { background: var(--tint); color: var(--brand); }
.book-link[aria-current] { font-weight: 700; color: var(--brand); text-decoration: underline; text-decoration-color: var(--orange); text-decoration-thickness: 2px; text-underline-offset: .3em; }
.brand-sub { display: block; padding-left: .45rem; font-size: .8rem; line-height: 1.75; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.spacer { flex: 1; }
.icon-btn {
  flex: none; width: 2.6rem; height: 2.6rem;
  display: grid; place-items: center;
  background: none; border: 0; border-radius: .6rem;
  color: var(--brand);
}
.icon-btn:hover { background: var(--tint); }
.icon-btn svg { width: 1.4rem; height: 1.4rem; }

.header-controls { flex: none; display: flex; align-items: center; gap: .5rem; }
.lang-toggle { flex: none; display: flex; padding: .15rem; background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); border-radius: 2rem; }
.lang-toggle button {
  border: 0; background: none; border-radius: 2rem; padding: .15rem .75rem;
  font: 500 .92rem/1.5 "Mukta", "Mukta Vaani", system-ui, sans-serif; color: var(--muted);
}
.lang-toggle button[data-lang-choice="gu"] { font-family: "Mukta Vaani", var(--sans-gu); }
.lang-toggle button[aria-pressed="true"] { background: var(--tint); color: var(--brand); font-weight: 700; box-shadow: inset 0 0 0 2px var(--brand); }
.lang-toggle button:disabled { opacity: .5; cursor: not-allowed; }
.lang-toggle .short { display: none; }

.search-trigger {
  flex: 0 1 11.5rem; min-width: 7rem; display: flex; align-items: center; gap: .5rem;
  height: 2.4rem; padding: 0 .8rem; white-space: nowrap;
  background: var(--bg); border: 1px solid var(--line); border-radius: 2rem;
  color: var(--muted); font-size: .95rem;
}
.search-trigger:hover { border-color: var(--brand); }
.search-trigger svg { width: 1.1rem; height: 1.1rem; color: var(--brand); flex: none; }
.search-trigger kbd { margin-left: auto; font: 500 .7rem system-ui, sans-serif; border: 1px solid var(--line); border-radius: .3rem; padding: .05rem .35rem; }
.search-icon { display: none; }
.progress {
  position: absolute; left: 0; right: 0; bottom: -1px; height: 3px;
  background: var(--orange);
  transform: scaleX(var(--read, 0)); transform-origin: left;
}

/* ---------- Granth / Prakaran / Chopai dropdowns ---------- */
.jumpbar {
  position: sticky; top: var(--header-h); z-index: 28;
  height: var(--bar-h);
  display: grid; grid-template-columns: minmax(0, 15rem) minmax(0, 26rem) minmax(0, 8.5rem); gap: .6rem;
  align-items: center;
  padding: 0 .9rem;
  background: var(--tint);
  border-bottom: 1px solid var(--line);
  margin: 0;
}
.jump-field { display: flex; flex-direction: column; min-width: 0; }
.jump-field span { font-size: .72rem; font-weight: 600; line-height: 1.2; color: var(--muted); padding-left: .15rem; }
.jump-field select {
  width: 100%; min-width: 0; height: 1.85rem; padding: 0 .35rem;
  font: 500 .95rem/1.2 var(--sans);
  color: var(--brand); background: var(--surface);
  border: 1px solid var(--line); border-radius: .4rem;
  text-overflow: ellipsis;
}
.jump-field select:disabled { color: var(--muted); opacity: .75; }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: 20.5rem minmax(0, 1fr); align-items: start; }
body.toc-collapsed .shell { grid-template-columns: minmax(0, 1fr); }
body.toc-collapsed .toc { display: none; }

.toc {
  position: sticky; top: calc(var(--header-h) + var(--bar-h));
  height: calc(100dvh - var(--header-h) - var(--bar-h));
  overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: .9rem .6rem 2rem;
}
.toc-back { display: block; padding: 0 .6rem .35rem; font-size: .88rem; color: var(--accent-ink); text-decoration: none; font-weight: 500; }
.toc-back:hover { text-decoration: underline; }
.toc-back[hidden] { display: none; }
.toc h2 { font: 700 1rem/1.4 var(--serif); color: var(--brand); padding: 0 .6rem .55rem; }
.toc ol { list-style: none; margin: 0; padding: 0; }
.toc-link {
  display: grid; grid-template-columns: 2.1rem 1fr; gap: .15rem .55rem;
  padding: .5rem .6rem; border-radius: .6rem;
  text-decoration: none; line-height: 1.35;
}
.toc-link:hover { background: var(--tint); }
.toc-num {
  grid-row: span 2; align-self: start;
  width: 2.1rem; height: 2.1rem; border-radius: 50%;
  display: grid; place-items: center;
  font: 600 .82rem var(--serif); color: var(--brand);
  background: var(--tint);
}
.toc-title { font-weight: 500; font-size: .98rem; overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.toc-meta { font-size: .8rem; color: var(--muted); }
.toc-link[aria-current="page"] { background: var(--tint); color: var(--brand); font-weight: 700; box-shadow: inset 0 0 0 2px var(--brand); }
.toc-link[aria-current="page"] .toc-num { background: var(--brand); color: var(--on-brand); }
.scrim { display: none; }

.main-column {
  min-width: 0; display: flex; flex-direction: column;
  min-height: calc(100dvh - var(--header-h) - var(--bar-h));
}
main { flex: 1; min-width: 0; outline: none; }
.site-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--line);
  font: 400 .82rem/1.5 var(--sans-en);
  color: var(--muted);
  text-align: center;
}
.page { max-width: 47rem; margin: 0 auto; padding: 2.25rem 1.5rem 4rem; }
.loading { padding: 4rem 1rem; text-align: center; color: var(--muted); }

/* ---------- Home and Granth landing ---------- */
.hero { text-align: center; padding-bottom: 2.25rem; }
.hero .logo-tile { display: inline-grid; padding: .4rem; }
.hero img { display: block; width: 10.5rem; height: auto; }
.hero h1 { margin-top: .75rem; font: 700 clamp(2.1rem, 6.5vw, 3rem)/1.3 var(--serif); color: var(--brand); }
.couplet { margin-top: .9rem; font: 600 1.1rem/1.9 var(--serif); }
.stats { margin-top: .6rem; color: var(--muted); font-size: .98rem; }
.actions { margin-top: 1.5rem; display: flex; flex-wrap: wrap; gap: .7rem; justify-content: center; }
.btn { display: inline-block; padding: .5rem 1.35rem; border-radius: 2rem; font-weight: 600; text-decoration: none; border: 1.5px solid var(--brand); }
.btn-primary { background: var(--brand); color: var(--on-brand); }
.btn-primary:hover { filter: brightness(1.1); }
.btn-ghost { color: var(--brand); }
.btn-ghost:hover { background: var(--tint); }
.about {
  overflow-wrap: anywhere; /* long Sanskrit compounds must not widen the page */
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 1rem; padding: 1.4rem 1.6rem; margin-bottom: 2.5rem;
}
.about h2 { font: 700 1.2rem/1.5 var(--serif); color: var(--brand); }
.about .invocation { font: 600 1rem/1.8 var(--serif); color: var(--accent-ink); }
.about p + p { margin-top: .5rem; }
.about-more { margin-top: 1rem; }
.about-more summary { cursor: pointer; font: 700 1.05rem/1.5 var(--serif); color: var(--brand); }
.about-more summary + p { margin-top: .6rem; }
.section-title { font: 700 1.35rem/1.5 var(--serif); color: var(--brand); margin-bottom: .9rem; }
.card-list {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); gap: .6rem;
}
.card-list .toc-link { height: 100%; background: var(--surface); border: 1px solid var(--line); }
.card-list .toc-link:hover { border-color: var(--brand); background: var(--surface); }

/* ---------- Prakaran ---------- */
.reader { font-size: calc(1rem * var(--scale)); }
.mode { flex: none; display: inline-flex; padding: .15rem; background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); border-radius: 2rem; font-size: .88rem; }
.mode button { border: 0; background: none; padding: .15rem .75rem; border-radius: 2rem; color: var(--muted); white-space: nowrap; }
.mode button[aria-pressed="true"] { background: var(--tint); color: var(--brand); font-weight: 700; box-shadow: inset 0 0 0 2px var(--brand); }
.prakaran-head { text-align: center; padding-bottom: 1.5rem; margin-bottom: 1.75rem; border-bottom: 1px solid var(--line); }
.eyebrow { color: var(--accent-ink); font-weight: 600; font-size: 1em; }
.prakaran-head h1 { font: 700 2em/1.35 var(--serif); color: var(--brand); text-wrap: balance; outline: none; }
.prakaran-meta { color: var(--muted); font-size: .95em; margin-top: .25rem; }
.raga {
  display: inline-block; margin-top: .55rem; padding: .05rem .85rem;
  border-radius: 2rem; background: var(--tint); color: var(--brand);
  font-size: .95em; font-weight: 500;
}
.editor-note { background: var(--tint); border-radius: .75rem; padding: .7rem 1.1rem; margin-bottom: 1.75rem; color: var(--muted); font-size: .98em; }
.subhead { font: 700 1.2em/1.5 var(--serif); color: var(--brand); text-align: center; margin: 2.25rem 0 1.5rem; }
.chopai { position: relative; padding: .35rem 0 .45rem; border-bottom: 1px dashed var(--line); }
.chopai:last-of-type { border-bottom: 0; }
/* Shadows widen the band without moving the text, in either view. */
.chopai:nth-of-type(even) { background: var(--alt-bg); box-shadow: -.6rem 0 0 var(--alt-bg), .6rem 0 0 var(--alt-bg); }
.verse {
  position: relative;
  padding: .15rem 0;
  font: 700 1.1em/1.5 var(--serif);
  color: var(--brand);
  border-radius: 2px;
}
.verse .line { padding-left: 1em; text-indent: -1em; overflow-wrap: anywhere; }
.verse .line + .line { margin-top: .15em; }
.label {
  display: inline-block; text-indent: 0; margin-bottom: .1rem;
  font: 600 .68em/1.6 var(--sans); color: var(--accent-ink);
  border: 1px solid currentColor; border-radius: 2rem; padding: 0 .65em;
}
.num { color: var(--accent-ink); text-decoration: none; white-space: nowrap; font-weight: 600; }
.num:hover { text-decoration: underline; }
/* Favourite star: beside the chopai number, which it never leaves; a large tap area that doesn't move the text. */
.num-end { white-space: nowrap; }
.fav {
  display: inline-grid; place-items: center; vertical-align: middle;
  width: 2.4em; height: 2.4em; margin: -.8em -.8em -.8em -.35em; padding: 0;
  border: 0; border-radius: 50%; background: none; color: var(--muted); cursor: pointer;
}
.fav::before {
  content: ""; width: .95em; height: .95em; background: currentColor;
  -webkit-mask: url("star-outline.svg") center / contain no-repeat; mask: url("star-outline.svg") center / contain no-repeat;
}
.fav[aria-pressed="true"] { color: var(--brand); }
.fav[aria-pressed="true"]::before { -webkit-mask-image: url("star.svg"); mask-image: url("star.svg"); }
.fav:hover { color: var(--brand); }
.fav-item { position: relative; }
.fav-item .toc-link { padding-right: 2.6rem; }
.fav-item .fav { position: absolute; top: .3rem; right: .2rem; margin: 0; font-size: 1.1rem; }
.fav-empty { text-align: center; color: var(--muted); }
.card-list + .section-title { margin-top: 1.75rem; }
.meaning { margin-top: .15rem; font: 400 1.1em/1.6 var(--serif); color: var(--meaning-ink); text-wrap: pretty; }
.meaning p + p { margin-top: .6rem; }
.gap-note { margin: 1rem 0; padding: .4rem .9rem; font-size: .92em; color: var(--muted); background: var(--tint); border-radius: .5rem; }
body.verse-only .meaning { display: none; }
body.verse-only .chopai { padding: .15rem 0 .2rem; border-bottom: 0; }
.chopai.flash .verse { animation: flash 2s ease-out; }
@keyframes flash { 0%, 40% { background: var(--mark); } 100% { background: transparent; } }
.running-total { text-align: right; margin-top: .75rem; font-size: .9em; font-weight: 600; color: var(--muted); }
.running-total + .running-total { margin-top: .1rem; }
.running-total + .editor-note { margin: 1.25rem 0 0; }
.colophon { text-align: center; margin-top: 2rem; font: 700 1.15em/1.6 var(--serif); color: var(--accent-ink); }
.colophon + .colophon { margin-top: .25rem; }
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; margin-top: 2.5rem; }
.pager a {
  display: block; padding: .8rem 1.1rem; border-radius: .8rem;
  background: var(--surface); border: 1px solid var(--line);
  text-decoration: none; line-height: 1.4; min-width: 0;
}
.pager a:hover { border-color: var(--brand); }
.pager small { display: block; color: var(--muted); font-size: .85rem; }
.pager strong { display: block; color: var(--brand); font-weight: 600; overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.pager .next { grid-column: 2; text-align: right; }

/* ---------- Full Granth page ---------- */
.full-prakaran { content-visibility: auto; contain-intrinsic-size: auto 3000px; margin-inline: -.6rem; padding-inline: .6rem; } /* room for the bands, which content-visibility would clip */
.full-prakaran + .full-prakaran { margin-top: 3rem; }
.prakaran-head h2 { font: 700 1.6em/1.35 var(--serif); color: var(--brand); text-wrap: balance; }
.setting-link { display: block; width: 100%; text-align: center; background: none; }
.setting-link + .setting-link { margin-top: .5rem; }
.offline-status { margin-top: .5rem; font-size: .88rem; color: var(--muted); }
.setting-link[hidden] { display: none; }
.setting-link.btn-primary { background: var(--brand); }
/* Offered when a new version has been published while the app stayed open. */
.update-bar {
  position: fixed; z-index: 35; left: 50%; bottom: 1rem; transform: translateX(-50%);
  display: flex; align-items: center; gap: .75rem;
  width: max-content; max-width: calc(100vw - 1rem);
  padding: .5rem .6rem .5rem 1rem; border-radius: 2rem;
  background: var(--surface); border: 1px solid var(--line); box-shadow: 0 4px 18px rgb(0 0 0 / .22);
  font-size: .95rem;
}
.update-bar[hidden] { display: none; }
.update-bar .btn { flex: none; padding: .25rem 1rem; }
.update-close { flex: none; width: 2rem; height: 2rem; border: 0; border-radius: 50%; background: none; color: var(--muted); font-size: 1.25rem; line-height: 1; }
.update-close:hover { background: var(--tint); }
.parayan-granth + .parayan-granth { margin-top: 4rem; }
.parayan-head { text-align: center; padding-bottom: 1rem; }
.parayan-head h2 { font: 700 2.2em/1.3 var(--serif); color: var(--brand); }

/* ---------- Dialogs ---------- */
dialog {
  border: 1px solid var(--line); border-radius: 1rem;
  background: var(--surface); color: var(--ink);
  box-shadow: var(--shadow); padding: 0;
}
dialog::backdrop { background: rgb(30 15 20 / .5); }
#searchDialog {
  width: min(42rem, calc(100vw - 1.5rem));
  height: min(38rem, calc(100dvh - 3rem));
  margin: 1.5rem auto auto;
  overflow: hidden;
}
#searchDialog[open] { display: flex; flex-direction: column; }
.search-box { display: flex; align-items: center; gap: .5rem; padding: .4rem .5rem .4rem .9rem; border-bottom: 1px solid var(--line); }
.search-box svg { width: 1.25rem; height: 1.25rem; color: var(--brand); flex: none; }
.search-box .icon-btn svg { color: inherit; }
.search-box input { flex: 1; min-width: 0; border: 0; background: none; color: inherit; outline: none; font: 400 1.15rem/2 var(--sans); }
.search-box input::-webkit-search-cancel-button { display: none; }
.search-scope { padding: .55rem .9rem 0; }
.search-scope .segmented { max-width: 32rem; font-size: .9rem; }
.search-status { padding: .45rem 1rem; font-size: .88rem; color: var(--muted); }
.results { flex: 1; min-height: 0; list-style: none; margin: 0; padding: 0 .4rem .5rem; overflow-y: auto; }
.results a { display: block; padding: .55rem .7rem; border-radius: .6rem; text-decoration: none; line-height: 1.55; }
.results a:hover, .results a:focus-visible { background: var(--tint); }
.result-where { font-size: .82rem; color: var(--accent-ink); font-weight: 600; }
.result-kind { color: var(--muted); font-weight: 400; }
.result-text { display: block; font-size: .98rem; }
.results a.is-verse .result-text { font-family: var(--serif); font-weight: 600; color: var(--brand); }
mark { background: var(--mark); color: inherit; border-radius: 2px; padding: 0 1px; }

#settingsDialog { width: min(23rem, calc(100vw - 1.5rem)); padding: 1.1rem 1.25rem 1.25rem; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .6rem; }
.dialog-head h2 { font: 700 1.15rem/1.4 var(--serif); color: var(--brand); }
.setting { margin-top: .9rem; }
.setting-label { display: block; font-weight: 600; margin-bottom: .35rem; font-size: .95rem; }
.segmented { display: flex; gap: .25rem; padding: .2rem; background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); border-radius: .7rem; }
.segmented button { flex: 1; border: 0; background: none; border-radius: .5rem; padding: .3rem .3rem; color: var(--muted); }
.segmented button[aria-pressed="true"] { background: var(--tint); color: var(--brand); font-weight: 700; box-shadow: inset 0 0 0 2px var(--brand); }
.size-row { display: flex; align-items: center; gap: .6rem; }
.size-row input { flex: 1; accent-color: var(--maroon); }
.size-value { min-width: 3.2rem; text-align: right; color: var(--muted); font-size: .9rem; }

/* The book names keep their room: the search box becomes an icon before they would be cut off. */
@media (max-width: 80rem) {
  .search-trigger { display: none; }
  .search-icon { display: grid; }
}
@media (max-width: 70rem) {
  .lang-toggle .long { display: none; }
  .lang-toggle .short { display: inline; }
  .lang-toggle button { padding: .15rem .55rem; }
}

/* ---------- Narrow screens: contents become a drawer ---------- */
@media (max-width: 62rem) {
  .shell, body.toc-collapsed .shell { grid-template-columns: minmax(0, 1fr); }
  body.toc-collapsed .toc { display: block; }
  .toc {
    position: fixed; z-index: 45; top: 0; left: 0; bottom: 0;
    width: min(21rem, 86vw); height: auto;
    transform: translateX(-102%); visibility: hidden;
    transition: transform .22s ease, visibility .22s;
    box-shadow: var(--shadow);
  }
  body.toc-open .toc { transform: none; visibility: visible; }
  body.toc-open .scrim {
    display: block; position: fixed; inset: 0; z-index: 40;
    background: rgb(30 15 20 / .45); border: 0; padding: 0;
  }
  body.toc-open { overflow: hidden; }
  .search-trigger { display: none; }
  .search-icon { display: grid; }
  .lang-toggle .long { display: none; }
  .lang-toggle .short { display: inline; }
  .lang-toggle button { padding: .15rem .55rem; }
  .jumpbar { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1.5fr) minmax(0, .8fr); }
}
@media (min-width: 40.01rem) and (max-width: 62rem) {
  /* Between phone and desktop the toggles need the room; the dropdowns show the position. */
  .brand-sub { display: none; }
}
@media (max-width: 56rem) {
  /* The two toggles take their own row, leaving the first for the logo and both book names. */
  :root { --header-h: 6.2rem; }
  .topbar { flex-wrap: wrap; align-content: center; gap: 0 .2rem; padding: .15rem .35rem .3rem; }
  .spacer { display: none; }
  .brand { flex: 1 1 0; }
  .header-controls { order: 5; flex: 1 0 100%; justify-content: space-between; gap: .3rem; }
}
@media (max-width: 23rem) {
  /* The smallest phones need tighter toggles to fit all the languages. Loaded before the phone
     rules, so these repeat the selector to win over them. */
  .header-controls .lang-toggle button { padding: .15rem .3rem; }
  .header-controls .mode button { padding-inline: .3rem; font-size: .7rem; }
}
@media (max-width: 40rem) {
  /* On a phone the dropdowns scroll away with the page. */
  :root { --bar-h: 0rem; }
  .icon-btn { width: 2.1rem; }
  .lang-toggle button { padding: .15rem .4rem; }
  .lang-toggle button[data-lang-choice^="en"] { font-size: .8rem; } /* EN-GU and EN-HI are the longest */
  .mode { min-width: 0; }
  .mode button { padding-inline: .45rem; font-size: .76rem; }
  .jumpbar { position: static; height: 3.35rem; gap: .35rem; padding: 0 .5rem; }
  .jump-field select { font-size: .85rem; }
  .logo-link img { height: 2.2rem; }
  .book-nav { gap: 0; }
  .book-link { font-size: .88rem; padding: 0 .2rem; }
  .brand-sub { font-size: .72rem; padding-left: .2rem; }
  .page { padding: 1.25rem 1.1rem 3rem; }
  .pager { grid-template-columns: 1fr; }
  .pager .next { grid-column: 1; }
  .about { padding: 1.1rem 1.15rem; }
}
@media (max-height: 500px) {
  /* A phone on its side: one slim header row stays, and the dropdowns scroll away with the page. */
  :root { --header-h: 2.9rem; --bar-h: 0rem; }
  .topbar { flex-wrap: nowrap; gap: .2rem; padding: 0 .35rem; }
  .spacer { display: block; }
  .brand { flex: 0 1 auto; }
  .brand-sub { display: none; }
  .book-link { font-size: .92rem; padding: 0 .3rem; }
  .logo-link img { height: 2.1rem; }
  .icon-btn { width: 2.2rem; height: 2.2rem; }
  .header-controls { order: 0; flex: none; gap: .3rem; }
  .mode { font-size: .8rem; }
  .mode button { padding: .1rem .55rem; }
  .jumpbar { position: static; height: 3.1rem; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
@media print {
  .topbar, .jumpbar, .toc, .pager, .update-bar { display: none !important; }
  .shell { display: block; }
  .chopai { break-inside: avoid; }
  .chopai:nth-of-type(even) { background: none; box-shadow: none; }
}

/* ---------- Inside the iOS and Android apps ----------
   assets/app.js marks the page "in-app" and lets it fill the whole screen, so the header, the side
   menu and the bottom bar keep clear of the notch, the status bar and the home bar. */
html.in-app {
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --header-h: calc(3.75rem + var(--safe-top));
}
html.in-app .topbar {
  padding-top: var(--safe-top);
  padding-left: max(.75rem, env(safe-area-inset-left, 0px));
  padding-right: max(.75rem, env(safe-area-inset-right, 0px));
}
html.in-app .toc { padding-top: var(--safe-top); padding-bottom: var(--safe-bottom); }
html.in-app .site-footer { padding-bottom: calc(1rem + var(--safe-bottom)); }
html.in-app .update-bar { bottom: calc(1rem + var(--safe-bottom)); }
html.in-app #searchDialog {
  margin-top: calc(1.5rem + var(--safe-top));
  height: min(38rem, calc(100dvh - 3rem - var(--safe-top) - var(--safe-bottom)));
}
html.in-app #settingsDialog { max-height: calc(100dvh - 2rem - var(--safe-top) - var(--safe-bottom)); }
@media (max-width: 56rem) {
  html.in-app { --header-h: calc(6.2rem + var(--safe-top)); }
  html.in-app .topbar { padding: calc(.15rem + var(--safe-top)) max(.35rem, env(safe-area-inset-right, 0px)) .3rem max(.35rem, env(safe-area-inset-left, 0px)); }
}

/* ---------- The privacy policy (privacy.html) ---------- */
.pv { --header-h: 3.75rem; display: flex; flex-direction: column; min-height: 100dvh; }
html.in-app .pv { --header-h: calc(3.75rem + var(--safe-top)); }
html.in-app .pv .topbar { padding-bottom: 0; }
.pv-back { padding: .3rem 1rem; font: 600 .92rem/1.4 var(--sans-en); }
.pv-main { flex: 1; width: 100%; max-width: 44rem; margin: 0 auto; padding: 1.25rem 1.25rem 3rem; color: var(--ink); }
.pv-langs { display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; padding-bottom: .75rem; border-bottom: 1px solid var(--line); }
.pv-langs a, .pv-sec a { color: var(--accent-ink); font-weight: 600; text-underline-offset: .2em; }
.pv-langs a[lang="gu"] { font-family: var(--sans-gu); }
.pv-langs a[lang="hi"] { font-family: var(--sans-hi); }
.pv-langs a:not([lang]) { font-family: var(--sans-en); }
.pv-sec { padding: 1.5rem 0 1rem; scroll-margin-top: var(--header-h); font: 400 1.02rem/1.7 var(--sans-en); }
.pv-sec + .pv-sec { border-top: 1px solid var(--line); }
.pv-sec[lang="gu"] { font-family: var(--sans-gu); }
.pv-sec[lang="hi"] { font-family: var(--sans-hi); }
.pv-sec h1 { margin: 0 0 .4rem; font-size: 1.6rem; line-height: 1.35; color: var(--brand); }
.pv-sec h2 { margin: 1.4rem 0 .25rem; font-size: 1.08rem; color: var(--brand); }
.pv-sec p { margin: 0 0 .5rem; }
.pv-for { color: var(--muted); font-size: .95rem; }
.site-footer a { color: inherit; text-underline-offset: .2em; }
