/* Granthālaya — Digital Library of Hindu Scriptures */
:root {
  --fs: 1;
  --saffron: #e07a1f; --saffron-soft: #f6c48b; --maroon: #7a1f2b; --maroon-deep: #4e0f19;
  --gold: #c9a227; --gold-soft: #e8d39a;
  --bg: #f7f1e5; --bg-elev: #fffaf0; --paper: #fffdf7; --paper-edge: #eadcc0;
  --ink: #2b1d14; --ink-soft: #5b4636; --muted: #8a7563; --line: #e3d3b4; --line-strong: #cdb58a;
  --accent: var(--maroon); --accent-2: var(--saffron); --hl: #fde7c2; --hl-strong: #f9cf86;
  --shadow: 0 1px 2px rgba(60,30,10,.06), 0 8px 28px rgba(80,40,10,.10);
  --shadow-lg: 0 2px 6px rgba(60,30,10,.08), 0 24px 60px rgba(80,40,10,.18);
  --radius: 14px;
  --f-display: "Cormorant Garamond", "EB Garamond", Georgia, serif;
  --f-body: "EB Garamond", Georgia, "Times New Roman", serif;
  --f-deva: "Noto Serif Devanagari", "Sanskrit Text", "Adobe Devanagari", serif;
  --f-ui: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --header-h: 64px; --palette-w: 330px;
  color-scheme: light;
}
[data-theme="sepia"] {
  --bg: #efe2c6; --bg-elev: #f6ebd3; --paper: #f8eed8; --paper-edge: #dcc79d;
  --ink: #3b2a19; --ink-soft: #5e4630; --muted: #8b7356; --line: #dac59b; --line-strong: #c2a36b;
  --hl: #f3d9a4; --hl-strong: #ebc479;
}
[data-theme="dark"] {
  --bg: #14100d; --bg-elev: #1d1712; --paper: #1f1914; --paper-edge: #3a2e22;
  --ink: #eadfcd; --ink-soft: #cdbda4; --muted: #9b8a73; --line: #3a2f24; --line-strong: #5a4732;
  --accent: #e6a25a; --accent-2: #f0b46c; --gold: #d8b45a; --maroon: #d07a6a;
  --hl: #3b2b17; --hl-strong: #5a3f1c;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 10px 30px rgba(0,0,0,.35);
  --shadow-lg: 0 2px 6px rgba(0,0,0,.5), 0 24px 60px rgba(0,0,0,.5);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { scroll-padding-top: calc(var(--header-h) + 96px); }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--f-body); font-size: 18px; line-height: 1.6;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; min-height: 100vh; display: flex; flex-direction: column; }
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; }
button { font: inherit; color: inherit; }
.skip { position: absolute; left: -999px; } .skip:focus { left: 12px; top: 12px; z-index: 99; background: var(--paper); padding: 8px; }
.deva { font-family: var(--f-deva); }
:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; border-radius: 6px; }

