:root {
  --primary: #c2410c; /* Sacred vermilion/terracotta */
  --primary-dark: #9a3412;
  --secondary: #b45309; /* Bronze/bell-metal gold */
  --accent: #0284c7; /* Peacock blue / copper patina */
  --bg-main: #fdfbf7; /* Parchment ivory */
  --bg-card: #ffffff;
  --bg-sidebar: #f8f4ec;
  --text-main: #1c1917;
  --text-muted: #57534e;
  --border-color: #e7e0d3;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --font-serif: "Merriweather", "Noto Serif Devanagari", Georgia, serif;
  --font-sans: "Inter", "Noto Sans Devanagari", -apple-system, BlinkMacSystemFont, sans-serif;
}

[data-theme="dark"] {
  --primary: #ea580c;
  --primary-dark: #c2410c;
  --secondary: #d97706;
  --accent: #38bdf8;
  --bg-main: #0c0a09;
  --bg-card: #1c1917;
  --bg-sidebar: #171412;
  --text-main: #f5f5f4;
  --text-muted: #a8a29e;
  --border-color: #292524;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* TOP HEADER */
.site-header {
  background: linear-gradient(135deg, #7c2d12, #9a3412, #c2410c);
  color: #fff;
  padding: 1.25rem 2rem;
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 0;
  z-index: 50;
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.brand-icon {
  width: 52px;
  height: 52px;
  background: #fef08a;
  color: #7c2d12;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  box-shadow: 0 0 15px rgba(254, 240, 138, 0.4);
}

.brand-title-area h1 {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.brand-title-area .subtitle {
  font-size: 0.85rem;
  opacity: 0.9;
  font-weight: 400;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.btn-lang {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #fff;
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-lang:hover, .btn-lang.active {
  background: #ffffff;
  color: #7c2d12;
  font-weight: 600;
}

.theme-toggle, .print-btn {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

/* MAIN LAYOUT */
.app-container {
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
  display: flex;
  flex: 1;
  position: relative;
}

/* SIDEBAR */
.sidebar {
  width: 340px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  padding: 1.5rem 1rem;
  overflow-y: auto;
  height: calc(100vh - 80px);
  position: sticky;
  top: 80px;
  flex-shrink: 0;
}

.search-box {
  margin-bottom: 1.25rem;
}

.search-input {
  width: 100%;
  padding: 0.6rem 0.9rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-main);
  font-size: 0.9rem;
}

.nav-tabs {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 1.5rem;
}

.nav-tab-btn {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.9rem;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-main);
  font-size: 0.9rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s ease;
}

.nav-tab-btn:hover {
  background: rgba(194, 65, 12, 0.08);
  color: var(--primary);
}

.nav-tab-btn.active {
  background: var(--primary);
  color: #fff;
}

.volume-tree-header {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  padding-left: 0.5rem;
  font-weight: 600;
}

.volume-group {
  margin-bottom: 1rem;
}

.volume-heading {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--secondary);
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
}

.chapter-nav-list {
  list-style: none;
  margin-top: 0.35rem;
}

.chapter-nav-item {
  padding: 0.45rem 0.65rem;
  font-size: 0.85rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--text-muted);
  transition: background 0.15s ease;
}

.chapter-nav-item:hover {
  background: rgba(194, 65, 12, 0.06);
  color: var(--text-main);
}

.chapter-nav-item.active {
  background: rgba(194, 65, 12, 0.12);
  color: var(--primary);
  font-weight: 600;
  border-left: 3px solid var(--primary);
}

.chapter-badge {
  font-size: 0.7rem;
  background: var(--border-color);
  padding: 0.15rem 0.4rem;
  border-radius: 10px;
}

/* MAIN CONTENT AREA */
.content-area {
  flex: 1;
  padding: 2rem;
  overflow-y: auto;
  min-width: 0;
}

/* AUDIO BAR COMPONENT */
.audio-player-banner {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem 1.5rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.audio-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.audio-track-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.audio-pulse {
  width: 12px;
  height: 12px;
  background-color: var(--primary);
  border-radius: 50%;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(194, 65, 12, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 8px rgba(194, 65, 12, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(194, 65, 12, 0); }
}

.audio-controls-row {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.audio-btn {
  background: var(--primary);
  color: #fff;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}

.audio-timeline {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.scrub-bar {
  flex: 1;
  height: 6px;
  background: var(--border-color);
  border-radius: 3px;
  outline: none;
  cursor: pointer;
}

.time-readout {
  font-family: monospace;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.rate-select {
  padding: 0.3rem 0.5rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-main);
  color: var(--text-main);
  font-size: 0.8rem;
}

/* MONOGRAPH ARTICLE READER */
.monograph-article {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 2.5rem 3rem;
  box-shadow: var(--shadow-sm);
  font-family: var(--font-serif);
  font-size: 1.05rem;
  line-height: 1.8;
}

.monograph-article h1 {
  font-size: 2.2rem;
  color: var(--primary-dark);
  margin-bottom: 0.5rem;
  line-height: 1.25;
}

.monograph-article h2 {
  font-size: 1.5rem;
  color: var(--secondary);
  margin-top: 2rem;
  margin-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.4rem;
}

.monograph-article h3 {
  font-size: 1.25rem;
  color: var(--text-main);
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
}

.monograph-article p {
  margin-bottom: 1.25rem;
}

.monograph-article blockquote {
  border-left: 4px solid var(--secondary);
  background: var(--bg-sidebar);
  padding: 1rem 1.5rem;
  margin: 1.5rem 0;
  font-style: italic;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.monograph-article table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-family: var(--font-sans);
  font-size: 0.9rem;
}

.monograph-article th, .monograph-article td {
  border: 1px solid var(--border-color);
  padding: 0.75rem 1rem;
  text-align: left;
}

.monograph-article th {
  background: var(--bg-sidebar);
  color: var(--primary);
  font-weight: 600;
}

/* METALLURGY LAB STYLES */
.metallurgy-calculator {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 2rem;
  margin-bottom: 2rem;
}

.calc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.5rem;
  margin-top: 1.5rem;
}

.calc-input-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}

.calc-input-group input {
  width: 100%;
  padding: 0.65rem 0.9rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-main);
  color: var(--text-main);
  font-size: 1rem;
}

.calc-result-box {
  background: var(--bg-sidebar);
  border-left: 4px solid var(--accent);
  padding: 1.25rem;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* GOTRAS EXPLORER */
.gotras-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.25rem;
  margin-top: 1.5rem;
}

.gotra-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.gotra-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary);
}

.gotra-card h4 {
  font-size: 1.15rem;
  color: var(--primary);
  margin-bottom: 0.5rem;
}

.devak-tag {
  display: inline-block;
  background: #fef08a;
  color: #713f12;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  margin-bottom: 0.75rem;
}

.surnames-list {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* TEMPLES DIRECTORY */
.temples-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1.5rem;
  margin-top: 1.5rem;
}

.temple-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.temple-card-body {
  padding: 1.25rem;
}

.temple-card h4 {
  color: var(--secondary);
  font-size: 1.1rem;
  margin-bottom: 0.4rem;
}

.temple-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

/* FOOTER */
.site-footer {
  background: #1c1917;
  color: #a8a29e;
  padding: 2.5rem 2rem;
  margin-top: auto;
  border-top: 1px solid #292524;
}

.footer-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1.5rem;
}

.footer-attribution {
  font-size: 0.85rem;
}

.footer-attribution strong {
  color: #f5f5f4;
}

@media (max-width: 900px) {
  .app-container {
    flex-direction: column;
  }
  .sidebar {
    width: 100%;
    height: auto;
    position: static;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
  }
  .content-area {
    padding: 1.25rem;
  }
  .monograph-article {
    padding: 1.5rem;
  }
}

@media print {
  .site-header, .sidebar, .audio-player-banner, .site-footer {
    display: none !important;
  }
  .content-area {
    padding: 0;
  }
  .monograph-article {
    border: none;
    box-shadow: none;
    padding: 0;
  }
}

/* AUDIO WAVEFORM ANIMATION */
.audio-wave {
  display: none;
  align-items: center;
  gap: 3px;
  height: 20px;
  margin-left: 0.5rem;
}

.audio-wave.active {
  display: flex;
}

.audio-wave span {
  width: 3px;
  height: 6px;
  background-color: var(--primary);
  border-radius: 2px;
  animation: audioWave 1s ease-in-out infinite alternate;
}

.audio-wave span:nth-child(1) { animation-delay: 0.1s; }
.audio-wave span:nth-child(2) { animation-delay: 0.25s; }
.audio-wave span:nth-child(3) { animation-delay: 0.4s; }
.audio-wave span:nth-child(4) { animation-delay: 0.15s; }
.audio-wave span:nth-child(5) { animation-delay: 0.3s; }

@keyframes audioWave {
  0% { height: 4px; }
  100% { height: 20px; background-color: var(--secondary); }
}

.bell-test-btn {
  background: rgba(194, 65, 12, 0.1);
  color: var(--primary);
  border: 1px solid var(--border-color);
  padding: 0.3rem 0.6rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.bell-test-btn:hover {
  background: var(--primary);
  color: #fff;
}
