/* ==========================================================================
   mathwithcye • KSSM Mathematics Form 4
   Chapter 1: Quadratic Functions and Equations in One Variable
   Lesson 1.2: Quadratic Equations and Roots (Persamaan Kuadratik & Punca)
   Responsive Design System, Touchscreen Ready, Teacher Teaching Tool & Remote
   ========================================================================== */

:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --secondary: #0ea5e9;
  --secondary-light: #f0f9ff;
  --accent: #8b5cf6;
  --accent-light: #f5f3ff;
  --success: #10b981;
  --success-light: #ecfdf5;
  --warning: #f59e0b;
  --warning-light: #fffbeb;
  --danger: #ef4444;
  --danger-light: #fef2f2;
  --dark: #0f172a;
  --card-bg: #ffffff;
  --bg-page: #f8fafc;
  --border: #e2e8f0;
  --border-focus: #3b82f6;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --font-main: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-math: "Cambria Math", "Times New Roman", Times, serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

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

body {
  font-family: var(--font-main);
  background-color: var(--bg-page);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* Container */
.app-container {
  max-width: 1240px;
  margin: 0 auto;
  padding: 16px 20px 80px 20px;
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  padding: 16px 24px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
}

.brand-zone {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.logo-badge {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--primary);
  background: var(--primary-light);
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  letter-spacing: -0.5px;
}

.header-meta {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.curriculum-tag {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

.lesson-title-badges {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.badge-chap, .badge-subtopic, .badge-tb {
  font-size: 0.85rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 9999px;
}

.badge-chap {
  background: #e0e7ff;
  color: #3730a3;
}

.badge-subtopic {
  background: var(--primary-light);
  color: var(--primary);
}

.badge-tb {
  background: #fef3c7;
  color: #92400e;
}

.user-session-bar {
  display: flex;
  align-items: center;
  gap: 16px;
}

.student-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-page);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.student-avatar {
  font-size: 1.2rem;
}

.student-info {
  display: flex;
  flex-direction: column;
}

.student-name {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-main);
}

.student-class {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.btn-icon-xs {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.8rem;
  color: var(--text-muted);
  padding: 2px;
}

.session-stat {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
  background: var(--bg-page);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.points-pill {
  background: #fef9c3;
  color: #854d0e;
  border-color: #fef08a;
}

/* Progress Bar */
.progress-bar-wrapper {
  background: var(--card-bg);
  padding: 12px 20px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
}

.progress-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.progress-track {
  height: 8px;
  background: #e2e8f0;
  border-radius: 9999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  border-radius: 9999px;
  transition: width 0.4s ease;
}

/* Stage Navigation Tabs */
.stage-nav-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 24px;
  scrollbar-width: thin;
}

.stage-tab-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 16px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  min-width: 140px;
  transition: all 0.2s ease;
  font-family: inherit;
  text-align: center;
}

.stage-tab-btn:hover {
  background: var(--primary-light);
  border-color: var(--primary);
}

.stage-tab-btn.active {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.25);
}

.tab-stage-id {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  opacity: 0.8;
}

.tab-stage-name {
  font-size: 0.88rem;
  font-weight: 700;
  margin-top: 2px;
}

/* Stage Cards */
.stage-card {
  display: none;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
}

.stage-card.active {
  display: block;
  animation: fadeIn 0.3s ease-out;
}

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

.stage-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 16px;
  margin-bottom: 24px;
}

.stage-title-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}

.badge-stage {
  background: var(--primary-light);
  color: var(--primary);
  font-size: 0.8rem;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
}

.stage-title-wrap h2 {
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--text-main);
}

.stage-time {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-page);
  padding: 4px 10px;
  border-radius: 9999px;
  border: 1px solid var(--border);
}

/* Typography & Math Standard */
.math-var, em.math-var {
  font-family: var(--font-math);
  font-style: italic !important;
  padding: 0 1px;
}

