/* ==========================================================================
   MathLab Interactive - Design System & Modern Glassmorphism Styling
   Author & Lead Engineer: Duc Tien (Control & Automation Engineer)
   ========================================================================== */

:root {
  --bg-main: #090d16;
  --bg-card: rgba(15, 23, 42, 0.85);
  --bg-card-hover: rgba(30, 41, 59, 0.9);
  --bg-header: rgba(10, 15, 29, 0.92);
  --bg-sidebar: rgba(15, 23, 42, 0.95);
  --border-glass: rgba(168, 85, 247, 0.2);
  --border-glass-light: rgba(255, 255, 255, 0.08);
  --math-accent: #a855f7;
  --math-accent-light: #c084fc;
  --math-accent-glow: rgba(168, 85, 247, 0.4);
  --cyan-accent: #06b6d4;
  --emerald-accent: #10b981;
  --amber-accent: #f59e0b;
  --rose-accent: #f43f5e;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Roboto Mono', monospace;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 22px;
  --shadow-glow: 0 0 25px rgba(168, 85, 247, 0.25);
  --shadow-card: 0 10px 30px -5px rgba(0, 0, 0, 0.5);
}

[data-theme="light"] {
  --bg-main: #f1f5f9;
  --bg-card: rgba(255, 255, 255, 0.92);
  --bg-card-hover: rgba(248, 250, 252, 0.98);
  --bg-header: rgba(255, 255, 255, 0.95);
  --bg-sidebar: rgba(255, 255, 255, 0.98);
  --border-glass: rgba(168, 85, 247, 0.25);
  --border-glass-light: rgba(0, 0, 0, 0.08);
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --shadow-card: 0 10px 25px -5px rgba(0, 0, 0, 0.08);
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-main);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* Header */
.lab-header {
  height: 60px;
  background: var(--bg-header);
  border-bottom: 1px solid var(--border-glass-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 50;
  flex-shrink: 0;
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
}

.brand-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #9333ea, #c084fc);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.2rem;
  box-shadow: 0 0 15px var(--math-accent-glow);
}

.brand-text h1 {
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #fff 30%, var(--math-accent-light) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

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

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

.btn-header {
  height: 34px;
  padding: 0 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border: 1px solid var(--border-glass-light);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-header:hover {
  background: rgba(168, 85, 247, 0.12);
  border-color: var(--math-accent);
  color: var(--math-accent-light);
}

.btn-header.active {
  background: var(--math-accent);
  color: #fff;
  border-color: var(--math-accent);
  box-shadow: 0 0 12px var(--math-accent-glow);
}

.btn-exam-hub {
  background: linear-gradient(135deg, #9333ea, #7c3aed);
  color: #fff !important;
  border: none;
  box-shadow: 0 4px 14px rgba(147, 51, 234, 0.35);
}

/* Main Workspace */
.workspace-layout {
  display: flex;
  flex: 1;
  height: calc(100vh - 60px);
  overflow: hidden;
}

/* Sidebar Catalog */
.sidebar-catalog {
  width: 320px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-glass-light);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: transform 0.3s ease;
}

.catalog-search-wrap {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-glass-light);
}

.catalog-search-input {
  width: 100%;
  height: 36px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-glass-light);
  border-radius: var(--radius-sm);
  padding: 0 0.85rem;
  color: var(--text-primary);
  font-size: 0.82rem;
  outline: none;
  transition: border-color 0.2s;
}

.catalog-search-input:focus {
  border-color: var(--math-accent);
}

.catalog-nav {
  display: flex;
  flex-wrap: wrap;
  padding: 0.5rem 0.75rem;
  gap: 0.3rem;
  border-bottom: 1px solid var(--border-glass-light);
  flex-shrink: 0;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.catalog-nav::-webkit-scrollbar {
  display: none;
}

.catalog-tab-btn {
  padding: 0.28rem 0.6rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-muted);
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}

