:root {
  --navy: #1e3a5f;
  --navy-dark: #132640;
  --navy-mid: #2a4f7c;
  --sky: #0ea5e9;
  --sky-light: #38bdf8;
  --sky-dark: #0284c7;
  --amber: #f59e0b;
  --amber-light: #fbbf24;
  --success: #10b981;
  --success-light: #d1fae5;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --white: #ffffff;
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-900: #0f172a;
  --text: #1e293b;
  --radius: 10px;
  --radius-lg: 16px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
  --shadow-xl: 0 20px 25px rgba(0,0,0,0.1), 0 8px 10px rgba(0,0,0,0.04);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  color: var(--text);
  background: var(--gray-50);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; }
input, textarea, select { font-family: inherit; }

/* ── Typography ── */
h1 { font-size: clamp(1.75rem, 4vw, 2.75rem); font-weight: 800; line-height: 1.15; }
h2 { font-size: clamp(1.4rem, 3vw, 2rem); font-weight: 700; line-height: 1.25; }
h3 { font-size: 1.2rem; font-weight: 700; line-height: 1.3; }
h4 { font-size: 1rem; font-weight: 600; }
p { margin-bottom: 1rem; }
p:last-child { margin-bottom: 0; }

/* ── Layout ── */
.container { max-width: 1200px; margin: 0 auto; padding: 0 24px; }
.container-sm { max-width: 800px; margin: 0 auto; padding: 0 24px; }
.container-xs { max-width: 540px; margin: 0 auto; padding: 0 24px; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 22px; border-radius: var(--radius); border: none;
  font-size: 0.95rem; font-weight: 600; cursor: pointer;
  transition: all 0.18s ease; white-space: nowrap; text-decoration: none;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--sky); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--sky-dark); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-navy { background: var(--navy); color: white; }
