/* ── Reset & base ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bar-h:      50px;
  --bg:         #fdf8f0;
  --bg-sidebar: #f5efe2;
  --bg-card:    #ffffff;
  --bar-bg:     #1e2d3d;
  --bar-fg:     #e8dcc8;
  --accent:     #62b2ba;
  --accent2:    #c0762a;
  --border:     #ddd3c0;
  --text:       #2c1d0e;
  --muted:      #7a6a55;
  --hover-bg:   #ecdfc8;
  --radius:     6px;
  --drawer-w:     min(340px, 90vw);
  --nav-drawer-w: min(160px, 85vw);

  /* sutra type badge colours */
  --badge-S:    #1a6b8a;
  --badge-P:    #6b3a8a;
  --badge-V:    #2e7d32;
  --badge-AD:   #b45309;
  --badge-AT:   #0f766e;
}

/* ── Colour themes ─────────────────────────────────────────────── */
[data-theme="slate"] {
  --bg: #f7f8fc; --bg-sidebar: #eef0f8; --bg-card: #ffffff;
  --bar-bg: #1e3a5f; --bar-fg: #e2eaf4;
  --accent: #3b82f6; --accent2: #f97316;
  --border: #c8d3e8; --text: #1e293b; --muted: #64748b; --hover-bg: #dde6f5;
  --badge-S: #1d4ed8; --badge-P: #7e22ce; --badge-V: #15803d;
  --badge-AD: #c2410c; --badge-AT: #0e7490;
}
[data-theme="forest"] {
  --bg: #f2f8f0; --bg-sidebar: #e4f0e0; --bg-card: #ffffff;
  --bar-bg: #1a3d2a; --bar-fg: #c8e8cc;
  --accent: #2d9c58; --accent2: #c89020;
  --border: #b8d8b0; --text: #1a2e1a; --muted: #4a7050; --hover-bg: #d0ecc8;
  --badge-S: #166534; --badge-P: #6b21a8; --badge-V: #14532d;
  --badge-AD: #92400e; --badge-AT: #065f46;
}
[data-theme="saffron"] {
  --bg: #fffbf0; --bg-sidebar: #fff4d8; --bg-card: #ffffff;
  --bar-bg: #7c2d12; --bar-fg: #fef3c7;
  --accent: #d97706; --accent2: #059669;
  --border: #fcd090; --text: #292524; --muted: #92400e; --hover-bg: #fde9b0;
  --badge-S: #b45309; --badge-P: #7e22ce; --badge-V: #15803d;
  --badge-AD: #9a3412; --badge-AT: #065f46;
}
[data-theme="night"] {
  --bg: #1e1e2e; --bg-sidebar: #181825; --bg-card: #313244;
  --bar-bg: #11111b; --bar-fg: #cdd6f4;
  --accent: #89b4fa; --accent2: #cba6f7;
  --border: #45475a; --text: #cdd6f4; --muted: #a6adc8; --hover-bg: #45475a;
  --badge-S: #89b4fa; --badge-P: #cba6f7; --badge-V: #a6e3a1;
  --badge-AD: #fab387; --badge-AT: #94e2d5;
}

html, body { height: 100%; overflow: hidden; }
body { font-family: 'Noto Sans Devanagari', 'Noto Sans', system-ui, sans-serif;
       background: var(--bg); color: var(--text); font-size: 15px; }

/* Sanskrit / Indic text — Vesper Libre where it counts */
.sutra-text, .detail-sutra-full, .detail-split,
.nav-label, .nav-book-btn, .nav-adhyaya-btn, .nav-pada-btn, .nav-section-btn,
.meta-label, .meta-value, .pc-word, .pc-gram,
.detail-anuvritta, .commentary-text, .gana-words,
.detail-sanskrit, .reader-sutra-text,
.about-title, .sri-text {
  font-family: 'Vesper Libre', 'Noto Sans Devanagari', serif;
}

/* ── App area ─────────────────────────────────────────────────── */
#app {
  height: 100vh;
  overflow-y: auto;
  padding: 0 10% 32px;
  padding-left: max(10%, 44px);
  padding-top: calc(var(--bar-h) + 20px);
}

/* ── Top navigation bar ───────────────────────────────────────── */
#bottom-bar {
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--bar-h);
  background: var(--bar-bg);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 10px; z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,.3);
}
.bar-group { display: flex; align-items: center; gap: 2px; }
.bar-center { gap: 4px; }

