/* ============================================================
   CFA Level 1 Curriculum -- Design System
   Warm light theme with dark sidebar for contrast
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@300;400;500;600;700;800&display=swap');

/* ---- Design Tokens ---- */
:root {
  /* Background and surface colours */
  --bg-deep: #f8f7f4;
  --bg-mid: #f1f0ec;
  --bg-surface: rgba(0, 0, 0, 0.02);
  --bg-glass: #ffffff;
  --bg-glass-hover: #fafafa;
  --bg-glass-active: #f5f4f1;

  /* Sidebar (stays dark) */
  --sidebar-bg: rgba(15, 18, 45, 0.96);
  --sidebar-border: rgba(255, 255, 255, 0.08);
  --sidebar-text-primary: #e8e6f0;
  --sidebar-text-secondary: rgba(232, 230, 240, 0.65);
  --sidebar-text-muted: rgba(232, 230, 240, 0.40);
  --sidebar-surface: rgba(255, 255, 255, 0.04);
  --sidebar-glass: rgba(255, 255, 255, 0.06);
  --sidebar-glass-hover: rgba(255, 255, 255, 0.10);
  --sidebar-glass-active: rgba(255, 255, 255, 0.14);

  /* Accent colours (adjusted for light bg) */
  --accent-lavender: #7c5cbf;
  --accent-teal: #0d9488;
  --accent-rose: #c084fc;
  --accent-peach: #e57373;
  --accent-sky: #0ea5e9;
  --accent-amber: #d97706;

  /* Light-tinted accent backgrounds */
  --accent-lavender-bg: rgba(124, 92, 191, 0.07);
  --accent-teal-bg: rgba(13, 148, 136, 0.07);
  --accent-rose-bg: rgba(192, 132, 252, 0.07);
  --accent-peach-bg: rgba(229, 115, 115, 0.06);
  --accent-sky-bg: rgba(14, 165, 233, 0.07);
  --accent-amber-bg: rgba(217, 119, 6, 0.07);

  /* Text colours */
  --text-primary: #1a1a2e;
  --text-secondary: #4a4a5e;
  --text-muted: #8a8a9e;
  --text-heading: #111127;

  /* Card properties */
  --card-border: rgba(0, 0, 0, 0.06);
  --card-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  --card-shadow-hover: 0 6px 20px rgba(0, 0, 0, 0.08);

  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  --space-3xl: 4rem;

  /* Radii */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  /* Transitions */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --transition-fast: 0.2s var(--ease-out);
  --transition-med: 0.4s var(--ease-out);
  --transition-slow: 0.6s var(--ease-out);

  /* Sidebar */
  --sidebar-width: 300px;
  --sidebar-collapsed: 0px;
}

/* ---- Reset and Base ---- */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-deep);
  color: var(--text-primary);
  line-height: 1.7;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Ambient background glow (subtle on light) */
body::before {
  content: '';
  position: fixed;
  top: -30%;
  left: -10%;
  width: 60%;
  height: 60%;
  background: radial-gradient(circle, rgba(124, 92, 191, 0.04) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

body::after {
  content: '';
  position: fixed;
  bottom: -20%;
  right: -10%;
  width: 50%;
  height: 50%;
  background: radial-gradient(circle, rgba(13, 148, 136, 0.03) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

/* ---- Typography ---- */
h1, h2, h3, h4, h5, h6 {
  font-family: 'Outfit', sans-serif;
  color: var(--text-heading);
  line-height: 1.3;
  letter-spacing: -0.01em;
}

h1 { font-size: 2.5rem; font-weight: 700; }
h2 { font-size: 1.85rem; font-weight: 600; }
h3 { font-size: 1.35rem; font-weight: 600; }
h4 { font-size: 1.1rem; font-weight: 500; }

p {
  color: var(--text-secondary);
  margin-bottom: var(--space-md);
  max-width: 72ch;
}

strong {
  color: var(--text-primary);
  font-weight: 600;
}

/* ---- Layout ---- */
.app-layout {
  display: flex;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

/* ---- Sidebar (stays dark / glassmorphic) ---- */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--sidebar-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform var(--transition-med);
  overflow: hidden;
}

.sidebar.collapsed {
  transform: translateX(-100%);
}

.sidebar-header {
  padding: var(--space-xl) var(--space-lg);
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}

.sidebar-header h1,
.sidebar-header .logo {
  font-family: 'Outfit', sans-serif;
  font-size: 1.15rem;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: 0.02em;
  line-height: 1.3;
}

.sidebar-header .subtitle {
  font-size: 0.75rem;
  color: var(--sidebar-text-muted);
  margin-top: var(--space-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* ---- Level Selector (Sidebar) ---- */
.level-selector {
  display: flex;
  gap: 6px;
  padding: 0 var(--space-lg) var(--space-md);
  margin-bottom: var(--space-xs);
}

.level-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 4px 6px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.06);
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
}

.level-btn-number {
  font-family: 'Outfit', sans-serif;
  font-size: 0.95rem;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.4);
  line-height: 1;
}

.level-btn-label {
  font-family: 'Inter', sans-serif;
  font-size: 0.6rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.35);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.level-btn-badge {
  position: absolute;
  top: -5px;
  right: -4px;
  padding: 1px 5px;
  border-radius: 6px;
  font-family: 'Inter', sans-serif;
  font-size: 0.5rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.45);
  line-height: 1.4;
}

.level-btn.active {
  background: rgba(124, 92, 191, 0.25);
  border-color: rgba(124, 92, 191, 0.5);
  box-shadow: 0 0 12px rgba(124, 92, 191, 0.15);
}

.level-btn.active .level-btn-number {
  color: #ffffff;
}

.level-btn.active .level-btn-label {
  color: rgba(255, 255, 255, 0.85);
}

.level-btn.locked {
  cursor: not-allowed;
  opacity: 0.6;
}

.level-btn.locked:hover {
  background: rgba(255, 255, 255, 0.08);
}

/* ---- Level Roadmap (Welcome Page) ---- */
.level-roadmap {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-lg);
}

.level-card {
  position: relative;
  padding: var(--space-lg);
  border-radius: var(--radius-lg);
  background: #ffffff;
  border: 1px solid var(--card-border);
  box-shadow: var(--card-shadow);
  transition: all var(--transition-fast);
  overflow: hidden;
}

.level-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--card-border);
  transition: background var(--transition-fast);
}

.level-card.active::before {
  background: linear-gradient(90deg, var(--accent-lavender), var(--accent-teal));
}

.level-card.active {
  border-color: rgba(124, 92, 191, 0.2);
  box-shadow: var(--card-shadow-hover);
}

.level-card.active:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(124, 92, 191, 0.15);
}

.level-card.coming-soon {
  opacity: 0.65;
}

.level-card.coming-soon:hover {
  opacity: 0.8;
}

.level-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-md);
}

.level-card-number {
  font-family: 'Outfit', sans-serif;
  font-size: 1.8rem;
  font-weight: 800;
  line-height: 1;
  color: var(--text-muted);
}

.level-card.active .level-card-number {
  color: var(--accent-lavender);
}

.level-card-status {
  font-family: 'Inter', sans-serif;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 3px 10px;
  border-radius: 20px;
}

.level-card.active .level-card-status {
  background: var(--accent-lavender-bg);
  color: var(--accent-lavender);
}

.level-card.coming-soon .level-card-status {
  background: var(--bg-mid);
  color: var(--text-muted);
}

.level-card h3 {
  font-family: 'Outfit', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: var(--space-sm);
  line-height: 1.3;
}

.level-card p {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: var(--space-md);
}

.level-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.level-card-meta span {
  font-family: 'Inter', sans-serif;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
  background: var(--bg-mid);
  color: var(--text-muted);
}

.level-card.active .level-card-meta span {
  background: var(--accent-lavender-bg);
  color: var(--accent-lavender);
}

@media (max-width: 768px) {
  .level-roadmap {
    grid-template-columns: 1fr;
  }
}

/* Progress summary in sidebar */
.sidebar-progress {
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}

.progress-bar-container {
  width: 100%;
  height: 6px;
  background: var(--sidebar-surface);
  border-radius: 3px;
  overflow: hidden;
  margin-top: var(--space-sm);
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #a78bfa, #5eead4);
  border-radius: 3px;
  width: 0%;
  transition: width var(--transition-slow);
}

.progress-text {
  font-size: 0.75rem;
  color: var(--sidebar-text-muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Nav list */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-md) 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

.sidebar-nav::-webkit-scrollbar {
  width: 4px;
}

.sidebar-nav::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
}

.nav-section {
  margin-bottom: var(--space-xs);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-lg);
  cursor: pointer;
  color: var(--sidebar-text-secondary);
  font-size: 0.875rem;
  transition: all var(--transition-fast);
  border-left: 3px solid transparent;
  text-decoration: none;
  user-select: none;
}

