/* ==========================================================================
   SANATANA DHARMA — APPLE BOOKS / GOOGLE PLAY BOOKS CALIBER E-READER
   Design: 100vh Viewport-Locked Paginated Layout (Zero Window Scrollbars)
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Cinzel+Decorative:wght@700;900&family=Cinzel:wght@500;600;700;800&family=Cormorant+Garamond:ital,wght@0,400;0,500;0,600;0,700;1,400;1,600&family=Eczar:wght@400;600;700&family=Inter:wght@400;500;600;700&family=Noto+Serif+Devanagari:wght@400;600;700&family=Noto+Serif+Telugu:wght@400;500;600;700&family=Rozha+One&display=swap');

/* --- Foundations & 4 Archival Palettes --- */
:root {
  /* Swarna Patra (Antique Royal Parchment & Gold) */
  --bg-canvas: #EDE3CF;
  --bg-stage: #E4D8BE;
  --bg-page: #FAF5E8;
  --bg-page-alt: #F3EBD8;
  --bg-card: #FFFFFF;
  --bg-hud: rgba(250, 245, 232, 0.9);
  --bg-scrim: rgba(28, 20, 14, 0.65);

  --ink-primary: #231B12;
  --ink-secondary: #544434;
  --ink-muted: #7E6B56;
  --ink-faint: #A69680;

  --accent-gold: #B8860B;
  --accent-gold-light: #DFAC38;
  --accent-gold-dark: #8C6203;
  --accent-vermillion: #A8332A;
  --accent-crimson: #801818;
  --accent-teal: #1C5D66;
  --accent-saffron: #D97706;

  --border-antique: #D5C6A9;
  --border-gold: #C9A45C;
  --border-subtle: rgba(140, 98, 3, 0.15);

  --shadow-hud: 0 10px 30px rgba(35, 27, 18, 0.15), 0 2px 8px rgba(35, 27, 18, 0.08);
  --shadow-page: 0 12px 36px rgba(35, 27, 18, 0.16), 0 2px 10px rgba(35, 27, 18, 0.08);
  --shadow-drawer: 0 20px 50px rgba(18, 12, 8, 0.35);

  --font-display: 'Cinzel Decorative', 'Cinzel', serif;
  --font-heading: 'Cinzel', 'Rozha One', serif;
  --font-english: 'Cormorant Garamond', Georgia, serif;
  --font-telugu: 'Noto Serif Telugu', serif;
  --font-sanskrit: 'Noto Serif Devanagari', serif;
  --font-ui: 'Inter', system-ui, -apple-system, sans-serif;

  --font-scale: 1;
  --reading-width: 54rem;

  --transition-fast: 0.18s ease;
  --transition-smooth: 0.32s cubic-bezier(0.25, 1, 0.5, 1);
  --transition-spring: 0.42s cubic-bezier(0.34, 1.3, 0.64, 1);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-pill: 9999px;
}

[data-theme="ratnakara"] {
  --bg-canvas: #0A0E17;
  --bg-stage: #111724;
  --bg-page: #162030;
  --bg-page-alt: #131B29;
  --bg-card: #1C273A;
  --bg-hud: rgba(22, 32, 48, 0.9);
  --bg-scrim: rgba(4, 7, 12, 0.78);

  --ink-primary: #EAEFF6;
  --ink-secondary: #B6C4D6;
  --ink-muted: #8395AD;
  --ink-faint: #56687E;

  --accent-gold: #DFB15B;
  --accent-gold-light: #F4CE84;
  --accent-gold-dark: #B3862D;
  --accent-vermillion: #E05349;
  --accent-crimson: #C93B3B;
  --accent-teal: #38BDF8;
  --accent-saffron: #FB923C;

  --border-antique: #28374D;
  --border-gold: #9B7832;
  --border-subtle: rgba(223, 177, 91, 0.2);

  --shadow-hud: 0 10px 30px rgba(0, 0, 0, 0.55);
  --shadow-page: 0 16px 48px rgba(0, 0, 0, 0.65);
}

