/* ═══════════════════════════════════════════════
   StudentAssist · Component Styles
   Vibrant + Gamified — every module its own color
═══════════════════════════════════════════════ */

/* ═════ LAYOUT ═════ */
.screen {
  display: none;
  width: 100%;
  min-height: 100vh;
  position: relative;
}
.screen.active {
  display: flex;
  flex-direction: column;
}
#hub-screen {
  justify-content: center;
  align-items: center;
  padding: 2rem 1.25rem;
  background:
    radial-gradient(ellipse 60% 40% at 20% 20%, rgba(0,212,255,.05) 0%, transparent 60%),
    radial-gradient(ellipse 50% 40% at 80% 80%, rgba(168,85,247,.05) 0%, transparent 60%),
    var(--bg);
}
#module-screen { overflow: hidden; }

/* ═════ HUB SCREEN ═════ */
.hub-inner {
  max-width: 520px;
  width: 100%;
  animation: fadeUp 0.5s ease-out;
}

.hub-wordmark {
  text-align: center;
  margin-bottom: 0;
}

.hub-logo {
  font-size: 2.8rem;
  font-weight: 900;
  color: var(--text);
  letter-spacing: -0.04em;
  line-height: 1;
  margin-bottom: 0.6rem;
}

.hub-dot {
  background: linear-gradient(135deg, #00d4ff 0%, #a855f7 50%, #f59e0b 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hub-tagline {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.hub-cards {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin-bottom: 2rem;
}

/* Hub card — uses --card-color (set inline per card) */
.hub-card {
  background: var(--surface);
  border: 1px solid color-mix(in srgb, var(--card-color) 25%, var(--border));
  border-radius: var(--radius);
  padding: 1.4rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  cursor: pointer;
  transition: all 0.25s ease;
  position: relative;
  overflow: hidden;
}

.hub-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 80% 100% at 0% 50%, color-mix(in srgb, var(--card-color) 12%, transparent), transparent 70%);
  pointer-events: none;
}

.hub-card::after {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--card-color);
  border-radius: var(--radius) 0 0 var(--radius);
  opacity: 0.8;
}

.hub-card:hover {
  border-color: var(--card-color);
  background: color-mix(in srgb, var(--card-color) 6%, var(--surface));
  transform: translateX(4px);
  box-shadow: 0 4px 24px color-mix(in srgb, var(--card-color) 20%, transparent);
}

.hub-card-soon {
  opacity: 0.5;
  cursor: not-allowed;
}
.hub-card-soon:hover {
  border-color: color-mix(in srgb, var(--card-color) 25%, var(--border));
  background: var(--surface);
  transform: none;
  box-shadow: none;
}

.hub-card-icon {
  width: 54px;
  height: 54px;
  border-radius: 14px;
  background: color-mix(in srgb, var(--card-color) 15%, var(--surface2));
  border: 1px solid color-mix(in srgb, var(--card-color) 30%, transparent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.9rem;
  flex-shrink: 0;
}

.hub-card-content {
  text-align: left;
  flex: 1;
  min-width: 0;
}

.hub-card-header {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  margin-bottom: 0.3rem;
}

.hub-card-code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--card-color);
  letter-spacing: 0.08em;
  background: color-mix(in srgb, var(--card-color) 12%, transparent);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
}

.hub-card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.hub-card-title-text { flex: 1; }

.hub-card-arrow {
  color: var(--card-color);
  font-size: 1.3rem;
  opacity: 0.6;
  transition: all 0.25s ease;
}
.hub-card:hover .hub-card-arrow {
  opacity: 1;
  transform: translateX(3px);
}

.hub-card-desc {
  font-size: 0.82rem;
  color: var(--muted);
  margin: 0.35rem 0 0.6rem 0;
  line-height: 1.45;
}

.hub-card-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.hub-chip {
  display: inline-block;
  background: var(--surface3);
  color: var(--text-2);
  padding: 0.25rem 0.6rem;
  border-radius: 8px;
  font-size: 0.72rem;
  font-weight: 500;
  border: 1px solid var(--border);
}

.hub-footer {
  text-align: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

/* ═════ MODULE SCREEN ═════ */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  background: rgba(8,8,17,0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 0.6rem;
  gap: 0.5rem;
  z-index: 50;
  /* Colored bottom line per module */
  box-shadow: 0 1px 0 0 color-mix(in srgb, var(--module-color) 40%, transparent);
}

.topbar-btn {
  width: 32px; height: 32px;
  border: none;
  background: var(--surface2);
  color: var(--text-2);
  cursor: pointer;
  font-size: 1rem;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px;
  transition: all 0.2s ease;
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.topbar-btn:hover {
  background: var(--surface3);
  color: var(--module-color);
  border-color: var(--module-color);
}

.topbar-breadcrumb {
  display: flex; align-items: center; gap: 0.4rem;
  flex: 1; min-width: 0;
  font-size: 0.88rem;
}
.topbar-favicon {
  width: 20px; height: 20px;
  border-radius: 5px;
  object-fit: contain;
  flex-shrink: 0;
  opacity: 0.85;
}
.topbar-home { color: var(--muted); }
.topbar-sep  { color: var(--dim); }
.topbar-module {
  color: var(--module-color);
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-actions { display: flex; align-items: center; gap: 0.35rem; }

.xp-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  padding: 0.35rem 0.75rem;
  background: color-mix(in srgb, var(--module-color) 12%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--module-color) 35%, transparent);
  border-radius: 8px;
  color: var(--module-color);
  font-weight: 700;
  white-space: nowrap;
}

/* ═════ SIDE NAVIGATION ═════ */
.nav-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  display: none;
  z-index: 90;
  backdrop-filter: blur(2px);
  animation: fadeIn 0.2s ease;
}
.nav-overlay.open { display: block; }

.side-nav {
  position: fixed;
  left: -300px; top: 0; bottom: 0;
  width: 280px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1.25rem 1rem;
  overflow-y: auto;
  z-index: 100;
  transition: left 0.3s cubic-bezier(0.4,0,0.2,1);
  display: flex;
  flex-direction: column;
}
.side-nav.open { left: 0; }

.sn-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
}
.sn-logo { font-size: 1rem; font-weight: 800; color: var(--text); }
.sn-logo span { color: var(--module-color); }

.sn-close {
  width: 30px; height: 30px;
  border: none;
  background: var(--surface2);
  color: var(--text-2);
  font-size: 1.1rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px;
  transition: all 0.2s ease;
}
.sn-close:hover { background: var(--surface3); color: var(--module-color); }

.sn-module-badge {
  background: color-mix(in srgb, var(--module-color) 12%, var(--surface2));
  color: var(--module-color);
  padding: 0.6rem 1rem;
  border-radius: 10px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  text-align: center;
  margin-bottom: 1.25rem;
  border: 1px solid color-mix(in srgb, var(--module-color) 30%, transparent);
  letter-spacing: 0.05em;
}

.sn-section { margin-bottom: 1.25rem; }

.sn-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.5rem;
  letter-spacing: 0.1em;
  padding: 0 0.5rem;
}

.sn-btn {
  width: 100%;
  padding: 0.7rem 0.9rem;
  border: none;
  background: transparent;
  color: var(--text-2);
  text-align: left;
  cursor: pointer;
  border-radius: 10px;
  transition: all 0.15s ease;
  font-size: 0.9rem;
  margin-bottom: 0.25rem;
  font-family: inherit;
  font-weight: 500;
}
.sn-btn:hover {
  background: var(--surface2);
  color: var(--text);
}
.sn-btn.active {
  background: color-mix(in srgb, var(--module-color) 12%, var(--surface2));
  color: var(--module-color);
  font-weight: 700;
  border-left: 3px solid var(--module-color);
  padding-left: calc(0.9rem - 3px);
}

.sn-danger { color: var(--red); }
.sn-danger:hover { background: rgba(244,63,94,0.1); color: var(--red); }

.sn-divider { height: 1px; background: var(--border); margin: 0.75rem 0; }

.sn-modules { display: flex; flex-direction: column; gap: 0.4rem; }

