/* ============================================================
   Moon Life - Exam Preparation Platform
   style.css — Master Stylesheet
   ============================================================
   A bilingual (EN/ZH) exam prep LMS inspired by Sun Life's
   palette, recast with a premium midnight / moon theme.
   ============================================================ */

/* ------------------------------------------------------------
   0.  CSS Custom Properties
   ------------------------------------------------------------ */
:root {
  /* — Brand --------------------------------------------------*/
  --ml-gold:           #FFD700;
  --ml-gold-light:     #FFF3B0;
  --ml-gold-dark:      #C7A600;
  --ml-navy:           #0F0E2A;
  --ml-navy-light:     #1A1840;
  --ml-blue:           #4A90D9;
  --ml-blue-light:     #6BB3F0;

  /* — Surfaces (light mode) ----------------------------------*/
  --ml-surface:        #FFFFFF;
  --ml-surface-alt:    #F8F6FF;
  --ml-text:           #1A1A2E;
  --ml-text-secondary: #6B7280;
  --ml-border:         #E5E7EB;

  /* — Semantic -----------------------------------------------*/
  --ml-success:        #10B981;
  --ml-danger:         #EF4444;
  --ml-warning:        #F59E0B;
  --ml-info:           #3B82F6;

  /* — Shadows ------------------------------------------------*/
  --ml-shadow-sm:   0 1px 2px rgba(0, 0, 0, 0.05);
  --ml-shadow:      0 4px 6px -1px rgba(0, 0, 0, 0.07),
                    0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --ml-shadow-md:   0 10px 15px -3px rgba(0, 0, 0, 0.08),
                    0 4px 6px -4px rgba(0, 0, 0, 0.05);
  --ml-shadow-lg:   0 20px 25px -5px rgba(0, 0, 0, 0.10),
                    0 8px 10px -6px rgba(0, 0, 0, 0.06);

  /* — Radii --------------------------------------------------*/
  --ml-radius-sm: 6px;
  --ml-radius:    10px;
  --ml-radius-lg: 16px;
  --ml-radius-xl: 24px;

  /* — Transitions --------------------------------------------*/
  --ml-transition: 0.2s ease;
  --ml-transition-slow: 0.35s ease;

  /* — Layout -------------------------------------------------*/
  --ml-container-max: 1200px;
  --ml-demo-banner-h: 32px;
  --ml-navbar-h: 64px;

  /* — Font stack ---------------------------------------------*/
  --ml-font-sans:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Noto Sans TC", "Noto Sans SC", "PingFang TC", "Microsoft JhengHei",
    "Helvetica Neue", Arial, sans-serif;
  --ml-font-mono:
    "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

/* — Dark mode overrides ------------------------------------- */
[data-theme="dark"] {
  --ml-surface:        #0F0E2A;
  --ml-surface-alt:    #1A1840;
  --ml-text:           #F3F4F6;
  --ml-text-secondary: #9CA3AF;
  --ml-border:         #374151;

  --ml-shadow-sm:   0 1px 2px rgba(0, 0, 0, 0.30);
  --ml-shadow:      0 4px 6px -1px rgba(0, 0, 0, 0.35),
                    0 2px 4px -2px rgba(0, 0, 0, 0.25);
  --ml-shadow-md:   0 10px 15px -3px rgba(0, 0, 0, 0.40),
                    0 4px 6px -4px rgba(0, 0, 0, 0.30);
  --ml-shadow-lg:   0 20px 25px -5px rgba(0, 0, 0, 0.50),
                    0 8px 10px -6px rgba(0, 0, 0, 0.35);
}

/* ------------------------------------------------------------
   1.  Reset & Base
   ------------------------------------------------------------ */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  -moz-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: var(--ml-font-sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--ml-text);
  background-color: var(--ml-surface);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  padding-top: calc(var(--ml-demo-banner-h) + var(--ml-navbar-h));
  min-height: 100vh;
  transition: background-color var(--ml-transition), color var(--ml-transition);
}

img, picture, video, canvas, svg {
  display: block;
  max-width: 100%;
}

input, button, textarea, select {
  font: inherit;
  color: inherit;
}

a {
  color: var(--ml-blue);
  text-decoration: none;
  transition: color var(--ml-transition);
}

a:hover {
  color: var(--ml-blue-light);
}

ul, ol {
  list-style: none;
}

table {
  border-collapse: collapse;
  width: 100%;
}

/* ------------------------------------------------------------
   2.  Demo Banner (fixed top)
   ------------------------------------------------------------ */
.ml-demo-banner {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: var(--ml-demo-banner-h);
  background: var(--ml-gold);
  color: #000000;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  z-index: 9999;
  user-select: none;
}

.ml-demo-banner a {
  color: var(--ml-navy);
  text-decoration: underline;
  margin-left: 0.5rem;
}

/* ------------------------------------------------------------
   3.  Header & Navbar
   ------------------------------------------------------------ */
.ml-header {
  position: relative;
}

.ml-navbar {
  position: fixed;
  top: var(--ml-demo-banner-h);
  left: 0;
  width: 100%;
  height: var(--ml-navbar-h);
  background: var(--ml-navy);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  z-index: 1000;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
}

.ml-navbar-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--ml-gold);
  letter-spacing: 0.01em;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}

.ml-navbar-brand:hover {
  color: var(--ml-gold-light);
}

/* Logo parts */
.ml-logo-icon {
  font-size: 1.5rem;
}

.ml-logo-text {
  font-weight: 800;
  color: var(--ml-gold);
}

/* — Nav menu container (desktop: flex row; mobile: dropdown) ---*/
.ml-nav-menu {
  display: flex;
  align-items: center;
  flex: 1;
  justify-content: space-between;
  margin-left: 2rem;
}

/* — Nav links ------------------------------------------------*/
.ml-nav-links {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.ml-nav-link {
  color: rgba(255, 255, 255, 0.8);
  padding: 0.5rem 0.875rem;
  border-radius: var(--ml-radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  transition: color var(--ml-transition), background var(--ml-transition);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}

.ml-nav-link:hover {
  color: var(--ml-gold);
  background: rgba(255, 215, 0, 0.08);
}

/* Active state — HTML uses ml-nav-link-active class */
.ml-nav-link-active,
.ml-nav-link.active {
  color: var(--ml-gold);
  background: rgba(255, 215, 0, 0.12);
}

/* — Nav actions (right side: language, theme, auth) ----------*/
.ml-nav-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

/* — Nav user (login/logout group) ---------------------------*/
.ml-nav-user {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.ml-username {
  color: #fff;
  font-size: 0.85rem;
  font-weight: 500;
}

/* Login / Logout buttons (use ml-btn-outline base) */
.ml-login-btn,
.ml-logout-btn {
  /* inherits from .ml-btn.ml-btn-outline */
}

/* JS-controlled visibility classes */
.ml-nav-auth-only,
.ml-nav-admin-only {
  /* display controlled by JS; no default hiding needed — they use inline style="display:none;" */
}

/* — Language toggle ------------------------------------------*/
.ml-lang-toggle {
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

/* — Dark mode toggle -----------------------------------------*/
.ml-theme-toggle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.8);
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--ml-transition);
}

.ml-theme-toggle:hover {
  background: rgba(255, 215, 0, 0.15);
  color: var(--ml-gold);
  border-color: rgba(255, 215, 0, 0.3);
}

.ml-theme-icon {
  font-size: 1.1rem;
  line-height: 1;
}

/* — Hamburger (mobile) ----------------------------------------*/
.ml-hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 4px;
}

.ml-hamburger span,
.ml-hamburger-bar {
  display: block;
  width: 100%;
  height: 2px;
  background: #fff;
  border-radius: 2px;
  transition: transform var(--ml-transition), opacity var(--ml-transition);
}

.ml-hamburger.active span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.ml-hamburger.active span:nth-child(2) {
  opacity: 0;
}

.ml-hamburger.active span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* ------------------------------------------------------------
   4.  Page Layout & Visibility System
   ------------------------------------------------------------ */
.ml-main {
  min-height: calc(100vh - var(--ml-demo-banner-h) - var(--ml-navbar-h) - 120px);
}

.ml-page {
  display: none;
}

/* HTML uses ml-page-active class (not .ml-page.active) */
.ml-page-active {
  display: block !important;
}

/* Keep legacy .active support too */
.ml-page.active {
  display: block;
}

.ml-container {
  width: 100%;
  max-width: var(--ml-container-max);
  margin: 0 auto;
  padding: 0 1.5rem;
}

.ml-section {
  padding: 3rem 1.5rem;
  max-width: var(--ml-container-max);
  margin: 0 auto;
}

.ml-section-title {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: var(--ml-text);
}

.ml-section-subtitle {
  color: var(--ml-text-secondary);
  font-size: 1.05rem;
  margin-bottom: 2rem;
}

/* ------------------------------------------------------------
   5.  Hero Section
   ------------------------------------------------------------ */
.ml-hero {
  background: linear-gradient(
    135deg,
    var(--ml-navy) 0%,
    var(--ml-navy-light) 60%,
    #2a2460 100%
  );
  position: relative;
  padding: 5rem 1.5rem 4rem;
  overflow: hidden;
  color: #fff;
}

.ml-hero::before {
  content: "";
  position: absolute;
  top: -40%;
  right: -10%;
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(255, 215, 0, 0.10) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
}