[data-theme="varanasi"] {
  --bg-canvas: #EADBD0;
  --bg-stage: #E0CEBF;
  --bg-page: #F6EEE6;
  --bg-page-alt: #EFE4D9;
  --bg-card: #FAF6F2;
  --bg-hud: rgba(246, 238, 230, 0.9);
  --bg-scrim: rgba(30, 18, 12, 0.68);

  --ink-primary: #2B1810;
  --ink-secondary: #583B2F;
  --ink-muted: #856152;
  --ink-faint: #AC8A7B;

  --accent-gold: #C07328;
  --accent-gold-light: #E0954C;
  --accent-gold-dark: #914E10;
  --accent-vermillion: #A82E1E;
  --accent-crimson: #78180E;
  --accent-teal: #2D6A4F;
  --accent-saffron: #D0681B;

  --border-antique: #D5BFAF;
  --border-gold: #C48E59;
  --border-subtle: rgba(192, 115, 40, 0.2);

  --shadow-hud: 0 10px 30px rgba(43, 24, 16, 0.15);
  --shadow-page: 0 14px 40px rgba(43, 24, 16, 0.2);
}

[data-theme="herbarium"] {
  --bg-canvas: #DEE6D8;
  --bg-stage: #D2DDCB;
  --bg-page: #F3F7F0;
  --bg-page-alt: #E9EFE5;
  --bg-card: #FFFFFF;
  --bg-hud: rgba(243, 247, 240, 0.9);
  --bg-scrim: rgba(16, 26, 18, 0.65);

  --ink-primary: #152419;
  --ink-secondary: #364C3D;
  --ink-muted: #5E7566;
  --ink-faint: #899E90;

  --accent-gold: #8E733B;
  --accent-gold-light: #B79B5D;
  --accent-gold-dark: #644E20;
  --accent-vermillion: #96382E;
  --accent-crimson: #731F17;
  --accent-teal: #285A48;
  --accent-saffron: #C47B2B;

  --border-antique: #C5D4BD;
  --border-gold: #9CA787;
  --border-subtle: rgba(40, 90, 72, 0.18);

  --shadow-hud: 0 10px 30px rgba(21, 36, 25, 0.15);
  --shadow-page: 0 14px 40px rgba(21, 36, 25, 0.18);
}

/* --- Zero Window Scrollbar Base Setup --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100vh;
  height: 100dvh;
  overflow: hidden; /* Strict lock on window scrollbar */
  background-color: var(--bg-canvas);
  color: var(--ink-primary);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  position: relative;
  transition: background-color var(--transition-smooth);
}

button {
  cursor: pointer;
  border: none;
  background: none;
  font: inherit;
  color: inherit;
}

input, select {
  font: inherit;
  color: inherit;
}

/* Custom In-Leaf Scrollbars */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border-gold);
  border-radius: 4px;
}

/* --- App Shell & 100vh Fullscreen Reading Canvas --- */
.reader-app {
  height: 100vh;
  height: 100dvh;
  width: 100vw;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* --- Apple Books-Style Auto-Hiding Floating HUD --- */
.reader-hud {
  position: fixed;
  left: 0;
  right: 0;
  z-index: 50;
  display: flex;
  justify-content: center;
  pointer-events: none;
  transition: transform var(--transition-spring), opacity var(--transition-smooth);
}

.reader-hud--top {
  top: 0.85rem;
  transform: translateY(-150%);
  opacity: 0;
}

.reader-hud--bottom {
  bottom: 0.85rem;
  transform: translateY(150%);
  opacity: 0;
}

/* When HUD is Active */
.reader-app.hud-active .reader-hud--top,
.reader-app.hud-active .reader-hud--bottom {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

/* Floating Glass Capsule */
.hud-capsule {
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  background: var(--bg-hud);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-gold);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-hud);
  padding: 0.3rem 0.6rem;
  max-width: 92vw;
}

