:root {
  --bg-main: #f7f1e3;
  --bg-card: #fffdf7;
  --bg-elevated: #efe4cc;
  --text-main: #231709;
  --text-muted: #6b533b;
  --accent: #c2590a;
  --accent-gold: #d97706;
  --border-color: #decba8;
  --shadow: 0 12px 35px rgba(59, 36, 12, 0.12);
  --reader-font-size: 1.15rem;
}

body.theme-light {
  --bg-main: #f4f6f9;
  --bg-card: #ffffff;
  --bg-elevated: #eef2f6;
  --text-main: #18202c;
  --text-muted: #5a6577;
  --accent: #b45309;
  --accent-gold: #d97706;
  --border-color: #dce3ec;
}

body.theme-dark {
  --bg-main: #120d08;
  --bg-card: #1d150e;
  --bg-elevated: #2a1f15;
  --text-main: #f5ebd9;
  --text-muted: #bba68a;
  --accent: #f59e0b;
  --accent-gold: #fbbf24;
  --border-color: #3d2d1e;
}

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

body {
  font-family: 'Plus Jakarta Sans', 'Noto Sans Devanagari', 'Noto Sans Bengali', 'Noto Sans Tamil', 'Noto Sans Telugu', 'Noto Sans Kannada', 'Noto Sans Malayalam', 'Noto Sans Gujarati', 'Noto Sans Gurmukhi', 'Noto Sans Oriya', sans-serif;
  background: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  transition: background 0.25s ease, color 0.25s ease;
}

.hidden { display: none !important; }

/* ==================== AUTH SCREEN ==================== */
.auth-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: radial-gradient(circle at top, #3b230e 0%, #170d05 100%);
}

.auth-card {
  width: 100%;
  max-width: 460px;
  background: #fffdf7;
  color: #231709;
  border-radius: 20px;
  padding: 32px 28px;
  border: 2px solid #d97706;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

.auth-crest {
  width: 56px;
  height: 56px;
  margin: 0 auto 10px;
  border-radius: 50%;
  background: linear-gradient(135deg, #d97706, #9a3412);
  color: #fff;
  font-size: 1.8rem;
  display: grid;
  place-items: center;
  font-weight: 700;
}

.brand-title {
  font-family: 'Cinzel', serif;
  text-align: center;
  font-size: 2rem;
  letter-spacing: 3px;
  color: #9a3412;
}

.brand-subtitle {
  text-align: center;
  font-size: 0.85rem;
  color: #6b533b;
  margin-bottom: 20px;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: #efe4cc;
  padding: 4px;
  border-radius: 12px;
  margin-bottom: 18px;
}

.auth-tab {
  border: none;
  background: transparent;
  padding: 10px;
  border-radius: 9px;
  font-weight: 600;
  cursor: pointer;
  color: #5c4328;
}

.auth-tab.active {
  background: #fffdf7;
  color: #9a3412;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.input-group {
  margin-bottom: 13px;
}

.input-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.input-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 5px;
  color: #4a3520;
}

.input-group input {
  width: 100%;
  padding: 11px 13px;
  border: 1.5px solid #d6c19c;
  border-radius: 10px;
  font-size: 0.95rem;
  background: #fff;
}

.input-group input:focus {
  outline: none;
  border-color: #d97706;
}

.free-badge {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.83rem;
  font-weight: 600;
  text-align: center;
  margin-bottom: 14px;
}

.btn-primary {
  width: 100%;
  padding: 13px;
  border: none;
  border-radius: 11px;
  background: linear-gradient(135deg, #d97706, #b45309);
  color: #fff;
  font-weight: 700;
  font-size: 0.98rem;
  cursor: pointer;
}

.btn-primary:hover { filter: brightness(1.06); }

.btn-secondary {
  padding: 11px 16px;
  border: 1.5px solid var(--border-color);
  border-radius: 10px;
  background: var(--bg-elevated);
  color: var(--text-main);
  font-weight: 600;
  cursor: pointer;
}

.btn-danger {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 10px;
  background: #dc2626;
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  margin-top: 10px;
}

.btn-link {
  background: none;
  border: none;
  color: #9a3412;
  font-weight: 600;
  margin-top: 10px;
  cursor: pointer;
  display: block;
  width: 100%;
  text-align: center;
}

.otp-info {
  text-align: center;
  background: #fef3c7;
  padding: 12px;
  border-radius: 10px;
  margin-bottom: 14px;
  font-size: 0.88rem;
}

.demo-otp-box {
  margin-top: 8px;
  padding: 6px;
  background: #fff;
  border: 1px dashed #b45309;
  border-radius: 6px;
  font-weight: 700;
  color: #9a3412;
}

.otp-field {
  text-align: center;
  font-size: 1.4rem !important;
  letter-spacing: 6px;
  font-weight: 700;
}

.error-msg {
  color: #dc2626;
  font-size: 0.85rem;
  text-align: center;
  margin-top: 10px;
  font-weight: 600;
}

/* ==================== TOPBAR & WORKSPACE ==================== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--bg-card);
  border-bottom: 1.5px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 40;
  gap: 10px;
}

.topbar-left, .topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.app-logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.om-badge {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, #d97706, #9a3412);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 1.2rem;
}

.app-logo h1 {
  font-family: 'Cinzel', serif;
  font-size: 1.25rem;
  line-height: 1.1;
}

.lang-pill {
  font-size: 0.72rem;
  background: var(--bg-elevated);
  color: var(--accent);
  padding: 2px 8px;
  border-radius: 99px;
  font-weight: 700;
}

.page-jumper {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-elevated);
  padding: 6px 12px;
  border-radius: 10px;
  font-size: 0.88rem;
}

.page-jumper input {
  width: 62px;
  padding: 4px 6px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-main);
  text-align: center;
  font-weight: 700;
}

.icon-btn {
  padding: 8px 13px;
  border-radius: 10px;
  border: 1.5px solid var(--border-color);
  background: var(--bg-elevated);
  color: var(--text-main);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
}

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

.progress-track {
  width: 100%;
  height: 4px;
  background: var(--bg-elevated);
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #d97706, #ea580c);
  transition: width 0.3s ease;
}

.workspace {
  display: flex;
  min-height: calc(100vh - 68px);
}

/* ==================== INDEX DRAWER ==================== */
.index-drawer {
  width: 310px;
  background: var(--bg-card);
  border-right: 1.5px solid var(--border-color);
  display: flex;
  flex-direction: column;
  height: calc(100vh - 68px);
  position: sticky;
  top: 68px;
}

.drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color);
}