.bar-btn {
  min-width: 44px; height: 44px; padding: 0 10px;
  border: none; background: none; cursor: pointer;
  color: var(--bar-fg); font-size: 1.55em;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, color .15s;
  font-family: 'Noto Sans', system-ui, sans-serif;
}
.bar-btn:hover          { background: rgba(255,255,255,.12); }
.bar-btn.active         { background: var(--accent); color: #fff; }
.bar-btn:disabled       { opacity: .3; cursor: not-allowed; }
.bar-btn:disabled:hover { background: none; }

.bar-nav-btn { font-size: 1em; min-width: 38px; }

.bar-ref {
  min-width: 68px; text-align: center; cursor: pointer;
  font-size: .82em; letter-spacing: .06em;
  color: var(--bar-fg); padding: 5px 8px; border-radius: var(--radius);
  font-family: 'Noto Sans', monospace;
  transition: background .15s;
  user-select: none;
}
.bar-ref:hover { background: rgba(255,255,255,.1); }
.bar-ref.empty { color: #607080; cursor: default; }
.bar-ref.empty:hover { background: none; }

/* ── 32-pada matrix popup ──────────────────────────────────────── */
.pada-matrix {
  position: fixed;
  bottom: calc(var(--bar-h) + 6px);
  left: 8px;
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 28px rgba(0,0,0,.28);
  z-index: 600; padding: 0; overflow: hidden;
  display: none; flex-direction: column;
}
.pada-matrix.open { display: flex; }
.pm-row {
  display: flex; align-items: stretch;
  border-bottom: 1px solid var(--border);
}
.pm-row:last-child { border-bottom: none; }
.pm-header { background: var(--bg-card); }
.pm-th {
  padding: 7px 12px; text-align: center;
  font-size: .8em; font-weight: 600; color: var(--muted);
  font-family: 'Vesper Libre', serif;
  border-right: 1px solid var(--border);
  min-width: 72px;
}
.pm-th:last-child { border-right: none; }
.pm-th-corner {
  min-width: 130px; text-align: left; color: var(--muted);
}
.pm-td-label {
  min-width: 130px; padding: 7px 12px;
  font-size: .82em; color: var(--text);
  font-family: 'Vesper Libre', serif;
  border-right: 1px solid var(--border);
  display: flex; align-items: center;
}
.pm-cell {
  min-width: 72px; padding: 7px 4px;
  text-align: center; font-size: .9em; font-weight: 600;
  color: var(--text); font-family: 'Noto Sans', monospace;
  background: none; border: none;
  border-right: 1px solid var(--border);
  cursor: pointer; transition: background .12s, color .12s;
}
.pm-cell:last-child { border-right: none; }
.pm-cell:hover { background: var(--hover-bg); color: var(--accent); }
.pm-row:hover .pm-td-label { color: var(--accent); }

/* ── Gana matrix popup ─────────────────────────────────────────── */
.gana-matrix {
  position: fixed;
  bottom: calc(var(--bar-h) + 6px);
  left: 8px;
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 28px rgba(0,0,0,.28);
  z-index: 600; padding: 8px;
  display: none; flex-direction: column; gap: 6px;
}
.gana-matrix.open { display: flex; }
.gm-caption {
  text-align: center; font-size: .7em; color: var(--muted);
  font-family: 'Vesper Libre', serif; letter-spacing: .04em;
}
.gm-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 3px;
}
.gm-cell {
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  padding: 6px 10px; min-width: 96px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 4px; cursor: pointer;
  transition: background .12s, border-color .12s;
}
.gm-cell:hover { background: var(--hover-bg); border-color: var(--accent); }
.gm-num {
  font-size: .65em; color: var(--muted);
  font-family: 'Noto Sans', monospace; letter-spacing: .04em;
}
.gm-name {
  font-size: .85em; font-weight: 600; color: var(--text);
  font-family: 'Vesper Libre', serif;
}
.gm-cell:hover .gm-name { color: var(--accent); }
.gm-count {
  font-size: .65em; color: var(--muted);
  font-family: 'Noto Sans', sans-serif;
}

/* ── Icon bar (always-visible collapsed nav strip) ────────────── */
#icon-bar {
  position: fixed; left: 0; top: var(--bar-h);
  height: calc(100vh - var(--bar-h));
  width: 60px; z-index: 60;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; align-items: stretch;
  padding: 4px 0; gap: 0;
  overflow: hidden;
}
.icon-bar-btn {
  width: 100%; height: auto;
  border: none; background: none; cursor: pointer;
  border-radius: 0;
  display: flex; align-items: center; justify-content: flex-start;
  transition: background .12s;
  padding: 10px 0 10px 9px;   /* mirrors nav-book-btn: padding 10px 14px */
}
.icon-bar-btn:hover { background: #ecdfc8; }
.icon-bar-btn.active { background: #e8d8c0; }
.icon-bar-char {
  font-size: .92em; font-weight: 700; color: var(--text); line-height: 1;
  font-family: 'Vesper Libre', 'Noto Sans Devanagari', serif;
  pointer-events: none;
  letter-spacing: .01em;
}

/* ── Backdrop ─────────────────────────────────────────────────── */
.drawer-backdrop {
  position: fixed; left: 0; right: 0; bottom: 0; top: var(--bar-h);
  background: rgba(0,0,0,.45);
  z-index: 200;
  opacity: 0; pointer-events: none;
  transition: opacity .25s;
}
.drawer-backdrop.visible { opacity: 1; pointer-events: all; }

/* ── Drawers ──────────────────────────────────────────────────── */
.drawer {
  position: fixed; top: var(--bar-h);
  height: calc(100vh - var(--bar-h));
  width: var(--drawer-w);
  background: var(--bg-sidebar);
  z-index: 300;
  display: flex; flex-direction: column;
  box-shadow: 0 0 28px rgba(0,0,0,.28);
  transition: transform .26s cubic-bezier(.4,0,.2,1);
}
#drawer-nav { width: var(--nav-drawer-w); }

.drawer-left  { left: 0;  transform: translateX(-100%); }
.drawer-right { right: 0; transform: translateX(100%);  }
.drawer-left.open  { transform: translateX(0); }
.drawer-right.open { transform: translateX(0); }

/* ── Pinned nav sidebar ───────────────────────────────────────── */
body.nav-pinned #drawer-nav {
  transform: translateX(0);
  box-shadow: none;
  border-right: 1px solid var(--border);
  z-index: 60;                         /* same layer as icon-bar */
}
body.nav-pinned #drawer-backdrop { display: none !important; }
body.nav-pinned #icon-bar         { display: none; }
body.nav-pinned #app {
  padding-left: calc(var(--nav-drawer-w) + 10%);
}

.drawer-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0; background: var(--bg-sidebar);
}
.drawer-title {
  font-size: .7em; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: var(--muted);
  font-family: 'Noto Sans', system-ui, sans-serif;
}
.drawer-header-actions { display: flex; align-items: center; gap: 2px; flex-shrink: 0; }

.drawer-pin {
  background: none; border: none; cursor: pointer;
  color: var(--muted); font-size: 1em;
  padding: 4px 6px; border-radius: var(--radius);
  transition: color .12s, background .12s; flex-shrink: 0;
  line-height: 1;
}
.drawer-pin:hover  { color: var(--text); background: var(--border); }
.drawer-pin.pinned { color: var(--accent); }

.drawer-close {
  background: none; border: none; cursor: pointer;
  color: var(--muted); font-size: .88em;
  padding: 4px 8px; border-radius: var(--radius);
  transition: color .12s, background .12s; flex-shrink: 0;
}
.drawer-close:hover { color: var(--text); background: var(--border); }

/* Hide close button when nav is pinned (pin button serves as toggle) */
body.nav-pinned #drawer-nav .drawer-close { display: none; }

.drawer-body { flex: 1; overflow-y: auto; }

/* ── Search drawer ────────────────────────────────────────────── */
.drawer-search-header { gap: 6px; }
.drawer-search-wrap { flex: 1; position: relative; }
.drawer-search-wrap input {
  width: 100%; padding: 7px 30px 7px 10px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text);
  font-size: .95em; outline: none;
  font-family: 'Noto Sans Devanagari', 'Noto Sans', system-ui, sans-serif;
}
.drawer-search-wrap input:focus { border-color: var(--accent2); }
.search-clear {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: var(--muted); cursor: pointer;
  font-size: .82em; display: none; padding: 2px 4px;
}
.search-clear:hover { color: var(--text); }

/* ── Search scope pills ───────────────────────────────────────── */
.search-scope-row {
  display: flex; flex-direction: column; gap: 5px;
  padding: 7px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0; background: var(--bg-sidebar);
}
.scope-row { display: flex; gap: 6px; align-items: center; }
.scope-row-2 { justify-content: space-between; }
.scope-pills { display: flex; gap: 6px; }
.scope-pill {
  border: 1px solid var(--border); background: var(--bg-card);
  border-radius: 12px; padding: 3px 10px;
  font-size: .78em; cursor: pointer; color: var(--muted);
  font-family: 'Vesper Libre', 'Noto Sans Devanagari', serif;
  transition: background .12s, color .12s, border-color .12s;
  white-space: nowrap;
}
.scope-pill:hover  { background: var(--hover-bg); border-color: var(--accent2); color: var(--text); }
.scope-pill.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }
.scope-type-filter {
  border: 1px solid var(--border); background: var(--bg-card);
  border-radius: 12px; padding: 3px 8px;
  font-size: .78em; color: var(--muted); cursor: pointer;
  font-family: 'Vesper Libre', 'Noto Sans Devanagari', serif;
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23999'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 7px center;
  padding-right: 20px;
  transition: border-color .12s, color .12s;
}

