/* ==================== DESIGN TOKENS ==================== */
:root {
  /* Science Journal Palette */
  --navy: #0f172a;
  --navy-light: #1e293b;
  --blue: #3b82f6;
  --blue-light: #60a5fa;
  --gold: #eab308;
  --gold-light: #fde047;

  /* Semantic (Light Mode) */
  --bg-page: #f1f5f9;
  --bg-panel: #ffffff;
  --bg-panel-alt: #f8fafc;
  --bg-input: #ffffff;
  --border: #e2e8f0;
  --border-light: #f1f5f9;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --text-faint: #94a3b8;

  /* Legacy semantic names (JS reads these) */
  --primary: #0f172a;
  --accent: #3b82f6;
  --correct: #22c55e;
  --wrong: #ef4444;
  --light: #f1f5f9;
  --easy: #3b82f6;
  --medium: #f59e0b;
  --hard: #ef4444;
  --boss: #d7263d;

  /* Energy bars */
  --ke-color: #3b82f6;
  --ke-dark: #1d4ed8;
  --gpe-color: #22c55e;
  --gpe-dark: #15803d;
  --spe-color: #a855f7;
  --spe-dark: #7e22ce;

  /* Layout */
  --sidebar-width: 260px;
  --topbar-height: 56px;
  --guest-banner-height: 0px;
  --radius: 10px;
  --radius-lg: 14px;

  /* Fonts */
  --font-ui: 'Inter', system-ui, -apple-system, sans-serif;
  --font-problem: 'Source Serif 4', Georgia, serif;
}

/* ==================== DARK MODE ==================== */
[data-theme="dark"] {
  --bg-page: #0f172a;
  --bg-panel: #1e293b;
  --bg-panel-alt: #334155;
  --bg-input: #1e293b;
  --border: #334155;
  --border-light: #1e293b;
  --text-primary: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --text-faint: #64748b;
  --primary: #f1f5f9;
  --light: #0f172a;
}

/* ==================== BASE ==================== */
* { box-sizing: border-box; }

body {
  font-family: var(--font-ui);
  margin: 0;
  padding: 0;
  background: var(--bg-page);
  color: var(--text-primary);
  line-height: 1.5;
}

/* ==================== SPLASH SCREEN ==================== */
.splash-screen {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: var(--navy);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity 0.4s ease, visibility 0.4s ease;
}
.splash-screen.hidden { opacity: 0; visibility: hidden; }

.splash-content { text-align: center; color: white; }

.splash-icon {
  width: 100px; height: 100px;
  margin: 0 auto 20px;
  position: relative;
}
.nucleus {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 24px; height: 24px;
  background: var(--gold);
  border-radius: 50%;
  box-shadow: 0 0 20px rgba(234,179,8,0.5);
}
.orbit {
  position: absolute;
  top: 50%; left: 50%;
  width: 80px; height: 80px;
  border: 3px solid rgba(59,130,246,0.35);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  animation: spin 2s linear infinite;
}
.electron {
  position: absolute;
  top: -6px; left: 50%;
  transform: translateX(-50%);
  width: 12px; height: 12px;
  background: var(--blue);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--blue);
}
@keyframes spin {
  from { transform: translate(-50%, -50%) rotate(0deg); }
  to { transform: translate(-50%, -50%) rotate(360deg); }
}
.splash-title {
  font-size: 2rem;
  font-weight: 800;
  margin: 0 0 10px;
  letter-spacing: -0.01em;
}
.splash-subtitle {
  font-size: 1rem;
  opacity: 0.9;
  margin: 0;
  animation: pulse 1.5s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

/* ==================== LOGIN SCREEN ==================== */
.login-screen {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.login-screen.hidden { display: none; }

.login-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  flex: 1;
  min-height: 100vh;
}

/* Left: Hero */
.login-hero {
  background: var(--navy);
  padding: 60px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;
  overflow: hidden;
}
.equations-bg {
  position: absolute;
  inset: 0;
  opacity: 0.05;
  font-family: 'Times New Roman', serif;
  font-size: 1.5rem;
  color: white;
  line-height: 2.6;
  padding: 40px;
  pointer-events: none;
  word-spacing: 1.5rem;
}
.login-hero-content { position: relative; z-index: 1; }
.hero-badge {
  display: inline-block;
  background: rgba(59,130,246,0.2);
  color: var(--blue-light);
  border: 1px solid rgba(59,130,246,0.3);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
  margin-bottom: 20px;
}
.login-hero h1 {
  color: white;
  font-size: clamp(2rem, 4vw, 3rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0 0 14px;
  text-align: left;
}
.login-hero h1 .gold { color: var(--gold); }
.hero-tagline {
  color: #94a3b8;
  font-size: 1.05rem;
  line-height: 1.6;
  max-width: 400px;
  margin: 0;
}
.hero-features {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 28px;
}
.hero-feature {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #cbd5e1;
  font-size: 0.9rem;
  font-weight: 500;
}
.hero-feature-icon {
  width: 32px; height: 32px;
  background: rgba(59,130,246,0.15);
  border: 1px solid rgba(59,130,246,0.25);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}

/* Right: Login form */
.login-form-side {
  padding: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-panel);
}
.login-card-inner {
  width: 100%;
  max-width: 380px;
}
.login-card-inner h2 {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-primary);
  margin: 0 0 6px;
}
.login-card-inner .subtitle {
  color: var(--text-muted);
  margin: 0 0 28px;
  font-size: 0.95rem;
  text-align: left;
}

