/* ============================================================
   The Four Jyotish Books — shared design system
   One stylesheet, four accent colors (set per-book via :root)
   ============================================================ */

:root {
  --bg: #14132b;
  --bg-top: #100f24;
  --bg-bot: #16142e;
  --panel: #f7f0e2;
  --panel-soft: #efe7d2;
  --ink: #2a2440;
  --ink2: #5a5270;
  --ink3: #8b84a4;
  --text: #ece6d8;
  --text-soft: #cfc7e0;
  --text-muted: #9b93b5;
  --accent: #7fd0c4;     /* override per book */
  --accent2: #3aa395;    /* override per book */
  --accent-rgb: 127, 208, 196;   /* override per book */
  --accent2-rgb: 58, 163, 149;   /* override per book */
  --line: rgba(247, 240, 226, 0.14);
  --line-strong: rgba(247, 240, 226, 0.28);
  --go: #5fa86b;
  --warn: #d97a3a;
  --bad: #c05050;

  --r-sm: 8px;
  --r-md: 14px;
  --r-lg: 20px;

  --shadow-card: 0 10px 28px rgba(0, 0, 0, 0.22);
  --shadow-glow: 0 0 0 1px rgba(127, 208, 196, 0.22), 0 12px 40px rgba(0, 0, 0, 0.35);

  --serif-display: 'Fraunces', 'Times New Roman', serif;
  --serif-body: 'Spectral', Georgia, 'Times New Roman', serif;
  --sans: 'Space Grotesk', -apple-system, 'Segoe UI', sans-serif;
  --devanagari: 'Noto Serif Devanagari', 'Sanskrit Text', serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: linear-gradient(180deg, var(--bg-top), var(--bg) 45%, var(--bg-bot));
  color: var(--text);
  font-family: var(--serif-body);
  line-height: 1.7;
  font-size: 17px;
  overflow-x: hidden;
}

img, svg { max-width: 100%; height: auto; }
a { color: var(--accent); text-decoration: none; border-bottom: 1px dotted rgba(127, 208, 196, 0.4); }
a:hover { color: #fff; border-bottom-color: #fff; }

/* ============================================================
   BookNav — unified hamburger navigation bar
   ============================================================ */
.booknav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.4rem;
  height: 3.2rem;
  background: linear-gradient(180deg, rgba(16, 15, 36, 0.96), rgba(16, 15, 36, 0.85));
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
}
.booknav-brand {
  font-family: var(--serif-display);
  font-size: 0.95rem;
  color: var(--accent);
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.booknav-brand small {
  font-family: var(--sans);
  font-size: 0.6rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-left: 0.5rem;
}
.booknav-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.booknav-hamburger {
  background: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text-soft);
  width: 40px;
  height: 32px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 0;
  transition: all 0.3s;
}
.booknav-hamburger span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--text-soft);
  border-radius: 2px;
  transition: all 0.3s;
}
.booknav-hamburger:hover { border-color: var(--accent); }
.booknav-hamburger:hover span { background: var(--accent); }
.booknav-hamburger.open span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.booknav-hamburger.open span:nth-child(2) { opacity: 0; }
.booknav-hamburger.open span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

.booknav-menu {
  display: none;
  position: fixed;
  top: 3.2rem;
  left: 0;
  right: 0;
  background: linear-gradient(180deg, rgba(16, 15, 36, 0.98), rgba(16, 15, 36, 0.95));
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--line);
  padding: 1.2rem 1.4rem 1.6rem;
  max-height: calc(100vh - 3.2rem);
  overflow-y: auto;
  z-index: 89;
  animation: navSlide 0.25s ease-out;
}
@keyframes navSlide {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.booknav-menu.open { display: block; }

.bn-section {
  margin-bottom: 1.2rem;
}
.bn-section:last-child { margin-bottom: 0; }
.bn-label {
  font-family: var(--sans);
  font-size: 0.6rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--line);
}
.bn-books {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.6rem;
}
.bn-book {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.65rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  text-decoration: none;
  color: var(--text-soft);
  font-family: var(--sans);
  font-size: 0.82rem;
  transition: all 0.25s;
  border-bottom: 1px solid var(--line);
}
.bn-book:hover {
  border-color: var(--accent);
  color: #fff;
  background: rgba(var(--accent-rgb), 0.08);
  transform: translateY(-1px);
}
.bn-book.bn-cur {
  border-color: var(--accent);
  background: rgba(var(--accent-rgb), 0.12);
  color: #fff;
}
.bn-book-num {
  font-family: var(--serif-display);
  font-style: italic;
  font-size: 1.1rem;
  color: var(--accent);
  min-width: 1.8rem;
  text-align: center;
}
.bn-book-info {
  display: flex;
  flex-direction: column;
}
.bn-book-title {
  font-weight: 600;
  font-size: 0.82rem;
  line-height: 1.25;
}
.bn-book-sub {
  font-size: 0.68rem;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}