.sn-mod-card {
  padding: 0.65rem 0.9rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s ease;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-2);
  font-family: inherit;
}
.sn-mod-card:hover { border-color: var(--module-color); color: var(--text); }
.sn-mod-card.active {
  border-color: var(--module-color);
  background: color-mix(in srgb, var(--module-color) 10%, var(--surface2));
  color: var(--module-color);
  font-weight: 700;
}

.sn-footer { margin-top: auto; padding-top: 1rem; border-top: 1px solid var(--border); }

/* ═════ BUTTONS ═════ */
.btn {
  border: none;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 700;
  padding: 0.7rem 1.25rem;
  border-radius: 10px;
  transition: all 0.2s ease;
  font-family: inherit;
  letter-spacing: 0.01em;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none !important; }

.btn-primary {
  background: var(--module-color);
  color: #06060e;
}
.btn-primary:not(:disabled):hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px color-mix(in srgb, var(--module-color) 40%, transparent);
  filter: brightness(1.1);
}
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  border: 1.5px solid var(--module-color);
  color: var(--module-color);
  background: transparent;
}
.btn-secondary:not(:disabled):hover {
  background: color-mix(in srgb, var(--module-color) 12%, transparent);
  transform: translateY(-2px);
}

.btn-ghost {
  background: var(--surface2);
  color: var(--text-2);
  border: 1px solid var(--border);
}
.btn-ghost:not(:disabled):hover {
  background: var(--surface3);
  color: var(--text);
  border-color: var(--module-color);
}

.btn-danger { background: var(--red); color: white; }
.btn-danger:hover { opacity: 0.9; }

.btn-got {
  background: var(--green);
  color: #06060e;
  font-weight: 800;
}
.btn-got:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px var(--green-glow);
}

.btn-again {
  background: var(--amber);
  color: #06060e;
  font-weight: 800;
}
.btn-again:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px var(--amber-glow);
}

.icon-btn {
  width: 34px; height: 34px;
  border: none;
  background: var(--surface2);
  color: var(--text-2);
  cursor: pointer;
  font-size: 1.1rem;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px;
  transition: all 0.2s ease;
  border: 1px solid var(--border);
}
.icon-btn:hover { background: var(--surface3); color: var(--module-color); border-color: var(--module-color); }

/* ═════ MAIN CONTENT ═════ */
.main-content {
  flex: 1;
  margin-top: var(--topbar-h);
  padding: 1.25rem 1.25rem 5rem 1.25rem;
  max-width: 640px;
  margin-left: auto;
  margin-right: auto;
  width: 100%;
  overflow-y: auto;
}

/* ═════ CARDS ═════ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  animation: fadeUp 0.35s ease-out;
}

/* ═════ MODULE HOME ═════ */
.module-home { animation: fadeUp 0.4s ease-out; }

.module-home-hero {
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--module-color) 10%, var(--surface)) 0%,
    var(--surface) 100%);
  border: 1px solid color-mix(in srgb, var(--module-color) 30%, var(--border));
  border-radius: var(--radius);
  padding: 1.75rem 1.5rem;
  text-align: center;
  margin-bottom: 1.5rem;
  position: relative;
  overflow: hidden;
}

.module-home-hero::before {
  content: '';
  position: absolute;
  top: -60px; right: -60px;
  width: 180px; height: 180px;
  background: radial-gradient(circle, color-mix(in srgb, var(--module-color) 20%, transparent), transparent 70%);
  pointer-events: none;
}

.module-home-icon { font-size: 3rem; margin-bottom: 0.5rem; }

.module-home-hero h1 {
  font-size: 1.5rem;
  background: linear-gradient(135deg, var(--text) 40%, var(--module-color));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 1rem;
}

.module-home-stats {
  display: flex;
  justify-content: center;
  gap: 2rem;
}

.mh-stat { text-align: center; }

.mh-stat-val {
  display: block;
  font-size: 1.5rem;
  font-weight: 900;
  color: var(--module-color);
  line-height: 1;
  margin-bottom: 0.2rem;
}

.mh-stat-lbl {
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.08em;
}

.home-section-label {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  margin-top: 1.25rem;
}

.section-pill {
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 0.3rem 0.7rem;
  border-radius: 20px;
}

.learn-pill {
  background: color-mix(in srgb, var(--module-color) 15%, transparent);
  color: var(--module-color);
  border: 1px solid color-mix(in srgb, var(--module-color) 35%, transparent);
}

.practice-pill {
  background: color-mix(in srgb, var(--purple) 15%, transparent);
  color: var(--purple);
  border: 1px solid color-mix(in srgb, var(--purple) 35%, transparent);
}

.section-caption {
  font-size: 0.8rem;
  color: var(--muted);
}

/* Learn Mode big card on home */
.home-learn-card {
  background: var(--surface);
  border: 1px solid color-mix(in srgb, var(--module-color) 25%, var(--border));
  border-radius: var(--radius);
  padding: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: all 0.25s ease;
  margin-bottom: 0.75rem;
  position: relative;
  overflow: hidden;
}
.home-learn-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: var(--module-color);
}
.home-learn-card:hover {
  border-color: var(--module-color);
  background: color-mix(in srgb, var(--module-color) 6%, var(--surface));
  transform: translateY(-2px);
  box-shadow: 0 6px 24px color-mix(in srgb, var(--module-color) 18%, transparent);
}
.learn-card-left { display: flex; align-items: flex-start; gap: 1rem; }
.learn-card-icon { font-size: 2rem; flex-shrink: 0; }
.learn-card-title { font-size: 1rem; font-weight: 700; color: var(--text); margin-bottom: 0.2rem; }
.learn-card-desc { font-size: 0.82rem; color: var(--muted); }
.learn-card-arrow { font-size: 1.8rem; color: var(--module-color); opacity: 0.6; transition: all 0.25s ease; }
.home-learn-card:hover .learn-card-arrow { opacity: 1; transform: translateX(3px); }

.learn-su-pills { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-top: 0.6rem; }

.su-pill {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.2rem 0.5rem;
  border-radius: 5px;
  background: var(--surface3);
  color: var(--muted);
  border: 1px solid var(--border);
  text-transform: uppercase;
}
.su-pill.done {
  background: color-mix(in srgb, var(--module-color) 15%, transparent);
  color: var(--module-color);
  border-color: color-mix(in srgb, var(--module-color) 35%, transparent);
}

/* ═════ MODE GRID ═════ */
.mode-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.85rem;
  margin-bottom: 1.5rem;
}
@media (max-width: 480px) {
  .mode-grid { grid-template-columns: 1fr; }
}

.mode-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.25s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
}
.mode-card:hover {
  border-color: var(--module-color);
  background: color-mix(in srgb, var(--module-color) 6%, var(--surface));
  transform: translateY(-4px);
  box-shadow: 0 8px 28px color-mix(in srgb, var(--module-color) 18%, transparent);
}
.mode-card.full-width { grid-column: 1 / -1; flex-direction: row; text-align: left; justify-content: flex-start; padding: 1.1rem 1.25rem; }
.mode-card.full-width .mode-icon { font-size: 1.8rem; }

.mode-icon { font-size: 2.2rem; }
.mode-title { font-size: 0.95rem; font-weight: 700; color: var(--text); margin: 0; }
.mode-desc { font-size: 0.78rem; color: var(--muted); margin: 0; line-height: 1.4; }

.mode-badge {
  display: inline-block;
  background: color-mix(in srgb, var(--module-color) 14%, transparent);
  color: var(--module-color);
  padding: 0.2rem 0.6rem;
  border-radius: 6px;
  font-size: 0.65rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border: 1px solid color-mix(in srgb, var(--module-color) 30%, transparent);
}
.mode-badge.purple {
  background: color-mix(in srgb, var(--purple) 14%, transparent);
  color: var(--purple);
  border-color: color-mix(in srgb, var(--purple) 30%, transparent);
}

/* ═════ PROGRESS & XP ═════ */
.xp-bar {
  height: 8px;
  background: var(--surface3);
  border-radius: 99px;
  overflow: hidden;
  margin: 0.75rem 0;
}
.xp-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--module-color), color-mix(in srgb, var(--module-color) 70%, var(--purple)));
  border-radius: 99px;
  transition: width 0.5s cubic-bezier(0.4,0,0.2,1);
  box-shadow: 0 0 10px color-mix(in srgb, var(--module-color) 50%, transparent);
}