.btn-navy:hover:not(:disabled) { background: var(--navy-dark); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-outline { background: transparent; color: var(--navy); border: 2px solid var(--navy); }
.btn-outline:hover:not(:disabled) { background: var(--navy); color: white; }
.btn-outline-white { background: transparent; color: white; border: 2px solid rgba(255,255,255,0.6); }
.btn-outline-white:hover:not(:disabled) { background: rgba(255,255,255,0.15); border-color: white; }
.btn-ghost { background: transparent; color: var(--gray-600); }
.btn-ghost:hover:not(:disabled) { background: var(--gray-100); color: var(--text); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover:not(:disabled) { background: #0d9668; transform: translateY(-1px); }
.btn-danger { background: var(--danger); color: white; }
.btn-lg { padding: 13px 28px; font-size: 1.05rem; border-radius: 12px; }
.btn-sm { padding: 6px 14px; font-size: 0.85rem; }
.btn-block { width: 100%; }
.btn-loading { position: relative; color: transparent !important; }
.btn-loading::after {
  content: ''; position: absolute; width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.4); border-top-color: white;
  border-radius: 50%; animation: spin 0.6s linear infinite;
}

/* ── Cards ── */
.card {
  background: white; border-radius: var(--radius-lg);
  box-shadow: var(--shadow); overflow: hidden;
}
.card-body { padding: 24px; }
.card-header { padding: 20px 24px; border-bottom: 1px solid var(--gray-200); }
.card-footer { padding: 16px 24px; border-top: 1px solid var(--gray-200); background: var(--gray-50); }

/* ── Badges ── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 999px; font-size: 0.75rem; font-weight: 600;
}
.badge-sky { background: #e0f2fe; color: #0369a1; }
.badge-navy { background: #dbeafe; color: var(--navy); }
.badge-success { background: var(--success-light); color: #065f46; }
.badge-warning { background: var(--warning-light); color: #92400e; }
.badge-danger { background: var(--danger-light); color: #991b1b; }
.badge-gray { background: var(--gray-100); color: var(--gray-600); }
.badge-amber { background: #fef3c7; color: #92400e; }

/* ── Form elements ── */
.form-group { margin-bottom: 20px; }
.form-label { display: block; font-size: 0.9rem; font-weight: 600; color: var(--gray-700); margin-bottom: 6px; }
.form-input {
  width: 100%; padding: 11px 14px; border: 2px solid var(--gray-200);
  border-radius: var(--radius); font-size: 0.95rem; color: var(--text);
  background: white; transition: border-color 0.15s;
  outline: none;
}
.form-input:focus { border-color: var(--sky); box-shadow: 0 0 0 3px rgba(14,165,233,0.12); }
.form-input::placeholder { color: var(--gray-400); }
.form-select {
  width: 100%; padding: 11px 14px; border: 2px solid var(--gray-200);
  border-radius: var(--radius); font-size: 0.95rem; color: var(--text);
  background: white; outline: none; appearance: none; cursor: pointer;
  transition: border-color 0.15s;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2364748b' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center;
  padding-right: 40px;
}
.form-select:focus { border-color: var(--sky); box-shadow: 0 0 0 3px rgba(14,165,233,0.12); }
.form-error { font-size: 0.82rem; color: var(--danger); margin-top: 5px; display: none; }
.form-error.visible { display: block; }
.form-hint { font-size: 0.82rem; color: var(--gray-500); margin-top: 5px; }

/* ── Progress bar ── */
.progress-bar {
  background: var(--gray-200); border-radius: 999px; height: 8px; overflow: hidden;
}
.progress-fill {
  height: 100%; background: linear-gradient(90deg, var(--sky), var(--sky-light));
  border-radius: 999px; transition: width 0.5s ease;
}
.progress-fill.success { background: linear-gradient(90deg, var(--success), #34d399); }

/* ── Tabs ── */
.tabs { display: flex; border-bottom: 2px solid var(--gray-200); gap: 0; }
.tab-btn {
  padding: 12px 20px; font-size: 0.95rem; font-weight: 600;
  color: var(--gray-500); background: none; border: none;
  border-bottom: 2px solid transparent; margin-bottom: -2px;
  transition: all 0.15s; cursor: pointer;
}
.tab-btn:hover { color: var(--navy); }
.tab-btn.active { color: var(--sky); border-bottom-color: var(--sky); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Navbar ── */
.navbar {
  background: var(--navy); padding: 0 24px; height: 64px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 100; box-shadow: var(--shadow);
}
.navbar-brand {
  display: flex; align-items: center; gap: 10px;
  color: white; font-size: 1.1rem; font-weight: 800; letter-spacing: -0.02em;
}
.navbar-brand .dot { color: var(--sky); }
.navbar-actions { display: flex; align-items: center; gap: 12px; }
.navbar-user {
  display: flex; align-items: center; gap: 8px;
  color: rgba(255,255,255,0.85); font-size: 0.9rem;
}
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--sky); color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.85rem; flex-shrink: 0;
}
.avatar.lg { width: 52px; height: 52px; font-size: 1.1rem; }

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15,23,42,0.6);
  backdrop-filter: blur(4px); z-index: 200;
  display: flex; align-items: center; justify-content: center; padding: 16px;
  opacity: 0; pointer-events: none; transition: opacity 0.2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: white; border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl); width: 100%; max-width: 480px;
  transform: translateY(12px); transition: transform 0.2s;
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-header {
  padding: 24px 24px 0; display: flex; align-items: center;
  justify-content: space-between;
}
.modal-close {
  width: 32px; height: 32px; border-radius: 50%; border: none;
  background: var(--gray-100); color: var(--gray-500);
  font-size: 1.2rem; display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all 0.15s;
}
.modal-close:hover { background: var(--gray-200); color: var(--text); }
.modal-body { padding: 20px 24px 24px; }

/* ── Alert / callout boxes ── */
.alert {
  padding: 14px 18px; border-radius: var(--radius);
  font-size: 0.9rem; border-left: 4px solid; margin-bottom: 16px;
}
.alert-info { background: #e0f2fe; border-color: var(--sky); color: #0c4a6e; }
.alert-success { background: var(--success-light); border-color: var(--success); color: #064e3b; }
.alert-warning { background: var(--warning-light); border-color: var(--amber); color: #78350f; }
.alert-danger { background: var(--danger-light); border-color: var(--danger); color: #7f1d1d; }

/* ── Toast ── */
.toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 300;
  background: var(--gray-900); color: white; padding: 12px 20px;
  border-radius: var(--radius); font-size: 0.9rem; font-weight: 500;
  box-shadow: var(--shadow-lg); transform: translateY(12px);
  opacity: 0; transition: all 0.25s; max-width: 360px;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.toast-success { background: var(--success); }
.toast.toast-error { background: var(--danger); }
.toast.toast-warning { background: #d97706; }

/* ── Module status indicators ── */
.module-card {
  background: white; border-radius: var(--radius-lg); border: 2px solid var(--gray-200);
  padding: 20px; display: flex; align-items: flex-start; gap: 16px;
  transition: all 0.18s; cursor: pointer; text-decoration: none;
}
.module-card:hover { border-color: var(--sky); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.module-card.locked { opacity: 0.55; cursor: not-allowed; }
.module-card.locked:hover { border-color: var(--gray-200); box-shadow: none; transform: none; }
.module-card.completed { border-color: var(--success); }
.module-card.active { border-color: var(--sky); background: #f0f9ff; }
.module-icon {
  width: 44px; height: 44px; border-radius: 10px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem;
}
.module-icon.common { background: #dbeafe; }
.module-icon.beginner { background: #dcfce7; }
.module-icon.medium { background: #fef3c7; }
.module-icon.advanced { background: #f3e8ff; }
.module-icon.student { background: #fce7f3; }
.status-dot {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; margin-top: 5px;
}
.status-dot.complete { background: var(--success); }
.status-dot.active { background: var(--sky); }
.status-dot.locked { background: var(--gray-300); }
.status-dot.available { background: var(--amber); }

/* ── Track badge ── */
.track-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 14px; border-radius: 999px; font-size: 0.85rem; font-weight: 700;
  text-transform: capitalize;
}
.track-badge.beginner { background: #dcfce7; color: #166534; }
.track-badge.medium { background: #fef3c7; color: #92400e; }
.track-badge.advanced { background: #f3e8ff; color: #6b21a8; }
.track-badge.student { background: #fce7f3; color: #9d174d; }
.track-badge.not-placed { background: var(--gray-100); color: var(--gray-600); }

/* ── Section headers ── */
.section-label {
  font-size: 0.75rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--gray-500); margin-bottom: 12px;
}

/* ── Stats ── */
.stat-card {
  background: white; border-radius: var(--radius-lg); padding: 20px 24px;
  box-shadow: var(--shadow); text-align: center;
}
.stat-number { font-size: 2rem; font-weight: 800; color: var(--navy); line-height: 1; }
.stat-label { font-size: 0.85rem; color: var(--gray-500); margin-top: 4px; font-weight: 500; }

/* ── Divider ── */
.divider {
  height: 1px; background: var(--gray-200); margin: 24px 0;
}
.divider-text {
  display: flex; align-items: center; gap: 12px; margin: 20px 0;
  color: var(--gray-400); font-size: 0.85rem;
}
.divider-text::before, .divider-text::after {
  content: ''; flex: 1; height: 1px; background: var(--gray-200);
}

/* ── Spinner ── */
.spinner {
  width: 40px; height: 40px; border: 3px solid var(--gray-200);
  border-top-color: var(--sky); border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.spinner.sm { width: 20px; height: 20px; border-width: 2px; }

/* ── Loading screen ── */
.loading-screen {
  position: fixed; inset: 0; background: white; z-index: 500;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
}
.loading-screen.hidden { display: none; }

/* ── Animations ── */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.fade-in { animation: fadeIn 0.3s ease forwards; }

/* ── Responsive grid helpers ── */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

/* ── Utility ── */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-navy { color: var(--navy); }
.text-sky { color: var(--sky); }
.text-amber { color: var(--amber); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-gray { color: var(--gray-500); }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.text-lg { font-size: 1.125rem; }
.fw-700 { font-weight: 700; }
.fw-600 { font-weight: 600; }
.mt-0 { margin-top: 0; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mt-32 { margin-top: 32px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.gap-20 { gap: 20px; }
.w-full { width: 100%; }
.hidden { display: none !important; }

@media (max-width: 768px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .container, .container-sm { padding: 0 16px; }
  .hide-mobile { display: none !important; }
  h1 { font-size: 1.75rem; }
}
@media (max-width: 480px) {
  .navbar { padding: 0 16px; }
  .card-body { padding: 16px; }
}

/* ── Track dot indicator (replaces track emoji) ── */
.track-dot {
  display: inline-block;
  width: 10px; height: 10px; border-radius: 50%;
  flex-shrink: 0; vertical-align: middle;
}

/* ── Coming-soon module row ── */
.mod-row.coming-soon {
  opacity: 0.6; cursor: default;
  pointer-events: none;
  background: var(--gray-50);
}
.mod-row.coming-soon .mod-num {
  background: var(--gray-100); color: var(--gray-300);
}

/* ── Coming-soon track banner ── */
.track-coming-soon-banner {
  background: white; border: 2px dashed var(--gray-200);
  border-radius: var(--radius-lg); padding: 20px 24px;
  display: flex; align-items: center; gap: 16px;
}

/* ── Premium module header (all modules) ── */
.module-header {
  background: linear-gradient(135deg, #0a1929 0%, #1e3a5f 55%, #1a4875 100%);
  border-radius: var(--radius-lg); padding: 36px; margin-bottom: 28px; color: white;
  position: relative; overflow: hidden;
}
.module-header::before {
  content: ''; position: absolute; inset: 0;
  background-image: radial-gradient(rgba(255,255,255,0.04) 1px, transparent 1px);
  background-size: 22px 22px; pointer-events: none;
}
.module-header::after {
  content: ''; position: absolute; top: -80px; right: -80px;
  width: 260px; height: 260px;
  background: radial-gradient(circle, rgba(14,165,233,0.18) 0%, transparent 65%);
  pointer-events: none;
}
.module-header > * { position: relative; }
.module-header h1 { color: white; font-size: clamp(1.5rem, 3vw, 2rem); margin-bottom: 8px; }
.module-header .meta { color: rgba(255,255,255,0.7); font-size: 0.875rem; display: flex; gap: 20px; flex-wrap: wrap; }
.module-header .meta span { display: flex; align-items: center; gap: 5px; }
.mod-track-tag {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(255,255,255,0.12); border: 1px solid rgba(255,255,255,0.18);
  border-radius: 999px; padding: 4px 14px; font-size: 0.72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: rgba(255,255,255,0.9); margin-bottom: 14px;
}

/* ── Subject selector pills ── */
.subject-pills {
  display: flex; flex-wrap: wrap; gap: 8px; margin: 20px 0 24px;
}
.subject-pill {
  padding: 7px 16px; border-radius: 999px; font-size: 0.85rem; font-weight: 600;
  border: 2px solid var(--gray-200); background: white; color: var(--gray-600);
  cursor: pointer; transition: all 0.15s;
}
.subject-pill:hover { border-color: var(--sky); color: var(--sky-dark); }
.subject-pill.active { background: var(--navy); border-color: var(--navy); color: white; }
.subject-panel { display: none; }
.subject-panel.active { display: block; }

/* ── Prompt cards (dark mode) ── */
.prompt-card {
  background: #0a1929; border-radius: var(--radius);
  padding: 16px 16px 14px; position: relative;
  border-left: 3px solid var(--sky); margin-bottom: 10px;
}
.prompt-label {
  font-size: 0.7rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.07em; color: var(--sky-light); margin-bottom: 8px;
}
.prompt-text {
  color: rgba(255,255,255,0.82); font-size: 0.88rem; line-height: 1.65;
  padding-right: 64px;
}
.btn-copy {
  position: absolute; top: 14px; right: 14px;
  background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.18);
  color: rgba(255,255,255,0.65); border-radius: 6px; padding: 4px 12px;
  font-size: 0.78rem; font-weight: 600; cursor: pointer; transition: all 0.15s;
  font-family: inherit;
}
.btn-copy:hover { background: rgba(14,165,233,0.25); border-color: var(--sky); color: white; }
.btn-copy.copied { background: rgba(16,185,129,0.25); border-color: var(--success); color: #6ee7b7; }

/* ── Principle cards (3-up grid) ── */
.principles-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 20px; }
.principle-card {
  background: var(--gray-50); border-radius: var(--radius-lg);
  padding: 20px; border: 2px solid var(--gray-100);
}
.principle-num {
  width: 32px; height: 32px; border-radius: 50%; background: var(--navy);
  color: white; font-weight: 800; font-size: 0.9rem;
  display: flex; align-items: center; justify-content: center; margin-bottom: 12px;
}
.principle-card h3 { font-size: 0.95rem; color: var(--navy); margin-bottom: 6px; }
.principle-card p { font-size: 0.87rem; color: var(--gray-600); line-height: 1.6; margin: 0; }

@media (max-width: 768px) {
  .principles-grid { grid-template-columns: 1fr; }
  .subject-pills { gap: 6px; }
  .subject-pill { font-size: 0.8rem; padding: 6px 12px; }
}

/* ── Confetti celebration ── */
@keyframes confetti-fall {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  80% { opacity: 1; }
  100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}
@keyframes confetti-sway {
  0%, 100% { margin-left: 0; }
  25% { margin-left: 14px; }
  75% { margin-left: -14px; }
}
.confetti-piece {
  position: fixed;
  animation: confetti-fall 2.4s linear forwards, confetti-sway 0.9s ease-in-out infinite;
  pointer-events: none;
  z-index: 9999;
}

/* ── Accordion (content cards) ─────────────────────────────── */
.card-toggle-head {
  cursor: pointer; user-select: none;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 16px; padding: 12px 16px;
  border-radius: 8px;
  /* background tint injected via JS per section color */
  transition: filter 0.15s, color 0.15s;
}
.card-toggle-head:hover { filter: brightness(0.92); color: var(--navy); }
.card-chevron {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
  background: rgba(255,255,255,0.8); border: 1.5px solid rgba(0,0,0,0.12);
  border-radius: 999px; padding: 4px 12px; color: inherit;
  flex-shrink: 0; white-space: nowrap; opacity: 0.8;
}
.card-toggle-head:hover .card-chevron { opacity: 1; }
.card-body { padding-top: 4px; }
.card-body.collapsed { display: none; }

/* ── TOC — numbered + scroll-aware ─────────────────────────── */
.toc-num {
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--gray-200); color: var(--gray-500);
  font-size: 0.65rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: background 0.25s, color 0.25s;
}
.toc-item.toc-active { color: var(--sky-dark); font-weight: 600; }
.toc-item.toc-active .toc-num { background: var(--sky); color: white; }
.toc-item.toc-done { color: var(--success); }
.toc-item.toc-done .toc-num { background: var(--success); color: white; }