.catalog-tab-btn:hover {
  background: rgba(168, 85, 247, 0.1);
  color: var(--math-accent-light);
}

.catalog-tab-btn.active {
  background: rgba(168, 85, 247, 0.2);
  border-color: rgba(168, 85, 247, 0.4);
  color: var(--math-accent-light);
}

.catalog-grade-filter-bar {
  display: flex;
  flex-wrap: wrap;
  padding: 0.4rem 0.75rem;
  gap: 0.3rem;
  border-bottom: 1px solid var(--border-glass-light);
  background: rgba(0, 0, 0, 0.2);
  flex-shrink: 0;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.catalog-grade-filter-bar::-webkit-scrollbar {
  display: none;
}

.grade-chip {
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-muted);
  border: 1px solid rgba(255, 255, 255, 0.08);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}

.grade-chip:hover {
  background: rgba(56, 189, 248, 0.1);
  color: #38bdf8;
  border-color: rgba(56, 189, 248, 0.3);
}

.grade-chip.active {
  background: rgba(56, 189, 248, 0.2);
  color: #38bdf8;
  border-color: rgba(56, 189, 248, 0.5);
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.25);
}

.catalog-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.sim-item-card {
  padding: 0.75rem;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  border: 1px solid var(--border-glass-light);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.sim-item-card:hover {
  background: var(--bg-card-hover);
  border-color: rgba(168, 85, 247, 0.4);
  transform: translateY(-2px);
}

.sim-item-card.active {
  border-color: var(--math-accent);
  background: rgba(168, 85, 247, 0.12);
  box-shadow: 0 0 15px rgba(168, 85, 247, 0.15);
}

.sim-item-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.sim-item-grade {
  font-size: 0.7rem;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  background: rgba(168, 85, 247, 0.15);
  color: var(--math-accent-light);
  font-weight: 600;
  align-self: flex-start;
}

.sim-item-desc {
  font-size: 0.75rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* Center Stage Canvas */
.canvas-stage {
  flex: 1;
  position: relative;
  background: radial-gradient(circle at center, rgba(168, 85, 247, 0.05) 0%, transparent 70%), #060911;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.stage-toolbar {
  height: 48px;
  background: rgba(15, 23, 42, 0.7);
  border-bottom: 1px solid var(--border-glass-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  backdrop-filter: blur(8px);
  z-index: 10;
}

.stage-title-wrap {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.stage-badge {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  color: #10b981;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 8px #10b981;
  animation: pulse-dot 1.8s infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

.stage-tools {
  display: flex;
  gap: 0.4rem;
}

.btn-tool {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-glass-light);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-tool:hover {
  background: rgba(168, 85, 247, 0.15);
  color: var(--math-accent-light);
}

.btn-tool.active {
  background: rgba(168, 85, 247, 0.35);
  border-color: #c084fc;
  color: #fef08a;
  box-shadow: 0 0 10px rgba(168, 85, 247, 0.4);
}

#mathCanvas {
  cursor: grab;
}

#mathCanvas.rotating {
  cursor: grabbing !important;
}

#mathCanvas.panning {
  cursor: move !important;
}

/* Learning Mode Tabs in Toolbar */
.stage-mode-tabs {
  display: flex;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border-glass-light);
  border-radius: var(--radius-sm);
  padding: 2px;
  gap: 2px;
}

.stage-mode-btn {
  padding: 0.35rem 0.75rem;
  border-radius: 4px;
  font-size: 0.76rem;
  font-weight: 700;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: all 0.2s ease;
}

.stage-mode-btn:hover {
  color: var(--text-primary);
}

.stage-mode-btn.active {
  background: var(--math-accent);
  color: #fff;
  box-shadow: 0 0 10px var(--math-accent-glow);
}

/* Stage Main Viewport */
.stage-main-viewport {
  flex: 1;
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.mode-view-pane {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: none;
  overflow-y: auto;
}

.mode-view-pane.active {
  display: block;
}

#paneSimView {
  overflow: hidden;
}

/* Theory & Problem Solving Containers */
.theory-content-container,
.methods-content-container {
  padding: 1.5rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  max-width: 980px;
  width: 100%;
  box-sizing: border-box;
  margin: 0 auto;
}

.theory-content-container p,
.theory-content-container li,
.methods-content-container p,
.methods-content-container div {
  font-size: 1.02rem;
  line-height: 1.75;
  word-break: break-word;
  overflow-wrap: break-word;
}

/* Big Crisp High-Contrast KaTeX Formulas */
.theory-content-container .katex,
.methods-content-container .katex {
  font-size: 1.18em !important;
  color: #38bdf8 !important;
  font-weight: 600;
  max-width: 100%;
}

.theory-content-container .katex-display,
.methods-content-container .katex-display {
  font-size: 1.22em !important;
  margin: 0.8rem 0 !important;
  padding: 0.75rem 1rem;
  background: rgba(10, 15, 29, 0.85);
  border: 1px solid rgba(168, 85, 247, 0.35);
  border-left: 4px solid var(--math-accent-light);
  border-radius: var(--radius-md);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  text-align: center;
  max-width: 100%;
  box-sizing: border-box;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
}

.theory-content-container .katex-display .katex,
.methods-content-container .katex-display .katex {
  color: #ffffff !important;
  max-width: 100%;
}

.theory-section-card,
.method-card {
  background: var(--bg-card);
  border: 1px solid var(--border-glass-light);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  overflow: hidden;
  transition: transform 0.2s, border-color 0.2s;
}

.theory-section-card:hover,
.method-card:hover {
  border-color: rgba(168, 85, 247, 0.4);
}

.theory-card-header,
.method-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-glass-light);
  padding-bottom: 0.6rem;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.method-tag {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  background: rgba(168, 85, 247, 0.15);
  color: var(--math-accent-light);
  text-transform: uppercase;
  white-space: nowrap;
}