/* ── Search results ───────────────────────────────────────────── */
.search-drawer-count {
  padding: 6px 14px;
  font-size: .75em; color: var(--muted);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.search-copy-md {
  font-size: .8em; padding: 2px 8px;
  border: 1px solid var(--border); border-radius: 10px;
  background: none; color: var(--muted); cursor: pointer;
  font-family: 'Noto Sans', system-ui, sans-serif;
  transition: color .12s, border-color .12s;
}
.search-copy-md:hover:not(:disabled) { color: var(--accent); border-color: var(--accent); }
.search-copy-md:disabled { opacity: .35; cursor: default; }
.search-group-header {
  padding: 7px 14px 5px;
  font-size: .72em; font-weight: 700; letter-spacing: .08em;
  color: var(--muted); text-transform: uppercase;
  background: var(--bg); border-bottom: 1px solid var(--border);
  font-family: 'Noto Sans', system-ui, sans-serif;
  display: flex; align-items: center; justify-content: space-between;
}
.search-group-more {
  font-weight: 400; letter-spacing: 0; text-transform: none; font-size: .95em;
}
.search-result-item {
  display: flex; align-items: baseline; gap: 10px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer; transition: background .12s;
}
.search-result-item:hover { background: var(--hover-bg); }
.sri-ref {
  font-size: .75em; color: var(--muted);
  min-width: 38px; flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}
.sri-text { flex: 1; font-size: .92em; color: var(--text); line-height: 1.4; }
.sri-text mark { background: none; color: var(--accent); font-weight: 700; }
.sri-source {
  font-size: .7em; color: var(--muted); flex-shrink: 0;
  border: 1px solid var(--border); border-radius: 10px;
  padding: 1px 7px; font-family: 'Noto Sans', system-ui, sans-serif;
}
.search-loading {
  padding: 14px; font-size: .85em; color: var(--muted); text-align: center;
}

/* ── Script inline dropdown ───────────────────────────────────── */
.script-dropdown { position: relative; }
.script-dropdown-btn {
  font-size: 1em !important;          /* script label fits at 1em */
  min-width: 76px !important;
  font-family: 'Noto Sans Devanagari', 'Noto Sans', system-ui, sans-serif !important;
  letter-spacing: 0 !important;
}
.script-dropdown-menu {
  position: absolute; top: calc(100% + 4px); right: 0;
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 6px 20px rgba(0,0,0,.22);
  min-width: 130px;
  z-index: 500;
  padding: 4px 0;
  opacity: 0; pointer-events: none;
  transform: translateY(-6px);
  transition: opacity .18s, transform .18s;
}
.script-dropdown.open .script-dropdown-menu {
  opacity: 1; pointer-events: all; transform: translateY(0);
}
.script-menu-item {
  display: block; width: 100%;
  border: none; background: none; cursor: pointer;
  padding: 9px 14px; text-align: left;
  font-size: .95em; color: var(--text);
  font-family: 'Noto Sans Devanagari', 'Noto Sans', system-ui, sans-serif;
  transition: background .12s;
  white-space: nowrap;
}
.script-menu-item:hover  { background: var(--hover-bg); }
.script-menu-item.active { color: var(--accent); font-weight: 700; background: var(--hover-bg); }

/* ── Theme picker ─────────────────────────────────────────────── */
.theme-picker { position: relative; }
.theme-picker-btn { font-size: 1.2em !important; min-width: 38px !important; }
.theme-picker-menu {
  position: absolute; top: 100%; right: 0;
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 6px 20px rgba(0,0,0,.22);
  z-index: 500; padding: 10px 12px;
  opacity: 0; pointer-events: none;
  transform: translateY(-6px);
  transition: opacity .18s, transform .18s;
  display: flex; gap: 8px; align-items: center;
}
.theme-picker.open .theme-picker-menu {
  opacity: 1; pointer-events: all; transform: translateY(0);
}
.theme-swatch {
  width: 28px; height: 28px; border-radius: 50%;
  border: 2px solid transparent; cursor: pointer;
  transition: transform .15s, border-color .15s;
  flex-shrink: 0;
}
.theme-swatch:hover   { transform: scale(1.18); }
.theme-swatch.active  { border-color: var(--text); }

/* ── About drawer ─────────────────────────────────────────────── */
.about-drawer-nav { padding: 6px 0; border-bottom: 1px solid var(--border); }
.about-drawer-nav-btn {
  width: 100%; text-align: left; border: none; background: none;
  padding: 10px 16px; cursor: pointer;
  font-size: .9em; color: var(--muted);
  transition: background .12s, color .12s;
  font-family: 'Noto Sans', system-ui, sans-serif;
}
.about-drawer-nav-btn:hover  { background: #ecdfc8; color: var(--text); }
.about-drawer-nav-btn.active { color: var(--accent); font-weight: 700; background: #ecdfc8; }
.about-drawer-content { padding: 16px; }

/* Nav drawer tree container */
#nav-tree { padding-bottom: 24px; }

/* ── Welcome panel ────────────────────────────────────────────── */
.panel-welcome {
  max-width: 600px; margin: 48px auto 0; text-align: center;
}
.welcome-logo {
  font-size: .75em; letter-spacing: .18em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 10px;
  font-family: 'Noto Sans', system-ui, sans-serif;
}
.welcome-title {
  font-size: 2.4em; font-weight: 700; color: var(--accent);
  letter-spacing: .03em; margin-bottom: 14px;
  font-family: 'Vesper Libre', 'Noto Sans Devanagari', serif;
}
.welcome-sub { color: var(--muted); line-height: 1.7; margin-bottom: 22px; }
.welcome-stats { font-size: .85em; color: var(--muted); margin-bottom: 20px; }
.welcome-scripts { font-size: .85em; color: var(--muted); }
.ws-label { margin-right: 8px; }
.script-pill {
  display: inline-block; padding: 2px 10px; margin: 2px;
  border: 1px solid var(--border); border-radius: 12px;
  font-size: .9em; cursor: pointer; background: var(--bg-card);
  transition: background .15s, border-color .15s;
}
.script-pill:hover { background: #ecdfc8; border-color: var(--accent); }

/* ── Welcome footer (privacy / terms links) ──────────────────── */
.welcome-footer {
  margin-top: 32px; font-size: .78em; color: var(--muted);
  font-family: 'Noto Sans', system-ui, sans-serif;
}
.welcome-footer a { color: var(--muted); text-decoration: underline; }
.welcome-footer a:hover { color: var(--text); }
.welcome-footer-sep { margin: 0 8px; }

/* ── Welcome hero (image + YouTube link) ─────────────────────── */
.welcome-hero {
  margin-top: 28px;
}
.welcome-yt-link {
  display: inline-block; position: relative;
  border-radius: 16px; overflow: hidden;
  box-shadow: 0 4px 18px rgba(0,0,0,.13);
  transition: transform .2s, box-shadow .2s;
  text-decoration: none;
}
.welcome-yt-link:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 28px rgba(0,0,0,.2);
}
.welcome-hero-img {
  display: block; width: 100%; max-width: 340px;
  border-radius: 16px;
}
.welcome-yt-badge {
  position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%);
  background: rgba(255,0,0,.88); color: #fff;
  font-size: .78em; font-weight: 700; letter-spacing: .04em;
  padding: 5px 14px; border-radius: 20px;
  white-space: nowrap;
  font-family: 'Noto Sans', system-ui, sans-serif;
}

/* ── Welcome intro video card ────────────────────────────────── */
.welcome-intro-video { margin-top: 20px; }
.welcome-intro-link {
  display: inline-flex; align-items: center; gap: 12px;
  text-decoration: none; color: var(--text);
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 12px; padding: 10px 16px 10px 10px;
  transition: transform .2s, box-shadow .2s;
  box-shadow: 0 2px 10px rgba(0,0,0,.08);
}
.welcome-intro-link:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,0,0,.14);
}
.welcome-intro-thumb {
  position: relative; flex-shrink: 0;
  border-radius: 8px; overflow: hidden;
}
.welcome-intro-thumb img {
  display: block; width: 120px; height: 68px;
  object-fit: cover; border-radius: 8px;
}
.welcome-intro-play {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.35);
  color: #fff; font-size: 1.4em;
}
.welcome-intro-label {
  font-size: .9em; font-weight: 600;
  font-family: 'Noto Sans', system-ui, sans-serif;
}