.math-sym {
  font-family: var(--font-math);
  font-style: normal;
  padding: 0 2px;
}

/* STRICT FRACTION ALIGNMENT STANDARD (GEMINI.md) */
.math-frac {
  display: inline-flex !important;
  flex-direction: column !important;
  vertical-align: middle !important;
  text-align: center !important;
  padding: 0 4px !important;
  font-size: 0.9em !important;
  line-height: 1 !important;
}

.math-num {
  border-bottom: 1.5px solid currentColor !important;
  padding-bottom: 2px !important;
  margin-bottom: 2px !important;
  display: block !important;
  line-height: 1 !important;
  text-align: center !important;
}

.math-den {
  padding-top: 2px !important;
  display: block !important;
  line-height: 1 !important;
  text-align: center !important;
}

.math-radicand {
  border-top: 1.5px solid currentColor;
  padding-top: 1px;
  margin-left: 1px;
}

.katex {
  font-size: 1.06em !important;
}

/* Utility Hidden Directive (Strict hidden-by-default) */
.hidden {
  display: none !important;
}

/* Cards & Layout Modules */
.grid-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

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

.content-box {
  background: var(--bg-page);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  margin-bottom: 20px;
}

.lead-text {
  font-size: 1.05rem;
  color: var(--text-main);
  margin-bottom: 20px;
  line-height: 1.6;
}

/* Profile Registration Card */
.profile-input-card {
  background: linear-gradient(135deg, #f0fdf4 0%, #ffffff 100%);
  border: 1.5px solid #86efac;
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 24px;
}

.profile-input-card h3 {
  color: #166534;
  font-size: 1.15rem;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.profile-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 16px;
  align-items: end;
}

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

.input-field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.input-field-group label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-main);
}

.input-field-group input {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-family: inherit;
}

.input-field-group input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

/* Symbol Decoder Card */
.symbol-decoder-card {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  margin-bottom: 24px;
}

.symbol-decoder-card h4 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 14px;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.symbol-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}

.symbol-pill {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.symbol-glyph {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--primary);
}

.symbol-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Authentic Dilemma Card */
.dilemma-card {
  background: linear-gradient(135deg, #eff6ff 0%, #f0fdfa 100%);
  border: 1.5px solid #bfdbfe;
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 24px;
}

.dilemma-badge {
  display: inline-block;
  background: #2563eb;
  color: white;
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: 9999px;
  margin-bottom: 10px;
}

.dilemma-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: #1e3a8a;
  margin-bottom: 12px;
}

.dilemma-body {
  font-size: 0.98rem;
  line-height: 1.6;
  color: #1e293b;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  font-size: 0.95rem;
  font-weight: 700;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
}

.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.btn-secondary {
  background: #ffffff;
  color: var(--text-main);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--bg-page);
  border-color: var(--text-muted);
}

.btn-success {
  background: var(--success);
  color: #ffffff;
}

.btn-success:hover {
  background: #059669;
}

.btn-sm {
  padding: 6px 14px;
  font-size: 0.85rem;
}

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--primary);
  color: var(--primary);
}

.btn-outline:hover {
  background: var(--primary-light);
}

.stage-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

/* STAGE B: DISCOVERY LAB MANIPULATIVES */
.manipulative-wrapper {
  background: #ffffff;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}

.manipulative-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}