.method-title {
  font-size: 1.05rem;
  font-weight: 800;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  word-break: break-word;
}

.step-box {
  background: rgba(0, 0, 0, 0.3);
  border-left: 3px solid var(--cyan-accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  width: 100%;
  box-sizing: border-box;
  overflow-x: auto;
}

.step-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--cyan-accent);
  text-transform: uppercase;
}

.example-box {
  background: rgba(255, 255, 255, 0.03);
  border: 1px dashed var(--border-glass);
  border-radius: var(--radius-md);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  width: 100%;
  box-sizing: border-box;
  overflow-x: auto;
}

.example-problem {
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.6;
  font-size: 0.94rem;
  word-break: break-word;
  overflow-wrap: break-word;
}

.example-solution {
  background: rgba(0, 0, 0, 0.4);
  border-radius: var(--radius-sm);
  padding: 0.85rem;
  font-size: 0.84rem;
  color: var(--text-secondary);
  line-height: 1.6;
  border-left: 3px solid var(--emerald-accent);
  word-break: break-word;
  overflow-wrap: break-word;
}

.casio-tip-box {
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.25);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.casio-badge {
  background: var(--amber-accent);
  color: #000;
  font-size: 0.72rem;
  font-weight: 800;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  text-transform: uppercase;
  flex-shrink: 0;
}

