/* ═══════════════════════════════════════════════════════
   MCQ Hub — Dark Academic Theme
   ═══════════════════════════════════════════════════════ */
@import url('https://fonts.googleapis.com/css2?family=Syne:wght@400;600;700;800&family=Literata:ital,wght@0,300;0,400;0,500;1,400&family=DM+Mono:wght@400;500&display=swap');

:root {
  --bg:     #0c0e14;
  --bg2:    #12151f;
  --bg3:    #181c28;
  --border: #232840;
  --border2:#2e3450;
  --text:   #e8eaf0;
  --muted:  #7a82a0;
  --gold:   #e8b84b;
  --gold2:  #f5d07a;
  --blue:   #4b7cf0;
  --blue2:  #7aa4f8;
  --green:  #34c78a;
  --red:    #e85555;
  --purple: #9b6cf0;
  --radius: 12px;
  --rad-sm: 8px;
  --trans:  .18s ease;
  --font:   'Syne', system-ui, sans-serif;
  --serif:  'Literata', Georgia, serif;
  --mono:   'DM Mono', monospace;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  min-height: 100vh;
}
a { color: var(--blue2); text-decoration: none; }
img { max-width: 100%; height: auto; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--bg2); }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 99px; }

/* ── Typography ── */
h1,h2,h3,h4 { font-weight: 700; line-height: 1.25; }
.serif { font-family: var(--serif); }
.mono  { font-family: var(--mono); }
small  { font-size: .8em; }

/* ══════════════════════════════════════
   LAYOUT
   ══════════════════════════════════════ */
#app { display: flex; flex-direction: column; min-height: 100vh; }
.page { display: none; flex: 1; }
.page.active { display: block; }
.container { max-width: 1140px; margin: 0 auto; padding: 0 20px; }
.section { padding: 40px 0; }

/* ══════════════════════════════════════
   NAVBAR
   ══════════════════════════════════════ */
#navbar {
  background: rgba(12,14,20,.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 200;
}
.navbar-inner {
  display: flex; align-items: center; gap: 24px;
  max-width: 1140px; margin: 0 auto; padding: 0 20px;
  height: 60px;
}
.logo {
  font-weight: 800; font-size: 1.2rem; color: var(--gold);
  letter-spacing: -.5px; cursor: pointer;
}
.logo span { color: var(--text); }
.nav-links { display: flex; gap: 4px; flex: 1; }
.nav-link {
  padding: 6px 14px; border-radius: var(--rad-sm);
  color: var(--muted); font-size: .88rem; font-weight: 600;
  cursor: pointer; transition: all var(--trans); border: none;
  background: transparent;
}
.nav-link:hover { color: var(--text); background: var(--bg3); }
.nav-link.active { color: var(--gold); background: rgba(232,184,75,.1); }
.nav-right { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.avatar-btn {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 99px; padding: 4px 12px 4px 4px;
  cursor: pointer; transition: all var(--trans);
}
.avatar-btn:hover { border-color: var(--border2); }
.avatar-btn img { width: 32px; height: 32px; border-radius: 50%; }
.avatar-btn .alias { font-size: .82rem; font-weight: 600; color: var(--text); }

/* ══════════════════════════════════════
   AUTH SCREEN
   ══════════════════════════════════════ */
#auth-screen {
  display: none; position: fixed; inset: 0; z-index: 999;
  background: var(--bg);
  align-items: center; justify-content: center;
}
#auth-screen.show { display: flex; }
.auth-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 20px; padding: 44px 40px; width: 100%; max-width: 420px;
  text-align: center;
}
.auth-logo { font-size: 2rem; font-weight: 800; color: var(--gold); margin-bottom: 6px; }
.auth-logo span { color: var(--text); }
.auth-sub { color: var(--muted); margin-bottom: 32px; font-size: .92rem; }
.auth-card .form-group { margin-bottom: 18px; text-align: left; }
.auth-card label { font-size: .82rem; color: var(--muted); font-weight: 600; margin-bottom: 6px; display: block; }

