/* ============================================================
   OxfordQ — Neumorphism Aviation Theme
   Primary: #c90b32  |  Neumorphic light-warm surfaces
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&family=DM+Serif+Display:ital@0;1&family=JetBrains+Mono:wght@400;600&display=swap');

:root {
  /* Neumorphic base */
  --bg:           #eae6e1;
  --bg-deep:      #dedad4;
  --bg-raised:    #f0ece7;
  --bg-inset:     #e0dcd6;

  /* Shadows for neumorphism */
  --shadow-out:   6px 6px 14px #c5c1bb, -6px -6px 14px #ffffff;
  --shadow-in:    inset 4px 4px 10px #c5c1bb, inset -4px -4px 10px #ffffff;
  --shadow-sm:    3px 3px 8px #c8c4be, -3px -3px 8px #ffffff;
  --shadow-lg:    10px 10px 24px #bab6b0, -10px -10px 24px #ffffff;
  --shadow-press: inset 2px 2px 6px #c5c1bb, inset -2px -2px 6px #ffffff;

  /* Brand */
  --red:          #c90b32;
  --red-dark:     #a00828;
  --red-light:    #e83058;
  --red-glow:     rgba(201,11,50,0.18);
  --red-soft:     rgba(201,11,50,0.08);

  /* Text */
  --text-prime:   #2a2420;
  --text-sec:     #6b6460;
  --text-dim:     #9e9a96;
  --text-white:   #f8f4f0;

  /* Semantic */
  --green:        #1a8a4a;
  --green-soft:   rgba(26,138,74,0.1);
  --orange:       #c47a1a;
  --orange-soft:  rgba(196,122,26,0.1);
  --fail:         #c90b32;
  --fail-soft:    rgba(201,11,50,0.08);

  /* Structure */
  --radius:       12px;
  --radius-lg:    20px;
  --radius-xl:    28px;
  --radius-pill:  999px;

  /* Border */
  --border:       rgba(160,155,150,0.3);
  --border-strong:rgba(160,155,150,0.55);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text-prime);
  font-family: 'Outfit', sans-serif;
  font-size: 17px;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Scrollbar ─────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-deep); }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }

/* ── Typography ────────────────────────────────── */
h1, h2, h3, h4 {
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  line-height: 1.2;
  color: var(--text-prime);
}
.serif { font-family: 'DM Serif Display', serif; }
code, .mono { font-family: 'JetBrains Mono', monospace; }

/* ── Layout ────────────────────────────────────── */
.container        { max-width: 1140px; margin: 0 auto; padding: 0 1.5rem; }
.container-narrow { max-width: 500px; margin: 0 auto; padding: 0 1.5rem; }
main { flex: 1; }

/* ── NEUMORPHIC HELPERS ────────────────────────── */
.nm-raised {
  background: var(--bg-raised);
  box-shadow: var(--shadow-out);
  border-radius: var(--radius-lg);
}
.nm-inset {
  background: var(--bg-inset);
  box-shadow: var(--shadow-in);
  border-radius: var(--radius);
}
.nm-flat {
  background: var(--bg);
  box-shadow: var(--shadow-sm);
  border-radius: var(--radius);
}

/* ── NAVBAR ────────────────────────────────────── */
.navbar {
  background: var(--bg);
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid var(--border);
}
.navbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 68px;
}
.navbar-brand {
  display: flex;
  align-items: center;
  text-decoration: none;
  gap: .5rem;
}
.navbar-brand img {
  height: 38px;
  width: auto;
  filter: drop-shadow(0 2px 4px rgba(201,11,50,0.3));
}
.navbar-brand .brand-text {
  font-size: 1.65rem;
  font-weight: 800;
  color: var(--red);
  letter-spacing: -.01em;
  font-family: 'Outfit', sans-serif;
}
.navbar-links { display: flex; align-items: center; gap: .35rem; }
.nav-link {
  color: var(--text-sec);
  text-decoration: none;
  padding: .45rem 1rem;
  border-radius: var(--radius-pill);
  font-size: 1rem;
  font-weight: 500;
  transition: all .2s;
  position: relative;
}
.nav-link:hover {
  color: var(--text-prime);
  box-shadow: var(--shadow-sm);
  background: var(--bg-raised);
}
.nav-link.active {
  color: var(--red);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
  background: var(--bg-raised);
}
.nav-btn {
  background: var(--red) !important;
  color: var(--text-white) !important;
  font-weight: 600;
  box-shadow: 3px 3px 8px rgba(201,11,50,0.35), -1px -1px 4px rgba(255,255,255,0.5) !important;
}
.nav-btn:hover {
  background: var(--red-light) !important;
  transform: translateY(-1px);
  box-shadow: 4px 6px 14px rgba(201,11,50,0.4), -1px -1px 4px rgba(255,255,255,0.5) !important;
}

