/**
 * @file public/css/layout.css
 * @description Page structured layout rules. Adaptive mobile-first dashboard matrices and administrative sidebars.
 * @dependencies public/css/base.css
 */

/* General body and typography */
body {
  font-family: var(--font-body);
  color: var(--color-text);
  background-color: var(--color-bg);
}

/* Nepali Typography Override */
body.lang-nepali {
  font-family: var(--font-np), var(--font-body);
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  color: var(--color-primary);
}

/* Utility classes */
.text-muted {
  color: var(--color-text-muted);
}
.text-danger {
  color: var(--color-danger);
}

/* Ensure the body fills the viewport and pushes the footer to the bottom */
body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.main-content-wrapper {
  flex: 1 0 auto;
}

/* Core Layout wrappers (header padding is set on .app-header .header-container) */
.footer-container,
.landing-page-container,
.dashboard-page-container,
.results-page-container,
.legal-page-container,
.error-page-container,
.admin-dashboard-container,
.admin-manager-container,
.template-builder-container,
.reports-queue-container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--space-4); /* Standardized padding for containers */
}

/* Sticky App Header — fixed height; logos scale inside via max-height only */
.app-header {
  position: sticky;
  top: 0;
  height: var(--header-height);
  min-height: var(--header-height);
  max-height: var(--header-height);
  background-color: var(--color-surface);
  color: var(--color-text);
  z-index: 100;
  box-shadow: var(--shadow-md);
  overflow: visible;
}

.app-header .header-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-height);
  max-height: var(--header-height);
  padding-top: 0;
  padding-bottom: 0;
  padding-left: var(--space-4);
  padding-right: var(--space-4);
  gap: var(--space-2);
  position: relative;
  overflow: visible;
}

.logo-area {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  min-width: 0;
  height: 100%;
  overflow: visible;
}

.brand-logo {
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--color-primary);
  font-family: var(--font-display);
  display: flex;
  align-items: center;
  height: 100%;
  line-height: 0;
  text-decoration: none;
}

.brand-logo:hover {
  text-decoration: none;
}

/* Fixed slot inside the header bar — image scales down, never grows the header */
.brand-logo-frame {
  display: flex;
  align-items: center;
  justify-content: center;
  height: var(--logo-max-height);
  flex-shrink: 0;
}

.brand-logo-img {
  display: block;
  width: auto;
  height: 100%;
  max-height: var(--logo-max-height);
  max-width: none;
  object-fit: contain;
  object-position: center;
}

.header-menu-spacer {
  width: 40px;
  flex-shrink: 0;
}

.header-menu-btn {
  flex-shrink: 0;
  margin-left: 0;
}

.nav-links {
  display: none;
  /* Auto collapsed on tiny mobile interfaces */
}

.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  color: var(--color-primary);
  font-size: var(--text-xl);
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.mobile-menu-btn {
  margin-left: var(--space-4);
}

@media (max-width: 767px) {
  .app-header .header-container {
    display: grid;
    grid-template-columns: 40px 1fr auto;
    grid-template-areas: "menu logo controls";
    align-items: center;
    column-gap: var(--space-2);
  }

  .header-menu-btn,
  .header-menu-spacer {
    grid-area: menu;
  }

  .logo-area {
    grid-area: logo;
    justify-self: center;
    flex: unset;
  }

  .header-controls {
    grid-area: controls;
    justify-self: end;
    gap: var(--space-2);
  }

  .nav-links {
    display: none;
    width: 100%;
  }

  .nav-links.mobile-open {
    display: flex;
    flex-direction: column;
    grid-column: 1 / -1;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background-color: var(--color-bg);
    padding: var(--space-4);
    z-index: 1000;
    border-top: 1px solid var(--color-border);
    box-shadow: var(--shadow-md);
  }

  .nav-link {
    padding: var(--space-2) 0;
    border-bottom: 1px solid var(--color-border);
    width: 100%;
    font-size: var(--text-base);
    color: var(--color-text);
  }

  .app-header .mobile-menu-btn {
    display: block;
  }

  .app-header .header-controls {
    display: flex;
    align-items: center;
    overflow: visible;
  }
}

@media (min-width: 768px) {
  .logo-area {
    flex: 0 1 auto;
    justify-content: flex-start;
  }

  .nav-links {
    display: flex;
    gap: var(--space-4);
  }

  .mobile-menu-btn,
  .header-menu-spacer {
    display: none;
  }
}

.nav-link { /* General nav link styles */
  color: var(--color-text); /* Dark text for contrast on white navbar */
  font-size: var(--text-sm);
  font-weight: 500;
  transition: color 0.2s;
}

.nav-link:hover {
  color: var(--color-accent); /* Saffron accent on hover */
  text-decoration: none; /* Keep for consistency */
}
.nav-link.active {
  color: var(--color-accent); /* Saffron accent for active state */
  position: relative;
}

.nav-link.active::after {
  content: '';
  position: absolute;
  bottom: -18px; /* Adjust as needed to align with the bottom of the header */
  left: 0;
  right: 0;
  height: 3px;
  background: var(--color-accent);
}
.header-controls {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.language-toggle {
  display: flex;
  align-items: center;
}

/* Compact EN | NP language switch */
.lang-switch-btn {
  display: inline-flex;
  align-items: center;
  gap: 0;
  padding: 2px;
  height: 24px;
  min-width: 52px;
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border);
  background-color: var(--color-bg);
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1;
  transition: border-color 0.2s, box-shadow 0.2s;
}

/* Dark mode toggle — same height as language toggle but compact square */
.dark-mode-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  width: 24px;
  height: 24px;
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border);
  background-color: var(--color-bg);
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
  flex-shrink: 0;
}

.dark-mode-toggle svg {
  width: 14px;
  height: 14px;
  stroke: var(--color-text);
}

.dark-mode-toggle:hover {
  border-color: var(--color-accent);
  box-shadow: var(--shadow-sm);
}

.lang-switch-btn:hover {
  border-color: var(--color-accent);
  box-shadow: var(--shadow-sm);
}

.lang-switch-opt {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 20px;
  padding: 0 6px;
  border-radius: var(--radius-full);
  color: var(--color-text-muted);
  transition: background-color 0.2s, color 0.2s;
}

.lang-switch-opt.is-active {
  background-color: var(--color-surface);
  color: var(--color-primary);
  box-shadow: var(--shadow-sm);
}

.btn-pop {
  animation: langPop 0.3s ease-out;
}

@keyframes langPop {
  0% { transform: scale(1); }
  50% { transform: scale(1.1); }
  100% { transform: scale(1); }
}

/* Dashboard dynamic matrices */
.test-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-4);
  margin-top: var(--space-4);
}

.test-card {
  background-color: var(--color-surface);
  border-radius: var(--radius-md);
  padding: var(--space-4); /* Using new spacing variable */
  display: flex;
  flex-direction: column;
  border: none;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s, box-shadow 0.2s;
}

.test-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.card-badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1); /* Using new spacing variable */
  margin-bottom: var(--space-2); /* Using new spacing variable */
}

.test-title {
  margin-bottom: var(--space-sm);
  font-family: var(--font-display); /* Apply display font to test title */
  font-size: var(--text-lg);
  color: var(--color-primary);
}