/* ══════════════════════════════════════
   BUTTONS
   ══════════════════════════════════════ */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 20px; border-radius: var(--rad-sm);
  font-weight: 700; font-size: .9rem; cursor: pointer;
  border: none; transition: all var(--trans); font-family: var(--font);
  white-space: nowrap;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--gold); color: #1a1200; }
.btn-primary:hover:not(:disabled) { background: var(--gold2); transform: translateY(-1px); }
.btn-blue { background: var(--blue); color: #fff; }
.btn-blue:hover:not(:disabled) { background: var(--blue2); }
.btn-secondary { background: var(--bg3); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { border-color: var(--border2); background: var(--border); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover:not(:disabled) { color: var(--text); background: var(--bg3); }
.btn-danger { background: rgba(232,85,85,.15); color: var(--red); border: 1px solid rgba(232,85,85,.3); }
.btn-danger:hover:not(:disabled) { background: rgba(232,85,85,.25); }
.btn-sm { padding: 5px 12px; font-size: .8rem; }
.btn-xs { padding: 3px 9px; font-size: .76rem; }
.btn-full { width: 100%; justify-content: center; }
.btn-icon { padding: 8px; }

/* ══════════════════════════════════════
   INPUTS
   ══════════════════════════════════════ */
.input, input[type="text"], input[type="email"], input[type="number"],
textarea, select {
  width: 100%; background: var(--bg3);
  border: 1px solid var(--border); border-radius: var(--rad-sm);
  color: var(--text); font-size: .9rem; font-family: var(--font);
  padding: 10px 14px; transition: border-color var(--trans);
  outline: none;
}
.input:focus, input:focus, textarea:focus, select:focus {
  border-color: var(--blue);
}
textarea { resize: vertical; min-height: 80px; }
select option { background: var(--bg3); color: var(--text); }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: .82rem; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.form-row { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
.form-row.cols3 { grid-template-columns: 1fr 1fr 1fr; }
.input-hint { font-size: .76rem; color: var(--muted); margin-top: 4px; }

/* ══════════════════════════════════════
   CARDS
   ══════════════════════════════════════ */
.card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px; transition: border-color var(--trans);
}
.card:hover { border-color: var(--border2); }
.card-sm { padding: 14px 18px; }

/* ══════════════════════════════════════
   BADGES / TAGS
   ══════════════════════════════════════ */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 99px;
  font-size: .76rem; font-weight: 700;
}
.badge-easy   { background: rgba(52,199,138,.15); color: var(--green); }
.badge-medium { background: rgba(232,184,75,.15);  color: var(--gold); }
.badge-hard   { background: rgba(232,85,85,.15);   color: var(--red); }
.badge-blue   { background: rgba(75,124,240,.15);  color: var(--blue2); }
.badge-purple { background: rgba(155,108,240,.15); color: var(--purple); }
.badge-gray   { background: var(--bg3); color: var(--muted); border: 1px solid var(--border); }

/* ══════════════════════════════════════
   DASHBOARD
   ══════════════════════════════════════ */
.dash-hero {
  background: linear-gradient(135deg, var(--bg2) 0%, #151828 100%);
  border-bottom: 1px solid var(--border);
  padding: 48px 0 36px;
}
.dash-hero h1 { font-size: 2.2rem; font-weight: 800; }
.dash-hero h1 span { color: var(--gold); }
.dash-hero p { color: var(--muted); margin-top: 8px; font-size: 1rem; }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px,1fr)); gap: 14px; margin-top: 28px; }
.stat-card {
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; text-align: center;
}
.stat-card .stat-val { font-size: 2rem; font-weight: 800; color: var(--gold); font-family: var(--mono); }
.stat-card .stat-lbl { font-size: .78rem; color: var(--muted); margin-top: 4px; }
.recent-section { margin-top: 36px; }
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.section-header h2 { font-size: 1.1rem; font-weight: 700; }

/* ══════════════════════════════════════
   SET CARD (library / dashboard)
   ══════════════════════════════════════ */
