:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --primary: #4f46e5;
  --primary-light: #eef2ff;
  --primary-dark: #3730a3;
  --mint: #059669;
  --mint-light: #ecfdf5;
  --amber: #d97706;
  --amber-light: #fffbeb;
  --rose: #e11d48;
  --rose-light: #fff1f2;
  --sky: #0284c7;
  --sky-light: #f0f9ff;
  --purple: #7c3aed;
  --purple-light: #f5f3ff;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 6px 24px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 18px 50px rgba(15, 23, 42, 0.14);
}

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

body {
  font-family: 'Nunito', 'Quicksand', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  min-height: 100vh;
}

.hidden {
  display: none !important;
}

/* ==================== TOPBAR ==================== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 22px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mobile-menu-btn {
  display: none;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 20px;
  cursor: pointer;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  width: 42px;
  height: 42px;
  border-radius: 13px;
  background: linear-gradient(135deg, #4f46e5, #06b6d4);
  display: grid;
  place-items: center;
  font-size: 22px;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.28);
}

.brand-title {
  font-weight: 900;
  font-size: 18px;
  color: var(--text);
  line-height: 1.2;
}

.brand-sub {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
}

.topbar-center {
  flex: 1;
  max-width: 320px;
}

.progress-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  padding: 7px 14px;
  border-radius: 999px;
}

.progress-label {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-muted);
}

.progress-track {
  flex: 1;
  height: 9px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #10b981, #4f46e5);
  border-radius: 999px;
  transition: width 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.progress-pct {
  font-size: 13px;
  font-weight: 800;
  color: var(--primary);
  min-width: 36px;
  text-align: right;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-zoo {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 999px;
  border: 2px solid #fde68a;
  background: linear-gradient(135deg, #fffbeb, #fef3c7);
  color: #92400e;
  font-family: inherit;
  font-weight: 800;
  font-size: 14px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}

.btn-zoo:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(245, 158, 11, 0.22);
}

.zoo-badge {
  background: #f59e0b;
  color: #fff;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
}

.btn-sound {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 18px;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-sound:hover {
  background: var(--surface-soft);
}

/* ==================== RETURN BANNER ==================== */
.return-banner {
  background: linear-gradient(90deg, #4f46e5, #7c3aed);
  color: #fff;
  padding: 10px 22px;
  position: sticky;
  top: 67px;
  z-index: 35;
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.25);
}

.return-banner-inner {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 14.5px;
}

.btn-return {
  background: #fde047;
  color: #1e293b;
  border: none;
  padding: 7px 16px;
  border-radius: 999px;
  font-family: inherit;
  font-weight: 900;
  font-size: 13.5px;
  cursor: pointer;
  transition: transform 0.15s;
}

.btn-return:hover {
  transform: scale(1.04);
}

/* ==================== LAYOUT ==================== */
.app-layout {
  display: flex;
  max-width: 1440px;
  margin: 0 auto;
  min-height: calc(100vh - 67px);
}

/* ==================== SIDEBAR: SỔ TAY BÍ KÍP ==================== */
.sidebar {
  width: 330px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 67px;
  height: calc(100vh - 67px);
  overflow: hidden;
}

.sidebar-header {
  padding: 18px 18px 12px;
  background: linear-gradient(135deg, #eef2ff, #f0f9ff);
  border-bottom: 1px solid var(--border);
}

.sidebar-title {
  font-weight: 900;
  font-size: 16.5px;
  color: var(--primary-dark);
}

.sidebar-sub {
  font-size: 12.5px;
  color: var(--text-muted);
  font-weight: 600;
  margin-top: 2px;
}

.sidebar-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-soft);
}

.sidebar-tab {
  border: none;
  background: transparent;
  padding: 8px 10px;
  border-radius: 10px;
  font-family: inherit;
  font-weight: 800;
  font-size: 12.5px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}

.sidebar-tab.active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
}

.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

.nav-section-group {
  margin-bottom: 16px;
}