.test-metadata {
  display: flex;
  justify-content: space-between;
  font-size: var(--text-sm); /* Using new type scale variable */
  color: var(--color-text-muted); /* Using new color variable */
  margin-bottom: var(--space-4); /* Using new spacing variable */
}

.test-action-row {
  margin-top: auto;
}

/* Scheduled Live competitive exam timer banners */
.competition-countdown-timer {
  background-color: var(--color-danger); /* Using new semantic color variable */
  color: var(--color-surface); /* White text on danger background */
  font-size: var(--text-sm); /* Using new type scale variable */
  font-weight: 600;
  text-align: center;
  padding: var(--space-1); /* Using new spacing variable */
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-4); /* Using new spacing variable */
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0% {
    opacity: 1;
  }

  50% {
    opacity: 0.6;
  }

  100% {
    opacity: 1;
  }
}

/* Evaluation Score and Accordion designs */
.score-summary-card {
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md); /* Using new border radius variable */
  padding: var(--space-lg);
  margin-bottom: var(--space-lg);
  text-align: center;
  box-shadow: var(--shadow-sm); /* Apply shadow to summary card */
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-4);
  margin-top: var(--space-4);
}

.metric-block {
  padding: var(--space-md);
  background-color: var(--color-bg); /* Using new color variable */
  border-radius: var(--radius-sm); /* Using new border radius variable */
}

.metric-label {
  display: block;
  font-size: var(--text-sm); /* Using new type scale variable */
  color: var(--color-text-muted); /* Using new color variable */
  margin-bottom: var(--space-1); /* Using new spacing variable */
}

.metric-value {
  font-size: var(--text-2xl); /* Using new type scale variable */
  font-weight: 700;
  color: var(--color-primary); /* Using new color variable */
}

.accordion-item {
  border: 1px solid var(--color-border); /* Using new color variable */
  border-radius: var(--radius-md); /* Using new border radius variable */
  margin-bottom: var(--space-2); /* Using new spacing variable */
  background-color: var(--color-surface); /* Using new color variable */
  overflow: hidden;
  box-shadow: var(--shadow-sm); /* Apply shadow to accordion items */
}

.accordion-header {
  padding: var(--space-md);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
  background-color: var(--color-primary-light); /* Lighter primary for header background */
  user-select: none;
  font-weight: 500;
  color: var(--color-text);
}

.accordion-body {
  display: none;
  padding: var(--space-4); /* Using new spacing variable */
  border-top: 1px solid var(--color-border); /* Using new color variable */
}

.accordion-body.active {
  display: block;
}

/* Option highlight statuses in results review */
.row-correct {
  background-color: var(--color-success); /* Using new semantic color variable */
  color: var(--color-surface); /* White text on success background */
  padding: var(--space-sm);
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-xs);
}

.row-selected-incorrect {
  background-color: var(--color-danger); /* Using new semantic color variable */
  color: var(--color-surface); /* White text on danger background */
  padding: var(--space-sm);
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-xs);
}

/* Administrative column layout switcher */
.admin-dashboard-container {
  margin-top: var(--space-md);
}

.page-title {
  font-family: var(--font-display);
  font-size: var(--text-3xl);
  color: var(--color-primary);
  margin-bottom: var(--space-md);
}
.page-description {
  color: var(--color-text-muted);
  margin-bottom: var(--space-lg);
}

.stats-panels-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.stat-card {
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  padding: var(--space-md) var(--space-lg);
  text-align: left;
  border-radius: var(--radius-sm);
  box-shadow: none;
}

.stat-count {
  display: block;
  font-size: var(--text-2xl);
  font-weight: 600;
  color: var(--color-text); /* Using neutral text color for counts */
  margin-top: var(--space-xs);
}

.section-title {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  color: var(--color-primary);
  margin-bottom: var(--space-md);
}

/* App Footer constraints */
.app-footer {
  background-color: var(--color-primary); /* Using new color variable */
  color: var(--color-text-on-dark-soft); /* White-tinted for contrast on dark navy */
  padding: var(--space-6) 0; /* Using new spacing variable */
  margin-top: var(--space-8); /* Using new spacing variable */
}

.footer-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4); /* Using new spacing variable */
}

@media (min-width: 768px) {
  .footer-container {
    flex-direction: row;
    justify-content: space-between;
  }
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
}

.footer-link {
  color: var(--color-text-on-dark-muted); /* Visible on dark navy footer */
  font-size: var(--text-sm); /* Using new type scale variable */
}

.footer-link:hover {
  color: var(--color-text-on-dark-soft);
  text-decoration: underline;
}

.password-field {
  position: relative;
}

.btn-secondary {
  background: transparent;
  border: 1.5px solid var(--color-border);
  color: var(--color-text);
}
.btn-ghost {
  background: transparent;
  color: var(--color-text-muted);
}

.nav-link-premium { color: var(--color-accent); }

.btn-primary:active, .btn-secondary:active {
  transform: translateY(1px);
}

.btn-challenge {
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-sm);
  font-weight: 600;
  background: var(--color-accent-light);
  color: var(--color-accent-dark);
  border: 1px solid var(--color-accent);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.btn-challenge:hover {
  background: var(--color-accent);
  color: var(--color-surface);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  filter: grayscale(0.5);
}

.password-field {
  position: relative;
}

.password-field .form-input {
  padding-right: 2.5rem;
}

.eye-toggle {
  position: absolute;
  right: var(--space-2);
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  font-size: var(--text-lg);
  color: var(--color-text-muted);
  line-height: 1;
  padding: 0 var(--space-1);
  border-radius: var(--radius-xs);
}

.eye-toggle:hover,
.eye-toggle:focus-visible {
  color: var(--color-primary);
  outline: 2px solid var(--color-accent);
  outline-offset: 1px;
}

/* Responsive Table Wrapper for Mobile */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: var(--space-4);
}

@media (max-width: 768px) {
  .data-table {
    font-size: var(--text-sm); /* Using new type scale variable */
    min-width: 500px; /* Force scroll rather than squashing info */
  }
}

/* CDC level badges and type/status badges are defined authoritatively in
   components.css (with dark-mode overrides in base.css) — duplicates removed. */

/* General badge styling (assuming it exists or needs to be added) */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25em 0.6em;
  font-size: 0.75em;
  font-weight: 600;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
  vertical-align: baseline;
  border-radius: 0.375rem; /* A common small radius */
}

/* Test Details Page Specific Styles */
.test-detail-panel {
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-6); /* Using new spacing variable */
  margin-top: var(--space-6); /* Using new spacing variable */
  box-shadow: var(--shadow-sm);
}

.test-meta-row {
  display: flex;
  flex-wrap: wrap; /* Keep as is */
  gap: var(--space-2); /* Using new spacing variable */
  margin-bottom: var(--space-6); /* Using new spacing variable */
}

/* .badge-type / .badge-premium / .badge-live consolidated into components.css */

.test-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--space-4); /* Using new spacing variable */
  margin-bottom: var(--space-8); /* Using new spacing variable */
}

.summary-card {
  background-color: var(--color-bg);
  padding: var(--space-4); /* Using new spacing variable */
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.summary-card strong {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-1); /* Using new spacing variable */
}

.summary-card span {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--color-primary);
}

.test-section-description h2 {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  color: var(--color-primary);
  margin-bottom: var(--space-6); /* Using new spacing variable */
}

.section-card {
  background-color: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-6); /* Using new spacing variable */
  margin-bottom: var(--space-4); /* Using new spacing variable */
}