/* ── FOOTER ────────────────────────────────────── */
footer {
  background: var(--bg-deep);
  border-top: 1px solid var(--border);
  padding: 1.2rem 0;
  margin-top: auto;
}
.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .5rem;
}
.footer-brand {
  display: flex;
  align-items: center;
  gap: .5rem;
}
.footer-brand img { height: 22px; opacity: .7; }
.footer-brand span {
  font-weight: 700;
  color: var(--red);
  font-size: .95rem;
}
.footer-copy {
  font-size: .78rem;
  color: var(--text-dim);
  font-style: italic;
}
.footer-copy a { color: var(--red); text-decoration: none; }
.footer-copy a:hover { text-decoration: underline; }
.footer-made {
  font-size: .82rem;
  color: var(--text-dim);
}
.footer-made .heart { color: var(--red); }

/* ── AUTH PAGES ────────────────────────────────── */
.auth-page {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem 1rem;
  background: var(--bg);
}
.auth-wrap {
  width: 100%;
  max-width: 480px;
}
.auth-logo-area {
  text-align: center;
  margin-bottom: 2rem;
}
.auth-logo-area img {
  height: 60px;
  filter: drop-shadow(0 3px 8px rgba(201,11,50,0.25));
}
.auth-tagline {
  margin-top: .5rem;
  font-size: .9rem;
  color: var(--text-dim);
  letter-spacing: .18em;
  text-transform: uppercase;
  font-weight: 500;
}
.auth-card {
  background: var(--bg);
  box-shadow: var(--shadow-lg);
  border-radius: var(--radius-xl);
  padding: 2.5rem 2.2rem;
  border: 1px solid rgba(255,255,255,0.8);
}
.auth-tabs {
  display: flex;
  background: var(--bg-inset);
  box-shadow: var(--shadow-in);
  border-radius: var(--radius-pill);
  padding: 4px;
  margin-bottom: 1.8rem;
}
.auth-tab {
  flex: 1;
  padding: .55rem;
  text-align: center;
  border-radius: var(--radius-pill);
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  color: var(--text-sec);
  transition: all .22s;
  user-select: none;
}
.auth-tab.active {
  background: var(--bg-raised);
  box-shadow: var(--shadow-sm);
  color: var(--red);
}

