/* ============================================================
   BTECH Assessment Platform — Shared Design Tokens v6.0
   Fully Responsive & Mobile-First Architecture
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Arabic:wght@300;400;500;600;700&family=Montserrat:wght@300;400;500;600;700&family=Orbitron:wght@400;600;700;900&family=Inter:wght@300;400;500;600&family=Noto+Sans+Arabic:wght@300;400;500;600;700&display=swap');

/* ── 1. CSS Variables ── */
:root {
  --bg: #070913;
  --text: #e2e8f0;
  --sub-text: #94a3b8;
  --accent: #00ffff;
  --accent-alt: #8b5cf6;
  --glass-bg: rgba(255, 255, 255, 0.035);
  --glass-border: rgba(0, 255, 255, 0.12);
  --input-bg: rgba(0, 255, 255, 0.03);
  --opt-bg: rgba(255, 255, 255, 0.025);
  --opt-border: rgba(255, 255, 255, 0.07);
  --opt-hover: rgba(0, 255, 255, 0.06);
  --card-shadow: 0 30px 60px rgba(0, 0, 0, 0.6);
  --sidebar-bg: rgba(255, 255, 255, 0.02);
  --sidebar-border: rgba(139, 92, 246, 0.1);
  --card-bg: rgba(255, 255, 255, 0.025);
  --input-border: rgba(139, 92, 246, 0.18);
  --table-hover: rgba(139, 92, 246, 0.04);
  --trans: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  
  /* Touch & Spacing Tokens */
  --touch-target: 48px;
  --safe-padding: 1.5rem;
}

body.light-mode {
  --bg: #f8fafc;
  --text: #0f172a;
  --sub-text: #475569;
  --accent: #0891b2;
  --accent-alt: #7c3aed;
  --glass-bg: rgba(255, 255, 255, 0.85);
  --glass-border: rgba(8, 145, 178, 0.2);
  --input-bg: #f1f5f9;
  --opt-bg: #ffffff;
  --opt-border: rgba(0, 0, 0, 0.05);
  --opt-hover: rgba(8, 145, 178, 0.05);
  --card-shadow: 0 20px 50px rgba(0, 0, 0, 0.05);
  --sidebar-bg: #ffffff;
  --sidebar-border: rgba(109, 40, 217, 0.08);
  --card-bg: #ffffff;
  --input-border: #e2e8f0;
  --table-hover: #f1f5f9;
}

/* ── 2. Base & Resets ── */
*, *::before, *::after {
  margin: 0; padding: 0; box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
  transition: background 0.5s ease, color 0.5s ease;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  animation: pageIn 0.4s ease both;
}

body.rtl { direction: rtl; font-family: 'IBM Plex Sans Arabic', sans-serif; }
body.ltr { direction: ltr; font-family: 'Montserrat', sans-serif; }

/* Scrollbar */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(139,92,246,.3); border-radius: 2px; }

/* ── Animation Keyframes ── */
@keyframes pageIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

@keyframes rowIn {
  from { opacity: 0; transform: translateX(-8px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes cardLift {
  from { transform: translateY(0); box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1); }
  to { transform: translateY(-4px); box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.2); }
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.05); opacity: 0.8; }
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes countUp {
  from { opacity: 0; transform: scale(0.8); }
  to { opacity: 1; transform: scale(1); }
}

/* ── 3. Layout & Containers ── */
.layout { display: flex; min-height: 100vh; position: relative; }

.glass {
  background: var(--glass-bg);
  backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--glass-border);
  border-radius: 24px;
  padding: var(--safe-padding);
  width: 100%;
  box-shadow: var(--card-shadow);
  transition: var(--trans);
  animation: fadeIn 0.5s ease both;
}

.grid2, .grid3, .grid4 {
  display: grid;
  gap: 1.5rem;
}

.grid2 { grid-template-columns: repeat(2, 1fr); }
.grid3 { grid-template-columns: repeat(3, 1fr); }
.grid4 { grid-template-columns: repeat(4, 1fr); }

/* ── 4. Components ── */
.btn {
  min-height: var(--touch-target);
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 12px;
  font-family: 'Orbitron', monospace;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 2px;
  cursor: pointer;
  transition: var(--trans);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  text-decoration: none;
  position: relative;
  overflow: hidden;
  transform: translateZ(0);
}

