/* iTestSeries PHP — Modern Dark Minimalist UI */

:root {
  --bg:         #0d1117;
  --bg-2:       #161b22;
  --bg-3:       #21262d;
  --border:     #30363d;
  --text:       #e6edf3;
  --text-muted: #8b949e;
  --accent:     #58a6ff;
  --accent-h:   #1f6feb;
  --green:      #3fb950;
  --red:        #f85149;
  --yellow:     #d29922;
  --purple:     #bc8cff;
  --radius:     8px;
  --shadow:     0 4px 24px rgba(0,0,0,.4);
  --font:       'Inter', system-ui, -apple-system, sans-serif;
  --mono:       'JetBrains Mono', 'Fira Code', monospace;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; color: #79c0ff; }

img { max-width: 100%; display: block; }

/* ── Scrollbar ─────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-2); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── Typography ────────────────────────────────────── */
h1,h2,h3,h4,h5,h6 { font-weight: 600; line-height: 1.25; color: var(--text); }
h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.2rem; }

.text-muted  { color: var(--text-muted); }
.text-accent { color: var(--accent); }
.text-green  { color: var(--green); }
.text-red    { color: var(--red); }
.text-yellow { color: var(--yellow); }

/* ── Layout ────────────────────────────────────────── */
.container { max-width: 1200px; margin: 0 auto; padding: 0 1.5rem; }
.container-sm { max-width: 640px; margin: 0 auto; padding: 0 1.5rem; }
.container-md { max-width: 860px; margin: 0 auto; padding: 0 1.5rem; }

.page-content { padding: 2rem 0; }

.grid { display: grid; gap: 1.5rem; }
.grid-2 { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }

.flex { display: flex; }
.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; }
.gap-3 { gap: 1.5rem; }

/* ── Navbar ────────────────────────────────────────── */
.navbar {
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.navbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
  gap: 1rem;
}
.navbar-brand {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text) !important;
  text-decoration: none;
  letter-spacing: -.5px;
}
.navbar-brand span { color: var(--accent); }

.navbar-nav {
  display: flex;
  align-items: center;
  gap: .25rem;
  list-style: none;
}
.navbar-nav a {
  padding: .4rem .75rem;
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: .9rem;
  transition: color .15s, background .15s;
}
.navbar-nav a:hover, .navbar-nav a.active {
  color: var(--text);
  background: var(--bg-3);
  text-decoration: none;
}

.navbar-actions { display: flex; gap: .5rem; align-items: center; }

/* ── Buttons ────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .5rem 1.1rem;
  border: none;
  border-radius: var(--radius);
  font-size: .9rem;
  font-weight: 500;
  cursor: pointer;
  transition: opacity .15s, background .15s, box-shadow .15s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; opacity: .9; }
.btn:active { transform: scale(.98); }

.btn-primary   { background: var(--accent);  color: #fff; }
.btn-primary:hover { background: var(--accent-h); opacity: 1; }
.btn-success   { background: var(--green);   color: #fff; }
.btn-danger    { background: var(--red);     color: #fff; }
.btn-ghost     { background: transparent;    color: var(--text-muted); border: 1px solid var(--border); }
.btn-ghost:hover { color: var(--text); border-color: var(--text-muted); background: var(--bg-3); opacity: 1; }
.btn-sm        { padding: .35rem .75rem; font-size: .8rem; }
.btn-lg        { padding: .75rem 1.75rem; font-size: 1rem; }
.btn-block     { width: 100%; justify-content: center; }
.btn[disabled] { opacity: .5; pointer-events: none; }

/* ── Cards ─────────────────────────────────────────── */
.card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 2px);
  overflow: hidden;
}
.image-card {
  background: #2e2e2e;
  border: 1px solid #444;
  border-radius: calc(var(--radius) + 2px);
  padding: 1rem;
  margin: 1rem 0;
  color: #fff;
}
.image-card img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0.75rem auto;
  border-radius: calc(var(--radius) - 2px);
  border: 1px solid #555;
}
.image-card p,
.image-card span,
.image-card div {
  color: #f5f5f5;
}
.option-label.image-card {
  display: block;
  padding: 0.75rem 0.85rem;
}
.card-body  { padding: 1.25rem; }
.card-header {
  padding: .85rem 1.25rem;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: .95rem;
}
.card-footer {
  padding: .85rem 1.25rem;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: .85rem;
}