.nav-item:hover {
  background: var(--sidebar-glass-hover);
  color: var(--sidebar-text-primary);
}

.nav-item.active {
  background: var(--sidebar-glass-active);
  color: #a78bfa;
  border-left-color: #a78bfa;
}

.nav-item .nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.7;
}

.nav-item.active .nav-icon {
  opacity: 1;
}

.nav-item .nav-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: var(--sidebar-glass);
  font-size: 0.7rem;
  font-weight: 600;
  flex-shrink: 0;
  color: var(--sidebar-text-muted);
}

.nav-item.active .nav-number {
  background: rgba(167, 139, 250, 0.2);
  color: #a78bfa;
}

.nav-item.completed .nav-number {
  background: rgba(94, 234, 212, 0.2);
  color: #5eead4;
}

/* ---- Main Content Area ---- */
.main-content {
  margin-left: var(--sidebar-width);
  padding: var(--space-3xl) var(--space-2xl);
  max-width: 1100px;
  margin-right: auto;
  min-height: 100vh;
  transition: margin-left var(--transition-med);
}

.sidebar.collapsed ~ .main-content {
  margin-left: 0;
}

/* ---- Sidebar Toggle Button ---- */
.sidebar-toggle {
  position: fixed;
  top: var(--space-lg);
  left: var(--space-lg);
  z-index: 200;
  width: 42px;
  height: 42px;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
  box-shadow: var(--card-shadow);
}

.sidebar-toggle:hover {
  background: #ffffff;
  color: var(--text-primary);
  box-shadow: var(--card-shadow-hover);
}

.sidebar.collapsed ~ .main-content ~ .sidebar-toggle,
.sidebar.collapsed ~ .sidebar-toggle {
  display: flex;
}

/* ---- Glass Card (now white card with subtle shadow) ---- */
.glass-card {
  background: var(--bg-glass);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  box-shadow: var(--card-shadow);
  transition: all var(--transition-fast);
}

.glass-card:hover {
  background: var(--bg-glass-hover);
  border-color: rgba(0, 0, 0, 0.09);
  transform: translateY(-2px);
  box-shadow: var(--card-shadow-hover);
}

.glass-card.no-hover:hover {
  transform: none;
  box-shadow: var(--card-shadow);
  background: var(--bg-glass);
  border-color: var(--card-border);
}

/* ---- Section Containers ---- */
.section {
  display: none;
  animation: fadeIn 0.5s var(--ease-out);
}

.section.active {
  display: block;
}

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

/* Section header with accent line */
.section-header {
  margin-bottom: var(--space-2xl);
  padding-bottom: var(--space-lg);
  border-bottom: 1px solid var(--card-border);
  text-align: center;
}

.section-header h1 {
  margin-bottom: var(--space-sm);
}

/* Large topic icon at top of each section */
.section-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  margin: 0 auto var(--space-lg);
  border-radius: var(--radius-lg);
  background: var(--accent-lavender-bg);
}

.section-icon svg {
  width: 36px;
  height: 36px;
}

/* Section meta (read time, exam weight) */
.section-meta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-lg);
  margin-top: var(--space-sm);
  flex-wrap: wrap;
}

.meta-item {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  font-size: 0.85rem;
  color: var(--text-muted);
}

.meta-item svg {
  width: 14px;
  height: 14px;
}

.section-header .section-subtitle {
  font-size: 1.05rem;
  color: var(--text-muted);
}

.section-label {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent-lavender);
  margin-bottom: var(--space-md);
}

/* ---- Content Elements ---- */
.concept-block {
  margin-bottom: var(--space-3xl);
  position: relative;
}

.concept-block h3 {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-heading);
  letter-spacing: -0.02em;
  padding-bottom: var(--space-sm);
  border-bottom: 2px solid var(--accent-lavender-bg);
}

.concept-block p {
  margin-bottom: var(--space-md);
  font-size: 0.98rem;
  line-height: 1.8;
}

/* First paragraph of each concept gets a drop-cap effect */
.concept-block > p:first-of-type::first-letter,
.sub-section > p:first-of-type::first-letter {
  font-family: 'Outfit', sans-serif;
  font-size: 2.6em;
  float: left;
  line-height: 0.85;
  margin-right: 0.08em;
  margin-top: 0.05em;
  color: var(--accent-lavender);
  font-weight: 700;
}

/* Sub-sections get a subtle left accent and indentation */
.sub-section {
  margin-bottom: var(--space-xl);
  padding-left: var(--space-lg);
  border-left: 2px solid rgba(124, 92, 191, 0.08);
}

.sub-section h4 {
  margin-bottom: var(--space-md);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--accent-lavender);
  letter-spacing: -0.01em;
}

/* Content section headings -- bigger, bolder, with accent underline */
.content-section h2 {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin-bottom: var(--space-xl);
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  padding-bottom: var(--space-md);
  border-bottom: 3px solid transparent;
  border-image: linear-gradient(90deg, var(--accent-lavender), var(--accent-teal), transparent) 1;
}

/* Key term highlight -- more prominent inline badge */
.key-term {
  color: var(--accent-teal);
  font-weight: 600;
  position: relative;
  background: var(--accent-teal-bg);
  padding: 1px 6px;
  border-radius: 4px;
}

.key-term::after {
  display: none;
}

/* ═══════════════════════════════════════════════
   DEFINITION BOX -- Teal, elevated card style
   ═══════════════════════════════════════════════ */
.definition-box {
  background: linear-gradient(135deg, rgba(13, 148, 136, 0.04) 0%, rgba(13, 148, 136, 0.09) 100%);
  border-left: 4px solid var(--accent-teal);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  padding: var(--space-lg) var(--space-xl);
  margin: var(--space-lg) 0;
  box-shadow: 0 2px 8px rgba(13, 148, 136, 0.06);
  position: relative;
  overflow: hidden;
}

.definition-box::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 80px;
  height: 80px;
  background: radial-gradient(circle at top right, rgba(13, 148, 136, 0.06) 0%, transparent 70%);
  pointer-events: none;
}

.definition-box .def-term {
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  color: var(--accent-teal);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: var(--space-sm);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.definition-box .def-term::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: var(--accent-teal);
  flex-shrink: 0;
}

.definition-box p {
  color: var(--text-primary);
  margin-bottom: 0;
  font-size: 0.95rem;
  line-height: 1.75;
  font-weight: 400;
}

/* ═══════════════════════════════════════════════
   ANALOGY BOX -- Lavender, pull-quote style
   ═══════════════════════════════════════════════ */
.analogy-box {
  background: linear-gradient(135deg, rgba(124, 92, 191, 0.03) 0%, rgba(124, 92, 191, 0.08) 100%);
  border: none;
  border-left: none;
  border-radius: var(--radius-lg);
  padding: var(--space-xl) var(--space-xl) var(--space-xl) var(--space-2xl);
  margin: var(--space-xl) 0;
  position: relative;
  box-shadow: 0 2px 12px rgba(124, 92, 191, 0.06);
}

.analogy-box::before {
  content: '\201C';
  position: absolute;
  top: 8px;
  left: 14px;
  font-family: 'Outfit', serif;
  font-size: 3.5rem;
  font-weight: 800;
  color: var(--accent-lavender);
  opacity: 0.2;
  line-height: 1;
  pointer-events: none;
}

.analogy-box .analogy-label {
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  color: var(--accent-lavender);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: var(--space-sm);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.analogy-box p {
  color: var(--text-primary);
  font-size: 1.02rem;
  line-height: 1.8;
  font-style: italic;
  margin-bottom: 0;
}

/* ═══════════════════════════════════════════════
   FORMULA CARD -- Peach, prominent centered card
   ═══════════════════════════════════════════════ */
.formula-card {
  background: linear-gradient(135deg, rgba(229, 115, 115, 0.04) 0%, rgba(229, 115, 115, 0.10) 100%);
  border: 2px solid rgba(229, 115, 115, 0.15);
  border-radius: var(--radius-lg);
  padding: var(--space-xl) var(--space-2xl);
  margin: var(--space-xl) 0;
  text-align: center;
  box-shadow: 0 4px 16px rgba(229, 115, 115, 0.06);
  position: relative;
  overflow: hidden;
}

.formula-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent-peach), rgba(229, 115, 115, 0.3));
}

.formula-card .formula-label {
  font-family: 'Outfit', sans-serif;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent-peach);
  margin-bottom: var(--space-md);
}

.formula-card .formula {
  font-family: 'Outfit', sans-serif;
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--text-heading);
  margin-bottom: var(--space-md);
  letter-spacing: 0.02em;
  line-height: 1.5;
}