.btn:hover:not(:disabled) { transform: translateY(-2px); }
.btn:active:not(:disabled) { transform: translateY(0) scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Ripple effect child element */
.btn span.ripple {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  background: currentColor;
  opacity: 0.35;
  transform: scale(0);
  animation: btnRipple 0.6s ease-out forwards;
}

@keyframes btnRipple {
  to { transform: scale(2.5); opacity: 0; }
}

/* Button variants - all now have glow on hover */
.btn-c { background: linear-gradient(135deg, rgba(0,255,255,.12), rgba(0,180,255,.08)); border: 1px solid rgba(0,255,255,.3); color: var(--accent); }
.btn-c:hover:not(:disabled) { background: linear-gradient(135deg, rgba(0,255,255,.22), rgba(0,180,255,.16)); box-shadow: 0 0 25px rgba(0,255,255,.2); }

.btn-p { background: linear-gradient(135deg, rgba(139,92,246,.18), rgba(167,139,250,.12)); border: 1px solid rgba(139,92,246,.35); color: var(--accent-alt); }
.btn-p:hover:not(:disabled) { background: linear-gradient(135deg, rgba(139,92,246,.28), rgba(167,139,250,.22)); box-shadow: 0 0 25px rgba(139,92,246,.25); }

.btn-g { background: linear-gradient(135deg, rgba(34,197,94,.15), rgba(16,185,129,.1)); border: 1px solid rgba(34,197,94,.3); color: #4ade80; }
.btn-g:hover:not(:disabled) { background: linear-gradient(135deg, rgba(34,197,94,.25), rgba(16,185,129,.18)); box-shadow: 0 0 20px rgba(34,197,94,.2); }

.btn-r { background: rgba(239,68,68,.1); border: 1px solid rgba(239,68,68,.3); color: #fca5a5; }
.btn-r:hover:not(:disabled) { background: rgba(239,68,68,.2); box-shadow: 0 0 20px rgba(239,68,68,.15); }

/* Button sizing variants */
.btn-sm { padding: 0.5rem 1rem; font-size: 0.7rem; }
.btn-full { width: 100%; margin-top: 0.5rem; }

/* Icon-only button animations */
.btn[class*="icon-"] { transition: var(--trans), transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1); }
.btn[class*="icon-"]:hover:not(:disabled) { transform: translateY(-2px) scale(1.1); }

/* Theme toggle button rotation */
.theme-toggle-btn { 
  transition: var(--trans), transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  background: transparent;
  border: 1px solid var(--glass-border);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}
.theme-toggle-btn:hover:not(:disabled) { 
  box-shadow: 0 0 15px rgba(var(--accent-rgb, 0,255,255),0.2);
  border-color: var(--accent);
}

/* Delete button shake animation on hover */
.btn-r:hover:not(:disabled)::before {
  content: '';
  position: absolute;
  inset: 0;
  animation: deleteShake 0.4s ease-out;
}

@keyframes deleteShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-2px); }
  75% { transform: translateX(2px); }
}

