/* ==========================================================================
   DESIGN TOKENS & SYSTEM ROOT
   ========================================================================== */
:root {
  /* Colors */
  --bg-base: #030712;
  --bg-card: rgba(17, 24, 39, 0.65);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(255, 255, 255, 0.15);
  
  --primary: #8b5cf6;
  --primary-rgb: 139, 92, 246;
  --primary-hover: #7c3aed;
  --primary-glow: rgba(139, 92, 246, 0.25);
  
  --secondary: #374151;
  --secondary-hover: #4b5563;
  
  --success: #10b981;
  --success-rgb: 16, 185, 129;
  --danger: #ef4444;
  --danger-rgb: 239, 68, 68;
  --warning: #f59e0b;
  --warning-rgb: 245, 158, 11;
  --info: #06b6d4;

  --text-main: #f9fafb;
  --text-muted: #9ca3af;
  
  /* Fonts */
  --font-ar: 'Tajawal', system-ui, -apple-system, sans-serif;
  --font-en: 'Outfit', system-ui, -apple-system, sans-serif;
  
  /* Layout Options */
  --radius-sm: 8px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --glass-blur: blur(16px) saturate(180%);
  --shadow-premium: 0 10px 30px -10px rgba(0, 0, 0, 0.7);
}

/* ==========================================================================
   GLOBAL RESET & INITIAL SETUP
   ========================================================================== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  min-height: 100vh;
  background-color: var(--bg-base);
  color: var(--text-main);
  scroll-behavior: smooth;
  overflow-x: hidden;
}

/* Language-specific font routing */
html[dir="rtl"] {
  font-family: var(--font-ar);
}
html[dir="ltr"] {
  font-family: var(--font-en);
}

/* Scrollbar Customization */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-base);
}
::-webkit-scrollbar-thumb {
  background: var(--secondary);
  border-radius: var(--radius-sm);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--primary);
}

/* ==========================================================================
   BACKGROUND GLOW DECORATIONS
   ========================================================================== */
.glow-bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

.glow-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.2;
}

.orb-1 {
  top: -10%;
  left: 10%;
  width: 50vw;
  height: 50vw;
  background: radial-gradient(circle, var(--primary) 0%, transparent 70%);
  animation: orbFloat 25s infinite alternate ease-in-out;
}

.orb-2 {
  bottom: -10%;
  right: 10%;
  width: 45vw;
  height: 45vw;
  background: radial-gradient(circle, var(--info) 0%, transparent 70%);
  animation: orbFloat 20s infinite alternate-reverse ease-in-out;
}

@keyframes orbFloat {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(4%, 8%) scale(1.15); }
  100% { transform: translate(-4%, -5%) scale(0.9); }
}

/* ==========================================================================
   APP SHELL LAYOUT
   ========================================================================== */
.app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  position: relative;
}

/* ==========================================================================
   HEADER COMPONENT
   ========================================================================== */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px 0;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 32px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  width: 32px;
  height: 32px;
  color: var(--primary);
  filter: drop-shadow(0 0 8px var(--primary-glow));
}

.logo h1 {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.logo h1 span {
  color: var(--primary);
  background: linear-gradient(to right, var(--primary), var(--info));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ==========================================================================
   BUTTONS & CONTROLS
   ========================================================================== */
.btn-icon {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  font-size: 0.9rem;
  transition: var(--transition-smooth);
  position: relative;
}

.btn-icon:hover {
  background: var(--secondary);
  border-color: var(--border-hover);
  transform: translateY(-2px);
}

.settings-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  position: absolute;
  top: 4px;
  right: 4px;
}

.pulse-amber {
  background-color: var(--warning);
  box-shadow: 0 0 0 0 rgba(var(--warning-rgb), 0.7);
  animation: pulseAmber 2s infinite;
}

.pulse-green {
  background-color: var(--success);
  box-shadow: 0 0 0 0 rgba(var(--success-rgb), 0.7);
  animation: pulseGreen 2s infinite;
}

@keyframes pulseAmber {
  0% { box-shadow: 0 0 0 0 rgba(var(--warning-rgb), 0.7); }
  70% { box-shadow: 0 0 0 6px rgba(var(--warning-rgb), 0); }
  100% { box-shadow: 0 0 0 0 rgba(var(--warning-rgb), 0); }
}

@keyframes pulseGreen {
  0% { box-shadow: 0 0 0 0 rgba(var(--success-rgb), 0.7); }
  70% { box-shadow: 0 0 0 6px rgba(var(--success-rgb), 0); }
  100% { box-shadow: 0 0 0 0 rgba(var(--success-rgb), 0); }
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-smooth);
  border: 1px solid transparent;
  font-size: 0.95rem;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  color: white;
  box-shadow: 0 4px 15px var(--primary-glow);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(var(--primary-rgb), 0.4);
}