.close-drawer-btn {
  display: none;
  background: none;
  border: none;
  font-size: 1.2rem;
  color: var(--text-main);
  cursor: pointer;
}

.drawer-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 8px;
  gap: 6px;
  border-bottom: 1px solid var(--border-color);
}

.d-tab {
  padding: 8px;
  border: none;
  border-radius: 8px;
  background: var(--bg-elevated);
  color: var(--text-muted);
  font-weight: 600;
  cursor: pointer;
}

.d-tab.active {
  background: var(--accent);
  color: #fff;
}

.drawer-list {
  overflow-y: auto;
  padding: 10px;
  flex: 1;
}

.chapter-item {
  padding: 11px 12px;
  border-radius: 10px;
  margin-bottom: 6px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: 0.15s;
}

.chapter-item:hover, .chapter-item.active {
  background: var(--bg-elevated);
  border-color: var(--accent-gold);
}

.chapter-item-top {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--accent);
  font-weight: 700;
}

.chapter-item-title {
  font-weight: 600;
  font-size: 0.92rem;
  margin-top: 2px;
}

/* ==================== SACRED BOOK PAGE ==================== */
.book-stage {
  flex: 1;
  padding: 28px 20px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

.sacred-page {
  width: 100%;
  max-width: 820px;
  background: var(--bg-card);
  border: 2px solid var(--border-color);
  border-radius: 18px;
  padding: 34px 38px;
  box-shadow: var(--shadow);
  position: relative;
}

.page-meta-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 10px;
}

.chapter-heading {
  font-family: 'Cinzel', serif;
  text-align: center;
  font-size: 1.55rem;
  color: var(--text-main);
}

.chapter-sub-sanskrit {
  text-align: center;
  font-size: 1.05rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.ornament-divider {
  text-align: center;
  color: var(--accent-gold);
  margin: 16px 0 22px;
  letter-spacing: 6px;
  font-size: 0.95rem;
}

.shloka-box {
  background: var(--bg-elevated);
  border-left: 4px solid var(--accent-gold);
  padding: 20px 22px;
  border-radius: 12px;
  margin-bottom: 22px;
}

.section-label {
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 8px;
}

.sanskrit-verse {
  font-size: calc(var(--reader-font-size) + 0.18rem);
  line-height: 1.9;
  font-weight: 600;
  text-align: center;
  white-space: pre-line;
}

.transliteration-verse {
  margin-top: 12px;
  font-size: 0.92rem;
  font-style: italic;
  color: var(--text-muted);
  text-align: center;
  white-space: pre-line;
}

.translation-box {
  margin-bottom: 20px;
}

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

.auto-save-indicator {
  font-size: 0.78rem;
  color: #059669;
  font-weight: 600;
}

.translation-verse {
  font-size: var(--reader-font-size);
  line-height: 1.85;
  margin-top: 6px;
}

.purport-box {
  border-top: 1px dashed var(--border-color);
  padding-top: 16px;
  margin-bottom: 26px;
}

.purport-verse {
  font-size: calc(var(--reader-font-size) - 0.1rem);
  line-height: 1.75;
  color: var(--text-muted);
}

.page-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1.5px solid var(--border-color);
  padding-top: 18px;
}

