/* ===================================================================
   YOGA VIDYA - Clean Digital Textbook & Exam Preparation Guide
   Paper 490E1110: Fundamentals and History of Yoga
   Simplified, High-Readability Exam Reader (No Notebook Lines)
   =================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=Merriweather:ital,wght@0,300;0,400;0,700;1,300;1,400&family=Fira+Code:wght@400;600&display=swap');

:root {
  /* Light Theme (Default - Clean Modern Textbook / Book Reader) */
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #f1f5f9;
  --border-color: #e2e8f0;
  --border-active: #4f46e5;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-accent: #4f46e5;
  --accent-gold: #d97706;
  --accent-emerald: #059669;
  --accent-rose: #e11d48;
  --accent-cyan: #0891b2;
  --flow-arrow: #6366f1;
  --font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --font-serif: 'Merriweather', Georgia, serif;
  --font-code: 'Fira Code', monospace;
  --card-radius: 12px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.03);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
}

/* Dark Theme (Night Reader Mode) */
body.theme-dark {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-card: #1e293b;
  --bg-card-hover: #334155;
  --border-color: #334155;
  --border-active: #818cf8;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-accent: #818cf8;
  --accent-gold: #fbbf24;
  --accent-emerald: #34d399;
  --accent-rose: #fb7185;
  --accent-cyan: #22d3ee;
  --flow-arrow: #818cf8;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 20px -3px rgba(0, 0, 0, 0.5);
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-main);
  line-height: 1.7;
  min-height: 100vh;
  transition: background-color 0.25s ease, color 0.25s ease;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}
body.theme-dark ::-webkit-scrollbar-thumb {
  background: #475569;
}

/* ================= Header & Navbar ================= */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--border-color);
  padding: 0.75rem 1.5rem;
  box-shadow: var(--shadow-sm);
  transition: all 0.25s ease;
}

body.theme-dark .app-header {
  background: rgba(15, 23, 42, 0.92);
}

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

.logo-area {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: var(--text-main);
}

.logo-badge {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  font-weight: 700;
  box-shadow: 0 4px 10px rgba(79, 70, 229, 0.3);
}

.logo-text h1 {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--text-main);
}

.logo-text p {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 500;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  list-style: none;
}

.nav-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 600;
  padding: 0.5rem 0.85rem;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.2s ease;
  font-family: inherit;
}

.nav-btn:hover {
  color: var(--text-accent);
  background: rgba(79, 70, 229, 0.08);
}

.nav-btn.active {
  color: #ffffff;
  background: #4f46e5;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.theme-toggle-btn {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 0.45rem 0.85rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
  transition: all 0.2s ease;
  font-family: inherit;
}

.theme-toggle-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--text-accent);
}

/* ================= Main Container ================= */
.main-layout {
  max-width: 1180px;
  margin: 1.5rem auto;
  padding: 0 1.25rem 4rem;
}

/* ================= Hero / Book Overview Header ================= */
.hero-banner {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--card-radius);
  padding: 2rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.hero-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(79, 70, 229, 0.08);
  color: #4f46e5;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.3rem 0.75rem;
  border-radius: 6px;
  margin-bottom: 0.75rem;
}

body.theme-dark .hero-tag {
  background: rgba(129, 140, 248, 0.15);
  color: #818cf8;
}

.hero-title {
  font-size: 1.85rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-main);
  margin-bottom: 0.5rem;
  line-height: 1.3;
}

.hero-desc {
  font-size: 1rem;
  color: var(--text-muted);
  max-width: 820px;
  margin-bottom: 1.5rem;
  line-height: 1.6;
}

.hero-stats-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 1.25rem;
  border-top: 1px solid var(--border-color);
  padding-top: 1.25rem;
}

.stat-pill {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  padding: 0.5rem 0.85rem;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.stat-num {
  font-weight: 800;
  font-size: 1.15rem;
  color: var(--text-accent);
}

.stat-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 600;
}

/* ================= Search & Unit Filter Bar ================= */
.search-filter-section {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1.75rem;
}

.search-box-wrap {
  width: 100%;
  position: relative;
}

.search-input {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 0.85rem 1rem 0.85rem 2.85rem;
  border-radius: 10px;
  color: var(--text-main);
  font-size: 0.95rem;
  outline: none;
  font-family: inherit;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
}

.search-input:focus {
  border-color: var(--border-active);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.search-icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

.unit-pills-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.unit-filter-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 0.45rem 0.85rem;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.unit-filter-btn:hover {
  background: var(--bg-card-hover);
  color: var(--text-main);
}

.unit-filter-btn.active {
  background: #4f46e5;
  color: #ffffff;
  border-color: #4f46e5;
}

/* ================= Study Mode Switcher Bar ================= */
.study-mode-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 0.75rem 1.25rem;
  border-radius: 10px;
  margin-bottom: 2rem;
  box-shadow: var(--shadow-sm);
}