.hud-capsule--bottom {
  padding: 0.3rem 0.8rem;
  gap: 0.75rem;
}

.hud-left, .hud-right {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.hud-btn {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--ink-secondary);
  transition: all var(--transition-fast);
}

.hud-btn:hover {
  background-color: rgba(184, 134, 11, 0.15);
  color: var(--accent-vermillion);
  transform: scale(1.05);
}

.hud-btn--toc {
  width: auto;
  height: 2rem;
  border-radius: var(--radius-pill);
  padding: 0 0.6rem;
  gap: 0.4rem;
  display: inline-flex;
}

.hud-chapter-text {
  font-family: var(--font-heading);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--ink-primary);
  max-width: 13rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hud-typography-icon {
  font-family: var(--font-english);
  font-size: 1rem;
  font-weight: 600;
}

.hud-kicker {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-vermillion);
}

/* Mode Switcher Pill */
.mode-segmented-control {
  display: flex;
  background-color: rgba(0, 0, 0, 0.06);
  border-radius: var(--radius-pill);
  padding: 0.15rem;
}

.mode-tab-btn {
  padding: 0.2rem 0.7rem;
  border-radius: var(--radius-pill);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--ink-muted);
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.mode-tab-btn:hover {
  color: var(--ink-primary);
}

.mode-tab-btn.is-active {
  background: var(--accent-vermillion);
  color: #FFFFFF;
  box-shadow: 0 2px 6px rgba(168, 51, 42, 0.3);
}

/* Bottom HUD Slider Group */
.hud-slider-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.slider-input {
  width: 8.5rem;
  accent-color: var(--accent-vermillion);
  cursor: pointer;
}

.hud-page-indicator {
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--ink-primary);
  min-width: 4.6rem;
  text-align: center;
}

/* Floating Bookmark Pin */
.floating-bookmark-pin {
  position: fixed;
  top: 1rem;
  right: 1.5rem;
  z-index: 20;
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 50%;
  background: var(--bg-hud);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-antique);
  color: var(--ink-muted);
  display: grid;
  place-items: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  transition: all var(--transition-fast);
}

.floating-bookmark-pin:hover {
  color: var(--accent-vermillion);
  border-color: var(--border-gold);
  transform: scale(1.1);
}

/* --- Pure 100vh Reading Stage --- */
.reader-stage {
  height: 100vh;
  height: 100dvh;
  max-height: 100vh;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem 1.5rem;
  cursor: default;
  touch-action: pan-y pinch-zoom;
}

/* Page Turn Hotzones */
.page-turn-zone {
  position: fixed;
  top: 0;
  bottom: 0;
  width: 12vw;
  z-index: 15;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.page-turn-zone--prev { left: 0; }
.page-turn-zone--next { right: 0; }

.page-turn-zone:hover {
  opacity: 0.6;
}

.page-turn-arrow {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 50%;
  background: var(--bg-hud);
  border: 1px solid var(--border-gold);
  color: var(--accent-gold-dark);
  font-size: 1.4rem;
  display: grid;
  place-items: center;
  box-shadow: var(--shadow-hud);
}

/* --- Viewport-Fitting Book Spread Container --- */
.book-stage-container {
  height: 100%;
  max-height: calc(100vh - 2.5rem);
  max-height: calc(100dvh - 2.5rem);
  width: 100%;
  max-width: calc(var(--reading-width) * 1.85);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.book-spread {
  height: 100%;
  max-height: 100%;
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  position: relative;
  background-color: var(--bg-page);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-page);
  border: 1px solid var(--border-gold);
  overflow: hidden;
}

/* Center Spine Crease */
.book-spread::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 28px;
  transform: translateX(-50%);
  background: linear-gradient(to right, 
    rgba(0,0,0,0.11) 0%, 
    rgba(0,0,0,0.02) 40%, 
    rgba(255,255,255,0.06) 50%, 
    rgba(0,0,0,0.02) 60%, 
    rgba(0,0,0,0.11) 100%);
  pointer-events: none;
  z-index: 10;
}