.level-badge {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--module-color) 12%, var(--surface2));
  border: 2.5px solid var(--module-color);
  display: flex; align-items: center; justify-content: center;
  font-weight: 900;
  color: var(--module-color);
  font-size: 1.1rem;
  box-shadow: 0 0 12px color-mix(in srgb, var(--module-color) 30%, transparent);
}

.streak-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: color-mix(in srgb, var(--amber) 12%, var(--surface2));
  border: 1px solid color-mix(in srgb, var(--amber) 30%, transparent);
  color: var(--amber);
  padding: 0.4rem 0.8rem;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 700;
}

/* Weak topics card */
.weak-topics-card {
  background: color-mix(in srgb, var(--red) 8%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--red) 25%, var(--border));
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-top: 1.25rem;
}
.weak-topics-header {
  font-weight: 800;
  color: var(--red);
  font-size: 0.9rem;
  margin-bottom: 0.75rem;
}
.weak-topics-list { display: flex; flex-direction: column; gap: 0.5rem; }
.weak-topic-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.85rem;
}
.weak-topic-concept { flex: 1; color: var(--text-2); }
.weak-topic-su {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  color: var(--muted);
}
.weak-topic-count { color: var(--red); font-weight: 700; font-size: 0.8rem; }

/* Mastery bar */
.mastery-bar {
  height: 4px;
  background: var(--surface3);
  border-radius: 99px;
  overflow: hidden;
  margin-top: 0.5rem;
}
.mastery-fill {
  height: 100%;
  background: var(--module-color);
  border-radius: 99px;
}
.mastery-label { font-size: 0.72rem; color: var(--muted); margin-top: 0.25rem; display: block; }

/* ═════ SU SELECTOR ═════ */
.su-selector { animation: fadeUp 0.35s ease-out; }

.su-selector-header {
  margin-bottom: 1.5rem;
}
.su-selector-header h2 {
  font-size: 1.35rem;
  font-weight: 900;
  margin-bottom: 0.25rem;
}
.su-selector-desc {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0;
}

.su-list { display: flex; flex-direction: column; gap: 0.75rem; }

.su-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  cursor: pointer;
  transition: all 0.22s ease;
  position: relative;
  overflow: hidden;
}
.su-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--module-color);
  opacity: 0;
  transition: opacity 0.22s ease;
}
.su-card:hover {
  border-color: var(--module-color);
  background: color-mix(in srgb, var(--module-color) 5%, var(--surface));
  transform: translateX(3px);
}
.su-card:hover::before { opacity: 1; }

.su-card-icon { font-size: 1.8rem; flex-shrink: 0; }
.su-card-body { flex: 1; min-width: 0; }
.su-card-code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--module-color);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.2rem;
}
.su-card-title { font-size: 0.95rem; font-weight: 700; color: var(--text); margin-bottom: 0.2rem; }
.su-card-desc { font-size: 0.8rem; color: var(--muted); line-height: 1.4; }

.su-card-status { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-top: 0.6rem; }
.su-status-chip {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.2rem 0.5rem;
  border-radius: 5px;
  background: var(--surface3);
  color: var(--muted);
  border: 1px solid var(--border);
}
.su-status-chip.done {
  background: color-mix(in srgb, var(--green) 14%, transparent);
  color: var(--green);
  border-color: color-mix(in srgb, var(--green) 30%, transparent);
}

.su-card-arrow { font-size: 1.4rem; color: var(--muted); transition: all 0.2s ease; }
.su-card:hover .su-card-arrow { color: var(--module-color); transform: translateX(2px); }
.su-done-badge {
  width: 28px; height: 28px;
  background: color-mix(in srgb, var(--green) 14%, transparent);
  color: var(--green);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}

/* ═════ LEARN MODE ═════ */
.learn-view { display: flex; flex-direction: column; gap: 1.25rem; animation: fadeUp 0.35s ease-out; }

.learn-phase-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.phase-unit {
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 500;
}

.phase-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.3rem 0.75rem;
  border-radius: 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.phase-1 {
  background: color-mix(in srgb, var(--blue) 15%, transparent);
  color: var(--blue);
  border: 1px solid color-mix(in srgb, var(--blue) 30%, transparent);
}
.phase-2 {
  background: color-mix(in srgb, var(--purple) 15%, transparent);
  color: var(--purple);
  border: 1px solid color-mix(in srgb, var(--purple) 30%, transparent);
}
.phase-3 {
  background: color-mix(in srgb, var(--amber) 15%, transparent);
  color: var(--amber);
  border: 1px solid color-mix(in srgb, var(--amber) 30%, transparent);
}

.learn-progress {
  height: 6px;
  background: var(--surface3);
  border-radius: 99px;
  overflow: hidden;
}
.learn-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--module-color), color-mix(in srgb, var(--module-color) 60%, var(--purple)));
  border-radius: 99px;
  transition: width 0.4s cubic-bezier(0.4,0,0.2,1);
  box-shadow: 0 0 8px color-mix(in srgb, var(--module-color) 50%, transparent);
}

.learn-section-counter {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  color: var(--muted);
  text-align: right;
}

.learn-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem 1.5rem;
  animation: cardReveal 0.3s ease-out;
  border-top: 3px solid var(--module-color);
}

.learn-section-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: color-mix(in srgb, var(--module-color) 12%, transparent);
  color: var(--module-color);
  padding: 0.35rem 0.8rem;
  border-radius: 8px;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  margin-bottom: 1rem;
  letter-spacing: 0.05em;
  border: 1px solid color-mix(in srgb, var(--module-color) 25%, transparent);
}

.learn-content { margin-bottom: 1.5rem; }
.learn-content h2 { margin-top: 1.25rem; margin-bottom: 0.75rem; color: var(--text); }
.learn-content p { margin-bottom: 0.75rem; line-height: 1.75; color: var(--text-2); }

.learn-content code {
  background: var(--surface3);
  padding: 0.2rem 0.45rem;
  border-radius: 5px;
  color: var(--module-color);
  font-size: 0.88em;
}
.learn-content .code-block {
  background: var(--surface3);
  padding: 1.1rem;
  border-radius: 10px;
  overflow-x: auto;
  margin: 1rem 0;
  border: 1px solid var(--border);
}
.learn-content .code-block code { background: transparent; padding: 0; color: var(--text); }

.learn-nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 0.5rem;
}

/* ═════ FLASHCARDS ═════ */
.fc-status {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.fc-counter {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  color: var(--muted);
}
.fc-got-count {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--green);
  background: color-mix(in srgb, var(--green) 12%, transparent);
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
}

.flashcard-container {
  perspective: 1200px;
  cursor: pointer;
  margin: 0.5rem 0;
  user-select: none;
}
.flashcard {
  position: relative;
  width: 100%;
  height: 320px;
  transition: transform 0.55s cubic-bezier(0.4, 0, 0.2, 1);
  transform-style: preserve-3d;
}
.flashcard.flipped { transform: rotateY(180deg); }

.flashcard-front,
.flashcard-back {
  position: absolute; inset: 0;
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  text-align: center;
  backface-visibility: hidden;
}

.flashcard-front {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 3px solid var(--module-color);
}
.flashcard-back {
  background: linear-gradient(145deg,
    color-mix(in srgb, var(--module-color) 10%, var(--surface)) 0%,
    var(--surface2) 100%);
  border: 1px solid color-mix(in srgb, var(--module-color) 30%, var(--border));
  border-top: 3px solid var(--module-color);
  transform: rotateY(180deg);
}

.fc-tag {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--module-color);
  background: color-mix(in srgb, var(--module-color) 12%, transparent);
  padding: 0.25rem 0.65rem;
  border-radius: 6px;
  margin-bottom: 1rem;
}
.fc-front-text { font-size: 1.3rem; font-weight: 700; color: var(--text); line-height: 1.5; }
.fc-back-text { font-size: 1rem; color: var(--text-2); line-height: 1.7; }

.fc-hint {
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 1.25rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  animation: pulse 2s ease-in-out infinite;
}

.fc-actions {
  display: flex;
  gap: 0.75rem;
  width: 100%;
}
.fc-actions button { flex: 1; }