.formula-card .formula-note {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.6;
  max-width: 60ch;
  margin: 0 auto;
}


/* ═══════════════════════════════════════════════
   STUDY TIP -- Amber, warm callout
   ═══════════════════════════════════════════════ */
.study-tip {
  background: linear-gradient(135deg, rgba(217, 119, 6, 0.04) 0%, rgba(217, 119, 6, 0.10) 100%);
  border-left: 4px solid var(--accent-amber);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  padding: var(--space-lg) var(--space-xl);
  margin: var(--space-xl) 0;
  box-shadow: 0 2px 8px rgba(217, 119, 6, 0.06);
  position: relative;
}

.study-tip .tip-label {
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  color: var(--accent-amber);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: var(--space-sm);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.study-tip p {
  color: var(--text-primary);
  font-size: 0.95rem;
  line-height: 1.75;
}

/* ═══════════════════════════════════════════════
   EXAM PITFALL -- Red warning card
   ═══════════════════════════════════════════════ */
.exam-pitfall {
  background: linear-gradient(135deg, rgba(229, 115, 115, 0.04) 0%, rgba(229, 115, 115, 0.10) 100%);
  border: 1px solid rgba(229, 115, 115, 0.18);
  border-left: 4px solid var(--accent-peach);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  padding: var(--space-lg) var(--space-xl);
  margin: var(--space-xl) 0;
  box-shadow: 0 2px 8px rgba(229, 115, 115, 0.06);
  position: relative;
}

.exam-pitfall .pitfall-label {
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  color: var(--accent-peach);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: var(--space-sm);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.exam-pitfall p {
  color: var(--text-primary);
  font-size: 0.95rem;
  line-height: 1.75;
  margin-bottom: 0;
}

/* ═══════════════════════════════════════════════
   COMPARISON TABLE -- Zebra-stripe, hover rows
   ═══════════════════════════════════════════════ */
.table-wrapper {
  margin: var(--space-xl) 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-md);
  border: 1px solid var(--card-border);
  box-shadow: var(--card-shadow);
}

.comparison-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  line-height: 1.6;
}

.comparison-table thead {
  position: sticky;
  top: 0;
  z-index: 1;
}

.comparison-table th {
  background: linear-gradient(135deg, rgba(124, 92, 191, 0.08) 0%, rgba(13, 148, 136, 0.06) 100%);
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-heading);
  padding: var(--space-md) var(--space-lg);
  text-align: left;
  border-bottom: 2px solid rgba(124, 92, 191, 0.15);
  white-space: nowrap;
}

.comparison-table td {
  padding: var(--space-sm) var(--space-lg);
  color: var(--text-secondary);
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
  vertical-align: top;
}

.comparison-table tbody tr:nth-child(even) {
  background: rgba(0, 0, 0, 0.015);
}

.comparison-table tbody tr:hover {
  background: rgba(124, 92, 191, 0.04);
  transition: background 0.15s ease;
}

.comparison-table td:first-child {
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
}

/* Also style bare <table> elements inside content for agents that didn't use comparison-table class */
.content-section table:not(.comparison-table) {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  margin: var(--space-lg) 0;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--card-shadow);
}

.content-section table:not(.comparison-table) th {
  background: linear-gradient(135deg, rgba(124, 92, 191, 0.08) 0%, rgba(13, 148, 136, 0.06) 100%);
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-heading);
  padding: var(--space-md) var(--space-lg);
  text-align: left;
  border-bottom: 2px solid rgba(124, 92, 191, 0.15);
}

.content-section table:not(.comparison-table) td {
  padding: var(--space-sm) var(--space-lg);
  color: var(--text-secondary);
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
}

.content-section table:not(.comparison-table) tbody tr:nth-child(even) {
  background: rgba(0, 0, 0, 0.015);
}

.content-section table:not(.comparison-table) tbody tr:hover {
  background: rgba(124, 92, 191, 0.04);
}

/* ═══════════════════════════════════════════════
   WORKED EXAMPLE -- Enhanced with gradient header
   (overrides the base worked-example below)
   ═══════════════════════════════════════════════ */
.example-title {
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  color: var(--accent-lavender);
  font-size: 0.95rem;
  margin-bottom: var(--space-md);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.example-title::before {
  content: '';
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent-lavender);
  flex-shrink: 0;
}

/* ═══════════════════════════════════════════════
   REAL-WORLD BOX -- Enhanced sky-blue card
   ═══════════════════════════════════════════════ */

/* ═══════════════════════════════════════════════
   CONTENT DIVIDERS between concept blocks
   ═══════════════════════════════════════════════ */
.concept-block + .concept-block::before {
  content: '';
  display: block;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--card-border), var(--accent-lavender-bg), var(--card-border), transparent);
  margin-bottom: var(--space-2xl);
}

/* Takeaway list */
.takeaway-list {
  list-style: none;
  padding: 0;
}

.takeaway-list li {
  display: flex;
  align-items: flex-start;
  gap: var(--space-md);
  padding: var(--space-sm) 0;
  color: var(--text-secondary);
  line-height: 1.6;
}

.takeaway-list li .check-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  margin-top: 2px;
  color: var(--accent-teal);
}


.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--space-lg);
  margin: var(--space-xl) 0;
}

.stat-card {
  text-align: center;
  padding: var(--space-xl) var(--space-lg);
}

.stat-card .stat-icon {
  width: 40px;
  height: 40px;
  margin: 0 auto var(--space-md);
  color: var(--accent-lavender);
}

.stat-card .stat-value {
  font-family: 'Outfit', sans-serif;
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-heading);
}

.stat-card .stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: var(--space-xs);
}

/* ---- Topic Card (Dashboard) ---- */
.topic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-lg);
  margin: var(--space-xl) 0;
}

.topic-card {
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.topic-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--card-accent, var(--accent-lavender)), transparent);
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.topic-card:hover::before {
  opacity: 1;
}

.topic-card .topic-number {
  font-family: 'Outfit', sans-serif;
  font-size: 2rem;
  font-weight: 800;
  color: var(--text-muted);
  opacity: 0.25;
  line-height: 1;
  margin-bottom: var(--space-sm);
}

.topic-card h3 {
  font-size: 1.05rem;
  margin-bottom: var(--space-sm);
}

.topic-card .topic-weight {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: var(--space-sm);
}

.topic-card .topic-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 0;
}

/* ---- Completion Checkbox ---- */
.completion-check {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-top: var(--space-2xl);
  padding-top: var(--space-lg);
  border-top: 1px solid var(--card-border);
  cursor: pointer;
  user-select: none;
}

.completion-check input[type="checkbox"] {
  display: none;
}

.check-box {
  width: 22px;
  height: 22px;
  border: 2px solid rgba(0, 0, 0, 0.15);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.completion-check:hover .check-box {
  border-color: var(--accent-teal);
}

.completion-check input:checked ~ .check-box {
  background: rgba(13, 148, 136, 0.12);
  border-color: var(--accent-teal);
}

.completion-check input:checked ~ .check-box svg {
  opacity: 1;
}

.check-box svg {
  width: 14px;
  height: 14px;
  color: var(--accent-teal);
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.completion-check .check-label {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

/* ---- Search Bar ---- */
.search-container {
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}

.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.search-input-wrapper svg {
  position: absolute;
  left: 10px;
  width: 16px;
  height: 16px;
  color: var(--sidebar-text-muted);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: var(--space-sm) var(--space-md) var(--space-sm) 34px;
  border: 1px solid var(--sidebar-border);
  border-radius: var(--radius-sm);
  background: var(--sidebar-surface);
  color: var(--sidebar-text-primary);
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  outline: none;
  transition: all var(--transition-fast);
}

.search-input::placeholder {
  color: var(--sidebar-text-muted);
}

.search-input:focus {
  border-color: rgba(167, 139, 250, 0.4);
  background: var(--sidebar-glass);
}

/* ---- Scroll to Top ---- */
.scroll-top {
  position: fixed;
  bottom: var(--space-xl);
  right: var(--space-xl);
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--card-border);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: all var(--transition-fast);
  z-index: 50;
  box-shadow: var(--card-shadow);
}

.scroll-top.visible {
  opacity: 1;
  pointer-events: auto;
}

.scroll-top:hover {
  background: #ffffff;
  color: var(--accent-lavender);
  transform: translateY(-2px);
  box-shadow: var(--card-shadow-hover);
}

/* ---- Content Divider ---- */
.content-divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--card-border), transparent);
  margin: var(--space-2xl) 0;
}

/* ---- Inline SVG Icon Sizing ---- */
.icon-inline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  vertical-align: middle;
}

.icon-sm {
  width: 16px;
  height: 16px;
}