/* Plus button rotate animation */
.btn-plus {
  transition: var(--trans), transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.btn-plus:hover:not(:disabled) {
  transform: translateY(-2px) rotate(90deg);
}

/* Loading state */
.btn.is-loading {
  pointer-events: none;
  opacity: 0.7;
}
.btn.is-loading { 
  position: relative;
}

/* Form Elements */
.field { margin-bottom: 1.5rem; }
label {
  display: block;
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-bottom: 0.5rem;
  opacity: 0.9;
}

input, select, textarea {
  width: 100%;
  min-height: var(--touch-target);
  padding: 0.75rem 1.25rem;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: 12px;
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-size: 1rem; /* Prevents iOS auto-zoom */
  outline: none;
  transition: var(--trans), box-shadow 0.2s ease;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(var(--accent-rgb, 0,255,255),0.1);
  background: rgba(var(--accent-rgb, 0,255,255),0.05);
  transform: scale(1.02);
}
body.light-mode input:focus, body.light-mode select:focus, body.light-mode textarea:focus {
  box-shadow: 0 0 0 4px rgba(8,145,178,0.15);
  background: rgba(8,145,178,0.04);
  transform: scale(1.02);
}

label:has(+ input:focus), label:has(+ select:focus), label:has(+ textarea:focus) {
  color: var(--accent);
  transform: translateX(-2px);
  opacity: 1;
}

/* ── 5. Responsive Breakpoints ── */

/* TABLET (768px) */
@media (max-width: 1024px) {
  .grid3 { grid-template-columns: repeat(2, 1fr); }
  .grid4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .grid2, .grid3, .grid4 { grid-template-columns: 1fr; }
  
  .layout { flex-direction: column; }
  
  /* Sidebar Mobile Behavior (Vertical Drawer - R-02) */
  .sidebar { 
    width: 240px !important; 
    height: 100vh !important;
    position: fixed !important;
    top: 0;
    left: -240px;
    background: var(--bg) !important;
    border-right: 1px solid var(--sidebar-border) !important; 
    border-bottom: none !important;
    padding: 1.5rem 1rem !important; 
    display: flex !important; 
    flex-direction: column !important;
    gap: 0.5rem; 
    z-index: 1000;
    transition: transform 0.3s ease !important;
    transform: none !important;
    overflow-y: auto !important;
  }
  .sidebar.on {
    transform: translateX(240px) !important;
  }
  body.rtl .sidebar {
    left: auto;
    right: -240px;
    border-right: none !important;
    border-left: 1px solid var(--sidebar-border) !important;
  }
  body.rtl .sidebar.on {
    transform: translateX(-240px) !important;
  }
  .sidebar .nav-section { 
    display: block !important;
    font-size: 0.65rem !important;
    letter-spacing: 1.5px !important;
    color: var(--accent) !important;
    margin: 1rem 0 0.3rem !important;
    opacity: 0.8;
    border: none !important;
    height: auto !important;
    white-space: normal !important;
    text-align: left !important;
  }
  body.rtl .sidebar .nav-section {
    text-align: right !important;
  }
  .sidebar .nav-item { 
    margin-bottom: 0.4rem !important; 
    padding: 0.75rem 1rem !important; 
    font-size: 0.8rem !important; 
    flex-shrink: 0;
    width: 100% !important;
    text-align: left !important;
  }
  body.rtl .sidebar .nav-item {
    text-align: right !important;
  }
  .sidebar .nav-icon { margin-bottom: 0; margin-right: 8px; font-size: 0.85rem; }
  .sidebar .nav-item span:not(.nav-icon) { display: inline !important; }
  
  .content { padding: 1rem; }
  .grid2, .grid3, .grid4 { grid-template-columns: 1fr !important; }
  
  .top-right { font-size: 0.7rem; }
  
  /* Show hamburger button on mobile */
  #hamburgerBtn { display: flex !important; }
  
  /* Modal Overhaul */
  .modal-content {
    width: 95%;
    padding: 1.5rem;
    border-radius: 20px;
  }
  
  .quiz-history-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 1.25rem;
  }
  
  .qh-actions {
    width: 100%;
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
  }
  .qh-actions .btn { width: 100%; font-size: 0.65rem; }
}

/* VERY SMALL PHONES (below 400px) */
@media (max-width: 400px) {
  .qh-actions {
    grid-template-columns: 1fr !important;
  }
}

/* MOBILE (480px) */
@media (max-width: 480px) {
  :root { --safe-padding: 1.25rem; }
  
  h1 { font-size: 1.3rem; }
  
  .glass { border-radius: 20px; }
  
  /* Modal Overhaul */
  .modal-content {
    width: 95%;
    padding: 1.5rem;
    border-radius: 20px;
  }
  
  .top-bar { padding: 1rem; }
  
  .quiz-history-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 1.25rem;
  }
  
  .qh-actions {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
  }
  
  .qh-actions .btn { width: 100%; font-size: 0.65rem; }
  
  /* Timer Scaling */
  .timer-svg { width: 80px; height: 80px; }
  .timer-text { font-size: 1.1rem; }
}

/* ── 6. Utility & UX ── */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  z-index: 999;
  display: none;
  opacity: 0;
  transition: opacity 0.2s ease, visibility 0s linear 0.2s;
}
.overlay.on {
  display: block;
  opacity: 1;
  visibility: visible;
  transition: opacity 0.2s ease, visibility 0s linear 0s;
}