.phase-complete-nudge {
  background: color-mix(in srgb, var(--green) 10%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--green) 30%, var(--border));
  border-radius: var(--radius);
  padding: 1.25rem;
  text-align: center;
  font-size: 0.95rem;
  color: var(--green);
  font-weight: 600;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ═════ CHECKPOINT ═════ */
.checkpoint-block {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px dashed var(--border2);
}
.checkpoint-prompt {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 1rem;
  line-height: 1.5;
}
.checkpoint-choices { display: flex; flex-direction: column; gap: 0.6rem; }

.choice-btn {
  width: 100%;
  padding: 0.85rem 1rem;
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  color: var(--text-2);
  cursor: pointer;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  transition: all 0.18s ease;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
}
.choice-btn:not(:disabled):hover {
  background: var(--surface3);
  border-color: var(--module-color);
  color: var(--text);
}
.choice-btn.correct {
  background: color-mix(in srgb, var(--green) 12%, transparent);
  border-color: var(--green);
  color: var(--green);
  font-weight: 700;
}
.choice-btn.wrong {
  background: color-mix(in srgb, var(--red) 10%, transparent);
  border-color: var(--red);
  color: var(--red);
  animation: shake 0.4s ease;
}
.choice-btn.dim {
  opacity: 0.4;
}

.choice-letter {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: var(--surface3);
  display: flex; align-items: center; justify-content: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  font-weight: 700;
  flex-shrink: 0;
  border: 1px solid var(--border);
}
.choice-btn.correct .choice-letter {
  background: color-mix(in srgb, var(--green) 20%, transparent);
  border-color: var(--green);
}
.choice-btn.wrong .choice-letter {
  background: color-mix(in srgb, var(--red) 20%, transparent);
  border-color: var(--red);
}
.choice-text { flex: 1; line-height: 1.4; }

.checkpoint-feedback {
  margin-top: 1rem;
  padding: 0.9rem 1rem;
  border-radius: 10px;
  font-size: 0.88rem;
  font-weight: 600;
  animation: bounceIn 0.4s ease;
}
.checkpoint-feedback p { margin: 0.4rem 0 0 0; font-weight: 400; }
.checkpoint-feedback.correct {
  background: color-mix(in srgb, var(--green) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--green) 30%, transparent);
  color: var(--green);
}
.checkpoint-feedback.wrong {
  background: color-mix(in srgb, var(--red) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--red) 30%, transparent);
  color: var(--red);
}

/* ═════ QUIZ ENGINE ═════ */
.quiz-view { display: flex; flex-direction: column; gap: 1.25rem; animation: fadeUp 0.35s ease-out; }

.quiz-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}
.quiz-counter {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  color: var(--muted);
}

.quiz-progress {
  height: 6px;
  background: var(--surface3);
  border-radius: 99px;
  overflow: hidden;
}
.quiz-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--module-color), color-mix(in srgb, var(--module-color) 60%, var(--purple)));
  border-radius: 99px;
  transition: width 0.4s ease;
  box-shadow: 0 0 8px color-mix(in srgb, var(--module-color) 50%, transparent);
}

.quiz-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  border-top: 3px solid var(--module-color);
  animation: cardReveal 0.3s ease-out;
}

.quiz-question {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 1.5rem;
  line-height: 1.6;
  color: var(--text);
}

.quiz-choices { display: flex; flex-direction: column; gap: 0.6rem; }

.quiz-choice {
  width: 100%;
  padding: 0.9rem 1rem;
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  color: var(--text-2);
  cursor: pointer;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  transition: all 0.18s ease;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
}
.quiz-choice:not(:disabled):hover {
  border-color: var(--module-color);
  background: color-mix(in srgb, var(--module-color) 6%, var(--surface2));
  color: var(--text);
}
.quiz-choice.selected {
  border-color: var(--module-color);
  background: color-mix(in srgb, var(--module-color) 10%, transparent);
  color: var(--module-color);
  font-weight: 600;
}
.quiz-choice.correct {
  border-color: var(--green);
  background: color-mix(in srgb, var(--green) 10%, transparent);
  color: var(--green);
  font-weight: 700;
}
.quiz-choice.wrong {
  border-color: var(--red);
  background: color-mix(in srgb, var(--red) 8%, transparent);
  color: var(--red);
  animation: shake 0.4s ease;
}
.quiz-choice.dim { opacity: 0.4; }

.quiz-choice-letter {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: var(--surface3);
  display: flex; align-items: center; justify-content: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  font-weight: 700;
  flex-shrink: 0;
  border: 1px solid var(--border);
}

.quiz-feedback {
  margin-top: 1rem;
  padding: 1rem;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.9rem;
  animation: bounceIn 0.35s ease;
}
.quiz-feedback p { margin: 0.35rem 0 0 0; font-weight: 400; color: inherit; opacity: 0.85; }
.quiz-feedback.correct {
  background: color-mix(in srgb, var(--green) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--green) 30%, transparent);
  color: var(--green);
}
.quiz-feedback.wrong {
  background: color-mix(in srgb, var(--red) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--red) 30%, transparent);
  color: var(--red);
}

.quiz-nav {
  display: flex;
  justify-content: flex-end;
  margin-top: 1rem;
}

/* Quiz Results */
.quiz-results { animation: fadeUp 0.4s ease-out; display: flex; flex-direction: column; gap: 1.25rem; }

.quiz-results-hero {
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--module-color) 10%, var(--surface)) 0%,
    var(--surface) 100%);
  border: 1px solid color-mix(in srgb, var(--module-color) 30%, var(--border));
  border-radius: var(--radius);
  padding: 2rem 1.5rem;
  text-align: center;
}

.results-score {
  font-size: 4rem;
  font-weight: 900;
  color: var(--module-color);
  line-height: 1;
  text-shadow: 0 0 30px color-mix(in srgb, var(--module-color) 50%, transparent);
}
.results-label {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 0.5rem;
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.08em;
}
.results-xp {
  margin-top: 1rem;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: color-mix(in srgb, var(--amber) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--amber) 30%, transparent);
  color: var(--amber);
  padding: 0.4rem 0.9rem;
  border-radius: 8px;
  font-weight: 800;
  font-size: 0.9rem;
}

/* ═════ ASSESSMENT ═════ */
.ai-notice {
  padding: 0.75rem 1rem;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 600;
  background: color-mix(in srgb, var(--amber) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--amber) 25%, transparent);
  color: var(--amber);
}
.ai-notice.ai-active {
  background: color-mix(in srgb, var(--purple) 10%, transparent);
  border-color: color-mix(in srgb, var(--purple) 25%, transparent);
  color: var(--purple);
}

.assessment-questions { display: flex; flex-direction: column; gap: 1.25rem; }

.assess-q {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  animation: cardReveal 0.3s ease-out;
}
.assess-q-num {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--module-color);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.6rem;
}
.assess-q-prompt {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 1rem;
  line-height: 1.55;
}

.assessment-answer {
  width: 100%;
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  padding: 0.9rem;
  min-height: 100px;
  resize: vertical;
  transition: border-color 0.2s ease;
  line-height: 1.6;
}
.assessment-answer:focus {
  outline: none;
  border-color: var(--module-color);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--module-color) 15%, transparent);
}
.assessment-answer:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.marking-result {
  margin-top: 1rem;
  padding: 1rem;
  background: var(--surface2);
  border-radius: 10px;
  border: 1px solid var(--border);
  animation: bounceIn 0.4s ease;
}
.marking-score {
  font-size: 1.2rem;
  font-weight: 900;
  color: var(--module-color);
  margin-bottom: 0.5rem;
}
.marking-feedback { font-size: 0.88rem; color: var(--text-2); line-height: 1.6; }

.model-answer-details {
  margin-top: 0.75rem;
  border-top: 1px solid var(--border);
  padding-top: 0.75rem;
}
.model-answer-details summary {
  font-size: 0.82rem;
  color: var(--muted);
  cursor: pointer;
  font-weight: 600;
  user-select: none;
}
.model-answer-details summary:hover { color: var(--module-color); }
.model-answer-block {
  margin-top: 0.75rem;
  padding: 0.9rem;
  background: var(--surface3);
  border-radius: 8px;
  font-size: 0.85rem;
  color: var(--text-2);
  line-height: 1.65;
  border: 1px solid var(--border);
}
.model-answer-block p { margin-bottom: 0.5rem; }