.ml-hero::after {
  content: "";
  position: absolute;
  bottom: -20%;
  left: -5%;
  width: 350px;
  height: 350px;
  background: radial-gradient(circle, rgba(74, 144, 217, 0.08) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
}

.ml-hero-content {
  position: relative;
  z-index: 1;
  max-width: 700px;
  margin: 0 auto;
  text-align: center;
}

.ml-hero-title {
  font-size: 3rem;
  font-weight: 800;
  line-height: 1.15;
  margin-bottom: 1rem;
  letter-spacing: -0.02em;
  color: #fff;
}

.ml-hero h1 {
  font-size: 3rem;
  font-weight: 800;
  line-height: 1.15;
  margin-bottom: 1rem;
  letter-spacing: -0.02em;
}

.ml-hero h1 .highlight {
  color: var(--ml-gold);
}

.ml-hero-subtitle {
  font-size: 1.2rem;
  line-height: 1.7;
  opacity: 0.85;
  margin-bottom: 2rem;
  max-width: 560px;
  margin-left: auto;
  margin-right: auto;
  color: rgba(255, 255, 255, 0.85);
}

.ml-hero p {
  font-size: 1.2rem;
  line-height: 1.7;
  opacity: 0.85;
  margin-bottom: 2rem;
  max-width: 560px;
}

/* IMPORTANT: ml-hero-cta is a FLEX CONTAINER for buttons, NOT a button itself */
.ml-hero-cta {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: center;
}

/* ------------------------------------------------------------
   6.  Cards & Grid
   ------------------------------------------------------------ */
.ml-card {
  background: var(--ml-surface);
  border: 1px solid var(--ml-border);
  border-radius: var(--ml-radius-lg);
  padding: 1.75rem;
  box-shadow: var(--ml-shadow);
  transition: transform var(--ml-transition), box-shadow var(--ml-transition),
              background var(--ml-transition), border-color var(--ml-transition);
}

.ml-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--ml-shadow-md);
}

.ml-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--ml-border);
}

.ml-card-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--ml-text);
}

.ml-card-body {
  color: var(--ml-text-secondary);
  font-size: 0.95rem;
  line-height: 1.65;
}

.ml-card-grid {
  display: grid;
  grid-template-columns: repeat(1, 1fr);
  gap: 1.5rem;
}

@media (min-width: 768px) {
  .ml-card-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  .ml-card-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* — Stat cards ------------------------------------------------*/
.ml-stat-card {
  background: var(--ml-surface);
  border: 1px solid var(--ml-border);
  border-top: 3px solid var(--ml-gold);
  border-radius: var(--ml-radius);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--ml-shadow-sm);
  transition: all var(--ml-transition);
  text-align: center;
}

.ml-stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--ml-shadow);
}

/* ml-stat-value — used directly in HTML (not .stat-value) */
.ml-stat-value {
  font-size: 2rem;
  font-weight: 800;
  color: var(--ml-text);
  line-height: 1.2;
}

/* ml-stat-label — used directly in HTML (not .stat-label) */
.ml-stat-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ml-text-secondary);
  font-weight: 600;
  margin-top: 0.25rem;
}

/* Legacy descendant selectors (keep for compatibility) */
.ml-stat-card .stat-value {
  font-size: 2rem;
  font-weight: 800;
  color: var(--ml-text);
  line-height: 1.2;
}

.ml-stat-card .stat-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ml-text-secondary);
  font-weight: 600;
  margin-top: 0.25rem;
}

.ml-stat-card.accent-success { border-top-color: var(--ml-success); }
.ml-stat-card.accent-danger  { border-top-color: var(--ml-danger);  }
.ml-stat-card.accent-info    { border-top-color: var(--ml-info);    }
.ml-stat-card.accent-gold    { border-top-color: var(--ml-gold);    }

/* — Stats grid (home page / dashboard) -----------------------*/
.ml-stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

@media (min-width: 768px) {
  .ml-stats-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.ml-stats-section {
  /* Additional wrapper styling if needed */
}

/* — Feature cards (landing page) -----------------------------*/
.ml-feature-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

@media (min-width: 640px) {
  .ml-feature-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  .ml-feature-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.ml-feature-card {
  text-align: center;
  padding: 2rem 1.5rem;
  background: var(--ml-surface);
  border: 1px solid var(--ml-border);
  border-radius: var(--ml-radius-lg);
  box-shadow: var(--ml-shadow-sm);
  transition: transform var(--ml-transition), box-shadow var(--ml-transition),
              background var(--ml-transition), border-color var(--ml-transition);
}

.ml-feature-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--ml-shadow-md);
}

.ml-feature-icon {
  font-size: 2.5rem;
  margin-bottom: 1rem;
}

.ml-feature-card-title {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: var(--ml-text);
}

.ml-feature-card-desc {
  color: var(--ml-text-secondary);
  font-size: 0.92rem;
  line-height: 1.6;
}

/* Legacy descendant selectors */
.ml-feature-card .feature-icon { font-size: 2.5rem; margin-bottom: 1rem; }
.ml-feature-card h3 { font-size: 1.15rem; font-weight: 700; margin-bottom: 0.5rem; color: var(--ml-text); }
.ml-feature-card p { color: var(--ml-text-secondary); font-size: 0.92rem; line-height: 1.6; }

/* ------------------------------------------------------------
   7.  Forms & Buttons
   ------------------------------------------------------------ */

/* — Form containers ------------------------------------------*/
.ml-form {
  width: 100%;
}

.ml-form-error {
  color: var(--ml-danger);
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.5rem 0.75rem;
  margin-bottom: 1rem;
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: var(--ml-radius-sm);
}

.ml-form-fieldset {
  border: 1px solid var(--ml-border);
  border-radius: var(--ml-radius);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

.ml-form-fieldset legend {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--ml-text);
  padding: 0 0.5rem;
}

.ml-form-inline {
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
}

.ml-form-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  padding-top: 1rem;
}

/* — Inputs ---------------------------------------------------*/
.ml-input,
.ml-select,
.ml-textarea {
  width: 100%;
  padding: 0.7rem 1rem;
  font-size: 0.95rem;
  color: var(--ml-text);
  background: var(--ml-surface);
  border: 1.5px solid var(--ml-border);
  border-radius: var(--ml-radius-sm);
  transition: border-color var(--ml-transition), box-shadow var(--ml-transition),
              background var(--ml-transition);
  outline: none;
}

.ml-input:focus,
.ml-select:focus,
.ml-textarea:focus {
  border-color: var(--ml-gold);
  box-shadow: 0 0 0 3px rgba(255, 215, 0, 0.15);
}

.ml-input::placeholder,
.ml-textarea::placeholder {
  color: var(--ml-text-secondary);
  opacity: 0.7;
}

.ml-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%236B7280' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.85rem center;
  padding-right: 2.5rem;
}

.ml-textarea {
  resize: vertical;
  min-height: 100px;
}

/* Small variants */
.ml-input-sm {
  padding: 0.4rem 0.7rem;
  font-size: 0.85rem;
  height: auto;
}

.ml-select-sm {
  padding: 0.4rem 2rem 0.4rem 0.7rem;
  font-size: 0.85rem;
  height: auto;
}

/* Form group */
.ml-form-group {
  margin-bottom: 1.25rem;
}

.ml-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--ml-text);
  margin-bottom: 0.4rem;
}

.ml-form-hint {
  font-size: 0.8rem;
  color: var(--ml-text-secondary);
  margin-top: 0.3rem;
}

/* — Checkbox & Radio -----------------------------------------*/
.ml-checkbox,
.ml-radio {
  accent-color: var(--ml-gold);
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.ml-checkbox-label,
.ml-radio-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--ml-text);
  padding: 0.25rem 0;
}

.ml-checkbox-group {
  margin-bottom: 0.75rem;
}

.ml-radio-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* — Buttons --------------------------------------------------*/
.ml-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.6rem 1.25rem;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: var(--ml-radius-sm);
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: all var(--ml-transition);
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.4;
  user-select: none;
  background: transparent;
}

.ml-btn:focus-visible {
  outline: 2px solid var(--ml-gold);
  outline-offset: 2px;
}

.ml-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* Primary — gold */
.ml-btn-primary {
  background: var(--ml-gold);
  color: var(--ml-navy);
  border-color: var(--ml-gold);
}

.ml-btn-primary:hover {
  background: var(--ml-gold-dark);
  border-color: var(--ml-gold-dark);
  box-shadow: 0 4px 12px rgba(255, 215, 0, 0.30);
}

/* Secondary — navy */
.ml-btn-secondary {
  background: var(--ml-navy);
  color: #fff;
  border-color: var(--ml-navy);
}

.ml-btn-secondary:hover {
  background: var(--ml-navy-light);
  border-color: var(--ml-navy-light);
}

/* Outline */
.ml-btn-outline {
  background: transparent;
  color: var(--ml-text);
  border-color: var(--ml-border);
}

.ml-btn-outline:hover {
  border-color: var(--ml-gold);
  color: var(--ml-gold);
  background: rgba(255, 215, 0, 0.06);
}

/* Ghost — transparent bg, text color, subtle hover */
.ml-btn-ghost {
  background: transparent;
  color: var(--ml-text);
  border-color: transparent;
}

.ml-btn-ghost:hover {
  background: rgba(255, 215, 0, 0.08);
  color: var(--ml-gold);
}