.section-card h3 {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  color: var(--color-primary-mid);
  margin-top: 0;
  margin-bottom: var(--space-4); /* Using new spacing variable */
}

.section-card p {
  margin-bottom: var(--space-2); /* Using new spacing variable */
  color: var(--color-text);
}

.section-card p strong {
  color: var(--color-text-muted);
}

.section-card ul {
  margin-top: var(--space-2); /* Using new spacing variable */
  margin-left: var(--space-6); /* Using new spacing variable */
  color: var(--color-text);
}

.section-card .badge {
  margin-right: var(--space-1); /* Using new spacing variable */
  margin-bottom: var(--space-1); /* Using new spacing variable */
}

/* Admin Dashboard Specific Styles */
.admin-dashboard-container {
  padding: var(--space-6); /* Using new spacing variable */
  max-width: 1200px;
  margin: 0 auto;
}

.quick-admin-navigation .shortcut-links {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: var(--space-4); /* Using new spacing variable */
}

/* --- Toast Notification System --- */
#toast-container {
  position: fixed;
  top: var(--space-6); /* Adjust as needed */
  right: var(--space-6); /* Adjust as needed */
  z-index: 13000; /* Increased to stay above modals (which are at 12000) */
  display: flex;
  flex-direction: column;
  gap: var(--space-3); /* Space between toasts */
  max-width: 350px; /* Limit width of toasts */
  pointer-events: none; /* Allow clicks to pass through container */
}

.toast {
  background-color: var(--color-surface);
  color: var(--color-text);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  /* Initial hidden state for animation */
  opacity: 0;
  transform: translateX(100%); /* Start off-screen to the right */
  transition: opacity 0.3s ease-out, transform 0.3s ease-out;
  pointer-events: all; /* Re-enable clicks for the toast itself */
}

.toast.show {
  opacity: 1;
  transform: translateX(0); /* Slide in */
}

.toast.toast-success {
  border-left: 4px solid var(--color-success);
}

.toast.toast-error {
  border-left: 4px solid var(--color-danger);
}

.toast.toast-warning {
  border-left: 4px solid var(--color-warning);
}

.toast.toast-info {
  border-left: 4px solid var(--color-info);
}

.toast-content {
  flex-grow: 1;
  font-size: var(--text-sm);
}

.toast-close {
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-size: var(--text-lg);
  cursor: pointer;
  line-height: 1;
  padding: 0;
  margin-left: var(--space-2);
}

.toast-close:hover {
  color: var(--color-text);
}

/* --- Modal UI System --- */
.mcqplex-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(10, 22, 40, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 12000 !important; /* Enforced to stay above sticky exam elements */
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease;
}

.mcqplex-modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.mcqplex-modal-content {
  background-color: var(--color-surface);
  padding: var(--space-8);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  max-width: 500px;
  width: 90%;
}

/* Auth Page Specific Styles */
.auth-page-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: calc(100vh - var(--header-height) - 100px);
  padding: var(--space-6);
}

.auth-card {
  background-color: var(--color-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: var(--space-6);
  width: 100%;
  max-width: 400px;
}

.auth-tabs {
  display: flex;
  margin-bottom: var(--space-4);
  border-bottom: 1px solid var(--color-border);
}

.auth-tabs .tab-btn {
  flex: 1;
  padding: var(--space-3);
  border: none;
  background: none;
  font-size: var(--text-lg);
  font-weight: 500;
  color: var(--color-text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s ease-in-out;
}

.auth-tabs .tab-btn.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-accent);
}

.auth-form:not(.active) {
  display: none;
}

.quick-admin-navigation .btn-secondary {
  width: 100%;
  padding: var(--space-3) var(--space-4); /* Using new spacing variables */
  text-align: center;
  text-decoration: none;
  font-weight: 500;
  transition: all 0.15s ease-in-out;
}

.quick-admin-navigation .btn-secondary:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
}

.system-status-card {
  background: var(--color-primary-light);
  padding: var(--space-6); /* Using new spacing variable */
  border-radius: var(--radius-sm);
  border-left: 4px solid var(--color-info);
  margin-bottom: var(--space-6); /* Using new spacing variable */
}

.system-status-card .info-card-title {
  margin-top: 0;
  margin-bottom: var(--space-4); /* Using new spacing variable */
}

.system-status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: var(--space-4); /* Using new spacing variable */
}

/* Template Builder Specific Styles */
.template-builder-container {
  padding: var(--space-6); /* Using new spacing variable */
  max-width: 1200px;
  margin: 0 auto;
}

.template-builder-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-8); /* Using new spacing variable */
}

.template-form-column .card {
  padding: var(--space-6); /* Using new spacing variable */
}

.fieldset-group {
  border: 1px solid var(--color-border);
  padding: var(--space-4); /* Using new spacing variable */
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-6); /* Using new spacing variable */
}

.fieldset-legend {
  font-weight: 600;
  padding: 0 var(--space-2); /* Using new spacing variable */
  color: var(--color-primary);
  font-size: var(--text-lg);
}

.form-group {
  margin-bottom: var(--space-4); /* Using new spacing variable */
}

.form-label {
  display: block;
  font-weight: 500;
  color: var(--color-text);
  margin-bottom: var(--space-1); /* Using new spacing variable */
}

.form-input,
.form-select {
  width: 100%;
  padding: var(--space-3); /* Using new spacing variable */
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: var(--text-base);
  color: var(--color-text);
  background-color: var(--color-surface);
}

.form-input:focus,
.form-select:focus {
  border-color: var(--color-accent);
  outline: none;
  box-shadow: 0 0 0 2px var(--color-accent-light);
}

.form-help-text {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  margin-top: var(--space-1); /* Using new spacing variable */
  display: block;
}

.cdc-level-distribution-card {
  background: var(--color-primary-light);
  padding: var(--space-4); /* Using new spacing variable */
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-4); /* Using new spacing variable */
  border: 1px solid var(--color-border);
}

.cdc-level-distribution-label {
  font-weight: 600;
  display: block;
  margin-bottom: var(--space-2); /* Using new spacing variable */
  color: var(--color-primary);
}

.cdc-level-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: var(--space-4); /* Using new spacing variable */
}

.cdc-level-input {
  width: 100%;
  padding: var(--space-2); /* Using new spacing variable */
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xs);
  font-size: var(--text-sm);
}

.form-toggle-card {
  background: var(--color-primary-light);
  padding: var(--space-4); /* Using new spacing variable */
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-4); /* Using new spacing variable */
  border: 1px solid var(--color-border);
}

.form-toggle-label {
  display: flex;
  align-items: center;
  gap: var(--space-2); /* Using new spacing variable */
  font-weight: 500;
  color: var(--color-text);
  cursor: pointer;
}

.form-toggle-label-inline {
  margin-bottom: var(--space-2); /* Add some spacing between inline toggles */
}

.form-checkbox {
  width: 18px;
  height: 18px;
}

.form-group-hidden {
  display: none;
  margin-top: var(--space-4); /* Using new spacing variable */
}

.btn-full-width {
  width: 100%;
  padding: var(--space-3) var(--space-4); /* Using new spacing variables */
  font-size: var(--text-lg);
}

.info-card {
  padding: var(--space-6); /* Using new spacing variable */
  border-radius: var(--radius-md);
  margin-bottom: var(--space-6); /* Using new spacing variable */
  border-left: 4px solid;
  box-shadow: var(--shadow-sm); /* Info cards also get a subtle shadow */
}