.icon-lg {
  width: 28px;
  height: 28px;
}

/* ---- Exam Weight Badge ---- */
.weight-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--accent-lavender-bg);
  color: var(--accent-lavender);
  border: 1px solid rgba(124, 92, 191, 0.18);
}

/* ---- Ordered content sections ---- */
.content-section {
  margin-bottom: var(--space-2xl);
  text-align: left;
}

.content-section h2 {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
}

.sub-section {
  margin-bottom: var(--space-xl);
}

.sub-section h4 {
  margin-bottom: var(--space-md);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

/* ---- Lists inside content ---- */
.content-list {
  list-style: none;
  padding: 0;
  margin: var(--space-md) 0;
}

.content-list li {
  position: relative;
  padding: var(--space-xs) 0 var(--space-xs) var(--space-xl);
  color: var(--text-secondary);
  line-height: 1.7;
}

.content-list li::before {
  content: '';
  position: absolute;
  left: 8px;
  top: 12px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent-lavender);
  opacity: 0.5;
}

/* Numbered steps */
.steps-list {
  list-style: none;
  padding: 0;
  counter-reset: step-counter;
}

.steps-list li {
  counter-increment: step-counter;
  position: relative;
  padding: var(--space-sm) 0 var(--space-sm) var(--space-2xl);
  color: var(--text-secondary);
  line-height: 1.7;
}

.steps-list li::before {
  content: counter(step-counter);
  position: absolute;
  left: 0;
  top: 8px;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: var(--bg-mid);
  border: 1px solid var(--card-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
}

/* ---- Timeline (for study plan) ---- */
.timeline {
  position: relative;
  padding-left: var(--space-2xl);
  margin: var(--space-xl) 0;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 11px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: linear-gradient(180deg, var(--accent-lavender), var(--accent-teal));
  opacity: 0.3;
}

.timeline-item {
  position: relative;
  margin-bottom: var(--space-xl);
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: calc(-1 * var(--space-2xl) + 6px);
  top: 6px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--bg-deep);
  border: 2px solid var(--accent-lavender);
}

.timeline-item h4 {
  color: var(--text-heading);
  margin-bottom: var(--space-xs);
}

.timeline-item p {
  font-size: 0.9rem;
}


/* ============================================================
   NEW COMPONENTS
   ============================================================ */

/* ---- (a) Virtual Calculator Widget ---- */
.calculator-widget {
  position: fixed;
  bottom: 80px;
  right: 24px;
  width: 320px;
  background: #ffffff;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.06);
  z-index: 500;
  display: none;
  flex-direction: column;
  overflow: hidden;
  transition: opacity var(--transition-fast), transform var(--transition-fast);
}

.calculator-widget.visible {
  display: flex;
}

/* Drag handle */
.calculator-widget .calc-drag-handle {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px 0;
  cursor: grab;
  background: var(--bg-mid);
  border-bottom: 1px solid var(--card-border);
  user-select: none;
}

.calculator-widget .calc-drag-handle:active {
  cursor: grabbing;
}

.calculator-widget .calc-drag-handle::before {
  content: '';
  width: 32px;
  height: 4px;
  border-radius: 2px;
  background: rgba(0, 0, 0, 0.12);
}

.calc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-mid);
  border-bottom: 1px solid var(--card-border);
}

.calc-header .calc-title {
  font-family: 'Outfit', sans-serif;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-heading);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.calc-header .calc-close {
  width: 24px;
  height: 24px;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--text-muted);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.calc-header .calc-close:hover {
  background: rgba(0, 0, 0, 0.05);
  color: var(--text-primary);
}

/* Calculator display */
.calc-display {
  background: #1a1a2e;
  color: #e8e6f0;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 1.6rem;
  font-weight: 500;
  text-align: right;
  padding: var(--space-md) var(--space-lg);
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  line-height: 1;
  letter-spacing: 0.02em;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  word-break: break-all;
  overflow: hidden;
}

/* TVM register display */
.calc-register-display {
  background: #1e1e36;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.calc-register-display .register {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 4px;
  border-right: 1px solid rgba(255, 255, 255, 0.04);
}

.calc-register-display .register:last-child {
  border-right: none;
}

.calc-register-display .register-label {
  font-family: 'Inter', sans-serif;
  font-size: 0.6rem;
  font-weight: 600;
  color: rgba(232, 230, 240, 0.4);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 2px;
}

.calc-register-display .register-value {
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 0.7rem;
  color: rgba(232, 230, 240, 0.7);
}

/* Calculator buttons */
.calc-buttons {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  padding: 8px;
  background: var(--bg-mid);
}

.calc-btn {
  height: 42px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: 'Inter', sans-serif;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  background: #ffffff;
  color: var(--text-primary);
  border: 1px solid var(--card-border);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.calc-btn:hover {
  background: var(--bg-glass-hover);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
  transform: translateY(-1px);
}

.calc-btn:active {
  transform: translateY(0);
  box-shadow: 0 0 0 rgba(0, 0, 0, 0.04);
  background: var(--bg-mid);
}

/* Number buttons */
.calc-btn.number {
  background: #ffffff;
  font-weight: 600;
}

/* Operator buttons */
.calc-btn.operator {
  background: var(--bg-mid);
  color: var(--accent-lavender);
  font-weight: 600;
  font-size: 0.95rem;
}

.calc-btn.operator:hover {
  background: var(--accent-lavender-bg);
  border-color: rgba(124, 92, 191, 0.2);
}

/* Financial function buttons (N, I/Y, PV, PMT, FV) */
.calc-btn.function {
  background: rgba(13, 148, 136, 0.06);
  color: var(--accent-teal);
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.calc-btn.function:hover {
  background: var(--accent-teal-bg);
  border-color: rgba(13, 148, 136, 0.2);
}

/* Action buttons (CE, C, 2ND) */
.calc-btn.action {
  background: rgba(229, 115, 115, 0.06);
  color: var(--accent-peach);
  font-weight: 600;
  font-size: 0.75rem;
}

.calc-btn.action:hover {
  background: var(--accent-peach-bg);
  border-color: rgba(229, 115, 115, 0.2);
}

/* CPT / Compute button */
.calc-btn.compute {
  background: var(--accent-lavender);
  color: #ffffff;
  font-weight: 700;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-color: var(--accent-lavender);
  box-shadow: 0 2px 8px rgba(124, 92, 191, 0.25);
}

.calc-btn.compute:hover {
  background: #6a4aad;
  box-shadow: 0 4px 14px rgba(124, 92, 191, 0.35);
  transform: translateY(-1px);
}

.calc-btn.compute:active {
  background: #5d3fa0;
  transform: translateY(0);
}

/* Toggle button (floating action button) */
.calc-toggle {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--accent-lavender);
  color: #ffffff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  box-shadow: 0 4px 16px rgba(124, 92, 191, 0.3);
  transition: all var(--transition-fast);
}

.calc-toggle:hover {
  background: #6a4aad;
  box-shadow: 0 6px 24px rgba(124, 92, 191, 0.4);
  transform: translateY(-2px) scale(1.05);
}

.calc-toggle:active {
  transform: translateY(0) scale(0.98);
}

.calc-toggle svg {
  width: 22px;
  height: 22px;
}


/* ---- Calculator JS-generated class aliases ---- */
/* The calculator.js creates DOM with these classes; map them to the CSS styles */
.calc-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 4px;
  padding: 8px;
  background: var(--bg-mid);
}

/* Rows 2-5 have 5 buttons each; make the last button in each row span the empty column */
/* This is handled naturally since we use 6 cols and row 1 has 6 items */

.calc-digit {
  background: #ffffff;
  font-weight: 600;
}

.calc-tvm {
  background: rgba(13, 148, 136, 0.06);
  color: var(--accent-teal);
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.calc-tvm:hover {
  background: var(--accent-teal-bg);
  border-color: rgba(13, 148, 136, 0.2);
}

.calc-op {
  background: var(--bg-mid);
  color: var(--accent-lavender);
  font-weight: 600;
  font-size: 0.95rem;
}

.calc-op:hover {
  background: var(--accent-lavender-bg);
  border-color: rgba(124, 92, 191, 0.2);
}

.calc-func {
  background: rgba(229, 115, 115, 0.06);
  color: var(--accent-peach);
  font-weight: 600;
  font-size: 0.75rem;
}

.calc-func:hover {
  background: var(--accent-peach-bg);
  border-color: rgba(229, 115, 115, 0.2);
}

/* CPT button in the JS uses calc-func but should look like compute */
.calc-btn.calc-func:first-child {
  background: rgba(229, 115, 115, 0.06);
}

.calc-equals {
  background: var(--accent-lavender) !important;
  color: #ffffff !important;
  font-weight: 700;
  border-color: var(--accent-lavender) !important;
  box-shadow: 0 2px 8px rgba(124, 92, 191, 0.25);
}

.calc-clear-all {
  grid-column: 1 / -1;
}

.calc-close-btn {
  width: 24px;
  height: 24px;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--text-muted);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  transition: all var(--transition-fast);
}