.sets-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(280px,1fr)); gap: 18px; }
.set-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
  cursor: pointer; transition: all var(--trans); position: relative;
}
.set-card:hover { border-color: var(--gold); transform: translateY(-2px); box-shadow: 0 8px 30px rgba(0,0,0,.3); }
.set-card-top { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 10px; }
.set-card h3 { font-size: 1rem; font-weight: 700; color: var(--text); flex: 1; line-height: 1.35; }
.set-card-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 12px; }
.set-card-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 14px; }
.set-card-foot .q-count { font-size: .82rem; color: var(--muted); font-family: var(--mono); }
.set-card-author { display: flex; align-items: center; gap: 6px; font-size: .78rem; color: var(--muted); }
.set-card-author img { width: 22px; height: 22px; border-radius: 50%; }

/* ══════════════════════════════════════
   LIBRARY FILTERS
   ══════════════════════════════════════ */
.library-bar {
  display: flex; gap: 10px; flex-wrap: wrap;
  padding: 20px 0; border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}
.library-bar input { max-width: 260px; }
.library-bar select { max-width: 180px; }

/* ══════════════════════════════════════
   SET DETAIL
   ══════════════════════════════════════ */
.set-detail-header {
  background: var(--bg2); border-bottom: 1px solid var(--border);
  padding: 32px 0;
}
.set-detail-header h1 { font-size: 1.7rem; }
.set-meta-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.set-actions { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.q-list { display: flex; flex-direction: column; gap: 18px; margin-top: 24px; }

/* ── Question card ── */
.question-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px; transition: border-color var(--trans);
}
.question-card:hover { border-color: var(--border2); }
.q-header { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.q-number {
  background: var(--gold); color: #1a1200; font-weight: 800;
  font-size: .8rem; padding: 3px 11px; border-radius: 99px;
}
.q-type-tag { font-size: .75rem; color: var(--muted); }
.q-text {
  font-family: var(--serif); font-size: 1rem; color: var(--text);
  line-height: 1.8; margin-bottom: 18px;
}
.q-text img { max-width: 100%; border-radius: 8px; margin: 10px 0; display: block; }
.q-img { max-width: 100%; border-radius: 8px; margin-bottom: 16px; display: block; max-height: 300px; object-fit: contain; }

/* ── Options ── */
.options-list { display: flex; flex-direction: column; gap: 8px; }
.option-item {
  display: flex; align-items: flex-start; gap: 12px;
  border: 1.5px solid var(--border); border-radius: var(--rad-sm);
  padding: 12px 14px; transition: all var(--trans); background: var(--bg3);
}
.option-item.correct { border-color: var(--green); background: rgba(52,199,138,.08); }
.option-item.wrong   { border-color: var(--red);   background: rgba(232,85,85,.08); }
.opt-label {
  font-weight: 800; font-size: .95rem; min-width: 26px;
  color: var(--muted); flex-shrink: 0; padding-top: 2px;
  font-family: var(--mono);
}
.option-item.correct .opt-label { color: var(--green); }
.option-item.wrong   .opt-label { color: var(--red); }
.opt-body { flex: 1; min-width: 0; }
.opt-text { font-family: var(--serif); font-size: .95rem; line-height: 1.65; }
.opt-img { max-width: 100%; max-height: 150px; border-radius: 6px; margin-top: 6px; display: block; }
.stat-bar-wrap { margin-top: 8px; }
.stat-bar-row { display: flex; align-items: center; gap: 8px; }
.stat-bar-bg { flex: 1; height: 5px; background: var(--border); border-radius: 99px; overflow: hidden; }
.stat-bar-fill { height: 100%; background: var(--gold); border-radius: 99px; transition: width .5s ease; }
.stat-bar-pct { font-size: .72rem; color: var(--muted); font-family: var(--mono); min-width: 38px; }
.correct-badge {
  font-size: .72rem; font-weight: 700; color: var(--green);
  background: rgba(52,199,138,.15); padding: 2px 8px; border-radius: 99px; margin-top: 5px; display: inline-block;
}

/* ── Solution section ── */
.solution-section { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--border); }
.solution-section h4 { font-size: .85rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 12px; }
.no-solution {
  color: var(--muted); font-size: .9rem; text-align: center;
  padding: 20px; background: var(--bg3); border-radius: var(--rad-sm);
  border: 1px dashed var(--border);
}
.solution-card {
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--rad-sm); padding: 16px; margin-bottom: 10px;
}
.solution-card-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.solution-card-head img { width: 24px; height: 24px; border-radius: 50%; }
.solution-author { font-size: .8rem; font-weight: 700; color: var(--muted); }
.solution-body { font-family: var(--serif); font-size: .95rem; line-height: 1.75; }
.solution-body img { max-width: 100%; border-radius: 8px; margin: 8px 0; }
.solution-votes { display: flex; gap: 8px; margin-top: 10px; }
.vote-btn {
  display: flex; align-items: center; gap: 4px;
  background: transparent; border: 1px solid var(--border);
  border-radius: 99px; padding: 3px 10px; font-size: .78rem;
  color: var(--muted); cursor: pointer; font-family: var(--font);
  transition: all var(--trans);
}
.vote-btn:hover { border-color: var(--border2); color: var(--text); }
.vote-btn.active-up   { border-color: var(--green); color: var(--green); }
.vote-btn.active-down { border-color: var(--red);   color: var(--red); }
.add-solution-form { margin-top: 14px; }
.add-solution-form textarea { margin-bottom: 8px; }