/* Single Page Viewport Fit */
.book-spread.is-single-page {
  grid-template-columns: 1fr;
  max-width: var(--reading-width);
  margin: 0 auto;
}

.book-spread.is-single-page::before {
  display: none;
}

/* Continuous Scroll Mode (Only if explicitly selected) */
.book-spread.is-continuous-scroll {
  display: flex;
  flex-direction: column;
  gap: 2rem;
  background: transparent;
  border: none;
  box-shadow: none;
  max-width: var(--reading-width);
  overflow-y: auto;
  max-height: 100%;
}

.book-spread.is-continuous-scroll::before {
  display: none;
}

.book-spread.is-continuous-scroll .book-leaf {
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-gold);
  box-shadow: var(--shadow-page);
  background-color: var(--bg-page);
  min-height: auto;
  max-height: none;
}

/* --- Authentic Book Page Leaf (Viewport Height Bound) --- */
.book-leaf {
  height: 100%;
  max-height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
  padding: 1.5rem 2.25rem 1.25rem 2.25rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background-color: var(--bg-page);
}

.book-leaf--left {
  border-right: 1px solid var(--border-antique);
}

.book-leaf--empty {
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle, var(--bg-page-alt) 0%, var(--bg-page) 70%);
}

/* --- Grand Antique Hardbound Book Cover Plate --- */
.book-cover-plate {
  height: 100%;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  text-align: center;
  padding: 1.5rem 1.25rem;
  background: radial-gradient(circle at 50% 35%, rgba(184, 134, 11, 0.12) 0%, transparent 70%),
              linear-gradient(145deg, var(--bg-page) 0%, var(--bg-page-alt) 100%);
  border: 2px solid var(--border-gold);
  border-radius: var(--radius-md);
  position: relative;
  box-shadow: inset 0 0 30px rgba(184, 134, 11, 0.08);
}

.book-cover-plate::before {
  content: "";
  position: absolute;
  inset: 6px;
  border: 1px dashed var(--border-gold);
  border-radius: calc(var(--radius-md) - 4px);
  pointer-events: none;
}

.cover-header-kicker {
  font-family: var(--font-ui);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent-vermillion);
}

.cover-gold-medallion {
  width: 4rem;
  height: 4rem;
  border-radius: 50%;
  background: radial-gradient(circle, #DFAC38 0%, #8C6203 100%);
  display: grid;
  place-items: center;
  color: #FFFFFF;
  font-family: var(--font-sanskrit);
  font-size: 2rem;
  box-shadow: 0 4px 16px rgba(184, 134, 11, 0.35), inset 0 2px 4px rgba(255, 255, 255, 0.4);
  border: 2px solid rgba(255, 255, 255, 0.6);
  margin: 0.35rem 0;
}

.cover-title-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.cover-title-latin {
  font-family: var(--font-display);
  font-size: clamp(1.25rem, 2.3vh + 0.4vw, 1.75rem);
  font-weight: 900;
  letter-spacing: 0.06em;
  color: var(--accent-crimson);
  line-height: 1.15;
}

.cover-title-telugu {
  font-family: var(--font-telugu);
  font-size: clamp(1.05rem, 1.8vh + 0.3vw, 1.35rem);
  font-weight: 700;
  color: var(--accent-gold-dark);
}

.cover-subtitle {
  font-family: var(--font-english);
  font-size: clamp(0.85rem, 1.25vh + 0.2vw, 1.05rem);
  font-style: italic;
  color: var(--ink-secondary);
  max-width: 20rem;
  margin: 0.2rem auto 0 auto;
}

.cover-seal-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-family: var(--font-ui);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-vermillion);
  padding: 0.2rem 0.65rem;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-gold);
  background: var(--bg-card);
}