.btn-secondary {
  background: var(--secondary);
  color: var(--text-main);
  border-color: var(--border-color);
}

.btn-secondary:hover {
  background: var(--secondary-hover);
  border-color: var(--border-hover);
  transform: translateY(-2px);
}

.btn-success {
  background: var(--success);
  color: white;
  box-shadow: 0 4px 15px rgba(var(--success-rgb), 0.2);
}

.btn-success:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(var(--success-rgb), 0.35);
}

.btn-block {
  display: flex;
  width: 100%;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

.btn-clear {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-smooth);
}

.btn-clear:hover {
  color: var(--text-main);
}

/* ==========================================================================
   GLASSMORPHISM CARD COMPONENT
   ========================================================================== */
.glass-card {
  background-color: var(--bg-card);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-premium);
  padding: 32px;
  transition: var(--transition-smooth);
}

/* ==========================================================================
   SCREENS VIEWPORT SWITCHER
   ========================================================================== */
.screen {
  display: none;
  animation: fadeIn 0.4s ease-out forwards;
}

.screen.active-screen {
  display: block;
}

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

.hidden {
  display: none !important;
}

.text-center {
  text-align: center;
}

.text-success {
  color: var(--success) !important;
}

.text-danger {
  color: var(--danger) !important;
}

.text-muted {
  color: var(--text-muted);
}

/* RTL Icons flips */
html[dir="rtl"] .icon-rtl {
  transform: scaleX(-1);
}

/* ==========================================================================
   SCREEN 1: SETUP LAYOUT
   ========================================================================== */
.intro-card {
  text-align: center;
  margin-bottom: 36px;
  animation: slideDown 0.5s ease-out;
}

.intro-card h2 {
  font-size: 2.2rem;
  font-weight: 800;
  margin-bottom: 12px;
  background: linear-gradient(135deg, var(--text-main) 30%, var(--text-muted));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.intro-card p {
  font-size: 1.1rem;
  color: var(--text-muted);
  max-width: 600px;
  margin: 0 auto;
}

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

/* Setup Grid */
.setup-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 24px;
  margin-bottom: 40px;
}

@media (max-width: 900px) {
  .setup-grid {
    grid-template-columns: 1fr;
  }
}

/* Tabs */
.tabs-container {
  display: flex;
  border-bottom: 2px solid var(--border-color);
  margin-bottom: 24px;
  gap: 8px;
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1rem;
  font-weight: 600;
  padding: 12px 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
  transition: var(--transition-smooth);
}

.tab-btn::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 100%;
  height: 2px;
  background-color: var(--primary);
  transform: scaleX(0);
  transition: var(--transition-smooth);
}

.tab-btn.active {
  color: var(--primary);
}

.tab-btn.active::after {
  transform: scaleX(1);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Upload zone */
.drop-zone {
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-md);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition-smooth);
  background: rgba(255, 255, 255, 0.01);
}

.drop-zone:hover, .drop-zone.dragover {
  border-color: var(--primary);
  background: rgba(139, 92, 246, 0.04);
}

.upload-icon {
  width: 48px;
  height: 48px;
  color: var(--text-muted);
  margin-bottom: 16px;
  transition: var(--transition-smooth);
}

.drop-zone:hover .upload-icon {
  color: var(--primary);
  transform: translateY(-4px);
}

.drop-zone h3 {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.drop-zone p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.file-info {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.2);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  margin-top: 16px;
  font-weight: 500;
  max-width: 100%;
}