.manipulative-header h3 {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.selector-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.tab-pill {
  padding: 6px 14px;
  font-size: 0.85rem;
  font-weight: 700;
  border-radius: 9999px;
  background: var(--bg-page);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.2s ease;
}

.tab-pill.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* SVG Graph Canvas Card (Strict Overflow Hidden Directive) */
.svg-graph-container {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: 400px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden !important; /* STRICT CLIPPING */
  margin-bottom: 16px;
}

.svg-graph-container svg {
  width: 100%;
  height: 100%;
  overflow: hidden !important;
  display: block;
}

.graph-readout-strip {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  background: #f8fafc;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-size: 0.92rem;
  font-weight: 600;
}

.root-found-badge {
  background: #dcfce7;
  color: #15803d;
  border: 1px solid #86efac;
  padding: 4px 12px;
  border-radius: 9999px;
  font-size: 0.85rem;
  font-weight: 800;
  display: none;
  animation: pulse 1.5s infinite;
}

.root-found-badge.visible {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

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

/* Slider Controls */
.slider-group {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.slider-label-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  font-weight: 700;
}

.range-slider {
  width: 100%;
  height: 8px;
  border-radius: 4px;
  background: #e2e8f0;
  outline: none;
  -webkit-appearance: none;
}

.range-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* Substitution Scale Manipulative */
.balance-scale-box {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  margin-top: 16px;
}

.balance-grid {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 16px;
  align-items: center;
  text-align: center;
  margin: 16px 0;
}

.balance-side {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
}

.balance-side h5 {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 8px;
}

.balance-val {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text-main);
}

.balance-eq-sym {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--text-muted);
}

.balance-status-alert {
  padding: 12px;
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  font-weight: 700;
  text-align: center;
}

.balance-status-alert.match {
  background: #dcfce7;
  color: #166534;
  border: 1px solid #86efac;
}

.balance-status-alert.mismatch {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fca5a5;
}

/* STAGE C: WORKED EXAMPLES ACCORDION */
.example-card {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  background: #ffffff;
  margin-bottom: 20px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.example-header {
  background: #f8fafc;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.example-header h4 {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 10px;
}

.example-body {
  padding: 24px;
}

.step-box {
  background: #f8fafc;
  border-left: 4px solid var(--primary);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 14px 18px;
  margin-bottom: 14px;
}

.step-label {
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--primary);
  margin-bottom: 4px;
}

.step-content {
  font-size: 0.95rem;
  line-height: 1.6;
}

/* Interactive Step Checkpoints */
.interactive-checkpoint {
  background: #fffbeb;
  border: 1px solid #fef08a;
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  margin: 16px 0;
}

.checkpoint-prompt {
  font-size: 0.92rem;
  font-weight: 700;
  color: #854d0e;
  margin-bottom: 10px;
}

.checkpoint-options {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.checkpoint-opt-btn {
  padding: 8px 16px;
  font-size: 0.88rem;
  font-weight: 600;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
}

.checkpoint-opt-btn:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.checkpoint-opt-btn.correct {
  background: #dcfce7 !important;
  border-color: #22c55e !important;
  color: #166534 !important;
}

.checkpoint-opt-btn.incorrect {
  background: #fee2e2 !important;
  border-color: #ef4444 !important;
  color: #991b1b !important;
}

.checkpoint-feedback {
  margin-top: 10px;
  font-size: 0.85rem;
  font-weight: 600;
}

/* STAGE D & E: PRACTICE CARDS & MULTI-TIER HINTS */
.question-card {
  background: #ffffff;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}

.question-meta-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.q-badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 9999px;
}

.q-badge.tier-foundation { background: #e0f2fe; color: #0369a1; }
.q-badge.tier-intermediate { background: #fef3c7; color: #92400e; }
.q-badge.tier-kbat { background: #fae8ff; color: #86198f; }

.q-prompt {
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.6;
  margin-bottom: 20px;
}

/* Options Grid */
.options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

@media (max-width: 640px) {
  .options-grid {
    grid-template-columns: 1fr;
  }
}

.opt-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  background: #f8fafc;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-family: inherit;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s ease;
}

.opt-btn:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  transform: translateY(-1px);
}

.opt-letter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #e2e8f0;
  color: var(--text-main);
  font-size: 0.85rem;
  font-weight: 800;
  flex-shrink: 0;
}

.opt-btn.selected {
  border-color: var(--primary);
  background: #eff6ff;
}

.opt-btn.correct {
  background: #ecfdf5 !important;
  border-color: #10b981 !important;
  color: #065f46 !important;
}

.opt-btn.correct .opt-letter {
  background: #10b981;
  color: white;
}

.opt-btn.incorrect {
  background: #fef2f2 !important;
  border-color: #ef4444 !important;
  color: #991b1b !important;
}

.opt-btn.incorrect .opt-letter {
  background: #ef4444;
  color: white;
}

/* STRICT HINT CONTAINER DIRECTIVE (GEMINI.md) */
.hint-container {
  margin: 16px 0;
}

.btn-hint-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  font-size: 0.85rem;
  font-weight: 700;
  color: #b45309;
  background: #fef3c7;
  border: 1px solid #fde68a;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-hint-toggle:hover {
  background: #fde68a;
}