.no-ai .marking-score-label {
  font-weight: 800;
  color: var(--muted);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.5rem;
}
.no-ai .key-points {
  margin-top: 0.75rem;
  font-size: 0.85rem;
  color: var(--text-2);
}
.no-ai .key-points ul { margin: 0.4rem 0 0 0; padding-left: 1.25rem; }
.no-ai .key-points li { margin-bottom: 0.35rem; }

.assess-complete-banner {
  text-align: center;
  padding: 2rem 1.5rem;
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--module-color) 10%, var(--surface)) 0%,
    var(--surface) 100%);
  border: 1px solid color-mix(in srgb, var(--module-color) 30%, var(--border));
  border-radius: var(--radius);
  margin-top: 1.25rem;
  animation: bounceIn 0.5s ease;
}
.assess-complete-icon { font-size: 3rem; margin-bottom: 0.75rem; }
.assess-complete-banner h3 { font-size: 1.4rem; font-weight: 900; margin-bottom: 0.5rem; }

/* ═════ MIXED RUN ═════ */
.mixed-view { display: flex; flex-direction: column; gap: 1.25rem; animation: fadeUp 0.35s ease-out; }

.mixed-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.85rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--module-color);
}
.mixed-timer {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--module-color);
}
.mixed-timer.warning { color: var(--red); animation: pulse 1s ease-in-out infinite; }
.mixed-progress-text {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  color: var(--muted);
}

.learn-complete, .mixed-complete {
  text-align: center;
  padding: 3rem 1.5rem;
  animation: bounceIn 0.5s ease;
}
.learn-complete-icon { font-size: 4rem; margin-bottom: 1rem; }
.learn-complete h2, .mixed-complete h2 { font-size: 1.6rem; font-weight: 900; margin-bottom: 0.75rem; }

/* ═════ LEADERBOARD ═════ */
.leaderboard-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  display: none;
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  backdrop-filter: blur(4px);
  animation: fadeIn 0.25s ease;
}
.leaderboard-overlay.open { display: flex; }

.leaderboard-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 520px;
  max-height: 80vh;
  overflow-y: auto;
  padding: 1.5rem 1.25rem;
  animation: scaleIn 0.25s ease;
}

.lb-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}
.lb-header h2 { font-size: 1.2rem; font-weight: 900; margin: 0; }

.lb-filters {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}
.lb-filter-btn {
  padding: 0.4rem 0.85rem;
  border: 1.5px solid var(--border);
  background: var(--surface2);
  color: var(--text-2);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 600;
  font-family: inherit;
  transition: all 0.15s ease;
}
.lb-filter-btn:hover { border-color: var(--module-color); color: var(--text); }
.lb-filter-btn.active {
  border-color: var(--module-color);
  background: color-mix(in srgb, var(--module-color) 12%, transparent);
  color: var(--module-color);
}

.lb-entry {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 0.75rem;
  border-radius: 10px;
  transition: all 0.15s ease;
}
.lb-entry:hover { background: var(--surface2); }
.lb-rank {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  width: 28px;
  text-align: center;
  font-size: 0.9rem;
  color: var(--muted);
}
.lb-rank.gold   { color: #ffd700; font-size: 1.2rem; }
.lb-rank.silver { color: #c0c0c0; font-size: 1.1rem; }
.lb-rank.bronze { color: #cd7f32; font-size: 1rem; }

.lb-name { flex: 1; font-weight: 600; font-size: 0.9rem; }
.lb-score {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  color: var(--module-color);
  font-weight: 700;
}
.lb-module {
  font-size: 0.72rem;
  color: var(--muted);
  font-family: 'JetBrains Mono', monospace;
  background: var(--surface3);
  padding: 0.2rem 0.5rem;
  border-radius: 5px;
}
.lb-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 0.5rem;
  border-radius: 10px;
  transition: background 0.15s ease;
}
.lb-row:hover { background: var(--surface2); }
.lb-info { flex: 1; min-width: 0; }
.lb-score-col { text-align: right; flex-shrink: 0; }
.lb-detail {
  font-size: 0.7rem;
  color: var(--muted);
  font-family: 'JetBrains Mono', monospace;
  margin-top: 0.1rem;
}
.lb-loading, .lb-empty {
  text-align: center;
  padding: 2rem;
  color: var(--muted);
  font-size: 0.9rem;
}

/* ═════ SETTINGS OVERLAY ═════ */
.settings-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  display: none;
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  backdrop-filter: blur(4px);
}
.settings-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 420px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 1.5rem;
  animation: scaleIn 0.25s ease;
}
.settings-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}
.settings-header h2 { font-size: 1.15rem; font-weight: 900; margin: 0; }

.settings-section { margin-bottom: 1.5rem; }
.settings-label {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 0.6rem;
}
.settings-input {
  width: 100%;
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  padding: 0.8rem;
  transition: border-color 0.2s ease;
}
.settings-input:focus {
  outline: none;
  border-color: var(--module-color);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--module-color) 12%, transparent);
}
.settings-input[type="password"] { font-family: 'JetBrains Mono', monospace; letter-spacing: 0.15em; }

.settings-status {
  font-size: 0.78rem;
  margin-top: 0.5rem;
  font-weight: 600;
}
.settings-status.success { color: var(--green); }
.settings-status.error   { color: var(--red); }

.settings-hint {
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 0.75rem;
  line-height: 1.4;
}

.settings-actions {
  display: flex;
  gap: 0.6rem;
  margin-top: 0.75rem;
  flex-wrap: wrap;
}

/* ═════ NAME MODAL ═════ */
.name-modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.75);
  display: none;
  z-index: 300;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  backdrop-filter: blur(6px);
}
.name-modal.open { display: flex; }
.name-modal-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  width: 100%;
  max-width: 360px;
  text-align: center;
  animation: bounceIn 0.4s ease;
}
.name-modal-panel h3 { font-size: 1.2rem; font-weight: 900; margin-bottom: 0.5rem; }
.name-modal-panel p { color: var(--muted); font-size: 0.85rem; margin-bottom: 1.25rem; }

/* ═════ TOASTS ═════ */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 999;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  pointer-events: none;
}
.toast {
  padding: 0.75rem 1.25rem;
  border-radius: 12px;
  font-size: 0.88rem;
  font-weight: 600;
  white-space: nowrap;
  opacity: 0;
  transform: translateY(8px) scale(0.95);
  transition: all 0.25s cubic-bezier(0.4,0,0.2,1);
  backdrop-filter: blur(12px);
  max-width: 300px;
  text-align: center;
  border: 1px solid transparent;
}
.toast.show { opacity: 1; transform: translateY(0) scale(1); }
.toast-info {
  background: color-mix(in srgb, var(--module-color) 12%, rgba(15,15,30,0.9));
  color: var(--module-color);
  border-color: color-mix(in srgb, var(--module-color) 30%, transparent);
}
.toast-success {
  background: color-mix(in srgb, var(--green) 12%, rgba(15,15,30,0.9));
  color: var(--green);
  border-color: color-mix(in srgb, var(--green) 30%, transparent);
}
.toast-error {
  background: color-mix(in srgb, var(--red) 12%, rgba(15,15,30,0.9));
  color: var(--red);
  border-color: color-mix(in srgb, var(--red) 30%, transparent);
}
.toast-warning {
  background: color-mix(in srgb, var(--amber) 12%, rgba(15,15,30,0.9));
  color: var(--amber);
  border-color: color-mix(in srgb, var(--amber) 30%, transparent);
}

/* ═════ PLACEHOLDER PAGE ═════ */
.placeholder-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  text-align: center;
  gap: 0.75rem;
  animation: fadeUp 0.4s ease-out;
}
.placeholder-icon { font-size: 3.5rem; }
.placeholder-title { font-size: 1.25rem; font-weight: 800; color: var(--text); }
.placeholder-desc { font-size: 0.88rem; color: var(--muted); max-width: 320px; line-height: 1.6; }