.file-info span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 250px;
}

.btn-clear {
  margin-inline-start: 8px;
}

/* Direct Textarea */
#text-input {
  width: 100%;
  height: 220px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 16px;
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.95rem;
  resize: none;
  outline: none;
  transition: var(--transition-smooth);
}

#text-input:focus {
  border-color: var(--primary);
  background: rgba(139, 92, 246, 0.02);
}

/* Config Panel */
.panel-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.2rem;
  font-weight: 700;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 16px;
  margin-bottom: 24px;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 8px;
}

/* Grid 2 Column form fields */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 600px) {
  .grid-2 {
    grid-template-columns: 1fr;
  }
}

/* Inputs, Selects */
select {
  width: 100%;
  background: var(--bg-base);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 12px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.95rem;
  outline: none;
  cursor: pointer;
  transition: var(--transition-smooth);
}

select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-glow);
}

/* Radio Count Selector pills */
.count-selector {
  display: flex;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  padding: 4px;
  border-radius: var(--radius-sm);
  gap: 4px;
}

.count-selector input[type="radio"] {
  display: none;
}

.count-selector label {
  flex: 1;
  text-align: center;
  padding: 10px;
  border-radius: calc(var(--radius-sm) - 2px);
  cursor: pointer;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0;
  transition: var(--transition-smooth);
}

.count-selector input[type="radio"]:checked + label {
  background: var(--primary);
  color: white;
}

/* Checkbox Pills */
.types-selector {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.checkbox-pill {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition-smooth);
}

.checkbox-pill:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--border-hover);
}

.checkbox-pill input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  cursor: pointer;
}

.checkbox-pill span {
  font-weight: 500;
  font-size: 0.95rem;
}

/* Source Mode Selector (Radio Pills) */
.source-mode-selector {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 8px;
}

.radio-pill {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  padding: 16px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition-smooth);
}

.radio-pill:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--border-hover);
}

.radio-pill input[type="radio"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  margin-top: 3px;
  cursor: pointer;
  flex-shrink: 0;
}

.radio-pill i {
  width: 20px;
  height: 20px;
  color: var(--text-muted);
  flex-shrink: 0;
  margin-top: 2px;
  transition: var(--transition-smooth);
}

.radio-pill:has(input[type="radio"]:checked) {
  background: rgba(139, 92, 246, 0.08);
  border-color: var(--primary);
}

.radio-pill:has(input[type="radio"]:checked) i {
  color: var(--primary);
}

.radio-pill .pill-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.radio-pill strong {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
}

.radio-pill span {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* History List style */
.history-section {
  margin-top: 24px;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 20px;
}

.history-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
}

.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 40px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-muted);
}

.empty-state i {
  width: 40px;
  height: 40px;
  margin-bottom: 12px;
}

.history-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-card);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border-color);
  padding: 18px 24px;
  border-radius: var(--radius-md);
  transition: var(--transition-smooth);
}

.history-card:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
  box-shadow: 0 4px 15px rgba(var(--primary-rgb), 0.1);
}

.history-card-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow: hidden;
  cursor: pointer;
  flex: 1;
}

.history-card-info h4 {
  font-size: 1.05rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-card-meta {
  display: flex;
  gap: 12px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.history-card-meta span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.history-actions-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ==========================================================================
   SCREEN 2: LOADING SCREEN
   ========================================================================== */
.loading-card {
  max-width: 500px;
  margin: 60px auto;
}

.loading-spinner-wrapper {
  position: relative;
  width: 100px;
  height: 100px;
  margin: 0 auto 24px;
}

.spinner-ring {
  box-sizing: border-box;
  display: block;
  position: absolute;
  width: 100px;
  height: 100px;
  border: 4px solid var(--primary);
  border-radius: 50%;
  animation: spinnerRotate 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;
  border-color: var(--primary) transparent transparent transparent;
}

.spinner-brain {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 40px;
  height: 40px;
  color: var(--primary);
  animation: pulseBrain 1.5s ease-in-out infinite;
}

@keyframes spinnerRotate {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes pulseBrain {
  0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: 0.7; }
  50% { transform: translate(-50%, -50%) scale(1.15); opacity: 1; }
}

.loading-card h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 12px;
}

.loading-card p {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 24px;
}

.loading-progress-bar {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(to right, var(--primary), var(--info));
  border-radius: var(--radius-sm);
  transition: width 0.4s ease-out;
}

/* ==========================================================================
   SCREEN 3: QUIZ PLAYER LAYOUT
   ========================================================================== */
.quiz-layout {
  max-width: 800px;
  margin: 0 auto;
}

.quiz-card {
  padding: 40px;
}

.quiz-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.quiz-progress-text {
  font-size: 1.1rem;
  font-weight: 700;
}

.quiz-progress-text span {
  font-weight: 800;
  color: var(--primary);
}

.timer-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  padding: 6px 14px;
  border-radius: 50px;
  font-size: 0.95rem;
  font-weight: 700;
  font-family: var(--font-en);
}