.trap-alert-box {
  background: rgba(244, 63, 94, 0.08);
  border: 1px solid rgba(244, 63, 94, 0.25);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.trap-badge {
  background: var(--rose-accent);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 800;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  text-transform: uppercase;
  flex-shrink: 0;
}

/* Right Controls Panel */
.controls-panel {
  width: 340px;
  background: var(--bg-sidebar);
  border-left: 1px solid var(--border-glass-light);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 1rem;
  gap: 1rem;
  flex-shrink: 0;
}

.panel-card {
  background: var(--bg-card);
  border: 1px solid var(--border-glass-light);
  border-radius: var(--radius-md);
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.panel-card-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--math-accent-light);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.formula-display-box {
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.75rem;
  min-height: 64px;
  width: 100%;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  color: #fff;
  text-align: center;
  line-height: 1.45;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
}

.formula-display-box .katex-display {
  margin: 0.15rem 0 !important;
  font-size: 1.05em !important;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
}

.formula-display-box .katex {
  font-size: 1em !important;
  white-space: nowrap !important;
  text-align: center;
}

.param-slider-group {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.param-slider-row {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.param-slider-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.param-input-wrap {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.param-num-input {
  width: 72px;
  height: 26px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  color: var(--cyan-accent);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 700;
  text-align: right;
  padding: 0 0.4rem;
  outline: none;
  transition: all 0.2s;
}

.param-num-input:focus {
  border-color: var(--math-accent);
  box-shadow: 0 0 8px var(--math-accent-glow);
  background: rgba(168, 85, 247, 0.12);
}

.coord-badge {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--cyan-accent);
  background: rgba(0, 0, 0, 0.3);
  padding: 3px 8px;
  border-radius: 4px;
  border: 1px solid var(--border-glass-light);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

#mathCanvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  cursor: grab;
}

#mathCanvas.panning {
  cursor: grabbing !important;
}

.math-slider {
  -webkit-appearance: none;
  width: 100%;
  height: 5px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.12);
  outline: none;
  transition: background 0.2s;
}

.math-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--math-accent);
  cursor: pointer;
  box-shadow: 0 0 8px var(--math-accent-glow);
  transition: transform 0.15s;
}

.math-slider::-webkit-slider-thumb:hover {
  transform: scale(1.25);
}

.analysis-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}