.bn-tools {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.bn-tool {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 20px;
  font-family: var(--sans);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: none;
  cursor: pointer;
  transition: all 0.25s;
  text-decoration: none;
  border-bottom: 1px solid var(--line);
}
.bn-tool:hover { border-color: var(--accent); color: var(--accent); }

/* Override old ribbon position when booknav exists */
.booknav ~ .ribbon { display: none; }
.booknav ~ .shell { padding-top: 3.5rem; }
.booknav ~ .progress { top: 3.2rem; }

@media (max-width: 720px) {
  .booknav { padding: 0 1rem; height: 2.8rem; }
  .booknav-brand small { display: none; }
  .booknav-menu { top: 2.8rem; padding: 0.8rem 1rem 1.2rem; }
  .bn-books { grid-template-columns: 1fr; }
  .booknav ~ .shell { padding-top: 3rem; }
  .booknav ~ .progress { top: 2.8rem; }
}

/* ============================================================
   Starfield + nebula
   ============================================================ */
.stars { position: fixed; inset: 0; z-index: 0; pointer-events: none; }
.stars i {
  position: absolute;
  width: 2px; height: 2px;
  border-radius: 50%;
  background: #fff;
  opacity: 0.4;
  animation: twinkle 4s infinite ease-in-out;
}
@keyframes twinkle {
  0%, 100% { opacity: 0.15; }
  50%      { opacity: 0.75; }
}
.nebula {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 60% 40% at 20% 25%, rgba(var(--accent-rgb), 0.180) 0%, transparent 60%),
    radial-gradient(ellipse 50% 35% at 80% 75%, rgba(var(--accent2-rgb), 0.140) 0%, transparent 60%);
  filter: blur(40px);
  opacity: 0.7;
}

/* ============================================================
   Ribbon (top of every page)
   ============================================================ */