.card-hover {
  transition: border-color .2s, box-shadow .2s, transform .2s;
  cursor: pointer;
}
.card-hover:hover {
  border-color: var(--accent-h);
  box-shadow: 0 0 0 1px var(--accent-h), var(--shadow);
  transform: translateY(-2px);
}

/* ── Forms ──────────────────────────────────────────── */
.form-group    { margin-bottom: 1.25rem; }
.form-label    { display: block; font-size: .85rem; font-weight: 500; margin-bottom: .35rem; color: var(--text-muted); }
.form-control  {
  width: 100%;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: .55rem .9rem;
  font-size: .9rem;
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}
.form-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(88,166,255,.15);
}
.form-control::placeholder { color: var(--text-muted); }
textarea.form-control { resize: vertical; min-height: 90px; }
select.form-control option { background: var(--bg-3); }

.form-check { display: flex; align-items: center; gap: .5rem; margin-bottom: .5rem; }
.form-check input[type=checkbox],
.form-check input[type=radio] { accent-color: var(--accent); width: 16px; height: 16px; cursor: pointer; }
.form-check-label { font-size: .9rem; cursor: pointer; }

.form-hint  { font-size: .78rem; color: var(--text-muted); margin-top: .3rem; }
.form-error { font-size: .78rem; color: var(--red); margin-top: .3rem; }

/* ── Alerts ──────────────────────────────────────────── */
.alert {
  padding: .8rem 1.1rem;
  border-radius: var(--radius);
  font-size: .9rem;
  margin-bottom: 1rem;
  border: 1px solid transparent;
  display: flex;
  align-items: flex-start;
  gap: .6rem;
}
.alert-info    { background: rgba(88,166,255,.1);  border-color: rgba(88,166,255,.3);  color: #79c0ff; }
.alert-success { background: rgba(63,185,80,.1);   border-color: rgba(63,185,80,.3);   color: var(--green); }
.alert-danger  { background: rgba(248,81,73,.1);   border-color: rgba(248,81,73,.3);   color: var(--red); }
.alert-warning { background: rgba(210,153,34,.1);  border-color: rgba(210,153,34,.3);  color: var(--yellow); }
.alert-close { margin-left: auto; cursor: pointer; opacity: .7; background: none; border: none; color: inherit; font-size: 1rem; }
.alert-close:hover { opacity: 1; }

/* ── Badges ──────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: .2em .55em;
  font-size: .72rem;
  font-weight: 600;
  border-radius: 4px;
  letter-spacing: .02em;
}
.badge-primary { background: rgba(88,166,255,.15);  color: var(--accent); }
.badge-green   { background: rgba(63,185,80,.15);   color: var(--green); }
.badge-red     { background: rgba(248,81,73,.15);   color: var(--red); }
.badge-yellow  { background: rgba(210,153,34,.15);  color: var(--yellow); }
.badge-muted   { background: var(--bg-3);           color: var(--text-muted); }
.badge-success { background: rgba(63,185,80,.15);   color: var(--green); }

/* ── Toggle Switch ───────────────────────────────────── */
.ts-wrap {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  cursor: pointer;
  user-select: none;
}
.ts-track {
  position: relative;
  width: 2.6rem;
  height: 1.35rem;
  border-radius: 99px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  transition: background .2s, border-color .2s;
  flex-shrink: 0;
}
.ts-track::after {
  content: '';
  position: absolute;
  top: .175rem;
  left: .175rem;
  width: .95rem;
  height: .95rem;
  border-radius: 50%;
  background: var(--text-muted);
  transition: transform .2s, background .2s;
}
.ts-wrap.is-on .ts-track {
  background: rgba(63,185,80,.25);
  border-color: var(--green);
}
.ts-wrap.is-on .ts-track::after {
  transform: translateX(1.25rem);
  background: var(--green);
}
.ts-wrap.is-loading .ts-track {
  opacity: .5;
  pointer-events: none;
}
.ts-label {
  font-size: .75rem;
  font-weight: 600;
  min-width: 2.5rem;
  color: var(--text-muted);
  transition: color .2s;
}
.ts-wrap.is-on .ts-label { color: var(--green); }


/* ── Tables ──────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: .75rem 1rem; text-align: left; border-bottom: 1px solid var(--border); }
th { color: var(--text-muted); font-weight: 500; font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; background: var(--bg-3); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,.02); }

/* ── Pagination ──────────────────────────────────────── */
.pagination { display: flex; gap: .25rem; align-items: center; flex-wrap: wrap; }
.page-link {
  padding: .4rem .8rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: .85rem;
  transition: all .15s;
  background: var(--bg-2);
}
.page-link:hover { color: var(--text); border-color: var(--accent); background: var(--bg-3); text-decoration: none; }
.page-link.active { background: var(--accent); color: #fff; border-color: var(--accent); pointer-events: none; }
.page-link.disabled { opacity: .4; pointer-events: none; }

/* ── Stats Cards ────────────────────────────────────── */
.stat-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 2px);
  padding: 1.25rem;
  text-align: center;
}
.stat-value { font-size: 2rem; font-weight: 700; color: var(--accent); line-height: 1; }
.stat-label { font-size: .8rem; color: var(--text-muted); margin-top: .3rem; text-transform: uppercase; letter-spacing: .05em; }