.info-card-info {
  background: var(--color-primary-light);
  border-left-color: var(--color-info);
}

.info-card-success {
  background: var(--color-success-light);
  border-left-color: var(--color-success);
}

.info-card-warning {
  background: var(--color-accent-light);
  border-left-color: var(--color-warning);
}

.info-card-title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  color: var(--color-primary);
  margin-top: 0;
  margin-bottom: var(--space-4); /* Using new spacing variable */
}

.info-card-list {
  line-height: 1.6;
  color: var(--color-text);
  padding-left: var(--space-4); /* Using new spacing variable */
  margin: 0;
}

.pro-tip-card {
  background: var(--color-surface);
  padding: var(--space-4); /* Using new spacing variable */
  border-radius: var(--radius-sm);
  margin-top: var(--space-4); /* Using new spacing variable */
  border-left: 3px solid var(--color-warning);
  color: var(--color-text);
  font-size: var(--text-sm);
}

.template-preview-box {
  background: var(--color-surface);
  padding: var(--space-4); /* Using new spacing variable */
  border-radius: var(--radius-sm);
  text-align: center;
  color: var(--color-text-muted);
  border: 1px dashed var(--color-border);
  min-height: 100px; /* Ensure preview box has some height */
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Admin Dashboard Specific Styles */
.admin-dashboard-container {
  padding: var(--space-6); /* Using new spacing variable */
  max-width: 1200px;
  margin: 0 auto;
}

.quick-admin-navigation .shortcut-links {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: var(--space-4); /* Using new spacing variable */
}

.quick-admin-navigation .btn-secondary {
  width: 100%;
  padding: var(--space-3) var(--space-4); /* Using new spacing variables */
  text-align: center;
  text-decoration: none;
  font-weight: 500;
  transition: all 0.15s ease-in-out;
}

.quick-admin-navigation .btn-secondary:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
}

.system-status-card {
  background: var(--color-primary-light);
  padding: var(--space-6); /* Using new spacing variable */
  border-radius: var(--radius-sm);
  border-left: 4px solid var(--color-info);
  margin-bottom: var(--space-6); /* Using new spacing variable */
}

.system-status-card .info-card-title {
  margin-top: 0;
  margin-bottom: var(--space-4); /* Using new spacing variable */
}

.system-status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: var(--space-4); /* Using new spacing variable */
}

/* Suggested CSS for KaTeX containers */
.preview-box, .question-body-text {
    min-height: 20px;
    padding: 10px;
    background: var(--color-bg);
    border-radius: var(--radius-sm);
    word-wrap: break-word;
    overflow-x: auto; /* Handles long equations on mobile */
}

/* ─── Header user profile (mobile dropdown + desktop inline) ─────────────── */
.user-profile-widget {
  position: relative;
  flex-shrink: 0;
}

.user-profile-desktop {
  display: none;
  align-items: center;
  gap: var(--space-3);
}

.user-profile-desktop .user-name {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text);
  white-space: nowrap;
}

.user-menu-mobile {
  display: block;
  position: relative;
}

.user-menu-mobile-trigger {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--color-primary);
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.user-menu-mobile-trigger::-webkit-details-marker {
  display: none;
}

.user-menu-mobile:not([open]) .user-menu-dropdown {
  display: none;
}

.user-menu-mobile[open] .user-menu-dropdown {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: var(--space-2);
  position: fixed;
  top: var(--header-height);
  right: var(--space-4);
  min-width: 180px;
  margin-top: var(--space-1);
  padding: var(--space-3);
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  z-index: 10000;
}

.user-menu-dropdown .user-name {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text);
  word-break: break-word;
}

.user-menu-dropdown .btn {
  width: 100%;
  text-align: center;
}

/* The account menu (.user-menu-mobile) is now the universal account dropdown —
   shown on ALL breakpoints so secondary destinations (Profile, History,
   Bookmarks, Premium, Billing, Sign out) live here instead of crowding the top
   bar. The old desktop-only name+logout widget (.user-profile-desktop) stays
   hidden (its default), since the dropdown's first row shows the name. */

/* My History — attempts table row hover (CSP-safe; no inline handlers) */
.attempts-table__row {
  border-bottom: 1px solid var(--color-border);
  transition: background 0.15s;
}

.attempts-table__row:hover {
  background: var(--color-bg);
}

/* ═══════════════════════════════════════════════════════════
   UI ROOT COMPONENTS  (toast + modal — from ui-root.ejs)
   ═══════════════════════════════════════════════════════════ */

/* Toast container */
.ui-toast-container {
  position: fixed;
  bottom: var(--space-5);
  right: var(--space-5);
  z-index: 50000;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  pointer-events: none;
  max-width: 360px;
}

.ui-toast {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-surface);
  pointer-events: all;
  transform: translateY(8px);
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.ui-toast--visible {
  opacity: 1;
  transform: translateY(0);
}

.ui-toast--exit {
  opacity: 0;
  transform: translateY(-4px);
}

.ui-toast--info    { background-color: var(--color-info); }
.ui-toast--success { background-color: var(--color-success); }
.ui-toast--warning { background-color: var(--color-warning); }
.ui-toast--error   { background-color: var(--color-danger); }

/* Modal overlay */
.ui-modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(10, 22, 40, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 50000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
}

.ui-overlay--hidden {
  display: none !important;
}

.ui-body--locked {
  overflow: hidden;
}

.ui-modal-panel {
  background-color: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 480px;
  width: 100%;
  overflow: hidden;
  border: 1px solid var(--color-border);
}

.ui-modal-body-wrap {
  padding: var(--space-6);
}

.ui-modal-title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--color-primary);
  margin: 0 0 var(--space-2);
}

.ui-modal-content {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  line-height: 1.6;
}

.ui-modal-footer {
  background-color: var(--color-bg);
  padding: var(--space-4) var(--space-6);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
  border-top: 1px solid var(--color-border);
}

.ui-modal-btn {
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
  font-weight: 500;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: none;
  transition: background-color 0.15s, color 0.15s;
}

.ui-modal-btn--secondary {
  background-color: transparent;
  color: var(--color-text-muted);
}

.ui-modal-btn--secondary:hover {
  background-color: var(--color-primary-light);
  color: var(--color-primary);
}

.ui-modal-btn--primary {
  background-color: var(--color-accent);
  color: var(--color-surface);
  box-shadow: var(--shadow-sm);
}

.ui-modal-btn--primary:hover {
  background-color: var(--color-accent-dark);
}

/* ═══════════════════════════════════════════════════════════
   DASHBOARD v2  —  Exam card system
   ═══════════════════════════════════════════════════════════ */

/* Page header */
.dashboard-header {
  margin-bottom: var(--space-6);
}

.dashboard-header h1 {
  font-family: var(--font-display);
  font-size: var(--text-3xl);
  color: var(--color-primary);
  margin: 0 0 var(--space-1);
}

.dashboard-header p {
  color: var(--color-text-muted);
  margin: 0;
  font-size: var(--text-sm);
}

/* Filter bar */
.filter-controls-bar {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}

.filter-group {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

/* Empty state */
.empty-list-placeholder {
  grid-column: 1 / -1;
  padding: var(--space-12) var(--space-6);
  text-align: center;
  color: var(--color-text-subtle);
  font-size: var(--text-sm);
}

.test-cards-grid-v2 {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--space-5);
  margin-top: var(--space-6);
}