.ribbon {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  gap: 0.35rem;
  justify-content: center;
  flex-wrap: wrap;
  padding: 0.9rem 4vw 0.5rem;
  background: linear-gradient(180deg, rgba(16, 15, 36, 0.95), rgba(16, 15, 36, 0.7));
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.rtier {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-family: var(--sans);
  font-size: 0.74rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  border: 1px solid var(--line);
  padding: 0.4rem 0.85rem;
  border-radius: 30px;
  transition: all 0.3s ease;
  text-decoration: none;
  border-bottom: 1px solid var(--line);
}
.rtier span {
  font-family: var(--serif-display);
  font-style: italic;
  color: var(--accent);
}
.rtier:hover {
  color: #fff;
  border-color: var(--accent);
  transform: translateY(-1px);
}
.rtier.rt-cur {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}
.rtier.rt-cur span { color: var(--bg); }

/* ============================================================
   Hero / Cover
   ============================================================ */
header.hero {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 9vh 5vw 8vh;
}
.eyebrow {
  font-family: var(--sans);
  text-transform: uppercase;
  letter-spacing: 0.34em;
  font-size: 0.72rem;
  color: var(--accent);
}
h1 {
  font-family: var(--serif-display);
  font-weight: 400;
  font-size: clamp(2.4rem, 6.5vw, 4.2rem);
  line-height: 1.04;
  margin: 0.6rem 0 0.3rem;
  letter-spacing: -0.01em;
  color: #fff;
}
h1 .sanskrit {
  display: block;
  font-family: var(--devanagari);
  font-size: 0.4em;
  color: var(--accent);
  letter-spacing: 0.02em;
  margin-top: 0.8rem;
  font-style: italic;
  font-weight: 400;
}
.hero p.tag {
  max-width: 720px;
  margin: 1.4rem auto 0;
  color: var(--text-soft);
  font-size: 1.12rem;
}
.facts {
  display: flex;
  gap: 1.6rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 2.2rem;
  font-family: var(--sans);
  font-size: 0.74rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.facts b {
  color: var(--accent);
  font-weight: 500;
  display: block;
  margin-bottom: 0.15rem;
  letter-spacing: 0.1em;
}
.facts div { max-width: 260px; }

/* ============================================================
   Layout — sidebar TOC + content
   ============================================================ */
.shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 4vw;
  gap: 3rem;
}
aside.toc {
  position: sticky;
  top: 5.5rem;
  align-self: start;
  max-height: calc(100vh - 6rem);
  overflow-y: auto;
  padding-right: 0.5rem;
  font-family: var(--sans);
}
aside.toc h4 {
  font-family: var(--sans);
  font-size: 0.65rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0 0 0.8rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--line);
}
aside.toc ol {
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: toc;
}
aside.toc ol li {
  counter-increment: toc;
  margin: 0.25rem 0;
}
aside.toc a {
  display: flex;
  gap: 0.55rem;
  align-items: baseline;
  color: var(--text-soft);
  font-size: 0.82rem;
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
  border: none;
  line-height: 1.35;
}
aside.toc a::before {
  content: counter(toc, decimal-leading-zero);
  font-family: var(--serif-display);
  font-style: italic;
  color: var(--accent);
  font-size: 0.78rem;
  min-width: 1.6rem;
}
aside.toc a:hover { background: rgba(247, 240, 226, 0.04); color: #fff; }
aside.toc a.active { background: rgba(var(--accent-rgb), 0.140); color: #fff; }

main.content { padding: 0 0 6vh; min-width: 0; }

/* Mobile TOC trigger */
.toc-toggle {
  display: none;
  position: fixed;
  bottom: 1.2rem;
  right: 1.2rem;
  z-index: 40;
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: 999px;
  padding: 0.8rem 1.1rem;
  font-family: var(--sans);
  font-weight: 600;
  font-size: 0.85rem;
  letter-spacing: 0.06em;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

/* ============================================================
   Cards, panels, typography
   ============================================================ */
section.chapter {
  padding: 5vh 0 4vh;
  scroll-margin-top: 6rem;
  border-top: 1px solid var(--line);
}
section.chapter:first-of-type { border-top: 0; }
section.front-matter { padding: 4vh 0; }

.ch-head {
  margin-bottom: 2.2rem;
  border-left: 3px solid var(--accent);
  padding-left: 1.4rem;
}
.ch-num {
  font-family: var(--sans);
  font-size: 0.72rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
}
.ch-num b { font-weight: 600; }
h2 {
  font-family: var(--serif-display);
  font-weight: 400;
  font-size: clamp(1.8rem, 4.5vw, 2.6rem);
  line-height: 1.1;
  margin: 0.4rem 0 0.4rem;
  color: #fff;
}
.ch-sub {
  font-family: var(--devanagari);
  font-style: italic;
  color: var(--accent);
  font-size: 0.95rem;
  margin: 0;
}
.ch-meta {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  margin-top: 1rem;
  font-family: var(--sans);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.ch-meta b { color: var(--accent); font-weight: 500; }

h3 {
  font-family: var(--serif-display);
  font-weight: 500;
  font-size: 1.35rem;
  color: #fff;
  margin: 2.2rem 0 0.8rem;
  letter-spacing: -0.005em;
}
h4 {
  font-family: var(--sans);
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 1.8rem 0 0.6rem;
}
p { margin: 0.6rem 0 1rem; }

.card {
  background: linear-gradient(135deg, #1d1b3a, #221f40);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 1.6rem 1.8rem;
  margin: 1.4rem 0;
}
.card.lite { border-color: rgba(247, 240, 226, 0.2); }
.card h3 { margin-top: 0; }
.card p:last-child { margin-bottom: 0; }

.panel {
  background: var(--panel);
  color: var(--ink);
  border-radius: var(--r-md);
  padding: 1.5rem 1.7rem;
  box-shadow: var(--shadow-card);
  margin: 1.4rem 0;
  border-left: 4px solid var(--accent);
}
.panel.soft { background: var(--panel-soft); }
.panel h3 { color: #1a1530; margin-top: 0; font-size: 1.25rem; }
.panel p { color: #3a3357; }
.panel.dark {
  background: linear-gradient(135deg, #1d1b3a, #241f42);
  color: var(--text);
  border-left-color: var(--accent);
}
.panel.dark h3 { color: #fff; }
.panel.dark p { color: var(--text-soft); }

.callout {
  background: rgba(var(--accent-rgb), 0.08);
  border: 1px solid rgba(var(--accent-rgb), 0.280);
  border-left: 4px solid var(--accent);
  border-radius: var(--r-md);
  padding: 1.2rem 1.4rem;
  margin: 1.4rem 0;
}
.callout.warn { background: rgba(217, 122, 58, 0.07); border-color: rgba(217, 122, 58, 0.35); border-left-color: var(--warn); }
.callout.tip { background: rgba(95, 168, 107, 0.07); border-color: rgba(95, 168, 107, 0.35); border-left-color: var(--go); }
.callout h4 { color: var(--accent); margin-top: 0; }
.callout.warn h4 { color: var(--warn); }
.callout.tip h4 { color: var(--go); }
.callout p:last-child { margin-bottom: 0; }

ul.flow, ol.flow { margin: 0.5rem 0 1.1rem; padding-left: 1.25rem; }
ul.flow li, ol.flow li { margin: 0.45rem 0; color: var(--text-soft); }
ul.flow li::marker { color: var(--accent); }

ul.check { list-style: none; padding: 0; }
ul.check li {
  padding-left: 1.6rem;
  position: relative;
  margin: 0.5rem 0;
  color: var(--text-soft);
}
ul.check li::before {
  content: "✓";
  position: absolute;
  left: 0;
  color: var(--go);
  font-weight: 600;
}

/* Glossary terms */
.glossary { margin: 1rem 0; }
.glossary dt {
  font-family: var(--serif-display);
  font-style: italic;
  color: var(--accent);
  font-size: 1.05rem;
  margin-top: 0.8rem;
}
.glossary dd {
  margin: 0.2rem 0 0 0;
  color: var(--text-soft);
}

/* Inline code / verse */
code, .mono {
  font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
  background: rgba(247, 240, 226, 0.06);
  padding: 0.05em 0.35em;
  border-radius: 4px;
  font-size: 0.88em;
  color: var(--accent);
}
.verse {
  font-family: var(--devanagari);
  display: block;
  background: rgba(247, 240, 226, 0.03);
  border-left: 3px solid var(--accent);
  padding: 1rem 1.2rem;
  margin: 1rem 0;
  font-style: italic;
  color: var(--text-soft);
  line-height: 1.85;
}
.verse small {
  display: block;
  font-family: var(--sans);
  font-style: normal;
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.4rem;
}
.sanskrit-inline { font-family: var(--devanagari); }

/* ============================================================
   Tables
   ============================================================ */
table.data {
  width: 100%;
  border-collapse: collapse;
  margin: 1.2rem 0;
  font-size: 0.92rem;
  font-family: var(--sans);
  background: rgba(247, 240, 226, 0.025);
  border-radius: var(--r-md);
  overflow: hidden;
  border: 1px solid var(--line);
}
table.data th, table.data td {
  text-align: left;
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--line);
}
table.data th {
  background: rgba(var(--accent-rgb), 0.140);
  color: #fff;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 0.72rem;
}
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: rgba(247, 240, 226, 0.03); }

/* ============================================================
   Illustrations
   ============================================================ */
figure {
  margin: 1.6rem 0;
  text-align: center;
}
figure img, figure svg { display: block; margin: 0 auto; border-radius: var(--r-md); cursor: zoom-in; }
figure .frame {
  background: rgba(247, 240, 226, 0.03);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 1rem;
  display: inline-block;
  max-width: 100%;
}
figure figcaption {
  font-family: var(--sans);
  font-size: 0.78rem;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  margin-top: 0.6rem;
  line-height: 1.4;
}
figure figcaption b { color: var(--accent); font-weight: 500; }

/* Deity/graha portrait */
figure.portrait img {
  width: 200px;
  height: 200px;
  object-fit: cover;
  border-radius: 50%;
  border: 3px solid var(--accent);
  box-shadow: 0 0 30px rgba(var(--accent-rgb), 0.300);
}
figure.portrait.small img { width: 120px; height: 120px; }

/* Grid of small images */
.grid-imgs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1.2rem;
  margin: 1.6rem 0;
}
.grid-imgs figure { margin: 0; }
.grid-imgs figcaption { font-size: 0.72rem; }

/* ============================================================
   Worked example boxes
   ============================================================ */
.workex {
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  margin: 1.6rem 0;
  overflow: hidden;
  background: linear-gradient(135deg, rgba(29, 27, 58, 0.5), rgba(34, 31, 64, 0.5));
}
.workex-head {
  background: rgba(var(--accent-rgb), 0.140);
  padding: 0.7rem 1.2rem;
  font-family: var(--sans);
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.workex-head b { font-weight: 600; color: #fff; }
.workex-body { padding: 1.2rem 1.4rem; }
.workex-body h4 { margin-top: 1.2rem; }
.workex-body h4:first-child { margin-top: 0; }
.workex details {
  margin-top: 1rem;
  border-top: 1px dashed var(--line);
  padding-top: 0.8rem;
}
.workex details summary {
  cursor: pointer;
  font-family: var(--sans);
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  user-select: none;
  list-style: none;
  padding: 0.3rem 0;
}
.workex details summary::-webkit-details-marker { display: none; }
.workex details summary::before {
  content: "▸ ";
  display: inline-block;
  transition: transform 0.2s;
}
.workex details[open] summary::before { content: "▾ "; }
.workex details[open] summary { margin-bottom: 0.6rem; }
.workex .result {
  margin-top: 0.8rem;
  padding: 0.8rem 1rem;
  background: rgba(95, 168, 107, 0.08);
  border-left: 3px solid var(--go);
  border-radius: 6px;
  color: var(--text);
}

/* ============================================================
   Two-column body
   ============================================================ */
.cols-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin: 1.4rem 0;
}
.cols-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1.2rem;
  margin: 1.4rem 0;
}
.cols-2 > *, .cols-3 > * { min-width: 0; }

/* ============================================================
   Reveal animations
   ============================================================ */
.reveal {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.7s, transform 0.7s;
}
.reveal.in { opacity: 1; transform: none; }

/* ============================================================
   Progress bar (reading)
   ============================================================ */
.progress {
  position: fixed;
  top: 0; left: 0;
  height: 3px;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  z-index: 100;
  transition: width 0.1s ease-out;
}

/* ============================================================
   Footer
   ============================================================ */
footer {
  text-align: center;
  padding: 8vh 5vw;
  color: var(--text-muted);
  border-top: 1px solid var(--line);
  margin-top: 6vh;
}
footer .om {
  font-family: var(--devanagari);
  font-size: 2.5rem;
  color: var(--accent);
  line-height: 1;
}
footer p {
  max-width: 720px;
  margin: 0.9rem auto;
  font-size: 0.93rem;
}
footer .small {
  font-family: var(--sans);
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-top: 2rem;
}

/* ============================================================
   Index of chapters (used in front matter)
   ============================================================ */
.chapter-list {
  list-style: none;
  padding: 0;
  margin: 1.5rem 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}
.chapter-list li a {
  display: flex;
  gap: 0.85rem;
  align-items: baseline;
  padding: 0.9rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: linear-gradient(135deg, rgba(29, 27, 58, 0.5), rgba(34, 31, 64, 0.5));
  border-bottom: 1px solid var(--line);
  text-decoration: none;
  transition: all 0.3s;
}
.chapter-list li a:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}
.chapter-list .cn {
  font-family: var(--serif-display);
  font-style: italic;
  color: var(--accent);
  font-size: 1.1rem;
  min-width: 2.5rem;
}
.chapter-list .ct {
  color: var(--text);
  font-family: var(--serif-display);
  font-size: 0.98rem;
  line-height: 1.3;
  flex: 1;
}
.chapter-list .cd {
  display: block;
  font-family: var(--sans);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

/* ============================================================
   Theme toggle (dark <-> parchment)
   ============================================================ */
.theme-toggle {
  position: fixed;
  top: 5rem;
  right: 1.2rem;
  z-index: 40;
  background: rgba(20, 19, 43, 0.8);
  border: 1px solid var(--line);
  border-radius: 999px;
  width: 42px;
  height: 42px;
  cursor: pointer;
  color: var(--text-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: all 0.3s;
}
.theme-toggle:hover { color: var(--accent); border-color: var(--accent); }
body.theme-paper {
  --bg: #f7f0e2;
  --bg-top: #ede4d0;
  --bg-bot: #ebe1c9;
  --text: #2a2440;
  --text-soft: #4a4260;
  --text-muted: #6a6280;
  --line: rgba(42, 36, 64, 0.12);
  --line-strong: rgba(42, 36, 64, 0.22);
}
body.theme-paper {
  background: linear-gradient(180deg, var(--bg-top), var(--bg) 45%, var(--bg-bot));
}
body.theme-paper .card,
body.theme-paper .workex,
body.theme-paper .callout {
  background: rgba(255, 252, 240, 0.7);
  color: var(--text);
  border-color: var(--line);
}
body.theme-paper .ribbon {
  background: linear-gradient(180deg, rgba(247, 240, 226, 0.95), rgba(247, 240, 226, 0.7));
  border-bottom-color: var(--line);
}
body.theme-paper table.data { background: rgba(42, 36, 64, 0.04); }
body.theme-paper aside.toc a { color: var(--text-soft); }
body.theme-paper aside.toc a:hover { background: rgba(42, 36, 64, 0.05); color: var(--text); }
body.theme-paper h2,
body.theme-paper h3 { color: var(--text); }
body.theme-paper .ch-num,
body.theme-paper .ch-sub,
body.theme-paper .eyebrow { color: var(--accent2); }
body.theme-paper .nebula { opacity: 0.25; }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 920px) {
  .shell { grid-template-columns: 1fr; padding: 0 5vw; }
  aside.toc {
    position: fixed;
    top: 0; left: 0;
    width: min(320px, 90vw);
    height: 100vh;
    max-height: 100vh;
    background: linear-gradient(180deg, var(--bg-top), var(--bg));
    z-index: 60;
    padding: 5rem 1.4rem 2rem;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    border-right: 1px solid var(--line);
  }
  aside.toc.open { transform: translateX(0); }
  .toc-toggle { display: block; }
  .toc-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 55;
  }
  .toc-overlay.open { display: block; }
}
@media (max-width: 720px) {
  .cols-2, .cols-3 { grid-template-columns: 1fr; }
  body { font-size: 16px; }
  header.hero { padding: 6vh 5vw 5vh; }
  .panel { padding: 1.1rem 1.2rem; }
  .theme-toggle { top: auto; bottom: 5rem; right: 1.2rem; }
}
@media (max-width: 420px) {
  .facts { gap: 1rem; }
  h1 { font-size: 2.1rem; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
  .reveal { opacity: 1; transform: none; }
}

/* Print */
@media print {
  .stars, .nebula, .ribbon, .toc-toggle, .theme-toggle, .progress { display: none; }
  body { background: white; color: black; }
  .shell { grid-template-columns: 1fr; }
  aside.toc { display: none; }
}

/* ============================================================
   Universal hover-glow system
   Every card, panel, table row, figure, button, chapter-list
   item, verse, workex gets a subtle accent glow on hover.
   ============================================================ */
.card, .panel, .callout, .workex, .verse,
figure .frame, figure.portrait img,
table.data tbody tr, table.data thead tr,
.chapter-list li a, .rtier, .toc-toggle, .theme-toggle,
.workex details summary {
  transition: box-shadow 0.35s ease, border-color 0.35s ease, transform 0.25s ease;
}

.card:hover {
  box-shadow: 0 0 0 1px rgba(224, 170, 50, 0.30), 0 14px 40px rgba(224, 170, 50, 0.10);
  border-color: rgba(224, 170, 50, 0.35);
}

.panel:hover {
  box-shadow: 0 0 0 1px rgba(224, 170, 50, 0.35), 0 12px 36px rgba(0,0,0,0.28);
  border-left-width: 5px;
}

.panel.dark:hover {
  box-shadow: 0 0 0 1px rgba(224, 170, 50, 0.35), 0 12px 36px rgba(224, 170, 50, 0.12);
}

.callout:hover {
  box-shadow: 0 0 0 1px rgba(224, 170, 50, 0.28), 0 8px 28px rgba(224, 170, 50, 0.08);
  border-left-width: 5px;
}
.callout.warn:hover { box-shadow: 0 0 0 1px rgba(217,122,58,0.30), 0 8px 28px rgba(217,122,58,0.08); }
.callout.tip:hover  { box-shadow: 0 0 0 1px rgba(95,168,107,0.30), 0 8px 28px rgba(95,168,107,0.08); }

.workex:hover {
  box-shadow: 0 0 0 1px rgba(224, 170, 50, 0.28), 0 10px 32px rgba(224, 170, 50, 0.09);
}

.verse:hover {
  box-shadow: 0 0 0 1px rgba(224, 170, 50, 0.22), 0 6px 22px rgba(224, 170, 50, 0.06);
  border-left-width: 4px;
}

figure .frame:hover {
  box-shadow: 0 0 0 1px rgba(224, 170, 50, 0.25), 0 10px 32px rgba(224, 170, 50, 0.10);
}

figure.portrait img:hover {
  box-shadow: 0 0 42px rgba(224, 170, 50, 0.40);
  transform: scale(1.05);
}

/* Table row glow */
table.data tbody tr:hover {
  background: rgba(224, 170, 50, 0.07);
  box-shadow: inset 0 0 0 1px rgba(224, 170, 50, 0.14);
}

/* TOC entries */
.chapter-list li a:hover {
  box-shadow: 0 0 0 1px rgba(224, 170, 50, 0.35), 0 10px 30px rgba(224, 170, 50, 0.12);
}

/* Ribbon pills */
.rtier:hover {
  box-shadow: 0 0 14px rgba(224, 170, 50, 0.25);
}

/* Theme / TOC buttons */
.toc-toggle:hover, .theme-toggle:hover {
  box-shadow: 0 0 18px rgba(224, 170, 50, 0.35);
}

/* Worked-example collapsible summary */
.workex details summary:hover {
  color: #ffe9a0;
  text-shadow: 0 0 10px rgba(224, 170, 50, 0.50);
}

/* Reduce glow for paper theme */
body.theme-paper .card:hover,
body.theme-paper .panel:hover,
body.theme-paper .callout:hover,
body.theme-paper .workex:hover,
body.theme-paper .verse:hover {
  box-shadow: 0 0 0 1px rgba(180, 130, 30, 0.25), 0 10px 30px rgba(0,0,0,0.06);
}

/* ============================================================
   Lightbox — zoom/pan/rotate overlay
   ============================================================ */
#lightbox-root {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
}
#lightbox-root.open { display: block; }

.lb-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 9, 24, 0.94);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.lb-stage {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  cursor: grab;
}

.lb-img-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 0;
}

.lb-img-wrap img, .lb-img-wrap svg {
  user-select: none;
  pointer-events: none;
}

.lb-close {
  position: absolute;
  top: 1rem;
  right: 1.2rem;
  z-index: 210;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  color: #fff;
  font-size: 1.6rem;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.25s;
  line-height: 1;
  padding: 0;
}
.lb-close:hover {
  background: rgba(224, 170, 50, 0.28);
  border-color: #e0aa32;
  box-shadow: 0 0 22px rgba(224, 170, 50, 0.35);
}

.lb-controls {
  position: absolute;
  bottom: 1.2rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 210;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(20,19,43,0.85);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.5rem 0.8rem;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.lb-btn {
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--line);
  color: var(--text-soft);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.1rem;
  font-family: var(--sans);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.25s;
  padding: 0;
}
.lb-btn:hover {
  background: rgba(224, 170, 50, 0.22);
  border-color: #e0aa32;
  color: #ffe9a0;
  box-shadow: 0 0 14px rgba(224, 170, 50, 0.25);
}

.lb-zoom-label {
  font-family: var(--sans);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  min-width: 3rem;
  text-align: center;
}

.lb-spacer {
  width: 0.5rem;
}

@media (max-width: 720px) {
  .lb-close { top: 0.6rem; right: 0.6rem; width: 38px; height: 38px; font-size: 1.4rem; }
  .lb-controls { bottom: 0.8rem; padding: 0.35rem 0.6rem; gap: 0.25rem; }
  .lb-btn { width: 32px; height: 32px; font-size: 1rem; }
}