.mode-toggle-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
}

.mode-btn {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 0.45rem 0.85rem;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.mode-btn:hover {
  color: var(--text-main);
  background: var(--bg-card-hover);
}

.mode-btn.active {
  background: #4f46e5;
  color: #ffffff;
  border-color: #4f46e5;
}

.expand-all-btn {
  background: rgba(217, 119, 6, 0.1);
  border-color: rgba(217, 119, 6, 0.3);
  color: var(--accent-gold);
}

.expand-all-btn:hover {
  background: rgba(217, 119, 6, 0.2);
}

/* ================= Tab Content Sections ================= */
.tab-pane {
  display: none;
  animation: fadeIn 0.25s ease forwards;
}

.tab-pane.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ================= Clean Chapter & Topic Card ================= */
.flowchart-module-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--card-radius);
  padding: 2rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}

.flowchart-module-card:hover {
  border-color: #cbd5e1;
  box-shadow: var(--shadow-md);
}

body.theme-dark .flowchart-module-card:hover {
  border-color: #475569;
}

.module-header {
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-color);
}

.module-title-box h3 {
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.01em;
  margin-bottom: 0.35rem;
}

.sanskrit-term-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--accent-gold);
  background: rgba(217, 119, 6, 0.1);
  padding: 0.25rem 0.65rem;
  border-radius: 6px;
  margin-top: 0.25rem;
}

.audio-speak-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  color: inherit;
  font-size: 0.95rem;
  display: inline-flex;
  align-items: center;
  transition: transform 0.2s ease;
}

.audio-speak-btn:hover {
  transform: scale(1.2);
}

.module-etymology {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-top: 0.45rem;
}

.module-summary-text {
  font-size: 1rem;
  color: var(--text-main);
  line-height: 1.7;
  margin-bottom: 1.5rem;
}

/* ================= Simplified Modern Flowchart Tree ================= */
.flowchart-step-tree {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 1.75rem 0;
  gap: 0;
  width: 100%;
}

.flow-node-step {
  width: 100%;
  max-width: 780px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 1rem 1.25rem;
  display: flex;
  gap: 1rem;
  align-items: center;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}

.flow-node-step:hover {
  border-color: var(--border-active);
  transform: translateY(-1px);
}

.step-num-badge {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #4f46e5;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.88rem;
  flex-shrink: 0;
}

.step-details h4 {
  font-size: 1.02rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 0.15rem;
}

.step-details p {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* Downward Connector Arrow */
.flow-connector-arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0.3rem 0;
  color: var(--flow-arrow);
  font-size: 1.35rem;
  font-weight: 800;
  line-height: 1;
  user-select: none;
}

/* Sub-branching nodes */
.branching-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem;
  width: 100%;
  max-width: 780px;
  margin-top: 0.5rem;
  justify-content: center;
}

.branch-node {
  flex: 1;
  min-width: 240px;
  background: rgba(79, 70, 229, 0.05);
  border: 1px solid rgba(79, 70, 229, 0.2);
  border-radius: 8px;
  padding: 0.85rem 1rem;
}

body.theme-dark .branch-node {
  background: rgba(129, 140, 248, 0.08);
  border-color: rgba(129, 140, 248, 0.25);
}