/* ── Sutra list (list panel) ──────────────────────────────────── */
.list-header {
  display: flex; align-items: baseline; gap: 10px;
  margin-bottom: 14px; padding-bottom: 10px;
  border-bottom: 2px solid var(--border);
}
.list-title { font-size: 1.1em; font-weight: 700; color: var(--accent);
  font-family: 'Vesper Libre', 'Noto Sans Devanagari', serif; }
.list-count  { font-size: .8em; color: var(--muted); }

/* ── Sutra card ───────────────────────────────────────────────── */
.sutra-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); margin-bottom: 10px;
  cursor: pointer; transition: box-shadow .15s, border-color .15s;
  overflow: hidden;
}
.sutra-card:hover { border-color: var(--accent2); box-shadow: 0 2px 8px rgba(139,69,19,.12); }
.sutra-card.open  { border-color: var(--accent);  box-shadow: 0 2px 12px rgba(139,69,19,.18); }

.sutra-row {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 14px;
}
.sutra-id {
  font-size: .78em; font-weight: 700; color: var(--muted);
  min-width: 42px; flex-shrink: 0; font-variant-numeric: tabular-nums;
}
.sutra-text { flex: 1; font-size: 1.1em; line-height: 1.4; color: var(--text); }
.sutra-badge {
  flex-shrink: 0; font-size: .72em; font-weight: 700;
  padding: 2px 10px; border-radius: 10px; color: #fff; letter-spacing: .02em;
}
.badge-S  { background: var(--badge-S);  }
.badge-P  { background: var(--badge-P);  }
.badge-V  { background: var(--badge-V);  }
.badge-AD { background: var(--badge-AD); }
.badge-AT { background: var(--badge-AT); }