/* ── Comments ── */
.comments-section { margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--border); }
.comment-item { display: flex; gap: 10px; margin-bottom: 14px; }
.comment-item img { width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0; }
.comment-body { flex: 1; }
.comment-author { font-size: .78rem; font-weight: 700; color: var(--muted); margin-bottom: 4px; }
.comment-text { font-size: .9rem; color: var(--text); line-height: 1.6; }
.comment-actions { display: flex; gap: 8px; margin-top: 5px; }
.comment-action-btn { font-size: .75rem; color: var(--muted); background: none; border: none; cursor: pointer; padding: 0; font-family: var(--font); }
.comment-action-btn:hover { color: var(--text); }
.comment-replies { margin-left: 38px; margin-top: 10px; padding-left: 12px; border-left: 2px solid var(--border); }
.reply-form { margin-top: 8px; }
.reply-form input { margin-bottom: 6px; }

/* ══════════════════════════════════════
   UPLOAD
   ══════════════════════════════════════ */
.upload-page { max-width: 780px; margin: 0 auto; padding: 36px 20px; }
.upload-page h1 { font-size: 1.6rem; margin-bottom: 4px; }
.upload-page .subtitle { color: var(--muted); margin-bottom: 32px; }
.steps-indicator { display: flex; gap: 0; margin-bottom: 32px; }
.step-item {
  flex: 1; display: flex; align-items: center; gap: 8px;
  padding: 12px 16px;
  background: var(--bg3); border: 1px solid var(--border);
  font-size: .82rem; font-weight: 600; color: var(--muted);
}
.step-item:first-child { border-radius: var(--rad-sm) 0 0 var(--rad-sm); }
.step-item:last-child  { border-radius: 0 var(--rad-sm) var(--rad-sm) 0; }
.step-item.active  { background: rgba(232,184,75,.1); border-color: var(--gold); color: var(--gold); }
.step-item.done    { background: rgba(52,199,138,.08); border-color: var(--green); color: var(--green); }
.step-num { font-weight: 800; font-family: var(--mono); }
.dropzone {
  border: 2px dashed var(--border2); border-radius: var(--radius);
  padding: 60px 30px; text-align: center; cursor: pointer;
  transition: all var(--trans); background: var(--bg2);
}
.dropzone:hover, .dropzone.drag-over {
  border-color: var(--gold); background: rgba(232,184,75,.05);
}
.dropzone-icon { font-size: 3rem; margin-bottom: 12px; }
.dropzone h3 { font-size: 1.1rem; margin-bottom: 6px; }
.dropzone p  { color: var(--muted); font-size: .88rem; }
.file-list { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.file-item {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg3); border: 1px solid var(--border); border-radius: var(--rad-sm); padding: 10px 14px;
}
.file-item-icon { font-size: 1.3rem; }
.file-item-name { flex: 1; font-size: .88rem; font-weight: 600; }
.file-item-size { font-size: .76rem; color: var(--muted); font-family: var(--mono); }
.file-item-rm { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 1rem; padding: 0 4px; }
.file-item-rm:hover { color: var(--red); }