/* ---------- header ---------- */
.site-header { position: sticky; top: 0; z-index: 40; height: var(--header-h);
  background: linear-gradient(180deg, var(--maroon-deep), #5e1420); color: #f8ead2;
  border-bottom: 2px solid var(--gold); box-shadow: 0 4px 18px rgba(40,10,0,.25); }
[data-theme="dark"] .site-header { background: linear-gradient(180deg, #23140f, #1a0f0b); }
.header-inner { max-width: 1480px; margin: 0 auto; height: 100%; display: flex; align-items: center; gap: 22px; padding: 0 22px; }
.brand { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.brand-mark { width: 38px; height: 38px; border-radius: 50%; background: url(../assets/favicon.svg) center/cover; box-shadow: 0 0 0 2px rgba(232,193,90,.5); }
.brand-text { display: flex; flex-direction: column; line-height: 1.05; }
.brand-sa { font-family: var(--f-deva); font-size: 19px; color: #f3cf74; font-weight: 600; }
.brand-en { font-family: var(--f-display); font-size: 17px; letter-spacing: .08em; text-transform: uppercase; color: #f8ead2; }
.main-nav { display: flex; gap: 4px; }
.main-nav a { color: #f1dcc0; text-decoration: none; font-family: var(--f-ui); font-size: 14px; padding: 8px 12px; border-radius: 999px; }
.main-nav a:hover { background: rgba(255,255,255,.08); }
.main-nav a.active { background: rgba(243,207,116,.16); color: #ffe7a8; }
.header-search { margin-left: auto; }
.header-search input { width: 260px; font-family: var(--f-ui); font-size: 14px; color: #fff; background: rgba(255,255,255,.1);
  border: 1px solid rgba(243,207,116,.35); border-radius: 999px; padding: 8px 14px 8px 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%23f3cf74' stroke-width='2'%3E%3Ccircle cx='7' cy='7' r='5'/%3E%3Cpath d='M11 11l4 4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: 12px center; }
.header-search input::placeholder { color: #d9c3a3; }
.header-tools { display: flex; gap: 6px; }
.icon-btn { width: 36px; height: 36px; border-radius: 50%; border: 1px solid rgba(243,207,116,.35); background: rgba(255,255,255,.06);
  color: #f3cf74; cursor: pointer; display: inline-grid; place-items: center; font-family: var(--f-ui); font-weight: 600; font-size: 15px; }
.icon-btn:hover { background: rgba(255,255,255,.14); }
.icon-btn svg { width: 18px; height: 18px; }

main { flex: 1; width: 100%; }
.loading { padding: 80px; text-align: center; color: var(--muted); font-family: var(--f-ui); }
.site-footer { text-align: center; color: var(--muted); font-family: var(--f-ui); font-size: 13px; padding: 26px 20px 34px; }
.ornament-line { height: 14px; max-width: 420px; margin: 0 auto 12px;
  background: radial-gradient(circle, var(--gold) 3px, transparent 4px) center/14px 14px no-repeat,
              linear-gradient(90deg, transparent, var(--line-strong) 20%, var(--line-strong) 80%, transparent) center/100% 1px no-repeat; }

/* ---------- library ---------- */
.hero { position: relative; overflow: hidden; padding: 70px 24px 60px; text-align: center;
  background: radial-gradient(1200px 400px at 50% -10%, rgba(224,122,31,.20), transparent 70%),
              linear-gradient(180deg, var(--bg-elev), var(--bg)); border-bottom: 1px solid var(--line); }
.hero-mandala { position: absolute; width: 720px; height: 720px; left: 50%; top: 50%; transform: translate(-50%,-50%); opacity: .10; pointer-events: none; color: var(--maroon); }
[data-theme="dark"] .hero-mandala { opacity: .14; color: var(--gold); }
.hero-sa { font-family: var(--f-deva); font-size: 22px; color: var(--accent-2); margin: 0 0 6px; letter-spacing: .02em; }
.hero h1 { font-family: var(--f-display); font-weight: 600; font-size: clamp(40px, 6vw, 68px); line-height: 1.02; margin: 0 0 14px; color: var(--accent); }
.hero p.lead { max-width: 660px; margin: 0 auto 26px; color: var(--ink-soft); font-size: 20px; }
.hero-stats { display: inline-flex; gap: 26px; flex-wrap: wrap; justify-content: center; font-family: var(--f-ui); font-size: 13px; color: var(--muted);
  border: 1px solid var(--line); background: color-mix(in srgb, var(--paper) 80%, transparent); padding: 10px 22px; border-radius: 999px; }
.hero-stats b { color: var(--accent); font-size: 24px; display: block; font-family: var(--f-display); font-variant-numeric: lining-nums; line-height: 1.1; }
.container { max-width: 1280px; margin: 0 auto; padding: 0 24px; }
.section-title { display: flex; align-items: baseline; gap: 14px; margin: 44px 0 18px; }
.section-title h2 { font-family: var(--f-display); font-weight: 600; font-size: 32px; margin: 0; color: var(--ink); }
.section-title .rule { flex: 1; height: 1px; background: linear-gradient(90deg, var(--line-strong), transparent); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin: -4px 0 18px; }
.chip { font-family: var(--f-ui); font-size: 13px; padding: 6px 14px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--paper); color: var(--ink-soft); cursor: pointer; }
.chip.active, .chip:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
[data-theme="dark"] .chip.active { color: #1a120c; }

.continue-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.continue-card { display: flex; gap: 14px; align-items: center; padding: 14px 16px; border-radius: var(--radius); background: var(--paper); border: 1px solid var(--line);
  text-decoration: none; color: inherit; box-shadow: var(--shadow); transition: transform .2s; }
.continue-card:hover { transform: translateY(-2px); }
.continue-card .mini-cover { width: 44px; height: 58px; border-radius: 6px; flex: none; }
.continue-card small { font-family: var(--f-ui); color: var(--muted); font-size: 12px; display: block; }
.continue-card strong { font-family: var(--f-display); font-size: 20px; display: block; line-height: 1.1; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 26px; }
.book-card { position: relative; display: flex; flex-direction: column; border-radius: 18px; overflow: hidden; background: var(--paper);
  border: 1px solid var(--line); box-shadow: var(--shadow); color: inherit; text-decoration: none; transition: transform .25s ease, box-shadow .25s ease; }
.book-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.cover { position: relative; height: 200px; display: grid; place-items: center; text-align: center; color: #fbe9c4; overflow: hidden;
  background: radial-gradient(circle at 50% 40%, rgba(255,255,255,.14), transparent 60%), var(--c, #7a1f2b); }
.cover::before { content: ""; position: absolute; inset: 10px; border: 1px solid rgba(243,207,116,.55); border-radius: 10px; }
.cover::after { content: ""; position: absolute; inset: 15px; border: 1px dashed rgba(243,207,116,.25); border-radius: 7px; }
.cover svg.mandala { position: absolute; width: 260px; height: 260px; opacity: .22; color: #f3cf74; }
.cover .cover-sa { position: relative; font-family: var(--f-deva); font-size: 25px; font-weight: 600; color: #ffe3a3; padding: 0 26px; line-height: 1.35; text-shadow: 0 2px 10px rgba(0,0,0,.35); }
.cover .cover-cat { position: absolute; top: 22px; left: 0; right: 0; font-family: var(--f-ui); font-size: 10.5px; letter-spacing: .18em; text-transform: uppercase; color: rgba(255,230,180,.85); }
.book-body { padding: 18px 20px 20px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.book-body h3 { font-family: var(--f-display); font-size: 26px; font-weight: 600; margin: 0; line-height: 1.1; color: var(--ink); }
.book-body .sub { font-size: 15.5px; color: var(--ink-soft); margin: 0; line-height: 1.4; }
.meta-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; padding-top: 10px; }
.tag { font-family: var(--f-ui); font-size: 11px; padding: 3px 8px; border-radius: 6px; background: color-mix(in srgb, var(--accent-2) 14%, transparent); color: var(--ink-soft); border: 1px solid color-mix(in srgb, var(--accent-2) 30%, transparent); }
.stat-line { font-family: var(--f-ui); font-size: 12.5px; color: var(--muted); }
.progress { height: 4px; border-radius: 4px; background: var(--line); overflow: hidden; margin-top: 6px; }
.progress span { display: block; height: 100%; background: linear-gradient(90deg, var(--saffron), var(--gold)); }
.book-card.soon { opacity: .78; cursor: default; }
.book-card.soon:hover { transform: none; box-shadow: var(--shadow); }
.book-card.soon .cover { filter: grayscale(.55) brightness(.92); }
.ribbon { position: absolute; top: 16px; right: -34px; transform: rotate(38deg); background: var(--gold); color: #3b2405; font-family: var(--f-ui);
  font-size: 10.5px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; padding: 4px 40px; z-index: 2; }
.soon-reason { font-size: 14.5px; color: var(--muted); font-style: italic; }

.upload-card { border: 2px dashed var(--line-strong); background: color-mix(in srgb, var(--paper) 70%, transparent); box-shadow: none; cursor: pointer; text-align: left; padding: 0; font: inherit; color: inherit; }
.upload-card:hover { border-color: var(--accent-2); }
.upload-inner { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 10px; padding: 34px 24px; height: 100%; min-height: 330px; }
.upload-inner h3 { font-family: var(--f-display); font-size: 28px; font-weight: 600; margin: 0; color: var(--accent); }
.upload-icon { width: 74px; height: 74px; border-radius: 50%; display: grid; place-items: center; font-family: var(--f-display); font-size: 52px; line-height: 1; color: #fff;
  background: radial-gradient(circle at 35% 30%, var(--saffron), var(--maroon)); box-shadow: 0 0 0 6px color-mix(in srgb, var(--gold) 30%, transparent), var(--shadow); }
.sample-banner { max-width: 860px; margin: 0 auto 14px; text-align: center; font-family: var(--f-ui); font-size: 13px; font-weight: 600; letter-spacing: .06em; color: #5a3a05;
  background: repeating-linear-gradient(135deg, #f8dd9a, #f8dd9a 12px, #f3d283 12px, #f3d283 24px); border: 1px solid #d9b25a; border-radius: 10px; padding: 8px 14px; }
.book-page .sample-banner { margin-top: -20px; margin-bottom: 26px; }

/* ---------- generic page ---------- */
.page-wrap { max-width: 980px; margin: 0 auto; padding: 34px 24px 60px; }
.page-wrap h1 { font-family: var(--f-display); font-size: 46px; font-weight: 600; margin: 0 0 8px; color: var(--accent); line-height: 1.05; }
.paper { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 26px 30px; }
.btn { display: inline-flex; align-items: center; gap: 8px; font-family: var(--f-ui); font-size: 14px; font-weight: 500; padding: 9px 16px; border-radius: 10px;
  border: 1px solid var(--line-strong); background: var(--paper); color: var(--ink); cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
[data-theme="dark"] .btn.primary { color: #1a120c; }
.btn.primary:hover { filter: brightness(1.08); color: #fff; }
.btn.small { padding: 5px 10px; font-size: 12.5px; border-radius: 8px; }
.btn svg { width: 16px; height: 16px; }
.muted { color: var(--muted); }

/* book overview */
.book-head { display: grid; grid-template-columns: 220px 1fr; gap: 30px; align-items: start; margin-bottom: 28px; }
.book-head .cover { height: 290px; border-radius: 14px; box-shadow: var(--shadow-lg); }
.book-head .actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.toc-part { border-top: 1px solid var(--line); }
.toc-part summary { cursor: pointer; padding: 14px 4px; display: flex; justify-content: space-between; align-items: baseline; gap: 12px; list-style: none; }
.toc-part summary::-webkit-details-marker { display: none; }
.toc-part summary h3 { margin: 0; font-family: var(--f-display); font-size: 24px; font-weight: 600; }
.toc-part summary .deva { color: var(--muted); font-size: 16px; margin-left: 10px; }
.toc-chapters { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 6px 18px; padding: 0 4px 18px; }
.toc-chapters a { text-decoration: none; color: var(--ink); padding: 6px 8px; border-radius: 8px; display: flex; gap: 10px; font-size: 16.5px; line-height: 1.3; }
.toc-chapters a:hover { background: var(--hl); }
.toc-chapters a .num { font-family: var(--f-ui); font-size: 12px; color: var(--muted); min-width: 26px; padding-top: 3px; }
.toc-chapters a small { display: block; color: var(--muted); font-size: 13.5px; }
.sources-list { padding-left: 18px; } .sources-list li { margin-bottom: 8px; }
.sources-table { width: 100%; border-collapse: collapse; font-size: 16px; }
.sources-table th, .sources-table td { text-align: left; vertical-align: top; padding: 12px 10px; border-bottom: 1px solid var(--line); }
.sources-table th { font-family: var(--f-ui); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }

/* ---------- reader ---------- */
.reader { display: grid; grid-template-columns: minmax(0, 1fr) var(--palette-w); gap: 34px; max-width: 1440px; margin: 0 auto; padding: 22px 28px 60px; }
.reader.palette-hidden { grid-template-columns: minmax(0,1fr) 0; gap: 0; }
.reader.palette-hidden .palette { display: none; }
.reader-main { min-width: 0; }
.toolbar { position: sticky; top: calc(var(--header-h) + 10px); z-index: 20; display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  max-width: 860px; margin: 0 auto 18px; padding: 8px 10px; border-radius: 14px; font-family: var(--f-ui); font-size: 13px;
  background: color-mix(in srgb, var(--bg-elev) 88%, transparent); backdrop-filter: blur(10px); border: 1px solid var(--line); box-shadow: var(--shadow); }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 10px; overflow: hidden; }
.seg button { border: 0; background: transparent; padding: 6px 11px; cursor: pointer; font-size: 13px; color: var(--ink-soft); display: inline-flex; gap: 6px; align-items: center; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--accent); color: #fff; }
[data-theme="dark"] .seg button.on { color: #1a120c; }
.seg button svg { width: 15px; height: 15px; }
.layer-toggles { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.layer-toggles label { display: inline-flex; align-items: center; gap: 4px; padding: 4px 7px; font-size: 12.5px; border-radius: 8px; border: 1px solid var(--line); cursor: pointer; color: var(--ink-soft); user-select: none; }
.layer-toggles input { accent-color: var(--accent); margin: 0; }
.layer-toggles label.off { opacity: .55; }
.toolbar .spacer { flex: 1; }
.tb-btn { border: 1px solid var(--line); background: transparent; border-radius: 8px; padding: 5px 9px; cursor: pointer; color: var(--ink-soft); display: inline-flex; align-items: center; gap: 5px; font-size: 13px; }
.tb-btn:hover { color: var(--accent); border-color: var(--accent); }
.tb-btn svg { width: 15px; height: 15px; }

.crumbs { max-width: 860px; margin: 0 auto 10px; font-family: var(--f-ui); font-size: 13px; color: var(--muted); }
.crumbs a { color: var(--muted); text-decoration: none; } .crumbs a:hover { color: var(--accent); }

/* ebook page */
.book-page { max-width: 860px; margin: 0 auto; background: var(--paper); border: 1px solid var(--paper-edge); border-radius: 6px;
  box-shadow: var(--shadow-lg), inset 0 0 80px rgba(160,110,40,.06); padding: 64px clamp(22px, 7%, 84px) 56px; position: relative; }
.book-page::before { content: ""; position: absolute; inset: 14px; border: 1px solid color-mix(in srgb, var(--gold) 40%, transparent); border-radius: 3px; pointer-events: none; }
.running-head { position: absolute; top: 26px; left: 0; right: 0; text-align: center; font-family: var(--f-ui); font-size: 10.5px; letter-spacing: .22em; text-transform: uppercase; color: var(--muted); }
.ch-open { text-align: center; margin-bottom: 36px; }
.ch-open .ch-label { font-family: var(--f-ui); font-size: 12px; letter-spacing: .3em; text-transform: uppercase; color: var(--accent-2); }
.ch-open .ch-num { font-family: var(--f-display); font-size: 74px; line-height: 1; color: var(--accent); margin: 6px 0 2px; font-weight: 600; }
.ch-open h1 { font-family: var(--f-display); font-weight: 600; font-size: calc(36px * var(--fs)); margin: 4px 0; line-height: 1.15; color: var(--ink); }
.ch-open .ch-sa { font-family: var(--f-deva); font-size: calc(22px * var(--fs)); color: var(--ink-soft); }
.ch-open .ch-sub { font-style: italic; color: var(--muted); font-size: calc(18px * var(--fs)); margin-top: 4px; }
.ch-open .ch-meta { font-size: 15px; color: var(--muted); margin-top: 10px; }
.fleuron { display: block; margin: 22px auto; width: 120px; height: 18px; color: var(--gold); }
.summary { font-size: calc(17.5px * var(--fs)); color: var(--ink-soft); border-left: 3px solid var(--gold-soft); padding: 4px 0 4px 18px; margin: 0 0 34px; }
.summary summary { cursor: pointer; font-family: var(--f-ui); font-size: 12.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.note-box { font-family: var(--f-ui); font-size: 13px; color: var(--muted); background: color-mix(in srgb, var(--gold) 10%, transparent); border: 1px solid color-mix(in srgb, var(--gold) 35%, transparent); border-radius: 10px; padding: 10px 14px; margin: 0 0 26px; }

.verse { position: relative; padding: 16px 18px 16px 18px; margin: 0 -18px 6px; border-radius: 10px; transition: background .6s; }
.verse:hover { background: color-mix(in srgb, var(--hl) 45%, transparent); }
.verse.current { background: color-mix(in srgb, var(--hl) 55%, transparent); }
.verse.flash { animation: flash 2.2s ease; }
@keyframes flash { 0%, 30% { background: var(--hl-strong); box-shadow: 0 0 0 2px var(--gold); } 100% { background: transparent; box-shadow: none; } }
.v-num { display: inline-block; font-family: var(--f-ui); font-size: 11.5px; font-weight: 600; color: var(--accent); letter-spacing: .04em;
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); border-radius: 999px; padding: 1px 9px; margin-bottom: 8px; text-decoration: none; }
.v-type { font-family: var(--f-ui); font-size: 11px; color: var(--muted); margin-left: 8px; }
.v-sp { font-family: var(--f-deva); color: var(--accent-2); font-size: calc(16px * var(--fs)); margin-bottom: 2px; }
.v-sa { font-family: var(--f-deva); font-size: calc(21px * var(--fs)); line-height: 1.85; color: var(--ink); white-space: pre-line; font-weight: 500; }
.v-tr { font-style: italic; font-size: calc(17.5px * var(--fs)); color: var(--ink-soft); white-space: pre-line; margin-top: 6px; line-height: 1.55; }
.v-en { font-size: calc(19px * var(--fs)); margin-top: 10px; line-height: 1.65; white-space: pre-line; }
.v-head { font-family: var(--f-display); font-size: calc(24px * var(--fs)); margin: 4px 0 6px; }
.v-img { margin: 14px 0; text-align: center; } .v-img img { max-width: 100%; height: auto; border-radius: 8px; box-shadow: var(--shadow); }
.v-wm { font-size: calc(15.5px * var(--fs)); color: var(--ink-soft); margin-top: 8px; line-height: 1.6; }
.v-wm i { color: var(--accent); font-weight: 500; }
.v-notes { margin-top: 10px; font-size: calc(16px * var(--fs)); color: var(--ink-soft); border-left: 2px solid var(--line-strong); padding-left: 14px; }
.v-notes p { margin: .5em 0; }
.v-notes .who { font-family: var(--f-ui); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.v-actions { position: absolute; top: 12px; right: 10px; display: flex; gap: 2px; opacity: 0; transition: opacity .2s; }
.verse:hover .v-actions, .verse.current .v-actions, .verse:focus-within .v-actions { opacity: 1; }
.v-actions button { border: 0; background: transparent; color: var(--muted); cursor: pointer; width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; }
.v-actions button:hover { background: var(--bg-elev); color: var(--accent); }
.v-actions button.on { color: var(--saffron); }
.v-actions svg { width: 16px; height: 16px; }
.has-note-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--saffron); margin-left: 6px; vertical-align: middle; }
.user-note { margin-top: 8px; font-family: var(--f-ui); font-size: 13.5px; background: color-mix(in srgb, var(--saffron) 10%, transparent); border-left: 3px solid var(--saffron); padding: 6px 10px; border-radius: 6px; white-space: pre-line; }
.ebook-flow .verse + .verse::before { content: ""; position: absolute; top: -3px; left: 30%; right: 30%; height: 1px; background: linear-gradient(90deg, transparent, var(--line), transparent); }
.hide-sa .v-sa, .hide-sa .v-sp, .hide-tr .v-tr, .hide-en .v-en, .hide-wm .v-wm, .hide-cm .v-notes, .hide-cm .cm-section { display: none !important; }
.en-block { margin-top: 30px; padding-top: 20px; border-top: 1px solid var(--line); }
.en-block h3 { font-family: var(--f-display); font-size: 24px; margin: 0 0 6px; }
.en-block ol { padding-left: 26px; } .en-block li { margin-bottom: 8px; white-space: pre-line; font-size: calc(18px * var(--fs)); }
.chapter-nav { max-width: 860px; margin: 26px auto 0; display: flex; justify-content: space-between; gap: 12px; }
.chapter-nav a { flex: 1; max-width: 48%; text-decoration: none; color: var(--ink); background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; box-shadow: var(--shadow); }
.chapter-nav a:hover { border-color: var(--accent); }
.chapter-nav a small { display: block; font-family: var(--f-ui); font-size: 11.5px; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; }
.chapter-nav a span { font-family: var(--f-display); font-size: 20px; font-weight: 600; }
.chapter-nav .next { text-align: right; margin-left: auto; }

/* imported-book blocks */
.v-ph { font-family: var(--f-ui); font-size: calc(13.5px * var(--fs)); color: var(--muted); white-space: pre-line; margin-top: 8px; line-height: 1.6; }
.v-lab { display: block; font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--accent-2); margin-bottom: 2px; }
.v-tn { font-family: var(--f-ui); font-size: 12.5px; color: var(--muted); margin: 6px 0; padding: 6px 10px; border-left: 2px solid var(--gold); background: color-mix(in srgb, var(--gold) 8%, transparent); border-radius: 4px; }
.cm-fold { margin: 6px 0; } .cm-fold > summary { cursor: pointer; list-style: none; padding: 4px 0; }
.cm-fold > summary::before { content: "▸ "; color: var(--accent-2); } .cm-fold[open] > summary::before { content: "▾ "; }
.cm-fold > summary::-webkit-details-marker { display: none; }
.prose, .cm-text { font-size: calc(18px * var(--fs)); line-height: 1.7; }
.prose p, .v-notes p, .cm-text p { margin: 0 0 .75em; }
.blk-h { font-family: var(--f-display); font-size: 1.12em; font-weight: 600; color: var(--accent); margin: 1.1em 0 .35em; line-height: 1.3; }
.blk-ul { margin: .2em 0 .9em; padding-left: 1.3em; } .blk-ul li { margin-bottom: .35em; }
.blk-ul li::marker { color: var(--gold); }
.blk-box { margin: 1em 0; padding: 14px 18px; border-radius: 12px; background: color-mix(in srgb, var(--saffron) 8%, var(--paper)); border: 1px solid color-mix(in srgb, var(--saffron) 30%, transparent); }
.blk-table { overflow-x: auto; margin: 1em 0; }
.blk-table table { border-collapse: collapse; width: 100%; font-size: .9em; }
.blk-table th, .blk-table td { border-bottom: 1px solid var(--line); padding: 7px 10px; text-align: left; vertical-align: top; }
.blk-table th { font-family: var(--f-ui); font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); background: var(--bg-elev); }
.v-img figcaption { font-family: var(--f-ui); font-size: 13px; color: var(--muted); margin-top: 8px; font-style: italic; }
.v-img img { background: #fff; padding: 8px; }
.fn-ref a { font-family: var(--f-ui); font-size: 11px; color: var(--accent-2); text-decoration: none; margin-left: 2px; }
.fn-list { font-family: var(--f-ui); font-size: 13px; color: var(--ink-soft); margin: 14px 0 0; padding-left: 22px; border-top: 1px solid var(--line); padding-top: 10px; }
.fn-list li { margin-bottom: 6px; } .fn-list li::marker { color: var(--accent-2); }
.pal-chlist { max-height: 260px; }
.pal-chlist button span:last-child { line-height: 1.3; }
.cm-text .blk-box { margin-top: 0; }

/* verse mode */
.verse-view { max-width: 860px; margin: 0 auto; }
.verse-card { background: var(--paper); border: 1px solid var(--paper-edge); border-radius: 8px; box-shadow: var(--shadow-lg); padding: 44px clamp(22px, 7%, 70px) 40px; position: relative; }
.verse-card h1 { font-family: var(--f-display); font-weight: 600; font-size: calc(34px * var(--fs)); text-align: center; color: var(--accent); margin: 0 0 4px; line-height: 1.15; }
.verse-card .vc-sub { text-align: center; font-family: var(--f-ui); font-size: 12.5px; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; margin-bottom: 26px; }
.verse-card .v-sa { text-align: center; font-size: calc(25px * var(--fs)); line-height: 1.9; color: var(--maroon); }
[data-theme="dark"] .verse-card .v-sa { color: #f0c98a; }
.verse-card .v-sp { text-align: center; }
.verse-card .v-tr { text-align: center; font-size: calc(19px * var(--fs)); margin-top: 16px; }
.verse-card .v-wm { margin-top: 26px; padding: 16px 18px; background: color-mix(in srgb, var(--hl) 50%, transparent); border-radius: 10px; font-size: calc(16.5px * var(--fs)); }
.vc-h { font-family: var(--f-display); font-size: 26px; font-weight: 600; margin: 30px 0 8px; color: var(--ink); display: flex; align-items: center; gap: 12px; }
.vc-h::after { content: ""; flex: 1; height: 1px; background: linear-gradient(90deg, var(--line-strong), transparent); }
.verse-card .v-en { font-size: calc(20px * var(--fs)); margin-top: 0; }
.verse-card .v-en .ref { font-weight: 600; color: var(--accent); }
.cm-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.cm-tabs button { font-family: var(--f-ui); font-size: 12.5px; border: 1px solid var(--line-strong); background: transparent; border-radius: 999px; padding: 5px 12px; cursor: pointer; color: var(--ink-soft); }
.cm-tabs button.on { background: var(--accent); border-color: var(--accent); color: #fff; }
[data-theme="dark"] .cm-tabs button.on { color: #1a120c; }
.cm-text { font-size: calc(17.5px * var(--fs)); line-height: 1.75; }
.cm-text.sa { font-family: var(--f-deva); font-size: calc(17px * var(--fs)); line-height: 1.95; }
.cm-text p { margin: 0 0 .8em; }
.vc-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; margin-top: 30px; }
.vc-nav { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: center; margin-top: 20px; }
.vc-nav a { text-decoration: none; }
.vc-nav .next { justify-self: end; }
.quick-jump { margin-top: 26px; text-align: center; font-family: var(--f-ui); font-size: 13px; color: var(--muted); }
.quick-jump select, .quick-jump input { font-family: var(--f-ui); font-size: 13px; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--line-strong); background: var(--paper); color: var(--ink); margin: 0 4px; }

/* palette */
.palette { position: sticky; top: calc(var(--header-h) + 10px); align-self: start; max-height: calc(100vh - var(--header-h) - 22px); display: flex; flex-direction: column;
  background: var(--bg-elev); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); font-family: var(--f-ui); font-size: 13px; overflow: hidden; }
.pal-head { padding: 14px 16px 10px; border-bottom: 1px solid var(--line); background: linear-gradient(180deg, color-mix(in srgb, var(--saffron) 9%, transparent), transparent); }
.pal-head .pal-title { font-family: var(--f-display); font-size: 21px; font-weight: 600; line-height: 1.1; color: var(--accent); }
.pal-head .pal-pos { color: var(--muted); font-size: 12px; margin-top: 2px; }
.pal-close { display: none; }
.pal-search { display: flex; gap: 6px; margin-top: 10px; }
.pal-search input { flex: 1; min-width: 0; font: inherit; padding: 7px 10px; border-radius: 9px; border: 1px solid var(--line-strong); background: var(--paper); color: var(--ink); }
.pal-body { overflow-y: auto; padding: 6px 14px 16px; overscroll-behavior: contain; }
.pal-sec { margin-top: 12px; }
.pal-sec h4 { margin: 0 0 7px; font-size: 10.5px; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); font-weight: 600; display: flex; justify-content: space-between; }
.pal-parts { display: flex; flex-direction: column; gap: 3px; max-height: 210px; overflow-y: auto; padding-right: 2px; }
.pal-parts button { text-align: left; border: 1px solid transparent; background: transparent; border-radius: 8px; padding: 6px 9px; cursor: pointer; color: var(--ink); display: flex; gap: 8px; align-items: baseline; }
.pal-parts button:hover { background: var(--hl); }
.pal-parts button.sel { border-color: var(--line-strong); background: var(--paper); }
.pal-parts button.cur { color: var(--accent); font-weight: 600; }
.pal-parts button .n { color: var(--muted); font-size: 11px; min-width: 18px; }
.pal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); gap: 4px; }
.pal-grid button { height: 32px; border-radius: 7px; border: 1px solid var(--line); background: var(--paper); cursor: pointer; font-size: 12px; color: var(--ink-soft); padding: 0; }
.pal-grid button:hover { border-color: var(--accent-2); color: var(--accent); }
.pal-grid button.sel { border-color: var(--accent-2); box-shadow: inset 0 0 0 1px var(--accent-2); }
.pal-grid button.cur { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
[data-theme="dark"] .pal-grid button.cur { color: #1a120c; }
.pal-grid button.bm { position: relative; } .pal-grid button.bm::after { content: ""; position: absolute; top: 3px; right: 3px; width: 5px; height: 5px; border-radius: 50%; background: var(--saffron); }
.pal-chtitle { font-family: var(--f-body); font-size: 15px; color: var(--ink); margin: 2px 0 8px; line-height: 1.3; }
.pal-results { margin-top: 10px; display: flex; flex-direction: column; gap: 4px; }
.pal-results a { display: block; text-decoration: none; color: var(--ink); padding: 7px 9px; border-radius: 8px; border: 1px solid var(--line); background: var(--paper); font-size: 12.5px; line-height: 1.4; }
.pal-results a b { color: var(--accent); font-weight: 600; margin-right: 4px; }
.pal-results a:hover { border-color: var(--accent-2); }
.palette-fab { display: none; }
.scrim { display: none; }

/* search & bookmarks */
.search-bar { display: flex; gap: 10px; flex-wrap: wrap; margin: 18px 0 8px; }
.search-bar input[type=search] { flex: 1; min-width: 240px; font: inherit; font-size: 19px; padding: 12px 16px; border-radius: 12px; border: 1px solid var(--line-strong); background: var(--paper); color: var(--ink); }
.search-bar select { font-family: var(--f-ui); font-size: 14px; padding: 0 12px; border-radius: 12px; border: 1px solid var(--line-strong); background: var(--paper); color: var(--ink); }
.search-status { font-family: var(--f-ui); font-size: 13px; color: var(--muted); margin: 10px 0 16px; min-height: 20px; }
.result { display: block; text-decoration: none; color: inherit; padding: 14px 18px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); margin-bottom: 10px; box-shadow: var(--shadow); }
.result:hover { border-color: var(--accent-2); }
.result .r-ref { font-family: var(--f-ui); font-size: 12px; color: var(--accent); font-weight: 600; letter-spacing: .04em; }
.result .r-text { margin-top: 4px; font-size: 17px; }
.result .r-text.deva { font-size: 18px; }
mark { background: var(--hl-strong); color: inherit; border-radius: 3px; padding: 0 2px; }
.bm-item { display: flex; gap: 16px; align-items: flex-start; padding: 14px 18px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); margin-bottom: 10px; }
.bm-item .grow { flex: 1; min-width: 0; }
.bm-item a.ref { font-family: var(--f-ui); font-size: 13px; font-weight: 600; text-decoration: none; }
.bm-item .snip { margin-top: 4px; color: var(--ink-soft); font-size: 16px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.empty { text-align: center; color: var(--muted); padding: 50px 20px; font-style: italic; }
.tabs-row { display: flex; gap: 8px; margin: 16px 0; }

/* dialog & toast */
.dialog { border: 1px solid var(--line); border-radius: 16px; background: var(--paper); color: var(--ink); padding: 0; width: min(560px, 92vw); box-shadow: var(--shadow-lg); }
.dialog::backdrop { background: rgba(20,10,5,.45); backdrop-filter: blur(2px); }
.dialog .d-head { padding: 16px 20px; border-bottom: 1px solid var(--line); font-family: var(--f-display); font-size: 24px; font-weight: 600; display: flex; justify-content: space-between; align-items: center; }
.dialog .d-body { padding: 18px 20px; }
.dialog .d-foot { padding: 12px 20px 18px; display: flex; justify-content: flex-end; gap: 8px; }
.dialog textarea { width: 100%; min-height: 150px; font: inherit; font-size: 17px; padding: 12px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--bg-elev); color: var(--ink); resize: vertical; }
.kbd-table { width: 100%; font-family: var(--f-ui); font-size: 13.5px; border-collapse: collapse; }
.kbd-table td { padding: 6px 4px; border-bottom: 1px solid var(--line); }
kbd { font-family: var(--f-ui); font-size: 12px; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 6px; padding: 1px 7px; background: var(--bg-elev); }
.toast { position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 30px); opacity: 0; pointer-events: none; z-index: 100;
  background: #2b1d14; color: #fbe9c4; font-family: var(--f-ui); font-size: 14px; padding: 10px 18px; border-radius: 999px; box-shadow: var(--shadow-lg); transition: all .3s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  :root { --palette-w: 290px; }
  .header-search input { width: 190px; }
}
@media (max-width: 920px) {
  .reader, .reader.palette-hidden { grid-template-columns: minmax(0,1fr); padding: 14px 12px 90px; gap: 0; }
  .reader .palette, .reader.palette-hidden .palette { display: flex; position: fixed; top: 0; right: 0; bottom: 0; width: min(360px, 88vw); max-height: none; z-index: 60;
    height: 100vh; height: 100dvh; border-radius: 16px 0 0 16px; transform: translateX(105%); transition: transform .3s ease; }
  .reader.drawer-open .palette { transform: none; }
  .reader.drawer-open .scrim { display: block; position: fixed; inset: 0; background: rgba(20,10,5,.45); z-index: 55; }
  .pal-close { display: inline-grid; position: absolute; top: 10px; right: 10px; width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--line); background: var(--paper); cursor: pointer; place-items: center; }
  .palette-fab { display: inline-flex; position: fixed; right: 16px; bottom: 18px; z-index: 50; align-items: center; gap: 8px; border: 0; border-radius: 999px; padding: 12px 18px;
    background: var(--accent); color: #fff; font-family: var(--f-ui); font-size: 14px; font-weight: 600; box-shadow: var(--shadow-lg); cursor: pointer; }
  [data-theme="dark"] .palette-fab { color: #1a120c; }
  .palette-fab svg { width: 18px; height: 18px; }
  .main-nav { display: none; }
  .header-search { margin-left: auto; }
  .book-head { grid-template-columns: 1fr; } .book-head .cover { height: 200px; }
}
@media (max-width: 640px) {
  body { font-size: 17px; }
  .header-inner { gap: 10px; padding: 0 12px; }
  .brand-en { font-size: 14px; } .brand-sa { font-size: 16px; }
  .header-search input { width: 130px; padding-left: 30px; }
  .toolbar { position: static; gap: 6px; }
  .book-page { padding: 48px 18px 36px; border-radius: 4px; }
  .book-page::before { inset: 8px; }
  .verse { margin: 0 -8px 6px; padding: 14px 8px; }
  .v-actions { opacity: 1; position: static; justify-content: flex-end; margin-top: 4px; }
  .verse-card { padding: 30px 18px; }
  .hero { padding: 44px 18px 40px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
  .chapter-nav a span { font-size: 16px; }
}

/* ---------- print ---------- */
@media print {
  :root { --fs: 1 !important; }
  html[data-theme] { --bg: #fff; --paper: #fff; --ink: #000; --ink-soft: #222; --muted: #555; --accent: #6a1420; --line: #ccc; }
  body { background: #fff; font-size: 12pt; }
  .site-header, .site-footer, .toolbar, .palette, .palette-fab, .chapter-nav, .v-actions, .vc-actions, .vc-nav, .quick-jump, .crumbs, .toast, .scrim, .cm-tabs { display: none !important; }
  .reader { display: block; padding: 0; }
  .book-page, .verse-card { box-shadow: none; border: 0; padding: 0; max-width: none; }
  .book-page::before, .running-head { display: none; }
  .verse { break-inside: avoid; margin: 0; padding: 8px 0; background: none !important; }
  .verse.current, .verse.flash { background: none !important; animation: none; box-shadow: none; }
  a { color: inherit; text-decoration: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

@media (max-width: 520px) {
  .header-search { min-width: 0; flex: 0 1 auto; }
  .header-search input { width: 104px; }
  .header-inner { gap: 8px; }
  .header-tools { gap: 6px; min-width: 0; }
  .brand-text small, .brand .en { font-size: 12px; }
  .site-header .inner, .header-inner { gap: 8px; }
  .v-actions + .btn, .vc-nav .btn { min-width: 0; }
  .vc-nav { gap: 8px; } .vc-nav .btn { padding-inline: 10px; font-size: 13px; max-width: 48%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

/* book-native chapter numbers in the palette */
.pal-grid button.cont { position: relative; line-height: 1; flex-direction: column; display: inline-flex; align-items: center; justify-content: center; gap: 1px; }
.pal-grid button .chip-cont { font-size: 8.5px; letter-spacing: .04em; text-transform: uppercase; opacity: .75; }
.pal-grid button.cont { border-style: dashed; }
.pal-grid button.wide { grid-column: span 3; font-size: 12px; }
.chip-word { font-size: 12px; }
.v-sa b, .v-sa i { font-weight: inherit; }

.nw { white-space: nowrap; }
.pal-sec[hidden] { display: none; }

/* named verses (e.g. "Caupāī 12 — title") */
.v-title { font-family: var(--f-ui); font-size: 12.5px; color: var(--muted); margin-left: 10px; font-style: italic; }
.vc-title { font-family: var(--f-display); font-size: 1.15em; font-style: italic; color: var(--muted); margin: -4px 0 14px; }
.ch-open .ch-orn { color: var(--accent); letter-spacing: .4em; margin-top: 8px; font-size: 15px; }
