:root {
  --bg-main: #f8fafc;
  --bg-surface: #ffffff;
  --bg-card: rgba(255, 255, 255, 0.95);
  --border-color: rgba(226, 232, 240, 0.85);
  --text-main: #0f172a;
  --text-muted: #64748b;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --success: #10b981;
  --success-light: #ecfdf5;
  --warning: #f59e0b;
  --warning-light: #fffbeb;
  --danger: #ef4444;
  --danger-light: #fef2f2;
  --purple: #8b5cf6;
  --purple-light: #f5f3ff;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.08), 0 2px 4px -2px rgba(0,0,0,0.05);
  --shadow-lg: 0 12px 28px -6px rgba(37, 99, 235, 0.15);
  --transition: all 0.22s ease;
}

[data-theme="dark"] {
  --bg-main: #0b1120;
  --bg-surface: #111827;
  --bg-card: rgba(17, 24, 39, 0.92);
  --border-color: rgba(51, 65, 85, 0.7);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --primary: #38bdf8;
  --primary-hover: #7dd3fc;
  --primary-light: rgba(56, 189, 248, 0.15);
  --success-light: rgba(16, 185, 129, 0.15);
  --warning-light: rgba(245, 158, 11, 0.15);
  --danger-light: rgba(239, 68, 68, 0.15);
  --purple-light: rgba(139, 92, 246, 0.15);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.4);
  --shadow-lg: 0 12px 28px -6px rgba(0,0,0,0.6);
}

* { margin:0; padding:0; box-sizing:border-box; }
body {
  font-family: 'Plus Jakarta Sans', sans-serif;
  background: var(--bg-main);
  color: var(--text-main);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background 0.3s ease, color 0.3s ease;
}

/* NAVBAR */
.navbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg-card);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-color);
  padding: 0.75rem 1.5rem;
}
.navbar-container {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.nav-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.btn-back {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  text-decoration: none;
  font-size: 0.84rem;
  font-weight: 700;
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  transition: var(--transition);
}
.btn-back:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.nav-title {
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.nav-badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  background: var(--primary-light);
  color: var(--primary);
}
.nav-right {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}
.progress-widget {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  font-weight: 600;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
}
.progress-bar-mini {
  width: 65px;
  height: 8px;
  background: var(--border-color);
  border-radius: 999px;
  overflow: hidden;
}
.progress-bar-mini-fill {
  height: 100%;
  width: 0%;
  background: var(--success);
  transition: width 0.3s ease;
}
.btn-theme {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  transition: var(--transition);
}
.btn-theme:hover { border-color: var(--primary); }

/* MAIN CONTENT */
main {
  flex: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
  width: 100%;
}

/* HERO */
.unit-hero {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
}
.hero-glow {
  position: absolute;
  top: -80px;
  right: -80px;
  width: 250px;
  height: 250px;
  background: radial-gradient(circle, rgba(37,99,235,0.15) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
}
.unit-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.tag {
  font-family: 'Outfit', sans-serif;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
}
.tag-blue { background: #dbeafe; color: #1e40af; }
.tag-purple { background: #f3e8ff; color: #6b21a8; }
.tag-emerald { background: #d1fae5; color: #065f46; }
[data-theme="dark"] .tag-blue { background: rgba(30,64,175,0.35); color: #93c5fd; }
[data-theme="dark"] .tag-purple { background: rgba(107,33,168,0.35); color: #d8b4fe; }
[data-theme="dark"] .tag-emerald { background: rgba(6,95,70,0.35); color: #6ee7b7; }

.unit-hero h1 {
  font-family: 'Outfit', sans-serif;
  font-size: 2.3rem;
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 0.75rem;
}
.gradient-text {
  background: linear-gradient(135deg, #2563eb 0%, #06b6d4 50%, #8b5cf6 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.unit-hero p.lead {
  font-size: 1.05rem;
  color: var(--text-muted);
  max-width: 850px;
  margin-bottom: 1.75rem;
}

/* SECTION TABS / NAVIGATION BAR */
.unit-nav-tabs {
  display: flex;
  gap: 0.5rem;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 2rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
}
.unit-tab-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: 0.9rem;
  padding: 0.6rem 1.25rem;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.unit-tab-btn.active, .unit-tab-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

/* THEORY MODULES */
.module-section {
  display: none;
}
.module-section.active {
  display: block;
}

.theory-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2.5rem;
}
.theory-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}
.theory-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
}
.theory-card-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 1rem;
}
.theory-icon {
  font-size: 1.75rem;
}
.theory-card h3 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
}
.formula-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1.15rem;
  margin: 1rem 0;
  font-size: 1.05rem;
  overflow-x: auto;
}
.callout {
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  margin-top: 1rem;
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
}
.callout-info {
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid rgba(37,99,235,0.25);
}
.callout-warning {
  background: var(--warning-light);
  color: #b45309;
  border: 1px solid rgba(245,158,11,0.25);
}
[data-theme="dark"] .callout-warning { color: #fde68a; }

/* INTERACTIVE CLASSIFIER WIDGET */
.widget-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 2rem;
  margin-bottom: 2.5rem;
  box-shadow: var(--shadow-md);
}
.widget-card h3 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}
.chips-pool {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin: 1.25rem 0;
  padding: 1rem;
  background: var(--bg-surface);
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-md);
}
.num-chip {
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid rgba(37,99,235,0.3);
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  font-family: 'Fira Code', monospace;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  transition: var(--transition);
}
.num-chip:hover {
  transform: scale(1.05);
}
.num-chip.selected {
  background: var(--primary);
  color: #fff;
}
.baskets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-top: 1.25rem;
}
.basket {
  background: var(--bg-surface);
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: var(--transition);
}
.basket:hover {
  border-color: var(--primary);
}
.basket-title {
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 0.5rem;
  text-align: center;
}
.basket-content {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  width: 100%;
}