/* Modal animation */
.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0s linear 0.2s;
}

.modal.on {
  display: flex;
  opacity: 1;
  visibility: visible;
  transition: opacity 0.2s ease, visibility 0s linear 0s;
}

.modal-content {
  transform: scale(0.96);
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal.on .modal-content {
  transform: scale(1);
}

@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes spin { to { transform: rotate(360deg); } }

.spin {
  width: 18px; height: 18px;
  border: 2.5px solid rgba(0,255,255,0.1);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ── 7. Advanced Components (KPIs, Reviews, Theme Toggle) ── */

/* Theme Toggle Button (RC-02) */
.theme-toggle-btn {
  min-width: var(--touch-target);
  min-height: var(--touch-target);
  width: var(--touch-target);
  height: var(--touch-target);
  border-radius: 12px;
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  color: var(--accent);
  font-size: 1.2rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: var(--trans);
  flex-shrink: 0;
  backdrop-filter: blur(8px);
}
.theme-toggle-btn:hover {
  background: var(--opt-hover);
  border-color: var(--accent);
  transform: scale(1.05);
}

/* KPI Cards */
.kpi-card { position: relative; overflow: hidden; background: var(--card-bg); border: 1px solid var(--glass-border); border-radius: 16px; padding: 1.5rem; transition: var(--trans); }
.kpi-card::before { content: ""; position: absolute; top: 0; right: 0; width: 60px; height: 60px; background: linear-gradient(135deg, transparent, var(--accent)); opacity: 0.1; }
.kpi-val { font-family: 'Orbitron', monospace; font-size: 1.8rem; font-weight: 700; color: var(--accent); display: block; margin-bottom: 0.25rem; }
.kpi-lbl { font-size: 0.65rem; text-transform: uppercase; letter-spacing: 1.5px; color: var(--sub-text); font-weight: 600; }
.kpi-sub { font-size: 0.6rem; color: var(--accent-alt); margin-top: 0.5rem; }

body.light-mode .kpi-card { border-color: var(--input-border); box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06); }
body.light-mode .kpi-card::before { opacity: 0.6; }
body.light-mode .kpi-val { color: var(--accent) !important; background: none !important; -webkit-text-fill-color: var(--accent) !important; }
body.light-mode .kpi-lbl, body.light-mode .kpi-sub { color: var(--sub-text); }

/* SUBMISSION DRILL-DOWN STYLES */
.review-grid { display: grid; grid-template-columns: 1fr; gap: 1rem; max-height: 65vh; overflow-y: auto; padding-right: .5rem; }
.review-card { background: rgba(255,255,255,0.03); border: 1px solid rgba(139,92,246,0.15); border-radius: 12px; padding: 1.25rem; transition: var(--trans); }
.review-card.correct { border-left: 4px solid #4ade80; }
.review-card.wrong { border-left: 4px solid #ef4444; }
.review-header { display: flex; gap: .5rem; align-items: center; margin-bottom: .75rem; flex-wrap: wrap; }
.q-index { font-family: 'Orbitron', monospace; color: var(--accent); font-size: .85rem; font-weight: 700; }
.review-qtext { font-size: 1rem; color: var(--text); margin-bottom: 1rem; line-height: 1.5; font-weight: 500; }
.user-ans { padding: .6rem .8rem; border-radius: 8px; margin-bottom: .4rem; font-size: .85rem; }
.user-ans.wrong { background: rgba(239,68,68,0.08); color: #fca5a5; border: 1px solid rgba(239,68,68,0.2); }
.user-ans.correct { background: rgba(74,222,128,0.08); color: #4ade80; border: 1px solid rgba(74,222,128,0.2); }
.correct-ans { padding: .6rem .8rem; background: rgba(0,255,255,0.04); color: var(--accent-alt); border-radius: 8px; font-size: .85rem; border: 1px solid rgba(0,255,255,0.1); }

/* Theme switch styles removed — replaced by .theme-toggle-btn (see above) */

/* Toasts */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  z-index: 9999;
  padding: 1rem 1.5rem;
  border-radius: 14px;
  backdrop-filter: blur(16px);
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.4s ease;
  box-shadow: 0 10px 30px rgba(0,0,0,0.4);
  opacity: 0;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-left: 4px solid var(--accent);
  animation: toastSlideIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.toast.info { border-left-color: var(--accent); background: rgba(0, 255, 255, 0.1); }
.toast.success { border-left-color: #4ade80; background: rgba(74, 222, 128, 0.1); }
.toast.error { border-left-color: #fca5a5; background: rgba(239, 68, 68, 0.1); }

@keyframes toastSlideIn {
  from {
    transform: translateX(-50%) translateY(100px) scale(0.95);
    opacity: 0;
  }
  to {
    transform: translateX(-50%) translateY(0) scale(1);
    opacity: 1;
  }
}

/* Toast progress bar */
.toast::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  height: 2px;
  background: var(--accent);
  border-radius: 0 0 14px 0;
  animation: toastDrain 4s linear forwards;
}

.toast.success::after { background: #4ade80; }
.toast.error::after { background: #fca5a5; }

@keyframes toastDrain {
  from { width: 100%; }
  to { width: 0%; }
}

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

/* Focus rings for keyboard navigation */
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
body.light-mode input:focus-visible, body.light-mode select:focus-visible,
body.light-mode textarea:focus-visible, body.light-mode button:focus-visible,
body.light-mode a:focus-visible, body.light-mode [tabindex]:focus-visible {
  outline-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(8,145,178,0.2);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-delay: -1ms !important;
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    background-attachment: initial !important;
    scroll-behavior: auto !important;
    transition-duration: 0s !important;
    transition-delay: 0s !important;
  }
  .orb {
    display: none !important;
  }
}

/* ── Light-Mode Table Fixes (T-06, T-07) ── */
body.light-mode td {
  background: var(--card-bg) !important;
  border-top-color: rgba(0,0,0,0.08) !important;
  border-bottom-color: rgba(0,0,0,0.08) !important;
}
body.light-mode td:first-child {
  border-left-color: rgba(0,0,0,0.08) !important;
}
body.light-mode td:last-child {
  border-right-color: rgba(0,0,0,0.08) !important;
}

/* ── Light-Mode Badge Contrast (T-13) ── */
body.light-mode .badge-g { color: #16a34a; background: rgba(22,163,74,0.1); }
body.light-mode .badge-r { color: #dc2626; background: rgba(220,38,38,0.1); }
body.light-mode .badge-pass { color: #16a34a; background: rgba(22,163,74,0.12); border-color: rgba(22,163,74,0.3); }
body.light-mode .badge-fail { color: #dc2626; background: rgba(220,38,38,0.12); border-color: rgba(220,38,38,0.3); }

/* SFX toggle button — matches theme toggle styling, own identity */
.sfx-toggle-btn {
  transition: var(--trans), transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  background: transparent;
  border: 1px solid var(--glass-border);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  min-width: 40px;
  min-height: 40px;
  color: var(--text);
  cursor: pointer;
  font-size: .95rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.sfx-toggle-btn:hover { box-shadow: 0 0 15px rgba(var(--accent-rgb, 0,255,255),0.2); border-color: var(--accent); }
.theme-toggle-btn {
  position: static;
}

/* ── Light-Mode Button Color Corrections (B-01) ── */
body.light-mode .btn-g { color: #15803d; }
body.light-mode .btn-r { color: #dc2626; }

/* ============================================================
   v7.0 UI/UX Enhancement Layer
   Modern animations • Mobile-first polish • RTL refinements
   Purely presentational — no quiz/proctoring behavior changes.
   ============================================================ */

/* ── 1. Keyframes ── */
@keyframes qSlideIn {
  from { opacity: 0; transform: translateX(var(--q-slide-from, 24px)); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes optPop {
  0%   { opacity: 0; transform: translateY(10px) scale(.98); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes selPulse {
  0%   { box-shadow: 0 0 0 0 rgba(0,255,255,.35); }
  100% { box-shadow: 0 0 0 12px rgba(0,255,255,0); }
}
@keyframes glowBreathe {
  0%, 100% { box-shadow: 0 30px 60px rgba(0,0,0,.6), 0 0 40px rgba(0,255,255,.04); }
  50%      { box-shadow: 0 30px 60px rgba(0,0,0,.6), 0 0 60px rgba(0,255,255,.09); }
}
@keyframes shakeX {
  0%,100% { transform: translateX(0); }
  20% { transform: translateX(-6px); } 40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); } 80% { transform: translateX(4px); }
}
@keyframes toastIn {
  from { opacity: 0; transform: translateY(16px) scale(.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
body.rtl { --q-slide-from: -24px; }

/* ── 2. Question & option transitions ── */
#qContent.q-anim .q-txt { animation: qSlideIn .38s cubic-bezier(.22,.9,.36,1) both; }
#qContent.q-anim .opt   { animation: optPop .34s cubic-bezier(.22,.9,.36,1) both; }
#qContent.q-anim .opt:nth-child(1) { animation-delay: .04s; }
#qContent.q-anim .opt:nth-child(2) { animation-delay: .08s; }
#qContent.q-anim .opt:nth-child(3) { animation-delay: .12s; }
#qContent.q-anim .opt:nth-child(4) { animation-delay: .16s; }
#qContent.q-anim .opt:nth-child(n+5){ animation-delay: .20s; }

.opt:active { transform: scale(.985); transition: transform .08s ease; }
.opt.sel, .opt.msq-sel { animation: selPulse .5s ease-out; }

.glass-wide { animation: glowBreathe 9s ease-in-out infinite; }

.err:not(:empty), #authErr[style*="block"] { animation: shakeX .45s ease both; }

.toast { animation: toastIn .3s cubic-bezier(.22,.9,.36,1) both; }

/* Auto-translated text gets a subtle fade so swaps feel smooth */
.tr-done { animation: fadeIn .25s ease both; }

/* ── 3. Button micro-interactions ── */
.btn { position: relative; overflow: hidden; }
.btn:active { transform: scale(.97); }
@media (hover: hover) and (pointer: fine) {
  .btn:hover { filter: brightness(1.12); }
}

/* ── 4. RTL refinements ── */
body.rtl .opt { text-align: right; }
body.rtl .nav { direction: rtl; }
body.rtl input:not([type="email"]):not([type="password"]), body.rtl textarea { text-align: right; }
body.rtl .short-ans-input { text-align: right; }
[dir="auto"] { text-align: start; }

/* ── 5. Mobile-first polish ── */
@media (max-width: 768px) {
  html { font-size: 15.5px; }

  /* Prevent iOS auto-zoom on focus (inputs must be ≥16px) */
  input, select, textarea { font-size: 16px !important; }

  .glass, .glass-wide {
    padding: calc(1.25rem + env(safe-area-inset-top)) calc(1rem + env(safe-area-inset-right))
             calc(1.25rem + env(safe-area-inset-bottom)) calc(1rem + env(safe-area-inset-left));
    border-radius: 16px;
    max-width: 100%;
  }
  .page { padding: 1rem; padding-top: max(1rem, env(safe-area-inset-top)); align-items: flex-start; }

  /* Floating controls become comfortable touch targets */
  .theme-toggle-btn, #sfxToggleBtn {
    position: static;
    width: 44px; height: 44px;
    font-size: 1.05rem;
  }

  /* Quiz header stack on narrow screens */
  .quiz-hdr { flex-wrap: wrap; gap: .6rem; }

  /* Larger touch targets for options */
  .opt { min-height: 54px; padding: .9rem 1rem; border-radius: 12px; }
  .btn { min-height: var(--touch-target); }

  /* Score ring scales down gracefully */
  .score-ring { width: 128px; height: 128px; }
  .score-pct { font-size: 1.8rem; }

  /* Full-width action stacks */
  .nav .btn { flex: 1 1 100%; }
}

@media (max-width: 400px) {
  .ch-title { font-size: 1.35rem; letter-spacing: 2px; }
  .stat-val { font-size: 1.15rem; }
  .q-txt { font-size: 1rem; }
}

/* Landscape phones: reclaim vertical space */
@media (max-height: 480px) and (orientation: landscape) {
  .page { padding-top: .75rem; align-items: flex-start; }
  .timer-svg { display: none; }
}

/* ── 6. Reduced motion: kill decorative animation only ── */
@media (prefers-reduced-motion: reduce) {
  #qContent.q-anim .q-txt,
  #qContent.q-anim .opt,
  .glass-wide,
  .tr-done,
  .toast,
  .err:not(:empty),
  .opt.sel, .opt.msq-sel {
    animation: none !important;
  }
}