/* ── FORMS ─────────────────────────────────────── */
.form-group { margin-bottom: 1.3rem; }
.form-label {
  display: block;
  font-size: .88rem;
  font-weight: 600;
  color: var(--text-sec);
  margin-bottom: .5rem;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.form-input {
  width: 100%;
  background: var(--bg-inset);
  box-shadow: var(--shadow-in);
  border: none;
  border-radius: var(--radius);
  color: var(--text-prime);
  padding: .75rem 1.1rem;
  font-size: 1.05rem;
  font-family: 'Outfit', sans-serif;
  font-weight: 400;
  outline: none;
  transition: box-shadow .2s;
}
.form-input:focus {
  box-shadow: var(--shadow-in), 0 0 0 2px var(--red-glow);
}
.form-input::placeholder { color: var(--text-dim); }
textarea.form-input { resize: vertical; min-height: 80px; line-height: 1.5; }

/* ── BUTTONS ────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: .75rem 1.6rem;
  border-radius: var(--radius-pill);
  font-family: 'Outfit', sans-serif;
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: all .18s;
  letter-spacing: .01em;
  white-space: nowrap;
  position: relative;
}
.btn-primary {
  background: var(--red);
  color: var(--text-white);
  box-shadow: 4px 4px 12px rgba(201,11,50,0.4), -2px -2px 6px rgba(255,255,255,0.6);
  width: 100%;
}
.btn-primary:hover {
  background: var(--red-light);
  transform: translateY(-2px);
  box-shadow: 6px 8px 18px rgba(201,11,50,0.45), -2px -2px 6px rgba(255,255,255,0.6);
}
.btn-primary:active {
  transform: translateY(0);
  box-shadow: var(--shadow-press);
  background: var(--red-dark);
}
.btn-secondary {
  background: var(--bg);
  color: var(--text-sec);
  box-shadow: var(--shadow-sm);
}
.btn-secondary:hover {
  color: var(--red);
  transform: translateY(-1px);
  box-shadow: var(--shadow-out);
}
.btn-secondary:active { box-shadow: var(--shadow-press); transform: translateY(0); }
.btn-ghost {
  background: transparent;
  color: var(--red);
  box-shadow: none;
  padding-left: .8rem;
  padding-right: .8rem;
}
.btn-ghost:hover { background: var(--red-soft); box-shadow: var(--shadow-sm); }
.btn-sm  { padding: .45rem 1rem; font-size: .93rem; }
.btn-lg  { padding: .9rem 2.2rem; font-size: 1.15rem; }
.btn-icon {
  width: 38px; height: 38px;
  padding: 0;
  border-radius: 50%;
  background: var(--bg);
  box-shadow: var(--shadow-sm);
  color: var(--text-sec);
}
.btn-icon:hover { color: var(--red); box-shadow: var(--shadow-out); }

/* ── ALERTS ─────────────────────────────────────── */
.alert {
  padding: .85rem 1.1rem;
  border-radius: var(--radius);
  margin-bottom: 1.2rem;
  font-size: .93rem;
  font-weight: 500;
  box-shadow: var(--shadow-sm);
}
.alert-error   { background: var(--fail-soft); color: var(--red); border-left: 3px solid var(--red); }
.alert-success { background: var(--green-soft); color: var(--green); border-left: 3px solid var(--green); }
.alert-info    { background: rgba(100,120,200,0.08); color: #4060b0; border-left: 3px solid #4060b0; }

/* ── PAGE HEADER ────────────────────────────────── */
.page-header {
  padding: 2.5rem 0 2rem;
}
.page-header h1 { font-size: 2.1rem; font-weight: 800; }
.page-header p  { color: var(--text-sec); margin-top: .35rem; font-size: 1.07rem; }

/* ── CARDS ──────────────────────────────────────── */
.card {
  background: var(--bg);
  box-shadow: var(--shadow-out);
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255,255,255,0.7);
  overflow: hidden;
}
.card-body { padding: 1.5rem; }
.card-header {
  padding: 1.1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 1rem;
  color: var(--text-sec);
  text-transform: uppercase;
  letter-spacing: .06em;
  font-size: .82rem;
}

/* ── DASHBOARD STATS ────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 1.2rem;
  margin-bottom: 2rem;
}
.stat-card {
  background: var(--bg);
  box-shadow: var(--shadow-out);
  border-radius: var(--radius-lg);
  padding: 1.6rem 1.5rem;
  border: 1px solid rgba(255,255,255,0.8);
  transition: transform .2s, box-shadow .2s;
  position: relative;
  overflow: hidden;
}
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--card-color, var(--red));
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.stat-icon { font-size: 1.7rem; margin-bottom: .6rem; }
.stat-value {
  font-size: 2.4rem;
  font-weight: 800;
  color: var(--card-color, var(--red));
  line-height: 1;
  font-family: 'Outfit', sans-serif;
}
.stat-label {
  font-size: .83rem;
  color: var(--text-sec);
  text-transform: uppercase;
  letter-spacing: .09em;
  margin-top: .4rem;
  font-weight: 600;
}

/* ── SUBJECT GRID ───────────────────────────────── */
.subjects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 1.2rem;
  margin-bottom: 2rem;
}
.subject-card {
  background: var(--bg);
  box-shadow: var(--shadow-out);
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255,255,255,0.8);
  padding: 1.5rem;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  transition: all .22s;
  position: relative;
  overflow: hidden;
}
.subject-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}
.subject-card:active {
  transform: translateY(0);
  box-shadow: var(--shadow-press);
}
.subject-card::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 3px;
  background: var(--card-color, var(--red));
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  transform: scaleX(0);
  transition: transform .22s;
}
.subject-card:hover::after { transform: scaleX(1); }
.subject-card-header {
  display: flex;
  align-items: center;
  gap: .8rem;
  margin-bottom: .9rem;
}
.subject-code {
  font-family: 'JetBrains Mono', monospace;
  font-size: .72rem;
  background: var(--bg-inset);
  box-shadow: var(--shadow-in);
  color: var(--text-sec);
  padding: .2rem .55rem;
  border-radius: var(--radius-pill);
  letter-spacing: .06em;
  font-weight: 600;
}
.subject-icon { font-size: 1.6rem; }
.subject-name {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-prime);
  margin-bottom: .35rem;
}
.subject-desc {
  font-size: .9rem;
  color: var(--text-sec);
  line-height: 1.45;
  margin-bottom: .8rem;
}
.subject-book {
  font-size: .75rem;
  color: var(--text-dim);
  font-style: italic;
}
.subject-stats {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: .9rem;
  padding-top: .9rem;
  border-top: 1px solid var(--border);
}
.subject-q-count { font-size: .85rem; color: var(--text-sec); font-weight: 500; }
.subject-accuracy { font-size: .93rem; font-weight: 700; }

/* ── MODAL ──────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(180,170,160,0.55);
  backdrop-filter: blur(6px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s;
}
.modal-backdrop.show { opacity: 1; pointer-events: all; }
.modal {
  background: var(--bg);
  box-shadow: var(--shadow-lg);
  border-radius: var(--radius-xl);
  border: 1px solid rgba(255,255,255,0.9);
  padding: 2.2rem;
  width: 100%;
  max-width: 460px;
  transform: scale(.95) translateY(16px);
  transition: transform .22s;
}
.modal-backdrop.show .modal { transform: scale(1) translateY(0); }
.modal h2 { font-size: 1.5rem; margin-bottom: .4rem; }
.modal-subject-tag {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  font-size: .82rem;
  color: var(--red);
  font-weight: 600;
  background: var(--red-soft);
  padding: .2rem .7rem;
  border-radius: var(--radius-pill);
  margin-bottom: 1.4rem;
}
.qty-btns {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin-bottom: .8rem;
}
.qty-btn {
  padding: .5rem 1.1rem;
  background: var(--bg);
  box-shadow: var(--shadow-sm);
  border: none;
  border-radius: var(--radius-pill);
  color: var(--text-sec);
  cursor: pointer;
  font-family: 'Outfit', sans-serif;
  font-size: .95rem;
  font-weight: 600;
  transition: all .15s;
}
.qty-btn:hover {
  box-shadow: var(--shadow-out);
  color: var(--text-prime);
}
.qty-btn.active {
  background: var(--red);
  color: var(--text-white);
  box-shadow: 3px 3px 10px rgba(201,11,50,0.35), -1px -1px 4px rgba(255,255,255,0.5);
}
.qty-btn:active { box-shadow: var(--shadow-press); }

/* ── QUIZ CHROME ────────────────────────────────── */
.quiz-header {
  background: var(--bg);
  box-shadow: 0 4px 12px rgba(0,0,0,0.07);
  position: sticky;
  top: 68px;
  z-index: 90;
  border-bottom: 1px solid var(--border);
}
.quiz-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .75rem 1.5rem;
}
.quiz-subject-label {
  font-size: 1rem;
  font-weight: 700;
  color: var(--red);
  display: flex;
  align-items: center;
  gap: .5rem;
}
.quiz-progress-text {
  font-family: 'JetBrains Mono', monospace;
  font-size: .88rem;
  color: var(--text-sec);
  font-weight: 600;
}
.progress-bar-track {
  height: 4px;
  background: var(--bg-inset);
  box-shadow: var(--shadow-in);
}
.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--red-dark), var(--red-light));
  transition: width .4s cubic-bezier(.4,0,.2,1);
  border-radius: 0 2px 2px 0;
}