.nav-section-title {
  font-size: 11.5px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 4px 8px 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav-item {
  width: 100%;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 9px 11px;
  margin-bottom: 4px;
  border: 1.5px solid transparent;
  border-radius: 12px;
  background: transparent;
  text-align: left;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
}

.nav-item:hover {
  background: var(--surface-soft);
  border-color: var(--border);
}

.nav-item.active {
  background: var(--primary-light);
  border-color: #a5b4fc;
}

.nav-item-icon {
  font-size: 16px;
  flex-shrink: 0;
  margin-top: 1px;
}

.nav-item-body {
  flex: 1;
  min-width: 0;
}

.nav-item-name {
  font-size: 13.5px;
  font-weight: 800;
  color: var(--text);
  line-height: 1.3;
}

.nav-item.active .nav-item-name {
  color: var(--primary-dark);
}

.nav-item-meta {
  font-size: 11.5px;
  color: var(--text-muted);
  font-weight: 600;
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav-badge-done {
  color: var(--mint);
  font-weight: 800;
}

.nav-badge-type {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 6px;
  font-size: 10.5px;
  font-weight: 800;
}

.nav-badge-type.theory {
  background: #dbeafe;
  color: #1d4ed8;
}

.nav-badge-type.ex-type {
  background: #fef3c7;
  color: #b45309;
}

/* Cheatsheet Cards inside Sidebar */
.cheat-card {
  background: var(--surface-soft);
  border: 1.5px solid var(--border);
  border-radius: 13px;
  padding: 11px 12px;
  margin-bottom: 10px;
  transition: border-color 0.15s;
}

.cheat-card:hover {
  border-color: #a5b4fc;
}

.cheat-card-tag {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 999px;
  margin-bottom: 5px;
}

.cheat-card-tag.theory {
  background: #e0e7ff;
  color: #3730a3;
}

.cheat-card-tag.formula {
  background: #fef3c7;
  color: #92400e;
}

.cheat-card-title {
  font-size: 13.5px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 4px;
}

.cheat-card-summary {
  font-size: 12.5px;
  color: #334155;
  margin-bottom: 8px;
  line-height: 1.5;
}

.cheat-card-actions {
  display: flex;
  gap: 6px;
}

.btn-cheat-peek,
.btn-cheat-go {
  flex: 1;
  padding: 5px 8px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  border: 1px solid var(--border);
}

.btn-cheat-peek {
  background: #fff;
  color: var(--primary);
  border-color: #c7d2fe;
}

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

.btn-cheat-go {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.btn-cheat-go:hover {
  background: var(--primary-dark);
}

.sidebar-footer {
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  background: var(--surface-soft);
}

.btn-reset-progress {
  width: 100%;
  padding: 7px;
  border-radius: 9px;
  border: 1px dashed #cbd5e1;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
}

.btn-reset-progress:hover {
  background: #fff1f2;
  color: var(--rose);
  border-color: #fecdd3;
}

/* ==================== MAIN STAGE ==================== */
.main-stage {
  flex: 1;
  padding: 26px 32px 60px;
  max-width: 980px;
  margin: 0 auto;
  width: 100%;
}

/* Hero Lesson Header */
.lesson-hero {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px 28px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  margin-bottom: 22px;
  position: relative;
  overflow: hidden;
}

.lesson-hero::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 5px;
  background: linear-gradient(90deg, #4f46e5, #06b6d4, #10b981);
}

.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 10px;
}

.hero-eyebrow.theory {
  background: var(--primary-light);
  color: var(--primary-dark);
}

.hero-eyebrow.ex-type {
  background: var(--amber-light);
  color: #b45309;
}

.lesson-hero h1 {
  font-size: 25px;
  font-weight: 900;
  color: var(--text);
  line-height: 1.3;
  margin-bottom: 8px;
}

.lesson-hero-desc {
  font-size: 15px;
  color: #475569;
  font-weight: 600;
}

/* Analogy / Easy Memory Card */
.analogy-box {
  background: linear-gradient(135deg, #fffbeb, #fef3c7);
  border: 2px solid #fde68a;
  border-radius: var(--radius);
  padding: 18px 22px;
  margin-bottom: 22px;
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.analogy-icon {
  font-size: 32px;
  line-height: 1;
  flex-shrink: 0;
}

.analogy-title {
  font-weight: 900;
  font-size: 15.5px;
  color: #92400e;
  margin-bottom: 4px;
}

.analogy-text {
  font-size: 14.5px;
  color: #78350f;
  font-weight: 600;
}

/* General Formula Box (for Exercise Types) */
.formula-card {
  background: linear-gradient(135deg, #eef2ff, #f5f3ff);
  border: 2px solid #c7d2fe;
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 22px;
}

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

.formula-card-title {
  font-size: 16.5px;
  font-weight: 900;
  color: var(--primary-dark);
}

.formula-saved-badge {
  background: #fff;
  color: var(--mint);
  border: 1px solid #a7f3d0;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.formula-steps-list {
  display: grid;
  gap: 9px;
}

.formula-step-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: rgba(255, 255, 255, 0.85);
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14.5px;
  font-weight: 700;
  color: var(--text);
}

.formula-step-num {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 900;
  flex-shrink: 0;
}

/* ==================== INTERACTIVE MOTION VIDEO PLAYER ==================== */
.motion-player {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1.5px solid var(--border);
  overflow: hidden;
  margin-bottom: 24px;
}

.motion-player-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  background: #1e293b;
  color: #fff;
  flex-wrap: wrap;
}

.motion-player-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 15px;
}

.live-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.28);
  animation: pulseDot 1.8s infinite;
}

@keyframes pulseDot {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.25); opacity: 0.7; }
}

.motion-step-counter {
  font-size: 13px;
  font-weight: 800;
  background: rgba(255, 255, 255, 0.14);
  padding: 4px 12px;
  border-radius: 999px;
}

.motion-stage {
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  gap: 20px;
  padding: 22px;
  background: linear-gradient(180deg, #f8fafc 0%, #ffffff 100%);
  align-items: center;
  min-height: 320px;
}

.motion-visual {
  background: #ffffff;
  border: 1.5px solid #e2e8f0;
  border-radius: 16px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 270px;
  position: relative;
}

.motion-visual svg {
  width: 100%;
  max-width: 380px;
  height: auto;
  display: block;
}

.motion-narration {
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: fadeSlideIn 0.35s ease;
}

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

.motion-step-badge {
  display: inline-block;
  align-self: flex-start;
  background: var(--primary-light);
  color: var(--primary-dark);
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 900;
}

.motion-step-heading {
  font-size: 19px;
  font-weight: 900;
  color: var(--text);
  line-height: 1.3;
}

.motion-step-math {
  background: #f1f5f9;
  border-left: 4px solid var(--primary);
  padding: 12px 16px;
  border-radius: 0 12px 12px 0;
  font-size: 17px;
  font-weight: 800;
  color: #0f172a;
}

.motion-step-explain {
  font-size: 15px;
  color: #334155;
  font-weight: 600;
}

.motion-why-box {
  background: var(--mint-light);
  border: 1.5px solid #a7f3d0;
  border-radius: 12px;
  padding: 11px 14px;
  font-size: 14px;
  color: #065f46;
  font-weight: 700;
}

.motion-why-box strong {
  color: #047857;
}

.motion-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  background: #f8fafc;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

.motion-btn-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-ctrl {
  padding: 8px 14px;
  border-radius: 10px;
  border: 1.5px solid var(--border);
  background: #fff;
  color: var(--text);
  font-family: inherit;
  font-weight: 800;
  font-size: 13.5px;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-ctrl:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

.btn-ctrl:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-ctrl.play-btn {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.btn-ctrl.play-btn:hover {
  background: var(--primary-dark);
  color: #fff;
}

.motion-dots {
  display: flex;
  align-items: center;
  gap: 6px;
}

.motion-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #cbd5e1;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
}

.motion-dot.active {
  width: 26px;
  background: var(--primary);
}

/* ==================== INTERACTIVE LAB ==================== */
.lab-card {
  background: var(--surface);
  border: 2px solid #bae6fd;
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
}

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

.lab-header h3 {
  font-size: 17px;
  font-weight: 900;
  color: #0369a1;
}

.lab-grid {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 20px;
  align-items: center;
}

.lab-controls {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.slider-group label {
  display: flex;
  justify-content: space-between;
  font-weight: 800;
  font-size: 14px;
  margin-bottom: 6px;
}

.slider-group input[type="range"] {
  width: 100%;
  accent-color: var(--primary);
  cursor: pointer;
}

.angle-toggle-group {
  display: flex;
  gap: 8px;
}

.btn-angle-toggle {
  flex: 1;
  padding: 9px;
  border-radius: 10px;
  border: 1.5px solid var(--border);
  background: var(--surface-soft);
  font-family: inherit;
  font-weight: 800;
  font-size: 13.5px;
  cursor: pointer;
}

.btn-angle-toggle.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.lab-readout-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.lab-readout-item {
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 13.5px;
  font-weight: 800;
}

/* ==================== LINE-BY-LINE SOLUTION TABLE ==================== */
.solution-walkthrough {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1.5px solid var(--border);
  padding: 20px 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
}

.solution-walkthrough h3 {
  font-size: 17px;
  font-weight: 900;
  color: var(--text);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sol-line-card {
  display: grid;
  grid-template-columns: 1fr 1.1fr;
  gap: 14px;
  padding: 13px 15px;
  border-radius: 13px;
  background: var(--surface-soft);
  border: 1.5px solid var(--border);
  margin-bottom: 10px;
  align-items: center;
}

.sol-line-math {
  font-size: 15.5px;
  font-weight: 800;
  color: #0f172a;
}

.sol-line-num {
  display: inline-block;
  background: var(--primary);
  color: #fff;
  font-size: 11px;
  font-weight: 900;
  padding: 2px 7px;
  border-radius: 6px;
  margin-right: 6px;
}

.sol-line-why {
  background: #ecfdf5;
  border-left: 3.5px solid #10b981;
  padding: 8px 12px;
  border-radius: 0 10px 10px 0;
  font-size: 13.5px;
  color: #065f46;
  font-weight: 700;
}

/* ==================== SPECIAL ANGLE TABLE ==================== */
.trig-table-wrap {
  overflow-x: auto;
  margin: 14px 0;
}

.trig-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: 14px;
  overflow: hidden;
  border: 1.5px solid var(--border);
}

.trig-table th,
.trig-table td {
  padding: 11px 14px;
  text-align: center;
  border: 1px solid var(--border);
  font-weight: 800;
  font-size: 15px;
}

.trig-table th {
  background: var(--primary-light);
  color: var(--primary-dark);
}

.trig-table tr:nth-child(even) td {
  background: #f8fafc;
}

/* ==================== PRACTICE EXERCISES ==================== */
.practice-section {
  margin-top: 28px;
}

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

.practice-section-title {
  font-size: 20px;
  font-weight: 900;
  color: var(--text);
}

.chest-reward-pill {
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  color: #92400e;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 900;
  border: 1.5px solid #fcd34d;
}

.exercise-card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
  transition: border-color 0.2s;
}

.exercise-card.solved {
  border-color: #6ee7b7;
  background: linear-gradient(180deg, #ffffff 0%, #f0fdf4 100%);
}

.ex-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.ex-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 900;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--sky-light);
  color: #0369a1;
}

.ex-badge.solved {
  background: var(--mint-light);
  color: var(--mint);
}

.ex-help-btn {
  background: #fffbeb;
  color: #b45309;
  border: 1.5px solid #fde68a;
  padding: 5px 12px;
  border-radius: 999px;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 800;
  cursor: pointer;
}

.ex-help-btn:hover {
  background: #fef3c7;
}

.ex-prompt {
  font-size: 16px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 14px;
}

.ex-diagram {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  margin-bottom: 16px;
  display: flex;
  justify-content: center;
}

.ex-diagram svg {
  max-width: 300px;
  width: 100%;
  height: auto;
}

.ex-options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}

