/* ============================================
   ENIHS ACADEMY — notes.css (Fully Restored & Upgraded)
   ============================================ */

:root {
  --primary-color: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #3b82f6;
  --secondary-color: #f59e0b;
  --secondary-dark: #d97706;
  --accent-color: #10b981;
  --background-light: #f8fafc;
  --background-white: #ffffff;
  --text-dark: #1e293b;
  --text-medium: #475569;
  --text-light: #94a3b8;
  --border-color: #e2e8f0;
  --shadow-sm: 0 1px 2px 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);
  --header-bg: #1e293b;
  --nav-bg: #f59e0b;
  --footer-bg: #0f172a;
  --transition: all 0.3s ease;
  --border-radius: 12px;
  --header-h: 130px;

  /* Aliases */
  --primary: var(--primary-color);
  --green: var(--accent-color);
  --surface: var(--background-white);
  --bg: var(--background-light);
  --border: var(--border-color);
  --text: var(--text-dark);
  --text-mid: var(--text-medium);
  --text-soft: var(--text-light);
  --ease: var(--transition);
  --radius: var(--border-radius);
}

html {
  transition: background-color 0.3s ease, color 0.3s ease;
}

button, a, .btn, .nav-link, .subject-link, .chapter-card, .video-card, .recent-card, .notice-item,
.quick-card, .notes-page-btn, .subject-item, .continue-reading-card, .sidebar-toggle-btn {
  transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease, transform 0.3s ease, box-shadow 0.3s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-top: calc(var(--header-h) + 15px); 
  background: linear-gradient(180deg, #f8fafc 0%, #eef2f7 48%, #f8fafc 100%);
  color: var(--text-dark);
  font-family: "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  line-height: 1.6;
}

button, input { font: inherit; }
button { border: 0; color: inherit; cursor: pointer; }
input { border: 0; background: transparent; }

/* ── SIDEBAR TOGGLE (Floating Menu Button) ─── */
.sidebar-toggle-btn {
  position: fixed;
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 14px rgba(37,99,235,.35);
  transition: var(--ease);

  /* Mobile Default: Floating Action Button (FAB) Bottom Right */
  bottom: 100px;
  right: 20px;
  top: auto;
  left: auto;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  font-size: 20px;
}
.sidebar-toggle-btn:hover { background: var(--primary-dark); transform: scale(1.05); }

@media (min-width: 769px) {
  .sidebar-toggle-btn {
    /* Desktop Default: Fixed Top Left */
    top: calc(var(--header-h) + 20px);
    left: 10px;
    bottom: auto;
    right: auto;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    font-size: 15px;
  }
}

.sidebar-overlay {
  position: fixed;
  inset: 0;
  z-index: 1099;
  display: none;
  background: rgba(15,23,42,.45);
  backdrop-filter: blur(2px);
}
.sidebar-overlay.active { display: block; }

/* ── SIDEBAR PANEL ─────────────────────────── */
.notes-sidebar {
  position: fixed;
  top: var(--header-h);
  left: 0;
  z-index: 1100;
  width: min(290px, calc(100vw - 16px));
  height: calc(100vh - var(--header-h));
  transform: translateX(-110%);
  background: var(--surface);
  border-right: 1px solid var(--border);
  border-top-right-radius: 16px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform .3s cubic-bezier(.4,0,.2,1);
}
.notes-sidebar.open { transform: translateX(0); }

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 16px;
  border-bottom: 1px solid var(--border);
  gap: 10px;
}
.sidebar-header h2 { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 700; }
.sidebar-close-btn {
  width: 30px;
  height: 30px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--bg);
  color: var(--text-mid);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--ease);
}
.sidebar-close-btn:hover { background: #fee2e2; border-color: #f87171; color: #dc2626; }

.sidebar-search { position: relative; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.sidebar-search i { position: absolute; left: 26px; top: 50%; transform: translateY(-50%); color: var(--text-soft); font-size: 12px; pointer-events: none; }
.sidebar-search input {
  width: 100%;
  padding: 9px 10px 9px 32px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
  outline: none;
  transition: var(--ease);
}
.sidebar-search input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }

.notes-list { flex: 1; overflow-y: auto; padding: 8px; }

.class-group { margin-bottom: 7px; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.class-group-header { display: flex; align-items: center; justify-content: space-between; padding: 10px 13px; cursor: pointer; gap: 10px; }
.class-group[data-class="10"] .class-group-header { background: linear-gradient(135deg,#2563eb,#3b82f6); }
.class-group[data-class="11"] .class-group-header { background: linear-gradient(135deg,#059669,#10b981); }
.class-group[data-class="12"] .class-group-header { background: linear-gradient(135deg,#d97706,#f59e0b); }
.class-group-label { display: flex; align-items: center; gap: 8px; color: #fff; font-size: 13px; font-weight: 700; }
.class-group-arrow { color: #fff; font-size: 11px; transition: transform .25s; }
.class-group.open .class-group-arrow { transform: rotate(180deg); }
.class-group-body { display: none; padding: 5px; background: var(--bg); }
.class-group.open .class-group-body { display: block; }

.subject-item {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 38px;
  margin-bottom: 3px;
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  font-size: 13px;
  font-weight: 600;
  transition: var(--ease);
}
.subject-item:hover { border-color: var(--primary); color: var(--primary); transform: translateX(2px); }
.subject-item i { width: 14px; color: var(--primary); text-align: center; }
.subject-item-count { margin-left: auto; padding: 1px 7px; border-radius: 10px; background: var(--bg); color: var(--text-soft); font-size: 11px; }

.no-results { padding: 26px 10px; color: var(--text-soft); text-align: center; font-size: 13px; }
.no-results i { display: block; margin-bottom: 8px; font-size: 24px; opacity: .4; }

/* ── LAYOUT PARAMS ─────────────────────────── */
.notes-container {
  width: min(1160px, 100%);
  margin: 0 auto;
  padding: 10px 30px 32px 32px;
  flex: 1;
  display: flex;
  flex-direction: column;
  height: auto;
  overflow: visible;
}

.notes-main {
  flex: 1;
  padding: clamp(14px, 2.5vw, 24px);
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  overflow: visible;
}

/* ── WELCOME PANEL ─────────────────────────── */
.notes-welcome {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  max-width: 640px;
  width: 100%;
  margin: 0 auto;
  padding: 32px 16px;
  text-align: center;
  animation: fadeUp .35s ease;
}
.welcome-icon {
  width: 82px;
  height: 82px;
  margin-bottom: 20px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--green));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 34px;
}
.notes-welcome h2 { font-size: clamp(20px, 3.5vw, 28px); margin-bottom: 8px; }
.notes-welcome > p { color: var(--text-mid); font-size: 14px; margin-bottom: 28px; }

.notes-welcome.hidden,
.subject-shelf.hidden,
.notes-reader.hidden {
  display: none !important;
}
.quick-access h3 { font-size: 13px; font-weight: 700; color: var(--text-mid); margin-bottom: 12px; text-transform: uppercase; letter-spacing: .5px; }
.quick-cards { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; }
.quick-card {
  min-height: 90px;
  padding: 16px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 700;
  transition: var(--ease);
}
.quick-card:hover { transform: translateY(-3px); border-color: var(--primary); box-shadow: var(--shadow-md); }
.quick-card i { color: var(--primary); font-size: 24px; }

/* ── CONTINUE READING ──────────────────────── */
.continue-reading { width: 100%; max-width: 420px; margin-bottom: 28px; text-align: left; }
.continue-reading h3 { font-size: 13px; font-weight: 700; color: var(--text-mid); margin-bottom: 10px; text-transform: uppercase; letter-spacing: .5px; }
.continue-reading-card {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border: 2px solid var(--primary);
  border-radius: var(--radius);
  background: linear-gradient(135deg, #eff6ff, #f0f7ff);
  color: var(--text);
  text-align: left;
  transition: var(--ease);
}
.continue-reading-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.continue-reading-meta { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.continue-reading-class { font-size: 11px; font-weight: 800; color: var(--primary); text-transform: uppercase; letter-spacing: .4px; }
.continue-reading-subject { font-size: 14px; font-weight: 800; color: var(--text); }
.continue-reading-section { font-size: 12px; font-weight: 600; color: var(--text-mid); }
.continue-reading-chapter { font-size: 13px; color: var(--text-mid); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.continue-reading-arrow { color: var(--primary); font-size: 16px; flex-shrink: 0; }

/* ── SUBJECT SHELF ─────────────────────────── */
.subject-shelf { flex: 1; display: flex; flex-direction: column; overflow: visible; animation: fadeUp .3s ease; }
.subject-shelf-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
  padding-bottom: 14px;
  border-bottom: 2px solid var(--border);
  flex-shrink: 0;
  flex-wrap: wrap;
}
.shelf-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  transition: var(--ease);
}
.shelf-back-btn:hover { border-color: var(--primary); color: var(--primary); }
.shelf-info { flex: 1; min-width: 0; }
.shelf-badge { display: inline-block; margin-bottom: 2px; padding: 2px 8px; border-radius: 20px; background: var(--primary); color: #fff; font-size: 11px; font-weight: 700; }
.shelf-info h2 { font-size: clamp(17px, 2.5vw, 22px); line-height: 1.2; }
.shelf-chapter-count { color: var(--text-soft); font-size: 13px; font-weight: 700; flex-shrink: 0; }

.shelf-scroll { flex: 1; overflow: visible; }
.shelf-chapters-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }

/* ── CURRICULUM VIEW (Syllabus Style) ──────────────── */
.curriculum-wrapper { width: 100%; display: flex; flex-direction: column; gap: 16px; }

.curriculum-tabs-wrapper {
  display: flex;
  gap: 8px;
  flex-wrap: wrap; /* Wraps instead of scrolling */
  padding-bottom: 4px;
}

.curriculum-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 24px;
  background: var(--bg);
  color: var(--text-mid);
  border: 1.5px solid var(--border);
  font-size: 13px;
  font-weight: 700;
  transition: var(--ease);
}
.curriculum-tab-btn:hover {
  border-color: var(--tab-color, var(--primary));
  color: var(--tab-color, var(--primary));
}
.curriculum-tab-btn.active {
  background: var(--tab-color, var(--primary));
  color: #fff;
  border-color: transparent;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.curriculum-section { display: flex; flex-direction: column; gap: 16px; margin-top: 4px; }

.curriculum-chapter-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}
.curriculum-chapter-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 14px;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 8px rgba(0,0,0,0.02);
  position: relative;
  overflow: hidden;
}
.curriculum-chapter-item::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; height: 4px;
  background: var(--sec-color, var(--primary));
  opacity: 0.8;
  transition: var(--ease);
}
.curriculum-chapter-item:hover, .curriculum-chapter-item.active {
  border-color: var(--sec-color, var(--primary));
  box-shadow: 0 12px 24px rgba(0,0,0,0.08);
  transform: translateY(-4px);
}
.curriculum-chapter-item:hover::before, .curriculum-chapter-item.active::before {
  opacity: 1;
  height: 6px;
}
.curriculum-chapter-item.active {
  background: linear-gradient(to bottom right, var(--surface), var(--bg));
}
.curr-ch-num {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: 10px;
  background: var(--bg);
  color: var(--sec-color, var(--primary));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 900;
  border: 1px solid var(--border);
  transition: var(--ease);
}
.curriculum-chapter-item:hover .curr-ch-num, .curriculum-chapter-item.active .curr-ch-num {
  background: var(--sec-color, var(--primary));
  color: #fff;
  border-color: transparent;
  transform: scale(1.05) rotate(-3deg);
}
.curr-ch-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.curr-ch-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--text);
  line-height: 1.35;
}
.curr-ch-author {
  font-size: 13px;
  color: var(--text-soft);
  font-style: italic;
}
.curr-ch-arrow {
  position: absolute;
  bottom: 20px;
  right: 20px;
  color: var(--sec-color, var(--primary));
  font-size: 14px;
  opacity: 0;
  transform: translateX(-10px);
  transition: all 0.3s ease;
}
.curriculum-chapter-item:hover .curr-ch-arrow, .curriculum-chapter-item.active .curr-ch-arrow {
  opacity: 1;
  transform: translateX(0);
}
.curriculum-empty {
  padding: 40px;
  text-align: center;
  color: var(--text-soft);
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  font-size: 15px;
  font-weight: 600;
}
.curriculum-empty i {
  display: block;
  font-size: 32px;
  margin-bottom: 12px;
  opacity: 0.5;
}

/* ── WRAPPER READER (Enables Natural Page Scroll) ── */
.notes-reader {
  flex: 1;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: visible;
}

.notes-reader-topbar {
  flex-shrink: 0;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 14px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
}
.notes-reader-back-btn, .notes-reader-action-btn {
  border: 1px solid rgba(255,255,255,.28);
  border-radius: 7px;
  background: rgba(255,255,255,.16);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transition: var(--ease);
  min-height: 32px;
}
.notes-reader-back-btn { padding: 5px 11px; font-size: 13px; font-weight: 700; white-space: nowrap; }
.notes-reader-action-btn { width: 34px; font-size: 13px; }
.notes-reader-back-btn:hover, .notes-reader-action-btn:hover { background: rgba(255,255,255,.3); }
.notes-reader-title { flex: 1; min-width: 0; color: #fff; font-size: 14px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 6px; }
.notes-reader-actions { display: flex; align-items: center; gap: 6px; }

.notes-reader-body { flex: 1; display: flex; overflow: visible; background: #fff; }
.notes-reader-inner {
  flex: 1;
  overflow: visible;
  padding: clamp(18px, 3vw, 34px);
  max-width: 850px;
  width: 100%;
  margin: 0 auto;
}

.notes-reader-pagination {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px clamp(14px, 3vw, 28px);
  border-top: 1px solid var(--border);
  background: var(--bg);
}
.notes-page-btn {
  min-height: 34px;
  padding: 6px 14px;
  border-radius: 7px;
  background: var(--primary);
  color: #fff;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  font-weight: 700;
  transition: var(--ease);
}
.notes-page-btn:hover:not(:disabled) { background: var(--primary-dark); transform: translateY(-1px); }
.notes-page-btn:disabled { background: var(--border); color: var(--text-soft); cursor: not-allowed; }
#notes-page-indicator { font-size: 13px; font-weight: 700; color: var(--text-soft); }

.reader-progress-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 0;
  max-width: 280px;
}
.progress-bar {
  width: 100%;
  height: 6px;
  border-radius: 20px;
  background: var(--border);
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  width: 0%;
  border-radius: 20px;
  background: linear-gradient(90deg, var(--primary), var(--primary-light));
  transition: width .35s ease;
}
.progress-text { font-size: 11px; font-weight: 700; color: var(--text-soft); }

.notes-loading-skeleton {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  min-height: 240px;
  color: var(--text-soft);
  text-align: center;
}
.notes-loading-spinner { font-size: 32px; color: var(--primary); opacity: .7; }
.notes-loading-skeleton p { font-size: 15px; font-weight: 600; color: var(--text-mid); }

.notes-reader-action-btn.bookmarked { background: rgba(255,255,255,.35); color: #fde68a; }

/* ── READER CONTENT LAYOUT RULES ───────────── */
.reader-section { margin-bottom: 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); overflow: hidden; }
.reader-section-header { padding: 11px 15px; border-bottom: 1px solid var(--border); background: #fff; }
.reader-section-header h2 { display: flex; align-items: center; gap: 7px; font-size: 14px; font-weight: 800; color: var(--text); }
.reader-section-header h2 i { color: var(--primary); font-size: 13px; }
.reader-section-body { padding: 17px; }
.reader-section-body p { color: var(--text-mid); font-size: 15.5px; line-height: 1.95; }
.reader-section-body p + p { margin-top: 12px; }
.reader-section-body, .eng-qa-answer, .math-topic-body, .gr-topic-body { overflow-wrap: anywhere; }

.eng-trick-section { border-color: #fcd34d; }
.eng-trick-header { background: linear-gradient(135deg,#fef3c7,#fde68a) !important; border-bottom-color: #fcd34d !important; }
.eng-trick-header h2, .eng-trick-header h2 i { color: #92400e !important; }
.eng-trick-body { background: #fffbeb !important; }
.eng-trick-badge { display: inline-flex; align-items: center; gap: 7px; margin-bottom: 12px; padding: 8px 13px; border: 1px solid #f59e0b; border-radius: 8px; background: #fef3c7; color: #92400e; font-size: 13px; font-weight: 600; }
.eng-trick-label { margin-bottom: 7px; font-size: 13px; font-weight: 800; color: var(--text); }
.eng-trick-flow { padding-left: 18px; display: flex; flex-direction: column; gap: 3px; }
.eng-trick-flow li { padding: 5px 0; border-bottom: 1px dashed var(--border); color: var(--text-mid); font-size: 13px; line-height: 1.6; }
.eng-trick-flow li:last-child { border-bottom: none; }

.eng-qa-list { display: flex; flex-direction: column; gap: 14px; }
.eng-qa-item { border: 1px solid var(--border); border-radius: 10px; background: #fff; overflow: hidden; }
.eng-qa-question { display: flex; align-items: flex-start; gap: 10px; padding: 11px 13px; border-bottom: 1px solid var(--border); background: var(--bg); }
.eng-qa-num { width: 22px; height: 22px; flex-shrink: 0; margin-top: 2px; border-radius: 50%; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 800; }
.eng-q-text { font-size: 14.5px; font-weight: 700; color: var(--text); line-height: 1.65; margin-bottom: 4px; }
.eng-word-limit { display: inline-block; padding: 1px 6px; border: 1px solid var(--border); border-radius: 20px; background: #fff; color: var(--text-soft); font-size: 11px; }
.eng-qa-answer { padding: 13px 15px; }
.eng-qa-answer p { font-size: 15px; color: var(--text-mid); line-height: 1.95; }
.eng-qa-answer p + p { margin-top: 10px; }

.reader-key-points { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.reader-key-points li { display: flex; align-items: flex-start; gap: 8px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 7px; background: #fff; font-size: 13px; color: var(--text); line-height: 1.6; }
.reader-key-points li::before { content: "✓"; flex-shrink: 0; color: var(--green); font-weight: 800; }

/* ── GRAMMAR COMPONENTS ────────────────────── */
.gr-topic { margin-bottom: 14px; border-radius: var(--radius); border: 1.5px solid var(--border); background: var(--surface); overflow: hidden; transition: box-shadow .2s; }
.gr-topic:hover { box-shadow: var(--shadow-md); }
.gr-topic-header { display: flex; align-items: center; gap: 10px; padding: 11px 15px; background: var(--bg); border-bottom: 1.5px solid var(--border); }
.gr-topic-icon { width: 32px; height: 32px; flex-shrink: 0; border-radius: 8px; color: #fff; display: flex; align-items: center; justify-content: center; font-size: 13px; }
.gr-topic-title { font-size: 14.5px; font-weight: 800; color: var(--text); flex: 1; }
.gr-topic-body { padding: 16px 18px; }

.gr-def-english { font-size: 15px; color: var(--text); line-height: 1.85; margin-bottom: 8px; }
.gr-def-nepali { font-size: 14px; color: var(--text-mid); line-height: 1.85; padding: 10px 14px; border-left: 3px solid var(--primary); background: #f0f7ff; border-radius: 0 8px 8px 0; margin-bottom: 12px; }
.gr-examples { display: flex; flex-direction: column; gap: 5px; margin-bottom: 10px; }
.gr-example-item { padding: 7px 12px; border: 1px solid var(--border); border-radius: 7px; background: #fff; font-size: 14px; color: var(--text-mid); line-height: 1.6; }
.gr-example-item mark { background: #dbeafe; color: #1d4ed8; padding: 1px 3px; border-radius: 3px; font-weight: 700; }
.gr-tip { display: inline-flex; align-items: center; gap: 7px; padding: 7px 12px; border-radius: 8px; background: #ecfdf5; border: 1px solid #6ee7b7; color: #065f46; font-size: 13px; font-weight: 600; margin-top: 4px; }
.gr-tip i { color: #059669; font-size: 12px; }

.gr-table-wrapper { overflow-x: auto; border-radius: 9px; border: 1px solid var(--border); }
.gr-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.gr-table thead tr { background: linear-gradient(135deg, var(--primary), var(--primary-light)); color: #fff; }
.gr-table thead th { padding: 10px 14px; text-align: left; font-weight: 700; font-size: 13px; white-space: nowrap; }
.gr-table tbody tr:nth-child(even) { background: var(--bg); }
.gr-table tbody tr:nth-child(odd) { background: #fff; }
.gr-table tbody td { padding: 9px 14px; color: var(--text-mid); border-top: 1px solid var(--border); font-size: 13.5px; line-height: 1.6; }
.gr-table tbody td mark { background: #dbeafe; color: #1d4ed8; padding: 1px 3px; border-radius: 3px; font-weight: 700; }
.gr-table-rule { font-size: 13px; color: var(--text-mid); margin-bottom: 10px; padding: 8px 12px; background: #f0f7ff; border-radius: 7px; border-left: 3px solid var(--primary); }
.gr-table-rule strong { color: var(--primary); }

.gr-topic.exam-trap { border-color: #fca5a5; }
.gr-topic.exam-trap .gr-topic-header { background: linear-gradient(135deg, #fef2f2, #fee2e2); border-bottom-color: #fca5a5; }
.gr-topic.exam-trap .gr-topic-title { color: #991b1b; }
.gr-trap-label { display: flex; align-items: center; gap: 7px; padding: 8px 12px; border-radius: 8px; background: #fee2e2; border: 1px solid #fca5a5; color: #991b1b; font-size: 13px; font-weight: 700; margin-bottom: 12px; }

.gr-topic.important-rule { border-color: #c4b5fd; }
.gr-topic.important-rule .gr-topic-header { background: linear-gradient(135deg, #f5f3ff, #ede9fe); border-bottom-color: #c4b5fd; }
.gr-topic.important-rule .gr-topic-title { color: #5b21b6; }
.gr-rule-box { padding: 10px 14px; border-radius: 8px; background: #f5f3ff; border-left: 3px solid #7c3aed; color: #4c1d95; font-size: 14px; font-weight: 600; margin-bottom: 14px; line-height: 1.7; }
.gr-rule-box strong { color: #7c3aed; }
.gr-linking-verbs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.gr-lv-pill { padding: 4px 11px; border-radius: 20px; border: 1px solid #c4b5fd; background: #ede9fe; color: #5b21b6; font-size: 12px; font-weight: 700; font-family: monospace; }

.gr-correct-wrong { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top:12px; }
.gr-correct-list, .gr-wrong-list { display: flex; flex-direction: column; gap: 6px; padding: 10px; border-radius: 8px; }
.gr-correct-list { background: #f0fdf4; border: 1px solid #86efac; }
.gr-wrong-list { background: #fef2f2; border: 1px solid #fca5a5; }
.gr-correct-list .label, .gr-wrong-list .label { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .5px; margin-bottom: 4px; }
.gr-correct-list .label { color: #15803d; }
.gr-wrong-list .label { color: #dc2626; }
.gr-correct-list span, .gr-wrong-list span { font-size: 13.5px; line-height: 1.6; }
.gr-correct-list span { color: #166534; }
.gr-wrong-list span { color: #991b1b; }
.gr-correct-list mark { background: #bbf7d0; color: #15803d; padding: 1px 3px; border-radius: 3px; font-weight: 700; }

/* ── RESTORED: TYPES GRID ── */
.gr-types-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.gr-type-card { padding: 12px 14px; border-radius: 10px; border: 1.5px solid var(--border); background: var(--bg); transition: var(--ease); }
.gr-type-card:hover { border-color: var(--card-color, var(--primary)); transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.gr-type-name { font-size: 13px; font-weight: 800; color: var(--text); margin-bottom: 3px; }
.gr-type-desc { font-size: 12px; color: var(--text-soft); margin-bottom: 8px; }
.gr-type-examples { display: flex; flex-wrap: wrap; gap: 4px; }
.gr-type-ex-tag { padding: 2px 8px; border-radius: 20px; background: #fff; border: 1px solid var(--border); font-size: 11.5px; color: var(--text-mid); }

/* ── RESTORED: MISTAKES LIST ── */
.gr-mistakes-list { display: flex; flex-direction: column; gap: 8px; }
.gr-mistake-row { display: flex; align-items: center; gap: 0; border: 1px solid var(--border); border-radius: 9px; overflow: hidden; font-size: 13.5px; }
.gr-mistake-wrong { flex: 1; padding: 9px 14px; background: #fef2f2; color: #991b1b; text-decoration: line-through; text-decoration-color: #dc2626; }
.gr-mistake-arrow { padding: 0 10px; background: #fff; color: var(--text-soft); font-size: 14px; border-left: 1px solid var(--border); border-right: 1px solid var(--border); align-self: stretch; display: flex; align-items: center; }
.gr-mistake-correct { flex: 1; padding: 9px 14px; background: #f0fdf4; color: #15803d; font-weight: 700; }

/* ── RESTORED: PRACTICE COMPONENTS ── */
.gr-practice-level-badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 20px; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .5px; margin-bottom: 14px; }
.gr-practice-level-badge.easy { background: #dcfce7; color: #15803d; border: 1px solid #86efac; }
.gr-practice-level-badge.medium { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }
.gr-practice-level-badge.hard { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }

.gr-practice-list { display: flex; flex-direction: column; gap: 10px; }
.gr-practice-item { border: 1px solid var(--border); border-radius: 10px; background: #fff; overflow: hidden; }
.gr-practice-q { padding: 10px 14px; background: var(--bg); border-bottom: 1px solid var(--border); display: flex; gap: 10px; align-items: flex-start; }
.gr-practice-num { width: 22px; height: 22px; flex-shrink: 0; border-radius: 50%; color: #fff; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 800; margin-top: 2px; }
.gr-practice-q-text { font-size: 14px; font-weight: 700; color: var(--text); flex: 1; line-height: 1.6; }
.gr-practice-options { padding: 10px 14px; display: flex; gap: 8px; flex-wrap: wrap; }
.gr-option-btn { padding: 5px 14px; border: 1.5px solid var(--border); border-radius: 20px; background: #fff; color: var(--text); font-size: 13px; font-weight: 600; cursor: pointer; transition: var(--ease); }
.gr-option-btn:hover { border-color: var(--practice-color, var(--primary)); color: var(--practice-color, var(--primary)); }
.gr-option-btn.correct { background: #dcfce7; border-color: #16a34a; color: #15803d; }
.gr-option-btn.wrong { background: #fee2e2; border-color: #dc2626; color: #991b1b; }
.gr-option-btn.reveal { background: #dcfce7; border-color: #16a34a; color: #15803d; }

.gr-practice-feedback { padding: 8px 14px; font-size: 12.5px; font-weight: 600; border-top: 1px solid var(--border); display: none; }
.gr-practice-feedback.show { display: block; }
.gr-practice-feedback.ok { background: #f0fdf4; color: #15803d; }
.gr-practice-feedback.no { background: #fef2f2; color: #991b1b; }

.gr-topic.practice-block { border-color: var(--practice-border, var(--border)); }

/* ── RESTORED: OPEN-ENDED INPUT FIELD RULES ──────────── */
.gr-practice-input-group { display: flex; gap: 10px; padding: 12px 14px; flex-wrap: wrap; align-items: center; }
.gr-practice-input { flex: 1; min-width: 220px; padding: 9px 14px; border: 1.5px solid var(--border); border-radius: 8px; font-size: 13.5px; color: var(--text); background: #ffffff; outline: none; transition: var(--ease); }
.gr-practice-input:focus { border-color: var(--practice-color, var(--primary)); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1); }
.gr-practice-input:disabled { background: var(--bg); color: var(--text-mid); cursor: not-allowed; }

.gr-action-btn { padding: 9px 16px; border-radius: 8px; font-size: 12.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; border: 0; cursor: pointer; transition: var(--ease); }
.gr-check-btn { background: var(--primary-color); color: #ffffff; box-shadow: var(--shadow-sm); }
.gr-check-btn:hover:not(:disabled) { background: var(--primary-dark); transform: translateY(-1px); }
.gr-reveal-btn { background: var(--background-light); border: 1px solid var(--border-color); color: var(--text-medium); }
.gr-reveal-btn:hover:not(:disabled) { background: var(--border-color); color: var(--text-dark); }
.gr-action-btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none !important; }

/* ── CHARTS & GRAPHS RESPONSIVE CSS ─────────── */
.gr-chart-svg-wrap svg { overflow: visible; }
.gr-chart-wrapper { width: 100%; padding: 4px 0; }
.gr-chart-bars { display: flex; flex-direction: column; gap: 14px; }
.gr-chart-row { display: flex; flex-direction: column; gap: 6px; width: 100%; }
.gr-chart-info { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.gr-chart-label { font-size: 13.5px; font-weight: 700; color: var(--text); }
.gr-chart-percentage-text { font-size: 13px; font-weight: 800; font-family: monospace; }
.gr-chart-track { width: 100%; height: 14px; background: var(--bg); border: 1px solid var(--border); border-radius: 20px; overflow: hidden; }
.gr-chart-fill { height: 100%; border-radius: 20px; transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1); }

/* Model Chart Wrapper */
.gr-model-chart-box {
  border: 1px solid var(--border, #e2e8f0);
  border-radius: var(--radius, 8px);
  background: var(--bg, #ffffff);
  padding: 24px 16px 16px 16px;
  margin: 16px 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ── LAYOUT ANIMATIONS ─────────────────────── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============================================
    RESPONSIVE BREAKPOINTS 
   ============================================ */

@media (max-width: 768px) {
  :root { --header-h: 70px; } 

  body { padding-top: calc(var(--header-h) + 12px); } 
  .notes-container { padding: 8px; } 
  .notes-main { padding: 10px; border-radius: 10px; }
  .quick-cards { grid-template-columns: 1fr; }
  .subject-shelf-header { flex-wrap: nowrap; gap: 8px; margin-bottom: 10px; padding-bottom: 10px; }
  .shelf-back-btn { padding: 6px 9px; font-size: 12px; }
  .shelf-info h2 { font-size: 17px; }
  .shelf-badge { font-size: 10px; padding: 1px 7px; }
  .shelf-chapter-count { width: auto; font-size: 11px; white-space: nowrap; }
  .shelf-chapters-grid { grid-template-columns: 1fr; }
  
  .curriculum-chapter-list {
    grid-template-columns: 1fr; /* Force 1 column on mobile for cards */
  }
  .curriculum-chapter-item {
    padding: 16px;
    gap: 12px;
  }
  .curr-ch-num {
    width: 32px;
    height: 32px;
    font-size: 13px;
  }
  .curr-ch-title {
    font-size: 15px;
  }
  .curr-ch-author {
    font-size: 12px;
  }

  .notes-reader-title { 
    display: block !important;
    font-size: 13px !important; 
    font-weight: 700 !important;
    text-align: center !important;
    white-space: normal !important; 
    word-break: break-word !important;
  }
  
  .notes-reader-topbar { height: auto !important; padding: 8px 12px !important; }
  .notes-reader-back-btn { padding: 5px 9px; }
  .notes-reader-action-btn { width: 32px; }
  .notes-reader-pagination { padding: 8px 10px; }
  .notes-page-btn { padding: 6px 10px; font-size: 12px; }
  .notes-reader-inner { padding: 10px; }
  .reader-section { margin-bottom: 10px; border-radius: 9px; }
  .reader-section-header { padding: 8px 10px; }
  .reader-section-header h2 { font-size: 13px; line-height: 1.35; }
  .reader-section-body { padding: 11px; }
  
  .reader-section-body p, .eng-qa-answer p { font-size: 14px; line-height: 1.75; }
  .eng-qa-list { gap: 10px; }
  .eng-qa-question { padding: 9px 10px; gap: 8px; }
  .eng-qa-answer { padding: 10px; }
  .eng-q-text { font-size: 13.5px; line-height: 1.55; }
  .gr-correct-wrong { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .gr-types-grid { grid-template-columns: 1fr; }
  .gr-table thead th, .gr-table tbody td { padding: 8px 10px; font-size: 12.5px; }

  .notes-reader-pagination { flex-direction: column; gap: 12px; }
  .notes-page-btn { width: 100%; justify-content: center; }
  .reader-progress-wrap { max-width: 100%; width: 100%; }
}

@media (max-width: 480px) {
  .subject-shelf-header { align-items: flex-start; }
  .shelf-chapter-count { display: none; }
  .notes-reader-back-btn span { display: none; }
  #notes-page-indicator { font-size: 11px; }

  .gr-practice-input-group { flex-direction: column; align-items: stretch; gap: 8px; }
  .gr-practice-input { width: 100%; }
}

/* ══════════════════════════════════════════════
   CLASS 12 MATHEMATICS — Full Component System
   ══════════════════════════════════════════════ */

/* ── MATH TOPIC BLOCK (base wrapper) ─────────── */
.math-topic-block {
  margin-bottom: 14px;
  border-radius: var(--radius);
  border: 1.5px solid var(--border);
  background: var(--surface);
  overflow: hidden;
  transition: box-shadow .2s;
}
.math-topic-block:hover { box-shadow: var(--shadow-md); }

.math-topic-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 15px;
  background: var(--bg);
  border-bottom: 1.5px solid var(--border);
}
.math-topic-icon {
  width: 32px; height: 32px;
  flex-shrink: 0;
  border-radius: 8px;
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
}
.math-topic-title { font-size: 14.5px; font-weight: 800; color: var(--text); flex: 1; }
.math-topic-body  { padding: 16px 18px; }

/* ── DEFINITION ───────────────────────────────── */
.math-def-text {
  font-size: 15px; color: var(--text);
  line-height: 1.85; margin-bottom: 10px;
}
.math-def-nepali {
  font-size: 14px; color: var(--text-mid);
  line-height: 1.85; padding: 10px 14px;
  border-left: 3px solid var(--primary);
  background: #f0f7ff;
  border-radius: 0 8px 8px 0;
  margin-bottom: 12px;
}

/* ── FORMULA BOX ──────────────────────────────── */
.math-formula-inline {
  background: #f8faff; border: 1px solid #dbeafe;
  border-radius: 8px; padding: 10px 16px;
  text-align: center; margin: 10px 0; overflow: visible;
}
.math-formula-box {
  display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px;
}
.math-formula-row {
  background: #f8faff;
  border: 1px solid #dbeafe;
  border-left: 4px solid var(--primary);
  border-radius: 0 8px 8px 0;
  padding: 12px 16px;
}
.math-formula-label {
  font-size: 11.5px; font-weight: 800; color: var(--primary);
  text-transform: uppercase; letter-spacing: .5px; margin-bottom: 6px;
}
.math-formula-katex   { overflow: visible; font-size: 15px; padding: 4px 0; }
.math-formula-note    { font-size: 12px; color: var(--text-soft); margin-top: 5px; }
.math-formula-katex-block {
  text-align: center; padding: 14px;
  background: #f8faff; border-radius: 8px;
  margin: 10px 0; overflow: visible;
}
.math-tip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 12px; border-radius: 8px;
  background: #ecfdf5; border: 1px solid #6ee7b7;
  color: #065f46; font-size: 13px; font-weight: 600; margin-top: 6px;
}
.math-tip i { color: #059669; font-size: 12px; }

/* ── TRICK ────────────────────────────────────── */
.math-trick-badge {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 14px; border-radius: 8px;
  background: #fef3c7; border: 1px solid #fcd34d;
  color: #92400e; font-size: 13px; font-weight: 700; margin-bottom: 12px;
}
.math-trick-label { font-size: 13px; font-weight: 800; color: var(--text); margin-bottom: 8px; }
.math-trick-flow  { padding-left: 20px; display: flex; flex-direction: column; gap: 3px; }
.math-trick-flow li {
  padding: 5px 0; border-bottom: 1px dashed var(--border);
  color: var(--text-mid); font-size: 13px; line-height: 1.6;
}
.math-trick-flow li:last-child { border-bottom: none; }
.math-mnemonic {
  margin-top: 10px; padding: 8px 12px;
  background: #ede9fe; border-radius: 7px; color: #5b21b6; font-size: 13px;
}

/* ── THEOREM ──────────────────────────────────── */
.math-theorem-block { border-color: #7c3aed; }
.math-theorem-block .math-topic-header { background: linear-gradient(135deg,#f5f3ff,#ede9fe); border-bottom-color: #c4b5fd; }
.math-theorem-block .math-topic-title  { color: #5b21b6; }
.math-theorem-statement {
  font-size: 15px; font-style: italic;
  color: var(--text); line-height: 1.85;
  padding: 12px 16px;
  background: #f5f3ff;
  border-left: 4px solid #7c3aed;
  border-radius: 0 8px 8px 0; margin-bottom: 12px;
}
.math-proof-label { font-size: 13px; font-weight: 800; color: var(--text); margin-bottom: 8px; }
.math-proof-steps { display: flex; flex-direction: column; gap: 6px; }
.math-proof-step {
  display: flex; gap: 10px;
  padding: 7px 12px;
  border: 1px solid var(--border); border-radius: 7px;
  background: #fff; font-size: 13.5px; color: var(--text-mid); line-height: 1.6;
}
.math-proof-num {
  width: 22px; height: 22px; flex-shrink: 0; border-radius: 50%;
  background: #7c3aed; color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 800;
}

/* ── IMPORTANT / NOTE ────────────────────────── */
.math-important-block { border-color: #f59e0b; }
.math-important-block .math-topic-header { background: linear-gradient(135deg,#fffbeb,#fef3c7); border-bottom-color: #fcd34d; }
.math-important-block .math-topic-title  { color: #92400e; }
.math-important-box {
  background: #fffbeb; border: 1px solid #fcd34d;
  border-radius: 8px; padding: 14px 16px;
  font-size: 14px; color: var(--text); line-height: 1.8;
}
.math-important-points { padding-left: 20px; margin-top: 8px; display: flex; flex-direction: column; gap: 4px; }
.math-important-points li { color: var(--text-mid); font-size: 13.5px; line-height: 1.6; }

/* ── DIAGRAM ──────────────────────────────────── */
.math-diagram-wrap {
  background: #fff; border: 1px solid var(--border);
  border-radius: 8px; padding: 20px; text-align: center; overflow: visible;
}
.math-diagram-wrap svg { max-width: 100%; height: auto; }
.math-diagram-caption { text-align: center; font-size: 12.5px; color: var(--text-soft); margin-top: 8px; font-style: italic; }

/* ── CARD FORMULA (types grid) ───────────────── */
.math-card-formula { font-size: 13px; color: var(--primary); margin: 3px 0 5px; overflow: visible; }

/* ── MCQ ──────────────────────────────────────── */
.math-practice-block { border-color: #3b82f6; }
.math-practice-block .math-topic-header { background: linear-gradient(135deg,#eff6ff,#dbeafe); border-bottom-color: #93c5fd; }
.math-practice-block .math-topic-title  { color: #1d4ed8; }
.math-mcq-list { display: flex; flex-direction: column; gap: 12px; }
.math-mcq-item { border: 1px solid var(--border); border-radius: 10px; background: #fff; overflow: hidden; }
.math-mcq-q {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 11px 13px; background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.math-mcq-num {
  width: 24px; height: 24px; flex-shrink: 0; border-radius: 50%;
  background: #3b82f6; color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 800; margin-top: 2px;
}
.math-mcq-text { font-size: 14.5px; font-weight: 700; color: var(--text); line-height: 1.65; flex: 1; overflow: visible; }
.math-mcq-options { padding: 10px 14px; display: flex; gap: 8px; flex-wrap: wrap; }
.math-opt-btn {
  padding: 6px 16px; border: 1.5px solid var(--border);
  border-radius: 20px; background: #fff; color: var(--text);
  font-size: 13px; font-weight: 600; cursor: pointer;
  transition: var(--ease); overflow: visible;
}
.math-opt-btn:hover:not(:disabled) { border-color: #3b82f6; color: #3b82f6; }
.math-opt-btn.correct { background: #dcfce7; border-color: #16a34a; color: #15803d; }
.math-opt-btn.wrong   { background: #fee2e2; border-color: #dc2626; color: #991b1b; }
.math-opt-btn:disabled { cursor: not-allowed; }
.math-toggle-sol-btn {
  margin-left: 10px; padding: 3px 10px; border-radius: 6px;
  background: rgba(255,255,255,.22); border: 1px solid rgba(255,255,255,.4);
  color: inherit; font-size: 12px; font-weight: 700; cursor: pointer;
  display: inline-flex; align-items: center; gap: 5px; vertical-align: middle;
  transition: var(--ease);
}
.math-mcq-solution { padding: 0 14px 12px; }

/* ── SHORT / LONG ANSWER ─────────────────────── */
.math-qa-block { border-color: #059669; }
.math-qa-block .math-topic-header { background: linear-gradient(135deg,#ecfdf5,#d1fae5); border-bottom-color: #6ee7b7; }
.math-qa-block .math-topic-title  { color: #065f46; }
.math-qa-list   { display: flex; flex-direction: column; gap: 14px; }
.math-qa-item   { border: 1px solid var(--border); border-radius: 10px; background: #fff; overflow: hidden; }
.math-qa-question {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px; background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.math-qa-num {
  width: 26px; height: 26px; flex-shrink: 0; border-radius: 50%;
  background: #059669; color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 800; margin-top: 2px;
}
.math-qa-text  { font-size: 14.5px; font-weight: 700; color: var(--text); line-height: 1.7; overflow: visible; }
.math-qa-marks {
  display: inline-block; margin-top: 5px;
  padding: 2px 8px; background: #fff;
  border: 1px solid var(--border); border-radius: 20px;
  color: var(--text-soft); font-size: 11px; font-weight: 700;
}
.math-qa-action   { padding: 10px 14px; border-bottom: 1px solid var(--border); }
.math-reveal-btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 16px; border-radius: 8px;
  background: #059669; color: #fff;
  font-size: 13px; font-weight: 700; border: 0; cursor: pointer;
  transition: var(--ease);
}
.math-reveal-btn:hover { background: #047857; transform: translateY(-1px); }
.math-qa-solution { padding: 0 14px 14px; }
.math-hide-btn {
  display: inline-flex; align-items: center; gap: 7px;
  margin-top: 10px; padding: 6px 14px; border-radius: 8px;
  background: var(--bg); border: 1px solid var(--border);
  color: var(--text-mid); font-size: 12.5px; font-weight: 700;
  cursor: pointer; transition: var(--ease);
}
.math-hide-btn:hover { background: #fee2e2; border-color: #fca5a5; color: #dc2626; }

/* ── COPY-STYLE SOLUTION ─────────────────────── */
.math-copy-solution {
  margin-top: 14px;
  border: 1.5px solid #dbeafe;
  border-radius: 10px;
  overflow: hidden;
  background: #f8faff;
  font-family: "DM Sans", sans-serif;
}
.math-copy-header {
  padding: 8px 14px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff; font-size: 13px; font-weight: 800;
  display: flex; align-items: center; gap: 7px;
}
.math-copy-steps {
  padding: 12px 16px;
  display: flex; flex-direction: column; gap: 0;
  border-bottom: 1.5px solid #dbeafe;
}
.math-copy-step {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 8px 0;
  border-bottom: 1px dashed #dbeafe;
  font-size: 14px; color: var(--text); line-height: 1.75; overflow: visible;
}
.math-copy-step:last-child { border-bottom: none; }
.math-copy-step-label {
  flex-shrink: 0; font-size: 11px; font-weight: 800;
  color: var(--primary); padding-top: 3px; min-width: 50px;
}
.math-copy-step-content { flex: 1; overflow: visible; }
.math-copy-step-last .math-copy-step-content { font-weight: 600; color: var(--text); }
.math-copy-answer {
  display: flex; align-items: center; justify-content: flex-end;
  gap: 12px; padding: 12px 20px;
  background: linear-gradient(135deg, #f0fdf4, #dcfce7);
  border-top: 1.5px solid #86efac;
}
.math-therefore   { font-size: 26px; font-weight: 900; color: #15803d; line-height: 1; }
.math-answer-text { font-size: 16px; font-weight: 800; color: #166534; overflow: visible; }

/* ── KATEX OVERFLOW FIX ──────────────────────── */
.katex-display { overflow: visible; white-space: normal; padding: 4px 0; }
.katex { font-size: 1rem; }

/* ── MATH RESPONSIVE ─────────────────────────── */
@media (max-width: 768px) {
  .katex { font-size: .85rem; }

  .math-topic-block, .gr-topic { margin-bottom: 10px; border-radius: 9px; }
  .math-topic-header, .gr-topic-header { padding: 8px 10px; gap: 8px; }
  .math-topic-icon, .gr-topic-icon { width: 28px; height: 28px; border-radius: 7px; font-size: 12px; }
  .math-topic-title, .gr-topic-title { font-size: 13.5px; line-height: 1.35; }
  .math-topic-body, .gr-topic-body { padding: 11px; }
  .math-def-text, .gr-def-english { font-size: 14px; line-height: 1.7; }
  .math-def-nepali, .gr-def-nepali { font-size: 13px; line-height: 1.65; padding: 8px 10px; }
  .math-copy-step  { flex-direction: column; gap: 3px; }
  .math-copy-step-label { min-width: unset; }
  .math-mcq-options { gap: 6px; }
  .math-opt-btn { padding: 6px 12px; font-size: 12.5px; }
  .math-formula-row { padding: 10px 12px; }
  .math-copy-answer { padding: 10px 14px; }
  .math-answer-text { font-size: 14.5px; }
}

/* ══════════════════════════════════════════════
   MATH — UPGRADED COMPONENTS (Saroj 2025)
   Only affects math JSON rendering. English/Grammar untouched.
   ══════════════════════════════════════════════ */

/* ── CHAPTER OVERVIEW ─────────────────────────── */
.math-overview-intro {
  position: relative;
  background: linear-gradient(135deg, #eff6ff 0%, #f0f9ff 100%);
  border: 1.5px solid #bfdbfe;
  border-radius: 12px;
  padding: 18px 20px 18px 56px;
  font-size: 15px;
  color: var(--text);
  line-height: 1.85;
  margin-bottom: 16px;
}
.math-overview-intro::before {
  content: "\f518"; /* fa-compass */
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
  position: absolute;
  left: 18px;
  top: 18px;
  font-size: 20px;
  color: #2563eb;
}

.math-overview-chips-label {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-mid);
  margin-bottom: 10px;
}
.math-overview-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.math-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 13px;
  border-radius: 20px;
  background: #eff6ff;
  border: 1.5px solid #bfdbfe;
  color: #1d4ed8;
  font-size: 12.5px;
  font-weight: 700;
  transition: var(--ease);
}
.math-chip:hover { background: #dbeafe; border-color: #3b82f6; }
.math-chip::before {
  content: "✓";
  color: #2563eb;
  font-size: 11px;
  font-weight: 900;
}

/* ── LEARNING OBJECTIVES ──────────────────────── */
.math-obj-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.math-obj-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  background: #fff;
  border: 1.5px solid #e0e7ff;
  border-left: 4px solid #4f46e5;
  border-radius: 0 10px 10px 0;
  font-size: 14px;
  color: var(--text);
  line-height: 1.7;
  transition: var(--ease);
}
.math-obj-item:hover {
  background: #f5f3ff;
  border-left-color: #7c3aed;
  border-color: #c4b5fd;
  border-left-color: #7c3aed;
  transform: translateX(2px);
}
.math-obj-num {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 800;
  margin-top: 1px;
}

/* ── DEFINITIONS ──────────────────────────────── */
.math-def-cards {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.math-def-card {
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: #fff;
  overflow: hidden;
  transition: var(--ease);
}
.math-def-card:hover {
  border-color: #93c5fd;
  box-shadow: 0 4px 12px rgba(37,99,235,0.08);
}
.math-def-term-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: linear-gradient(135deg, #eff6ff, #e0e7ff);
  border-bottom: 1.5px solid #c7d2fe;
}
.math-def-term-icon {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  border-radius: 7px;
  background: linear-gradient(135deg, #2563eb, #4f46e5);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
}
.math-def-term {
  font-size: 14px;
  font-weight: 800;
  color: #1e3a8a;
  letter-spacing: 0.2px;
}
.math-def-body {
  padding: 12px 14px;
}
.math-def-meaning {
  font-size: 14.5px;
  color: var(--text);
  line-height: 1.8;
  margin-bottom: 8px;
}
.math-def-formula-wrap {
  background: #f8faff;
  border: 1px solid #dbeafe;
  border-radius: 8px;
  padding: 10px 14px;
  text-align: center;
  margin-top: 8px;
  overflow: visible;
}

/* ── SOLUTION BOX (Fully Rebuilt) ─────────────── */
.math-copy-solution {
  margin-top: 14px;
  border: 1.5px solid #c7d2fe;
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
  font-family: "DM Sans", sans-serif;
  box-shadow: 0 2px 8px rgba(79,70,229,0.06);
}
.math-copy-header {
  padding: 10px 16px;
  background: linear-gradient(135deg, #4f46e5, #2563eb);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: 0.3px;
}
.math-sol-text-area {
  padding: 16px 18px;
  border-bottom: 1.5px solid #e0e7ff;
  font-size: 14.5px;
  color: var(--text);
  line-height: 1.9;
  background: #fafbff;
  overflow: visible;
}
.math-sol-text-area p { margin-bottom: 10px; }
.math-sol-text-area p:last-child { margin-bottom: 0; }
/* Make strong tags inside solution pop */
.math-sol-text-area strong { color: #1e3a8a; }

.math-copy-answer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 12px 20px;
  background: linear-gradient(135deg, #f0fdf4, #dcfce7);
  border-top: 1.5px solid #86efac;
}
.math-therefore {
  font-size: 26px;
  font-weight: 900;
  color: #15803d;
  line-height: 1;
}
.math-answer-text {
  font-size: 16px;
  font-weight: 800;
  color: #166534;
  overflow: visible;
}

/* ── MCQ EXPLANATION BOX ──────────────────────── */
.math-mcq-explain .math-tip {
  margin: 10px 14px;
  background: #eff6ff;
  border-color: #93c5fd;
  color: #1e40af;
  font-size: 13.5px;
  line-height: 1.7;
  padding: 10px 14px;
  border-radius: 8px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.math-mcq-explain .math-tip i { margin-top: 2px; flex-shrink: 0; color: #3b82f6; }

/* ── FORMULA-SHEET ROW (spacing fix) ─────────── */
.math-formula-row {
  background: #f8faff;
  border: 1.5px solid #dbeafe;
  border-left: 4px solid #2563eb;
  border-radius: 0 10px 10px 0;
  padding: 14px 16px;
  transition: var(--ease);
}
.math-formula-row:hover {
  border-left-color: #4f46e5;
  background: #f0f7ff;
}

/* ── MATH TOGGLE SOL BTN (better look) ───────── */
.math-toggle-sol-btn {
  margin-top: 8px;
  margin-left: 0;
  padding: 5px 13px;
  border-radius: 7px;
  background: #eff6ff;
  border: 1.5px solid #bfdbfe;
  color: #2563eb;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: var(--ease);
}
.math-toggle-sol-btn:hover { background: #dbeafe; border-color: #3b82f6; }

/* ── PROOF STEPS (derivation) ─────────────────── */
.math-proof-steps {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}
.math-proof-step {
  display: flex;
  gap: 12px;
  padding: 9px 14px;
  border: 1.5px solid #e0e7ff;
  border-radius: 8px;
  background: #fafbff;
  font-size: 13.5px;
  color: var(--text-mid);
  line-height: 1.7;
}
.math-proof-num {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 800;
}

/* ── RECOGNITION GUIDE TABLE ─────────────────── */
.math-recognition-block .gr-table thead tr {
  background: linear-gradient(135deg, #4f46e5, #2563eb);
}
.gr-table tbody tr:hover { background: #eff6ff !important; }
.gr-table tbody td:last-child {
  font-weight: 700;
  color: #1d4ed8;
}

/* ── RESPONSIVE ───────────────────────────────── */
@media (max-width: 768px) {
  .math-overview-intro { padding: 14px 14px 14px 46px; font-size: 14px; }
  .math-overview-intro::before { left: 14px; top: 14px; font-size: 17px; }
  .math-obj-item { padding: 10px 12px; font-size: 13.5px; }
  .math-def-card { border-radius: 8px; }
  .math-def-meaning { font-size: 14px; }
  .math-sol-text-area { padding: 12px 14px; font-size: 13.5px; }
  .math-chip { font-size: 11.5px; padding: 4px 10px; }
}

/* ══════════════════════════════════════════════
   MATH — ROUND 2 UPGRADES
   ══════════════════════════════════════════════ */

/* ── DIFFICULTY BADGE (solved examples) ──────── */
.math-diff-badge {
  display: inline-block;
  margin-top: 5px;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

/* ── PAST NEB ─────────────────────────────────── */
.math-neb-header {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 16px;
  margin-bottom: 14px;
  background: linear-gradient(135deg, #4c1d95, #7c3aed);
  color: #fff;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.3px;
}
.math-neb-item { border-color: #c4b5fd !important; }
.math-neb-item .math-qa-question { background: linear-gradient(135deg, #f5f3ff, #ede9fe) !important; border-bottom-color: #c4b5fd !important; }
.math-neb-item .math-qa-num { background: linear-gradient(135deg, #4c1d95, #7c3aed) !important; }
.math-neb-year {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  background: #4c1d95;
  color: #fff;
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: 0.3px;
}
.math-neb-item .math-reveal-btn { background: #7c3aed; }
.math-neb-item .math-reveal-btn:hover { background: #4c1d95; }

/* ── CHAPTER TEST ─────────────────────────────── */
.math-test-intro {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 16px;
  margin-bottom: 16px;
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  border: 1.5px solid #fcd34d;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
  color: #78350f;
}
.math-test-section {
  margin-bottom: 20px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.math-test-section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 16px;
  background: linear-gradient(135deg, #1e293b, #334155);
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.3px;
}
.math-test-section-num {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  border: 1.5px solid rgba(255,255,255,0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 800;
}
.math-test-section > div:not(.math-test-section-title) {
  padding: 14px;
}

/* ── REVISION SHEET (Cheat Sheet) ─────────────── */
.math-cheatsheet {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 10px;
}
.math-cheatsheet-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  background: #fff;
  border: 1.5px solid #bfdbfe;
  border-radius: 10px;
  transition: var(--ease);
}
.math-cheatsheet-item:hover {
  border-color: #2563eb;
  background: #eff6ff;
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(37,99,235,0.08);
}
.math-cheatsheet-num {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2563eb, #4f46e5);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 800;
}
.math-cheatsheet-text {
  font-size: 13.5px;
  color: var(--text);
  line-height: 1.7;
  overflow: visible;
}
.math-cheatsheet-text strong { color: #1e3a8a; }

/* ── IMPORTANT POINTS (with icons) ───────────── */
.math-important-points {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-left: 0;
}
.math-important-points li {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 13.5px;
  color: var(--text-mid);
  line-height: 1.65;
}
.math-important-points li span { flex: 1; }

/* ── KEY INSIGHT ──────────────────────────────── */
.math-key-insight {
  border: 2px solid #f59e0b;
  border-radius: 12px;
  background: linear-gradient(135deg, #fffbeb, #fef3c7);
  overflow: hidden;
}
.math-key-insight-label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: linear-gradient(135deg, #d97706, #f59e0b);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.3px;
}
.math-key-insight-text {
  padding: 14px 16px;
  font-size: 15px;
  font-weight: 600;
  color: #78350f;
  line-height: 1.85;
}
.math-key-insight-note {
  padding: 10px 16px;
  background: rgba(245,158,11,0.12);
  border-top: 1px solid #fcd34d;
  font-size: 13px;
  color: #92400e;
  line-height: 1.65;
}
/* chapter-overview block with key-insight gets gold border */
.math-topic-block:has(.math-key-insight) { border-color: #fcd34d; }

/* ── EXAM WARNING ─────────────────────────────── */
.math-exam-warning {
  border: 2px solid #fca5a5;
  border-radius: 12px;
  background: #fff;
  overflow: hidden;
}
.math-exam-warning-label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: linear-gradient(135deg, #b91c1c, #dc2626);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.3px;
}
.math-exam-warning-text {
  padding: 12px 16px 8px;
  font-size: 14px;
  color: #7f1d1d;
  line-height: 1.75;
  font-weight: 600;
}
.math-exam-warning-list {
  list-style: none;
  padding: 0 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.math-exam-warning-list li {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 13.5px;
  color: #991b1b;
  line-height: 1.65;
  padding: 8px 12px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 8px;
}
.math-exam-warning-list li::before {
  content: "✗";
  font-weight: 900;
  font-size: 14px;
  color: #dc2626;
  flex-shrink: 0;
  margin-top: 1px;
}
/* topic block highlight for exam-warning */
.math-topic-block:has(.math-exam-warning) { border-color: #fca5a5; }
.math-topic-block:has(.math-exam-warning) .math-topic-header { background: linear-gradient(135deg,#fef2f2,#fee2e2); border-bottom-color: #fca5a5; }
.math-topic-block:has(.math-exam-warning) .math-topic-title { color: #991b1b; }

/* ── FLOWCHART ────────────────────────────────── */
.math-flowchart {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}
.math-flow-step {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  background: #fff;
  border: 1.5px solid #bfdbfe;
  border-radius: 10px;
  width: 100%;
  max-width: 480px;
  font-size: 14px;
  color: var(--text);
  line-height: 1.6;
}
.math-flow-step-num {
  flex-shrink: 0;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2563eb, #4f46e5);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 800;
}
.math-flow-step-text { flex: 1; font-weight: 600; }
.math-flow-arrow {
  color: var(--text-soft);
  font-size: 16px;
  padding: 4px 0;
  text-align: center;
  width: 100%;
  max-width: 480px;
}
.math-flow-decision {
  width: 100%;
  max-width: 560px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.math-flow-diamond {
  padding: 12px 24px;
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  border: 2px solid #f59e0b;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 800;
  color: #78350f;
  text-align: center;
  width: 100%;
}
.math-flow-branches {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  width: 100%;
}
.math-flow-branch {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.math-flow-label {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 10px;
  border-radius: 20px;
}
.math-flow-label.yes { background: #dcfce7; color: #15803d; }
.math-flow-label.no  { background: #fee2e2; color: #dc2626; }
.math-flow-result {
  padding: 10px 14px;
  border-radius: 9px;
  font-size: 13.5px;
  font-weight: 700;
  color: #fff;
  text-align: center;
  width: 100%;
}
.math-flow-yes .math-flow-result { background: linear-gradient(135deg, #059669, #10b981); }
.math-flow-no  .math-flow-result { background: linear-gradient(135deg, #7c3aed, #4f46e5); }

/* ── COMPARISON ───────────────────────────────── */
.math-comparison {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 0;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.math-cmp-col { display: flex; flex-direction: column; }
.math-cmp-header {
  padding: 12px 16px;
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  text-align: center;
  letter-spacing: 0.3px;
}
.math-cmp-body {
  padding: 14px;
  background: #fff;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.math-cmp-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 13.5px;
  color: var(--text);
  line-height: 1.65;
}
.math-cmp-row i { margin-top: 3px; flex-shrink: 0; }
.math-cmp-vs {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  background: #f8fafc;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  font-size: 13px;
  font-weight: 900;
  color: var(--text-soft);
  writing-mode: vertical-lr;
  letter-spacing: 4px;
}

/* ── RESPONSIVE ───────────────────────────────── */
@media (max-width: 768px) {
  .math-cheatsheet { grid-template-columns: 1fr; }
  .math-comparison { grid-template-columns: 1fr; }
  .math-cmp-vs { writing-mode: horizontal-tb; padding: 8px; letter-spacing: 2px; border: none; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
  .math-flow-branches { grid-template-columns: 1fr; }
  .math-flow-step, .math-flow-diamond, .math-flow-decision { max-width: 100%; }
  .math-neb-header { font-size: 13px; }
  .math-key-insight-text { font-size: 14px; }
}

/* ============================================
   DARK MODE
   ============================================ */
[data-theme="dark"] {
  --primary-color: #3b82f6;
  --primary-dark: #2563eb;
  --primary-light: #60a5fa;
  --secondary-color: #f59e0b;
  --secondary-dark: #d97706;
  --accent-color: #10b981;
  --background-light: #0f1117;
  --background-white: #1a1d27;
  --surface-raised: #21253a;
  --surface-hover: #272b40;
  --text-dark: #e8eaf0;
  --text-medium: #9da5b4;
  --text-light: #636b7a;
  --border-color: #2a2f45;
  --header-bg: #0d1117;
  --nav-bg: #1a1d27;
  --footer-bg: #0a0d14;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.6);
  --surface: #1a1d27;
  --bg: #0f1117;
  --border: #2a2f45;
  --text: #e8eaf0;
  --text-mid: #9da5b4;
  --text-soft: #636b7a;
}

[data-theme="dark"] body {
  background: #0f1117 !important;
  color: #e8eaf0;
}

[data-theme="dark"] .notes-sidebar,
[data-theme="dark"] .notes-main,
[data-theme="dark"] .notes-reader,
[data-theme="dark"] .subject-item,
[data-theme="dark"] .quick-card,
[data-theme="dark"] .curriculum-chapter-item,
[data-theme="dark"] .chapter-card,
[data-theme="dark"] .reader-section,
[data-theme="dark"] .eng-qa-item,
[data-theme="dark"] .gr-topic,
[data-theme="dark"] .math-topic-block,
[data-theme="dark"] .math-def-card,
[data-theme="dark"] .math-mcq-item,
[data-theme="dark"] .math-qa-item,
[data-theme="dark"] .gr-practice-item,
[data-theme="dark"] .gr-type-card,
[data-theme="dark"] .math-cheatsheet-item,
[data-theme="dark"] .math-flow-step,
[data-theme="dark"] .math-cmp-body,
[data-theme="dark"] .math-exam-warning,
[data-theme="dark"] .math-copy-solution {
  background: #1a1d27;
  border-color: #2a2f45;
  color: #e8eaf0;
}

[data-theme="dark"] .notes-reader-body,
[data-theme="dark"] .reader-section-header,
[data-theme="dark"] .gr-example-item,
[data-theme="dark"] .reader-key-points li,
[data-theme="dark"] .math-proof-step,
[data-theme="dark"] .gr-option-btn,
[data-theme="dark"] .math-opt-btn {
  background: #21253a;
  border-color: #2a2f45;
  color: #e8eaf0;
}

[data-theme="dark"] .continue-reading-card {
  background: linear-gradient(135deg, #1a2540, #1e2a45);
  border-color: #3b82f6;
}

[data-theme="dark"] .sidebar-search input,
[data-theme="dark"] .gr-practice-input {
  background: #21253a;
  color: #e8eaf0;
  border-color: #2a2f45;
}

[data-theme="dark"] .sidebar-item,
[data-theme="dark"] .chapter-link,
[data-theme="dark"] .subject-item {
  color: #c9cdd6;
}

[data-theme="dark"] .sidebar-item:hover,
[data-theme="dark"] .chapter-link:hover,
[data-theme="dark"] .subject-item:hover {
  background: #21253a;
  color: #60a5fa;
}

[data-theme="dark"] .sidebar-item.active,
[data-theme="dark"] .chapter-link.active {
  background: rgba(59, 130, 246, 0.2);
  color: #60a5fa;
  border-left-color: #3b82f6;
}

[data-theme="dark"] .recent-title,
[data-theme="dark"] h1,
[data-theme="dark"] h2,
[data-theme="dark"] h3,
[data-theme="dark"] h4 {
  color: #e8eaf0;
}

[data-theme="dark"] .recent-meta,
[data-theme="dark"] .notice-date,
[data-theme="dark"] p,
[data-theme="dark"] .reader-section-body p,
[data-theme="dark"] .eng-qa-answer p {
  color: #9da5b4;
}

[data-theme="dark"] #main-nav {
  background-color: #1a1d27;
  border-bottom: 1px solid #2a2f45;
}

[data-theme="dark"] .nav-link {
  color: #c9cdd6;
}

[data-theme="dark"] .nav-link:hover,
[data-theme="dark"] .nav-link.active {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
}

[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] textarea {
  background: #21253a;
  color: #e8eaf0;
  border-color: #2a2f45;
}

[data-theme="dark"] input::placeholder {
  color: #636b7a;
}

[data-theme="dark"] .katex,
[data-theme="dark"] .math-block,
[data-theme="dark"] .content-body,
[data-theme="dark"] .math-formula-katex,
[data-theme="dark"] .math-formula-katex-block {
  color: #e8eaf0;
}

[data-theme="dark"] .math-formula-inline,
[data-theme="dark"] .math-formula-row,
[data-theme="dark"] .math-formula-katex-block,
[data-theme="dark"] .math-def-formula-wrap,
[data-theme="dark"] .math-def-nepali,
[data-theme="dark"] .gr-def-nepali,
[data-theme="dark"] .gr-table-rule,
[data-theme="dark"] .math-sol-text-area {
  background: #21253a;
  border-color: #2a2f45;
  color: #e8eaf0;
}

[data-theme="dark"] .math-overview-intro {
  background: linear-gradient(135deg, #1a2540 0%, #1e2a45 100%);
  border-color: #2a4a7a;
  color: #e8eaf0;
}

[data-theme="dark"] .math-chip {
  background: #1e2a45;
  border-color: #2a4a7a;
  color: #93c5fd;
}

[data-theme="dark"] .math-obj-item {
  background: #1a1d27;
  border-color: #2a2f45;
  color: #e8eaf0;
}

[data-theme="dark"] .math-obj-item:hover {
  background: #21253a;
}

[data-theme="dark"] pre,
[data-theme="dark"] code {
  background: #0d1117;
  color: #c9d1d9;
  border-color: #2a2f45;
}

[data-theme="dark"] table,
[data-theme="dark"] .gr-table {
  color: #e8eaf0;
}
[data-theme="dark"] th,
[data-theme="dark"] .gr-table thead tr {
  background: #21253a;
  color: #e8eaf0;
}
[data-theme="dark"] td {
  border-color: #2a2f45;
}
[data-theme="dark"] .gr-table tbody tr:nth-child(even),
[data-theme="dark"] tr:nth-child(even) {
  background: #1e2230;
}
[data-theme="dark"] .gr-table tbody tr:nth-child(odd) {
  background: #1a1d27;
}

[data-theme="dark"] .sidebar,
[data-theme="dark"] #sidebar,
[data-theme="dark"] .notes-sidebar {
  background: #1a1d27;
  border-color: #2a2f45;
}

[data-theme="dark"] .content-section {
  background: #1a1d27;
  border-color: #2a2f45;
}

[data-theme="dark"] .sidebar-overlay {
  background: rgba(0, 0, 0, 0.6);
}

[data-theme="dark"] ::-webkit-scrollbar {
  width: 8px;
}
[data-theme="dark"] ::-webkit-scrollbar-track {
  background: #0f1117;
}
[data-theme="dark"] ::-webkit-scrollbar-thumb {
  background: #2a2f45;
  border-radius: 4px;
}
[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
  background: #3b82f6;
}

