:root {
  --red:       #ff5e5f;
  --red-light: #fff0f0;
  --red-dark:  #cc3a3b;
  --black:     #0f0f0f;
  --gray-900:  #1a1a1a;
  --gray-700:  #3a3a3a;
  --gray-600:  #555;
  --gray-400:  #767676;   /* was #999 — darkened to pass WCAG AA 4.5:1 on white */
  --gray-200:  #ddd;
  --gray-100:  #f5f5f3;
  --gray-50:   #fafaf9;
  --white:     #ffffff;
  --playfair: 'Playfair Display', Georgia, 'Times New Roman', serif;
  --lora:     'Lora', Georgia, 'Times New Roman', serif;
  --sans:     Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  --mono:     'JetBrains Mono', 'Courier New', monospace;
  --max:    1160px;
  --radius: 3px;
  --varc: #7c3aed;
  --dilr: #0284c7;
  --qa:   #059669;
  --bg:          var(--white);
  --bg-alt:      var(--gray-50);
  --bg-card:     var(--white);
  --border:      var(--gray-200);
  --text:        var(--gray-900);
  --text-muted:  var(--gray-600);
  --text-dim:    var(--gray-400);
  --shadow:      0 1px 4px rgba(0,0,0,0.08), 0 4px 16px rgba(0,0,0,0.04);
  --shadow-md:   0 4px 20px rgba(0,0,0,0.1);
  --red-shadow:  0 4px 20px rgba(255,94,95,0.25);
  --green: #059669;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--white);
  color: var(--gray-900);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  font-synthesis: none;
}

/* ── Typography ── */
h1, h2, h3, h4, h5 {
  font-family: var(--playfair);
  line-height: 1.2;
  color: var(--black);
}
p { color: var(--gray-700); }
a { color: var(--red); text-decoration: none; }
a:hover { color: var(--red-dark); }
.mono { font-family: var(--mono); }
.serif { font-family: var(--lora); }

/* ── Navbar ── */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255,255,255,0.97);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--gray-200);
  padding: 0 2rem;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.navbar-brand {
  font-family: var(--playfair);
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--red);
  text-decoration: none;
  letter-spacing: -0.01em;
}
.navbar-brand span { color: var(--black); }
.navbar-nav { display: flex; align-items: center; gap: 0.15rem; }
.nav-link {
  color: var(--gray-600);
  text-decoration: none;
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius);
  font-size: 0.88rem;
  font-weight: 500;
  font-family: var(--sans);
  transition: color 0.15s, background 0.15s;
}
.nav-link:hover, .nav-link.active {
  color: var(--black);
  background: var(--gray-100);
}
.nav-pill {
  background: var(--red);
  color: var(--white);
  padding: 0.38rem 1rem;
  border-radius: var(--radius);
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  font-family: var(--sans);
  transition: background 0.15s;
}
.nav-pill:hover { background: var(--red-dark); color: var(--white); }

/* Hamburger hidden on desktop, mobile nav hidden on desktop */
.nav-hamburger { display: none; }
.mobile-nav { display: none; }