/* Base card */
.exam-card {
  background-color: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: var(--space-6);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 192px;
  border: 1px solid transparent;
  transition: box-shadow 0.3s ease;
}

.exam-card:hover {
  box-shadow: var(--shadow-lg);
}

.exam-card--locked {
  opacity: 0.85;
}

/* Subject / grade tag line */
.exam-card__subject {
  display: block;
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-subtle);
  margin-bottom: var(--space-1);
}

/* Title — truncates to one line to prevent height variance */
.exam-card__title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--color-primary);
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Meta row: questions · duration · difficulty dots */
.exam-card__meta {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-top: var(--space-3);
}

.exam-card__meta-sep {
  color: var(--color-border);
}

.exam-card__difficulty {
  display: flex;
  align-items: center;
  gap: 3px;
}

.difficulty-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
}

.difficulty-dot--filled {
  background-color: var(--color-accent);
}

.difficulty-dot--empty {
  background-color: var(--color-border);
}

/* Action row: Start button + Preview link */
.exam-card__actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-top: var(--space-4);
}

.exam-card__btn-start {
  flex: 1;
  background-color: var(--color-primary);
  color: var(--color-surface);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 500;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  display: block;
  transition: background-color 0.15s;
  line-height: 1.5;
}

.exam-card__btn-start:hover {
  background-color: var(--color-primary-mid);
  text-decoration: none;
  color: var(--color-surface);
}
/* Press + keyboard-focus feedback to match the global .btn states (this is a
   custom button class, so it doesn't inherit them). */
.exam-card__btn-start:active {
  transform: translateY(1px);
}
.exam-card__btn-start:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}
.exam-card__btn-start:disabled,
.exam-card__btn-start[aria-busy="true"] {
  opacity: 0.6;
  cursor: not-allowed;
  pointer-events: none;
}
@media (prefers-reduced-motion: reduce) {
  .exam-card__btn-start:active { transform: none; }
}

.exam-card__btn-preview {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-muted);
  background: none;
  border: none;
  cursor: pointer;
  padding: var(--space-2) var(--space-3);
  display: flex;
  align-items: center;
  gap: var(--space-1);
  white-space: nowrap;
  transition: color 0.15s;
}

.exam-card__btn-preview:hover {
  color: var(--color-primary);
}

.exam-card__btn-preview .preview-arrow {
  display: inline-block;
  transition: transform 0.15s;
}

.exam-card__btn-preview:hover .preview-arrow {
  transform: translateX(3px);
}

/* ── Resume banner ────────────────────────────────────────── */

.resume-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  background-color: var(--color-accent-light);
  border: 1px solid var(--color-accent);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  margin-bottom: var(--space-6);
  box-shadow: var(--shadow-sm);
}

.resume-banner__left {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.resume-banner__icon {
  font-size: var(--text-2xl);
  flex-shrink: 0;
}

.resume-banner__title {
  margin: 0 0 var(--space-1);
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--color-primary);
}

.resume-banner__sub {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

/* ═══════════════════════════════════════════════════════════
   SLIDE-IN PREVIEW DRAWER
   ═══════════════════════════════════════════════════════════ */

/* Scrim behind the drawer */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(10, 22, 40, 0.35);
  z-index: 39000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.drawer-backdrop--visible {
  opacity: 1;
  pointer-events: all;
}

/* Drawer panel */
.preview-drawer {
  position: fixed;
  inset-block: 0;
  right: 0;
  width: min(420px, 92vw);
  background-color: var(--color-surface);
  box-shadow: var(--shadow-lg);
  z-index: 40000;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--color-border);
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1),
              visibility 0.3s;
  visibility: hidden;
}

.preview-drawer--hidden {
  visibility: hidden;
  transform: translateX(100%);
}

.preview-drawer--open {
  transform: translateX(0);
  visibility: visible;
}

.preview-drawer__header {
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.preview-drawer__title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--color-primary);
  margin: 0;
}

.preview-drawer__close {
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-size: var(--text-2xl);
  line-height: 1;
  cursor: pointer;
  padding: var(--space-1);
  border-radius: var(--radius-sm);
  transition: color 0.15s, background-color 0.15s;
}

.preview-drawer__close:hover {
  color: var(--color-primary);
  background-color: var(--color-primary-light);
}

.preview-drawer__body {
  padding: var(--space-6);
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

.drawer-section__label {
  display: block;
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-subtle);
  margin-bottom: var(--space-2);
}

.drawer-section__content {
  font-size: var(--text-sm);
  color: var(--color-text);
  background-color: var(--color-bg);
  border-radius: var(--radius-sm);
  padding: var(--space-3);
  line-height: 1.5;
}

.drawer-taxonomy-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--color-border);
}

.drawer-taxonomy-row:last-child {
  border-bottom: none;
}

.drawer-taxonomy-label {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.drawer-taxonomy-count {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-primary);
}

.drawer-loading-text {
  font-size: var(--text-sm);
  color: var(--color-text-subtle);
  font-style: italic;
  margin: 0;
}

/* ═══════════════════════════════════════════════════════════
   HEADER SOCIAL LINKS + IN-PROGRESS BADGE
   ═══════════════════════════════════════════════════════════ */

/* Header social links */
.header-social-links {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.header-social-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  transition: color 0.2s, background-color 0.2s;
}
.header-social-link:hover {
  color: var(--color-accent);
  background-color: var(--color-bg-hover, var(--color-bg));
}

/* Beta / In-Progress badge */
.header-beta-badge {
  display: inline-block;
  font-size: 0.6rem;
  font-family: var(--font-mono);
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--color-accent);
  border: 1px solid var(--color-accent);
  border-radius: var(--radius-sm);
  padding: 1px 5px;
  vertical-align: middle;
  margin-left: var(--space-2);
  opacity: 0.85;
}

html.dark-mode .header-social-link:hover {
  background-color: rgba(255,255,255,0.08);
}

/* ═══════════════════════════════════════════════════════════
   FOOTER SOCIAL NAV  (SoloLearn-style icon row)
   ═══════════════════════════════════════════════════════════ */
.footer-social {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.footer-social-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-full);
  color: var(--color-text-on-dark-muted);
  background-color: var(--color-surface-overlay-08);
  transition: color 0.2s, background-color 0.2s;
}
.footer-social-link:hover {
  color: var(--color-text-on-dark);
  background-color: var(--color-accent);
}

/* ── Back to top button ──────────────────────────────────────── */
.l-back-to-top {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1.5px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: opacity 0.3s, visibility 0.3s, transform 0.3s, background 0.2s, border-color 0.2s;
  z-index: 900;
  box-shadow: 0 2px 12px rgba(0,0,0,0.15);
}
.l-back-to-top.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.l-back-to-top:hover {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: var(--color-text-on-dark);
}

/* ═══════════════════════════════════════════════════════════
   UNIFIED TOAST + MODAL VISUAL IDENTITY
   Aligns both MCQplexUI (#toast-container/.toast/.mcqplex-modal-*)
   and UI (.ui-toast-*/.ui-modal-*) systems to one look.
   CSS-only — appended last so equal-specificity rules win.
   ═══════════════════════════════════════════════════════════ */

