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

:root {
  --bg: #f7f8fc;
  --bg2: #ffffff;
  --surface: #eef0f7;
  --border: rgba(0,0,0,0.1);
  --border2: rgba(0,0,0,0.06);
  --text: #18181b;
  --text2: #52525b;
  --text3: #a1a1aa;
  /* AIGP brand: deep navy + gold accent */
  --brand: #1a3a6b;
  --brand-light: #e8eef8;
  --gold: #b8860b;
  --gold-bg: #fdf6e3;
  --gold-text: #7a5800;
  /* semantic colours */
  --blue: #1d4ed8;
  --blue-bg: #eff6ff;
  --blue-text: #1e40af;
  --green: #15803d;
  --green-bg: #f0fdf4;
  --green-text: #166534;
  --amber: #b45309;
  --amber-bg: #fffbeb;
  --amber-text: #92400e;
  --purple: #6d28d9;
  --purple-bg: #f5f3ff;
  --purple-text: #4c1d95;
  --teal: #0f766e;
  --teal-bg: #f0fdfa;
  --teal-text: #134e4a;
  --coral: #be123c;
  --coral-bg: #fff1f2;
  --coral-text: #9f1239;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f111a;
    --bg2: #1a1d2e;
    --surface: #252840;
    --border: rgba(255,255,255,0.1);
    --border2: rgba(255,255,255,0.05);
    --text: #e4e6f0;
    --text2: #9ca3af;
    --text3: #6b7280;
    --brand: #4a7fd4;
    --brand-light: #1e2d4a;
    --gold: #f0c040;
    --gold-bg: #2a2000;
    --gold-text: #f0c040;
    --blue: #93c5fd;
    --blue-bg: #1e3a5f;
    --blue-text: #bfdbfe;
    --green: #4ade80;
    --green-bg: #14532d;
    --green-text: #86efac;
    --amber: #fbbf24;
    --amber-bg: #451a03;
    --amber-text: #fcd34d;
    --purple: #c084fc;
    --purple-bg: #3b0764;
    --purple-text: #e9d5ff;
    --teal: #2dd4bf;
    --teal-bg: #042f2e;
    --teal-text: #99f6e4;
    --coral: #fb7185;
    --coral-bg: #4c0519;
    --coral-text: #fda4af;
    --shadow: 0 1px 3px rgba(0,0,0,0.4);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  }
}

html { font-size: 16px; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}
#root { min-height: 100vh; }
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

h1 { font-size: 1.75rem; font-weight: 600; line-height: 1.3; }
h2 { font-size: 1.25rem; font-weight: 600; line-height: 1.4; }
h3 { font-size: 1rem; font-weight: 600; }
p { color: var(--text2); }

.container { max-width: 960px; margin: 0 auto; padding: 0 1.5rem; }

.card {
  background: var(--bg2);
  border: 0.5px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}
.card-hover { cursor: pointer; transition: all 0.15s; }
.card-hover:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.badge-brand  { background: var(--brand-light); color: var(--brand); }
.badge-gold   { background: var(--gold-bg);    color: var(--gold-text); }
.badge-blue   { background: var(--blue-bg);    color: var(--blue-text); }
.badge-green  { background: var(--green-bg);   color: var(--green-text); }
.badge-amber  { background: var(--amber-bg);   color: var(--amber-text); }
.badge-purple { background: var(--purple-bg);  color: var(--purple-text); }
.badge-teal   { background: var(--teal-bg);    color: var(--teal-text); }
.badge-coral  { background: var(--coral-bg);   color: var(--coral-text); }