.quiz-progress-bar {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 50px;
  margin-bottom: 36px;
  overflow: hidden;
}

/* Question Content styling */
.question-container {
  min-height: 280px;
  margin-bottom: 32px;
}

.quiz-question-type {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  background: rgba(139, 92, 246, 0.1);
  color: var(--primary);
  padding: 4px 12px;
  border-radius: 50px;
  margin-bottom: 16px;
}

.quiz-question-text {
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.5;
  margin-bottom: 24px;
}

/* Answer Choices */
.answers-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.choice-option {
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  padding: 16px 20px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition-smooth);
}

.choice-option:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--border-hover);
  transform: translateX(4px);
}

html[dir="rtl"] .choice-option:hover {
  transform: translateX(-4px);
}

.choice-letter {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--secondary);
  font-size: 0.85rem;
  font-weight: 700;
  margin-inline-end: 16px;
  font-family: var(--font-en);
  transition: var(--transition-smooth);
}

.choice-text {
  font-size: 1rem;
  font-weight: 500;
  flex: 1;
}

/* Option States */
.choice-option.selected {
  background: rgba(139, 92, 246, 0.08);
  border-color: var(--primary);
}

.choice-option.selected .choice-letter {
  background: var(--primary);
  color: white;
}

/* True False Option cards */
.tf-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.tf-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  cursor: pointer;
  gap: 12px;
  transition: var(--transition-smooth);
}

.tf-option:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--border-hover);
}

.tf-option.selected {
  border-color: var(--primary);
  background: rgba(139, 92, 246, 0.08);
}

.tf-option i {
  width: 32px;
  height: 32px;
  color: var(--text-muted);
}

.tf-option.selected i {
  color: var(--primary);
}

.tf-option span {
  font-size: 1.1rem;
  font-weight: 700;
}

/* Short answer input */
.short-input-wrapper {
  margin-top: 16px;
}

.short-input-wrapper textarea {
  width: 100%;
  height: 140px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  color: var(--text-main);
  font-family: inherit;
  font-size: 1rem;
  resize: none;
  outline: none;
  transition: var(--transition-smooth);
}

.short-input-wrapper textarea:focus {
  border-color: var(--primary);
  background: rgba(139, 92, 246, 0.02);
}

/* Quiz Navigation Bullets */
.quiz-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--border-color);
  padding-top: 24px;
  margin-top: 24px;
  gap: 16px;
}

.quiz-nav-bullets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.bullet-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-en);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.bullet-btn:hover {
  background: var(--secondary);
  border-color: var(--border-hover);
}

.bullet-btn.answered {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-main);
}

.bullet-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* ==========================================================================
   SCREEN 4: RESULTS SCREEN
   ========================================================================== */
.results-layout {
  display: grid;
  grid-template-columns: 0.8fr 1.2fr;
  gap: 24px;
  align-items: start;
}

@media (max-width: 900px) {
  .results-layout {
    grid-template-columns: 1fr;
  }
}