.quiz-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 1.5rem;
  padding: 2rem 0 3rem;
  align-items: start;
}
@media (max-width: 820px) {
  .quiz-layout { grid-template-columns: 1fr; }
  .quiz-sidebar { display: none; }
}

/* ── QUESTION CARD ──────────────────────────────── */
.question-card {
  background: var(--bg);
  box-shadow: var(--shadow-out);
  border-radius: var(--radius-xl);
  border: 1px solid rgba(255,255,255,0.8);
  padding: 2rem 2.2rem;
}
.question-number {
  font-family: 'JetBrains Mono', monospace;
  font-size: .75rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: .12em;
  margin-bottom: .6rem;
  font-weight: 600;
}
.question-category-badge {
  display: inline-block;
  font-size: .75rem;
  background: var(--bg-inset);
  box-shadow: var(--shadow-in);
  color: var(--text-sec);
  padding: .2rem .7rem;
  border-radius: var(--radius-pill);
  margin-bottom: 1.1rem;
  font-weight: 600;
  letter-spacing: .03em;
}
.question-text {
  font-size: 1.18rem;
  color: var(--text-prime);
  line-height: 1.75;
  margin-bottom: 1.6rem;
  font-weight: 500;
}

/* ── ANSWER OPTIONS ─────────────────────────────── */
.answers-list { display: flex; flex-direction: column; gap: .8rem; }
.answer-option {
  display: flex;
  align-items: flex-start;
  gap: .9rem;
  padding: .95rem 1.1rem;
  background: var(--bg);
  box-shadow: var(--shadow-sm);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all .15s;
  border: 1.5px solid transparent;
  user-select: none;
}
.answer-option:hover:not(.disabled) {
  box-shadow: var(--shadow-out);
  border-color: var(--border);
  transform: translateX(3px);
}
.answer-option:active:not(.disabled) { box-shadow: var(--shadow-press); transform: translateX(0); }
.answer-option.selected {
  background: var(--bg-inset);
  box-shadow: var(--shadow-in);
  border-color: var(--red);
}
.answer-option.correct {
  background: var(--green-soft) !important;
  box-shadow: var(--shadow-in) !important;
  border-color: var(--green) !important;
}
.answer-option.incorrect {
  background: var(--fail-soft) !important;
  box-shadow: var(--shadow-in) !important;
  border-color: var(--red) !important;
  opacity: .85;
}
.answer-option.dimmed:not(.correct) {
  opacity: .5;
}
.answer-option.disabled { cursor: default; }
.answer-letter {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  font-size: .88rem;
  min-width: 1.6rem;
  height: 1.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-inset);
  box-shadow: var(--shadow-in);
  border-radius: 6px;
  color: var(--text-sec);
  flex-shrink: 0;
  margin-top: .05rem;
  transition: all .15s;
}
.answer-option.selected  .answer-letter { background: var(--red); color: #fff; box-shadow: 2px 2px 6px rgba(201,11,50,.35); }
.answer-option.correct   .answer-letter { background: var(--green); color: #fff; box-shadow: none; }
.answer-option.incorrect .answer-letter { background: var(--red); color: #fff; box-shadow: none; }
.answer-text { font-size: 1.03rem; line-height: 1.5; font-weight: 400; color: var(--text-prime); }

/* ── EXPLANATION BOX ────────────────────────────── */
.explanation-section {
  margin-top: 1.6rem;
  display: none;
}
.explanation-section.show { display: block; }
.explanation-box {
  background: var(--bg-inset);
  box-shadow: var(--shadow-in);
  border-radius: var(--radius-lg);
  padding: 1.2rem 1.4rem;
  border-left: 4px solid var(--red);
}
.explanation-box .expl-label {
  font-size: .75rem;
  font-weight: 700;
  color: var(--red);
  text-transform: uppercase;
  letter-spacing: .1em;
  margin-bottom: .5rem;
  display: flex;
  align-items: center;
  gap: .4rem;
}
.explanation-box p {
  font-size: 1rem;
  color: var(--text-sec);
  line-height: 1.6;
}

/* ── COMMENTS SECTION ───────────────────────────── */
.comments-section {
  margin-top: 1.4rem;
  display: none;
}
.comments-section.show { display: block; }
.comments-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: .9rem;
}
.comments-header h4 {
  font-size: .95rem;
  font-weight: 700;
  color: var(--text-sec);
  display: flex;
  align-items: center;
  gap: .4rem;
}
.comment-item {
  background: var(--bg);
  box-shadow: var(--shadow-sm);
  border-radius: var(--radius);
  padding: .85rem 1rem;
  margin-bottom: .7rem;
  border: 1px solid rgba(255,255,255,0.7);
}
.comment-meta {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-bottom: .35rem;
}
.comment-avatar {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--red);
  color: #fff;
  font-size: .72rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}
.comment-username { font-size: .82rem; font-weight: 700; color: var(--text-prime); }
.comment-date     { font-size: .75rem; color: var(--text-dim); margin-left: auto; }
.comment-text     { font-size: .93rem; color: var(--text-sec); line-height: 1.5; }
.comment-form {
  margin-top: .8rem;
  display: flex;
  gap: .6rem;
  align-items: flex-start;
}
.comment-form textarea {
  flex: 1;
  background: var(--bg-inset);
  box-shadow: var(--shadow-in);
  border: none;
  border-radius: var(--radius);
  padding: .65rem .9rem;
  font-family: 'Outfit', sans-serif;
  font-size: .9rem;
  color: var(--text-prime);
  resize: none;
  min-height: 68px;
  outline: none;
}
.comment-form textarea::placeholder { color: var(--text-dim); }
.comment-form textarea:focus { box-shadow: var(--shadow-in), 0 0 0 2px var(--red-glow); }

/* ── QUIZ ACTIONS ───────────────────────────────── */
.quiz-actions {
  display: flex;
  gap: .8rem;
  margin-top: 1.6rem;
  justify-content: flex-end;
  flex-wrap: wrap;
}

/* ── QUIZ SIDEBAR ───────────────────────────────── */
.quiz-sidebar {
  position: sticky;
  top: calc(68px + 52px + 4px + 1rem);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.sidebar-card {
  background: var(--bg);
  box-shadow: var(--shadow-out);
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255,255,255,0.8);
  padding: 1.3rem;
}
.sidebar-card-label {
  font-size: .72rem;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: .1em;
  margin-bottom: .8rem;
}
.timer-display {
  font-family: 'JetBrains Mono', monospace;
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--text-prime);
  text-align: center;
  letter-spacing: .06em;
  background: var(--bg-inset);
  box-shadow: var(--shadow-in);
  border-radius: var(--radius);
  padding: .5rem;
}
.timer-display.warning { color: var(--orange); }
.timer-display.danger  { color: var(--red); animation: pulse-red .6s infinite; }
@keyframes pulse-red { 0%,100%{opacity:1} 50%{opacity:.55} }