.branch-node h5 {
  color: var(--text-accent);
  font-size: 0.92rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.branch-node p {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* High-Yield Exam Takeaway Box */
.exam-takeaway-box {
  background: rgba(217, 119, 6, 0.06);
  border-left: 4px solid var(--accent-gold);
  border-radius: 0 8px 8px 0;
  padding: 1rem 1.25rem;
  margin-top: 1.5rem;
}

.takeaway-title {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--accent-gold);
  margin-bottom: 0.5rem;
}

.takeaway-list {
  list-style: square;
  padding-left: 1.25rem;
  font-size: 0.9rem;
  color: var(--text-main);
  line-height: 1.6;
}

.takeaway-list li {
  margin-bottom: 0.35rem;
}

/* ================= In-Depth Textbook Chapter Drawer ================= */
.textbook-toggle-btn {
  width: 100%;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  color: var(--text-accent);
  padding: 0.85rem 1.25rem;
  border-radius: 8px;
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 1.5rem;
  font-family: inherit;
  transition: all 0.2s ease;
}

.textbook-toggle-btn:hover {
  background: rgba(79, 70, 229, 0.08);
  border-color: var(--text-accent);
}

.textbook-drawer {
  display: none;
  margin-top: 1rem;
  padding: 1.75rem;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  animation: fadeIn 0.3s ease;
}

.textbook-drawer.open {
  display: block;
}

.textbook-content {
  font-size: 0.98rem;
  line-height: 1.8;
  color: var(--text-main);
}

.textbook-content h4 {
  color: var(--text-accent);
  font-size: 1.25rem;
  font-weight: 800;
  margin: 1.5rem 0 0.6rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.35rem;
}

.textbook-content h5 {
  color: var(--accent-gold);
  font-size: 1.08rem;
  font-weight: 700;
  margin: 1.25rem 0 0.45rem;
}

.textbook-content h6 {
  font-size: 0.98rem;
  font-weight: 700;
  margin: 1rem 0 0.35rem;
}

.textbook-content p {
  margin-bottom: 1.15rem;
}

.textbook-content blockquote {
  border-left: 4px solid var(--accent-gold);
  padding: 0.65rem 1.25rem;
  margin: 1rem 0;
  background: rgba(217, 119, 6, 0.08);
  font-style: italic;
  border-radius: 0 6px 6px 0;
  color: var(--text-main);
}

/* Global View Mode Filter rules */
body.mode-flowchart-only .textbook-drawer,
body.mode-flowchart-only .textbook-toggle-btn {
  display: none !important;
}

body.mode-textbook-only .flowchart-step-tree,
body.mode-textbook-only .branching-row {
  display: none !important;
}

body.mode-textbook-only .textbook-drawer {
  display: block !important;
}

body.mode-textbook-only .textbook-toggle-btn {
  display: none !important;
}

/* ================= Asana & Anatomy Directory Styling ================= */
.asana-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 1.5rem;
  margin-top: 1.5rem;
}

.asana-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--card-radius);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: all 0.2s ease;
}

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

.asana-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.75rem;
}

.asana-cat-badge {
  font-size: 0.72rem;
  text-transform: uppercase;
  font-weight: 700;
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
  background: rgba(5, 150, 105, 0.1);
  color: var(--accent-emerald);
}

.anatomy-pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.75rem 0;
}

.anatomy-pill {
  font-size: 0.75rem;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  padding: 0.25rem 0.55rem;
  border-radius: 6px;
  color: var(--text-muted);
}

.view-modal-btn {
  background: #4f46e5;
  color: #ffffff;
  border: none;
  padding: 0.65rem 1rem;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  width: 100%;
  margin-top: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: all 0.2s ease;
  font-family: inherit;
}

.view-modal-btn:hover {
  background: #4338ca;
}

/* ================= Exam Bank Styling ================= */
.exam-filter-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.exam-pill-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 0.45rem 0.85rem;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.exam-pill-btn.active {
  background: var(--accent-rose);
  color: #ffffff;
  border-color: var(--accent-rose);
}

.exam-question-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--card-radius);
  padding: 1.75rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.exam-q-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.75rem;
  gap: 1rem;
}

.marks-badge {
  padding: 0.25rem 0.65rem;
  border-radius: 6px;
  font-weight: 800;
  font-size: 0.78rem;
  flex-shrink: 0;
}

.marks-badge.m2 {
  background: rgba(5, 150, 105, 0.1);
  color: var(--accent-emerald);
}

.marks-badge.m16 {
  background: rgba(225, 29, 72, 0.1);
  color: var(--accent-rose);
}

.univ-tag {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 600;
}

.exam-tip-alert {
  background: rgba(79, 70, 229, 0.06);
  border-left: 3px solid #6366f1;
  padding: 0.65rem 1rem;
  border-radius: 0 6px 6px 0;
  font-size: 0.85rem;
  margin: 0.75rem 0;
  color: var(--text-main);
}

.exam-toggle-answer-btn {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 0.55rem 1rem;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  margin-top: 0.75rem;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: inherit;
  transition: all 0.2s ease;
}

.exam-toggle-answer-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--text-accent);
}

.exam-answer-drawer {
  display: none;
  margin-top: 1rem;
  padding: 1.25rem;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  animation: fadeIn 0.25s ease;
}

.exam-answer-drawer.open {
  display: block;
}

/* ================= Pranayama Breath Pacer ================= */
.pacer-container {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--card-radius);
  padding: 2.5rem;
  text-align: center;
  max-width: 600px;
  margin: 2rem auto;
  box-shadow: var(--shadow-sm);
}