.calc-close-btn:hover {
  background: rgba(0, 0, 0, 0.05);
  color: var(--text-primary);
}

.calc-indicator {
  background: #15152e;
  color: rgba(167, 139, 250, 0.8);
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 0.7rem;
  font-weight: 600;
  text-align: right;
  padding: 4px var(--space-lg);
  min-height: 18px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.calc-registers {
  background: #1e1e36;
  color: rgba(232, 230, 240, 0.6);
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 0.65rem;
  text-align: center;
  padding: 6px var(--space-md);
  letter-spacing: 0.02em;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  white-space: nowrap;
  overflow-x: auto;
}

/* Make first row (2ND + 5 TVM keys = 6 buttons) span properly */
.calc-grid {
  grid-template-columns: repeat(5, 1fr);
}

/* The first 6 items need to fit in a 6-column sub-grid effect */
.calc-grid > button:nth-child(1),
.calc-grid > button:nth-child(2),
.calc-grid > button:nth-child(3),
.calc-grid > button:nth-child(4),
.calc-grid > button:nth-child(5),
.calc-grid > button:nth-child(6) {
  /* First row has 6 buttons -- they will wrap to use available space */
}


/* ---- (b) Calculator Guide Component ---- */
.calculator-guide {

  background: rgba(14, 165, 233, 0.05);
  border: 1px solid rgba(14, 165, 233, 0.12);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  margin: var(--space-lg) 0;
}

.calc-guide-label {
  font-weight: 600;
  color: var(--accent-sky);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-md);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.calc-steps {
  list-style: none;
  padding: 0;
  counter-reset: calc-step;
}

.calc-steps li {
  counter-increment: calc-step;
  position: relative;
  padding: var(--space-xs) 0 var(--space-xs) var(--space-2xl);
  color: var(--text-secondary);
  line-height: 1.7;
}

.calc-steps li::before {
  content: counter(calc-step);
  position: absolute;
  left: 0;
  top: 6px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent-sky-bg);
  border: 1px solid rgba(14, 165, 233, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--accent-sky);
}

/* Inline calculator key styling */
.calc-key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 1px 8px;
  border-radius: 4px;
  background: var(--bg-mid);
  border: 1px solid var(--card-border);
  font-family: 'Inter', sans-serif;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-heading);
  white-space: nowrap;
  vertical-align: baseline;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}


/* ---- (c) Worked Example Component ---- */
.worked-example {
  background: #ffffff;
  border: 1px solid rgba(124, 92, 191, 0.12);
  border-radius: var(--radius-lg);
  padding: 0;
  margin: var(--space-xl) 0;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.04);
  overflow: hidden;
  position: relative;
}

.worked-example::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--accent-lavender), var(--accent-teal));
}

.example-label {
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  color: var(--accent-lavender);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: var(--space-lg) var(--space-xl) 0;
  margin-bottom: var(--space-md);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.example-problem {
  color: var(--text-secondary);
  padding: 0 var(--space-xl) var(--space-lg);
  border-bottom: 1px solid var(--card-border);
  margin-bottom: 0;
}

.example-problem p {
  margin-bottom: var(--space-sm);
  font-size: 0.95rem;
  line-height: 1.75;
}

.example-solution {
  position: relative;
  padding: var(--space-lg) var(--space-xl);
  background: rgba(0, 0, 0, 0.012);
}

.solution-toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  background: var(--bg-mid);
  color: var(--text-secondary);
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.solution-toggle:hover {
  background: var(--accent-lavender-bg);
  border-color: rgba(124, 92, 191, 0.2);
  color: var(--accent-lavender);
}

.solution-content {
  display: none;
  margin-top: var(--space-md);
  padding: var(--space-md);
  background: #ffffff;
  border-radius: var(--radius-sm);
  border: 1px solid var(--card-border);
}

.example-solution.show .solution-content {
  display: block;
  animation: fadeIn 0.3s var(--ease-out);
}

.solution-content p {
  margin-bottom: var(--space-sm);
  font-size: 0.95rem;
  line-height: 1.75;
}


/* ---- (d) Real-World Example Component ---- */
.real-world-box {
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.03) 0%, rgba(14, 165, 233, 0.09) 100%);
  border-left: 4px solid var(--accent-sky);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  padding: var(--space-lg) var(--space-xl);
  margin: var(--space-xl) 0;
  box-shadow: 0 2px 8px rgba(14, 165, 233, 0.06);
  position: relative;
  overflow: hidden;
}

.real-world-box::after {
  content: '';
  position: absolute;
  bottom: -20px;
  right: -20px;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  border: 2px solid rgba(14, 165, 233, 0.06);
  pointer-events: none;
}

.real-world-label {
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  color: var(--accent-sky);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: var(--space-sm);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.real-world-box p {
  color: var(--text-primary);
  margin-bottom: var(--space-sm);
  font-size: 0.95rem;
  line-height: 1.75;
}

.real-world-box p:last-child {
  margin-bottom: 0;
}



/* ---- (e) Quiz / Practice Activity Component ---- */
.quiz-container {
  background: #ffffff;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  margin: var(--space-xl) 0;
  box-shadow: var(--card-shadow);
}

.quiz-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text-heading);
  margin-bottom: var(--space-lg);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding-bottom: var(--space-md);
  border-bottom: 1px solid var(--card-border);
}

.quiz-question {
  margin-bottom: var(--space-xl);
  padding-bottom: var(--space-lg);
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
}

.quiz-question:last-of-type {
  border-bottom: none;
  margin-bottom: var(--space-md);
}

.question-text {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: var(--space-md);
  line-height: 1.6;
}

.quiz-options {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.quiz-option {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  background: var(--bg-deep);
  cursor: pointer;
  transition: all var(--transition-fast);
  user-select: none;
}

.quiz-option:hover {
  background: var(--accent-lavender-bg);
  border-color: rgba(124, 92, 191, 0.2);
}

.quiz-option.selected {
  background: var(--accent-lavender-bg);
  border-color: rgba(124, 92, 191, 0.3);
  box-shadow: 0 0 0 2px rgba(124, 92, 191, 0.1);
}

.quiz-option.correct {
  background: rgba(13, 148, 136, 0.08);
  border-color: rgba(13, 148, 136, 0.3);
  box-shadow: 0 0 0 2px rgba(13, 148, 136, 0.1);
}

.quiz-option.incorrect {
  background: rgba(229, 115, 115, 0.08);
  border-color: rgba(229, 115, 115, 0.3);
  box-shadow: 0 0 0 2px rgba(229, 115, 115, 0.1);
}

.option-letter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg-mid);
  border: 1px solid var(--card-border);
  font-family: 'Outfit', sans-serif;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  flex-shrink: 0;
  transition: all var(--transition-fast);
}

.quiz-option.selected .option-letter {
  background: var(--accent-lavender);
  color: #ffffff;
  border-color: var(--accent-lavender);
}

.quiz-option.correct .option-letter {
  background: var(--accent-teal);
  color: #ffffff;
  border-color: var(--accent-teal);
}

.quiz-option.incorrect .option-letter {
  background: var(--accent-peach);
  color: #ffffff;
  border-color: var(--accent-peach);
}