.cover-colophon {
  font-family: var(--font-heading);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

/* --- Frontispiece & Benediction Plate (Right Leaf Page 1) --- */
.frontispiece-plate {
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  text-align: center;
  padding: 0.5rem 0;
}

.frontispiece-benediction {
  background: radial-gradient(circle, var(--bg-card) 0%, var(--bg-page-alt) 100%);
  border: 1px solid var(--border-gold);
  border-radius: var(--radius-md);
  padding: 0.9rem 0.85rem;
  margin: 0.5rem 0;
}

.benediction-sanskrit {
  font-family: var(--font-sanskrit);
  font-size: clamp(1.05rem, 1.5vh + 0.3vw, 1.2rem);
  font-weight: 600;
  color: var(--accent-crimson);
  line-height: 1.7;
  margin-bottom: 0.35rem;
}

.benediction-telugu {
  font-family: var(--font-telugu);
  font-size: clamp(0.9rem, 1.25vh + 0.2vw, 1rem);
  font-weight: 500;
  color: var(--accent-gold-dark);
  line-height: 1.55;
  margin-bottom: 0.35rem;
}

.benediction-translation {
  font-family: var(--font-english);
  font-size: 0.85rem;
  font-style: italic;
  color: var(--ink-secondary);
}

.frontispiece-censor-box {
  background: var(--bg-page-alt);
  border-radius: var(--radius-sm);
  border: 1px dashed var(--border-antique);
  padding: 0.5rem 0.75rem;
  font-family: var(--font-heading);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
  text-transform: uppercase;
  margin: 0.35rem 0;
}

.frontispiece-quick-actions {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-top: 0.4rem;
}

.frontispiece-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-pill);
  font-size: 0.82rem;
  font-weight: 600;
  transition: all var(--transition-fast);
}

.frontispiece-btn--primary {
  background: linear-gradient(135deg, var(--accent-vermillion), var(--accent-crimson));
  color: #FFFFFF;
  box-shadow: 0 3px 10px rgba(168, 51, 42, 0.35);
}

.frontispiece-btn--primary:hover {
  background: linear-gradient(135deg, var(--accent-gold-dark), var(--accent-gold));
  transform: translateY(-1px);
}

.frontispiece-btn--secondary {
  background: var(--bg-page-alt);
  border: 1px solid var(--border-gold);
  color: var(--ink-primary);
}

.frontispiece-btn--secondary:hover {
  background: var(--bg-card);
  color: var(--accent-vermillion);
}

/* Running Book Header */
.running-book-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--font-heading);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-muted);
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 0.45rem;
  margin-bottom: 1rem;
  flex-shrink: 0;
}

/* Chapter Title on Page */
.page-chapter-title {
  font-family: var(--font-heading);
  font-size: clamp(1.1rem, 2vh + 0.3vw, 1.3rem);
  font-weight: 700;
  color: var(--accent-crimson);
  text-align: center;
  letter-spacing: 0.04em;
  margin-bottom: 0.85rem;
}

/* Running Book Footer & Page Number */
.running-book-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent-vermillion);
  border-top: 1px solid var(--border-subtle);
  padding-top: 0.45rem;
  margin-top: 1rem;
  flex-shrink: 0;
}

/* --- Fluid Responsive Body Prose --- */
.page-body {
  flex: 1;
  font-size: clamp(0.95rem, 1.35vh + 0.35vw, calc(1.15rem * var(--font-scale)));
  line-height: clamp(1.55, 2.2vh, 1.85);
  color: var(--ink-primary);
  font-family: var(--font-english);
}

.page-body p {
  margin-bottom: 0.9rem;
  text-align: justify;
  text-justify: inter-word;
  hyphens: auto;
}

/* Telugu Script Adaptation */
.page-body[data-lang="telugu"],
.telugu-block {
  font-family: var(--font-telugu);
  font-size: clamp(0.92rem, 1.3vh + 0.35vw, calc(1.05rem * var(--font-scale)));
  line-height: clamp(1.6, 2.3vh, 1.9);
}