/* In navbar context, ghost buttons should be white text */
.ml-navbar .ml-btn-ghost,
.ml-nav-actions .ml-btn-ghost {
  color: rgba(255, 255, 255, 0.8);
}

.ml-navbar .ml-btn-ghost:hover,
.ml-nav-actions .ml-btn-ghost:hover {
  color: var(--ml-gold);
  background: rgba(255, 215, 0, 0.1);
}

/* Block — full width */
.ml-btn-block {
  width: 100%;
  display: flex;
}

/* Icon — square button */
.ml-btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--ml-radius-sm);
  border: 1.5px solid var(--ml-border);
  background: transparent;
  color: var(--ml-text-secondary);
  font-size: 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.ml-btn-icon:hover {
  border-color: var(--ml-gold);
  color: var(--ml-gold);
  background: rgba(255, 215, 0, 0.06);
}

/* Success */
.ml-btn-success {
  background: var(--ml-success);
  color: #fff;
  border-color: var(--ml-success);
}

.ml-btn-success:hover {
  background: #0ea572;
  border-color: #0ea572;
}

/* Danger */
.ml-btn-danger {
  background: var(--ml-danger);
  color: #fff;
  border-color: var(--ml-danger);
}

.ml-btn-danger:hover {
  background: #dc2626;
  border-color: #dc2626;
}

/* Sizes */
.ml-btn-sm {
  padding: 0.35rem 0.85rem;
  font-size: 0.8rem;
}

.ml-btn-lg {
  padding: 0.85rem 1.75rem;
  font-size: 1.05rem;
}

/* Button group */
.ml-btn-group {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* ------------------------------------------------------------
   8.  Auth Pages (Login / Register)
   ------------------------------------------------------------ */
.ml-auth-section {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem 1.5rem;
  min-height: 60vh;
}

.ml-auth-card {
  width: 100%;
  max-width: 450px;
  margin: 0 auto;
  background: var(--ml-surface);
  border: 1px solid var(--ml-border);
  border-radius: var(--ml-radius-xl);
  padding: 2.5rem;
  box-shadow: var(--ml-shadow-md);
  transition: background var(--ml-transition), border-color var(--ml-transition);
}

.ml-auth-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--ml-text);
  margin-bottom: 1.5rem;
  text-align: center;
}

.ml-auth-link {
  text-align: center;
  margin-top: 1.25rem;
  font-size: 0.9rem;
  color: var(--ml-text-secondary);
}

.ml-auth-link a {
  color: var(--ml-gold);
  font-weight: 600;
  text-decoration: none;
}

.ml-auth-link a:hover {
  color: var(--ml-gold-light);
  text-decoration: underline;
}

/* Demo accounts info box */
.ml-demo-accounts {
  margin-top: 1.5rem;
  padding: 1rem 1.25rem;
  border: 1px solid var(--ml-border);
  border-radius: var(--ml-radius);
  background: var(--ml-surface-alt);
}

.ml-demo-accounts-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--ml-text);
  margin-bottom: 0.75rem;
}

.ml-demo-accounts-table {
  width: 100%;
  font-size: 0.82rem;
}

.ml-demo-accounts-table th {
  text-align: left;
  font-weight: 700;
  padding: 0.35rem 0.5rem;
  color: var(--ml-text-secondary);
  border-bottom: 1px solid var(--ml-border);
}

.ml-demo-accounts-table td {
  padding: 0.35rem 0.5rem;
  color: var(--ml-text);
  border-bottom: 1px solid var(--ml-border);
}

.ml-demo-accounts-table code {
  font-family: var(--ml-font-mono);
  background: var(--ml-surface);
  padding: 0.15rem 0.35rem;
  border-radius: 4px;
  font-size: 0.82rem;
  border: 1px solid var(--ml-border);
}

/* ------------------------------------------------------------
   9.  Quiz Setup
   ------------------------------------------------------------ */
.ml-quiz-setup-card {
  max-width: 700px;
  margin: 2rem auto;
  background: var(--ml-surface);
  border: 1px solid var(--ml-border);
  border-radius: var(--ml-radius-xl);
  padding: 2.5rem;
  box-shadow: var(--ml-shadow-md);
  transition: background var(--ml-transition), border-color var(--ml-transition);
}

/* — Tab bar (used in quiz setup, dashboard, admin) -----------*/
.ml-tab-bar {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--ml-border);
  margin-bottom: 1.5rem;
}

.ml-tab {
  padding: 0.6rem 1.25rem;
  font-size: 0.9rem;
  font-weight: 600;
  border: none;
  background: transparent;
  color: var(--ml-text-secondary);
  cursor: pointer;
  transition: all var(--ml-transition);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
}

.ml-tab:hover {
  color: var(--ml-text);
}

/* Active tab — HTML uses ml-tab-active class */
.ml-tab-active,
.ml-tab.active {
  color: var(--ml-gold);
  border-bottom-color: var(--ml-gold);
  font-weight: 700;
}

[data-theme="dark"] .ml-tab-active,
[data-theme="dark"] .ml-tab.active {
  color: var(--ml-gold);
}

/* — Paper selector -------------------------------------------*/
.ml-paper-selector {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.ml-paper-btn {
  min-width: 60px;
  padding: 0.65rem 1rem;
  border: 2px solid var(--ml-border);
  border-radius: var(--ml-radius);
  background: var(--ml-surface);
  color: var(--ml-text);
  cursor: pointer;
  text-align: center;
  font-weight: 600;
  font-size: 0.9rem;
  transition: all var(--ml-transition);
  user-select: none;
}

.ml-paper-btn:hover {
  border-color: var(--ml-gold-dark);
  background: rgba(255, 215, 0, 0.04);
}

/* Active paper — HTML uses ml-paper-btn-active class */
.ml-paper-btn-active,
.ml-paper-btn.active {
  background: var(--ml-gold);
  color: var(--ml-navy);
  border-color: var(--ml-gold);
  box-shadow: 0 0 0 3px rgba(255, 215, 0, 0.15);
}

.ml-paper-btn-label {
  font-weight: 700;
}

.ml-iiqe-paper {
  /* Display controlled by JS */
}

/* — Mode selector --------------------------------------------*/
.ml-mode-selector {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.ml-mode-card {
  flex: 1;
  min-width: 140px;
  padding: 1.25rem;
  border: 2px solid var(--ml-border);
  border-radius: var(--ml-radius);
  background: var(--ml-surface);
  cursor: pointer;
  text-align: center;
  transition: all var(--ml-transition);
  user-select: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}

.ml-mode-card:hover {
  border-color: var(--ml-gold-dark);
  background: rgba(255, 215, 0, 0.03);
}

/* Active mode — HTML uses ml-mode-card-active class */
.ml-mode-card-active,
.ml-mode-card.active {
  border-color: var(--ml-gold);
  background: rgba(255, 215, 0, 0.06);
  box-shadow: 0 0 0 3px rgba(255, 215, 0, 0.15);
}

.ml-mode-icon {
  font-size: 2rem;
  margin-bottom: 0.25rem;
}

.ml-mode-label {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--ml-text);
}

.ml-mode-desc {
  font-size: 0.8rem;
  color: var(--ml-text-secondary);
  line-height: 1.4;
}

/* Available count display */
.ml-available-count {
  padding: 0.75rem 1rem;
  background: var(--ml-surface-alt);
  border-radius: var(--ml-radius-sm);
  font-size: 0.9rem;
  color: var(--ml-text-secondary);
  margin-bottom: 1.25rem;
}

/* Exam-only elements (display controlled by JS) */
.ml-exam-only {
  /* Display toggled by JS */
}

/* Input groups */
.ml-input-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.ml-input-group .ml-label {
  min-width: 120px;
  margin-bottom: 0;
}

.ml-input-group .ml-input,
.ml-input-group .ml-select {
  flex: 1;
}

/* ------------------------------------------------------------
   10.  Quiz Interface
   ------------------------------------------------------------ */

/* — Quiz top bar ---------------------------------------------*/
.ml-quiz-topbar {
  position: sticky;
  top: calc(var(--ml-demo-banner-h) + var(--ml-navbar-h));
  background: var(--ml-surface);
  border-bottom: 1px solid var(--ml-border);
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  z-index: 100;
  box-shadow: var(--ml-shadow-sm);
  transition: background var(--ml-transition), border-color var(--ml-transition);
}

.ml-quiz-topbar-left,
.ml-quiz-topbar-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* — Timer ----------------------------------------------------*/
.ml-quiz-timer {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 1.1rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--ml-text);
  padding: 0.35rem 0.75rem;
  border-radius: var(--ml-radius-sm);
  background: var(--ml-surface-alt);
  transition: all var(--ml-transition);
}

.ml-quiz-timer.warning {
  color: var(--ml-danger);
  background: rgba(239, 68, 68, 0.1);
  animation: pulse 1s ease infinite;
}

.ml-timer-icon {
  font-size: 1rem;
}

/* Legacy .ml-timer class */
.ml-timer {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 1.1rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--ml-text);
  padding: 0.35rem 0.75rem;
  border-radius: var(--ml-radius-sm);
  background: var(--ml-surface-alt);
  transition: all var(--ml-transition);
}

.ml-timer.warning {
  color: var(--ml-danger);
  background: rgba(239, 68, 68, 0.1);
  animation: pulse 1s ease infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* — Progress display -----------------------------------------*/
.ml-quiz-progress {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--ml-text);
  white-space: nowrap;
}