/* ═════ LOADING ═════ */
.loading-spinner {
  width: 24px; height: 24px;
  border: 2.5px solid var(--border2);
  border-top-color: var(--module-color);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* ═════ INLINE CODE ═════ */
.inline-code {
  background: var(--surface3);
  padding: 0.15rem 0.4rem;
  border-radius: 5px;
  color: var(--module-color);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.88em;
  border: 1px solid var(--border);
}
.code-block {
  background: var(--surface3);
  padding: 1rem;
  border-radius: 10px;
  overflow-x: auto;
  margin: 1rem 0;
  border: 1px solid var(--border);
}

/* ═════ UTILITY ═════ */
.visually-hidden { position: absolute; clip: rect(0,0,0,0); overflow: hidden; }
.text-center { text-align: center; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.gap-1 { gap: 0.5rem; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }


/* ========================
   EXAM PILL
   ======================== */
.exam-pill { background: linear-gradient(135deg, #f59e0b, #d97706); color: #fff; }

/* ========================
   SETTINGS DATA ACTIONS
   ======================== */
.settings-data-actions {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 0.75rem;
}
.settings-data-btn { width: 100%; justify-content: center; }

/* ========================
   CHOICE BUTTON SELECTED STATE
   ======================== */
.choice-btn.selected {
  border-color: var(--module-color) !important;
  background: color-mix(in srgb, var(--module-color) 15%, transparent) !important;
  color: var(--text) !important;
}

/* ========================
   PRACTICE ENGINE
   ======================== */
.practice-selector {
  max-width: 760px;
  margin: 0 auto;
  padding: 1rem 1rem 4rem;
}
.practice-paper-header {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}
.practice-paper-info h2 { margin: 0 0 0.25rem; font-size: 1.15rem; }
.practice-paper-info p { margin: 0; font-size: 0.82rem; color: var(--muted); }
.practice-qtype-icon { font-size: 1.1rem; }

.practice-view {
  max-width: 760px;
  margin: 0 auto;
  padding: 1rem 1rem 5rem;
}
.practice-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  gap: 0.5rem;
}
.practice-nav-counter {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--muted);
}
.practice-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1rem;
}
.practice-qlabel {
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.practice-marks-badge {
  background: var(--surface3);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 0.1rem 0.5rem;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--module-color);
  text-transform: none;
  letter-spacing: 0;
}
.practice-qtext {
  font-size: 0.97rem;
  line-height: 1.75;
  color: var(--text);
  margin-bottom: 1rem;
}
.practice-subitems {
  margin: 0 0 1rem 1.25rem;
  padding: 0;
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--text);
}
.practice-subitems li { margin-bottom: 0.3rem; }

.practice-choices { flex-direction: column; gap: 0.5rem; }
.practice-blank-input { margin-top: 0.5rem; }
.practice-textarea { margin-top: 0.5rem; width: 100%; min-height: 160px; resize: vertical; }

.practice-submit-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.ai-hint { font-size: 0.78rem; color: var(--muted); }

.practice-result {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin-top: 1rem;
}
.practice-result-banner {
  font-weight: 800;
  font-size: 1.05rem;
  margin-bottom: 0.75rem;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
}
.practice-result-banner.correct { background: rgba(16,185,129,0.15); color: #10b981; }
.practice-result-banner.wrong { background: rgba(239,68,68,0.15); color: #ef4444; }

.practice-explanation {
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--muted);
  margin-bottom: 1rem;
}
.practice-nav-btns {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}

/* ========================
   CASE STUDY ACCORDION
   ======================== */
.case-study-accordion {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1rem;
}
.cs-summary {
  padding: 0.85rem 1.25rem;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--module-color);
  list-style: none;
  user-select: none;
}
.cs-summary::-webkit-details-marker { display: none; }
.case-study-body {
  padding: 0 1.25rem 1.25rem;
  font-size: 0.88rem;
  line-height: 1.75;
  color: var(--muted);
  border-top: 1px solid var(--border);
  white-space: pre-wrap;
  font-family: inherit;
}

/* ========================
   EXAM FIGURES
   ======================== */
.exam-figures {
  margin-bottom: 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}
.exam-figure-img {
  max-width: 100%;
  border-radius: 8px;
  border: 1px solid var(--border);
  cursor: zoom-in;
  transition: max-width 0.2s;
}
.exam-figure-img.exam-figure-expanded {
  max-width: 100%;
  width: 100%;
  cursor: zoom-out;
}
.figure-hint {
  font-size: 0.72rem;
  color: var(--muted);
  text-align: center;
  margin: 0;
}

/* ========================
   EXAM ENGINE (LEGACY)
   ======================== */
.exam-full-view {
  max-width: 820px;
  margin: 0 auto;
  padding-bottom: 6rem;
}
.exam-sticky-bar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 0.6rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}
.exam-paper-title { font-size: 0.85rem; font-weight: 700; color: var(--text); }
.exam-live-timer {
  font-family: "JetBrains Mono", monospace;
  font-size: 1rem;
  font-weight: 700;
  color: #10b981;
  letter-spacing: 0.05em;
  transition: color 0.3s;
}
.exam-live-timer.warn { color: #f59e0b; }
.exam-live-timer.danger { color: #ef4444; animation: timerPulse 1s ease-in-out infinite; }
@keyframes timerPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

.exam-body { padding: 1rem; }
.exam-question-block {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1.25rem;
  overflow: hidden;
}
.exam-q-header {
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.exam-q-label { font-weight: 800; font-size: 0.9rem; color: var(--text); }
.exam-q-marks {
  font-size: 0.8rem;
  background: var(--surface3);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 0.15rem 0.6rem;
  color: var(--module-color);
  font-weight: 700;
}
.exam-q-body {
  padding: 1rem 1.25rem;
  font-size: 0.93rem;
  line-height: 1.75;
  color: var(--text);
}
.exam-subq {
  margin-top: 0.75rem;
  padding: 0.85rem 1rem;
  background: var(--surface3);
  border-radius: 8px;
  border: 1px solid var(--border);
}
.exam-subq-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--module-color);
  margin-bottom: 0.4rem;
}
.exam-subq-text {
  font-size: 0.9rem;
  line-height: 1.65;
  color: var(--text);
  margin-bottom: 0.6rem;
}
.exam-textarea {
  width: 100%;
  min-height: 100px;
  resize: vertical;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.88rem;
  padding: 0.65rem 0.85rem;
  font-family: inherit;
  line-height: 1.6;
}
.exam-textarea:focus { outline: none; border-color: var(--module-color); }

.exam-submit-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg);
  border-top: 1px solid var(--border);
  padding: 0.85rem 1.25rem;
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  z-index: 60;
}