.q-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: .35rem;
}
.q-dot {
  aspect-ratio: 1;
  border-radius: 6px;
  background: var(--bg-inset);
  box-shadow: var(--shadow-in);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .68rem;
  color: var(--text-dim);
  font-family: 'JetBrains Mono', monospace;
  cursor: pointer;
  transition: all .15s;
  font-weight: 600;
}
.q-dot:hover    { box-shadow: var(--shadow-sm); color: var(--red); }
.q-dot.current {
  background: var(--red);
  color: #fff;
  font-weight: 800;
  box-shadow: 2px 2px 10px rgba(201,11,50,.5), inset 0 1px 0 rgba(255,255,255,.2);
}
.q-dot.c {
  background: #1a8a4a;
  box-shadow: 2px 2px 6px rgba(0,0,0,.25), inset 0 1px 0 rgba(255,255,255,.15);
  color: #ffffff;
  font-weight: 800;
}
.q-dot.w {
  background: #c90b32;
  box-shadow: 2px 2px 6px rgba(0,0,0,.25), inset 0 1px 0 rgba(255,255,255,.15);
  color: #ffffff;
  font-weight: 800;
}

.tally-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: .93rem;
  color: var(--text-sec);
  font-weight: 500;
  padding: .3rem 0;
}
.tally-row + .tally-row { border-top: 1px solid var(--border); }
.tally-val { font-weight: 800; font-size: 1.05rem; }
.tally-val.g { color: var(--green); }
.tally-val.r { color: var(--red); }

/* ── RESULTS ────────────────────────────────────── */
.results-hero {
  text-align: center;
  padding: 3rem 0 2rem;
}
.score-ring-wrap {
  position: relative;
  width: 170px;
  height: 170px;
  margin: 0 auto 1.5rem;
}
.score-ring-wrap svg { transform: rotate(-90deg); }
.score-ring-bg  { fill: none; stroke: var(--bg-inset); stroke-width: 10; }
.score-ring-fill { fill: none; stroke-width: 10; stroke-linecap: round; transition: stroke-dashoffset 1.2s cubic-bezier(.4,0,.2,1); }
.score-ring-fill.pass   { stroke: var(--green); }
.score-ring-fill.warn   { stroke: var(--orange); }
.score-ring-fill.fail   { stroke: var(--red); }
.score-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.score-pct {
  font-size: 3rem;
  font-weight: 800;
  line-height: 1;
}
.score-lbl { font-size: .82rem; font-weight: 800; text-transform: uppercase; letter-spacing: .12em; color: var(--text-sec); }
.score-ring-wrap.pass .score-lbl { color: var(--green); }
.score-ring-wrap.fail .score-lbl { color: var(--red); }
.score-ring-wrap.warn .score-lbl { color: var(--orange); }
.score-pass .score-pct { color: var(--green); }
.score-warn .score-pct { color: var(--orange); }
.score-fail .score-pct { color: var(--red); }