/* Domain colour mapping */
.domain-I    { background: var(--blue-bg);   color: var(--blue-text); }
.domain-II   { background: var(--purple-bg); color: var(--purple-text); }
.domain-III  { background: var(--teal-bg);   color: var(--teal-text); }
.domain-IV   { background: var(--amber-bg);  color: var(--amber-text); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  border: 0.5px solid var(--border);
  background: var(--bg2);
  color: var(--text);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
  white-space: nowrap;
}
.btn:hover { background: var(--surface); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: #fff; border-color: transparent; }
.btn-primary:hover { opacity: 0.88; background: var(--brand); }
.btn-gold { background: var(--gold); color: #fff; border-color: transparent; }
.btn-gold:hover { opacity: 0.88; }
.btn-sm { font-size: 0.8rem; padding: 0.35rem 0.75rem; }

/* Progress */
.progress-track { height: 6px; background: var(--surface); border-radius: 3px; overflow: hidden; }
.progress-fill  { height: 100%; border-radius: 3px; background: var(--brand); transition: width 0.4s ease; }
.progress-fill-gold { background: var(--gold); }
.progress-fill-green { background: var(--green); }

/* Chat bubbles */
.bubble-user {
  background: var(--brand);
  color: #fff;
  border-radius: var(--radius) var(--radius) 4px var(--radius);
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
  max-width: 85%;
  align-self: flex-end;
}
.bubble-ai {
  background: var(--bg2);
  border: 0.5px solid var(--border);
  border-radius: var(--radius) var(--radius) var(--radius) 4px;
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
  max-width: 92%;
  align-self: flex-start;
  line-height: 1.65;
}
.bubble-ai p { color: var(--text); margin-bottom: 0.5rem; }
.bubble-ai p:last-child { margin-bottom: 0; }

/* Flashcard */
.flashcard { perspective: 1000px; cursor: pointer; }
.flashcard-inner {
  transition: transform 0.5s;
  transform-style: preserve-3d;
  position: relative;
  min-height: 180px;
}
.flashcard-inner.flipped { transform: rotateY(180deg); }
.flashcard-face {
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  padding: 1.75rem;
  border-radius: var(--radius);
  border: 0.5px solid var(--border);
  background: var(--bg2);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 180px;
}
.flashcard-back {
  transform: rotateY(180deg);
  position: absolute;
  inset: 0;
  background: var(--brand-light);
  border-color: var(--brand);
}

/* Quiz answer options */
.answer-option {
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  border: 0.5px solid var(--border);
  background: var(--bg2);
  cursor: pointer;
  transition: all 0.15s;
  font-size: 0.9rem;
  color: var(--text);
  line-height: 1.5;
  text-align: left;
  width: 100%;
  font-family: inherit;
}
.answer-option:hover:not(:disabled) { border-color: var(--brand); background: var(--brand-light); }
.answer-option.correct  { background: var(--green-bg);  border-color: var(--green); }
.answer-option.wrong    { background: var(--coral-bg);  border-color: var(--coral); }
.answer-option.selected { background: var(--blue-bg);   border-color: var(--blue); }

/* Lesson list item */
.lesson-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  border: 0.5px solid var(--border2);
  background: var(--bg2);
  cursor: pointer;
  transition: all 0.15s;
}
.lesson-item:hover { border-color: var(--brand); background: var(--brand-light); }
.lesson-item.active { border-color: var(--brand); background: var(--brand-light); }
.lesson-item.completed .lesson-num { background: var(--green); color: #fff; }
.lesson-num {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--surface);
  color: var(--text2);
  font-size: 0.75rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Animations */
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.fade-in { animation: fadeIn 0.25s ease forwards; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.5; } }
.typing-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--text3); animation: pulse 1s ease-in-out infinite; }
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

/* Grid helpers */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }
@media (max-width: 640px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

/* Mindmap container */
.mindmap-svg { width: 100%; height: 520px; cursor: grab; }
.mindmap-svg:active { cursor: grabbing; }
.mindmap-node { cursor: pointer; transition: opacity 0.2s; }
.mindmap-node:hover { opacity: 0.85; }

/* Tab nav */
.tab-nav {
  display: flex;
  gap: 0;
  border-bottom: 0.5px solid var(--border);
  overflow-x: auto;
}
.tab-btn {
  padding: 0.65rem 1.1rem;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 400;
  color: var(--text3);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}
.tab-btn:hover { color: var(--text2); }
.tab-btn.active {
  font-weight: 600;
  color: var(--text);
  border-bottom-color: var(--brand);
}

/* Stat card */
.stat-card {
  background: var(--bg2);
  border: 0.5px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  text-align: center;
}
.stat-num {
  font-size: 2rem;
  font-weight: 700;
  color: var(--brand);
  line-height: 1;
  margin-bottom: 0.25rem;
}
.stat-label { font-size: 0.8rem; color: var(--text3); font-weight: 500; }

/* Info banner */
.banner {
  border-radius: var(--radius-sm);
  padding: 0.875rem 1rem;
  font-size: 0.875rem;
  line-height: 1.6;
  border: 0.5px solid;
}
.banner-brand { background: var(--brand-light); border-color: var(--brand); color: var(--brand); }
.banner-gold  { background: var(--gold-bg);    border-color: var(--gold);  color: var(--gold-text); }
.banner-green { background: var(--green-bg);   border-color: var(--green); color: var(--green-text); }

/* Section header row */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}