/* Parallel Mode Synchronized Columns */
.parallel-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin-bottom: 1.15rem;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-md);
  background-color: var(--bg-page-alt);
  border-left: 3px solid var(--accent-gold);
}

.parallel-col--english {
  font-family: var(--font-english);
}

.parallel-col--telugu {
  font-family: var(--font-telugu);
  border-left: 1px dashed var(--border-antique);
  padding-left: 1rem;
}

.parallel-col__label {
  font-family: var(--font-ui);
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--accent-vermillion);
  margin-bottom: 0.25rem;
  display: block;
}

/* Sanskrit Shloka Card */
.sanskrit-verse-block {
  margin: 1rem 0;
  padding: 0.85rem 1.25rem;
  background: radial-gradient(circle at 50% 50%, var(--bg-card) 0%, var(--bg-page-alt) 100%);
  border: 1px solid var(--border-gold);
  border-radius: var(--radius-md);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
  text-align: center;
  position: relative;
}

.sanskrit-verse-block::before {
  content: "ॐ";
  position: absolute;
  top: -0.7rem;
  left: 50%;
  transform: translateX(-50%);
  background-color: var(--bg-page);
  padding: 0 0.35rem;
  font-family: var(--font-sanskrit);
  font-size: 1rem;
  color: var(--accent-gold);
}

.sanskrit-text {
  font-family: var(--font-sanskrit);
  font-size: clamp(1.05rem, 1.5vh + 0.4vw, calc(1.2rem * var(--font-scale)));
  line-height: 1.75;
  color: var(--accent-crimson);
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.sanskrit-actions {
  display: flex;
  justify-content: center;
  gap: 0.4rem;
}

.verse-action-btn {
  font-size: 0.7rem;
  color: var(--ink-muted);
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-antique);
  background: var(--bg-page);
  transition: all var(--transition-fast);
}

.verse-action-btn:hover {
  color: var(--accent-vermillion);
  border-color: var(--border-gold);
}

/* Footnotes */
.page-footnotes {
  margin-top: 1rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--border-antique);
  font-size: 0.78rem;
  color: var(--ink-secondary);
  font-family: var(--font-english);
  flex-shrink: 0;
}

.page-footnotes p {
  margin-bottom: 0.25rem;
}

/* Glossary Chips & Highlights */
.glossary-term {
  cursor: pointer;
  color: var(--accent-vermillion);
  border-bottom: 1.5px dotted var(--accent-gold);
  font-weight: 600;
  transition: all var(--transition-fast);
}

.glossary-term:hover {
  background-color: rgba(184, 134, 11, 0.14);
  color: var(--accent-gold-dark);
}

mark.search-highlight {
  background-color: rgba(251, 191, 36, 0.45);
  color: var(--ink-primary);
  padding: 0.1em 0.25em;
  border-radius: 2px;
  font-weight: 600;
  border-bottom: 2px solid var(--accent-saffron);
}

/* --- Modals & Drawers --- */
.modal-scrim, .drawer-scrim {
  position: fixed;
  inset: 0;
  background-color: var(--bg-scrim);
  backdrop-filter: blur(6px);
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-smooth);
}

.modal-scrim.is-open, .drawer-scrim.is-open {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  width: 100%;
  max-width: 42rem;
  max-height: 85vh;
  background-color: var(--bg-card);
  border: 1px solid var(--border-gold);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-drawer);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.96) translateY(12px);
  transition: transform var(--transition-spring);
}

.modal-scrim.is-open .modal-card {
  transform: scale(1) translateY(0);
}

.modal-header {
  padding: 1.15rem 1.4rem;
  border-bottom: 1px solid var(--border-antique);
  background-color: var(--bg-page);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title-group h3 {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  color: var(--accent-crimson);
}

.modal-close-btn {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--ink-muted);
  transition: all var(--transition-fast);
}