/* — Progress bar ---------------------------------------------*/
.ml-progress-bar {
  width: 100%;
  height: 4px;
  background: var(--ml-border);
  border-radius: 4px;
  overflow: hidden;
}

.ml-progress-bar-fill {
  height: 100%;
  background: var(--ml-gold);
  border-radius: 4px;
  transition: width 0.4s ease;
}

.ml-progress-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ml-text-secondary);
  white-space: nowrap;
}

/* — Quiz body (sidebar + content layout) ---------------------*/
.ml-quiz-body {
  display: flex;
  gap: 1.5rem;
  padding: 1.5rem;
  max-width: var(--ml-container-max);
  margin: 0 auto;
}

.ml-quiz-content {
  flex: 1;
  min-width: 0;
}

/* — Question navigator sidebar -------------------------------*/
.ml-quiz-navigator {
  width: 250px;
  min-width: 250px;
  background: var(--ml-surface);
  border: 1px solid var(--ml-border);
  border-radius: var(--ml-radius);
  padding: 1.25rem;
  align-self: flex-start;
  position: sticky;
  top: calc(var(--ml-demo-banner-h) + var(--ml-navbar-h) + 60px);
}

.ml-navigator-title {
  font-size: 1rem;
  font-weight: 700;
  padding-bottom: 0.75rem;
  margin-bottom: 0.75rem;
  border-bottom: 1px solid var(--ml-border);
  color: var(--ml-text);
}

/* — Question card --------------------------------------------*/
.ml-question-card {
  background: var(--ml-surface);
  border: 1px solid var(--ml-border);
  border-radius: var(--ml-radius-lg);
  padding: 2rem;
  box-shadow: var(--ml-shadow);
  transition: background var(--ml-transition), border-color var(--ml-transition);
}

.ml-question-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--ml-border);
}

.ml-question-qid {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--ml-text-secondary);
  background: var(--ml-surface-alt);
  padding: 0.25rem 0.6rem;
  border-radius: var(--ml-radius-sm);
  font-family: var(--ml-font-mono);
}

.ml-question-topic {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--ml-text-secondary);
  background: var(--ml-surface-alt);
  border: 1px solid var(--ml-border);
  padding: 0.2rem 0.6rem;
  border-radius: 10px;
}

.ml-question-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.ml-question-text {
  font-size: 1.1rem;
  font-weight: 500;
  line-height: 1.7;
  color: var(--ml-text);
  margin-bottom: 1.75rem;
}

/* — Options --------------------------------------------------*/
.ml-options {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.ml-option-card {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  padding: 1rem 1.25rem;
  border: 2px solid var(--ml-border);
  border-radius: var(--ml-radius);
  cursor: pointer;
  transition: all var(--ml-transition);
  background: var(--ml-surface);
  user-select: none;
  text-align: left;
  width: 100%;
}

.ml-option-card:hover {
  border-color: var(--ml-blue-light);
  background: rgba(74, 144, 217, 0.04);
}

.ml-option-letter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  min-width: 32px;
  border-radius: 50%;
  background: var(--ml-surface-alt);
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--ml-text-secondary);
  transition: all var(--ml-transition);
}

.ml-option-text {
  flex: 1;
  padding-top: 0.25rem;
  line-height: 1.55;
  color: var(--ml-text);
}

/* Selected */
.ml-option-card.selected,
.ml-option-card.ml-option-selected {
  border-color: var(--ml-blue);
  background: rgba(74, 144, 217, 0.06);
}

.ml-option-card.selected .ml-option-letter,
.ml-option-card.ml-option-selected .ml-option-letter {
  background: var(--ml-blue);
  color: #fff;
}

/* Correct */
.ml-option-card.correct,
.ml-option-card.ml-option-correct {
  border-color: var(--ml-success);
  background: rgba(16, 185, 129, 0.06);
}

.ml-option-card.correct .ml-option-letter,
.ml-option-card.ml-option-correct .ml-option-letter {
  background: var(--ml-success);
  color: #fff;
}

/* Wrong */
.ml-option-card.wrong,
.ml-option-card.ml-option-wrong {
  border-color: var(--ml-danger);
  background: rgba(239, 68, 68, 0.06);
}

.ml-option-card.wrong .ml-option-letter,
.ml-option-card.ml-option-wrong .ml-option-letter {
  background: var(--ml-danger);
  color: #fff;
}

/* Legacy .ml-option selectors (keep for compatibility) */
.ml-options-list { display: flex; flex-direction: column; gap: 0.75rem; margin-bottom: 1.5rem; }
.ml-option { display: flex; align-items: flex-start; gap: 0.85rem; padding: 1rem 1.25rem; border: 2px solid var(--ml-border); border-radius: var(--ml-radius); cursor: pointer; transition: all var(--ml-transition); background: var(--ml-surface); user-select: none; }
.ml-option:hover { border-color: var(--ml-blue-light); background: rgba(74, 144, 217, 0.04); }
.ml-option .option-letter { display: flex; align-items: center; justify-content: center; width: 32px; height: 32px; min-width: 32px; border-radius: 50%; background: var(--ml-surface-alt); font-weight: 700; font-size: 0.85rem; color: var(--ml-text-secondary); transition: all var(--ml-transition); }
.ml-option .option-text { padding-top: 0.25rem; line-height: 1.55; color: var(--ml-text); }
.ml-option.selected { border-color: var(--ml-blue); background: rgba(74, 144, 217, 0.06); }
.ml-option.selected .option-letter { background: var(--ml-blue); color: #fff; }
.ml-option.correct { border-color: var(--ml-success); background: rgba(16, 185, 129, 0.06); }
.ml-option.correct .option-letter { background: var(--ml-success); color: #fff; }
.ml-option.wrong { border-color: var(--ml-danger); background: rgba(239, 68, 68, 0.06); }
.ml-option.wrong .option-letter { background: var(--ml-danger); color: #fff; }

/* — Hint box ------------------------------------------------*/
.ml-hint-box {
  margin-top: 1.25rem;
  padding: 1.25rem;
  border: 1px solid var(--ml-border);
  border-left: 4px solid var(--ml-gold);
  border-radius: var(--ml-radius-sm);
  background: rgba(255, 215, 0, 0.06);
  transition: background var(--ml-transition), border-color var(--ml-transition);
}

.ml-hint-title {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--ml-gold-dark);
  margin-bottom: 0.5rem;
}

[data-theme="dark"] .ml-hint-title {
  color: var(--ml-gold);
}

.ml-hint-text {
  font-size: 0.92rem;
  line-height: 1.7;
  color: var(--ml-text);
  white-space: pre-wrap;
}

/* — Explanation box ------------------------------------------*/
.ml-explanation-box {
  margin-top: 1.25rem;
  padding: 1.25rem;
  border: 1px solid var(--ml-border);
  border-left: 4px solid var(--ml-info);
  border-radius: var(--ml-radius-sm);
  background: var(--ml-surface-alt);
  transition: background var(--ml-transition), border-color var(--ml-transition);
}

.ml-explanation-title {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--ml-info);
  margin-bottom: 0.5rem;
}

.ml-explanation-text {
  font-size: 0.92rem;
  line-height: 1.65;
  color: var(--ml-text);
  white-space: pre-wrap;
}

/* Legacy .ml-explanation */
.ml-explanation {
  margin-top: 1.25rem;
  padding: 1.25rem;
  border: 1px solid var(--ml-border);
  border-left: 4px solid var(--ml-info);
  border-radius: var(--ml-radius-sm);
  background: var(--ml-surface-alt);
  transition: background var(--ml-transition), border-color var(--ml-transition);
}

.ml-explanation p {
  font-size: 0.92rem;
  line-height: 1.65;
  color: var(--ml-text);
}

/* — Note section ---------------------------------------------*/
.ml-note-section {
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--ml-border);
}

/* — Quiz navigation (prev/next) ------------------------------*/
.ml-quiz-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--ml-border);
}

/* — Navigator grid -------------------------------------------*/
.ml-navigator-grid {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 6px;
  margin-bottom: 1rem;
}

.ml-navigator-cell,
.ml-nav-cell {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 4px;
  border: 1.5px solid var(--ml-border);
  background: var(--ml-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--ml-transition);
  color: var(--ml-text-secondary);
}

.ml-navigator-cell:hover,
.ml-nav-cell:hover {
  border-color: var(--ml-gold);
}

.ml-navigator-cell.current,
.ml-nav-cell.ml-nav-current {
  border-color: var(--ml-blue);
  background: rgba(74, 144, 217, 0.1);
  color: var(--ml-blue);
}

.ml-navigator-cell.answered,
.ml-nav-cell.ml-nav-answered {
  background: var(--ml-gold);
  border-color: var(--ml-gold);
  color: var(--ml-navy);
}

.ml-navigator-cell.flagged,
.ml-nav-cell.ml-nav-flagged {
  background: var(--ml-warning);
  border-color: var(--ml-warning);
  color: #fff;
}

.ml-navigator-cell.correct,
.ml-nav-cell.ml-nav-correct {
  background: var(--ml-success);
  border-color: var(--ml-success);
  color: #fff;
}

.ml-navigator-cell.wrong,
.ml-nav-cell.ml-nav-wrong {
  background: var(--ml-danger);
  border-color: var(--ml-danger);
  color: #fff;
}

/* Navigator legend */
.ml-navigator-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  font-size: 0.75rem;
  color: var(--ml-text-secondary);
}