/* ── Section badges ── */
.badge {
  display: inline-block;
  padding: 0.18rem 0.55rem;
  border-radius: var(--radius);
  font-size: 0.72rem;
  font-family: var(--mono);
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border: 1px solid;
}
.badge-varc { background: #ede9fe; color: #5b21b6; border-color: #c4b5fd; }
.badge-dilr { background: #e0f2fe; color: #075985; border-color: #7dd3fc; }
.badge-qa   { background: #d1fae5; color: #065f46; border-color: #6ee7b7; }
.badge-red  { background: var(--red-light); color: var(--red-dark); border-color: #fca5a5; }

/* ── Cards ── */
.card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 1.5rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.card:hover { border-color: #fca5a5; box-shadow: var(--shadow); }
.card-lg { padding: 2rem; }
.card-red { background: var(--red-light); border-color: #fca5a5; }
.card-glow { box-shadow: 0 0 0 1px rgba(255,94,95,0.15), 0 8px 32px rgba(255,94,95,0.08); }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1.35rem;
  border-radius: var(--radius);
  font-family: var(--sans);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
  letter-spacing: 0.01em;
}
.btn-primary {
  background: var(--red);
  color: var(--white);
  border-color: var(--red);
}
.btn-primary:hover {
  background: var(--red-dark);
  border-color: var(--red-dark);
  color: var(--white);
  box-shadow: var(--red-shadow);
}
.btn-outline {
  background: transparent;
  color: var(--gray-700);
  border-color: var(--gray-200);
}
.btn-outline:hover { border-color: var(--gray-400); color: var(--black); background: var(--gray-50); }
.btn-ghost {
  background: transparent;
  color: var(--red);
  border-color: transparent;
}
.btn-ghost:hover { background: var(--red-light); }
.btn-lg { padding: 0.75rem 1.75rem; font-size: 0.95rem; }
.btn-sm { padding: 0.3rem 0.8rem; font-size: 0.8rem; }

/* ── Forms ── */
.form-group { margin-bottom: 1.25rem; }
.form-label {
  display: block;
  font-size: 0.82rem;
  color: var(--gray-700);
  margin-bottom: 0.4rem;
  font-weight: 500;
  font-family: var(--sans);
}
.form-control {
  width: 100%;
  padding: 0.65rem 0.9rem;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  color: var(--black);
  font-family: var(--sans);
  font-size: 0.92rem;
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}
.form-control:focus { border-color: var(--red); box-shadow: 0 0 0 3px rgba(255,94,95,0.1); }
.form-control::placeholder { color: var(--gray-400); }
select.form-control { cursor: pointer; }

/* ── Stats ── */
.stat-block { text-align: center; padding: 1.5rem 1rem; }
.stat-number {
  font-family: var(--playfair);
  font-size: 2.4rem;
  font-weight: 800;
  color: var(--red);
  line-height: 1;
}
.stat-label {
  font-size: 0.75rem;
  color: var(--gray-600);
  margin-top: 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-family: var(--sans);
}

/* ── Progress bars ── */
.progress-bar-wrap {
  background: var(--gray-100);
  border-radius: 99px;
  height: 6px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  border-radius: 99px;
  background: var(--red);
  transition: width 0.6s ease;
}
.progress-bar-fill.varc { background: var(--varc); }
.progress-bar-fill.dilr { background: var(--dilr); }
.progress-bar-fill.qa   { background: var(--qa); }

/* ── Tables ── */
.gs-table { width: 100%; border-collapse: collapse; }
.gs-table th {
  text-align: left;
  font-size: 0.72rem;
  color: var(--gray-600);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.55rem 1rem;
  border-bottom: 2px solid var(--gray-200);
  font-family: var(--mono);
  font-weight: 500;
}
.gs-table td {
  padding: 0.8rem 1rem;
  border-bottom: 1px solid var(--gray-100);
  font-size: 0.88rem;
  color: var(--gray-700);
}
.gs-table tr:hover td { background: var(--gray-50); }

/* ── Alerts ── */
.alert { padding: 0.8rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; font-size: 0.88rem; border: 1px solid; }
.alert-error   { background: var(--red-light); border-color: #fca5a5; color: var(--red-dark); }
.alert-success { background: #d1fae5; border-color: #6ee7b7; color: #065f46; }
.alert-info    { background: #e0f2fe; border-color: #7dd3fc; color: #075985; }

/* ── Layout ── */
.container { max-width: 1200px; margin: 0 auto; padding: 0 1.5rem; }
.page-content { padding: 2.5rem 0; }
.section { padding: 5rem 0; }
.section-alt { background: var(--gray-50); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 1.5rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4,1fr); gap: 1rem; }
.divider { border: none; border-top: 1px solid var(--gray-200); margin: 1.5rem 0; }

/* ── Footer ── */
footer {
  border-top: 1px solid var(--gray-200);
  padding: 2rem 0;
  text-align: center;
  color: var(--gray-400);
  font-size: 0.82rem;
  background: var(--gray-50);
  margin-top: 5rem;
}

/* ── Exam Tabs ── */
.exam-tabs {
  display: flex;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--gray-50);
  margin-bottom: 2rem;
}
.exam-tab {
  flex: 1;
  padding: 0.7rem 1rem;
  text-align: center;
  cursor: pointer;
  text-decoration: none;
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--gray-600);
  border-right: 1px solid var(--gray-200);
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
}
.exam-tab:last-child { border-right: none; }
.exam-tab:hover { background: var(--white); color: var(--black); }
.exam-tab.active { background: var(--red); color: var(--white); font-weight: 700; }
.exam-tab .tab-emoji { font-size: 1.15rem; }
.exam-tab .tab-name { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; }

/* ── Admin nav ── */
.admin-nav {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--gray-200);
}
.admin-nav-link {
  padding: 0.35rem 0.9rem;
  border-radius: var(--radius);
  font-size: 0.82rem;
  font-weight: 500;
  text-decoration: none;
  color: var(--gray-600);
  border: 1px solid var(--gray-200);
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  font-family: var(--sans);
  background: var(--white);
}
.admin-nav-link:hover, .admin-nav-link.active {
  background: var(--red);
  color: var(--white);
  border-color: var(--red);
}

/* ── Drill / Question styles ── */
.question-card { border-left: 3px solid var(--red); }
.option-label {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 1rem;
  border-radius: var(--radius);
  cursor: pointer;
  border: 1px solid var(--gray-200);
  margin-bottom: 0.5rem;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
  background: var(--white);
}
.option-label:hover { border-color: var(--red); background: var(--red-light); }
.option-label input[type=radio] { display: none; }
.option-label.selected { border-color: var(--red); background: var(--red-light); }
.option-letter {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--gray-100);
  border: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: 0.78rem;
  flex-shrink: 0;
  color: var(--gray-700);
}
.result-correct { border-color: #6ee7b7 !important; background: #d1fae5 !important; }
.result-wrong   { border-color: #fca5a5 !important; background: var(--red-light) !important; }
.result-score-ring {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  border: 4px solid var(--red);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.5rem;
  background: var(--red-light);
}

/* ── Leaderboard ranks ── */
.rank-1 { color: #b45309; font-weight: 700; }
.rank-2 { color: var(--gray-600); font-weight: 700; }
.rank-3 { color: #92400e; font-weight: 700; }

/* ── Page header ── */
.page-header {
  padding: 2rem 0 1.5rem;
  border-bottom: 1px solid var(--gray-200);
  margin-bottom: 2rem;
}
.page-header h1 { font-size: 1.9rem; letter-spacing: -0.02em; }
.page-header p  { color: var(--gray-600); font-size: 0.92rem; margin-top: 0.25rem; }

/* ── Streak ── */
.streak-bar {
  background: var(--red-light);
  border: 1px solid #fca5a5;
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* ── Timer ── */
.timer {
  font-family: var(--mono);
  font-size: 1rem;
  font-weight: 500;
  color: var(--red-dark);
  background: var(--red-light);
  border: 1px solid #fca5a5;
  padding: 0.3rem 0.8rem;
  border-radius: var(--radius);
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: var(--gray-50); }
::-webkit-scrollbar-thumb { background: var(--gray-200); border-radius: 3px; }

/* ── Skip to main content (accessibility) ── */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--red);
  color: var(--white);
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  font-weight: 600;
  z-index: 9999;
  border-radius: 0 0 var(--radius) 0;
  transition: top 0.2s;
}
.skip-link:focus { top: 0; }

/* ── Responsive ── */
@media (max-width: 768px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .navbar { padding: 0 1rem; }
  .exam-tabs { flex-direction: column; }
  .exam-tab { border-right: none; border-bottom: 1px solid var(--gray-200); }
  .exam-tab:last-child { border-bottom: none; }
  .admin-nav { gap: 0.35rem; }

  /* Hide desktop nav, show hamburger */
  .desktop-nav { display: none !important; }
  .nav-hamburger {
    display: flex;
    flex-direction: column;
    gap: 5px;
    cursor: pointer;
    padding: 0.4rem;
    border: none;
    background: none;
  }
  .nav-hamburger span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--gray-700);
    border-radius: 2px;
    transition: transform 0.2s, opacity 0.2s;
  }
  .nav-hamburger.open span:nth-child(1) { transform: rotate(45deg) translate(5px, 5px); }
  .nav-hamburger.open span:nth-child(2) { opacity: 0; }
  .nav-hamburger.open span:nth-child(3) { transform: rotate(-45deg) translate(5px, -5px); }

  /* Mobile nav dropdown */
  .mobile-nav {
    position: fixed;
    top: 64px;
    left: 0;
    right: 0;
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    flex-direction: column;
    align-items: stretch;
    padding: 0.75rem 1rem;
    gap: 0.25rem;
    z-index: 99;
    box-shadow: 0 8px 24px rgba(0,0,0,0.08);
    max-height: calc(100vh - 64px);
    overflow-y: auto;
  }
  .mobile-nav.open { display: flex; }
  .mobile-nav .nav-link {
    padding: 0.7rem 1rem;
    font-size: 0.95rem;
    border-bottom: 1px solid var(--gray-100);
  }
  .mobile-nav .nav-pill {
    margin-top: 0.5rem;
    text-align: center;
    padding: 0.75rem;
    font-size: 0.95rem;
  }

  /* Footer mobile */
  .footer-grid {
    grid-template-columns: 1fr 1fr !important;
    gap: 2rem !important;
  }
  .footer-brand { grid-column: 1 / -1; }

  /* Page content */
  .page-content { padding: 1.5rem 0; }
  .card-lg { padding: 1.25rem; }
  .btn-lg { padding: 0.65rem 1.25rem; font-size: 0.88rem; }
  .stat-number { font-size: 1.8rem; }
}

@media (max-width: 480px) {
  .footer-grid { grid-template-columns: 1fr !important; }
  .container { padding: 0 1rem; }
  .card { padding: 1rem; }
  .card-lg { padding: 1rem; }
}