.hint-content-box {
  margin-top: 10px;
  padding: 14px 18px;
  background: #fffbeb;
  border: 1px dashed #f59e0b;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  line-height: 1.55;
  color: #92400e;
}

.hint-content-box ol {
  padding-left: 20px;
  margin-top: 6px;
}

/* Solution Box */
.solution-box {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: var(--radius-sm);
  padding: 16px 20px;
  font-size: 0.92rem;
  color: #166534;
  line-height: 1.6;
  margin-top: 14px;
}

/* ==========================================================================
   MILESTONE 1: SPM MISCONCEPTION BUSTER (At Stage D conclusion)
   ========================================================================== */
.misconception-card {
  background: #ffffff;
  border: 2px solid #cbd5e1;
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-top: 32px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-md);
}

.misconception-header {
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1.5px solid var(--border);
  padding-bottom: 16px;
  margin-bottom: 20px;
}

.badge-misconception {
  background: #ef4444;
  color: #ffffff;
  font-size: 0.8rem;
  font-weight: 800;
  padding: 4px 12px;
  border-radius: 9999px;
  text-transform: uppercase;
}

.misconception-header h3 {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-main);
}

.misconception-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

@media (max-width: 800px) {
  .misconception-grid {
    grid-template-columns: 1fr;
  }
}

.pitfall-col {
  background: #fff1f2;
  border: 1.5px solid #fecdd3;
  border-radius: var(--radius-md);
  padding: 18px;
}

.pitfall-col h4 {
  color: #be123c;
  font-size: 0.95rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.standard-col {
  background: #f0fdf4;
  border: 1.5px solid #bbf7d0;
  border-radius: var(--radius-md);
  padding: 18px;
}

.standard-col h4 {
  color: #15803d;
  font-size: 0.95rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.examiner-warning {
  background: #fffbeb;
  border-left: 4px solid #f59e0b;
  padding: 10px 14px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 0.85rem;
  color: #92400e;
  margin-top: 10px;
  line-height: 1.5;
}

.breakthrough-box {
  background: #eff6ff;
  border-left: 4px solid #2563eb;
  padding: 10px 14px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 0.85rem;
  color: #1e40af;
  margin-top: 10px;
  line-height: 1.5;
}

/* ==========================================================================
   MILESTONE 2: THE VAULT & THE GOLDEN TAKEAWAY (At Stage F opening)
   ========================================================================== */
.summary-vault-card {
  background: #ffffff;
  border: 2px solid #e2e8f0;
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}

.vault-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.vault-badge {
  background: #4f46e5;
  color: #ffffff;
  font-size: 0.78rem;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 9999px;
  text-transform: uppercase;
}

.vault-header h3 {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-main);
}

.formula-matrix-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
}

.formula-matrix-table th, .formula-matrix-table td {
  border: 1px solid var(--border);
  padding: 12px 16px;
  text-align: left;
  font-size: 0.92rem;
}

.formula-matrix-table th {
  background: #f1f5f9;
  font-weight: 700;
  color: var(--text-main);
}

/* The Golden Takeaway Card */
.golden-takeaway-card {
  background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
  border: 2px solid #f59e0b;
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 28px;
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.15);
}