/* ─── Toast containers — fixed bottom-right, above modals ─── */
#toast-container,
.ui-toast-container {
  position: fixed;
  top: auto;
  left: auto;
  bottom: var(--space-5);
  right: var(--space-5);
  z-index: 50000;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  pointer-events: none;
  max-width: 380px;
}

/* ─── Toast cards — shared surface + coloured left border ─── */
.toast,
.ui-toast {
  background-color: var(--color-bg-card, var(--color-surface));
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 500;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  border-left: 4px solid var(--color-info, #3b82f6);
  min-width: 280px;
  max-width: 380px;
  pointer-events: all;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

/* Visible state (MCQplexUI toggles .show, UI toggles --visible) */
.toast.show,
.ui-toast.ui-toast--visible {
  opacity: 1;
  transform: translateY(0);
}

/* Exit state — slide up + fade out */
.ui-toast.ui-toast--exit {
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

/* Type colours — left border only, shared surface background */
.toast.toast-success,
.ui-toast--success {
  background-color: var(--color-bg-card, var(--color-surface));
  border-left-color: var(--color-success, #22c55e);
}
.toast.toast-error,
.ui-toast--error {
  background-color: var(--color-bg-card, var(--color-surface));
  border-left-color: var(--color-danger, #ef4444);
}
.toast.toast-warning,
.ui-toast--warning {
  background-color: var(--color-bg-card, var(--color-surface));
  border-left-color: var(--color-warning, #f59e0b);
}
.toast.toast-info,
.ui-toast--info {
  background-color: var(--color-bg-card, var(--color-surface));
  border-left-color: var(--color-info, #3b82f6);
}

/* Dark mode — card surface already adapts; keep border colours */
html.dark-mode .toast,
html.dark-mode .ui-toast,
html.dark-mode .toast.toast-success,
html.dark-mode .toast.toast-error,
html.dark-mode .toast.toast-warning,
html.dark-mode .toast.toast-info,
html.dark-mode .ui-toast--success,
html.dark-mode .ui-toast--error,
html.dark-mode .ui-toast--warning,
html.dark-mode .ui-toast--info {
  background-color: var(--color-bg-card-dark, var(--color-dark-elevated));
  color: var(--color-dark-text);
}

/* ─── Modal overlays — shared backdrop, below toasts ─── */
.mcqplex-modal-overlay,
.ui-modal-overlay {
  background-color: rgba(0,0,0,0.6);
  z-index: 49000 !important;
}

/* ─── Modal panels — shared surface, radius, shadow ─── */
.mcqplex-modal-content,
.ui-modal-panel {
  background-color: var(--color-bg-card, var(--color-surface));
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  max-width: 480px;
  min-width: 300px;
  animation: rp-modal-enter 0.2s ease;
}
.mcqplex-modal-content {
  padding: var(--space-6);
}

/* UI modal keeps its inner body padding wrapper */
.ui-modal-body-wrap {
  padding: var(--space-6);
}

/* Header — DM Serif Display */
.ui-modal-title {
  font-family: var(--font-display);
  font-size: 1.25rem;
  color: var(--color-text-primary, var(--color-text));
}

/* Body — secondary text, comfortable line-height */
.ui-modal-content {
  font-size: 0.9rem;
  color: var(--color-text-secondary, var(--color-text-muted));
  line-height: 1.6;
}

@keyframes rp-modal-enter {
  from { opacity: 0; transform: scale(0.96); }
  to   { opacity: 1; transform: scale(1); }
}

/* Dark-mode panel surface */
html.dark-mode .mcqplex-modal-content,
html.dark-mode .ui-modal-panel {
  background-color: var(--color-bg-card-dark, var(--color-dark-elevated));
}

/* ═══════════════════════════════════════════════════════════
   SMART PRACTICE CARD
   ═══════════════════════════════════════════════════════════ */
.smart-practice-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-accent);
  border-radius: var(--radius-md);
  padding: var(--space-4) var(--space-5);
  box-shadow: var(--shadow-sm);
  margin-top: var(--space-6);
}

.smart-practice-card__content {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.smart-practice-card__icon {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: var(--color-accent-light);
  color: var(--color-accent);
  display: flex;
  align-items: center;
  justify-content: center;
}

.smart-practice-card__title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  color: var(--color-primary);
  margin: 0 0 2px;
}

.smart-practice-card__sub {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin: 0;
  line-height: 1.45;
}

.smart-practice-card__form {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.sp-select {
  height: 36px;
  padding: 0 var(--space-3);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  cursor: pointer;
  transition: border-color 0.15s;
}

.sp-select:focus {
  outline: none;
  border-color: var(--color-accent);
}

.sp-btn {
  height: 36px;
  padding: 0 var(--space-4);
  font-size: var(--text-sm);
  white-space: nowrap;
}

html.dark-mode .smart-practice-card {
  background: var(--color-dark-surface);
  border-color: var(--color-dark-border);
  border-left-color: var(--color-accent);
}

html.dark-mode .smart-practice-card__title {
  color: var(--color-dark-text);
}

html.dark-mode .smart-practice-card__icon {
  background: rgba(232, 130, 10, 0.12);
}

html.dark-mode .sp-select {
  background: var(--color-dark-elevated);
  border-color: var(--color-dark-border);
  color: var(--color-dark-text);
}

@media (max-width: 640px) {
  .smart-practice-card { flex-direction: column; align-items: flex-start; }
  .smart-practice-card__form { width: 100%; }
  .sp-select { flex: 1; min-width: 0; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   EXAM RESULT PAGE REDESIGN — score hero, analytics, question review.
   Consolidated here (results styles already lived in this file).
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── H2H result banner ─────────────────────────────────────────────────────── */
.h2h-result-banner {
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-mid, var(--color-primary)) 100%);
  color: var(--color-text-on-dark);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  text-align: center;
  margin-bottom: var(--space-6);
  border-left: 6px solid rgba(255,255,255,0.4);
}
.h2h-result-banner.win  { border-left-color: var(--color-success); }
.h2h-result-banner.loss { border-left-color: var(--color-danger); }
.h2h-result-banner.draw,
.h2h-result-banner.pending { border-left-color: var(--color-warning); }
.h2h-result-kicker { text-transform: uppercase; letter-spacing: 0.08em; font-size: var(--text-xs); opacity: 0.85; }
.h2h-result-title { font-size: 1.8rem; font-weight: 800; margin: var(--space-1) 0 var(--space-2); font-family: var(--font-display); }
.h2h-result-sub { opacity: 0.9; margin-bottom: var(--space-2); }
.h2h-result-points { font-size: 1.15rem; font-weight: 700; }
.h2h-demo { font-weight: 400; opacity: 0.8; font-size: var(--text-sm); }

/* ── Score hero ────────────────────────────────────────────────────────────── */
.score-hero {
  display: flex;
  gap: var(--space-8);
  align-items: center;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  margin-bottom: var(--space-5);
  box-shadow: var(--shadow-sm);
  flex-wrap: wrap;
}
.score-ring-wrap { display: flex; flex-direction: column; align-items: center; gap: var(--space-3); flex-shrink: 0; }
.score-ring { position: relative; width: 180px; height: 180px; }
.score-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.score-ring .ring-bg { fill: none; stroke: var(--color-border); stroke-width: 10; }
.score-ring .ring-fill {
  fill: none;
  stroke-width: 10;
  stroke-linecap: round;
  transition: stroke-dashoffset 1.2s cubic-bezier(0.22, 1, 0.36, 1);
}
.ring-pass .ring-fill { stroke: var(--color-success); }
.ring-warn .ring-fill { stroke: var(--color-warning); }
.ring-fail .ring-fill { stroke: var(--color-danger); }
.ring-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring-percentage { font-size: 2.4rem; font-weight: 800; font-family: var(--font-display); color: var(--color-text); line-height: 1; }
.ring-grade { font-size: var(--text-sm); color: var(--color-text-muted); margin-top: var(--space-1); }
.pass-stamp { font-size: var(--text-xs); font-weight: 700; letter-spacing: 0.05em; padding: 4px var(--space-3); border-radius: 9999px; }
.pass-stamp.passed { background: color-mix(in srgb, var(--color-success) 18%, transparent); color: var(--color-success-strong); }
.pass-stamp.needs  { background: color-mix(in srgb, var(--color-warning) 18%, transparent); color: var(--color-warning-strong); }
.score-hero.ring-pass { box-shadow: 0 0 22px rgba(34, 197, 94, 0.18); }

.score-hero-body { flex: 1; min-width: 260px; }
.score-hero-title { font-family: var(--font-display); margin: 0 0 var(--space-2); }
.score-big { font-size: 2rem; font-weight: 800; font-family: var(--font-display); color: var(--color-primary); margin-bottom: var(--space-3); }

.improvement-pill { display: inline-flex; align-items: center; gap: var(--space-2); padding: 4px var(--space-3); border-radius: 9999px; font-weight: 700; font-size: var(--text-sm); margin-bottom: var(--space-4); }
.improvement-pill.up   { background: color-mix(in srgb, var(--color-success) 16%, transparent); color: var(--color-success-strong); }
.improvement-pill.down { background: color-mix(in srgb, var(--color-danger) 16%, transparent); color: var(--color-danger-strong); }
.improvement-pill.same { background: var(--color-bg); color: var(--color-text-muted); }
.improvement-pill .imp-sub { font-weight: 400; opacity: 0.8; }

/* segmented breakdown bar */
.breakdown-bar { position: relative; display: flex; height: 16px; border-radius: 9999px; overflow: hidden; background: var(--color-border); margin-bottom: var(--space-2); }
.breakdown-bar .seg { height: 100%; cursor: pointer; transition: filter 0.15s ease; }
.breakdown-bar .seg:hover { filter: brightness(1.1); }
.seg-correct { background: var(--color-success); }
.seg-wrong { background: var(--color-danger); }
.seg-unattempted { background: var(--color-text-muted); }
.pass-line { position: absolute; top: -3px; bottom: -3px; width: 0; border-left: 2px dashed var(--color-text); opacity: 0.6; }
.breakdown-legend { display: flex; gap: var(--space-4); flex-wrap: wrap; font-size: var(--text-sm); color: var(--color-text-muted); }
.breakdown-legend .pass-mark-label { margin-left: auto; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: middle; margin-right: 4px; }
.dot-correct { background: var(--color-success); }
.dot-wrong { background: var(--color-danger); }
.dot-unattempted { background: var(--color-text-muted); }

/* ── Quick stats strip ─────────────────────────────────────────────────────── */
.quick-stats-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-4); margin-bottom: var(--space-5); }
.qstat { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: var(--space-4); text-align: center; }
.qstat-icon { font-size: 1.5rem; }
.qstat-value { font-size: 1.4rem; font-weight: 800; font-family: var(--font-display); color: var(--color-text); }
.qstat-value.qstat-locked { color: var(--color-text-muted); }
.qstat-label { font-size: var(--text-xs); color: var(--color-text-muted); }

/* ── Reward row: badges + points ───────────────────────────────────────────── */
.reward-row { display: flex; gap: var(--space-4); flex-wrap: wrap; margin-bottom: var(--space-5); }
.badges-earned { display: flex; gap: var(--space-3); flex-wrap: wrap; flex: 1; }
.result-badge { display: inline-flex; flex-direction: column; align-items: center; gap: 4px; padding: var(--space-3); background: var(--color-surface); border: 1.5px solid var(--color-border); border-radius: var(--radius-md); min-width: 84px; animation: badge-pop 0.4s ease-out; }
.rb-icon { font-size: 1.6rem; }
.rb-name { font-size: var(--text-xs); font-weight: 600; text-align: center; }
.result-badge.rarity-common    { border-color: var(--rarity-common); }
.result-badge.rarity-rare      { border-color: var(--rarity-rare); }
.result-badge.rarity-epic      { border-color: var(--rarity-epic); }
.result-badge.rarity-legendary { border-color: var(--rarity-legendary); box-shadow: 0 0 10px color-mix(in srgb, var(--rarity-legendary) 33%, transparent); }
@keyframes badge-pop { 0% { transform: scale(0); } 70% { transform: scale(1.18); } 100% { transform: scale(1); } }

.points-award { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: var(--space-4); min-width: 200px; }
.pa-total { font-size: 1.3rem; font-weight: 800; color: var(--color-success); font-family: var(--font-display); margin-bottom: var(--space-2); }
.pa-line { font-size: var(--text-sm); color: var(--color-text-muted); }
.pa-line span { color: var(--color-success); font-weight: 700; }

/* ── Analytics cards (CDC, subject, comparison, qmap, reco) ─────────────────── */
.analytics-card { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); padding: var(--space-5); margin-bottom: var(--space-5); }
.analytics-title { font-family: var(--font-display); margin: 0 0 var(--space-4); font-size: var(--text-lg); }
.bar-list { display: flex; flex-direction: column; gap: var(--space-3); }
.bar-row { display: flex; align-items: center; gap: var(--space-3); }
.bar-row[role="button"] { cursor: pointer; border-radius: var(--radius-sm); }
.bar-row[role="button"]:hover { background: var(--color-bg); }
.bar-name { width: 150px; flex-shrink: 0; font-size: var(--text-sm); color: var(--color-text); }
.bar-track { flex: 1; height: 14px; background: var(--color-border); border-radius: 9999px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 9999px; width: var(--w, 0%); }
.bar-fill.animate-fill { width: 0; transition: width 0.8s cubic-bezier(0.22, 1, 0.36, 1); }
.bar-fill.animate-fill.filled { width: var(--w, 0%); }
.bar-good { background: var(--color-success); }
.bar-mid  { background: var(--color-warning); }
.bar-low  { background: var(--color-danger); }
.bar-num { width: 110px; flex-shrink: 0; text-align: right; font-size: var(--text-sm); font-weight: 600; color: var(--color-text-muted); }

/* comparison */
.compare-row { display: flex; align-items: center; gap: var(--space-3); margin-bottom: var(--space-3); }
.compare-label { width: 80px; flex-shrink: 0; font-size: var(--text-sm); }
.cmp-track { flex: 1; height: 16px; background: var(--color-border); border-radius: 9999px; overflow: hidden; }
.cmp-fill { height: 100%; border-radius: 9999px; }
.compare-num { width: 48px; text-align: right; font-weight: 700; }
.compare-summary { font-weight: 700; margin: var(--space-2) 0 0; }
.compare-summary.above { color: var(--color-success); }
.compare-summary.below { color: var(--color-danger); }

/* ── Question map ──────────────────────────────────────────────────────────── */
.question-map { display: grid; grid-template-columns: repeat(10, 1fr); gap: 6px; margin-bottom: var(--space-3); }
.qmap-cell { aspect-ratio: 1; border: none; border-radius: var(--radius-sm); font-size: var(--text-xs); font-weight: 700; color: var(--color-text-on-dark); cursor: pointer; display: flex; align-items: center; justify-content: center; transition: transform 0.12s ease; }
.qmap-cell:hover { transform: scale(1.12); }
.qmap-correct { background: var(--color-success); }
.qmap-wrong { background: var(--color-danger); }
.qmap-unattempted { background: var(--color-text-muted); }
.qmap-legend { display: flex; gap: var(--space-4); font-size: var(--text-sm); color: var(--color-text-muted); }

/* ── Recommendations ───────────────────────────────────────────────────────── */
.reco-list { list-style: none; padding: 0; margin: 0 0 var(--space-3); display: flex; flex-direction: column; gap: var(--space-2); }
.reco-item { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3); border-radius: var(--radius-md); background: var(--color-bg); border-left: 4px solid var(--color-border); }
.reco-weak { border-left-color: var(--color-danger); }
.reco-review { border-left-color: var(--color-warning); }
.reco-tag { font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.04em; font-weight: 700; color: var(--color-text-muted); }
.reco-label-link { color: var(--color-primary); font-weight: 600; text-decoration: none; }
.reco-label-link:hover { text-decoration: underline; }
.reco-cta { margin: 0; }

/* ── Action bar ────────────────────────────────────────────────────────────── */
.results-action-bar { display: flex; gap: var(--space-3); flex-wrap: wrap; margin-bottom: var(--space-6); }

/* ── Review toolbar + filter tabs ──────────────────────────────────────────── */
.review-toolbar { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: var(--space-3); margin-bottom: var(--space-3); }
.review-toolbar h3 { margin: 0; font-family: var(--font-display); }
.review-controls { display: flex; gap: var(--space-2); }
.filter-tabs { display: flex; gap: var(--space-2); flex-wrap: wrap; margin-bottom: var(--space-4); border-bottom: 2px solid var(--color-border); }
.filter-tab { padding: var(--space-2) var(--space-3); border: none; background: none; cursor: pointer; color: var(--color-text-muted); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -2px; }
.filter-tab.active { color: var(--color-primary); border-bottom-color: var(--color-primary); }
.ft-count { background: var(--color-bg); border-radius: 9999px; padding: 0 6px; font-size: var(--text-xs); }

/* ── Question cards ────────────────────────────────────────────────────────── */
.question-cards { display: flex; flex-direction: column; gap: var(--space-3); }
.question-card { border: 1px solid var(--color-border); border-left: 4px solid var(--color-border); border-radius: var(--radius-md); background: var(--color-surface); overflow: hidden; }
.question-card.status-correct { border-left-color: var(--color-success); }
.question-card.status-wrong { border-left-color: var(--color-danger); }
.question-card.status-unattempted { border-left-color: var(--color-text-muted); }
.qc-header { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-4); cursor: pointer; user-select: none; }
.status-pill { font-size: var(--text-xs); font-weight: 700; padding: 2px var(--space-2); border-radius: 9999px; color: var(--color-text-on-dark); }
.pill-correct { background: var(--color-success); }
.pill-wrong { background: var(--color-danger); }
.pill-unattempted { background: var(--color-text-muted); }
.qc-number { font-weight: 600; }
.qc-cdc { font-size: var(--text-xs); color: var(--color-text-muted); }
.qc-chevron { margin-left: auto; transition: transform 0.2s ease; color: var(--color-text-muted); }
.qc-header.open .qc-chevron { transform: rotate(180deg); }
.qc-body { display: none; padding: var(--space-4); border-top: 1px solid var(--color-border); }
.qc-body.active { display: block; }
.option-row { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-2) var(--space-3); border-radius: var(--radius-sm); margin-bottom: 6px; }
.qc-body .question-image { display: block; max-width: 100%; max-height: 280px; height: auto; margin: var(--space-3) 0; border: 1px solid var(--color-border); border-radius: var(--radius-sm); }
.option-row .option-image { max-height: 44px; max-width: 40%; height: auto; margin-left: auto; object-fit: contain; }
.opt-tag { margin-left: auto; font-size: var(--text-xs); font-weight: 700; padding: 1px var(--space-2); border-radius: var(--radius-sm); background: rgba(255,255,255,0.25); }
.explanation-box-card { background: var(--color-bg); border-radius: var(--radius-md); padding: var(--space-4); margin-top: var(--space-3); }
.explanation-box-card h4 { margin: 0 0 var(--space-2); }
.qc-actions { display: flex; gap: var(--space-2); margin-top: var(--space-3); flex-wrap: wrap; }