.login-form { display: flex; flex-direction: column; gap: 12px; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group label { font-weight: 600; font-size: 0.9rem; color: var(--text-secondary); }
.form-group input {
  padding: 12px 15px;
  font-size: 1rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-input);
  color: var(--text-primary);
}
.form-group input:focus { outline: none; border-color: var(--accent); }

.login-btn {
  padding: 14px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.login-btn:hover { filter: brightness(1.08); }
.login-btn:disabled { background: #94a3b8; cursor: wait; }

.google-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-panel);
  color: var(--text-primary);
  border: 2px solid var(--border);
  padding: 14px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  border-radius: var(--radius);
  transition: all 0.15s;
}
.google-btn:hover {
  border-color: var(--blue);
  box-shadow: 0 2px 8px rgba(59,130,246,0.15);
}
.google-btn:disabled { opacity: 0.6; cursor: wait; }

.login-hint {
  font-size: 0.82rem;
  color: var(--text-muted);
  text-align: center;
  margin: 4px 0 0;
}
.login-divider {
  display: flex;
  align-items: center;
  margin: 8px 0;
  color: var(--text-faint);
  font-size: 0.85rem;
}
.login-divider::before,
.login-divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid var(--border);
}
.login-divider span { padding: 0 12px; }

.guest-btn { background: var(--navy-light); color: white; }
.guest-btn:hover { background: var(--navy); }
.guest-hint { font-style: italic; color: var(--text-faint); }

.login-error { color: var(--wrong); font-size: 0.9rem; text-align: center; display: none; }
.login-error.show { display: block; }
.name-hint { font-size: 0.8rem; color: var(--text-muted); text-align: center; margin: -5px 0 10px 0; }

.login-links {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}
.login-links a { color: var(--accent); text-decoration: none; font-size: 0.9rem; font-weight: 600; }
.login-links a:hover { text-decoration: underline; }
.login-links .link-divider { color: var(--text-faint); }

.local-login {
  display: none;
  flex-direction: column;
  gap: 12px;
  border-top: 1px solid var(--border);
  padding-top: 15px;
}
.local-login.show { display: flex; }
.local-login-divider { font-size: 0.8rem; color: var(--text-muted); text-align: center; }
.local-login-note { font-size: 0.75rem; color: var(--text-faint); text-align: center; margin-top: -6px; }
.local-btn { background: var(--navy-light); }
.local-btn:hover { background: var(--navy); }

/* Landing info blocks */
.landing-sections {
  margin-top: 25px;
  display: grid;
  gap: 12px;
}
.landing-section {
  background: var(--bg-panel-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.landing-section h2 {
  margin: 0 0 6px; font-size: 1rem; color: var(--text-primary); text-align: left;
}
.landing-section p {
  margin: 0 0 8px; color: var(--text-secondary); font-size: 0.9rem; line-height: 1.5; text-align: left;
}
.landing-section a {
  color: var(--accent); text-decoration: none; font-weight: 600; font-size: 0.9rem;
}
.landing-section a:hover { text-decoration: underline; }

@media (max-width: 768px) {
  .login-layout { grid-template-columns: 1fr; }
  .login-hero { display: none; }
  .login-form-side { padding: 40px 24px; }
  .login-card-inner h2 { text-align: center; }
  .login-card-inner .subtitle { text-align: center; }
}

/* ==================== MAIN APP ==================== */
.app-screen { display: none; }
.app-screen.active { display: flex; flex-direction: column; min-height: 100vh; }

/* --- Topbar --- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: var(--topbar-height);
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: var(--guest-banner-height);
  z-index: 100;
  gap: 14px;
  flex-shrink: 0;
}
.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--text-primary);
  flex-shrink: 0;
}
.topbar-atom {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, var(--blue-light), var(--blue));
  position: relative;
  box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
  flex-shrink: 0;
}
.topbar-atom::after {
  content: '';
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--gold);
  position: absolute;
  top: -2px; left: 58%;
  animation: orbit 2.6s linear infinite;
  transform-origin: -5px 13px;
}
@keyframes orbit { to { transform: rotate(360deg); } }

.topbar-nav {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.current-unit-display {
  font-size: 0.85rem;
  color: var(--accent);
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.change-unit-btn {
  padding: 5px 12px;
  background: var(--bg-panel);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.78rem;
  color: var(--accent);
  font-weight: 600;
  transition: all 0.15s;
  white-space: nowrap;
}
.change-unit-btn:hover { background: var(--accent); color: white; }

/* Algebra Blocks dropdown */
.algebra-blocks-dropdown {
  position: relative;
}
.algebra-blocks-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  background: var(--bg-panel);
  border: 1px solid var(--gold);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.78rem;
  color: var(--gold);
  font-weight: 600;
  transition: all 0.15s;
  white-space: nowrap;
  font-family: inherit;
}
.algebra-blocks-btn:hover { background: var(--gold); color: white; }
.algebra-blocks-btn:hover svg { stroke: white; }
.ab-chevron { transition: transform 0.2s; }
.algebra-blocks-dropdown.open .ab-chevron { transform: rotate(180deg); }
.ab-dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 260px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  padding: 6px;
  z-index: 200;
}
.algebra-blocks-dropdown.open .ab-dropdown-menu { display: block; }
.ab-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--text-primary);
  transition: background 0.12s;
}
.ab-menu-item:hover { background: var(--bg-panel-alt); }
.ab-item-icon { font-size: 1.3rem; flex-shrink: 0; }
.ab-item-title { font-weight: 600; font-size: 0.85rem; }
.ab-item-desc { font-size: 0.72rem; color: var(--text-secondary); margin-top: 1px; }