.quiz-option .option-text {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.quiz-option.selected .option-text {
  color: var(--text-primary);
}

.quiz-feedback {
  display: none;
  margin-top: var(--space-md);
  padding: var(--space-md);
  border-radius: var(--radius-sm);
  background: var(--bg-mid);
  border: 1px solid var(--card-border);
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.quiz-feedback.visible {
  display: block;
  animation: fadeIn 0.3s var(--ease-out);
}

.quiz-score {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
  padding: var(--space-lg);
  background: var(--bg-mid);
  border-radius: var(--radius-md);
  border: 1px solid var(--card-border);
  margin-top: var(--space-lg);
  font-family: 'Outfit', sans-serif;
}

.quiz-score .score-value {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--accent-teal);
}

.quiz-score .score-label {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Quiz action buttons */
.quiz-actions {
  display: flex;
  gap: var(--space-md);
  margin-top: var(--space-lg);
}

.quiz-check-btn,
.quiz-reset-btn {
  padding: var(--space-sm) var(--space-lg);
  border-radius: var(--radius-sm);
  font-family: 'Inter', sans-serif;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  border: none;
}

.quiz-check-btn {
  background: var(--accent-lavender);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(124, 92, 191, 0.2);
}

.quiz-check-btn:hover {
  background: #6a4aad;
  box-shadow: 0 4px 14px rgba(124, 92, 191, 0.3);
  transform: translateY(-1px);
}

.quiz-check-btn:active {
  transform: translateY(0);
}

.quiz-reset-btn {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--card-border);
}

.quiz-reset-btn:hover {
  background: var(--bg-mid);
  color: var(--text-primary);
  border-color: rgba(0, 0, 0, 0.12);
}

.quiz-reset-btn {
  margin-top: var(--space-lg);
}

/* Disabled state -- after answering */
.quiz-option.disabled {
  pointer-events: none;
  opacity: 0.7;
}

.quiz-option.disabled.correct {
  opacity: 1;
}

.quiz-option.disabled.incorrect {
  opacity: 0.85;
}

/* Feedback colours */
.quiz-feedback.correct {
  background: rgba(13, 148, 136, 0.06);
  border-color: rgba(13, 148, 136, 0.15);
  color: #0d6b63;
}

.quiz-feedback.incorrect {
  background: rgba(229, 115, 115, 0.06);
  border-color: rgba(229, 115, 115, 0.15);
  color: #a14040;
}

/* Score display states */
.quiz-score {
  display: none;
}

.quiz-score.visible {
  display: flex;
  animation: fadeIn 0.3s var(--ease-out);
}

.quiz-score.pass {
  background: rgba(13, 148, 136, 0.06);
  border-color: rgba(13, 148, 136, 0.2);
  color: var(--accent-teal);
  font-weight: 600;
}

.quiz-score.fail {
  background: rgba(229, 115, 115, 0.06);
  border-color: rgba(229, 115, 115, 0.2);
  color: var(--accent-peach);
  font-weight: 600;
}

/* ---- Quiz: Reveal Answer Button ---- */
.quiz-reveal-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  margin-top: var(--space-md);
  padding: var(--space-sm) var(--space-lg);
  border-radius: var(--radius-sm);
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--card-border);
  background: var(--bg-mid);
  color: var(--text-muted);
  transition: all var(--transition-fast);
}

.quiz-reveal-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.quiz-reveal-btn.enabled {
  background: var(--accent-lavender-bg);
  color: var(--accent-lavender);
  border-color: rgba(124, 92, 191, 0.2);
}

.quiz-reveal-btn.enabled:hover {
  background: var(--accent-lavender);
  color: #ffffff;
  border-color: var(--accent-lavender);
  box-shadow: 0 2px 8px rgba(124, 92, 191, 0.25);
  transform: translateY(-1px);
}

/* ---- Quiz: Feedback (after reveal) ---- */
.quiz-feedback .feedback-status {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
  font-size: 0.9rem;
}

.quiz-feedback .feedback-status.correct {
  color: var(--accent-teal);
}

.quiz-feedback .feedback-status.incorrect {
  color: var(--accent-peach);
}

.quiz-feedback .feedback-status.unanswered {
  color: var(--text-muted);
}

.quiz-feedback .feedback-explanation {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.7;
}

.quiz-feedback.unanswered {
  background: var(--bg-mid);
  border-color: var(--card-border);
}

/* ---- Quiz: Count Info ---- */
.quiz-count-info {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  margin-bottom: var(--space-lg);
  border-radius: var(--radius-sm);
  background: var(--accent-lavender-bg);
  border: 1px solid rgba(124, 92, 191, 0.12);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--accent-lavender);
}