.pacer-visual-wrap {
  position: relative;
  width: 220px;
  height: 220px;
  margin: 1.5rem auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pacer-circle {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  color: #ffffff;
  font-weight: 800;
  transition: transform 4s ease-in-out;
  box-shadow: 0 4px 20px rgba(79, 70, 229, 0.4);
}

.pacer-status {
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.pacer-timer {
  font-size: 2rem;
  font-family: var(--font-code);
}

.pacer-controls {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-top: 1.5rem;
}

.pacer-btn {
  background: #4f46e5;
  color: #ffffff;
  border: none;
  padding: 0.65rem 1.5rem;
  border-radius: 8px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s ease;
}

.pacer-btn:hover {
  background: #4338ca;
}

/* ================= Modal Drawer ================= */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(6px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.modal-backdrop.open {
  display: flex;
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  width: 100%;
  max-width: 800px;
  max-height: 88vh;
  overflow-y: auto;
  padding: 2rem;
  box-shadow: var(--shadow-lg);
  position: relative;
  animation: modalScale 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalScale {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

.close-modal-btn {
  position: absolute;
  top: 1.25rem;
  right: 1.25rem;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  transition: all 0.2s ease;
}

.close-modal-btn:hover {
  background: var(--bg-card-hover);
}

/* ================= Mobile Bottom Navigation & Floating Top Button ================= */
.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: var(--bg-card);
  border-top: 1px solid var(--border-color);
  z-index: 999;
  justify-content: space-around;
  align-items: center;
  padding: 0 0.5rem;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
}

.mobile-nav-item {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 6px 0;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  transition: all 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.mobile-nav-icon {
  font-size: 1.25rem;
  line-height: 1;
}

.mobile-nav-item.active {
  color: #4f46e5;
}

body.theme-dark .mobile-nav-item.active {
  color: #818cf8;
}

/* Floating Back-To-Top Button */
.floating-top-btn {
  position: fixed;
  bottom: 75px;
  right: 1.25rem;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #4f46e5;
  color: #ffffff;
  border: none;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.4);
  font-size: 1.1rem;
  cursor: pointer;
  z-index: 900;
  display: none;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.floating-top-btn.visible {
  display: flex;
}

/* Print Friendly Styles */
@media print {
  .app-header, .mobile-bottom-nav, .floating-top-btn, .search-filter-section, .study-mode-bar, .view-modal-btn, .theme-toggle-btn, .pacer-container, .nav-links {
    display: none !important;
  }
  body {
    background: #ffffff !important;
    color: #000000 !important;
  }
  .flowchart-module-card, .exam-question-card {
    page-break-inside: avoid;
    border: 1px solid #000000 !important;
    box-shadow: none !important;
  }
  .textbook-drawer, .exam-answer-drawer {
    display: block !important;
  }
}

/* ================= Comprehensive Mobile Optimizations ================= */
@media (max-width: 768px) {
  .desktop-nav, .desktop-only {
    display: none !important;
  }
  .mobile-bottom-nav {
    display: flex !important;
  }

  .main-layout {
    padding: 0 0.85rem 6.5rem;
    margin: 1rem auto;
  }

  .app-header {
    padding: 0.6rem 0.85rem;
  }
  .logo-text h1 {
    font-size: 1.1rem;
  }
  .logo-badge {
    width: 34px;
    height: 34px;
    font-size: 1.2rem;
  }

  .hero-banner {
    padding: 1.25rem 1rem;
    margin-bottom: 1.25rem;
  }
  .hero-title {
    font-size: 1.4rem !important;
  }

  /* Horizontal unit scroll */
  .unit-pills-wrap {
    flex-wrap: nowrap !important;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 4px;
  }
  .unit-pills-wrap::-webkit-scrollbar {
    display: none;
  }
  .unit-filter-btn {
    flex-shrink: 0;
  }

  /* Cards */
  .flowchart-module-card, .exam-question-card {
    padding: 1.25rem 1rem !important;
    margin-bottom: 1.25rem;
  }

  .module-title-box h3 {
    font-size: 1.2rem;
  }

  .flow-node-step {
    padding: 0.75rem 0.85rem !important;
    gap: 0.65rem !important;
  }
  .step-num-badge {
    width: 28px !important;
    height: 28px !important;
    font-size: 0.8rem !important;
  }

  .branching-row {
    flex-direction: column;
    gap: 0.5rem;
  }
  .branch-node {
    min-width: 100% !important;
  }

  .asana-grid {
    grid-template-columns: 1fr !important;
  }

  /* Modal Bottom Sheet */
  .modal-backdrop {
    padding: 0;
    align-items: flex-end;
  }
  .modal-card {
    border-radius: 18px 18px 0 0 !important;
    padding: 1.25rem 1rem 3rem !important;
    max-height: 92vh !important;
  }
  .modal-card [style*="grid-template-columns: 1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }

  .study-mode-bar {
    padding: 0.65rem 0.85rem;
  }
  .mode-toggle-group {
    width: 100%;
  }
  .expand-all-btn {
    width: 100%;
    text-align: center;
  }
}