/* EXERCISE ENGINE CARDS */
.exercise-container {
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}
.exercise-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  position: relative;
}
.exercise-card.completed {
  border-color: var(--success);
  background: linear-gradient(180deg, var(--success-light) 0%, var(--bg-card) 60px);
}
.exercise-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.ex-num {
  font-family: 'Outfit', sans-serif;
  font-weight: 800;
  font-size: 1.15rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.level-badge {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
}
.level-green { background: #d1fae5; color: #065f46; }
.level-yellow { background: #fef3c7; color: #92400e; }
.level-red { background: #fee2e2; color: #991b1b; }
[data-theme="dark"] .level-green { background: rgba(6,95,70,0.35); color: #6ee7b7; }
[data-theme="dark"] .level-yellow { background: rgba(217,119,6,0.35); color: #fde68a; }
[data-theme="dark"] .level-red { background: rgba(185,28,28,0.35); color: #fca5a5; }

.exercise-prompt {
  font-size: 1.05rem;
  margin-bottom: 1.25rem;
  line-height: 1.6;
}
.exercise-interactive-area {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.input-answer {
  background: var(--bg-surface);
  border: 1.5px solid var(--border-color);
  color: var(--text-main);
  padding: 0.65rem 1rem;
  border-radius: var(--radius-sm);
  font-family: 'Fira Code', monospace;
  font-size: 1rem;
  width: 220px;
  max-width: 100%;
  transition: var(--transition);
}
.input-answer:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.15);
}
.btn-check {
  background: var(--primary);
  color: #fff;
  border: none;
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: 0.95rem;
  padding: 0.65rem 1.4rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
}
.btn-check:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

/* MCQ OPTIONS */
.mcq-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.75rem;
  width: 100%;
  margin-bottom: 1rem;
}
.mcq-btn {
  background: var(--bg-surface);
  border: 1.5px solid var(--border-color);
  color: var(--text-main);
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 0.95rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  text-align: left;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.mcq-btn:hover {
  border-color: var(--primary);
}
.mcq-btn.selected {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 700;
}

/* FEEDBACK MSG */
.feedback-msg {
  display: none;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  margin-bottom: 1rem;
  align-items: center;
  gap: 0.5rem;
}
.feedback-msg.show {
  display: flex;
}
.feedback-success {
  background: var(--success-light);
  color: var(--success);
  border: 1px solid rgba(16,185,129,0.3);
}
.feedback-error {
  background: var(--danger-light);
  color: var(--danger);
  border: 1px solid rgba(239,68,68,0.3);
}

/* SOLUTION ACCORDION */
.solution-details {
  border-top: 1px dashed var(--border-color);
  padding-top: 0.75rem;
  margin-top: 0.75rem;
}
.solution-summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--text-muted);
  user-select: none;
  transition: var(--transition);
}
.solution-summary:hover {
  color: var(--primary);
}
.solution-content {
  margin-top: 0.75rem;
  padding: 1rem;
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  font-size: 0.92rem;
  line-height: 1.6;
}

/* SCHEMA STYLES */
.schema-block {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 2rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow-sm);
}
.schema-block h3 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.schema-tree-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  margin: 1rem 0;
  line-height: 1.7;
}
.schema-table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: 0.93rem;
}
.schema-table th, .schema-table td {
  padding: 0.75rem 1rem;
  border: 1px solid var(--border-color);
  text-align: left;
}
.schema-table th {
  background: var(--primary-light);
  color: var(--primary);
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
}
.schema-table tr:nth-child(even) {
  background: rgba(0,0,0,0.015);
}
[data-theme="dark"] .schema-table tr:nth-child(even) {
  background: rgba(255,255,255,0.02);
}
.trap-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}
.trap-card {
  background: var(--danger-light);
  border: 1px solid rgba(239,68,68,0.3);
  border-radius: var(--radius-md);
  padding: 1.25rem;
}
.trap-card h4 {
  color: var(--danger);
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  margin-bottom: 0.4rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.trap-card p {
  font-size: 0.88rem;
  line-height: 1.5;
}

/* FOOTER */
footer {
  border-top: 1px solid var(--border-color);
  padding: 2.5rem 1.5rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: auto;
}