.ml-navigator-legend span {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.ml-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  color: var(--ml-text-secondary);
}

.ml-legend-color {
  width: 16px;
  height: 16px;
  border-radius: 3px;
  display: inline-block;
}

.ml-legend-unanswered {
  background: var(--ml-border);
}

.ml-legend-answered {
  background: var(--ml-blue);
}

.ml-legend-flagged {
  background: var(--ml-warning);
}

/* Legacy .ml-legend-dot */
.ml-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  display: inline-block;
}

/* ------------------------------------------------------------
   11.  Results Screen
   ------------------------------------------------------------ */
.ml-results-score-card {
  text-align: center;
  padding: 2.5rem 1.5rem;
  background: var(--ml-surface);
  border: 1px solid var(--ml-border);
  border-radius: var(--ml-radius-xl);
  box-shadow: var(--ml-shadow-md);
  max-width: 500px;
  margin: 0 auto 2rem;
  transition: background var(--ml-transition), border-color var(--ml-transition);
}

.ml-score-circle {
  position: relative;
  width: 180px;
  height: 180px;
  margin: 0 auto 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 6px solid var(--ml-border);
}

.ml-score-pct {
  font-size: 2.75rem;
  font-weight: 800;
  line-height: 1;
  color: var(--ml-text);
}

.ml-score-circle svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.ml-score-circle .score-bg {
  fill: none;
  stroke: var(--ml-border);
  stroke-width: 8;
}

.ml-score-circle .score-fill {
  fill: none;
  stroke-width: 8;
  stroke-linecap: round;
  transition: stroke-dashoffset 1s ease;
}

.ml-score-circle .score-value {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.ml-score-circle .score-number {
  font-size: 2.75rem;
  font-weight: 800;
  line-height: 1;
}

.ml-score-circle .score-label {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ml-text-secondary);
  margin-top: 0.25rem;
}

.ml-score-verdict {
  font-size: 1.5rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-top: 0.5rem;
}

/* Pass / Fail colors */
.ml-pass .score-fill { stroke: var(--ml-success); }
.ml-pass .score-number { color: var(--ml-success); }
.ml-fail .score-fill { stroke: var(--ml-danger); }
.ml-fail .score-number { color: var(--ml-danger); }

/* Results stats grid */
.ml-results-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  max-width: 600px;
  margin: 0 auto 2rem;
}

@media (min-width: 768px) {
  .ml-results-stats {
    grid-template-columns: repeat(4, 1fr);
  }
}

.ml-results-stat {
  text-align: center;
  padding: 1rem;
  background: var(--ml-surface);
  border: 1px solid var(--ml-border);
  border-radius: var(--ml-radius);
}

.ml-results-stat-value {
  font-size: 1.75rem;
  font-weight: 800;
  line-height: 1.2;
}

.ml-results-stat-label {
  font-size: 0.8rem;
  color: var(--ml-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
  margin-top: 0.25rem;
}

/* Stat color modifiers */
.ml-stat-correct {
  color: var(--ml-success);
}

.ml-stat-wrong {
  color: var(--ml-danger);
}

.ml-stat-unanswered {
  color: var(--ml-text-secondary);
}

/* Results actions */
.ml-results-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 2rem;
}

/* Review cards */
.ml-review-cards {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.ml-review-card {
  background: var(--ml-surface);
  border: 1px solid var(--ml-border);
  border-radius: var(--ml-radius);
  padding: 1.25rem;
  transition: background var(--ml-transition), border-color var(--ml-transition);
}

/* Review card status (left border) */
.ml-review-card.review-correct,
.ml-review-card.ml-review-correct {
  border-left: 4px solid var(--ml-success);
}
.ml-review-card.review-wrong,
.ml-review-card.ml-review-wrong {
  border-left: 4px solid var(--ml-danger);
}
.ml-review-card.review-skipped,
.ml-review-card.ml-review-unanswered {
  border-left: 4px solid var(--ml-text-secondary);
}

/* Review card header */
.ml-review-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--ml-border);
}
.ml-review-qid {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--ml-text-secondary);
}
.ml-review-status {
  font-weight: 700;
  font-size: 0.8rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
}
.ml-review-status.ml-review-correct { color: var(--ml-success); background: rgba(16,185,129,0.1); }
.ml-review-status.ml-review-wrong { color: var(--ml-danger); background: rgba(239,68,68,0.1); }
.ml-review-status.ml-review-unanswered { color: var(--ml-text-secondary); background: var(--ml-surface-alt); }

/* Review question text */
.ml-review-question {
  margin-bottom: 0.75rem;
  line-height: 1.6;
  font-size: 0.95rem;
}

/* Review options list */
.ml-review-options {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}
.ml-review-opt {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.6rem 0.85rem;
  border: 1.5px solid var(--ml-border);
  border-radius: var(--ml-radius);
  background: var(--ml-surface);
  transition: all var(--ml-transition);
}
.ml-review-opt-letter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  min-width: 26px;
  border-radius: 50%;
  background: var(--ml-surface-alt);
  font-weight: 700;
  font-size: 0.78rem;
  color: var(--ml-text-secondary);
  flex-shrink: 0;
}
.ml-review-opt-text {
  flex: 1;
  line-height: 1.5;
  font-size: 0.9rem;
  padding-top: 0.1rem;
}
/* Correct option */
.ml-review-opt-correct {
  border-color: var(--ml-success);
  background: rgba(16,185,129,0.06);
}
.ml-review-opt-correct .ml-review-opt-letter {
  background: var(--ml-success);
  color: #fff;
}
/* Wrong selected option */
.ml-review-opt-wrong {
  border-color: var(--ml-danger);
  background: rgba(239,68,68,0.06);
}
.ml-review-opt-wrong .ml-review-opt-letter {
  background: var(--ml-danger);
  color: #fff;
}

/* Review answer / explanation */
.ml-review-answers {
  display: flex;
  gap: 1.5rem;
  font-size: 0.85rem;
  color: var(--ml-text-secondary);
  padding: 0.5rem 0;
}
.ml-review-explanation {
  margin-top: 0.6rem;
  padding: 0.75rem 1rem;
  background: var(--ml-surface-alt);
  border-radius: var(--ml-radius);
  border-left: 3px solid var(--ml-gold);
  font-size: 0.88rem;
  line-height: 1.6;
  white-space: pre-wrap;
}

/* Review option (legacy — results page) */
.ml-review-option {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.5rem 0.75rem;
  border: 1.5px solid var(--ml-border);
  border-radius: var(--ml-radius);
  margin-bottom: 0.35rem;
  font-size: 0.9rem;
}
.ml-review-option-correct { border-color: var(--ml-success); background: rgba(16,185,129,0.06); }
.ml-review-option-wrong { border-color: var(--ml-danger); background: rgba(239,68,68,0.06); }

/* Attempt summary header */
.ml-attempt-summary {
  margin-bottom: 1.25rem;
  padding: 1rem 1.25rem;
  background: var(--ml-surface-alt);
  border-radius: var(--ml-radius);
  border: 1px solid var(--ml-border);
}
.ml-attempt-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  text-align: center;
  margin-bottom: 0.75rem;
}
.ml-attempt-stat-value {
  display: block;
  font-size: 1.5rem;
  font-weight: 800;
  line-height: 1.2;
}
.ml-attempt-stat-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ml-text-secondary);
}
.ml-score-pass { color: var(--ml-success); }
.ml-score-fail { color: var(--ml-danger); }
.ml-attempt-summary-meta {
  display: flex;
  gap: 1rem;
  align-items: center;
  font-size: 0.82rem;
  color: var(--ml-text-secondary);
  padding-top: 0.5rem;
  border-top: 1px solid var(--ml-border);
}

/* Legacy .ml-results-hero / .ml-results-verdict */
.ml-results-hero { text-align: center; padding: 3rem 1rem; }
.ml-results-verdict { font-size: 1.5rem; font-weight: 700; margin-bottom: 0.5rem; }
.ml-results-verdict.pass { color: var(--ml-success); }
.ml-results-verdict.fail { color: var(--ml-danger); }
.ml-results-summary { color: var(--ml-text-secondary); font-size: 1rem; margin-bottom: 2rem; }

/* ------------------------------------------------------------
   12.  Dashboard
   ------------------------------------------------------------ */

/* — Dashboard tabs (ml-dash-tabs is an alias for ml-tab-bar) --*/
.ml-dash-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--ml-border);
  margin-bottom: 1.5rem;
}

/* — Dashboard stat grid --------------------------------------*/
.ml-dash-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin-bottom: 2rem;
}

@media (min-width: 768px) {
  .ml-dash-stats {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* — Subsections ----------------------------------------------*/
.ml-subsection {
  margin-top: 2rem;
  padding-top: 1.5rem;
}

.ml-subsection-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 1rem;
  color: var(--ml-text);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.ml-subsection-hint {
  font-size: 0.85rem;
  color: var(--ml-text-secondary);
  font-weight: 400;
}

/* — Tables ---------------------------------------------------*/
.ml-table-wrap {
  overflow-x: auto;
  border-radius: var(--ml-radius);
  border: 1px solid var(--ml-border);
}

/* Legacy alias */
.ml-table-responsive {
  overflow-x: auto;
  border-radius: var(--ml-radius);
  border: 1px solid var(--ml-border);
}

.ml-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.ml-table thead {
  background: var(--ml-surface-alt);
}

.ml-table th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-weight: 700;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ml-text-secondary);
  border-bottom: 2px solid var(--ml-border);
  white-space: nowrap;
}