/* ---- Quiz: See Results Button ---- */
.quiz-see-results-btn {
  display: block;
  width: 100%;
  margin-top: var(--space-xl);
  padding: var(--space-md) var(--space-xl);
  border-radius: var(--radius-md);
  font-family: 'Outfit', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  border: none;
  background: linear-gradient(135deg, var(--accent-lavender), #6a4aad);
  color: #ffffff;
  box-shadow: 0 4px 16px rgba(124, 92, 191, 0.3);
  transition: all var(--transition-fast);
  letter-spacing: 0.02em;
}

.quiz-see-results-btn:hover {
  box-shadow: 0 6px 24px rgba(124, 92, 191, 0.4);
  transform: translateY(-2px);
}

.quiz-see-results-btn:active {
  transform: translateY(0);
}

/* ---- Quiz: Results Tally ---- */
.quiz-tally {
  margin-top: var(--space-2xl);
  padding: var(--space-xl);
  border-radius: var(--radius-lg);
  background: #ffffff;
  border: 1px solid var(--card-border);
  box-shadow: var(--card-shadow-hover);
  animation: fadeIn 0.4s var(--ease-out);
}

.tally-header {
  text-align: center;
  margin-bottom: var(--space-xl);
  padding-bottom: var(--space-lg);
  border-bottom: 1px solid var(--card-border);
}

.tally-score {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: var(--space-md);
  margin-bottom: var(--space-sm);
}

.tally-number {
  font-family: 'Outfit', sans-serif;
  font-size: 2.5rem;
  font-weight: 800;
  line-height: 1;
}

.tally-pct {
  font-family: 'Outfit', sans-serif;
  font-size: 1.2rem;
  font-weight: 600;
  opacity: 0.7;
}

.tally-score.pass .tally-number,
.tally-score.pass .tally-pct {
  color: var(--accent-teal);
}

.tally-score.needs-work .tally-number,
.tally-score.needs-work .tally-pct {
  color: var(--accent-peach);
}

.tally-message {
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.tally-breakdown {
  margin-bottom: var(--space-lg);
}

.tally-breakdown-title {
  font-family: 'Outfit', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: var(--space-md);
}

.tally-row {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  margin-bottom: 4px;
  font-size: 0.85rem;
  transition: background var(--transition-fast);
}

.tally-row.correct {
  background: rgba(13, 148, 136, 0.04);
}

.tally-row.incorrect {
  background: rgba(229, 115, 115, 0.04);
}

.tally-row:hover {
  background: var(--bg-mid);
}

.tally-row-icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
}

.tally-row.correct .tally-row-icon {
  color: var(--accent-teal);
}

.tally-row.incorrect .tally-row-icon {
  color: var(--accent-peach);
}

.tally-row-text {
  flex: 1;
  color: var(--text-secondary);
  line-height: 1.4;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tally-q-num {
  font-weight: 700;
  color: var(--text-primary);
}

.tally-row-answer {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-shrink: 0;
  font-size: 0.78rem;
  font-weight: 600;
}

.tally-ans-correct {
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(13, 148, 136, 0.08);
  color: var(--accent-teal);
}

.tally-ans-wrong {
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(229, 115, 115, 0.08);
  color: var(--accent-peach);
  text-decoration: line-through;
}

/* ---- Quiz: Retry Button ---- */
.quiz-retry-btn {
  display: block;
  width: 100%;
  margin-top: var(--space-lg);
  padding: var(--space-md) var(--space-xl);
  border-radius: var(--radius-md);
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--card-border);
  background: var(--bg-mid);
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.quiz-retry-btn:hover {
  background: var(--accent-lavender-bg);
  color: var(--accent-lavender);
  border-color: rgba(124, 92, 191, 0.2);
  transform: translateY(-1px);
  box-shadow: var(--card-shadow);
}

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

@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-toggle {
    display: flex !important;
  }

  .main-content {
    margin-left: 0;
    padding: var(--space-2xl) var(--space-lg);
    padding-top: calc(var(--space-3xl) + 20px);
  }

  /* Move calculator to take more width on tablet */
  .calculator-widget {
    width: 300px;
    right: 16px;
    bottom: 72px;
  }

  .calc-toggle {
    right: 16px;
    bottom: 16px;
  }
}

@media (max-width: 640px) {
  h1 { font-size: 1.8rem; }
  h2 { font-size: 1.4rem; }

  .main-content {
    padding: var(--space-xl) var(--space-md);
    padding-top: calc(var(--space-3xl) + 20px);
  }

  .dashboard-grid {
    grid-template-columns: 1fr 1fr;
  }

  .topic-grid {
    grid-template-columns: 1fr;
  }

  .glass-card {
    padding: var(--space-lg);
  }

  /* Calculator adapts to mobile */
  .calculator-widget {
    width: calc(100vw - 32px);
    right: 16px;
    bottom: 72px;
    max-width: 360px;
  }

  .calc-toggle {
    width: 46px;
    height: 46px;
    right: 16px;
    bottom: 16px;
  }

  /* Stack quiz action buttons */
  .quiz-actions {
    flex-direction: column;
  }

  .quiz-check-btn,
  .quiz-reset-btn {
    width: 100%;
    text-align: center;
    justify-content: center;
  }

  /* Worked example adjustments */
  .worked-example {
    padding: var(--space-md);
  }

  .quiz-container {
    padding: var(--space-lg);
  }
}

/* ============================================================
   ANIMATIONS
   ============================================================ */

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

@keyframes glow {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

.animate-in {
  animation: slideUp 0.6s var(--ease-out) both;
}

.animate-delay-1 { animation-delay: 0.1s; }
.animate-delay-2 { animation-delay: 0.2s; }
.animate-delay-3 { animation-delay: 0.3s; }
.animate-delay-4 { animation-delay: 0.4s; }

/* ============================================================
   STUDY TOOLS -- bookmark, highlights, notes
   ============================================================ */

/* ---- Floating tool button stack (bottom-right column) ----
   calc-toggle sits at bottom: 24px; the stack builds upward. */
.tool-fab {
  position: fixed;
  right: 24px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  color: #ffffff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  transition: all var(--transition-fast);
}

.tool-fab svg {
  width: 22px;
  height: 22px;
}

.bookmark-toggle {
  bottom: 88px;
  background: var(--accent-teal);
  box-shadow: 0 4px 16px rgba(13, 148, 136, 0.3);
}

.bookmark-toggle:hover {
  background: #0b7c72;
  box-shadow: 0 6px 24px rgba(13, 148, 136, 0.4);
  transform: translateY(-2px) scale(1.05);
}

.notes-toggle {
  bottom: 152px;
  background: var(--accent-amber);
  box-shadow: 0 4px 16px rgba(217, 119, 6, 0.3);
}

.notes-toggle:hover,
.notes-toggle.active {
  background: #b45309;
  box-shadow: 0 6px 24px rgba(217, 119, 6, 0.4);
}

.notes-toggle:hover {
  transform: translateY(-2px) scale(1.05);
}

.tool-fab:active {
  transform: translateY(0) scale(0.98);
}

/* Bookmark FAB feedback: swap icon to a check when saved */
.bookmark-toggle .icon-check { display: none; }
.bookmark-toggle.flash .icon-bookmark { display: none; }
.bookmark-toggle.flash .icon-check { display: block; }
.bookmark-toggle.flash { background: #0b7c72; }

/* Move scroll-to-top to the head of the stack so it no longer
   hides underneath the calculator button */
.scroll-top {
  bottom: 216px;
  right: 29px;
}

/* ---- Sidebar bookmark chip ---- */
.bookmark-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: var(--space-sm) var(--space-lg) 0;
  padding: 10px 12px;
  background: var(--sidebar-glass);
  border: 1px solid var(--sidebar-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.bookmark-chip:hover {
  background: var(--sidebar-glass-hover);
}

.bookmark-chip-icon {
  flex: none;
  display: flex;
  color: #5eead4;
}

.bookmark-chip-icon svg {
  width: 16px;
  height: 16px;
}

.bookmark-chip-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.bookmark-chip-title {
  font-family: 'Outfit', sans-serif;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--sidebar-text-secondary);
}

.bookmark-chip-detail {
  font-size: 0.8rem;
  color: var(--sidebar-text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bookmark-chip-remove {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--sidebar-text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.bookmark-chip-remove:hover {
  background: var(--sidebar-glass-hover);
  color: var(--sidebar-text-primary);
}

.bookmark-chip-remove svg {
  width: 12px;
  height: 12px;
}

/* ---- Highlight marks ---- */
mark.cfa-highlight {
  color: inherit;
  padding: 0.05em 0;
  border-radius: 3px;
  cursor: pointer;
  transition: background var(--transition-fast);
}

mark.cfa-hl-amber {
  background: rgba(251, 191, 36, 0.35);
  border-bottom: 2px solid rgba(217, 119, 6, 0.45);
}

mark.cfa-hl-amber:hover { background: rgba(251, 191, 36, 0.5); }

mark.cfa-hl-teal {
  background: rgba(45, 212, 191, 0.28);
  border-bottom: 2px solid rgba(13, 148, 136, 0.45);
}

mark.cfa-hl-teal:hover { background: rgba(45, 212, 191, 0.42); }

mark.cfa-hl-lavender {
  background: rgba(167, 139, 250, 0.28);
  border-bottom: 2px solid rgba(124, 92, 191, 0.45);
}

mark.cfa-hl-lavender:hover { background: rgba(167, 139, 250, 0.42); }

/* Highlights carrying a note get a dotted underline + dot cue */
mark.cfa-highlight.has-note {
  border-bottom-style: dotted;
  border-bottom-width: 2px;
}

mark.cfa-highlight.has-note::after {
  content: '';
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.45;
  margin-left: 3px;
  vertical-align: super;
}

/* Flash pulse when jumping to a highlight from the notes panel */
@keyframes hlFlash {
  0%, 100% { box-shadow: 0 0 0 0 rgba(124, 92, 191, 0); }
  30% { box-shadow: 0 0 0 6px rgba(124, 92, 191, 0.25); }
}

mark.cfa-highlight.hl-flash {
  animation: hlFlash 0.8s var(--ease-out) 2;
}

/* ---- Selection toolbar ---- */
.hl-toolbar {
  position: fixed;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  background: var(--sidebar-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--sidebar-border);
  border-radius: 999px;
  box-shadow: 0 8px 30px rgba(15, 18, 45, 0.35);
  z-index: 700;
  opacity: 0;
  pointer-events: none;
  transform: translateY(4px);
  transition: opacity var(--transition-fast), transform var(--transition-fast);
}

.hl-toolbar.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.hl-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.25);
  cursor: pointer;
  transition: transform var(--transition-fast), border-color var(--transition-fast);
}

.hl-dot:hover {
  transform: scale(1.2);
  border-color: rgba(255, 255, 255, 0.7);
}

.hl-dot-amber { background: #fbbf24; }
.hl-dot-teal { background: #2dd4bf; }
.hl-dot-lavender { background: #a78bfa; }

.hl-toolbar-sep {
  width: 1px;
  height: 18px;
  background: var(--sidebar-border);
}

.hl-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--sidebar-text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.hl-btn:hover {
  background: var(--sidebar-glass-hover);
  color: var(--sidebar-text-primary);
}

.hl-btn svg {
  width: 14px;
  height: 14px;
}

/* Remove button only makes sense on an existing highlight */
.hl-toolbar .hl-btn-remove { display: none; }
.hl-toolbar.edit-mode .hl-btn-remove { display: flex; }

/* ---- Note popover ---- */
.hl-popover {
  position: fixed;
  width: 300px;
  max-width: calc(100vw - 24px);
  padding: var(--space-md);
  background: var(--bg-glass);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  box-shadow: var(--card-shadow-hover);
  z-index: 700;
  opacity: 0;
  pointer-events: none;
  transform: translateY(4px);
  transition: opacity var(--transition-fast), transform var(--transition-fast);
}

.hl-popover.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.hl-popover-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'Outfit', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-heading);
  margin-bottom: var(--space-sm);
}

.hl-popover-title svg {
  width: 14px;
  height: 14px;
  color: var(--accent-lavender);
}

.hl-popover-text {
  width: 100%;
  resize: vertical;
  min-height: 72px;
  padding: 10px;
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-mid);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color var(--transition-fast);
}

.hl-popover-text:focus {
  border-color: var(--accent-lavender);
}

.hl-popover-actions {
  display: flex;
  gap: 8px;
  margin-top: var(--space-sm);
}

.hl-popover-save,
.hl-popover-clear {
  flex: 1;
  padding: 8px 12px;
  font-family: 'Outfit', sans-serif;
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.hl-popover-save {
  background: var(--accent-lavender);
  color: #ffffff;
  border: none;
}

.hl-popover-save:hover { background: #6a4aad; }

.hl-popover-clear {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--card-border);
}

.hl-popover-clear:hover {
  color: var(--accent-peach);
  border-color: var(--accent-peach);
}

/* ---- Notes panel ---- */
.notes-panel {
  position: fixed;
  top: 0;
  right: 0;
  height: 100dvh;
  width: 380px;
  max-width: 94vw;
  display: flex;
  flex-direction: column;
  background: var(--bg-glass);
  border-left: 1px solid var(--card-border);
  box-shadow: -12px 0 40px rgba(0, 0, 0, 0.12);
  z-index: 600;
  transform: translateX(105%);
  transition: transform var(--transition-med);
}

.notes-panel.open {
  transform: translateX(0);
}

.notes-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  padding: var(--space-lg);
  border-bottom: 1px solid var(--card-border);
}

.notes-header-text h3 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-heading);
}

.notes-topic {
  font-size: 0.8rem;
  color: var(--accent-lavender);
  font-weight: 500;
}

.notes-header-actions {
  display: flex;
  gap: 6px;
}

.notes-export,
.notes-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.notes-export:hover,
.notes-close:hover {
  color: var(--accent-lavender);
  border-color: var(--accent-lavender);
}

.notes-export svg,
.notes-close svg {
  width: 15px;
  height: 15px;
}

.notes-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: var(--space-lg);
  gap: var(--space-sm);
  overflow-y: auto;
}

.notes-label {
  font-family: 'Outfit', sans-serif;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.notes-annotations-label {
  margin-top: var(--space-md);
}

.notes-textarea {
  width: 100%;
  min-height: 220px;
  resize: vertical;
  padding: var(--space-md);
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg-mid);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  outline: none;
  transition: border-color var(--transition-fast);
}

.notes-textarea:focus {
  border-color: var(--accent-lavender);
}

.notes-annotations {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.notes-empty {
  font-size: 0.83rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.note-annotation {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  text-align: left;
  background: var(--bg-mid);
  border: 1px solid var(--card-border);
  border-left-width: 3px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.note-annotation:hover {
  background: var(--bg-glass-hover);
  box-shadow: var(--card-shadow);
}

.note-annotation-amber { border-left-color: var(--accent-amber); }
.note-annotation-teal { border-left-color: var(--accent-teal); }
.note-annotation-lavender { border-left-color: var(--accent-lavender); }

.note-annotation-quote {
  font-size: 0.8rem;
  font-style: italic;
  color: var(--text-secondary);
}

.note-annotation-note {
  font-size: 0.83rem;
  color: var(--text-primary);
}

/* ---- Study tools responsive ---- */
@media (max-width: 1024px) {
  .tool-fab { right: 16px; }
  .bookmark-toggle { bottom: 80px; }
  .notes-toggle { bottom: 144px; }
  .scroll-top { bottom: 208px; right: 21px; }
}

@media (max-width: 640px) {
  .tool-fab {
    width: 46px;
    height: 46px;
    right: 16px;
  }
  .bookmark-toggle { bottom: 74px; }
  .notes-toggle { bottom: 132px; }
  .scroll-top { bottom: 190px; right: 18px; }
  .notes-panel { width: 100vw; max-width: 100vw; }
}

/* ============================================================
   MOTION & ENGAGEMENT LAYER
   Scroll reveals, sliding nav indicator, reading progress,
   card tilt + cursor spotlight, ripples, tactile quiz feedback.
   All effects use transform/opacity only (GPU-friendly) and are
   disabled under prefers-reduced-motion.
   ============================================================ */

/* ---- Scroll reveal system (transition-based so computed
   transform returns to none, keeping position:sticky intact) ---- */
.reveal {
  opacity: 0;
  transform: translateY(20px);
}

.reveal.reveal-left { transform: translateX(-26px); }
.reveal.reveal-scale { transform: translateY(12px) scale(0.965); }

.reveal.reveal-in {
  opacity: 1;
  transform: none;
  transition: opacity 0.65s var(--ease-out), transform 0.65s var(--ease-out);
}

/* ---- Reading progress bar (top of viewport) ---- */
.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 100%;
  transform-origin: 0 50%;
  transform: scaleX(0);
  background: linear-gradient(90deg, #a78bfa, #5eead4, #7dd3fc);
  z-index: 300;
  pointer-events: none;
  transition: transform 0.08s linear;
}

/* ---- Sliding sidebar nav indicator ---- */
.sidebar-nav { position: relative; }

.nav-indicator {
  position: absolute;
  left: 0;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: linear-gradient(180deg, #a78bfa, #5eead4);
  box-shadow: 0 0 12px rgba(167, 139, 250, 0.5);
  transition: top 0.45s var(--ease-out), height 0.45s var(--ease-out), opacity 0.3s;
  pointer-events: none;
}

/* the sliding pill replaces the static active border */
.sidebar .nav-item.active { border-left-color: transparent; }

.nav-item {
  position: relative;
  overflow: hidden;
}

.nav-item:hover {
  transform: translateX(3px);
}

/* ---- Ripple effect (spawned by JS on click) ---- */
.ripple {
  position: absolute;
  border-radius: 50%;
  transform: scale(0);
  background: rgba(124, 92, 191, 0.18);
  animation: rippleGrow 0.55s var(--ease-out) forwards;
  pointer-events: none;
}

.sidebar .ripple,
.calc-toggle .ripple,
.tool-fab .ripple {
  background: rgba(255, 255, 255, 0.28);
}

@keyframes rippleGrow {
  to { transform: scale(1); opacity: 0; }
}

/* ripple hosts need containment */
.quiz-reveal-btn,
.quiz-see-results-btn,
.quiz-retry-btn,
.level-btn,
.calc-toggle,
.tool-fab {
  position: relative;
  overflow: hidden;
}

.quiz-option { position: relative; overflow: hidden; }

/* ---- Topic card tilt + cursor spotlight ---- */
.topic-card {
  will-change: transform;
  transition: transform 0.18s ease-out, box-shadow var(--transition-fast);
}

.topic-card::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(260px circle at var(--mx, 50%) var(--my, 50%),
    rgba(124, 92, 191, 0.10), transparent 65%);
  opacity: 0;
  transition: opacity 0.35s var(--ease-out);
  pointer-events: none;
}

.topic-card:hover::after { opacity: 1; }

.topic-card:hover {
  box-shadow: var(--card-shadow-hover);
}

.topic-card:hover .topic-number {
  opacity: 0.5;
  transition: opacity 0.3s var(--ease-out);
}

/* ---- Level roadmap cards: lift + ambient glow on active ---- */
.level-card {
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.level-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--card-shadow-hover);
}

.level-card.active {
  animation: activeGlow 4.5s ease-in-out infinite;
}

@keyframes activeGlow {
  0%, 100% { box-shadow: 0 0 0 1px rgba(124, 92, 191, 0.15), 0 4px 20px rgba(124, 92, 191, 0.08); }
  50% { box-shadow: 0 0 0 1px rgba(124, 92, 191, 0.3), 0 6px 28px rgba(124, 92, 191, 0.18); }
}

/* ---- Content box micro-interactions ---- */
.definition-box,
.formula-card,
.study-tip,
.exam-pitfall,
.real-world-box,
.calculator-guide,
.worked-example {
  transition: transform 0.25s var(--ease-out), box-shadow 0.25s var(--ease-out);
}

.definition-box:hover,
.study-tip:hover,
.exam-pitfall:hover,
.real-world-box:hover,
.calculator-guide:hover {
  transform: translateY(-2px);
}

.formula-card:hover,
.worked-example:hover {
  transform: translateY(-3px);
  box-shadow: var(--card-shadow-hover);
}

/* ---- Progress bar sheen ---- */
.progress-bar-fill {
  position: relative;
  overflow: hidden;
}

.progress-bar-fill::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  width: 40%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.35), transparent);
  animation: sheenSweep 2.8s var(--ease-out) infinite;
}