.ex-option-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 16px;
  border-radius: 13px;
  border: 2px solid var(--border);
  background: #fff;
  font-family: inherit;
  font-size: 15px;
  font-weight: 800;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: all 0.15s;
}

.ex-option-btn:hover:not(:disabled) {
  border-color: var(--primary);
  background: var(--primary-light);
}

.ex-option-btn.selected {
  border-color: var(--primary);
  background: var(--primary-light);
}

.ex-option-btn.correct {
  border-color: #10b981;
  background: #d1fae5;
  color: #065f46;
}

.ex-option-btn.wrong {
  border-color: #f43f5e;
  background: #ffe4e6;
  color: #9f1239;
}

.opt-letter {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 900;
  flex-shrink: 0;
}

.ex-actions-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.btn-hint {
  background: var(--surface-soft);
  border: 1.5px solid var(--border);
  color: #475569;
  padding: 8px 14px;
  border-radius: 10px;
  font-family: inherit;
  font-weight: 800;
  font-size: 13.5px;
  cursor: pointer;
}

.btn-hint:hover {
  background: #fef3c7;
  border-color: #fde68a;
  color: #92400e;
}

.ex-feedback {
  margin-top: 14px;
  padding: 14px 16px;
  border-radius: 13px;
  font-size: 14.5px;
  font-weight: 700;
}

.ex-feedback.hint {
  background: #fffbeb;
  border: 1.5px solid #fde68a;
  color: #92400e;
}

.ex-feedback.wrong {
  background: #fff1f2;
  border: 1.5px solid #fecdd3;
  color: #9f1239;
}

.ex-feedback.correct {
  background: #ecfdf5;
  border: 1.5px solid #a7f3d0;
  color: #065f46;
}

.btn-open-chest-inline {
  margin-top: 10px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, #f59e0b, #ea580c);
  color: #fff;
  border: none;
  padding: 10px 18px;
  border-radius: 12px;
  font-family: inherit;
  font-weight: 900;
  font-size: 14.5px;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(234, 88, 12, 0.3);
  animation: bounceGentle 1.5s infinite;
}

@keyframes bounceGentle {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

/* ==================== BOTTOM NAVIGATION ==================== */
.stage-footer-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 30px;
  padding-top: 20px;
  border-top: 1.5px solid var(--border);
}

.btn-primary {
  background: linear-gradient(135deg, #4f46e5, #6366f1);
  color: #fff;
  border: none;
  padding: 11px 22px;
  border-radius: 12px;
  font-family: inherit;
  font-weight: 800;
  font-size: 14.5px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.28);
  transition: transform 0.15s;
}

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

.btn-secondary {
  background: #fff;
  color: var(--text);
  border: 1.5px solid var(--border);
  padding: 10px 18px;
  border-radius: 12px;
  font-family: inherit;
  font-weight: 800;
  font-size: 14px;
  cursor: pointer;
}

.btn-secondary:hover {
  background: var(--surface-soft);
  border-color: #cbd5e1;
}

/* ==================== MATH FRACTIONS ==================== */
.frac {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  vertical-align: middle;
  margin: 0 3px;
  line-height: 1.1;
  font-size: 0.92em;
}

.frac > span:first-child {
  border-bottom: 2px solid currentColor;
  padding: 0 4px 2px;
}

.frac > span:last-child {
  padding: 2px 4px 0;
}

/* ==================== CASIO SIMULATOR ==================== */
.casio-box {
  background: #1e293b;
  border-radius: 18px;
  padding: 16px;
  color: #fff;
  max-width: 310px;
  margin: 0 auto;
  box-shadow: 0 12px 26px rgba(15, 23, 42, 0.28);
}

.casio-brand {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 900;
  color: #94a3b8;
  margin-bottom: 8px;
}

.casio-screen {
  background: #cbd5e1;
  color: #0f172a;
  border-radius: 10px;
  padding: 10px 12px;
  font-family: 'Consolas', 'Courier New', monospace;
  margin-bottom: 12px;
  min-height: 58px;
}