.ml-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--ml-border);
  color: var(--ml-text);
  vertical-align: middle;
}

.ml-table tbody tr {
  transition: background var(--ml-transition);
}

.ml-table tbody tr:nth-child(even) {
  background: var(--ml-surface-alt);
}

.ml-table tbody tr:hover {
  background: rgba(255, 215, 0, 0.04);
}

/* Sortable table */
.ml-table-sortable th {
  cursor: pointer;
  user-select: none;
}

.ml-table-sortable th:hover {
  color: var(--ml-gold);
}

.ml-table-sortable th::after {
  content: " \25B4\25BE";
  font-size: 0.7rem;
  opacity: 0.3;
}

.ml-table-sortable th.sort-asc::after {
  content: " \25B4";
  opacity: 1;
  color: var(--ml-gold);
}

.ml-table-sortable th.sort-desc::after {
  content: " \25BE";
  opacity: 1;
  color: var(--ml-gold);
}

/* Legacy .ml-sortable */
.ml-sortable { cursor: pointer; user-select: none; }
.ml-sortable::after { content: " \25B4\25BE"; font-size: 0.7rem; opacity: 0.3; }
.ml-sortable.sort-asc::after { content: " \25B4"; opacity: 1; color: var(--ml-gold); }
.ml-sortable.sort-desc::after { content: " \25BE"; opacity: 1; color: var(--ml-gold); }

.ml-text-success { color: var(--ml-success); font-weight: 600; }
.ml-text-danger { color: var(--ml-danger); font-weight: 600; }

.ml-weak-row {
  background: rgba(239, 68, 68, 0.06) !important;
}

.ml-weak-row td {
  color: var(--ml-danger);
  font-weight: 600;
}

/* Bilingual display — EN and ZH stacked */
.ml-lang-en, .ml-lang-zh {
  display: block;
}
.ml-lang-en {
  margin-bottom: 0.35em;
}
.ml-lang-zh {
  color: var(--ml-text-secondary);
  font-size: 0.92em;
}
/* Inside option cards, keep bilingual compact */
.ml-option-card .ml-lang-en,
.ml-option-card .ml-lang-zh,
.ml-review-option .ml-lang-en,
.ml-review-option .ml-lang-zh {
  display: block;
}
.ml-option-card .ml-lang-zh,
.ml-review-option .ml-lang-zh {
  font-size: 0.88em;
  margin-top: 0.15em;
}

/* Empty state */
.ml-empty-state {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--ml-text-secondary);
  font-size: 0.95rem;
}

/* Notes list */
.ml-notes-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* Attempt review (expandable) */
.ml-attempt-review {
  margin-top: 1rem;
  border: 1px solid var(--ml-border);
  border-radius: var(--ml-radius);
  overflow: hidden;
  transition: border-color var(--ml-transition);
}

.ml-attempt-review-header {
  padding: 0.85rem 1.25rem;
  background: var(--ml-surface-alt);
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  transition: background var(--ml-transition);
}

.ml-attempt-review-header:hover {
  background: rgba(255, 215, 0, 0.06);
}

.ml-attempt-review-content {
  padding: 1.25rem;
  border-top: 1px solid var(--ml-border);
}

/* Legacy body class */
.ml-attempt-review-body {
  display: none;
  padding: 1.25rem;
  border-top: 1px solid var(--ml-border);
}

.ml-attempt-review.open .ml-attempt-review-body {
  display: block;
}

/* Questions list (admin) */
.ml-questions-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* ------------------------------------------------------------
   13.  Admin Panel
   ------------------------------------------------------------ */
.ml-admin-layout {
  display: flex;
  min-height: calc(100vh - var(--ml-demo-banner-h) - var(--ml-navbar-h));
}

/* — Sidebar --------------------------------------------------*/
.ml-admin-sidebar {
  width: 260px;
  min-width: 260px;
  background: var(--ml-navy);
  color: #fff;
  padding: 1.5rem 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.ml-admin-sidebar-title {
  padding: 0 1.5rem;
  font-size: 1rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.8);
  margin-bottom: 1rem;
}

/* — Admin nav ------------------------------------------------*/
.ml-admin-nav {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0;
  margin: 0;
}

.ml-admin-nav li {
  width: 100%;
}

.ml-admin-nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.7rem 1.5rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.65);
  cursor: pointer;
  transition: all var(--ml-transition);
  border: none;
  border-left: 3px solid transparent;
  background: transparent;
  text-align: left;
  text-decoration: none;
}

.ml-admin-nav-link:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
}

/* Active admin nav — HTML uses ml-admin-nav-active class */
.ml-admin-nav-active,
.ml-admin-nav-link.active {
  color: var(--ml-gold);
  background: rgba(255, 215, 0, 0.08);
  border-left-color: var(--ml-gold);
}

/* Legacy .ml-admin-nav-item */
.ml-admin-nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 1.5rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.65);
  cursor: pointer;
  transition: all var(--ml-transition);
  border-left: 3px solid transparent;
  text-decoration: none;
}
.ml-admin-nav-item:hover { color: #fff; background: rgba(255, 255, 255, 0.06); }
.ml-admin-nav-item.active { color: var(--ml-gold); background: rgba(255, 215, 0, 0.08); border-left-color: var(--ml-gold); }
.ml-admin-nav-item .nav-icon { font-size: 1.1rem; width: 20px; text-align: center; }
.ml-admin-nav-item .nav-badge { margin-left: auto; background: rgba(255, 215, 0, 0.2); color: var(--ml-gold); font-size: 0.7rem; font-weight: 700; padding: 0.15rem 0.5rem; border-radius: 10px; }

/* — Admin pages (sub-pages within admin) ---------------------*/
.ml-admin-page {
  display: none;
}

/* Active admin page — HTML uses ml-admin-page-active class */
.ml-admin-page-active,
.ml-admin-page.active {
  display: block;
}

.ml-admin-page-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--ml-text);
  margin-bottom: 1.5rem;
}

/* — Admin content area ---------------------------------------*/
.ml-admin-content {
  flex: 1;
  padding: 2rem;
  overflow-y: auto;
  background: var(--ml-surface-alt);
  transition: background var(--ml-transition);
}

/* — Admin stats grid -----------------------------------------*/
.ml-admin-stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin-bottom: 2rem;
}

@media (min-width: 768px) {
  .ml-admin-stats-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* — Admin paper cards ----------------------------------------*/
.ml-admin-paper-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}

/* — Admin average scores -------------------------------------*/
.ml-admin-avg-scores {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

/* — Admin filters --------------------------------------------*/
.ml-admin-filters {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  align-items: flex-end;
  margin-bottom: 1.5rem;
  padding: 1rem;
  background: var(--ml-surface);
  border: 1px solid var(--ml-border);
  border-radius: var(--ml-radius);
}

.ml-admin-filters .ml-form-group {
  margin-bottom: 0;
}

/* — Admin detail panel ---------------------------------------*/
.ml-admin-detail-panel {
  border: 1px solid var(--ml-border);
  border-radius: var(--ml-radius);
  background: var(--ml-surface);
  margin-top: 1.5rem;
  overflow: hidden;
}

.ml-admin-detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  background: var(--ml-surface-alt);
  border-bottom: 1px solid var(--ml-border);
}

.ml-admin-detail-content {
  padding: 1.25rem;
  max-height: 70vh;
  overflow-y: auto;
}

/* — Admin Questions List -------------------------------------*/
.ml-questions-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.ml-questions-count {
  font-size: 0.82rem;
  color: var(--ml-text-secondary);
  padding: 0.5rem 0 0.75rem;
}
.ml-question-item {
  border: 1px solid var(--ml-border);
  border-radius: var(--ml-radius);
  background: var(--ml-surface);
  margin-bottom: 0.75rem;
  overflow: hidden;
  transition: border-color var(--ml-transition), box-shadow var(--ml-transition);
}
.ml-question-item:hover {
  border-color: var(--ml-blue-light);
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.ml-question-item-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--ml-surface-alt);
  border-bottom: 1px solid var(--ml-border);
  flex-wrap: wrap;
}
.ml-question-item-qid {
  font-weight: 700;
  font-size: 0.82rem;
  color: var(--ml-gold);
  white-space: nowrap;
}
.ml-question-item-badges {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  flex: 1;
}
.ml-question-item-body {
  padding: 0.85rem 1rem;
}
.ml-question-item-text {
  margin-bottom: 0.65rem;
  line-height: 1.6;
  font-size: 0.92rem;
}
/* Options preview in admin question list */
.ml-question-item-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
}
@media (max-width: 640px) {
  .ml-question-item-options { grid-template-columns: 1fr; }
}
.ml-qi-option {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.45rem 0.65rem;
  border-radius: 6px;
  border: 1px solid var(--ml-border);
  background: var(--ml-surface);
  font-size: 0.84rem;
  line-height: 1.45;
  transition: all var(--ml-transition);
}
.ml-qi-option-correct {
  border-color: var(--ml-success);
  background: rgba(16,185,129,0.06);
}
.ml-qi-option-letter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  min-width: 22px;
  border-radius: 50%;
  background: var(--ml-surface-alt);
  font-weight: 700;
  font-size: 0.72rem;
  color: var(--ml-text-secondary);
  flex-shrink: 0;
}
.ml-qi-letter-correct {
  background: var(--ml-success);
  color: #fff;
}
.ml-qi-option-text {
  flex: 1;
  padding-top: 0.05rem;
}
.ml-qi-option-text .ml-lang-zh {
  font-size: 0.82em;
}