.golden-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.golden-badge {
  background: #d97706;
  color: #ffffff;
  font-size: 0.8rem;
  font-weight: 800;
  padding: 4px 12px;
  border-radius: 9999px;
  text-transform: uppercase;
}

.golden-header h3 {
  font-size: 1.3rem;
  font-weight: 800;
  color: #92400e;
}

.golden-takeaway-card ul {
  list-style: none;
  padding-left: 0;
  margin-bottom: 14px;
}

.golden-takeaway-card li {
  position: relative;
  padding-left: 24px;
  margin-bottom: 10px;
  font-size: 0.98rem;
  font-weight: 600;
  color: #78350f;
  line-height: 1.5;
}

.golden-takeaway-card li::before {
  content: "•";
  position: absolute;
  left: 6px;
  top: 0;
  font-size: 1.4rem;
  color: #d97706;
}

.golden-mnemonic {
  background: rgba(255, 255, 255, 0.6);
  border-left: 4px solid #f59e0b;
  padding: 10px 14px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 0.9rem;
  font-style: italic;
  font-weight: 700;
  color: #b45309;
}

/* Exit Ticket Diagnostic & Certificate */
.exit-ticket-container {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 24px;
}

.certificate-card {
  display: none;
  background: #ffffff;
  border: 6px double #0f172a;
  border-radius: var(--radius-lg);
  padding: 36px;
  text-align: center;
  margin-top: 24px;
  position: relative;
  box-shadow: var(--shadow-lg);
}

.certificate-card.visible {
  display: block;
}

.cert-header h2 {
  font-size: 1.8rem;
  font-weight: 900;
  letter-spacing: 1px;
  color: var(--text-main);
  text-transform: uppercase;
}

.cert-header p {
  font-size: 0.95rem;
  color: var(--text-muted);
}

.cert-student-name {
  font-size: 1.8rem;
  font-weight: 900;
  color: var(--primary);
  margin: 16px 0 6px 0;
  border-bottom: 2px solid var(--border);
  display: inline-block;
  padding: 0 24px 6px 24px;
}

.cert-meta-row {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin: 16px 0;
  font-size: 0.95rem;
  color: var(--text-muted);
}

.cert-golden-takeaway {
  background: #fffbeb;
  border: 1.5px dashed #f59e0b;
  border-radius: var(--radius-md);
  padding: 14px 20px;
  margin: 20px auto;
  max-width: 700px;
  text-align: left;
  font-size: 0.88rem;
  color: #92400e;
}

/* ==========================================================================
   CLASSROOM TEACHER TEACHING TOOL & SCREEN ANNOTATION (GEMINI.md)
   ========================================================================== */
.teaching-layer {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 9998;
  pointer-events: none;
}

.teaching-layer.mode-pen,
.teaching-layer.mode-eraser,
.teaching-layer.mode-laser {
  pointer-events: auto;
}

.teaching-layer canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.teaching-toolbar {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  background: #0f172a;
  color: #ffffff;
  border-radius: 40px;
  padding: 6px 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.1);
  border: 1px solid #334155;
  transition: all 0.25s ease;
  user-select: none;
}

.teaching-toolbar.hidden {
  display: none !important;
}

.toolbar-drag-handle {
  cursor: grab;
  font-size: 1.15rem;
  color: #64748b;
  padding: 2px 8px 2px 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  border-right: 1px solid #334155;
  margin-right: 2px;
  line-height: 1;
}

.toolbar-drag-handle:active {
  cursor: grabbing;
}

.toolbar-tools,
.toolbar-btn-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.tool-btn,
.toolbar-btn {
  background: rgba(255, 255, 255, 0.08) !important;
  color: #cbd5e1 !important;
  border: 1px solid rgba(255, 255, 255, 0.12) !important;
  border-radius: 20px !important;
  padding: 6px 12px !important;
  font-size: 0.82rem !important;
  font-weight: 700 !important;
  cursor: pointer !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 6px !important;
  font-family: inherit !important;
  line-height: 1 !important;
  transition: all 0.18s ease !important;
  white-space: nowrap !important;
  outline: none !important;
  box-shadow: none !important;
}