.analysis-table td {
  padding: 0.35rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.analysis-table td:first-child {
  color: var(--text-muted);
}

.analysis-table td:last-child {
  text-align: right;
  font-family: var(--font-mono);
  color: var(--emerald-accent);
  font-weight: 600;
}

/* Exam Hub Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

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

.exam-hub-card {
  width: 100%;
  max-width: 900px;
  max-height: 88vh;
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.exam-hub-header {
  padding: 1rem 1.5rem;
  background: linear-gradient(135deg, rgba(147, 51, 234, 0.2), rgba(192, 132, 252, 0.1));
  border-bottom: 1px solid var(--border-glass-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.exam-hub-tabs {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  background: rgba(0, 0, 0, 0.2);
  border-bottom: 1px solid var(--border-glass-light);
}

.exam-tab-btn {
  padding: 0.4rem 0.9rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
}

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

.exam-hub-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.cheatsheet-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
}

.formula-card {
  background: rgba(10, 15, 29, 0.75);
  border: 1px solid rgba(168, 85, 247, 0.3);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.formula-card:hover {
  border-color: rgba(56, 189, 248, 0.55);
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(56, 189, 248, 0.2);
}

.formula-card h4 {
  font-size: 1.05rem;
  font-weight: 700;
  color: #c084fc;
  margin-bottom: 0.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 0.4rem;
}

.formula-card p {
  font-size: 0.95rem !important;
  color: #e2e8f0 !important;
  line-height: 1.85 !important;
}

.formula-card .katex {
  font-size: 1.2em !important;
  color: #ffffff !important;
  font-weight: 500;
}

.formula-latex .katex {
  font-size: 1.35em !important;
  color: #38bdf8 !important;
  font-weight: 600;
}

.theory-content-container .katex,
.methods-content-container .katex {
  font-size: 1.18em !important;
}

.theory-section-card p,
.theory-section-card li,
.method-card p,
.step-box,
.example-problem,
.casio-tip,
.trap-warning {
  font-size: 0.95rem !important;
  line-height: 1.7 !important;
}

@media (max-width: 1024px) {
  .sidebar-catalog {
    width: 260px;
  }
  .controls-panel {
    width: 280px;
  }
}

@media (max-width: 768px) {
  .workspace-layout {
    flex-direction: column;
  }
  .sidebar-catalog {
    width: 100%;
    height: 180px;
  }
  .controls-panel {
    width: 100%;
    height: auto;
  }
}

/* ==========================================================================
   Pedagogical Modals System (Problem Solvers, Flashcards, Mastery, Shortcuts)
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.modal-backdrop.active {
  display: flex;
  opacity: 1;
}

.pedagogy-modal-card {
  background: #0b0f19;
  border: 1px solid rgba(168, 85, 247, 0.35);
  border-radius: 20px;
  width: 100%;
  max-width: 1100px;
  height: 88vh;
  max-height: 820px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.9), 0 0 40px rgba(168, 85, 247, 0.15);
  overflow: hidden;
  animation: modalScaleIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.pedagogy-modal-header {
  padding: 1.1rem 1.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(15, 23, 42, 0.6);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.pedagogy-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* Problem Solver Grid */
.solver-layout-grid {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 1.5rem;
  height: 100%;
}

@media (max-width: 900px) {
  .solver-layout-grid {
    grid-template-columns: 1fr;
  }
}

.solver-nav-list {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 14px;
  padding: 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  overflow-y: auto;
  max-height: 660px;
}

.solver-nav-btn {
  padding: 0.75rem 0.9rem;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s;
  line-height: 1.4;
}

.solver-nav-btn:hover {
  background: rgba(168, 85, 247, 0.12);
  color: var(--text-primary);
}

.solver-nav-btn.active {
  background: rgba(168, 85, 247, 0.25);
  border-color: rgba(168, 85, 247, 0.6);
  color: #c084fc;
  box-shadow: 0 0 15px rgba(168, 85, 247, 0.2);
}

.solver-detail-area {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  overflow-y: auto;
  padding-right: 0.5rem;
}

.solver-card-box {
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 1.25rem;
}

.solver-card-box h4 {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Flashcards 3D Flip System */
.flashcards-filter-bar {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.flashcard-pill-btn {
  padding: 0.45rem 0.9rem;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(15, 23, 42, 0.6);
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}

.flashcard-pill-btn.active {
  background: #9333ea;
  border-color: #c084fc;
  color: #fff;
  box-shadow: 0 0 15px rgba(168, 85, 247, 0.4);
}

.flashcard-deck-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  perspective: 1200px;
}

.math-flashcard-wrap {
  width: 100%;
  max-width: 650px;
  height: 340px;
  cursor: pointer;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.math-flashcard-wrap.flipped {
  transform: rotateY(180deg);
}

.math-card-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 20px;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border: 1px solid rgba(168, 85, 247, 0.4);
  box-shadow: 0 15px 35px -5px rgba(0, 0, 0, 0.7);
}

.math-card-face.front {
  background: linear-gradient(145deg, #0d1322, #161f36);
}

.math-card-face.back {
  background: linear-gradient(145deg, #150f29, #231542);
  transform: rotateY(180deg);
  border-color: rgba(56, 189, 248, 0.4);
}

/* Mastery Badges Grid */
.mastery-badges-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1.25rem;
}

.mastery-badge-card {
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  transition: all 0.25s;
}

.mastery-badge-card:hover {
  transform: translateY(-4px);
  border-color: rgba(168, 85, 247, 0.5);
  box-shadow: 0 12px 30px rgba(168, 85, 247, 0.2);
}

/* Shortcuts kbd styling */
.shortcut-table-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1rem;
}

.shortcut-item-row {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  padding: 0.9rem 1.1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

kbd.math-kbd {
  background: #1e293b;
  border: 1px solid #475569;
  box-shadow: 0 2px 0 #0f172a;
  border-radius: 6px;
  padding: 0.25rem 0.6rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 700;
  color: #38bdf8;
}