/* Badges */
.ml-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.ml-badge-paper {
  background: rgba(74,144,217,0.12);
  color: var(--ml-blue);
}
.ml-badge-topic {
  background: rgba(139,92,246,0.12);
  color: #8b5cf6;
}
.ml-badge-hot {
  background: rgba(239,68,68,0.12);
  color: var(--ml-danger);
}
.ml-badge-easy {
  background: rgba(16,185,129,0.12);
  color: var(--ml-success);
}
.ml-badge-medium {
  background: rgba(245,158,11,0.12);
  color: var(--ml-warning);
}
.ml-badge-hard {
  background: rgba(239,68,68,0.12);
  color: var(--ml-danger);
}
.ml-badge-answer {
  background: rgba(255,215,0,0.15);
  color: var(--ml-gold);
}

/* — Pagination -----------------------------------------------*/
.ml-pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 0;
}

.ml-pagination-info {
  font-size: 0.85rem;
  color: var(--ml-text-secondary);
}

/* — Admin cards / headers (legacy) ---------------------------*/
.ml-admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 2rem;
}

.ml-admin-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--ml-text);
}

.ml-admin-card {
  background: var(--ml-surface);
  border: 1px solid var(--ml-border);
  border-radius: var(--ml-radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--ml-shadow-sm);
  transition: background var(--ml-transition), border-color var(--ml-transition);
}

.ml-admin-card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--ml-text);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* — Settings card --------------------------------------------*/
.ml-settings-card {
  max-width: 600px;
  background: var(--ml-surface);
  border: 1px solid var(--ml-border);
  border-radius: var(--ml-radius-lg);
  padding: 2rem;
  box-shadow: var(--ml-shadow-sm);
  transition: background var(--ml-transition), border-color var(--ml-transition);
}

/* Mobile sidebar toggle */
.ml-admin-sidebar-toggle {
  display: none;
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--ml-navy);
  color: var(--ml-gold);
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
  box-shadow: var(--ml-shadow-lg);
  z-index: 1001;
  align-items: center;
  justify-content: center;
}

/* ------------------------------------------------------------
   14.  Badges
   ------------------------------------------------------------ */
.ml-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.6rem;
  font-size: 0.72rem;
  font-weight: 700;
  border-radius: 10px;
  line-height: 1.4;
}

.ml-badge-gold {
  background: rgba(255, 215, 0, 0.15);
  color: var(--ml-gold-dark);
}

[data-theme="dark"] .ml-badge-gold {
  color: var(--ml-gold);
}

.ml-badge-success {
  background: rgba(16, 185, 129, 0.12);
  color: var(--ml-success);
}

.ml-badge-danger {
  background: rgba(239, 68, 68, 0.12);
  color: var(--ml-danger);
}

.ml-badge-info {
  background: rgba(59, 130, 246, 0.12);
  color: var(--ml-info);
}

.ml-badge-warning {
  background: rgba(245, 158, 11, 0.12);
  color: var(--ml-warning);
}

.ml-badge-secondary {
  background: var(--ml-surface-alt);
  color: var(--ml-text-secondary);
}

/* ------------------------------------------------------------
   15.  Modal
   ------------------------------------------------------------ */
.ml-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  backdrop-filter: blur(3px);
}

.ml-modal-overlay.active {
  display: flex;
}

.ml-modal {
  background: var(--ml-surface);
  border-radius: var(--ml-radius-lg);
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--ml-shadow-lg);
  animation: fadeIn 0.2s ease;
  transition: background var(--ml-transition);
}

.ml-modal.active {
  display: block;
}

.ml-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--ml-border);
}

.ml-modal-header h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--ml-text);
}

.ml-modal-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--ml-surface-alt);
  color: var(--ml-text-secondary);
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--ml-transition);
}

.ml-modal-close:hover {
  background: var(--ml-danger);
  color: #fff;
}

.ml-modal-body {
  padding: 1.5rem;
}

.ml-modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--ml-border);
}

.ml-modal-wide {
  max-width: 700px;
}

/* Report QID display */
.ml-report-qid-display {
  font-weight: 700;
  font-family: var(--ml-font-mono);
  font-size: 0.9rem;
  color: var(--ml-text-secondary);
  margin-bottom: 1rem;
}

/* ------------------------------------------------------------
   16.  Footer
   ------------------------------------------------------------ */
.ml-footer {
  background: var(--ml-navy);
  color: rgba(255, 255, 255, 0.55);
  padding: 2.5rem 0 1.5rem;
  margin-top: 4rem;
  font-size: 0.85rem;
}

.ml-footer a {
  color: var(--ml-gold);
  text-decoration: none;
}

.ml-footer a:hover {
  color: var(--ml-gold-light);
}

.ml-footer-content {
  max-width: var(--ml-container-max);
  margin: 0 auto;
  padding: 0 1.5rem;
  text-align: center;
}

.ml-footer-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-size: 1rem;
  color: rgba(255, 255, 255, 0.8);
  margin-bottom: 0.5rem;
}

.ml-footer-brand .ml-logo-icon {
  font-size: 1.2rem;
}

.ml-footer-demo {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.4);
  margin-bottom: 0.25rem;
}

.ml-footer-powered {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.3);
}

/* Legacy footer grid */
.ml-footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 2rem;
  margin-bottom: 2rem;
}

.ml-footer-col h4 {
  color: #fff;
  font-size: 0.9rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
}

.ml-footer-col ul li {
  margin-bottom: 0.4rem;
}

.ml-footer-bottom {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  font-size: 0.8rem;
}

/* ------------------------------------------------------------
   17.  Loading Overlay & Spinner
   ------------------------------------------------------------ */
.ml-loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 14, 42, 0.60);
  z-index: 5000;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 1.25rem;
  backdrop-filter: blur(4px);
}

.ml-loading-overlay.active {
  display: flex;
}

.ml-loading-spinner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
}

.ml-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(255, 215, 0, 0.2);
  border-top-color: var(--ml-gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.ml-loading-text {
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  text-align: center;
  line-height: 1.6;
}

/* Inline spinner (small) */
.ml-spinner-sm {
  width: 20px;
  height: 20px;
  border-width: 2.5px;
}

/* Skeleton loading */
.ml-skeleton {
  background: linear-gradient(
    90deg,
    var(--ml-surface-alt) 0%,
    var(--ml-border) 50%,
    var(--ml-surface-alt) 100%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s ease infinite;
  border-radius: var(--ml-radius-sm);
}

@keyframes skeleton-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.ml-skeleton-text { height: 1rem; margin-bottom: 0.5rem; }
.ml-skeleton-title { height: 1.5rem; width: 60%; margin-bottom: 0.75rem; }
.ml-skeleton-avatar { width: 48px; height: 48px; border-radius: 50%; }

/* ------------------------------------------------------------
   18.  Utilities
   ------------------------------------------------------------ */

/* Display */
.hidden       { display: none !important; }
.block        { display: block; }
.inline-block { display: inline-block; }

/* Flex */
.flex         { display: flex; }
.flex-col     { display: flex; flex-direction: column; }
.flex-center  { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-wrap    { flex-wrap: wrap; }
.items-center { align-items: center; }
.items-start  { align-items: flex-start; }
.justify-end  { justify-content: flex-end; }
.flex-1       { flex: 1; }

/* Gap */
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 1rem; }
.gap-4 { gap: 1.5rem; }

/* Text alignment */
.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-left   { text-align: left; }

/* Text size */
.text-xs { font-size: 0.75rem; }
.text-sm { font-size: 0.875rem; }
.text-base { font-size: 1rem; }
.text-lg { font-size: 1.125rem; }
.text-xl { font-size: 1.25rem; }
.text-2xl { font-size: 1.5rem; }

/* Font weight */
.font-normal   { font-weight: 400; }
.font-medium   { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold     { font-weight: 700; }

/* Text colors */
.text-gold    { color: var(--ml-gold) !important; }
.text-success { color: var(--ml-success) !important; }
.text-danger  { color: var(--ml-danger) !important; }
.text-warning { color: var(--ml-warning) !important; }
.text-info    { color: var(--ml-info) !important; }
.text-muted   { color: var(--ml-text-secondary) !important; }

/* Background colors */
.bg-gold    { background-color: var(--ml-gold) !important; }
.bg-success { background-color: var(--ml-success) !important; }
.bg-danger  { background-color: var(--ml-danger) !important; }
.bg-warning { background-color: var(--ml-warning) !important; }
.bg-info    { background-color: var(--ml-info) !important; }
.bg-surface { background-color: var(--ml-surface) !important; }

/* Spacing — Margin */
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1.5rem; }

.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 1rem; }
.mb-4 { margin-bottom: 1.5rem; }

/* NOTE: .ml-1 through .ml-4 are utility margin-left classes, NOT ml- prefixed component classes */
.ml-1 { margin-left: 0.25rem; }
.ml-2 { margin-left: 0.5rem; }
.ml-3 { margin-left: 1rem; }
.ml-4 { margin-left: 1.5rem; }

.mr-1 { margin-right: 0.25rem; }
.mr-2 { margin-right: 0.5rem; }
.mr-3 { margin-right: 1rem; }
.mr-4 { margin-right: 1.5rem; }

.mx-auto { margin-left: auto; margin-right: auto; }

/* Spacing — Padding */
.p-1 { padding: 0.25rem; }
.p-2 { padding: 0.5rem; }
.p-3 { padding: 1rem; }
.p-4 { padding: 1.5rem; }

.px-1 { padding-left: 0.25rem; padding-right: 0.25rem; }
.px-2 { padding-left: 0.5rem; padding-right: 0.5rem; }
.px-3 { padding-left: 1rem; padding-right: 1rem; }
.px-4 { padding-left: 1.5rem; padding-right: 1.5rem; }

.py-1 { padding-top: 0.25rem; padding-bottom: 0.25rem; }
.py-2 { padding-top: 0.5rem; padding-bottom: 0.5rem; }
.py-3 { padding-top: 1rem; padding-bottom: 1rem; }
.py-4 { padding-top: 1.5rem; padding-bottom: 1.5rem; }

/* Border & shape */
.rounded    { border-radius: var(--ml-radius); }
.rounded-lg { border-radius: var(--ml-radius-lg); }
.rounded-full { border-radius: 9999px; }
.shadow     { box-shadow: var(--ml-shadow); }
.shadow-md  { box-shadow: var(--ml-shadow-md); }
.shadow-lg  { box-shadow: var(--ml-shadow-lg); }

/* Overflow */
.overflow-hidden { overflow: hidden; }
.overflow-auto   { overflow: auto; }

/* Cursor */
.cursor-pointer { cursor: pointer; }

/* Width */
.w-full { width: 100%; }

/* Truncate */
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Divider */
.ml-divider {
  height: 1px;
  background: var(--ml-border);
  margin: 1.5rem 0;
  border: none;
}

/* Tag / Chip */
.ml-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 6px;
  background: var(--ml-surface-alt);
  color: var(--ml-text-secondary);
  border: 1px solid var(--ml-border);
}