.casio-expr {
  font-size: 13px;
  font-weight: 700;
  color: #334155;
}

.casio-res {
  font-size: 18px;
  font-weight: 900;
  text-align: right;
  margin-top: 2px;
}

.casio-keys {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.casio-key {
  padding: 8px 4px;
  border-radius: 8px;
  border: none;
  background: #334155;
  color: #fff;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.1s, background 0.15s;
}

.casio-key:hover {
  background: #475569;
}

.casio-key.shift {
  background: #d97706;
}

.casio-key.func {
  background: #4f46e5;
}

.casio-key.eq {
  background: #059669;
}

.casio-key.glow {
  box-shadow: 0 0 0 3px #fde047, 0 0 14px #fde047;
  transform: scale(1.06);
}

/* ==================== QUICK PEEK DRAWER ==================== */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 60;
}

.quick-peek-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 440px;
  max-width: 94vw;
  background: #fff;
  z-index: 65;
  display: flex;
  flex-direction: column;
  box-shadow: -12px 0 40px rgba(15, 23, 42, 0.18);
  animation: slideInRight 0.25s ease;
}

@keyframes slideInRight {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

.drawer-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 18px 20px;
  background: linear-gradient(135deg, #eef2ff, #f5f3ff);
  border-bottom: 1px solid var(--border);
}

.drawer-eyebrow {
  font-size: 12px;
  font-weight: 800;
  color: var(--primary);
}

.drawer-title {
  font-size: 18px;
  font-weight: 900;
  color: var(--text);
  margin-top: 2px;
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 20px;
}

.drawer-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  background: var(--surface-soft);
}

.btn-close-modal {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  font-size: 16px;
  font-weight: 900;
  cursor: pointer;
}

/* ==================== TREASURE CHEST MODAL ==================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(6px);
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 18px;
}

.confetti-container {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 82;
}

.confetti-piece {
  position: absolute;
  top: -20px;
  width: 11px;
  height: 11px;
  border-radius: 3px;
  animation: confettiFall 2.4s linear forwards;
}

@keyframes confettiFall {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(105vh) rotate(720deg); opacity: 0; }
}

.chest-card {
  position: relative;
  z-index: 85;
  background: #fff;
  border-radius: 26px;
  padding: 30px 28px;
  width: 460px;
  max-width: 95vw;
  text-align: center;
  box-shadow: var(--shadow-lg);
  animation: popIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes popIn {
  from { transform: scale(0.84); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.chest-eyebrow {
  display: inline-block;
  background: #fef3c7;
  color: #b45309;
  padding: 5px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 900;
  margin-bottom: 10px;
}

.chest-heading {
  font-size: 23px;
  font-weight: 900;
  color: var(--text);
  margin-bottom: 6px;
}

.chest-sub {
  font-size: 14.5px;
  color: var(--text-muted);
  font-weight: 700;
  margin-bottom: 18px;
}

.chest-box-wrapper {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  padding: 10px 26px;
  border-radius: 20px;
  transition: transform 0.2s;
}

.chest-box-wrapper:hover {
  transform: scale(1.05);
}

.chest-glow {
  position: absolute;
  width: 190px;
  height: 190px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(251, 191, 36, 0.45) 0%, rgba(251, 191, 36, 0) 72%);
  top: 5px;
  pointer-events: none;
}

.chest-svg {
  width: 190px;
  height: 170px;
  position: relative;
  z-index: 2;
}

.chest-svg-wrap.shaking .chest-svg {
  animation: chestShake 0.55s ease-in-out;
}

@keyframes chestShake {
  0%, 100% { transform: rotate(0deg) scale(1); }
  20% { transform: rotate(-10deg) scale(1.06); }
  40% { transform: rotate(10deg) scale(1.08); }
  60% { transform: rotate(-8deg) scale(1.1); }
  80% { transform: rotate(8deg) scale(1.06); }
}

.chest-tap-hint {
  margin-top: 6px;
  font-weight: 900;
  font-size: 15px;
  color: #d97706;
  animation: bounceGentle 1.3s infinite;
}

/* Animal Reveal */
.rarity-pill {
  display: inline-block;
  padding: 4px 14px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 900;
  margin-bottom: 12px;
}