/* ── Test Series Card ───────────────────────────────── */
.series-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 2px);
  display: flex;
  flex-direction: column;
  transition: border-color .2s, transform .2s, box-shadow .2s;
  overflow: hidden;
}
.series-card:hover {
  border-color: rgba(88,166,255,.4);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,.3);
}
.series-card-banner {
  height: 6px;
  background: linear-gradient(90deg, var(--accent), var(--purple));
}
.series-card-body { padding: 1.25rem; flex: 1; }
.series-card-meta { padding: .85rem 1.25rem; border-top: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.series-title { font-size: 1rem; font-weight: 600; margin-bottom: .4rem; line-height: 1.35; }
.series-desc  { font-size: .85rem; color: var(--text-muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.series-tags  { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .7rem; }

/* ── Test List Item ─────────────────────────────────── */
.test-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .75rem;
}

/* ── Series Detail UI ─────────────────────────────── */
.series-detail-grid {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 1.5rem;
  align-items: start;
}
.desktop-sticky {
  position: sticky;
  top: 76px;
}
.mobile-top-enroll { display: none; }

/* ── Analytics Layout ─────────────────────────────── */
.analytics-layout {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 1.5rem;
  align-items: start;
}
.analytics-layout-equal {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  align-items: start;
}
.stats-grid {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
}

/* ── Quiz UI ────────────────────────────────────────── */
.quiz-layout { display: grid; grid-template-columns: 1fr 260px; gap: 1.5rem; min-height: calc(100vh - 60px); align-items: start; }
.quiz-layout > div:last-child { position: sticky; top: 76px; align-self: start; }
@media (max-width: 768px) { .quiz-layout { grid-template-columns: 1fr; } .quiz-layout > div:last-child { position: static; top: auto; } }

.question-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 2px);
  padding: 1.5rem;
}
.question-number { font-size: .8rem; color: var(--text-muted); margin-bottom: .5rem; }
.question-text   { font-size: 1.05rem; margin-bottom: 1.25rem; line-height: 1.6; }