.results-meta {
  display: flex;
  justify-content: center;
  gap: 2.5rem;
  flex-wrap: wrap;
  margin-bottom: 2rem;
}
.results-meta-item .val {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-prime);
}
.results-meta-item .lbl {
  font-size: .76rem;
  color: var(--text-sec);
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 600;
}

.review-list { display: flex; flex-direction: column; gap: 1rem; }
.review-item {
  background: var(--bg);
  box-shadow: var(--shadow-sm);
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255,255,255,0.8);
  padding: 1.2rem 1.5rem;
  border-left: 4px solid var(--border);
  transition: box-shadow .2s;
}
.review-item:hover { box-shadow: var(--shadow-out); }
.review-item.correct { border-left-color: var(--green); }
.review-item.wrong   { border-left-color: var(--red); }
.review-q { font-size: .97rem; color: var(--text-prime); margin-bottom: .6rem; font-weight: 500; line-height: 1.5; }
.review-ans { font-size: .85rem; }
.correct-ans { color: var(--green); font-weight: 700; }
.wrong-ans   { color: var(--red); text-decoration: line-through; }
.review-expl {
  margin-top: .6rem;
  font-size: .83rem;
  color: var(--text-sec);
  line-height: 1.5;
  padding: .5rem .8rem;
  background: var(--bg-inset);
  box-shadow: var(--shadow-in);
  border-radius: var(--radius);
}

/* ── TABLE ──────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .95rem;
}
.data-table th {
  text-align: left;
  padding: .65rem 1.1rem;
  background: var(--bg-deep);
  color: var(--text-sec);
  font-weight: 700;
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .07em;
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: .75rem 1.1rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-prime);
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: var(--bg-raised); }

/* ── BADGES ─────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: .18rem .6rem;
  border-radius: var(--radius-pill);
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .02em;
}
.badge-pass { background: var(--green-soft);  color: var(--green); }
.badge-fail { background: var(--fail-soft);   color: var(--red); }
.badge-warn { background: var(--orange-soft); color: var(--orange); }

/* ── DIVIDER ────────────────────────────────────── */
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.5rem 0;
}

/* ── SECTION TITLE ──────────────────────────────── */
.section-title {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text-prime);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: .5rem;
}

/* ── UTIL ───────────────────────────────────────── */
.text-center  { text-align: center; }
.text-muted   { color: var(--text-sec); }
.text-red     { color: var(--red); }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-center  { display: flex; align-items: center; justify-content: center; }
.gap-1 { gap: .5rem; }
.gap-2 { gap: 1rem; }

/* ── ANIMATIONS ─────────────────────────────────── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: translateY(0); }
}
.fade-up { animation: fadeUp .4s ease both; }
.fade-up-1 { animation-delay: .05s; }
.fade-up-2 { animation-delay: .10s; }
.fade-up-3 { animation-delay: .15s; }
.fade-up-4 { animation-delay: .20s; }

/* ── RESPONSIVE ─────────────────────────────────── */
@media (max-width: 640px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .subjects-grid { grid-template-columns: 1fr; }
  .footer-inner { flex-direction: column; text-align: center; }
  .auth-card { padding: 1.8rem 1.3rem; }
}

/* ============================================================
   DARK MODE — activated by <html data-theme="dark">
   ============================================================ */
[data-theme="dark"] {
  --bg:           #1a1e28;
  --bg-deep:      #141720;
  --bg-raised:    #1f2435;
  --bg-inset:     #141720;

  --shadow-out:   6px 6px 14px #0d1018, -6px -6px 14px #232840;
  --shadow-in:    inset 4px 4px 10px #0d1018, inset -4px -4px 10px #232840;
  --shadow-sm:    3px 3px 8px #0d1018, -3px -3px 8px #232840;
  --shadow-lg:    10px 10px 28px #090c14, -10px -10px 28px #252b40;
  --shadow-press: inset 2px 2px 6px #0d1018, inset -2px -2px 6px #232840;

  --text-prime:   #e8eaf2;
  --text-sec:     #8892aa;
  --text-dim:     #4a5268;

  --border:       rgba(60,70,100,0.45);
  --border-strong:rgba(80,95,130,0.6);

  --green-soft:   rgba(46,204,113,0.12);
  --orange-soft:  rgba(196,122,26,0.12);
  --fail-soft:    rgba(201,11,50,0.12);
  --red-soft:     rgba(201,11,50,0.1);
  --red-glow:     rgba(201,11,50,0.22);
}

[data-theme="dark"] .navbar,
[data-theme="dark"] .quiz-header {
  background: var(--bg-raised);
}
[data-theme="dark"] .data-table th {
  background: var(--bg-deep);
}
[data-theme="dark"] .hero-pill,
[data-theme="dark"] .subject-code,
[data-theme="dark"] .question-category-badge {
  background: var(--bg-inset);
  color: var(--text-sec);
}
[data-theme="dark"] footer {
  background: var(--bg-deep);
}