/* ------------------------------------------------------------
   19.  Responsive Design
   ------------------------------------------------------------ */

/* Small phones (up to 480px) */
@media (max-width: 480px) {
  body {
    font-size: 15px;
  }

  .ml-container {
    padding: 0 1rem;
  }

  .ml-section {
    padding: 2rem 1rem;
  }

  .ml-hero {
    padding: 3rem 1rem 2.5rem;
  }

  .ml-hero-title,
  .ml-hero h1 {
    font-size: 1.75rem;
  }

  .ml-hero p,
  .ml-hero-subtitle {
    font-size: 1rem;
  }

  .ml-hero-cta {
    flex-direction: column;
    align-items: stretch;
  }

  .ml-quiz-setup-card {
    padding: 1.5rem;
    margin: 1rem;
    border-radius: var(--ml-radius-lg);
  }

  .ml-question-card {
    padding: 1.25rem;
    border-radius: var(--ml-radius);
  }

  .ml-navigator-grid {
    grid-template-columns: repeat(8, 1fr);
  }

  .ml-score-circle {
    width: 140px;
    height: 140px;
  }

  .ml-results-stats {
    grid-template-columns: 1fr;
  }

  .ml-feature-grid {
    grid-template-columns: 1fr;
  }

  .ml-mode-selector {
    flex-direction: column;
  }

  .ml-auth-card {
    padding: 1.5rem;
  }

  .ml-admin-stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Tablets and below (up to 768px) */
@media (max-width: 768px) {
  .ml-nav-menu {
    display: none;
    position: fixed;
    top: calc(var(--ml-demo-banner-h) + var(--ml-navbar-h));
    left: 0;
    width: 100%;
    background: var(--ml-navy);
    padding: 1rem 1.5rem 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    z-index: 999;
    flex-direction: column;
    margin-left: 0;
    animation: slideDown var(--ml-transition-slow) ease;
  }

  .ml-nav-menu.active {
    display: flex;
  }

  .ml-nav-links {
    flex-direction: column;
    width: 100%;
  }

  .ml-nav-links li {
    width: 100%;
  }

  .ml-nav-link {
    display: block;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    border-radius: var(--ml-radius-sm);
  }

  .ml-nav-actions {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    flex-wrap: wrap;
  }

  .ml-hamburger {
    display: flex;
  }

  .ml-hero {
    padding: 3rem 1.5rem 2.5rem;
  }

  .ml-hero-title,
  .ml-hero h1 {
    font-size: 2rem;
  }

  .ml-section {
    padding: 2rem 1.5rem;
  }

  .ml-section-title {
    font-size: 1.4rem;
  }

  .ml-quiz-topbar {
    flex-wrap: wrap;
    padding: 0.5rem 1rem;
  }

  .ml-quiz-topbar-left,
  .ml-quiz-topbar-right {
    gap: 0.5rem;
  }

  .ml-quiz-body {
    flex-direction: column;
  }

  .ml-quiz-navigator {
    width: 100%;
    min-width: auto;
    position: static;
  }

  /* Admin sidebar: collapse */
  .ml-admin-sidebar {
    position: fixed;
    left: -260px;
    top: calc(var(--ml-demo-banner-h) + var(--ml-navbar-h));
    bottom: 0;
    z-index: 1001;
    transition: left var(--ml-transition-slow);
    box-shadow: none;
  }

  .ml-admin-sidebar.open {
    left: 0;
    box-shadow: 8px 0 24px rgba(0, 0, 0, 0.3);
  }

  .ml-admin-sidebar-toggle {
    display: flex;
  }

  .ml-admin-content {
    padding: 1.25rem;
  }

  .ml-admin-header h1 {
    font-size: 1.25rem;
  }

  .ml-admin-filters {
    flex-direction: column;
  }

  .ml-form-inline {
    flex-direction: column;
    align-items: stretch;
  }
}

/* Medium screens (up to 1024px) */
@media (max-width: 1024px) {
  .ml-hero-title,
  .ml-hero h1 {
    font-size: 2.5rem;
  }

  .ml-admin-sidebar {
    width: 220px;
    min-width: 220px;
  }
}

/* Large screens */
@media (min-width: 1200px) {
  .ml-container {
    padding: 0 2rem;
  }
}

/* ------------------------------------------------------------
   20.  Animations
   ------------------------------------------------------------ */
@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-12px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.95); }
  to   { opacity: 1; transform: scale(1); }
}

/* Animation utility classes */
.animate-fade-in   { animation: fadeIn 0.3s ease; }
.animate-slide-down { animation: slideDown 0.3s ease; }
.animate-slide-up  { animation: slideUp 0.3s ease; }
.animate-scale-in  { animation: scaleIn 0.2s ease; }

/* Transition base */
.transition { transition: all var(--ml-transition); }
.transition-slow { transition: all var(--ml-transition-slow); }

/* ------------------------------------------------------------
   21.  Print Styles
   ------------------------------------------------------------ */
@media print {
  .ml-demo-banner,
  .ml-navbar,
  .ml-hamburger,
  .ml-nav-menu,
  .ml-admin-sidebar,
  .ml-admin-sidebar-toggle,
  .ml-quiz-topbar,
  .ml-quiz-nav,
  .ml-loading-overlay,
  .ml-modal-overlay,
  .ml-flag-btn,
  .ml-note-section,
  footer {
    display: none !important;
  }

  body {
    padding-top: 0;
    color: #000;
    background: #fff;
    font-size: 12pt;
  }

  .ml-page {
    display: block !important;
  }

  .ml-card,
  .ml-question-card,
  .ml-review-card,
  .ml-admin-card {
    box-shadow: none;
    border: 1px solid #ccc;
    break-inside: avoid;
  }

  .ml-hero {
    background: none !important;
    color: #000;
    padding: 1rem 0;
  }

  a {
    color: #000;
    text-decoration: underline;
  }

  .ml-btn {
    border: 1px solid #999;
  }
}

/* ------------------------------------------------------------
   22.  Scrollbar (dark mode)
   ------------------------------------------------------------ */
[data-theme="dark"] {
  scrollbar-color: var(--ml-navy-light) var(--ml-navy);
}

[data-theme="dark"] ::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

[data-theme="dark"] ::-webkit-scrollbar-track {
  background: var(--ml-navy);
}

[data-theme="dark"] ::-webkit-scrollbar-thumb {
  background: var(--ml-navy-light);
  border-radius: 6px;
  border: 2px solid var(--ml-navy);
}

[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
  background: var(--ml-gold-dark);
}

/* ------------------------------------------------------------
   23.  Accessibility Enhancements
   ------------------------------------------------------------ */

/* Focus-visible for keyboard navigation */
*:focus-visible {
  outline: 2px solid var(--ml-gold);
  outline-offset: 2px;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Screen-reader only */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* Skip link */
.ml-skip-link {
  position: absolute;
  top: -100%;
  left: 1rem;
  background: var(--ml-gold);
  color: var(--ml-navy);
  padding: 0.5rem 1rem;
  border-radius: var(--ml-radius-sm);
  font-weight: 700;
  z-index: 10000;
  transition: top 0.2s ease;
}

.ml-skip-link:focus {
  top: calc(var(--ml-demo-banner-h) + 0.5rem);
}

/* High contrast selection */
::selection {
  background: var(--ml-gold);
  color: var(--ml-navy);
}

/* ============================================================
   End of Moon Life Stylesheet
   ============================================================ */