/* Marking screen */
.exam-marking-screen {
  max-width: 700px;
  margin: 2rem auto;
  padding: 1rem;
  text-align: center;
}
.marking-progress-list {
  text-align: left;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin: 1.5rem 0;
  list-style: none;
}
.marking-progress-list li {
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.marking-progress-list li:last-child { border-bottom: none; }
.marking-progress-list li.done { color: #10b981; }
.marking-progress-list li.active { color: var(--module-color); font-weight: 600; }

/* Exam results / review */
.exam-review-block {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1.25rem;
  overflow: hidden;
}
.exam-review-header {
  padding: 0.85rem 1.25rem;
  background: var(--surface3);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
  font-size: 0.9rem;
}
.exam-review-score {
  font-size: 0.82rem;
  color: var(--module-color);
  font-weight: 800;
}
.exam-review-body { padding: 1rem 1.25rem; }
.exam-review-feedback {
  font-size: 0.88rem;
  line-height: 1.7;
  color: var(--muted);
  margin-top: 0.75rem;
}

.marking-result { padding: 1rem; border-radius: 10px; margin-bottom: 1rem; }
.marking-result.good { background: rgba(16,185,129,0.1); border: 1px solid rgba(16,185,129,0.3); }
.marking-result.ok { background: rgba(245,158,11,0.1); border: 1px solid rgba(245,158,11,0.3); }
.marking-result.low { background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.3); }
.marking-score-header { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.65rem; }
.marking-score-label { font-weight: 800; font-size: 0.95rem; }
.marking-score-bar { flex: 1; height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.marking-score-fill { height: 100%; background: var(--module-color); border-radius: 3px; }
.marking-feedback { font-size: 0.9rem; line-height: 1.7; color: var(--muted); }

.model-answer-block {
  font-size: 0.88rem;
  line-height: 1.75;
  color: var(--muted);
  padding-top: 0.75rem;
}
.key-points-list {
  margin-top: 0.75rem;
  font-size: 0.85rem;
  color: var(--muted);
}
.key-points-list ul { margin: 0.4rem 0 0 1.2rem; padding: 0; }
.key-points-list li { margin-bottom: 0.25rem; }

/* ========================
   EMPTY STATE
   ======================== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1rem;
  text-align: center;
}
.empty-state-desc { font-size: 0.9rem; color: var(--muted); }


/* ============================================================
   CHEATSHEET OVERLAY
   ============================================================ */

/* FAB button */
.cs-fab {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: 900;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 50%;
  border: none;
  background: var(--module-color, #00d4ff);
  color: #000;
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  transition: transform 0.15s, box-shadow 0.15s, opacity 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cs-fab:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 24px rgba(0,0,0,0.5);
}
.cs-fab[hidden] { display: none !important; }

/* Overlay backdrop */
.cs-overlay {
  position: fixed;
  inset: 0;
  z-index: 950;
  background: rgba(0,0,0,0.65);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  animation: cs-fade-in 0.2s ease;
}
.cs-overlay[hidden] { display: none !important; }

@keyframes cs-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* Slide-up panel */
.cs-panel {
  background: var(--bg-card, #12121e);
  border-radius: 1.25rem 1.25rem 0 0;
  width: 100%;
  max-width: 1100px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  animation: cs-slide-up 0.25s cubic-bezier(0.34,1.2,0.64,1);
  overflow: hidden;
}

@keyframes cs-slide-up {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

/* Panel header */
.cs-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem 0.75rem;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
}
.cs-module-label {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--cs-color, #00d4ff);
}
.cs-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary, #fff);
}
.cs-close-btn {
  background: none;
  border: none;
  color: var(--text-muted, #888);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}
.cs-close-btn:hover {
  color: var(--text-primary, #fff);
  background: rgba(255,255,255,0.07);
}

/* Scrollable body */
.cs-body {
  overflow-y: auto;
  padding: 1rem 1.25rem 1.5rem;
  flex: 1;
  -webkit-overflow-scrolling: touch;
}

/* Two-column grid (2 A4 "pages") */
.cs-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  align-items: start;
}
@media (max-width: 640px) {
  .cs-cols { grid-template-columns: 1fr; }
}

/* Column divider */
.cs-col {
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 0.75rem;
  padding: 0.85rem;
  background: rgba(255,255,255,0.02);
}

/* Section block */
.cs-section {
  margin-bottom: 0.85rem;
}
.cs-section:last-child { margin-bottom: 0; }

/* Section heading */
.cs-sh {
  font-size: 0.65rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--cs-color, #00d4ff);
  margin-bottom: 0.35rem;
  padding-bottom: 0.2rem;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

/* Dense table */
.cs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.72rem;
  margin-top: 0.25rem;
}
.cs-table th {
  text-align: left;
  font-weight: 700;
  color: var(--text-muted, #888);
  padding: 0.15rem 0.4rem;
  border-bottom: 1px solid rgba(255,255,255,0.07);
}
.cs-table td {
  padding: 0.15rem 0.4rem;
  color: var(--text-primary, #fff);
  vertical-align: top;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.cs-table tr:last-child td { border-bottom: none; }
.cs-table .yes { color: #10b981; font-weight: 700; }
.cs-table .no  { color: #ef4444; font-weight: 700; }

/* Formula highlight */
.cs-formula {
  background: rgba(255,255,255,0.05);
  border-left: 2px solid var(--cs-color, #00d4ff);
  padding: 0.3rem 0.5rem;
  border-radius: 0 4px 4px 0;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  color: var(--text-primary, #fff);
  margin: 0.25rem 0;
}

/* Bullet list */
.cs-list {
  margin: 0.2rem 0 0 0;
  padding-left: 1.1rem;
  font-size: 0.72rem;
  color: var(--text-primary, #fff);
  line-height: 1.5;
}
.cs-list li { margin-bottom: 0.1rem; }

/* Code block */
.cs-pre {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.62rem;
  background: rgba(0,0,0,0.35);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 6px;
  padding: 0.5rem 0.6rem;
  margin: 0.25rem 0;
  white-space: pre;
  overflow-x: auto;
  color: #cdd6f4;
  line-height: 1.5;
}

/* Note / tip */
.cs-note {
  font-size: 0.68rem;
  color: var(--text-muted, #888);
  font-style: italic;
  margin-top: 0.2rem;
}

/* Chips row */
.cs-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.25rem;
}
.cs-chip {
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 20px;
  padding: 0.1rem 0.5rem;
  font-size: 0.65rem;
  color: var(--text-primary, #eee);
  white-space: nowrap;
}
.cs-chip.cs-target {
  background: rgba(255,215,0,0.12);
  border-color: rgba(255,215,0,0.3);
  color: gold;
}

/* yes / no text helpers */
.yes { color: #10b981; font-weight: 700; }
.no  { color: #ef4444; font-weight: 700; }


/* ============================================================
   MARKDOWN TABLE RENDERING (.md-table)
   Used in lesson content, model answers, AI feedback
   ============================================================ */

.md-table-wrap {
  overflow-x: auto;
  margin: 0.75rem 0;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.08);
}

.md-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  min-width: 420px;
}

.md-table thead {
  background: rgba(255,255,255,0.05);
}

.md-table th {
  text-align: left;
  font-weight: 700;
  color: var(--text-primary, #fff);
  padding: 0.55rem 0.75rem;
  border-bottom: 2px solid rgba(255,255,255,0.1);
  white-space: nowrap;
}

.md-table td {
  padding: 0.45rem 0.75rem;
  color: var(--text-secondary, #ccc);
  vertical-align: top;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.md-table tbody tr:last-child td {
  border-bottom: none;
}

.md-table tbody tr:hover {
  background: rgba(255,255,255,0.03);
}

@media (max-width: 480px) {
  .md-table { font-size: 0.75rem; }
  .md-table th,
  .md-table td { padding: 0.4rem 0.5rem; }
}

/* ═════ APP LOADER ═════ */
.app-loader {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 1.5rem;
  background: var(--bg);
}
.loader-brand { display: flex; align-items: center; gap: 0.5rem; }
.loader-logo {
  font-size: 1.6rem; font-weight: 800; letter-spacing: -0.5px;
  color: var(--text);
}
.loader-logo span { color: var(--accent); }
.loader-spinner {
  width: 28px; height: 28px;
  border: 3px solid rgba(255,255,255,0.1);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.app-loader.hidden { display: none; }

/* ═════ AUTH GATE ═════ */
.gate-overlay {
  position: fixed; inset: 0; z-index: 9000;
  display: flex; align-items: center; justify-content: center;
  overflow-y: auto;
  padding: 1.5rem;
  background:
    radial-gradient(ellipse 60% 40% at 20% 20%, rgba(0,212,255,.06) 0%, transparent 60%),
    radial-gradient(ellipse 50% 40% at 80% 80%, rgba(168,85,247,.06) 0%, transparent 60%),
    var(--bg);
}
.gate-overlay.hidden { display: none; }
.gate-card {
  width: 100%; max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2rem 1.75rem;
  margin: auto;
}
.gate-wordmark {
  font-size: 1.5rem; font-weight: 800; letter-spacing: -0.5px;
  color: var(--text);
}
.gate-wordmark span {
  background: linear-gradient(135deg, #00d4ff 0%, #a855f7 50%, #f59e0b 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.gate-tagline { font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; }
.gate-logo { margin-bottom: 1.5rem; }
.gate-auth-tabs {
  display: flex; gap: 0.5rem;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.75rem;
}
.gate-tab {
  flex: 1; padding: 0.45rem; border-radius: 8px;
  font-size: 0.85rem; font-weight: 600;
  background: transparent; border: none;
  color: var(--text-muted); cursor: pointer;
  transition: color 0.15s, background 0.15s;
}
.gate-tab.active { background: var(--accent); color: #fff; }
.gate-field-label { font-size: 0.75rem; font-weight: 600; color: var(--text-muted); margin-bottom: 5px; text-transform: uppercase; letter-spacing: 0.5px; }
.gate-input {
  width: 100%; padding: 0.6rem 0.75rem;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: 0.9rem;
  outline: none; box-sizing: border-box;
  transition: border-color 0.15s;
}
.gate-input:focus { border-color: var(--accent); }
.gate-hint { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.75rem; text-align: center; }
.gate-hint a { color: var(--accent); text-decoration: none; }
.gate-sub { font-size: 0.85rem; color: var(--text-secondary); text-align: center; margin: 0.5rem 0 1rem; }
.gate-sent-icon { font-size: 2rem; text-align: center; margin-bottom: 0.5rem; }
.pw-strength { margin-top: 0.4rem; display: flex; align-items: center; gap: 0.5rem; }
.pw-track { flex: 1; height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; }
.pw-bar { height: 100%; border-radius: 2px; transition: width 0.2s; width: 0; }
.pw-bar-red   { background: #ef4444; }
.pw-bar-amber { background: #f59e0b; }
.pw-bar-green { background: #22c55e; }
.pw-label { font-size: 0.7rem; font-weight: 600; white-space: nowrap; }
.pw-label-red   { color: #ef4444; }
.pw-label-amber { color: #f59e0b; }
.pw-label-green { color: #22c55e; }

/* ═════ HUB MENU BUTTON ═════ */
.hub-inner { position: relative; }
.hub-wordmark { text-align: center; margin-bottom: 2.5rem; }
.hub-menu-btn {
  position: absolute; top: 0; right: 0;
  width: 38px; height: 38px; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); font-size: 1.1rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, border-color 0.15s;
  z-index: 10;
}
.hub-menu-btn:hover { background: var(--surface-hover, var(--border)); }
.hub-menu-btn.hidden { display: none; }

/* ═════ HUB ACCOUNT DROPDOWN ═════ */
.hub-account-panel {
  position: absolute; top: 46px; right: 0; z-index: 200;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 1rem;
  min-width: 220px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
.hub-account-panel.hidden { display: none; }
.hub-account-user { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.75rem; }
.hub-account-avatar {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, #00d4ff, #a855f7);
  color: #fff; font-size: 0.9rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.hub-account-name { font-size: 0.88rem; font-weight: 700; color: var(--text); }
.hub-account-label { font-size: 0.65rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.4px; margin-top: 1px; }
.hub-account-divider { height: 1px; background: var(--border); margin-bottom: 0.75rem; }
.hub-account-signout {
  width: 100%; padding: 0.5rem; border-radius: 8px;
  background: none; border: 1px solid var(--border);
  color: var(--text-muted); font-size: 0.82rem; font-weight: 600;
  cursor: pointer; transition: color 0.15s, background 0.15s;
}
.hub-account-signout:hover { color: var(--text); background: var(--bg); }

/* ═════ TOPBAR USER CHIP ═════ */
.topbar-user-chip {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent); color: #fff;
  font-size: 0.7rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0;
}
.topbar-user-chip:empty { display: none; }

/* ═════ SETTINGS ACCOUNT CARD ═════ */
.settings-account-card {
  display: flex; align-items: center; gap: 0.75rem;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 10px; padding: 0.75rem 1rem;
}
.settings-user-avatar {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  background: var(--accent); color: #fff;
  font-size: 0.9rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.settings-user-info { flex: 1; min-width: 0; }
.settings-user-displayname { font-size: 0.9rem; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.settings-user-email { font-size: 0.75rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 1px; }
.settings-signout-btn { flex-shrink: 0; font-size: 0.78rem; padding: 0.3rem 0.65rem; }

/* ═════ HIDDEN UTILITY ═════ */
.hidden { display: none !important; }

/* ── TTS (Text-to-Speech) ─────────────────────────────────────────── */
/* ── TTS Button ─────────────────────────────────────────────────── */
.tts-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  padding: 3px 8px;
  line-height: 1;
  transition: all 0.15s;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 30px;
  gap: 2px;
}
.tts-btn:hover:not(:disabled) { background: var(--surface-hover); color: var(--text); }
.tts-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Loading state — dim pulse on the whole button */
.tts-btn[data-tts-state="loading"] {
  animation: tts-loading-pulse 1s ease-in-out infinite;
  opacity: 0.7;
}
@keyframes tts-loading-pulse { 0%,100%{opacity:0.7} 50%{opacity:0.35} }

/* Speaking state — accent colour */
.tts-btn[data-tts-state="speaking"],
.tts-btn.tts-speaking {
  color: var(--accent);
  border-color: var(--accent);
}

/* Soundbar elements — hidden by default, visible when speaking */
.tts-glyph { display: flex; }
.tts-bars  { display: none; align-items: flex-end; gap: 2px; height: 16px; }
.tts-bars b {
  display: block;
  width: 3px;
  border-radius: 2px;
  background: currentColor;
  min-height: 3px;
  animation: tts-wave 0.7s ease-in-out infinite alternate;
}
.tts-bars b:nth-child(1) { animation-delay: 0s;    animation-duration: 0.6s; }
.tts-bars b:nth-child(2) { animation-delay: 0.18s; animation-duration: 0.8s; }
.tts-bars b:nth-child(3) { animation-delay: 0.34s; animation-duration: 0.5s; }
@keyframes tts-wave {
  from { height: 3px;  }
  to   { height: 15px; }
}

/* Toggle glyph↔bars based on data-tts-state */
.tts-btn[data-tts-state="speaking"] .tts-glyph { display: none; }
.tts-btn[data-tts-state="speaking"] .tts-bars  { display: flex; }
.learn-section-badge {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}
.tts-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  cursor: pointer;
  padding: 0.5rem 0;
  margin-top: 0.5rem;
}
.tts-toggle-label-text { font-size: 0.9rem; color: var(--text); user-select: none; }
.tts-switch-wrap { position: relative; flex-shrink: 0; }
.tts-switch-input { position: absolute; opacity: 0; width: 0; height: 0; }
.tts-switch-track {
  display: block;
  width: 44px; height: 24px;
  background: var(--border);
  border-radius: 12px;
  transition: background 0.2s;
  position: relative;
}
.tts-switch-input:checked ~ .tts-switch-track { background: var(--accent); }
.tts-switch-thumb {
  position: absolute;
  top: 3px; left: 3px;
  width: 18px; height: 18px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.tts-switch-input:checked ~ .tts-switch-track .tts-switch-thumb { transform: translateX(20px); }
.tts-voice-row {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
  align-items: center;
}
.tts-load-indicator {
  font-size: 0.78rem;
  margin-top: 0.5rem;
  min-height: 1.1em;
  color: var(--text-muted);
}
.tts-load-indicator.loading { color: var(--accent); }
.tts-load-indicator.ready   { color: #10b981; }
.tts-load-indicator.error   { color: #ef4444; }

/* ── Token Usage ──────────────────────────────────────────────────── */
.token-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1.5rem;
  padding: 0.6rem 0.85rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.75rem;
  color: var(--text-muted);
}
.token-footer-label { font-weight: 600; }
.token-footer-stats { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; }
.token-footer-stats span { opacity: 0.8; }
.token-footer-cost {
  font-weight: 700;
  color: #10b981;
  opacity: 1 !important;
}

/* Settings token usage table */
.token-usage-summary { margin-top: 0.5rem; }
.token-usage-loading, .token-usage-empty { font-size: 0.82rem; color: var(--text-muted); padding: 0.4rem 0; }
.token-row {
  display: grid;
  grid-template-columns: 60px 1fr 1fr 1fr auto;
  gap: 0.4rem;
  align-items: center;
  font-size: 0.78rem;
  padding: 0.3rem 0;
  border-bottom: 1px solid var(--border);
}
.token-row:last-child { border-bottom: none; }
.token-row-total {
  font-weight: 700;
  margin-top: 0.2rem;
  padding-top: 0.4rem;
  border-top: 1px solid var(--border);
  border-bottom: none;
}
.token-row-module { font-weight: 600; color: var(--accent); }
.token-row-stat { color: var(--text-muted); text-align: right; }
.token-row-cost { color: #10b981; font-weight: 600; text-align: right; }
.token-row-cost-total { font-size: 0.85rem; }

/* ── Sync / Refresh buttons ───────────────────────────────────────── */
.topbar-btn-sync { font-size: 1.1rem; font-weight: 700; }
.topbar-btn-sync:disabled { opacity: 0.5; }