/* Theme toggle button */
.theme-toggle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--bg);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .2s;
  flex-shrink: 0;
}
.theme-toggle:hover {
  box-shadow: var(--shadow-out);
  transform: rotate(20deg);
}
.theme-toggle:active {
  box-shadow: var(--shadow-press);
  transform: rotate(0);
}

/* ── Ensure body bg changes with theme ─────────── */
[data-theme="dark"] body {
  background: var(--bg);
}
[data-theme="dark"] .auth-card,
[data-theme="dark"] .modal,
[data-theme="dark"] .card,
[data-theme="dark"] .stat-card,
[data-theme="dark"] .subject-card,
[data-theme="dark"] .question-card,
[data-theme="dark"] .sidebar-card,
[data-theme="dark"] .post-card,
[data-theme="dark"] .post-hero,
[data-theme="dark"] .post-body,
[data-theme="dark"] .comments-wrap,
[data-theme="dark"] .editor-card,
[data-theme="dark"] .review-item,
[data-theme="dark"] .sidebar-widget {
  border-color: rgba(60,70,100,0.4);
}
[data-theme="dark"] .form-input,
[data-theme="dark"] #content-editor,
[data-theme="dark"] .comment-form textarea {
  color: var(--text-prime);
}
[data-theme="dark"] .progress-bar-track {
  background: var(--bg-inset);
}

/* ── Keyboard key badges ─────────────── */
kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 5px;
  font-family: 'JetBrains Mono', monospace;
  font-size: .72rem;
  font-weight: 700;
  color: var(--text-sec);
  background: var(--bg-inset);
  box-shadow: var(--shadow-in);
  border-radius: 5px;
  line-height: 1;
}
[data-theme="dark"] kbd {
  color: var(--text-sec);
}

/* ── q-dot dark mode — already solid, ensure text stays white ── */
[data-theme="dark"] .q-dot.c { background: #1e9e55; }
[data-theme="dark"] .q-dot.w { background: #d90f37; }

/* ============================================================
   RESPONSIVE — Mobile & Tablet
   ============================================================ */

/* ── Navbar mobile ─────────────────────────────────────────── */
@media (max-width: 768px) {
  .navbar-inner { height: 56px; padding: 0 1rem; }
  .navbar-brand img { height: 30px; }
  .navbar-links { gap: .15rem; }
  .nav-link { padding: .35rem .55rem; font-size: .85rem; }
  .nav-btn  { padding: .35rem .7rem; }
  .theme-toggle { width: 34px; height: 34px; font-size: .95rem; }

  /* Hamburger — show/hide nav links on small screens */
  .navbar-links {
    position: fixed;
    top: 56px; left: 0; right: 0;
    background: var(--bg);
    box-shadow: 0 8px 24px rgba(0,0,0,.12);
    flex-direction: column;
    align-items: stretch;
    padding: .75rem 1rem 1rem;
    gap: .3rem;
    z-index: 99;
    transform: translateY(-110%);
    transition: transform .25s cubic-bezier(.4,0,.2,1);
    border-bottom: 1px solid var(--border);
  }
  .navbar-links.open { transform: translateY(0); }
  .nav-link { border-radius: var(--radius); padding: .6rem .9rem; font-size: 1rem; }
  .nav-btn  { border-radius: var(--radius); padding: .6rem .9rem; text-align: center; }
  .theme-toggle { display: none; } /* moved into menu */

  /* Hamburger button */
  .hamburger {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 36px; height: 36px;
    padding: 4px;
    background: var(--bg);
    box-shadow: var(--shadow-sm);
    border-radius: var(--radius);
    cursor: pointer;
    border: none;
    margin-left: .5rem;
  }
  .hamburger span {
    display: block; height: 2px;
    background: var(--text-prime);
    border-radius: 2px;
    transition: all .2s;
  }
  .hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
  .hamburger.open span:nth-child(2) { opacity: 0; }
  .hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
}
@media (min-width: 769px) {
  .hamburger { display: none; }
}

/* ── Container padding ─────────────────────────────────────── */
@media (max-width: 480px) {
  .container { padding: 0 .9rem; }
  .page-header { padding: 1.5rem 0 1.2rem; }
  .page-header h1 { font-size: 1.6rem; }
}

/* ── Stats grid ────────────────────────────────────────────── */
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: .7rem; }
  .stat-card { padding: 1.1rem; }
  .stat-value { font-size: 1.8rem; }
}