.modal-close-btn:hover {
  background-color: var(--bg-page-alt);
  color: var(--accent-vermillion);
}

.modal-body {
  padding: 1.4rem;
  overflow-y: auto;
  flex: 1;
}

/* Search Modal */
.search-input-wrapper {
  position: relative;
  margin-bottom: 1.25rem;
}

.search-input {
  width: 100%;
  padding: 0.8rem 1rem 0.8rem 2.8rem;
  background-color: var(--bg-page);
  border: 1.5px solid var(--border-gold);
  border-radius: var(--radius-md);
  font-size: 1rem;
  color: var(--ink-primary);
  outline: none;
}

.search-input:focus {
  border-color: var(--accent-vermillion);
  box-shadow: 0 0 0 3px rgba(168, 51, 42, 0.15);
}

.search-icon-inside {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--accent-gold);
}

.search-results-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.search-result-item {
  padding: 0.85rem 1.1rem;
  background-color: var(--bg-page);
  border: 1px solid var(--border-antique);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.search-result-item:hover {
  border-color: var(--accent-gold);
  background-color: var(--bg-page-alt);
  transform: translateY(-1px);
}

.result-page-tag {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent-vermillion);
  margin-bottom: 0.25rem;
}

.result-snippet {
  font-family: var(--font-english);
  font-size: 0.95rem;
  color: var(--ink-secondary);
  line-height: 1.45;
}

/* Drawers */
.drawer-panel {
  position: fixed;
  top: 0;
  bottom: 0;
  width: 100%;
  max-width: 25rem;
  background-color: var(--bg-card);
  box-shadow: var(--shadow-drawer);
  z-index: 55;
  display: flex;
  flex-direction: column;
  transition: transform var(--transition-smooth);
}

.drawer-panel--left {
  left: 0;
  transform: translateX(-100%);
  border-right: 1px solid var(--border-gold);
}

.drawer-panel--right {
  right: 0;
  transform: translateX(100%);
  border-left: 1px solid var(--border-gold);
}

.drawer-scrim.is-open .drawer-panel {
  transform: translateX(0);
}

.drawer-header {
  padding: 1.15rem 1.4rem;
  background-color: var(--bg-page);
  border-bottom: 1px solid var(--border-antique);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.drawer-title {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  color: var(--ink-primary);
}

.drawer-body {
  padding: 1.15rem 1.4rem;
  overflow-y: auto;
  flex: 1;
}

.toc-part-group {
  margin-bottom: 1.4rem;
}

.toc-part-title {
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent-vermillion);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 0.5rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px dashed var(--border-antique);
}

.toc-chapter-item {
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.65rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  color: var(--ink-primary);
  font-family: var(--font-english);
  font-size: 0.95rem;
}

.toc-chapter-item:hover {
  background-color: var(--bg-page);
  color: var(--accent-vermillion);
}

.toc-chapter-item.is-active {
  background-color: var(--bg-page-alt);
  font-weight: 700;
  color: var(--accent-crimson);
  border-left: 3px solid var(--accent-vermillion);
}

.toc-page-num {
  font-family: var(--font-display);
  font-size: 0.72rem;
  color: var(--ink-muted);
}

/* Settings Modal */
.settings-group {
  margin-bottom: 1.35rem;
}

.settings-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent-vermillion);
  margin-bottom: 0.65rem;
  display: block;
}

.theme-palette-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.65rem;
}

.theme-card-option {
  padding: 0.75rem;
  border-radius: var(--radius-md);
  border: 2px solid var(--border-antique);
  background-color: var(--bg-page);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  transition: all var(--transition-fast);
}

.theme-card-option:hover {
  border-color: var(--accent-gold);
}

.theme-card-option.is-selected {
  border-color: var(--accent-vermillion);
  background-color: var(--bg-page-alt);
  box-shadow: 0 0 0 2px rgba(168, 51, 42, 0.2);
}