.rarity-common { background: #e0f2fe; color: #0369a1; }
.rarity-rare { background: #ede9fe; color: #6d28d9; }
.rarity-epic { background: #fce7f3; color: #be185d; }
.rarity-legendary { background: linear-gradient(90deg, #fef08a, #fed7aa); color: #9a3412; }

.animal-avatar-big {
  width: 150px;
  height: 150px;
  margin: 0 auto 12px;
  border-radius: 30px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #fffbeb, #eef2ff);
  border: 3px solid #fde68a;
  box-shadow: 0 10px 26px rgba(245, 158, 11, 0.22);
  animation: popIn 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.animal-avatar-big svg {
  width: 128px;
  height: 128px;
}

.animal-name {
  font-size: 24px;
  font-weight: 900;
  color: var(--text);
}

.animal-new-tag {
  display: inline-block;
  background: #10b981;
  color: #fff;
  font-size: 11.5px;
  font-weight: 900;
  padding: 2px 10px;
  border-radius: 999px;
  margin: 6px 0;
}

.animal-praise {
  font-size: 15px;
  font-weight: 800;
  color: var(--primary-dark);
  margin: 8px 0 6px;
}

.animal-fact {
  font-size: 13.5px;
  color: var(--text-muted);
  font-weight: 600;
  background: var(--surface-soft);
  padding: 10px 14px;
  border-radius: 12px;
  margin-bottom: 18px;
}

.chest-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

/* ==================== PET ZOO MODAL ==================== */
.zoo-card {
  background: #fff;
  border-radius: 24px;
  width: 780px;
  max-width: 96vw;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

.zoo-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  background: linear-gradient(135deg, #fffbeb, #fef3c7);
  border-bottom: 1px solid #fde68a;
}

.zoo-header h2 {
  font-size: 21px;
  font-weight: 900;
  color: #92400e;
}

.zoo-header p {
  font-size: 13.5px;
  color: #b45309;
  font-weight: 700;
}

.zoo-grid {
  padding: 20px 24px;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
}

.zoo-item {
  border: 2px solid var(--border);
  border-radius: 18px;
  padding: 14px 10px;
  text-align: center;
  background: #fff;
  transition: transform 0.15s;
}

.zoo-item.unlocked {
  border-color: #fde68a;
  background: linear-gradient(180deg, #ffffff 0%, #fffbeb 100%);
}

.zoo-item.unlocked:hover {
  transform: translateY(-3px);
}

.zoo-item.locked {
  background: #f8fafc;
  opacity: 0.65;
}

.zoo-item-svg {
  width: 82px;
  height: 82px;
  margin: 0 auto 8px;
  display: grid;
  place-items: center;
}

.zoo-item-svg svg {
  width: 78px;
  height: 78px;
}

.zoo-item-name {
  font-size: 14px;
  font-weight: 900;
  color: var(--text);
}

.zoo-item-count {
  font-size: 11.5px;
  font-weight: 800;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 960px) {
  .mobile-menu-btn {
    display: grid;
    place-items: center;
  }

  .topbar-center {
    display: none;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 67px;
    bottom: 0;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: 12px 0 36px rgba(15, 23, 42, 0.16);
  }

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

  .main-stage {
    padding: 18px 16px 50px;
  }

  .motion-stage,
  .lab-grid,
  .sol-line-card,
  .ex-options-grid {
    grid-template-columns: 1fr;
  }
}

/* ==================== LESSON SWITCHER BAR (HK1) ==================== */
.lesson-bar {
  background: #ffffff;
  border-bottom: 1.5px solid var(--border);
  padding: 8px 18px;
  position: sticky;
  top: 67px;
  z-index: 38;
}

.lesson-bar-inner {
  max-width: 1440px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: thin;
  padding-bottom: 2px;
}

.chapter-pill {
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 5px 10px;
  border-radius: 8px;
  white-space: nowrap;
  flex-shrink: 0;
}

.chapter-pill.c4 {
  background: #eef2ff;
  color: #3730a3;
}

.chapter-pill.c5 {
  background: #ecfdf5;
  color: #065f46;
}

.lesson-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  border-radius: 999px;
  border: 1.5px solid var(--border);
  background: var(--surface-soft);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s;
}

.lesson-chip:hover {
  border-color: #a5b4fc;
  background: #eef2ff;
}

.lesson-chip.active {
  background: linear-gradient(135deg, #4f46e5, #6366f1);
  color: #fff;
  border-color: #4f46e5;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.28);
}

.lesson-chip-prog {
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.08);
  font-weight: 900;
}

.lesson-chip.active .lesson-chip-prog {
  background: rgba(255, 255, 255, 0.25);
  color: #fff;
}

.lesson-chip-prog.done {
  background: #d1fae5;
  color: #065f46;
}

.lesson-chip.active .lesson-chip-prog.done {
  background: #34d399;
  color: #064e3b;
}

/* Adjust sticky offsets for lesson-bar height (~51px) */
.return-banner {
  top: 118px;
}

.sidebar {
  top: 118px;
  height: calc(100vh - 118px);
}

.cheat-scope-bar {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}

.cheat-scope-btn {
  flex: 1;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  background: #fff;
  font-family: inherit;
  font-size: 12px;
  font-weight: 800;
  color: var(--text-muted);
  cursor: pointer;
}

.cheat-scope-btn.active {
  background: var(--primary-light);
  color: var(--primary-dark);
  border-color: #a5b4fc;
}

@media (max-width: 960px) {
  .sidebar {
    top: 118px;
    height: calc(100vh - 118px);
  }
}

/* ==================== SEQUENTIAL LINE-BY-LINE SCAFFOLDED ESSAYS ==================== */
.scaffold-banner {
  background: linear-gradient(135deg, #f0f9ff, #eef2ff);
  border: 2px solid #bfdbfe;
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 18px;
}

.scaffold-banner-title {
  font-size: 16px;
  font-weight: 900;
  color: #1e3a8a;
  margin-bottom: 6px;
}

.scaffold-levels-legend {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.level-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
}

.level-pill.lv1 { background: #dcfce7; color: #166534; border: 1px solid #86efac; }
.level-pill.lv2 { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.level-pill.lv3 { background: #ffe4e6; color: #9f1239; border: 1px solid #fecdd3; }
.level-pill.mcq { background: #ede9fe; color: #5b21b6; border: 1px solid #ddd6fe; }

.essay-card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
  position: relative;
}

.essay-card.solved {
  border-color: #6ee7b7;
  background: linear-gradient(180deg, #ffffff 0%, #f0fdf4 100%);
}

.essay-card.locked-card {
  opacity: 0.72;
  background: #f8fafc;
  border-style: dashed;
}

.locked-card-msg {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-radius: 12px;
  background: #f1f5f9;
  color: #475569;
  font-weight: 800;
  font-size: 14px;
  margin-top: 10px;
}

.essay-steps-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 14px;
}

.essay-line {
  border: 2px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  background: #ffffff;
  transition: all 0.2s ease;
}

.essay-line.active-line {
  border-color: #6366f1;
  box-shadow: 0 4px 16px rgba(79, 70, 229, 0.1);
}

.essay-line.done-line {
  border-color: #6ee7b7;
  background: #f0fdf4;
}

.essay-line.locked-line {
  background: #f8fafc;
  border-style: dashed;
  border-color: #cbd5e1;
  opacity: 0.65;
}

.essay-line-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.essay-line-tag {
  font-size: 12.5px;
  font-weight: 900;
  padding: 3px 10px;
  border-radius: 8px;
  background: var(--primary-light);
  color: var(--primary-dark);
}

.essay-line.done-line .essay-line-tag {
  background: #bbf7d0;
  color: #166534;
}

.essay-line.locked-line .essay-line-tag {
  background: #e2e8f0;
  color: #64748b;
}

.essay-line-scaffold {
  background: #fffbeb;
  border-left: 3.5px solid #f59e0b;
  padding: 8px 12px;
  border-radius: 0 10px 10px 0;
  font-size: 13.5px;
  font-weight: 700;
  color: #92400e;
  margin-bottom: 10px;
}

.essay-line-prompt {
  font-size: 15px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.essay-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.essay-prefix,
.essay-suffix {
  font-size: 15px;
  font-weight: 800;
  color: #334155;
}

.essay-input {
  min-width: 140px;
  max-width: 240px;
  padding: 9px 12px;
  border-radius: 10px;
  border: 2px solid #cbd5e1;
  font-family: inherit;
  font-size: 15.5px;
  font-weight: 800;
  color: #0f172a;
  outline: none;
  transition: border-color 0.15s;
}

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

.essay-input.input-ok {
  border-color: #10b981;
  background: #ecfdf5;
  color: #065f46;
}

.essay-input.input-err {
  border-color: #f43f5e;
  background: #fff1f2;
}

.btn-check-line {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 9px 16px;
  border-radius: 10px;
  font-family: inherit;
  font-weight: 800;
  font-size: 13.5px;
  cursor: pointer;
}

.btn-check-line:hover {
  background: var(--primary-dark);
}

.math-sym-bar {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.math-sym-label {
  font-size: 11.5px;
  font-weight: 800;
  color: var(--text-muted);
  margin-right: 4px;
}

.btn-sym {
  padding: 3px 9px;
  border-radius: 7px;
  border: 1.5px solid var(--border);
  background: var(--surface-soft);
  font-family: inherit;
  font-size: 13px;
  font-weight: 900;
  color: var(--text);
  cursor: pointer;
}

.btn-sym:hover {
  background: var(--primary-light);
  border-color: #a5b4fc;
  color: var(--primary-dark);
}

/* Casio Detailed Keycap Guide */
.casio-guide-box {
  margin-top: 10px;
  background: #0f172a;
  color: #f8fafc;
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 700;
}

.casio-guide-title {
  color: #fde047;
  font-weight: 900;
  font-size: 12.5px;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.casio-key-seq {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  margin-bottom: 5px;
}

.ckey {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 6px;
  background: #334155;
  color: #fff;
  border: 1px solid #64748b;
  font-family: 'Consolas', monospace;
  font-size: 12px;
  font-weight: 900;
  box-shadow: 0 2px 0 #1e293b;
}

.ckey.shift { background: #d97706; border-color: #fbbf24; }
.ckey.func { background: #4f46e5; border-color: #818cf8; }
.ckey.eq { background: #059669; border-color: #34d399; }

.casio-note {
  font-size: 12px;
  color: #cbd5e1;
  font-weight: 600;
}

.btn-toggle-casio {
  background: #1e293b;
  color: #fde047;
  border: none;
  padding: 6px 12px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.btn-toggle-casio:hover {
  background: #334155;
}

.line-feedback {
  margin-top: 8px;
  padding: 8px 12px;
  border-radius: 9px;
  font-size: 13.5px;
  font-weight: 700;
}

.line-feedback.ok {
  background: #dcfce7;
  color: #166534;
}

.line-feedback.err {
  background: #ffe4e6;
  color: #9f1239;
}

.mcq-final-section {
  margin-top: 28px;
  padding-top: 20px;
  border-top: 2px dashed var(--border);
}

.mcq-locked-box {
  background: linear-gradient(135deg, #f5f3ff, #eef2ff);
  border: 2px dashed #a5b4fc;
  border-radius: var(--radius);
  padding: 22px;
  text-align: center;
  color: #3730a3;
  font-weight: 800;
  font-size: 15px;
}

/* ==================== WELCOME MODAL & ROYAL PRAISE FOR TRÂM BẦU ==================== */
.welcome-card {
  background: linear-gradient(180deg, #fffbeb 0%, #ffffff 42%, #fdf2f8 100%);
  border: 3px solid #fbcfe8;
  border-radius: 28px;
  padding: 32px 28px;
  width: 470px;
  max-width: 94vw;
  text-align: center;
  box-shadow: 0 22px 60px rgba(236, 72, 153, 0.22);
  animation: popIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.welcome-crown {
  font-size: 46px;
  line-height: 1.1;
  margin-bottom: 10px;
  animation: bounceGentle 1.6s infinite;
}

.welcome-eyebrow {
  display: inline-block;
  background: #fce7f3;
  color: #be185d;
  padding: 5px 15px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 900;
  margin-bottom: 10px;
}

.welcome-title {
  font-size: 22px;
  font-weight: 900;
  color: #831843;
  line-height: 1.35;
  margin-bottom: 10px;
}

.welcome-msg {
  font-size: 15px;
  font-weight: 700;
  color: #475569;
  line-height: 1.6;
  margin-bottom: 16px;
}

.welcome-stats {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.welcome-stat-chip {
  background: #ffffff;
  border: 1.5px solid #f9a8d4;
  color: #9d174d;
  padding: 6px 13px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 900;
}

.welcome-start-btn {
  width: 100%;
  padding: 13px 20px;
  font-size: 16px;
  background: linear-gradient(135deg, #ec4899, #8b5cf6);
  box-shadow: 0 8px 22px rgba(236, 72, 153, 0.32);
}

.praise-toast {
  position: fixed;
  bottom: 22px;
  right: 22px;
  z-index: 95;
  max-width: 390px;
  padding: 14px 18px;
  border-radius: 16px;
  font-size: 14.5px;
  font-weight: 800;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.18);
  animation: fadeSlideIn 0.3s ease;
}

.praise-toast.easy {
  background: #ecfdf5;
  border: 2px solid #6ee7b7;
  color: #065f46;
}

.praise-toast.medium {
  background: linear-gradient(135deg, #fffbeb, #fef3c7);
  border: 2px solid #fbbf24;
  color: #92400e;
}

.praise-toast.hard {
  background: linear-gradient(135deg, #fdf2f8, #eef2ff);
  border: 2.5px solid #ec4899;
  color: #831843;
}

/* ==================== SYMBOL GLOSSARY CARD (GIẢI MÃ KÝ HIỆU TRƯỚC KHI HỌC) ==================== */
.glossary-card {
  background: linear-gradient(135deg, #ecfdf5, #f0f9ff);
  border: 2px solid #6ee7b7;
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 22px;
  box-shadow: var(--shadow);
}

.glossary-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.glossary-title {
  font-size: 17px;
  font-weight: 900;
  color: #065f46;
}

.glossary-sub {
  font-size: 13px;
  font-weight: 700;
  color: #047857;
}

.glossary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(255px, 1fr));
  gap: 10px;
}

.glossary-item {
  background: #ffffff;
  border: 1.5px solid #a7f3d0;
  border-radius: 13px;
  padding: 11px 14px;
  display: flex;
  gap: 11px;
  align-items: flex-start;
}

.glossary-sym {
  min-width: 54px;
  padding: 6px 8px;
  border-radius: 10px;
  background: linear-gradient(135deg, #4f46e5, #0284c7);
  color: #ffffff;
  font-weight: 900;
  font-size: 15px;
  text-align: center;
  flex-shrink: 0;
}

.glossary-read {
  font-size: 12.5px;
  font-weight: 900;
  color: #0369a1;
  margin-bottom: 2px;
}

.glossary-mean {
  font-size: 13.5px;
  font-weight: 700;
  color: #334155;
  line-height: 1.45;
}

/* ==================== FULLSCREEN PPT PRESENTATION MODE ==================== */
.btn-ppt-open {
  background: linear-gradient(135deg, #f59e0b, #ec4899);
  color: #fff;
  border: none;
  padding: 6px 14px;
  border-radius: 999px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 3px 10px rgba(236, 72, 153, 0.32);
  transition: transform 0.15s;
}

.btn-ppt-open:hover {
  transform: scale(1.05);
}

.motion-visual.clickable-ppt {
  cursor: zoom-in;
}

.motion-visual.clickable-ppt::after {
  content: '🖥️ Bấm để phóng to như PowerPoint';
  position: absolute;
  bottom: 8px;
  right: 10px;
  font-size: 11px;
  font-weight: 800;
  color: #6366f1;
  background: rgba(238, 242, 255, 0.92);
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid #c7d2fe;
}

.ppt-overlay {
  position: fixed;
  inset: 0;
  z-index: 120;
  background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 100%);
  color: #f8fafc;
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
}

.ppt-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 28px;
  background: rgba(15, 23, 42, 0.78);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  flex-wrap: wrap;
}

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

.ppt-live-pill {
  background: linear-gradient(135deg, #ec4899, #f59e0b);
  color: #fff;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
}

.ppt-lesson-title {
  font-size: 17px;
  font-weight: 900;
  color: #fff;
}

.ppt-topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ppt-counter {
  background: rgba(255, 255, 255, 0.14);
  padding: 5px 14px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 900;
}

.ppt-btn-exit {
  background: #ef4444;
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: 10px;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 900;
  cursor: pointer;
}

.ppt-btn-exit:hover {
  background: #dc2626;
}

.ppt-canvas {
  flex: 1;
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  gap: 32px;
  padding: 28px 44px;
  align-items: center;
  overflow-y: auto;
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
}

.ppt-visual-box {
  background: #ffffff;
  border-radius: 24px;
  padding: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 20px 55px rgba(0, 0, 0, 0.35);
  min-height: 380px;
}

.ppt-visual-box svg {
  width: 100%;
  max-width: 560px;
  height: auto;
}

.ppt-text-box {
  display: flex;
  flex-direction: column;
  gap: 18px;
  animation: fadeSlideIn 0.3s ease;
}

.ppt-badge {
  align-self: flex-start;
  background: rgba(99, 102, 241, 0.28);
  color: #c7d2fe;
  border: 1px solid rgba(165, 180, 252, 0.4);
  padding: 6px 16px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 900;
}

.ppt-heading {
  font-size: 30px;
  font-weight: 900;
  color: #ffffff;
  line-height: 1.3;
}

.ppt-math {
  background: rgba(255, 255, 255, 0.1);
  border-left: 5px solid #fbbf24;
  padding: 16px 20px;
  border-radius: 0 16px 16px 0;
  font-size: 22px;
  font-weight: 900;
  color: #fde68a;
}

.ppt-explain {
  font-size: 19px;
  line-height: 1.65;
  color: #e2e8f0;
  font-weight: 600;
  white-space: pre-line;
}

.ppt-why {
  background: rgba(16, 185, 129, 0.16);
  border: 1.5px solid rgba(52, 211, 153, 0.45);
  border-radius: 16px;
  padding: 15px 18px;
  font-size: 17px;
  color: #a7f3d0;
  font-weight: 700;
  line-height: 1.55;
}

.ppt-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 28px;
  background: rgba(15, 23, 42, 0.88);
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  flex-wrap: wrap;
}

.ppt-ctrl-left {
  display: flex;
  gap: 10px;
}

.ppt-nav-btn {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 10px 18px;
  border-radius: 12px;
  font-family: inherit;
  font-size: 14.5px;
  font-weight: 800;
  cursor: pointer;
}

.ppt-nav-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.24);
}

.ppt-nav-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.ppt-nav-btn.play {
  background: #4f46e5;
  border-color: #6366f1;
}

.ppt-dots {
  display: flex;
  gap: 8px;
}

.ppt-key-hint {
  font-size: 12.5px;
  color: #94a3b8;
  font-weight: 700;
}

@media (max-width: 960px) {
  .ppt-canvas {
    grid-template-columns: 1fr;
    padding: 18px;
  }
  .ppt-heading {
    font-size: 22px;
  }
  .ppt-math {
    font-size: 17px;
  }
  .ppt-explain {
    font-size: 15.5px;
  }
}

/* ==================== FUN FACTS / MATH HISTORY SIDE STORIES ==================== */
.funfacts-section {
  background: linear-gradient(135deg, #fdf2f8, #f5f3ff);
  border: 2px solid #e9d5ff;
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
}

.funfacts-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.funfacts-title {
  font-size: 17px;
  font-weight: 900;
  color: #6b21a8;
}

.funfacts-sub {
  font-size: 12.5px;
  font-weight: 800;
  color: #9333ea;
  background: #fff;
  padding: 4px 11px;
  border-radius: 999px;
  border: 1px solid #e9d5ff;
}

.funfact-list {
  display: grid;
  gap: 12px;
}

.funfact-card {
  background: #ffffff;
  border: 1.5px solid #e9d5ff;
  border-radius: 14px;
  padding: 15px 18px;
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.funfact-emoji {
  font-size: 32px;
  line-height: 1;
  flex-shrink: 0;
}

.funfact-tag {
  display: inline-block;
  background: #f3e8ff;
  color: #7e22ce;
  font-size: 11px;
  font-weight: 900;
  padding: 2px 9px;
  border-radius: 999px;
  margin-bottom: 5px;
}

.funfact-heading {
  font-size: 15.5px;
  font-weight: 900;
  color: #1e293b;
  margin-bottom: 4px;
}

.funfact-story {
  font-size: 14.5px;
  color: #475569;
  font-weight: 600;
  line-height: 1.6;
}

/* ==================== BRIGHT MODERN EDTECH THEME REFRESH ==================== */
:root {
  --bg: #f5f9ff;
  --surface: #ffffff;
  --surface-soft: #f8fbff;
  --primary: #2563eb;
  --primary-light: #eff6ff;
  --primary-dark: #1d4ed8;
  --border: #dbeafe;
  --shadow: 0 6px 24px rgba(37, 99, 235, 0.07);
}

body {
  background: linear-gradient(180deg, #f0f7ff 0%, #f8fbff 45%, #ffffff 100%);
}

.topbar {
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 2px solid #dbeafe;
  box-shadow: 0 2px 12px rgba(37, 99, 235, 0.05);
}

.brand-logo {
  background: linear-gradient(135deg, #2563eb, #38bdf8);
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.28);
}

.sidebar {
  background: #ffffff;
  border-right: 2px solid #dbeafe;
}

.sidebar-header {
  background: linear-gradient(135deg, #eff6ff, #ecfeff);
  border-bottom: 1.5px solid #dbeafe;
}

.lesson-hero::before {
  background: linear-gradient(90deg, #2563eb, #06b6d4, #10b981, #f59e0b);
}

/* Bright EdTech Motion Player Header (replaces dark header) */
.motion-player {
  border: 2px solid #bfdbfe;
}

.motion-player-header {
  background: linear-gradient(90deg, #eff6ff, #e0f2fe);
  color: #1e3a8a;
  border-bottom: 1.5px solid #bfdbfe;
}

.motion-step-counter {
  background: #ffffff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
}

/* Bright Clean PowerPoint Fullscreen Theme (Light Classroom Whiteboard) */
.ppt-overlay {
  background: linear-gradient(135deg, #f0f7ff 0%, #ffffff 55%, #f0fdf4 100%);
  color: #1e293b;
}

.ppt-topbar {
  background: #ffffff;
  border-bottom: 2px solid #dbeafe;
  box-shadow: 0 2px 14px rgba(37, 99, 235, 0.06);
}

.ppt-lesson-title {
  color: #1e3a8a;
}

.ppt-counter {
  background: #eff6ff;
  color: #1d4ed8;
  border: 1.5px solid #bfdbfe;
}

.ppt-visual-box {
  background: #ffffff;
  border: 2px solid #bfdbfe;
  box-shadow: 0 14px 36px rgba(37, 99, 235, 0.1);
}

.ppt-badge {
  background: #dbeafe;
  color: #1d4ed8;
  border: 1px solid #93c5fd;
}

.ppt-heading {
  color: #0f172a;
}

.ppt-math {
  background: #fffbeb;
  border-left: 5px solid #f59e0b;
  color: #92400e;
}

.ppt-explain {
  color: #334155;
}

.ppt-why {
  background: #ecfdf5;
  border: 1.5px solid #6ee7b7;
  color: #065f46;
}

.ppt-controls {
  background: #ffffff;
  border-top: 2px solid #dbeafe;
}

.ppt-nav-btn {
  background: #eff6ff;
  color: #1d4ed8;
  border: 1.5px solid #bfdbfe;
}

.ppt-nav-btn:hover:not(:disabled) {
  background: #dbeafe;
}

.ppt-nav-btn.play {
  background: #2563eb;
  color: #ffffff;
  border-color: #2563eb;
}

.ppt-key-hint {
  color: #64748b;
}

/* Bright Casio Guide Box */
.casio-guide-box {
  background: #f8fafc;
  color: #1e293b;
  border: 1.5px solid #cbd5e1;
}

.casio-guide-title {
  color: #1d4ed8;
}

.casio-note {
  color: #475569;
}

/* Crisp Pixel Art Pet Rendering */
.pixel-pet-svg {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* ==================== FLOATING AI TUTOR CHATBOT WIDGET ==================== */
.chatbot-fab {
  position: fixed;
  bottom: 22px;
  right: 22px;
  z-index: 90;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 12px 20px;
  border-radius: 999px;
  border: 2px solid #93c5fd;
  background: linear-gradient(135deg, #2563eb, #0ea5e9);
  color: #ffffff;
  font-family: inherit;
  font-size: 14.5px;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 10px 28px rgba(37, 99, 235, 0.34);
  transition: transform 0.18s, box-shadow 0.18s;
}

.chatbot-fab:hover {
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 14px 34px rgba(37, 99, 235, 0.42);
}

.chatbot-panel {
  position: fixed;
  bottom: 84px;
  right: 22px;
  z-index: 92;
  width: 390px;
  max-width: calc(100vw - 24px);
  height: 540px;
  max-height: calc(100vh - 110px);
  background: #ffffff;
  border: 2px solid #bfdbfe;
  border-radius: 22px;
  box-shadow: 0 20px 55px rgba(15, 23, 42, 0.18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: popIn 0.22s ease;
}

.chatbot-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: linear-gradient(135deg, #2563eb, #0284c7);
  color: #ffffff;
}

.chatbot-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chatbot-avatar {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.22);
  display: grid;
  place-items: center;
  font-size: 20px;
}

.chatbot-name {
  font-size: 15px;
  font-weight: 900;
  line-height: 1.2;
}

.chatbot-status {
  font-size: 11.5px;
  opacity: 0.92;
  font-weight: 700;
}

.chatbot-header-btns {
  display: flex;
  gap: 6px;
}

.chatbot-icon-btn {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  border: none;
  background: rgba(255, 255, 255, 0.2);
  color: #ffffff;
  font-size: 14px;
  font-weight: 900;
  cursor: pointer;
}

.chatbot-icon-btn:hover {
  background: rgba(255, 255, 255, 0.32);
}

.chatbot-settings {
  padding: 10px 14px;
  background: #eff6ff;
  border-bottom: 1.5px solid #bfdbfe;
  font-size: 12.5px;
  font-weight: 700;
  color: #1e3a8a;
}

.chatbot-settings-row {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}

.chatbot-settings input {
  flex: 1;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1.5px solid #93c5fd;
  font-size: 12.5px;
  font-family: inherit;
}

.chatbot-quick-chips {
  display: flex;
  gap: 6px;
  padding: 8px 12px;
  background: #f8fbff;
  border-bottom: 1px solid #e2e8f0;
  overflow-x: auto;
  scrollbar-width: thin;
}

.chat-chip {
  white-space: nowrap;
  flex-shrink: 0;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1.5px solid #bfdbfe;
  background: #ffffff;
  color: #1d4ed8;
  font-family: inherit;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.chat-chip:hover {
  background: #eff6ff;
}

.chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #f8fbff;
}

.chat-msg {
  max-width: 88%;
  padding: 10px 13px;
  border-radius: 15px;
  font-size: 13.8px;
  font-weight: 600;
  line-height: 1.55;
  white-space: pre-line;
}

.chat-msg.bot {
  align-self: flex-start;
  background: #ffffff;
  color: #1e293b;
  border: 1.5px solid #dbeafe;
  border-bottom-left-radius: 4px;
}

.chat-msg.user {
  align-self: flex-end;
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  color: #ffffff;
  border-bottom-right-radius: 4px;
}

.chatbot-input-bar {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  background: #ffffff;
  border-top: 1.5px solid #dbeafe;
}

.chatbot-input-bar input {
  flex: 1;
  padding: 9px 13px;
  border-radius: 12px;
  border: 1.5px solid #cbd5e1;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  outline: none;
}

.chatbot-input-bar input:focus {
  border-color: #2563eb;
}

.chatbot-send-btn {
  background: #2563eb;
  color: #ffffff;
  border: none;
  padding: 9px 15px;
  border-radius: 12px;
  font-family: inherit;
  font-weight: 900;
  font-size: 14px;
  cursor: pointer;
}

.chatbot-send-btn:hover {
  background: #1d4ed8;
}

/* Shift praise toast slightly up so it doesn't overlap floating chatbot button */
.praise-toast {
  bottom: 84px;
}