/* ── Subject cards ─────────────────────────────────────────── */
@media (max-width: 640px) {
  .subjects-grid { grid-template-columns: 1fr; gap: .8rem; }
}
@media (min-width: 641px) and (max-width: 900px) {
  .subjects-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ── Auth page ─────────────────────────────────────────────── */
@media (max-width: 480px) {
  .auth-card { padding: 1.5rem 1.1rem; border-radius: var(--radius-lg); }
  .hero-pills { display: none; } /* too cramped on phone */
}

/* ── Quiz layout ───────────────────────────────────────────── */
@media (max-width: 820px) {
  .quiz-layout { grid-template-columns: 1fr; gap: 1rem; padding: 1rem 0 2rem; }
  .quiz-sidebar { display: none; }
  /* Show mini progress bar instead */
  .quiz-mobile-bar {
    display: flex !important;
    align-items: center;
    gap: .75rem;
    padding: .6rem 1rem;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    font-size: .82rem;
    color: var(--text-sec);
  }
  .quiz-mobile-tally {
    display: flex;
    gap: .8rem;
    margin-left: auto;
    font-family: 'JetBrains Mono', monospace;
    font-size: .82rem;
    font-weight: 700;
  }
}
@media (min-width: 821px) {
  .quiz-mobile-bar { display: none; }
}

/* ── Question card on mobile ───────────────────────────────── */
@media (max-width: 600px) {
  .question-card { padding: 1.2rem 1rem; border-radius: var(--radius-lg); }
  .question-text { font-size: 1rem; }
  .answer-option { padding: .75rem .85rem; }
  .answer-text   { font-size: .93rem; }
  .quiz-actions  { flex-wrap: wrap; gap: .5rem; }
  .quiz-actions .btn { flex: 1; min-width: 120px; font-size: .9rem; padding: .6rem .8rem; }
}

/* ── Quiz header on mobile ─────────────────────────────────── */
@media (max-width: 600px) {
  .quiz-header-inner { padding: .5rem .9rem; }
  .quiz-subject-label { font-size: .88rem; }
  .quiz-progress-text { font-size: .78rem; }
}

/* ── Results ───────────────────────────────────────────────── */
@media (max-width: 540px) {
  .results-hero { padding: 1.5rem 0 1rem; }
  .score-ring-wrap { width: 140px; height: 140px; }
  .score-pct { font-size: 2.4rem; }
  .results-meta { gap: 1.2rem; }
  .results-meta-item .val { font-size: 1.2rem; }
  .review-item { padding: .9rem 1rem; }
}

/* ── History / Table ───────────────────────────────────────── */
@media (max-width: 700px) {
  .data-table { font-size: .82rem; }
  .data-table th, .data-table td { padding: .5rem .65rem; }
  /* Hide less important columns on small screens */
  .data-table .col-hide-sm { display: none; }
}

/* ── Modal ─────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .modal { padding: 1.5rem 1.1rem; border-radius: var(--radius-lg); }
  .modal h2 { font-size: 1.2rem; }
  .qty-btns { gap: .35rem; }
  .qty-btn  { padding: .45rem .8rem; font-size: .9rem; }
}

/* ── News grid ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  .news-grid { grid-template-columns: 1fr; }
  .news-sidebar { position: static; }
}

/* ── News post body ────────────────────────────────────────── */
@media (max-width: 600px) {
  .post-hero, .post-body, .comments-wrap { padding: 1.2rem 1rem; border-radius: var(--radius-lg); }
  .post-h1 { font-size: 1.5rem; }
}

/* ── Dashboard table on mobile ─────────────────────────────── */
@media (max-width: 600px) {
  .card { border-radius: var(--radius); }
  .flex-between { flex-direction: column; gap: .7rem; align-items: flex-start; }
}

/* ── Footer responsive ─────────────────────────────────────── */
@media (max-width: 700px) {
  .footer-inner { flex-direction: column; align-items: center; text-align: center; gap: .6rem; }
  .footer-copy, .footer-made { font-size: .8rem; }
}

/* ── Version badge ─────────────────────────────────────────── */
.footer-version {
  font-family: 'JetBrains Mono', monospace;
  font-size: .7rem;
  font-weight: 700;
  color: var(--text-dim);
  background: var(--bg-inset);
  box-shadow: var(--shadow-in);
  padding: .15rem .5rem;
  border-radius: var(--radius-pill);
  letter-spacing: .05em;
}

/* ── Touch targets — minimum 44px for mobile ───────────────── */
@media (max-width: 768px) {
  .btn { min-height: 44px; }
  .qty-btn { min-height: 40px; }
  .answer-option { min-height: 52px; }
  .nav-link { min-height: 44px; display: flex; align-items: center; }
}

/* ── Keyboard hint under question number ──────────────── */
.q-kbd-hint {
  font-size: .7rem;
  color: var(--text-dim);
  font-family: 'JetBrains Mono', monospace;
  margin-bottom: .5rem;
  letter-spacing: .03em;
}
@media (max-width: 600px) {
  .q-kbd-hint { display: none; } /* hide on touch devices */
}

/* ── Comment list scrollbar ───────────────────────────── */
#comments-list::-webkit-scrollbar { width: 4px; }
#comments-list::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 2px;
}

/* ── Comment avatar fix for dark mode ────────────────── */
[data-theme="dark"] .comment-avatar {
  box-shadow: var(--shadow-sm);
}

/* ── Question ID badge ────────────────────────────────── */
.q-id-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: .75rem;
  font-weight: 700;
  background: var(--bg-inset);
  box-shadow: var(--shadow-in);
  padding: .15rem .55rem;
  border-radius: var(--radius-pill);
  color: var(--red);
  letter-spacing: .04em;
}

/* ── Dashboard bottom widgets ─────────────────────────────── */
@media (max-width: 640px) {
  .dashboard-bottom-grid { grid-template-columns: 1fr !important; }
}