.theme-swatch {
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  border: 2px solid var(--border-gold);
  flex-shrink: 0;
}

.theme-info-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink-primary);
}

.theme-info-desc {
  font-size: 0.7rem;
  color: var(--ink-muted);
}

.layout-choice-btn {
  padding: 0.5rem 0.6rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-antique);
  background-color: var(--bg-page);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink-secondary);
  transition: all var(--transition-fast);
  text-align: center;
}

.layout-choice-btn:hover {
  border-color: var(--accent-gold);
}

.layout-choice-btn.is-active {
  border-color: var(--accent-vermillion);
  background: var(--accent-vermillion);
  color: #FFFFFF;
}

.range-setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 0.6rem;
}

.range-setting-row span {
  font-size: 0.82rem;
  color: var(--ink-secondary);
}

/* Download Grid */
.download-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.85rem;
}

.download-card {
  padding: 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-antique);
  background-color: var(--bg-page);
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  transition: all var(--transition-fast);
}

.download-card:hover {
  border-color: var(--accent-gold);
  transform: translateY(-2px);
}

.download-format-badge {
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent-vermillion);
}

.download-title {
  font-weight: 600;
  color: var(--ink-primary);
  font-size: 0.9rem;
}

.download-desc {
  font-size: 0.78rem;
  color: var(--ink-muted);
  flex: 1;
}

.download-action-btn {
  margin-top: 0.4rem;
  padding: 0.4rem 0.75rem;
  background-color: var(--accent-vermillion);
  color: #FFFFFF;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color var(--transition-fast);
}

.download-action-btn:hover {
  background-color: var(--accent-gold-dark);
}

/* ==========================================================================
   RESPONSIVE MULTI-SCREEN BREAKPOINTS
   ========================================================================== */

/* Tablets & Smaller Laptops (Max 1024px) */
@media (max-width: 1024px) {
  .book-stage-container {
    max-width: 96vw;
  }
  .book-spread {
    grid-template-columns: 1fr;
  }
  .book-spread::before {
    display: none;
  }
  .book-leaf--left {
    display: none !important; /* Show active right page on tablets & mobile */
  }
  .book-leaf {
    padding: 1.5rem 1.85rem 1.25rem 1.85rem;
  }
  .parallel-pair {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }
  .parallel-col--telugu {
    border-left: none;
    border-top: 1px dashed var(--border-antique);
    padding-left: 0;
    padding-top: 0.75rem;
  }
  .page-turn-zone {
    width: 16vw;
  }
}

/* Mobile Phones (Max 768px) */
@media (max-width: 768px) {
  .reader-stage {
    padding: 0.5rem;
  }
  .book-stage-container {
    max-height: calc(100vh - 1.25rem);
    max-height: calc(100dvh - 1.25rem);
    max-width: 100vw;
  }
  .book-spread {
    border-radius: var(--radius-md);
  }
  .book-leaf {
    padding: 1rem 1rem 0.85rem 1rem;
  }
  .running-book-header, .running-book-footer {
    padding-bottom: 0.35rem;
    padding-top: 0.35rem;
    margin-bottom: 0.65rem;
    margin-top: 0.65rem;
    font-size: 0.65rem;
  }
  .page-body {
    font-size: clamp(0.9rem, 1.2vh + 0.35vw, 1.05rem);
    line-height: 1.65;
  }
  .page-body p {
    margin-bottom: 0.7rem;
  }
  .reader-hud--top {
    top: 0.4rem;
  }
  .reader-hud--bottom {
    bottom: 0.4rem;
  }
  .hud-capsule {
    max-width: 98vw;
    padding: 0.25rem 0.45rem;
    gap: 0.35rem;
  }
  .hud-chapter-text {
    max-width: 7rem;
    font-size: 0.75rem;
  }
  .slider-input {
    width: 5.5rem;
  }
  .theme-palette-grid {
    grid-template-columns: 1fr;
  }
  .page-turn-zone {
    width: 20vw;
  }
}