.summary-card {
  padding: 40px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.score-visualization {
  position: relative;
  width: 160px;
  height: 160px;
  margin: 24px auto;
}

.progress-ring-fill {
  transform: rotate(-90deg);
  transform-origin: 80px 80px;
  transition: stroke-dashoffset 0.6s ease-in-out;
}

.score-display {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}

.score-display span {
  font-size: 2.2rem;
  font-weight: 800;
  font-family: var(--font-en);
}

.score-display p {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-top: -4px;
  font-family: var(--font-en);
}

.summary-card h3 {
  font-size: 1.4rem;
  font-weight: 800;
  margin-bottom: 6px;
}

.result-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  margin-top: 24px;
}

.result-actions .btn {
  width: 100%;
}

/* Correction Details List */
.correction-list {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-top: 20px;
}

.correction-item {
  border: 1px solid var(--border-color);
  background: rgba(255, 255, 255, 0.01);
  border-radius: var(--radius-md);
  padding: 20px;
}

.correction-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.correction-num {
  font-weight: 700;
  color: var(--text-muted);
}

.correction-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 50px;
  font-size: 0.8rem;
  font-weight: 700;
}

.status-correct {
  background: rgba(16, 185, 129, 0.1);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.status-wrong {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.correction-text {
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.4;
  margin-bottom: 16px;
}

.correction-answers {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

.ans-line {
  display: flex;
  align-items: flex-start;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  line-height: 1.4;
}

.ans-line strong {
  margin-inline-end: 8px;
  white-space: nowrap;
}

.ans-line.user-ans {
  background: rgba(255, 255, 255, 0.03);
}

.ans-line.user-ans.correct {
  border-inline-start: 4px solid var(--success);
}

.ans-line.user-ans.incorrect {
  border-inline-start: 4px solid var(--danger);
}

.ans-line.correct-ans {
  border-inline-start: 4px solid var(--success);
  background: rgba(16, 185, 129, 0.05);
}

.correction-explanation {
  background: rgba(255, 255, 255, 0.02);
  border-top: 1px solid var(--border-color);
  padding-top: 12px;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--text-muted);
}

.correction-explanation strong {
  color: var(--primary);
  margin-inline-end: 4px;
}

/* ==========================================================================
   SETTINGS MODAL LAYOUT
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(3, 7, 18, 0.8);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: var(--transition-smooth);
}

.modal-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  width: 100%;
  max-width: 500px;
  border-radius: var(--radius-lg);
  padding: 0; /* Clear padding for structural wrapper */
  transform: translateY(20px) scale(0.95);
  transition: var(--transition-smooth);
  overflow: hidden;
}

.modal-backdrop.active .modal {
  transform: translateY(0) scale(1);
}

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

.modal-header h3 {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.25rem;
}

.modal-body {
  padding: 24px;
}

.modal-intro {
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.5;
  margin-bottom: 20px;
}

/* Input password style with visibility toggle */
.input-password-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-password-wrapper input {
  width: 100%;
  background: var(--bg-base);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 12px 44px 12px 12px;
  border-radius: var(--radius-sm);
  font-family: var(--font-en);
  font-size: 0.95rem;
  outline: none;
  transition: var(--transition-smooth);
}

html[dir="rtl"] .input-password-wrapper input {
  padding: 12px 12px 12px 44px;
}

.input-password-wrapper input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-glow);
}

.btn-input-action {
  position: absolute;
  inset-inline-end: 12px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-smooth);
}

.btn-input-action:hover {
  color: var(--text-main);
}

.field-hint {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 6px;
}

.field-hint a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}

.field-hint a:hover {
  text-decoration: underline;
}

/* Status Banner */
.api-status-banner {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  line-height: 1.5;
  margin-top: 20px;
}

.api-status-banner.warning {
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.2);
  color: #fbbf24;
}

.api-status-banner.success {
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.2);
  color: #34d399;
}

.modal-footer {
  padding: 20px 24px;
  background: rgba(255, 255, 255, 0.01);
  border-top: 1px solid var(--border-color);
}

/* ==========================================================================
   APP FOOTER COMPONENT
   ========================================================================== */
.app-footer {
  text-align: center;
  padding: 40px 0;
  color: var(--text-muted);
  font-size: 0.85rem;
  border-top: 1px solid var(--border-color);
  margin-top: auto;
}