.tool-btn:hover,
.toolbar-btn:hover {
  background: rgba(255, 255, 255, 0.18) !important;
  color: #ffffff !important;
  border-color: rgba(255, 255, 255, 0.3) !important;
  transform: translateY(-1px) !important;
}

.tool-btn.active,
.toolbar-btn.active {
  background: var(--primary, #2563eb) !important;
  color: #ffffff !important;
  border-color: #60a5fa !important;
  box-shadow: 0 0 12px rgba(37, 99, 235, 0.6) !important;
}

.tool-icon {
  font-size: 0.95rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.tool-label {
  font-size: 0.8rem;
  letter-spacing: 0.2px;
  line-height: 1;
}

.toolbar-remote-dot,
.remote-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ef4444;
  display: inline-block;
  margin-left: 2px;
  box-shadow: 0 0 4px rgba(239, 68, 68, 0.6);
  transition: all 0.3s ease;
}

.toolbar-remote-dot.connected,
.remote-dot.connected {
  background: #10b981;
  box-shadow: 0 0 8px #10b981;
}

.btn-toolbar-minimize,
.toolbar-btn.btn-minimize {
  background: transparent !important;
  border: none !important;
  color: #64748b !important;
  cursor: pointer !important;
  padding: 4px 8px !important;
  font-size: 0.85rem !important;
  font-weight: 700 !important;
  border-radius: 50% !important;
  transition: all 0.15s ease !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  line-height: 1 !important;
  outline: none !important;
  box-shadow: none !important;
}

.btn-toolbar-minimize:hover,
.toolbar-btn.btn-minimize:hover {
  color: #ef4444 !important;
  background: rgba(239, 68, 68, 0.2) !important;
  transform: none !important;
  box-shadow: none !important;
}

.toolbar-expand-pill {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  background: #0f172a;
  color: #ffffff;
  border-radius: 9999px;
  padding: 8px 18px;
  font-size: 0.85rem;
  font-weight: 700;
  border: 1px solid #334155;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.35);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
}

.toolbar-expand-pill:hover {
  background: #1e293b;
  border-color: #64748b;
  transform: translateY(-2px);
}

.tool-toast-notification {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.95);
  color: #ffffff;
  padding: 8px 20px;
  border-radius: 9999px;
  font-size: 0.85rem;
  font-weight: 700;
  z-index: 10000;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
  border: 1px solid #334155;
  backdrop-filter: blur(6px);
  animation: fadeIn 0.2s ease;
  pointer-events: none;
}

/* ==========================================================================
   PRINT STYLESHEET (Clean PDF Certificate Generator)
   ========================================================================== */
@media print {
  body {
    background: #ffffff !important;
    color: #000000 !important;
  }
  .app-header,
  .progress-bar-wrapper,
  .stage-nav-tabs,
  .stage-footer,
  .btn,
  .teaching-toolbar,
  .toolbar-expand-pill,
  .teaching-layer,
  .misconception-card,
  .summary-vault-card,
  .exit-ticket-container,
  #stageA, #stageB, #stageC, #stageD, #stageE {
    display: none !important;
  }
  #stageF {
    display: block !important;
    border: none !important;
    padding: 0 !important;
  }
  .certificate-card {
    display: block !important;
    box-shadow: none !important;
    border: 3px double #000000 !important;
    page-break-inside: avoid;
    margin: 0 !important;
    padding: 24px !important;
  }
  .cert-golden-takeaway {
    display: block !important;
  }
}

/* Textbook Diagram & Graphic Styling */
.textbook-diagram-svg {
  display: block;
  margin: 8px auto;
  border-radius: 8px;
  background: #f8fafc;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  max-width: 100%;
  height: auto;
}
.question-diagram-wrapper {
  margin: 12px 0 14px 0;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
}