/* ── Preview table ── */
.preview-section { margin-top: 28px; }
.preview-section h3 { font-size: 1rem; margin-bottom: 14px; }
.q-preview-card {
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--rad-sm); padding: 14px 16px; margin-bottom: 10px;
}
.q-preview-card:hover { border-color: var(--border2); }
.q-preview-header { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.q-preview-text { font-family: var(--serif); font-size: .92rem; color: var(--text); line-height: 1.6; }
.q-preview-opts { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.q-preview-opt {
  font-size: .78rem; padding: 3px 9px; border-radius: 99px;
  border: 1px solid var(--border); color: var(--muted);
}
.q-preview-opt.correct { border-color: var(--green); color: var(--green); background: rgba(52,199,138,.1); }

/* ── Mixed tag UI ── */
.mixed-tag-row {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  padding: 10px 14px; background: var(--bg3); border-radius: var(--rad-sm);
  border: 1px solid var(--border); margin-bottom: 8px;
}
.mixed-tag-row .q-short { flex: 1; font-size: .88rem; font-family: var(--serif); color: var(--muted); }
.mixed-tag-row select { max-width: 140px; padding: 5px 10px; font-size: .8rem; }

/* ══════════════════════════════════════
   TEST PAGE (fullscreen)
   ══════════════════════════════════════ */
#test-page {
  display: none; position: fixed; inset: 0; z-index: 500;
  background: var(--bg); flex-direction: column;
}
#test-page.active { display: flex; }
.test-topbar {
  background: var(--bg2); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 16px; padding: 0 20px;
  height: 56px; flex-shrink: 0;
}
.test-topbar h2 { font-size: 1rem; font-weight: 700; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.test-timer {
  font-family: var(--mono); font-size: 1.1rem; font-weight: 700;
  color: var(--gold); padding: 6px 14px;
  background: rgba(232,184,75,.1); border-radius: var(--rad-sm);
}
.test-timer.danger { color: var(--red); background: rgba(232,85,85,.15); animation: timerPulse 1s infinite; }
@keyframes timerPulse { 0%,100%{opacity:1} 50%{opacity:.5} }
.test-body { display: flex; flex: 1; overflow: hidden; }
.test-sidebar {
  width: 220px; background: var(--bg2); border-right: 1px solid var(--border);
  padding: 16px; overflow-y: auto; flex-shrink: 0;
}
.test-sidebar h3 { font-size: .78rem; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin-bottom: 12px; }
.q-nav-grid { display: grid; grid-template-columns: repeat(5,1fr); gap: 4px; }
.q-nav-btn {
  aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
  background: var(--bg3); border: 1.5px solid var(--border);
  border-radius: var(--rad-sm); font-size: .78rem; font-weight: 700;
  cursor: pointer; transition: all var(--trans); font-family: var(--mono);
  color: var(--muted);
}
.q-nav-btn:hover   { border-color: var(--border2); color: var(--text); }
.q-nav-btn.current { border-color: var(--gold); color: var(--gold); background: rgba(232,184,75,.1); }
.q-nav-btn.answered{ border-color: var(--blue); color: var(--blue2); background: rgba(75,124,240,.1); }
.q-nav-btn.marked  { border-color: var(--purple); color: var(--purple); }
.test-main { flex: 1; overflow-y: auto; padding: 28px 32px; }
.test-q-header { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.test-q-text { font-family: var(--serif); font-size: 1.08rem; line-height: 1.85; margin-bottom: 22px; }
.test-q-text img { max-width: 100%; border-radius: 8px; margin: 10px 0; display: block; }
.test-options { display: flex; flex-direction: column; gap: 10px; }
.test-option {
  display: flex; align-items: flex-start; gap: 14px;
  border: 2px solid var(--border); border-radius: var(--rad-sm);
  padding: 14px 16px; cursor: pointer; transition: all var(--trans);
  background: var(--bg2); user-select: none;
}
.test-option:hover { border-color: var(--border2); background: var(--bg3); }
.test-option.selected { border-color: var(--blue); background: rgba(75,124,240,.12); }
.test-option.selected .opt-label { color: var(--blue2); }
.test-opt-key {
  font-family: var(--mono); font-weight: 800; color: var(--muted);
  font-size: 1rem; min-width: 28px; flex-shrink: 0; padding-top: 1px;
}
.test-option.selected .test-opt-key { color: var(--blue2); }
.test-opt-content { flex: 1; font-family: var(--serif); font-size: 1rem; line-height: 1.7; }
.test-opt-img { max-width: 100%; max-height: 160px; border-radius: 6px; margin-top: 8px; display: block; }
.test-footer {
  background: var(--bg2); border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
  padding: 12px 20px; flex-shrink: 0; flex-wrap: wrap;
}
.test-progress { flex: 1; }
.test-prog-bar { width: 100%; height: 5px; background: var(--border); border-radius: 99px; overflow: hidden; }
.test-prog-fill { height: 100%; background: linear-gradient(90deg,var(--blue),var(--gold)); transition: width .3s ease; }
.test-prog-text { font-size: .75rem; color: var(--muted); margin-top: 4px; }

/* ══════════════════════════════════════
   RESULTS
   ══════════════════════════════════════ */
.results-hero { text-align: center; padding: 48px 20px 32px; }
.score-ring-wrap { width: 140px; height: 140px; margin: 0 auto 20px; position: relative; }
.score-ring-wrap svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.score-ring-bg  { fill: none; stroke: var(--bg3); stroke-width: 10; }
.score-ring-val { fill: none; stroke: var(--gold); stroke-width: 10; stroke-linecap: round; transition: stroke-dashoffset 1s ease; }
.score-center {
  position: absolute; inset: 0; display: flex;
  flex-direction: column; align-items: center; justify-content: center;
}
.score-pct { font-size: 2rem; font-weight: 800; color: var(--gold); font-family: var(--mono); }
.score-frac { font-size: .82rem; color: var(--muted); }
.results-stats { display: grid; grid-template-columns: repeat(auto-fill,minmax(140px,1fr)); gap: 12px; max-width: 600px; margin: 24px auto; }
.results-review { max-width: 860px; margin: 0 auto; padding: 0 20px 60px; }
.review-q {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px; margin-bottom: 16px;
}
.review-q.correct { border-left: 4px solid var(--green); }
.review-q.wrong   { border-left: 4px solid var(--red); }
.review-q.skipped { border-left: 4px solid var(--muted); }

/* ══════════════════════════════════════
   ADMIN
   ══════════════════════════════════════ */
.admin-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 24px; }
.admin-tab {
  padding: 10px 18px; border: none; background: transparent;
  color: var(--muted); font-weight: 600; font-size: .88rem;
  cursor: pointer; font-family: var(--font); border-bottom: 2px solid transparent;
  transition: all var(--trans); margin-bottom: -1px;
}
.admin-tab.active { color: var(--gold); border-bottom-color: var(--gold); }
.admin-panel { display: none; }
.admin-panel.active { display: block; }
.admin-stats-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(160px,1fr)); gap: 14px; margin-bottom: 28px; }
.admin-stat {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; text-align: center;
}
.admin-stat-val { font-size: 2.2rem; font-weight: 800; color: var(--blue2); font-family: var(--mono); }
.admin-stat-lbl { font-size: .78rem; color: var(--muted); margin-top: 5px; }
.data-table { width: 100%; border-collapse: collapse; font-size: .86rem; }
.data-table th { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .4px; }
.data-table td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg3); }