/* ── Confetti + toast ──────────────────────────────────────────────────────── */
.confetti-layer { position: fixed; inset: 0; pointer-events: none; z-index: 1300; overflow: hidden; }
.confetti-piece { position: fixed; width: 8px; height: 8px; top: -10px; border-radius: 1px; animation: confetti-fall 3s ease-in forwards; }
@keyframes confetti-fall { 0% { transform: translateY(0) rotate(0deg); opacity: 1; } 100% { transform: translateY(105vh) rotate(720deg); opacity: 0; } }
.toast-container { position: fixed; top: var(--space-5); right: var(--space-5); z-index: 1200; display: flex; flex-direction: column; gap: var(--space-2); }
.toast { background: var(--color-surface); border: 1px solid var(--color-border); border-left: 4px solid var(--color-primary); color: var(--color-text); border-radius: var(--radius-md); padding: var(--space-3) var(--space-4); box-shadow: var(--shadow-lg); font-size: var(--text-sm); min-width: 220px; animation: toastIn 0.25s ease; }
.toast.toast-success { border-left-color: var(--color-success); }
.toast.toast-error { border-left-color: var(--color-danger); }
@keyframes toastIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }

.results-ad { margin: var(--space-5) 0; }

@media (prefers-reduced-motion: reduce) {
  .ring-fill, .bar-fill.animate-fill, .confetti-piece, .toast, .result-badge, .qmap-cell { transition: none !important; animation: none !important; }
}

@media (max-width: 768px) {
  .score-hero { flex-direction: column; text-align: center; }
  .quick-stats-strip { grid-template-columns: repeat(2, 1fr); }
  .question-map { grid-template-columns: repeat(8, 1fr); }
  .bar-name { width: 96px; }
  .bar-num { width: 90px; }
  .results-action-bar .btn { flex: 1; }
}

/* ── Dark mode ─────────────────────────────────────────────────────────────── */
html.dark-mode .score-hero,
html.dark-mode .qstat,
html.dark-mode .analytics-card,
html.dark-mode .result-badge,
html.dark-mode .points-award,
html.dark-mode .question-card,
html.dark-mode .toast { background: var(--color-dark-surface); border-color: var(--color-dark-border); }
html.dark-mode .qc-body { border-color: var(--color-dark-border); }
html.dark-mode .explanation-box-card,
html.dark-mode .reco-item,
html.dark-mode .ft-count { background: var(--color-dark-elevated); }
html.dark-mode .breakdown-bar,
html.dark-mode .bar-track,
html.dark-mode .cmp-track { background: var(--color-dark-border); }
html.dark-mode .ring-bg { stroke: var(--color-dark-border); }