.options-list { list-style: none; display: flex; flex-direction: column; gap: .5rem; }
.option-item {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  padding: .75rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.option-item:hover { border-color: var(--accent); background: rgba(88,166,255,.05); }
.option-item.selected { border-color: var(--accent); background: rgba(88,166,255,.1); }
.option-item.correct  { border-color: var(--green);  background: rgba(63,185,80,.1); }
.option-item.wrong    { border-color: var(--red);    background: rgba(248,81,73,.1); }
.option-label { flex: 1; font-size: .95rem; cursor: pointer; }

.question-nav-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
  gap: .3rem;
  max-height: 320px;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: .35rem;
  padding-bottom: .3rem;
}
.question-nav-grid::-webkit-scrollbar {
  width: 8px;
}
.question-nav-grid::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,.12);
  border-radius: 999px;
}
.progress-summary {
  display: flex;
  flex-wrap: nowrap;
  gap: .5rem;
  justify-content: space-between;
  align-items: center;
  overflow-x: auto;
  padding-bottom: .25rem;
}
.progress-summary div {
  flex: 1 1 auto;
  min-width: 110px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 2px);
  padding: .65rem .75rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 58px;
}
.progress-summary div strong {
  display: block;
  font-size: .95rem;
  margin-bottom: .15rem;
}
.progress-summary div span {
  color: var(--text-muted);
  font-size: .75rem;
  letter-spacing: .01em;
}
.progress-current {
  font-size: .85rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: .5rem;
  padding: .55rem .85rem;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.toggle-btn {
  width: 30px;
  height: 30px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-3);
  color: var(--text);
}
.timer-box {
  position: relative;
}
.timer-section {
  position: relative;
}
.timer-section .btn-toggle-timer {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 1;
}
.summary-header {
  display: flex;
  justify-content: flex-end;
  margin-bottom: .35rem;
}
.btn-toggle-progress {
  width: 30px;
  height: 30px;
}
.hidden {
  display: none !important;
}
.progress-summary div.answered { border-color: rgba(63,185,80,.35); }
.progress-summary div.flagged { border-color: rgba(210,153,34,.35); }
.progress-summary div.unanswered { border-color: rgba(210,210,210,.6); }
.progress-summary div.reviewed { border-color: rgba(88,166,255,.35); }
.progress-summary div.not-reviewed { border-color: rgba(153,153,153,.35); }
.q-nav-btn {
  aspect-ratio: 1;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-3);
  color: var(--text-muted);
  font-size: .8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.q-nav-btn:hover         { border-color: var(--accent); color: var(--accent); }
.q-nav-btn.answered      { background: rgba(63,185,80,.2);  border-color: var(--green);  color: var(--green); }
.q-nav-btn.flagged       { background: rgba(210,153,34,.2); border-color: var(--yellow); color: var(--yellow); }
.q-nav-btn.current       { border-color: var(--accent); background: rgba(88,166,255,.15); color: var(--accent); }
.q-nav-btn.unanswered    { }
.q-nav-indicator {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-3);
}
.q-nav-indicator.answered { background: rgba(63,185,80,.2); border-color: var(--green); }
.q-nav-indicator.flagged  { background: rgba(210,153,34,.2); border-color: var(--yellow); }
.q-nav-indicator.unanswered { background: var(--bg-3); }

/* ── Timer ──────────────────────────────────────────── */
.timer-box {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .55rem .8rem;
  text-align: center;
  margin-bottom: .75rem;
}
.timer-value { font-size: 1.35rem; font-weight: 700; font-family: var(--mono); color: var(--text); }
.timer-label { font-size: .7rem; color: var(--text-muted); text-transform: uppercase; }
.timer-box.warning .timer-value { color: var(--yellow); }
.timer-box.danger  .timer-value { color: var(--red); animation: pulse .5s infinite; }

@keyframes pulse { 0%,100%{ opacity:1 } 50%{ opacity:.5 } }