/* ══════════════════════════════════════
   MODALS
   ══════════════════════════════════════ */
.modal-overlay {
  display: none; position: fixed; inset: 0; z-index: 800;
  background: rgba(0,0,0,.7); backdrop-filter: blur(4px);
  align-items: center; justify-content: center; padding: 20px;
}
.modal-overlay.show { display: flex; }
.modal {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 18px; width: 100%; max-width: 540px;
  max-height: 90vh; overflow-y: auto;
  box-shadow: 0 24px 60px rgba(0,0,0,.5);
}
.modal-lg { max-width: 700px; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px 0; margin-bottom: 18px;
}
.modal-header h3 { font-size: 1.1rem; font-weight: 700; }
.modal-close {
  background: var(--bg3); border: 1px solid var(--border);
  width: 32px; height: 32px; border-radius: 99px; cursor: pointer;
  color: var(--muted); font-size: 1.1rem; display: flex;
  align-items: center; justify-content: center; transition: all var(--trans);
}
.modal-close:hover { color: var(--text); border-color: var(--border2); }
.modal-body { padding: 0 24px 24px; }

/* ══════════════════════════════════════
   TOAST
   ══════════════════════════════════════ */
#toast-container {
  position: fixed; bottom: 24px; right: 24px; z-index: 9000;
  display: flex; flex-direction: column; gap: 8px; max-width: 340px;
}
.toast {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--rad-sm); padding: 12px 16px;
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
  display: flex; align-items: center; gap: 10px;
  animation: slideIn .25s ease;
  font-size: .88rem;
}
@keyframes slideIn { from { transform: translateX(30px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.toast-icon { font-size: 1.1rem; flex-shrink: 0; }
.toast-text { flex: 1; color: var(--text); line-height: 1.4; }
.toast.success { border-color: var(--green); }
.toast.error   { border-color: var(--red); }
.toast.info    { border-color: var(--blue); }
.toast.warning { border-color: var(--gold); }

/* ══════════════════════════════════════
   MISC
   ══════════════════════════════════════ */
.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
.empty-state { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty-state .icon { font-size: 3rem; margin-bottom: 14px; }
.empty-state h3 { font-size: 1.1rem; color: var(--text); margin-bottom: 8px; }
.loading { display: flex; align-items: center; justify-content: center; padding: 40px; color: var(--muted); gap: 10px; }
.spinner {
  width: 22px; height: 22px; border: 2.5px solid var(--border);
  border-top-color: var(--gold); border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.toggle-switch { position: relative; width: 44px; height: 24px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-track {
  position: absolute; inset: 0; background: var(--border2);
  border-radius: 99px; cursor: pointer; transition: background var(--trans);
}
.toggle-track::after {
  content: ''; position: absolute; width: 18px; height: 18px;
  border-radius: 50%; background: #fff; top: 3px; left: 3px;
  transition: left var(--trans);
}
.toggle-switch input:checked ~ .toggle-track { background: var(--gold); }
.toggle-switch input:checked ~ .toggle-track::after { left: 23px; }
.pagination { display: flex; gap: 6px; align-items: center; justify-content: center; margin-top: 28px; }
.page-btn {
  min-width: 36px; height: 36px; display: flex; align-items: center; justify-content: center;
  border-radius: var(--rad-sm); border: 1px solid var(--border);
  background: var(--bg2); color: var(--muted); cursor: pointer;
  font-family: var(--mono); font-size: .85rem; transition: all var(--trans);
}
.page-btn:hover { border-color: var(--border2); color: var(--text); }
.page-btn.active { background: var(--gold); color: #1a1200; border-color: var(--gold); font-weight: 700; }
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 99px; font-size: .75rem; font-weight: 600;
  background: var(--bg3); border: 1px solid var(--border); color: var(--muted);
}

/* KaTeX overrides */
.katex { font-size: 1em !important; }
.katex-display { overflow-x: auto; overflow-y: hidden; padding: 6px 0; }
mjx-container, math { display: inline !important; }

/* ── Responsive ── */
@media (max-width: 768px) {
  .form-row, .form-row.cols3 { grid-template-columns: 1fr; }
  .test-sidebar { display: none; }
  .nav-links .nav-link span { display: none; }
  .sets-grid { grid-template-columns: 1fr; }
  .test-main { padding: 16px; }
}