@keyframes sheenSweep {
  0% { left: -45%; }
  60%, 100% { left: 110%; }
}

/* ---- Quiz feedback: tactile pop and shake ---- */
.quiz-option.correct {
  animation: popCorrect 0.5s var(--ease-out);
}

.quiz-option.incorrect {
  animation: shakeWrong 0.45s var(--ease-out);
}

@keyframes popCorrect {
  0% { transform: scale(1); }
  35% { transform: scale(1.025); }
  100% { transform: scale(1); }
}

@keyframes shakeWrong {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-5px); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(3px); }
}

.quiz-option.correct .option-letter {
  animation: popCorrect 0.5s var(--ease-out);
}

.quiz-feedback.visible {
  animation: feedbackIn 0.45s var(--ease-out);
}

@keyframes feedbackIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.quiz-tally {
  animation: slideUp 0.6s var(--ease-out);
}

/* primary quiz buttons: sheen sweep on hover */
.quiz-reveal-btn::after,
.quiz-see-results-btn::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: -60%;
  width: 45%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.25), transparent);
  transform: skewX(-18deg);
  transition: left 0.5s var(--ease-out);
  pointer-events: none;
}

.quiz-reveal-btn.enabled:hover::after,
.quiz-see-results-btn:hover::after {
  left: 115%;
}

/* ---- Completion checkbox celebration ---- */
@keyframes checkPop {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(13, 148, 136, 0.45); }
  45% { transform: scale(1.25); }
  100% { transform: scale(1); box-shadow: 0 0 0 14px rgba(13, 148, 136, 0); }
}

.completion-check input:checked ~ .check-box {
  animation: checkPop 0.55s var(--ease-out);
}

/* ---- Stat value counter styling hook ---- */
.stat-card .stat-value {
  font-variant-numeric: tabular-nums;
}

/* ---- Reduced motion: show everything, move nothing ---- */
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1 !important; transform: none !important; }
  .reading-progress { display: none; }
  *,
  *::before,
  *::after {
    animation-duration: 0.001s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001s !important;
  }
}