/* ── Result Page ────────────────────────────────────── */
.result-hero {
  text-align: center;
  padding: 2.5rem;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 4px);
  margin-bottom: 2rem;
}
.result-score {
  font-size: 4rem;
  font-weight: 800;
  line-height: 1;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.result-passed  { color: var(--green); }
.result-failed  { color: var(--red); }

.question-review {
  margin-bottom: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.question-review-header {
  padding: .75rem 1rem;
  background: var(--bg-3);
  font-size: .85rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.question-review-body { padding: 1rem; }
.explanation-box {
  margin-top: .75rem;
  padding: .75rem 1rem;
  background: rgba(88,166,255,.05);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: .85rem;
  color: var(--text-muted);
}

/* ── Hero Section ───────────────────────────────────── */
.hero {
  padding: 5rem 0 4rem;
  text-align: center;
}
.hero h1 { font-size: 3rem; font-weight: 800; margin-bottom: 1rem; letter-spacing: -.5px; }
.hero h1 span { color: var(--accent); }
.hero p { font-size: 1.15rem; color: var(--text-muted); max-width: 560px; margin: 0 auto 2rem; }

/* ── Footer ─────────────────────────────────────────── */
footer {
  margin-top: 4rem;
  padding: 2rem 0;
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--text-muted);
  font-size: .85rem;
}

/* ── Utilities ──────────────────────────────────────── */
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }

.py-1 { padding-top: .5rem; padding-bottom: .5rem; }
.py-2 { padding-top: 1rem; padding-bottom: 1rem; }
.py-3 { padding-top: 1.5rem; padding-bottom: 1.5rem; }

.text-center { text-align: center; }
.text-right  { text-align: right; }
.d-none      { display: none !important; }
.d-flex      { display: flex; }
.hidden      { display: none !important; }
.w-full      { width: 100%; }

.section-title {
  font-size: 1.3rem;
  font-weight: 600;
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
  margin-left: .75rem;
}

.divider { border: none; border-top: 1px solid var(--border); margin: 1.5rem 0; }

/* ── Responsive ─────────────────────────────────────── */

/* Prevent iOS zoom on input focus */
@media screen and (max-width: 768px) {
  input, select, textarea { font-size: 16px !important; }
}

/* Tablets & small laptops */
@media (max-width: 768px) {
  .container { padding: 0 1.25rem; }
  .page-content { padding: 1.5rem 0; }

  .hero { padding: 3rem 0 2.5rem; }
  .hero h1 { font-size: 2.2rem; }
  .hero p { font-size: 1rem; }
  .grid { gap: 1rem; }
  .grid-2 { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
  .grid-3 { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
  .grid-4 { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  
  .analytics-layout,
  .analytics-layout-equal {
    grid-template-columns: 1fr;
  }
  
  .series-detail-grid {
    grid-template-columns: 1fr;
  }
  .desktop-sticky {
    position: static;
  }
  .mobile-top-enroll {
    display: block;
    margin-bottom: 1.5rem;
  }
  .series-detail-sidebar {
    margin-top: 1.5rem;
  }

  .result-score { font-size: 3rem; }
  .stat-value { font-size: 1.75rem; }

  .series-card-meta { flex-direction: column; align-items: flex-start; }

  .pagination { justify-content: center; }

  .flex-between { flex-direction: column; gap: .75rem; }

  .progress-summary { flex-wrap: wrap; }
  .progress-summary div { min-width: calc(50% - .25rem); }

  footer > .container > div { flex-direction: column; text-align: center; }
  footer > .container > div > div { justify-content: center; }
}

/* Phones */
@media (max-width: 640px) {
  .navbar-nav {
    display: none;
    position: absolute;
    top: 60px;
    left: 0;
    right: 0;
    background: var(--bg-2);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    padding: .5rem 1rem;
    gap: .15rem;
    z-index: 99;
    box-shadow: 0 8px 24px rgba(0,0,0,.3);
  }
  .navbar-nav.open {
    display: flex;
  }
  .navbar-nav a {
    display: block;
    padding: .7rem .75rem;
    font-size: .95rem;
    width: 100%;
  }
  #nav-toggle {
    display: inline-flex !important;
  }

  .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: 1fr; }

  .hero { padding: 3rem 0 2.5rem; }
  .hero h1 { font-size: 1.75rem; }
  .hero p { font-size: .95rem; }

  .container { padding: 0 1rem; }
  .page-content { padding: 1.25rem 0; }

  .result-score { font-size: 2.5rem; }
  .stat-value { font-size: 1.5rem; }

  .series-card-meta { flex-direction: column; align-items: flex-start; }
  .pagination { justify-content: center; }
  .flex-between { flex-direction: column; gap: .75rem; }

  .progress-summary { flex-wrap: wrap; }
  .progress-summary div { min-width: calc(50% - .25rem); }

  /* Make touch targets at least 44px */
  .btn, .navbar-nav a, .page-link, .option-item, .q-nav-btn {
    min-height: 44px;
  }
  .btn-sm { min-height: 36px; }

  /* Stack filter/search forms */
  .flex-between form,
  .flex-between .d-flex {
    width: 100%;
  }
  .flex-between form .form-control,
  .flex-between .d-flex .form-control {
    width: 100%;
  }

  /* Table improvements for mobile */
  .table-wrap table { font-size: .8rem; }
  .table-wrap th,
  .table-wrap td {
    padding: .5rem .6rem;
    white-space: nowrap;
  }

  /* Page headers */
  .section-title { font-size: 1.1rem; }

  /* Footer */
  footer > .container > div { flex-direction: column; text-align: center; }
  footer > .container > div > div { justify-content: center; }

  /* Stats cards */
  .stat-card { padding: 1rem; }

  /* Quiz question nav */
  .question-nav-grid {
    grid-template-columns: repeat(auto-fill, minmax(36px, 1fr));
    max-height: 240px;
  }

  /* Series detail page — stack sidebar below content on mobile */
  .mobile-top-enroll {
    display: block;
    margin-bottom: 1.5rem;
  }
  .series-detail-sidebar {
    position: static;
    margin-top: 1.5rem;
    margin-bottom: 1.5rem;
  }
  .series-detail-sidebar .card {
    border: 1px solid var(--border);
    box-shadow: 0 2px 12px rgba(0,0,0,.15);
  }
  .series-detail-sidebar .btn-block {
    width: 100%;
    min-height: 48px;
    font-size: 1rem;
  }
  .series-detail-desc {
    padding: 1.25rem !important;
  }
  .series-detail-grid .grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }
  .test-list-item {
    flex-direction: column;
    align-items: stretch;
  }
  .test-list-item > div {
    text-align: left;
  }
  .test-list-item .btn,
  .test-list-item span.btn {
    width: 100%;
    text-align: center;
  }
}

/* Small phones */
@media (max-width: 480px) {
  .hero { padding: 2rem 0 1.5rem; }
  .hero h1 { font-size: 1.4rem; }
  .hero p { font-size: .88rem; }

  .container { padding: 0 .75rem; }
  .page-content { padding: 1rem 0; }

  .result-score { font-size: 2rem; }
  .stat-value { font-size: 1.25rem; }

  .card-body { padding: 1rem; }
  .card-header { padding: .7rem 1rem; }

  .btn { padding: .45rem .9rem; font-size: .85rem; }
  .btn-sm { padding: .3rem .65rem; font-size: .75rem; }

  .table-wrap th,
  .table-wrap td {
    padding: .4rem .5rem;
    font-size: .75rem;
  }

  .navbar-brand { font-size: 1.1rem; }

  .progress-summary div { min-width: 100%; }

  .question-nav-grid {
    grid-template-columns: repeat(auto-fill, minmax(32px, 1fr));
    max-height: 200px;
  }

  .quiz-layout { gap: 1rem; }
  .question-card { padding: 1rem; }
  .option-item { padding: .6rem .75rem; }
  .option-label { font-size: .88rem; }
}

/* ── Loading spinner ────────────────────────────────── */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .6s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Toast notifications ────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.toast {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .75rem 1.1rem;
  min-width: 280px;
  max-width: 380px;
  font-size: .9rem;
  box-shadow: var(--shadow);
  animation: slide-up .2s ease;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.toast.success { border-left: 3px solid var(--green); }
.toast.error   { border-left: 3px solid var(--red); }
.toast.info    { border-left: 3px solid var(--accent); }
.toast.warning { border-left: 3px solid var(--yellow); }
@keyframes slide-up { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:translateY(0); } }

/* ── Legal / Policy pages (Terms, Privacy) ───────────────────── */
.legal-page .card-header {
  font-size: 1rem;
  font-weight: 600;
}
.legal-page .card-body p,
.legal-page .card-body li {
  line-height: 1.65;
}
.legal-page .card-body ul {
  display: grid;
  gap: 0.45rem;
  margin: 0.5rem 0 0;
  padding-left: 1.25rem;
  list-style-position: outside;
}
.legal-page .grid {
  gap: 1rem;
}