.nav-page-btn {
  padding: 11px 20px;
  border-radius: 10px;
  border: 1.5px solid var(--accent-gold);
  background: var(--bg-elevated);
  color: var(--text-main);
  font-weight: 700;
  cursor: pointer;
}

.nav-page-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.page-footer-num {
  font-family: 'Cinzel', serif;
  font-weight: 700;
  color: var(--accent);
}

/* ==================== MODALS (RECEIPT & SETTINGS) ==================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
}

.modal-card {
  background: var(--bg-card);
  color: var(--text-main);
  border-radius: 18px;
  border: 2px solid var(--accent-gold);
  width: 100%;
  max-width: 660px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 26px;
}

.receipt-container {
  max-width: 500px;
  background: #fffdf7;
  color: #231709;
}

.receipt-header {
  text-align: center;
  border-bottom: 2px dashed #d97706;
  padding-bottom: 14px;
  margin-bottom: 16px;
}

.receipt-om { color: #b45309; font-weight: 700; }
.receipt-header h2 { font-family: 'Cinzel', serif; font-size: 1.2rem; margin-top: 4px; }
.receipt-sub { font-size: 0.82rem; color: #6b533b; }

.receipt-row {
  display: flex;
  justify-content: space-between;
  padding: 9px 0;
  border-bottom: 1px solid #efe4cc;
  font-size: 0.92rem;
}

.paid-free { color: #059669; }

.receipt-footer-note {
  margin-top: 16px;
  padding: 10px;
  background: #fef3c7;
  border-radius: 8px;
  font-size: 0.82rem;
  text-align: center;
  color: #78350f;
}

.modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 18px;
}

/* Settings Modal */
.settings-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.settings-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 18px;
}

.s-tab {
  padding: 10px 8px;
  border-radius: 10px;
  border: 1.5px solid var(--border-color);
  background: var(--bg-elevated);
  color: var(--text-main);
  font-weight: 700;
  font-size: 0.84rem;
  cursor: pointer;
}

.s-tab.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.pane-desc {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.language-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
  margin-bottom: 20px;
}

.lang-option {
  padding: 11px 10px;
  border-radius: 10px;
  border: 1.5px solid var(--border-color);
  background: var(--bg-elevated);
  color: var(--text-main);
  text-align: left;
  cursor: pointer;
}

.lang-option.selected {
  border-color: var(--accent-gold);
  background: #fef3c7;
  color: #78350f;
}

.lang-option strong { display: block; font-size: 0.95rem; }
.lang-option span { font-size: 0.78rem; opacity: 0.8; }

.appearance-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  border-top: 1px solid var(--border-color);
  padding-top: 14px;
}

.theme-btns {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.theme-chip {
  padding: 7px 11px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: var(--bg-elevated);
  color: var(--text-main);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
}

.profile-summary-box {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--bg-elevated);
  padding: 16px;
  border-radius: 12px;
  margin-bottom: 14px;
}

.profile-avatar {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 1.5rem;
  font-weight: 700;
}

.profile-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.stat-pill {
  background: var(--bg-elevated);
  padding: 10px;
  border-radius: 10px;
  text-align: center;
}

.stat-pill span { display: block; font-size: 0.75rem; color: var(--text-muted); }
.stat-pill strong { font-size: 0.95rem; color: var(--accent); }

/* Owner Dashboard */
.owner-lock {
  text-align: center;
  max-width: 380px;
  margin: 0 auto;
}

.owner-lock .input-group { text-align: left; margin-top: 10px; }
.lock-icon { font-size: 2.2rem; margin-bottom: 6px; }

.owner-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.owner-toolbar input {
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: var(--bg-elevated);
  color: var(--text-main);
}

.receipts-table-wrap {
  overflow-x: auto;
}

.receipts-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.receipts-table th, .receipts-table td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--border-color);
  text-align: left;
}

@media (max-width: 820px) {
  .index-drawer {
    position: fixed;
    left: -320px;
    top: 0;
    height: 100vh;
    z-index: 80;
    transition: left 0.25s ease;
  }
  .index-drawer.open { left: 0; }
  .close-drawer-btn { display: block; }
  .sacred-page { padding: 22px 18px; }
  .language-grid { grid-template-columns: repeat(2, 1fr); }
  .appearance-controls { grid-template-columns: 1fr; }
}

@media print {
  body * { visibility: hidden; }
  #printable-receipt, #printable-receipt * { visibility: visible; }
  #printable-receipt { position: fixed; inset: 0; border: none; box-shadow: none; }
  .no-print { display: none !important; }
}