/* Audio button */
.audio-btn {
  flex-shrink: 0; width: 26px; height: 26px; border-radius: 50%;
  border: 1.5px solid var(--border); background: var(--bg-card);
  color: var(--muted); font-size: .7em; line-height: 1;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background .12s, color .12s, border-color .12s;
}
.audio-btn:hover   { background: #ecdfc8; border-color: var(--accent2); color: var(--accent2); }
.audio-btn.playing { background: var(--accent); border-color: var(--accent); color: #fff; }
.audio-btn.loading { opacity: .6; cursor: wait; }

/* Sutra detail (expanded card) */
.sutra-detail {
  border-top: 1px solid var(--border);
  padding: 14px 16px 16px;
  background: #fdfaf4;
  display: none;
}
.sutra-card.open .sutra-detail { display: block; }

.detail-sutra-full {
  font-size: 1.5em; font-weight: 700; color: var(--accent);
  margin-bottom: 8px; letter-spacing: .02em; white-space: pre-line;
}
.detail-split {
  font-size: .9em; color: var(--muted); margin-bottom: 12px; font-style: italic;
}
.detail-section   { margin-bottom: 10px; }
.detail-label {
  font-size: .72em; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted); margin-bottom: 3px;
}
.detail-english  { font-size: .95em; color: var(--text); line-height: 1.6; }
.detail-sanskrit { font-size: 1em; color: #3a2a10; line-height: 1.7; }

/* ── Sutra meta block ─────────────────────────────────────────── */
.sutra-meta {
  margin: 10px 0 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  font-size: .85em;
}
.meta-row {
  display: flex; align-items: baseline; gap: 10px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
}
.meta-row:last-child { border-bottom: none; }
.meta-label {
  flex-shrink: 0; min-width: 190px;
  font-size: .78em; font-weight: 700; letter-spacing: .04em;
  color: var(--muted);
}
.meta-value { color: var(--text); line-height: 1.6; }
.pc-word { color: var(--accent); font-weight: 600; }
.pc-gram { color: var(--muted); font-size: .88em; }
.meta-empty { color: var(--muted); opacity: .4; }
.detail-anuvritta { font-size: .88em; }
.detail-anuvritta a { color: var(--accent); text-decoration: none; }
.detail-anuvritta a:hover { text-decoration: underline; }

/* ── Sutra detail tabs ────────────────────────────────────────── */
.detail-tabs {
  display: flex;
  margin: 14px -16px 0;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
}
.detail-tab {
  padding: 7px 16px;
  border: none; background: none; cursor: pointer;
  font-family: inherit; font-size: .82em; font-weight: 500;
  color: var(--muted); letter-spacing: .01em;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: color .12s, border-color .12s;
}
.detail-tab:hover  { color: var(--text); }
.detail-tab.active { color: var(--accent); font-weight: 700; border-bottom-color: var(--accent); }
.detail-tab-panels { padding: 14px 0 2px; min-height: 1.8em; }
.detail-tab-panel  { font-size: .93em; line-height: 1.75; color: var(--text); display: none; }
.detail-tab-panel.active { display: block; }
.detail-tab-panel.commentary-text { font-size: .9em; line-height: 2; color: #3a2a10; }
.no-data { color: var(--muted); font-size: .85em; font-style: italic; }

/* Inline sutra quote  <<text>> */
.sutra-quote { color: var(--accent); font-style: italic; }
/* Inline sutra link  [[7.2.1]] */
.sutra-link {
  color: var(--accent2); font-weight: 600; text-decoration: none;
  font-size: .85em; border-bottom: 1px dashed var(--accent2);
}
.sutra-link:hover { color: var(--accent); border-bottom-color: var(--accent); }

/* ── Reader panel ─────────────────────────────────────────────── */
.panel-reader { max-width: none; }
.reader-content { padding: 28px 0 60px; }

.reader-top-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.reader-ref {
  font-size: .85em; color: var(--muted);
  letter-spacing: .08em; font-variant-numeric: tabular-nums;
  font-family: 'Noto Sans', monospace;
}
.reader-top-right { display: flex; align-items: center; gap: 8px; }
.copy-link-btn {
  background: none; border: none; cursor: pointer;
  font-size: .85em; padding: 2px 4px; color: var(--muted);
  opacity: .55; transition: opacity .15s;
  line-height: 1;
}
.copy-link-btn:hover { opacity: 1; }
.reader-sutra-text {
  font-size: 2.1em; font-weight: 700; color: var(--accent);
  line-height: 1.4; letter-spacing: .02em;
  margin-bottom: 18px;
}
/* ── Commentary tab groups (stacked) ─────────────────────────── */
.tab-group { margin-top: 16px; }

/* Card-mode tab bars bleed to card edge */
.detail-tabs-card {
  margin-left: -16px; margin-right: -16px;
  padding-left: 16px;
}

/* Reader tab bars: flush left, no bleed */
#reader-content .detail-tabs { margin: 0; padding: 0; }

/* ── Notes tab (Phase 4) ──────────────────────────────────────── */
.notes-group { margin-top: 16px; border-top: 1px solid var(--border); }
.notes-tab-panel { padding: 10px 0 4px; }

.notes-signin-wrap { display: flex; flex-direction: column; gap: 10px; padding: 12px 0 8px; }
.notes-signin-msg  { font-size: .88em; color: var(--text); font-family: 'Noto Sans', system-ui, sans-serif; }
.notes-privacy     { font-size: .78em; color: var(--muted); font-family: 'Noto Sans', system-ui, sans-serif; }
.notes-signin-btn  {
  align-self: flex-start; padding: 7px 16px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg-card); color: var(--text);
  font-size: .85em; cursor: pointer;
  font-family: 'Noto Sans', system-ui, sans-serif;
}
.notes-signin-btn:hover { background: var(--hover-bg); }

.notes-header {
  display: flex; justify-content: space-between; align-items: center;
  padding-bottom: 6px; margin-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.notes-user        { font-size: .78em; color: var(--muted); font-family: 'Noto Sans', system-ui, sans-serif; }
.notes-signout-btn {
  font-size: .78em; color: var(--muted); background: none; border: none;
  cursor: pointer; text-decoration: underline;
  font-family: 'Noto Sans', system-ui, sans-serif;
}
.notes-textarea {
  width: 100%; min-height: 110px; padding: 8px 10px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg); color: var(--text);
  font-size: .9em; line-height: 1.65; resize: vertical;
  font-family: 'Noto Sans', system-ui, sans-serif;
}
.notes-textarea:focus { outline: none; border-color: var(--accent); }
.notes-save-btn {
  margin-top: 6px; padding: 5px 16px;
  border-radius: var(--radius); border: 1px solid var(--border);
  font-size: .82em; font-family: 'Noto Sans', system-ui, sans-serif;
  transition: background .15s, color .15s, border-color .15s;
  cursor: pointer;
}
.notes-save-btn:disabled {
  background: var(--bg); color: var(--muted);
  border-color: var(--border); cursor: default;
}
.notes-save-btn:not(:disabled) {
  background: var(--accent); color: #fff;
  border-color: var(--accent); cursor: pointer;
}
.notes-readonly {
  font-size: .9em; line-height: 1.75;
  color: var(--text); padding: 4px 0 8px;
}
.notes-empty {
  font-size: .85em; color: var(--muted);
  font-family: 'Noto Sans', system-ui, sans-serif;
  padding: 10px 0 4px; font-style: italic;
}
.notes-author-footer {
  display: flex; align-items: center; gap: 12px; margin-top: 6px;
}
.notes-publish-hint {
  font-size: .75em; color: var(--muted);
  font-family: 'Noto Sans', system-ui, sans-serif;
}
.notes-owner-signin {
  margin-left: auto;
  background: none; border: none; cursor: pointer;
  font-size: .85em; color: var(--muted);
  opacity: .4; padding: 2px 4px;
  transition: opacity .15s;
}
.notes-owner-signin:hover { opacity: .9; }

/* ── Section headers within flat lists ───────────────────────── */
.section-header {
  padding: 10px 0 4px; margin-top: 10px;
  font-size: .75em; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: var(--muted);
  border-bottom: 1px solid var(--border);
}

/* ── Commentary text ──────────────────────────────────────────── */
.commentary-text { font-size: .92em; line-height: 1.9; color: #3a2a10; }

/* ── Nav tree ─────────────────────────────────────────────────── */
.nav-book { border-bottom: 1px solid var(--border); }
.nav-book-btn {
  width: 100%; text-align: left; border: none; background: none;
  padding: 10px 14px; cursor: pointer;
  display: flex; align-items: center; justify-content: space-between;
  font-size: .92em; font-weight: 700; color: var(--text);
  transition: background .15s; letter-spacing: .01em;
}
.nav-book-btn:hover { background: #ecdfc8; }
.nav-book-btn.open  { color: var(--accent); background: #e8d8c0; }
.nav-book-btn .arrow { font-size: .7em; transition: transform .2s; color: var(--muted); }
.nav-book-btn.open .arrow { transform: rotate(90deg); }
.nav-book-leaf { cursor: pointer; }
.nav-book-leaf.active { color: var(--accent); background: #e8d8c0; }

.nav-sections { display: none; background: #f0e8d6; }
.nav-sections.open { display: block; }

.nav-adhyaya { border-top: 1px solid var(--border); }
.nav-adhyaya-btn {
  width: 100%; text-align: left; border: none; background: none;
  padding: 8px 14px 8px 20px; cursor: pointer;
  display: flex; align-items: center; justify-content: space-between;
  font-size: .84em; font-weight: 600; color: var(--text); transition: background .15s;
}
.nav-adhyaya-btn:hover { background: #ecdfc8; }
.nav-adhyaya-btn.open  { color: var(--accent); background: #ecdfc8; }
.nav-adhyaya-btn .arrow { font-size: .7em; transition: transform .2s; color: var(--muted); }
.nav-adhyaya-btn.open .arrow { transform: rotate(90deg); }

.nav-padas { display: none; }
.nav-padas.open { display: block; }
.nav-pada-btn {
  width: 100%; text-align: left; border: none;
  background: none; padding: 7px 14px 7px 32px;
  cursor: pointer; font-size: .82em; color: var(--muted);
  display: flex; align-items: center; justify-content: space-between;
  transition: background .12s;
}
.nav-pada-btn:hover  { background: #e5d8c0; color: var(--text); }
.nav-pada-btn.active { background: var(--accent); color: #fff; font-weight: 600; }
.nav-pada-count { font-size: .75em; opacity: .75; }

.nav-section-btn {
  width: 100%; text-align: left; border: none;
  background: none; padding: 7px 14px 7px 26px;
  cursor: pointer; font-size: .84em; color: var(--muted);
  display: flex; align-items: center; justify-content: space-between;
  transition: background .12s; border-top: 1px solid rgba(0,0,0,.06);
}
.nav-section-btn:hover  { background: #e5d8c0; color: var(--text); }
.nav-section-btn.active { background: var(--accent); color: #fff; font-weight: 600; }
.nav-loading { padding: 8px 26px; font-size: .82em; color: var(--muted); font-style: italic; }

/* ── Dhatu card ───────────────────────────────────────────────── */
.dhatu-text-wrap { flex: 1; display: flex; flex-direction: column; gap: 1px; }
.dhatu-artha { font-size: .78em; color: var(--muted); font-style: italic; }
.dhatu-strip {
  font-size: .85em; color: var(--muted); margin-bottom: 10px;
  font-family: 'Vesper Libre', 'Noto Sans Devanagari', serif;
}
.upasarga-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 6px; margin-top: 4px;
}
.upasarga-item {
  background: #fdfaf4; border: 1px solid var(--border);
  border-radius: var(--radius); padding: 5px 10px;
  display: flex; flex-direction: column; gap: 2px;
}
.upasarga-name    { font-size: .92em; color: var(--accent); font-weight: 600;
  font-family: 'Vesper Libre', 'Noto Sans Devanagari', serif; }
.upasarga-meaning { font-size: .78em; color: var(--muted); }

/* ── Gana words ───────────────────────────────────────────────── */
.gana-words { font-size: .92em; color: var(--text); line-height: 2; word-spacing: 2px; }

/* ── About panel (full-width main area) ───────────────────────── */
.about-panel-tabs {
  display: flex; gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 28px;
}
.about-panel-tab {
  padding: 9px 22px; border: none; background: none; cursor: pointer;
  font-size: .9em; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -2px;
  transition: color .12s, border-color .12s;
  font-family: 'Noto Sans', system-ui, sans-serif;
}
.about-panel-tab:hover  { color: var(--text); }
.about-panel-tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 700; }
.about-panel-content { max-width: 680px; }

.about-section { padding-bottom: 16px; }
.about-title {
  font-size: 1.5em; font-weight: 700; color: var(--accent);
  margin-bottom: 10px;
  font-family: 'Vesper Libre', 'Noto Sans Devanagari', serif;
}
.about-intro { color: var(--muted); line-height: 1.7; margin-bottom: 18px; font-size: .95em; }
.about-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 18px; margin-bottom: 12px;
}
.about-card-title {
  font-weight: 700; font-size: .82em; color: var(--accent2);
  letter-spacing: .04em; margin-bottom: 6px;
  text-transform: uppercase; font-family: 'Noto Sans', system-ui, sans-serif;
}
.about-card p { font-size: .92em; line-height: 1.75; color: var(--text); }
.about-card a { color: var(--accent); text-decoration: none; }
.about-card a:hover { text-decoration: underline; }
.about-email { font-weight: 600; }

/* Guru cards */
.about-guru-name {
  font-family: 'Vesper Libre', 'Noto Sans Devanagari', serif;
  font-size: 1.1em; font-weight: 700;
  color: var(--text); margin-bottom: 3px;
}
.about-guru-tradition {
  font-size: .78em; color: var(--muted);
  letter-spacing: .03em; margin-bottom: 10px;
  font-family: 'Noto Sans', system-ui, sans-serif;
}
.about-guru-links { margin-top: 10px; }
.about-guru-links a { font-size: .88em; color: var(--accent); text-decoration: none; }
.about-guru-links a:hover { text-decoration: underline; }

/* ── Theme preview section ──────────────────────────────────────────────────── */
.theme-preview-controls { display: flex; flex-direction: column; gap: 14px; }
.tp-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.tp-lbl { font-size: .78em; font-weight: 700; color: var(--muted); min-width: 48px; }
.tp-swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.tp-swatch {
  display: flex; flex-direction: row; align-items: center; gap: 7px;
  padding: 5px 14px 5px 10px; border-radius: 20px; cursor: pointer;
  transition: transform .12s, box-shadow .12s;
  height: 34px; box-sizing: border-box;
}
.tp-swatch:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,.18); }
.tp-swatch.active { box-shadow: 0 0 0 3px var(--accent); transform: translateY(-2px); }
.tp-swatch-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.tp-swatch-lbl { font-size: .82em; font-weight: 600; color: #333; white-space: nowrap; }
.tp-script-pills { display: flex; gap: 6px; flex-wrap: wrap; }
.tp-script-pill {
  padding: 4px 10px; border-radius: 20px; border: 1px solid var(--border);
  background: var(--card-bg); color: var(--fg); cursor: pointer;
  font-size: .82em; transition: background .12s, color .12s;
}
.tp-script-pill:hover { background: var(--hover-bg); }
.tp-script-pill.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.tp-preview-label {
  font-size: .78em; font-weight: 700; color: var(--muted);
  letter-spacing: .05em; margin: 16px 0 6px;
  text-transform: uppercase;
}
.tp-preview-card { pointer-events: none; }
.tp-preview-card .sutra-row { cursor: default; }

/* Resource list */
.about-resource-list {
  list-style: none; padding: 0; margin: 4px 0 0;
  display: flex; flex-direction: column; gap: 7px;
}
.about-resource-list li { font-size: .92em; line-height: 1.6; color: var(--text); }
.about-resource-list a { color: var(--accent); text-decoration: none; }
.about-resource-list a:hover { text-decoration: underline; }

/* ── Feedback form ────────────────────────────────────────────── */
.feedback-form { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.fb-input {
  width: 100%; padding: 8px 10px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg); color: var(--text);
  font-size: .92em; font-family: 'Noto Sans', system-ui, sans-serif;
  outline: none; transition: border-color .15s;
}
.fb-input:focus { border-color: var(--accent2); }
.fb-textarea { resize: vertical; min-height: 90px; }
.fb-submit {
  align-self: flex-start;
  padding: 8px 22px; border: none; border-radius: var(--radius);
  background: var(--accent); color: #fff;
  font-size: .92em; font-weight: 700; cursor: pointer;
  transition: background .15s;
}
.fb-submit:hover    { background: var(--accent2); }
.fb-submit:disabled { opacity: .5; cursor: not-allowed; }
.fb-status { font-size: .85em; line-height: 1.5; min-height: 1.2em; }
.fb-status.fb-ok    { color: #2e7d32; }
.fb-status.fb-error { color: #c0392b; }

/* ── Loading overlay ──────────────────────────────────────────── */
.loading-overlay {
  position: fixed; inset: 0; background: rgba(253,248,240,.92);
  display: flex; align-items: center; justify-content: center;
  z-index: 999; transition: opacity .3s;
}
.loading-overlay.hidden { opacity: 0; pointer-events: none; }
.loading-box { text-align: center; }
.loading-spinner {
  width: 36px; height: 36px; border-radius: 50%;
  border: 3px solid var(--border); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
  margin: 0 auto 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { color: var(--muted); font-size: .9em; }

/* ── Dhatu forms tables ───────────────────────────────────────── */
.dhatu-lakara-section {
  margin-bottom: 18px;
}
.dhatu-lakara-label {
  font-family: var(--font-dev);
  font-size: 1em;
  font-weight: 700;
  color: var(--bg-card);
  background: var(--accent);
  padding: 5px 10px;
  border-radius: var(--radius) var(--radius) 0 0;
  margin-bottom: 0;
}
.forms-split {
  display: flex;
  gap: 0;
  align-items: flex-start;
}
.forms-split .forms-table-wrap {
  flex: 1;
  min-width: 0;
}
.forms-divider {
  width: 1px;
  background: var(--border);
  align-self: stretch;
  margin: 0 8px;
  flex-shrink: 0;
}
.forms-table-wrap {
  margin-bottom: 10px;
}
.forms-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-dev);
  font-size: .88em;
  border: 1px solid var(--border);
  border-top: none;
}
.forms-pada-header {
  background: #e8dcc8;
  color: var(--accent);
  font-family: var(--font-dev);
  font-size: .82em;
  font-weight: 700;
  text-align: center;
  padding: 5px 8px;
  border-bottom: 1px solid var(--border);
}
.forms-vacana-hdr {
  font-family: var(--font-dev);
  font-size: .75em;
  color: var(--muted);
  text-align: center;
  padding: 4px 6px;
  background: #f5efe2;
  border-bottom: 1px solid var(--border);
  font-weight: 500;
}
.forms-table th:first-child { border-right: 1px solid var(--border); }
.forms-row-label {
  font-family: var(--font-dev);
  font-size: .75em;
  color: var(--muted);
  padding: 5px 8px;
  white-space: nowrap;
  vertical-align: middle;
  background: #f5efe2;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.forms-cell {
  padding: 5px 8px;
  text-align: center;
  vertical-align: middle;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  line-height: 1.4;
}
.forms-cell:last-child { border-right: none; }
.forms-table tbody tr:last-child .forms-cell,
.forms-table tbody tr:last-child .forms-row-label { border-bottom: none; }
.forms-table tbody tr:hover .forms-cell { background: #fdf0dc; }

/* ── Pratyaya reference panel ─────────────────────────────────── */
.panel-pratyaya {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 0 32px;
}
.pratyaya-page-title {
  font-family: var(--font-dev);
  font-size: 1.6em;
  font-weight: 700;
  color: var(--text);
  margin-bottom: .25em;
}
.pratyaya-ganas {
  font-family: var(--font-dev);
  font-size: .85em;
  color: var(--muted);
  margin-bottom: 1.25em;
  letter-spacing: .01em;
}
.pratyaya-tab-bar {
  margin-bottom: 0;
}
.pratyaya-tab-panel {
  padding-top: 8px;
}
.pratyaya-empty {
  padding: 24px;
  text-align: center;
  color: var(--muted);
  font-size: 1.2em;
}

/* ── Siddhi derivation panel ──────────────────────────────────── */
.siddhi-group {
  margin-top: 12px;
}
.siddhi-header {
  background: var(--bar);
  color: #fff;
  padding: 0 12px;
  min-height: 36px;
  display: flex;
  align-items: center;
  border-radius: 6px 6px 0 0;
  margin-bottom: 0;
}
.siddhi-header-label {
  font-family: var(--font-dev);
  font-size: .82em;
  font-weight: 600;
  letter-spacing: .04em;
  opacity: .9;
}
.siddhi-body {
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 6px 6px;
  overflow: hidden;
}
.siddhi-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 12px 8px;
  background: var(--hover-bg);
  border-bottom: 1px solid var(--border);
}
.siddhi-pill {
  font-family: var(--font-dev);
  font-size: .82em;
  padding: 3px 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  transition: background .15s, color .15s;
}
.siddhi-pill:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.siddhi-pill.active { background: var(--bar-bg); color: var(--bar-fg); border-color: var(--bar-bg); }
.siddhi-entry {
  padding: 10px 12px 14px;
}
.siddhi-intro {
  font-size: .88em;
  color: var(--muted);
  margin-bottom: 10px;
  line-height: 1.5;
}
.siddhi-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .85em;
}
.siddhi-table thead th {
  font-family: var(--font-dev);
  font-size: .78em;
  font-weight: 600;
  color: var(--muted);
  text-align: left;
  padding: 4px 8px;
  border-bottom: 1px solid var(--border);
  background: var(--hover-bg);
}
.siddhi-table { table-layout: fixed; }
.siddhi-table thead th:first-child  { width: 10%; text-align: center; }
.siddhi-table thead th:nth-child(2) { width: 30%; }
.siddhi-table thead th:nth-child(3) { width: 60%; }
.siddhi-num {
  text-align: center;
  color: var(--muted);
  font-size: .8em;
  padding: 5px 4px;
  vertical-align: top;
  border-bottom: 1px solid var(--border);
}
.siddhi-form {
  font-family: var(--font-dev);
  padding: 5px 8px;
  vertical-align: top;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-weight: 600;
  overflow-wrap: anywhere;
  word-break: break-all;
}
.siddhi-note {
  padding: 5px 8px;
  vertical-align: top;
  border-bottom: 1px solid var(--border);
  line-height: 1.55;
  color: var(--fg);
}
/* Inline sutra links within siddhi notes */
.siddhi-sutra-link {
  font-family: var(--font-dev);
  font-size: .88em;
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
  border-bottom: 1px dotted var(--accent);
  white-space: nowrap;
}
.siddhi-sutra-link:hover { color: var(--bar); border-bottom-style: solid; }
.siddhi-ext-link { color: var(--accent); text-decoration: none; }
.siddhi-ext-link:hover { text-decoration: underline; }
.siddhi-dhatu-ref {
  font-family: var(--font-dev);
  font-size: .88em;
  color: var(--muted);
  font-style: italic;
}
/* Hover tooltip showing the 1-line sutra text */
/* Artha popup card — appears on hover over siddhi sutra links */
.artha-popup {
  position: fixed;
  z-index: 9999;
  width: 380px;
  border-radius: 8px;
  box-shadow: 0 6px 24px rgba(0,0,0,.38);
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s;
  font-size: .88em;
  line-height: 1.5;
  overflow: hidden;          /* clips children to border-radius */
  background: #fff;          /* solid — no bleed-through from page */
}
.artha-popup.visible {
  opacity: 1;
  pointer-events: auto;
}
.artha-popup-head {
  background: #1e2235;       /* dark, theme-independent */
  color: #fff;
  padding: 7px 12px;
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.artha-popup-ref {
  font-size: .78em;
  opacity: .75;
  white-space: nowrap;
  flex-shrink: 0;
}
.artha-popup-sutra {
  font-family: var(--font-dev);
  font-weight: 700;
  font-size: 1em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.artha-popup-body {
  background: #fff;
  padding: 8px 12px 10px;
  overflow-y: auto;
  max-height: 300px;   /* scrolls only if both artha lines are very long */
}
.artha-row {
  display: flex;
  gap: 8px;
  margin-bottom: 5px;
}
.artha-row:last-child { margin-bottom: 0; }
.artha-lbl {
  font-family: var(--font-dev);
  font-size: .82em;
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
  padding-top: 1px;
  flex-shrink: 0;
}
.artha-val {
  font-family: var(--font-dev);
  color: #1a1a2e;
  font-size: .93em;
}
.artha-hindi {
  border-top: 1px solid #eee;
  padding-top: 5px;
  margin-top: 2px;
  color: #444;
  font-size: .87em;
}
.siddhi-table tbody tr:last-child td { border-bottom: none; }
.siddhi-table tbody tr:hover td { background: var(--hover-bg); }

/* ── Pravachanam tab (आ० सुदर्शनदेव) ──────────────────────────────────────── */
.pravachanam-panel {
  padding: 10px 14px;
}
.prav-row {
  display: flex;
  gap: 10px;
  margin-bottom: 8px;
  line-height: 1.6;
}
.prav-row:last-child { margin-bottom: 0; }
.prav-lbl {
  font-family: var(--font-dev);
  font-size: .78em;
  color: var(--muted);
  white-space: nowrap;
  padding-top: 2px;
  min-width: 52px;
}
.prav-val {
  font-family: var(--font-dev);
  font-size: .92em;
  color: var(--fg);
}
.prav-hindi .prav-lbl,
.prav-hindi .prav-val {
  font-family: var(--font-dev);
  font-size: .88em;
  color: #555;
}

/* ── Shabda browser ───────────────────────────────────────────── */
.panel-shabda { padding: 0 0 80px; }

.shabda-disclaimer {
  margin: 10px 16px 0;
  padding: 7px 12px;
  background: var(--meta-bg, #f5f0e6);
  border-left: 3px solid var(--accent);
  border-radius: 4px;
  font-size: .8em;
  color: var(--text-muted);
  font-family: 'Noto Sans', sans-serif;
}

.shabda-search-wrap {
  position: sticky; top: 0; z-index: 10;
  background: var(--bg);
  padding: 12px 16px 8px;
  display: flex; gap: 6px; align-items: center;
  border-bottom: 1px solid var(--border);
}
.shabda-search {
  flex: 1; padding: 7px 10px;
  border: 1px solid var(--border); border-radius: 6px;
  background: var(--card-bg); color: var(--fg);
  font-family: var(--font-dev); font-size: .95rem;
}
.shabda-search:focus { outline: none; border-color: var(--accent); }
.shabda-search-clear {
  background: none; border: none; color: var(--muted);
  cursor: pointer; font-size: .9rem; padding: 4px 6px;
}
.shabda-pills {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}
.shabda-pill {
  padding: 4px 11px; border-radius: 20px;
  border: 1px solid var(--border); background: var(--card-bg);
  color: var(--fg); font-family: var(--font-dev); font-size: .82rem;
  cursor: pointer; transition: background .15s, color .15s;
}
.shabda-pill:hover { border-color: var(--accent); color: var(--accent); }
.shabda-pill.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.shabda-pill.suggested { border-color: var(--accent); color: var(--accent); }

.shabda-table-area { padding: 14px 16px 0; }
.shabda-header {
  display: flex; align-items: baseline; gap: 10px; margin-bottom: 12px;
}
.shabda-stem {
  font-family: var(--font-dev); font-size: 1.8rem;
  font-weight: 700; color: var(--fg);
}
.shabda-label {
  font-family: var(--font-dev); font-size: .85rem; color: var(--muted);
}
.shabda-pattern-note {
  font-family: var(--font-dev); font-size: .8rem; color: var(--muted);
  margin-bottom: 8px; padding: 5px 8px;
  background: var(--card-bg); border-radius: 4px;
  border-left: 3px solid var(--accent);
}
.shabda-table {
  width: 100%; border-collapse: collapse;
  font-family: var(--font-dev); font-size: .9rem; margin-bottom: 14px;
}
.shabda-table thead th {
  padding: 6px 10px; text-align: center;
  font-weight: 600; color: var(--muted);
  border-bottom: 2px solid var(--border); font-size: .78rem;
}
.shabda-table thead th:first-child { text-align: left; }
.shabda-vib {
  padding: 7px 10px 7px 0; font-size: .78rem;
  color: var(--muted); font-weight: 600;
  white-space: nowrap; border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.shabda-form {
  padding: 7px 10px; text-align: center;
  border-bottom: 1px solid var(--border);
  border-left: 1px solid var(--border);
  color: var(--fg); cursor: default;
  transition: background .12s;
}
.shabda-form:hover { background: var(--card-bg); }
.shabda-table tbody tr:last-child .shabda-vib,
.shabda-table tbody tr:last-child .shabda-form { border-bottom: none; }
.shabda-similar {
  display: flex; flex-wrap: wrap; gap: 6px;
  align-items: center; padding: 6px 0 16px;
}
.shabda-similar-label {
  font-family: var(--font-dev); font-size: .78rem;
  color: var(--muted); white-space: nowrap;
}
.shabda-sim-pill {
  padding: 3px 10px; border-radius: 14px;
  border: 1px solid var(--border); background: none;
  color: var(--accent); font-family: var(--font-dev); font-size: .82rem;
  cursor: pointer; transition: background .12s;
}
.shabda-sim-pill:hover { background: var(--card-bg); }
.shabda-loading, .shabda-empty {
  padding: 32px 16px; color: var(--muted);
  text-align: center; font-family: var(--font-dev);
}

/* ── Avyaya panel ─────────────────────────────────────────────── */
.panel-avyaya {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 0 40px;
}
.avyaya-section-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 16px 0 10px;
}
.avyaya-letter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px 0 16px;
  min-height: 38px;
}
.avyaya-sec-pill,
.avyaya-pill {
  font-family: var(--font-dev);
  font-size: .92em;
  padding: 5px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text);
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.avyaya-sec-pill {
  font-size: 1em;
  font-weight: 700;
  padding: 6px 18px;
}
.avyaya-sec-pill:hover,
.avyaya-pill:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.avyaya-sec-pill.active,
.avyaya-pill.active {
  background: var(--bar-bg, var(--bar));
  color: var(--bar-fg, #fff);
  border-color: var(--bar-bg, var(--bar));
}
.avyaya-table-wrap {
  overflow-x: auto;
}
.avyaya-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-dev);
  font-size: .9em;
}
.avyaya-table thead th {
  font-weight: 700;
  background: var(--bar);
  color: #fff;
  padding: 8px 12px;
  text-align: left;
  white-space: nowrap;
}
.avyaya-th-a { width: 18%; }
.avyaya-th-m { width: 25%; }
.avyaya-th-u { width: 57%; }
.avyaya-table tbody tr {
  border-bottom: 1px solid var(--border);
}
.avyaya-table tbody tr:hover {
  background: var(--card-bg);
}
.avyaya-cell-a {
  padding: 8px 12px;
  font-weight: 600;
  color: var(--text);
  vertical-align: top;
}
.avyaya-cell-m {
  padding: 8px 12px;
  color: var(--accent);
  vertical-align: top;
}
.avyaya-cell-u {
  padding: 8px 12px;
  color: var(--muted);
  vertical-align: top;
  line-height: 1.55;
}
.avyaya-loading,
.avyaya-empty {
  padding: 32px 16px;
  text-align: center;
  color: var(--muted);
  font-family: var(--font-dev);
  font-size: 1.1em;
}

/* ── Scrollbar ────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ── Responsive ───────────────────────────────────────────────── */
@media (max-width: 480px) {
  #icon-bar { display: none; }
  #app { padding: 14px 5% 24px; }
  .reader-sutra-text { font-size: 1.65em; }
  .bar-btn { min-width: 32px; padding: 0 4px; font-size: .95em; }
  .bar-ref { min-width: 54px; font-size: .76em; }
}

/* ── Varnochchaaran Shiksha panel ──────────────────────────────────────────── */
.panel-varnochchaaran {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 16px 60px;
}
.vns-header {
  padding: 20px 0 12px;
  border-bottom: 1px solid var(--border);
}
.vns-title {
  font-family: var(--font-dev);
  font-size: 1.4em;
  font-weight: 700;
  color: var(--text);
}
.vns-author {
  font-size: .82em;
  color: var(--muted);
  margin-top: 5px;
}
.vns-pills-wrap {
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 5;
  border-bottom: 1px solid var(--border);
  padding: 10px 0 8px;
  margin-bottom: 20px;
}
.vns-pills-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
}
.vns-prakarana-label {
  font-family: var(--font-dev);
  font-size: .85em;
  color: var(--muted);
  white-space: nowrap;
  padding-right: 2px;
}
.vns-pill {
  font-family: var(--font-dev);
  font-size: .88em;
  padding: 5px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
  white-space: nowrap;
}
.vns-pill-num {
  padding: 4px 10px;
  min-width: 32px;
  text-align: center;
}
.vns-pill:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.vns-pill.active {
  background: var(--bar-bg);
  color: var(--bar-fg);
  border-color: var(--bar-bg);
}
.vns-body {
  line-height: 1.8;
}
.vns-sutra {
  font-family: var(--font-dev);
  font-size: 1.05em;
  font-weight: 700;
  color: var(--accent);
  margin: 22px 0 6px;
  padding: 8px 14px;
  background: var(--bg-sidebar);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
}
.vns-para {
  font-family: var(--font-dev);
  font-size: 1em;
  color: var(--text);
  margin-bottom: 10px;
}
.vns-para strong {
  color: var(--accent);
  font-weight: 600;
}
.vns-section-img {
  display: block;
  max-width: 100%;
  margin: 28px auto 12px;
  border-radius: var(--radius);
}