/* Theme toggle */
.theme-toggle {
  background: var(--bg-panel-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: all 0.15s;
  flex-shrink: 0;
}
.theme-toggle:hover { background: var(--border); }
[data-theme="light"] .theme-icon-sun,
:root:not([data-theme]) .theme-icon-sun { display: none; }
[data-theme="light"] .theme-icon-moon,
:root:not([data-theme]) .theme-icon-moon { display: block; }
[data-theme="dark"] .theme-icon-sun { display: block; }
[data-theme="dark"] .theme-icon-moon { display: none; }

.user-info {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-primary);
}
.user-avatar {
  width: 26px; height: 26px;
  border-radius: 50%;
  vertical-align: middle;
}
.sync-status { font-size: 0.75rem; color: var(--text-muted); }
.sync-status.guest { color: var(--gold); font-weight: 600; }
.sync-status.saving { color: var(--medium); }
.sync-status.saved { color: var(--correct); }
.sync-status.error { color: var(--wrong); }

.logout-btn {
  padding: 5px 14px;
  background: var(--bg-panel-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.8rem;
  color: var(--text-secondary);
  transition: all 0.15s;
}
.logout-btn:hover { background: var(--border); }

@media (max-width: 700px) {
  .topbar { padding: 0 12px; gap: 8px; }
  .topbar-brand .topbar-title { display: none; }
  .user-info #display-username { display: none; }
  .change-unit-btn { display: none; }
  .algebra-blocks-btn { font-size: 0; padding: 6px 8px; }
  .algebra-blocks-btn svg:first-child { width: 18px; height: 18px; }
  .algebra-blocks-btn .ab-chevron { display: none; }
  .ab-dropdown-menu { left: auto; right: 0; }
}

/* --- Stat Strip --- */
.hero-strip {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-panel);
}
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  max-width: 600px;
  margin: 0 auto;
}
.stat-card {
  background: var(--bg-panel-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  text-align: center;
}
.stat-label {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}
.stat-value {
  display: block;
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-top: 2px;
}

@media (max-width: 500px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}

/* --- App Layout: Sidebar + Main --- */
.app-layout {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  flex: 1;
}
.sidebar {
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  padding: 16px;
  overflow-y: auto;
  position: sticky;
  top: calc(var(--topbar-height) + var(--guest-banner-height));
  height: calc(100vh - var(--topbar-height) - var(--guest-banner-height));
}
.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.sidebar-title {
  font-size: 0.85rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin: 0;
}
.sidebar-progress {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.sidebar-toggle {
  display: none;
  padding: 10px 16px;
  margin: 12px 20px 0;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-primary);
  cursor: pointer;
  text-align: center;
}
.sidebar-toggle:hover { background: var(--bg-panel-alt); }

@media (max-width: 900px) {
  .app-layout { grid-template-columns: 1fr; }
  .sidebar {
    display: none;
    position: fixed;
    top: calc(var(--topbar-height) + var(--guest-banner-height));
    left: 0;
    width: 280px;
    height: calc(100vh - var(--topbar-height) - var(--guest-banner-height));
    z-index: 200;
    box-shadow: 4px 0 20px rgba(0,0,0,0.15);
  }
  .sidebar.open { display: block; }
  .sidebar-toggle { display: block; }
}

.main-content {
  padding: 20px;
  max-width: 900px;
  width: 100%;
}

@media (max-width: 900px) {
  .main-content { max-width: 100%; }
}

/* ==================== TABS (vertical in sidebar) ==================== */
.tabs {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.tab-btn {
  padding: 9px 12px;
  border: 1px solid var(--border);
  background: var(--bg-panel);
  color: var(--text-primary);
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 600;
  font-size: 0.8rem;
  text-align: left;
  transition: all 0.15s;
  position: relative;
}
.tab-btn:hover { background: var(--bg-panel-alt); }
.tab-btn.active { background: var(--accent); color: white; border-color: var(--accent); }
.tab-btn.complete::after {
  content: "\2713";
  position: absolute;
  top: -6px; right: -6px;
  background: var(--correct);
  color: white;
  width: 16px; height: 16px;
  border-radius: 50%;
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ==================== PROGRESS ==================== */
.progress-title { font-weight: 700; color: var(--accent); font-size: 0.85rem; }
.points-display { font-size: 0.95rem; font-weight: 700; color: var(--text-primary); }
.points-current { color: var(--accent); font-weight: 800; }
.progress-bar-container {
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--blue), var(--gold));
  border-radius: 4px;
  transition: width 0.3s ease;
}
.progress-bar.complete { background: linear-gradient(90deg, var(--correct), #4ade80); }

/* ==================== DIFFICULTY ==================== */
.difficulty-section {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.diff-btn {
  padding: 8px 16px;
  border: 2px solid var(--border);
  background: var(--bg-panel);
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 700;
  font-size: 0.85rem;
  transition: all 0.15s;
  color: var(--text-primary);
}
.diff-btn:hover { transform: translateY(-1px); }
.diff-btn.guided { border-color: #8b5cf6; color: #8b5cf6; }
.diff-btn.guided:hover, .diff-btn.guided.active { background: #8b5cf6; color: white; }
.diff-btn.guided.completed { border-color: var(--correct); color: var(--correct); background: rgba(34,197,94,0.08); }
.diff-btn.guided.completed:hover { background: var(--correct); color: white; }
.diff-btn.easy { border-color: var(--easy); color: var(--easy); }
.diff-btn.easy:hover, .diff-btn.easy.active { background: var(--easy); color: white; }
.diff-btn.medium { border-color: var(--medium); color: var(--medium); }
.diff-btn.medium:hover, .diff-btn.medium.active { background: var(--medium); color: white; }
.diff-btn.hard { border-color: var(--hard); color: var(--hard); }
.diff-btn.hard:hover, .diff-btn.hard.active { background: var(--hard); color: white; }
.diff-btn.boss { border-color: var(--boss); color: var(--boss); }
.diff-btn.boss:hover, .diff-btn.boss.active { background: var(--boss); color: white; }
.diff-btn.boss.locked { border-color: var(--border); color: var(--text-faint); background: var(--bg-panel-alt); }
.diff-points { font-size: 0.72rem; opacity: 0.8; }

/* ==================== ADMIN PROBLEM BROWSER ==================== */
.admin-browser {
  background: #fef3c7;
  border: 2px solid #f59e0b;
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 16px;
}
.admin-browser-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.admin-badge {
  background: #f59e0b;
  color: #78350f;
  font-weight: 700;
  font-size: 0.72rem;
  padding: 4px 10px;
  border-radius: 4px;
  letter-spacing: 1px;
  text-transform: uppercase;
  white-space: nowrap;
}
.admin-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}
.admin-nav-btn {
  background: #fff;
  border: 1px solid #d97706;
  color: #92400e;
  padding: 5px 12px;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.85rem;
}
.admin-nav-btn:hover { background: #fde68a; }
.admin-position {
  font-weight: 700;
  font-size: 0.95rem;
  color: #92400e;
  min-width: 80px;
  text-align: center;
}
.admin-cycle {
  font-size: 0.82rem;
  color: #a16207;
  font-style: italic;
}
.admin-toggle-btn {
  margin-left: auto;
  background: #fee2e2;
  border: 1px solid #fca5a5;
  color: #991b1b;
  padding: 5px 12px;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.82rem;
}
.admin-toggle-btn:hover { background: #fecaca; }
.admin-answer-display {
  margin-top: 10px;
  padding: 10px 14px;
  background: #dcfce7;
  border: 1px solid #86efac;
  border-radius: 6px;
  font-size: 1.05rem;
  color: #166534;
}
.admin-answer-display #admin-answer-value {
  font-weight: 700;
  font-size: 1.15rem;
}
.admin-qa-btn {
  background: #fef3c7 !important;
  color: #92400e !important;
  border-color: #f59e0b !important;
}
.admin-qa-btn:hover, .admin-qa-btn.active {
  background: #f59e0b !important;
  color: white !important;
}
[data-theme="dark"] .admin-browser {
  background: #451a03;
  border-color: #b45309;
}
[data-theme="dark"] .admin-badge { background: #b45309; color: #fef3c7; }
[data-theme="dark"] .admin-nav-btn { background: #78350f; color: #fde68a; border-color: #b45309; }
[data-theme="dark"] .admin-nav-btn:hover { background: #92400e; }
[data-theme="dark"] .admin-position { color: #fde68a; }
[data-theme="dark"] .admin-cycle { color: #fbbf24; }
[data-theme="dark"] .admin-toggle-btn { background: #450a0a; border-color: #991b1b; color: #fca5a5; }
[data-theme="dark"] .admin-answer-display {
  background: #052e16;
  border-color: #166534;
  color: #86efac;
}
[data-theme="dark"] .admin-qa-btn {
  background: #78350f !important;
  color: #fde68a !important;
}
[data-theme="dark"] .admin-qa-btn:hover, [data-theme="dark"] .admin-qa-btn.active {
  background: #b45309 !important;
  color: white !important;
}

/* ==================== PROBLEM CARD ==================== */
.problem-card {
  background: var(--bg-panel);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.06);
  border: 1px solid var(--border);
  margin-bottom: 16px;
}
.problem-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
}
@media (min-width: 900px) {
  .problem-layout {
    grid-template-columns: 1.3fr 1fr;
    align-items: start;
  }
  .answer-panel {
    position: sticky;
    top: calc(80px + var(--guest-banner-height));
    background: var(--bg-panel-alt);
    padding: 20px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
  }
}

.problem-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; flex-wrap: wrap; gap: 8px; }
.topic-label {
  display: inline-block;
  background: rgba(59,130,246,0.1);
  color: var(--accent);
  border: 1px solid rgba(59,130,246,0.25);
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
}
.difficulty-badge { padding: 4px 10px; border-radius: 999px; font-size: 0.72rem; font-weight: 700; text-transform: uppercase; }
.difficulty-badge.easy { background: rgba(59,130,246,0.1); color: var(--easy); }
.difficulty-badge.medium { background: rgba(245,158,11,0.1); color: var(--medium); }
.difficulty-badge.hard { background: rgba(239,68,68,0.1); color: var(--hard); }
.difficulty-badge.boss { background: rgba(215,38,61,0.1); color: var(--boss); }

.problem-debug {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  color: var(--text-muted);
  font-size: 0.78rem;
}
.problem-debug-label {
  font-weight: 600;
  letter-spacing: 0.01em;
}
.problem-debug code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', monospace;
  font-size: 0.72rem;
  color: var(--text-secondary);
  background: var(--bg-panel-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2px 8px;
}
.problem-debug-copy {
  border: 1px solid var(--border);
  background: var(--bg-panel);
  color: var(--text-secondary);
  border-radius: 8px;
  padding: 3px 8px;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
}
.problem-debug-copy:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.problem-text {
  font-family: var(--font-problem);
  font-size: 1.05rem;
  margin-bottom: 14px;
  line-height: 1.7;
  color: var(--text-primary);
}
.given-info {
  background: var(--bg-panel-alt);
  border: 1px solid var(--border);
  padding: 12px 15px;
  border-radius: var(--radius);
  margin-bottom: 14px;
  font-size: 0.95rem;
  color: var(--text-secondary);
}

/* Graph */
.graph-container {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 15px;
  margin-bottom: 14px;
  display: flex;
  justify-content: center;
}
.graph-container svg { max-width: 100%; }

/* ==================== ANSWER PANEL ==================== */
.answer-section { margin-bottom: 14px; }
.input-row { display: flex; gap: 8px; margin-bottom: 10px; }
.answer-input {
  padding: 10px 14px;
  font-size: 1.05rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  flex: 1;
  min-width: 0;
  background: var(--bg-input);
  color: var(--text-primary);
  font-family: var(--font-ui);
  -moz-appearance: textfield;
}
.answer-input::-webkit-outer-spin-button,
.answer-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.answer-input:focus { outline: none; border-color: var(--accent); }
.answer-input.wrong-shake { animation: shake 0.4s; border-color: var(--wrong); }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-5px); }
  40%, 80% { transform: translateX(5px); }
}

.unit-select {
  padding: 10px 12px;
  font-size: 0.95rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-input);
  color: var(--text-primary);
  cursor: pointer;
  min-width: 70px;
}
.unit-select:focus { outline: none; border-color: var(--accent); }

.button-row { display: flex; gap: 8px; margin-bottom: 10px; }
.check-btn {
  flex: 1;
  padding: 12px 20px;
  background: linear-gradient(135deg, var(--blue), #1d4ed8);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
}
.check-btn:hover { filter: brightness(1.08); }
.next-btn {
  flex: 1;
  padding: 12px 20px;
  background: var(--navy);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
}
[data-theme="dark"] .next-btn { background: var(--blue); }
.next-btn:hover { filter: brightness(1.08); }
.skip-btn {
  flex: 1;
  padding: 12px 20px;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
}
[data-theme="dark"] .skip-btn { background: linear-gradient(135deg, #d97706, #b45309); }
.skip-btn:hover { filter: brightness(1.08); }

/* Attempt indicator */
.attempt-indicator { font-size: 0.82rem; color: var(--text-muted); display: block; text-align: center; }
.attempt-dot {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--border);
  margin-left: 3px;
}
.attempt-dot.used { background: var(--wrong); }

/* Feedback */
.feedback { margin-top: 14px; padding: 14px; border-radius: var(--radius); display: none; font-size: 0.95rem; }
.feedback.correct { background: rgba(34,197,94,0.1); border: 2px solid var(--correct); color: #15803d; display: block; }
.feedback.wrong { background: rgba(239,68,68,0.1); border: 2px solid var(--wrong); color: #b91c1c; display: block; }
.feedback.tryagain { background: rgba(245,158,11,0.1); border: 2px solid var(--medium); color: #92400e; display: block; }
.feedback.wrong-unit { background: rgba(245,158,11,0.1); border: 2px solid var(--medium); color: #92400e; display: block; }
.feedback.warning { background: rgba(245,158,11,0.1); border: 2px solid var(--medium); color: #92400e; display: block; }
.points-earned { font-weight: 700; margin-left: 10px; }
.points-lost { font-weight: 700; margin-left: 10px; color: var(--wrong); }

[data-theme="dark"] .feedback.correct { color: #86efac; }
[data-theme="dark"] .feedback.wrong { color: #fca5a5; }
[data-theme="dark"] .feedback.tryagain,
[data-theme="dark"] .feedback.wrong-unit,
[data-theme="dark"] .feedback.warning { color: #fcd34d; }

/* Hint */
.hint-btn {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 0.88rem;
  text-decoration: underline;
  margin-top: 10px;
  display: block;
  width: 100%;
  text-align: left;
}
.hint-btn.unlocked { color: var(--correct); }
.hint-text {
  margin-top: 10px;
  padding: 10px 14px;
  background: rgba(59,130,246,0.06);
  border-left: 3px solid var(--accent);
  font-size: 0.9rem;
  display: none;
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--text-secondary);
}
.hint-text.show { display: block; }

/* ==================== CELEBRATION ==================== */
.celebration {
  display: none;
  text-align: center;
  padding: 20px;
  background: rgba(34,197,94,0.1);
  border: 2px solid var(--correct);
  border-radius: var(--radius-lg);
  margin-bottom: 16px;
}
.celebration.show { display: block; animation: pop 0.3s ease; }
@keyframes pop { 0% { transform: scale(0.8); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
.celebration h2 { color: var(--correct); margin: 0 0 10px; }
.celebration p { color: var(--text-secondary); margin: 0; }

/* ==================== GUIDED PRIMER CARD ==================== */
.guided-primer-card {
  background: linear-gradient(135deg, rgba(59,130,246,0.1), rgba(59,130,246,0.04));
  border: 2px solid rgba(59,130,246,0.25);
  border-radius: var(--radius-lg);
  padding: 14px 18px;
  margin-bottom: 16px;
}
.primer-content { display: flex; align-items: center; gap: 14px; }
.primer-icon { font-size: 1.8rem; flex-shrink: 0; }
.primer-text { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.primer-text strong { color: var(--text-primary); font-size: 1rem; }
.primer-description { color: var(--text-muted); font-size: 0.85rem; }
.primer-launch-btn {
  padding: 10px 20px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.15s;
}
.primer-launch-btn:hover { filter: brightness(1.08); transform: translateY(-1px); }

.guided-primer-card.completed {
  background: rgba(34,197,94,0.08);
  border-color: var(--correct);
}
.guided-primer-card.completed .primer-description { color: #15803d; font-weight: 600; }
[data-theme="dark"] .guided-primer-card.completed .primer-description { color: #86efac; }
.guided-primer-card.completed .primer-launch-btn { background: var(--correct); }

/* ==================== RESET ==================== */
.reset-section { text-align: center; margin-top: 16px; }
.reset-btn {
  padding: 8px 20px;
  background: var(--bg-panel-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text-muted);
  transition: all 0.15s;
}
.reset-btn:hover { background: var(--border); }

/* ==================== SYSTEM CHECK (CONSERVATION) ==================== */
.system-check {
  background: rgba(59,130,246,0.05);
  border: 1px solid rgba(59,130,246,0.15);
  padding: 12px 15px;
  border-radius: var(--radius);
  margin-bottom: 14px;
}
.system-check-title { margin: 0 0 2px; font-size: 0.9rem; font-weight: 800; color: var(--text-primary); }
.system-check-subtitle { margin: 0 0 10px; font-size: 0.8rem; color: var(--text-muted); }
.system-check-options { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.system-check-item { font-size: 0.9rem; color: var(--text-primary); user-select: none; }
.system-check-item input { margin-right: 6px; transform: translateY(1px); }

/* ==================== ENERGY BAR CHART ==================== */
.energy-chart-wrapper {
  background: var(--bg-panel-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 15px;
  margin: 14px 0;
}
.energy-chart-title {
  text-align: center;
  font-weight: bold;
  color: var(--text-secondary);
  margin-bottom: 12px;
  font-size: 0.95rem;
}
.energy-chart {
  display: flex;
  height: 200px;
  position: relative;
  background: var(--bg-panel);
  border-radius: var(--radius);
  padding: 10px;
  border: 1px solid var(--border);
}
.energy-y-axis {
  width: 35px; height: 160px;
  position: relative;
  border-right: 2px solid var(--text-primary);
  margin-right: 10px;
  flex-shrink: 0;
}
.y-tick {
  position: absolute;
  right: 8px;
  font-size: 0.65rem;
  color: var(--text-muted);
  transform: translateY(50%);
}
.energy-bars-area {
  display: flex;
  align-items: flex-end;
  justify-content: space-around;
  flex: 1;
  height: 160px;
  position: relative;
  padding: 0 10px;
}
.total-line {
  position: absolute;
  left: 0; right: 0;
  border-top: 3px dashed var(--wrong);
  z-index: 5;
  pointer-events: none;
}
.total-label {
  position: absolute;
  right: 5px; top: -20px;
  font-size: 0.7rem;
  color: var(--wrong);
  font-weight: bold;
  background: var(--bg-panel);
  padding: 2px 5px;
  border-radius: 3px;
  white-space: nowrap;
}
.bar-column {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
}
.energy-bar {
  width: 55px;
  border-radius: 6px 6px 0 0;
  position: relative;
  transition: height 0.05s ease-out, box-shadow 0.2s;
  min-height: 3px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}
.energy-bar.draggable { cursor: ns-resize; }
.energy-bar.draggable:hover { filter: brightness(1.1); box-shadow: 0 0 15px rgba(0,0,0,0.25); }
.energy-bar.dragging { filter: brightness(1.15); box-shadow: 0 0 20px rgba(0,0,0,0.35); z-index: 10; }
.ke-bar { background: linear-gradient(to top, var(--ke-dark), var(--ke-color)); border: 2px solid var(--ke-dark); }
.gpe-bar { background: linear-gradient(to top, var(--gpe-dark), var(--gpe-color)); border: 2px solid var(--gpe-dark); }
.spe-bar { background: linear-gradient(to top, var(--spe-dark), var(--spe-color)); border: 2px solid var(--spe-dark); }
.bar-val {
  position: absolute;
  top: -24px;
  font-size: 0.8rem;
  font-weight: bold;
  white-space: nowrap;
}
.ke-bar .bar-val { color: var(--ke-dark); }
.gpe-bar .bar-val { color: var(--gpe-dark); }
.spe-bar .bar-val { color: var(--spe-dark); }
[data-theme="dark"] .ke-bar .bar-val { color: var(--ke-color); }
[data-theme="dark"] .gpe-bar .bar-val { color: var(--gpe-color); }
[data-theme="dark"] .spe-bar .bar-val { color: var(--spe-color); }
.bar-lbl { margin-top: 8px; font-weight: bold; font-size: 0.85rem; }
.ke-lbl { color: var(--ke-color); }
.gpe-lbl { color: var(--gpe-color); }
.spe-lbl { color: var(--spe-color); }
.chart-hint {
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-style: italic;
  margin-top: 10px;
  padding: 6px;
  background: rgba(234,179,8,0.1);
  border-radius: 6px;
  border: 1px solid rgba(234,179,8,0.3);
}
.sum-display {
  text-align: center;
  font-size: 0.9rem;
  font-weight: bold;
  margin-top: 10px;
  padding: 8px 12px;
  border-radius: 6px;
  transition: all 0.3s;
}
.sum-display.valid { background: rgba(34,197,94,0.1); color: #15803d; border: 2px solid var(--correct); }
.sum-display.invalid { background: rgba(239,68,68,0.1); color: #b91c1c; border: 2px solid var(--wrong); }
[data-theme="dark"] .sum-display.valid { color: #86efac; }
[data-theme="dark"] .sum-display.invalid { color: #fca5a5; }

/* ==================== RESPONSIVE ==================== */
@media (max-width: 600px) {
  .problem-card { padding: 16px; }
  .difficulty-section { flex-wrap: wrap; }
  .diff-btn { flex: 1; min-width: 70px; text-align: center; }
  .energy-bar { width: 45px; }
}

/* ==================== CONFETTI ==================== */
#confetti-container {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  overflow: hidden;
  z-index: 9999;
}
.confetti-particle {
  position: absolute;
  top: -10px;
  width: 10px; height: 10px;
  opacity: 0;
  animation: confetti-fall 2s ease-out forwards;
}
@keyframes confetti-fall {
  0% { opacity: 1; transform: translateY(0) rotate(0deg) scale(1); }
  20% { opacity: 1; }
  100% { opacity: 0; transform: translateY(100vh) rotate(720deg) scale(0.3); }
}
.confetti-particle:nth-child(odd) { animation-name: confetti-fall-left; }
.confetti-particle:nth-child(even) { animation-name: confetti-fall-right; }
@keyframes confetti-fall-left {
  0% { opacity: 1; transform: translateY(0) translateX(0) rotate(0deg) scale(1); }
  20% { opacity: 1; }
  100% { opacity: 0; transform: translateY(100vh) translateX(-100px) rotate(-720deg) scale(0.3); }
}
@keyframes confetti-fall-right {
  0% { opacity: 1; transform: translateY(0) translateX(0) rotate(0deg) scale(1); }
  20% { opacity: 1; }
  100% { opacity: 0; transform: translateY(100vh) translateX(100px) rotate(720deg) scale(0.3); }
}

/* ==================== UNIT SELECTION MODAL ==================== */
.unit-selection-modal {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--bg-page);
  z-index: 1000;
  overflow-y: auto;
}
.unit-selection-modal.active { display: block; }

/* Topbar inside unit selection modal */
.unit-modal-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: var(--topbar-height);
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 101;
  gap: 14px;
}
.unit-modal-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--text-primary);
  flex-shrink: 0;
}
.unit-modal-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
}
.unit-modal-nav a {
  padding: 5px 12px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: 8px;
  transition: background 0.15s, color 0.15s;
}
.unit-modal-nav a:hover { background: var(--bg-panel-alt); color: var(--text-primary); }
.unit-modal-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.unit-selection-content { max-width: 900px; margin: 0 auto; padding: 20px; }
.unit-selection-header { text-align: center; margin-bottom: 30px; }
.unit-selection-header h2 { color: var(--text-primary); margin: 0 0 10px; font-size: 1.8rem; }
.unit-selection-header p { color: var(--text-muted); margin: 0; font-size: 1.1rem; }
.unit-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 30px;
}
.unit-card {
  background: var(--bg-panel);
  border-radius: var(--radius-lg);
  padding: 20px;
  text-align: center;
  box-shadow: 0 2px 10px rgba(0,0,0,0.06);
  cursor: pointer;
  transition: all 0.15s;
  border: 3px solid transparent;
}
.unit-card:hover:not(.locked) {
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.1);
  border-color: var(--accent);
}
.unit-card.locked { opacity: 0.5; cursor: not-allowed; background: var(--bg-panel-alt); }
.unit-card-icon { font-size: 2.5rem; margin-bottom: 10px; }
.unit-card-title { font-size: 0.82rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }
.unit-card-name { font-size: 1.05rem; font-weight: 700; color: var(--text-primary); margin-bottom: 12px; }
.unit-card-progress { margin-top: 8px; }
.unit-progress-bar { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; margin-bottom: 6px; }
.unit-progress-fill { height: 100%; background: linear-gradient(90deg, var(--blue), var(--gold)); border-radius: 3px; transition: width 0.3s ease; }
.unit-progress-text { font-size: 0.78rem; color: var(--text-muted); }
.unit-card-locked { font-size: 0.82rem; color: var(--text-faint); margin-top: 8px; }
.unit-selection-footer { text-align: center; padding-top: 10px; border-top: 1px solid var(--border); }
.unit-footer-links { margin-bottom: 12px; }
.unit-footer-links a { color: var(--accent); text-decoration: none; font-size: 0.9rem; font-weight: 600; }
.unit-footer-links a:hover { text-decoration: underline; }
.unit-footer-links .link-divider { color: var(--text-faint); margin: 0 8px; }
.logout-btn-small {
  padding: 8px 20px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text-muted);
  transition: all 0.15s;
}
.logout-btn-small:hover { background: var(--bg-panel-alt); }

@media (max-width: 600px) {
  .unit-cards-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .unit-card { padding: 15px; }
  .unit-card-icon { font-size: 2rem; }
  .unit-card-name { font-size: 0.95rem; }
}

/* ==================== HEADER UNIT INDICATOR ==================== */
.unit-indicator { display: flex; align-items: center; gap: 10px; }

/* ==================== GUEST BANNER ==================== */
.guest-banner {
  position: fixed;
  top: 0; left: 0; right: 0;
  background: linear-gradient(135deg, var(--gold), #d97706);
  color: white;
  padding: 8px 20px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 15px;
  font-size: 0.88rem;
  font-weight: 600;
  z-index: 1001;
  box-shadow: 0 2px 10px rgba(0,0,0,0.15);
}
.guest-banner button {
  background: white;
  color: #d97706;
  border: none;
  padding: 5px 15px;
  border-radius: var(--radius);
  font-weight: 700;
  cursor: pointer;
  font-size: 0.82rem;
}
.guest-banner button:hover { background: #f8fafc; }
.guest-mode-active { --guest-banner-height: 50px; }

/* ==================== GUIDED PROBLEM MODAL ==================== */
.guided-modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 20px;
}
.guided-modal {
  background: var(--bg-panel);
  border-radius: 16px;
  padding: 35px 40px;
  max-width: 450px;
  width: 100%;
  text-align: center;
  box-shadow: 0 10px 40px rgba(0,0,0,0.3);
  animation: modal-pop 0.25s ease-out;
}
@keyframes modal-pop {
  0% { transform: scale(0.9); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}
.guided-modal-icon { font-size: 3.5rem; margin-bottom: 15px; }
.guided-modal h2 { color: var(--text-primary); margin: 0 0 10px; font-size: 1.4rem; }
.guided-modal-desc { color: var(--text-muted); margin: 0 0 25px; font-size: 1rem; line-height: 1.5; }
.guided-modal-buttons { display: flex; flex-direction: column; gap: 10px; margin-bottom: 15px; }
.guided-modal-btn {
  padding: 14px 28px;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
}
.guided-modal-btn.primary {
  background: linear-gradient(135deg, var(--blue), #1d4ed8);
  color: white;
}
.guided-modal-btn.primary:hover {
  filter: brightness(1.08);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(59,130,246,0.3);
}
.guided-modal-btn.secondary {
  background: var(--bg-panel-alt);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.guided-modal-btn.secondary:hover { background: var(--border); }
.guided-modal-remember {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-faint);
  cursor: pointer;
}
.guided-modal-remember input { cursor: pointer; }

/* ==================== CLASS CODE MODAL ==================== */
.class-code-modal {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--navy);
  z-index: 1100;
  overflow-y: auto;
  padding: 20px;
}
.class-code-modal.active { display: flex; align-items: center; justify-content: center; }
.class-code-content {
  background: var(--bg-panel);
  border-radius: 16px;
  padding: 40px;
  max-width: 400px;
  width: 100%;
  box-shadow: 0 10px 40px rgba(0,0,0,0.3);
  text-align: center;
}
.class-code-header h2 { color: var(--text-primary); margin: 0 0 10px; font-size: 1.5rem; }
.class-code-header p { color: var(--text-muted); margin: 0 0 25px; font-size: 0.95rem; }
.class-code-form { margin-bottom: 25px; }
#class-code-input {
  width: 100%;
  padding: 14px 16px;
  font-size: 1.2rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  text-align: center;
  letter-spacing: 2px;
  font-family: monospace;
  background: var(--bg-input);
  color: var(--text-primary);
  transition: border-color 0.2s;
}
#class-code-input:focus { outline: none; border-color: var(--accent); }
.class-code-error { color: var(--wrong); font-size: 0.9rem; margin: 10px 0; }
.class-code-btn {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, var(--blue), #1d4ed8);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
  margin-top: 15px;
}
.class-code-btn:hover { filter: brightness(1.08); transform: translateY(-1px); }
.class-code-btn:disabled { background: var(--text-faint); cursor: not-allowed; transform: none; }
.class-code-footer { border-top: 1px solid var(--border); padding-top: 20px; }
.class-code-footer p { color: var(--text-faint); font-size: 0.85rem; margin: 0 0 15px; }
.class-code-footer .logout-btn-small {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 0.85rem;
  cursor: pointer;
}
.class-code-footer .logout-btn-small:hover { background: var(--bg-panel-alt); }

/* ==================== ASSUMPTION BOX ==================== */
.assumption-box {
  background: rgba(59,130,246,0.05);
  border: 1px solid rgba(59,130,246,0.15);
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 14px;
  font-size: 0.9rem;
  color: var(--text-secondary);
}
