@import url('https://fonts.googleapis.com/css2?family=Amiri:ital,wght@0,400;0,700;1,400;1,700&family=Plus+Jakarta+Sans:wght@300;400;500;600;700&display=swap');

/* --- Design System & CSS Variables --- */
:root {
  /* Color Palette - Dark Theme (Default) */
  --bg-color: #171B3C;
  --bg-gradient: radial-gradient(circle at 50% 50%, #262C58 0%, #171B3C 100%);
  --panel-bg: rgba(32, 38, 77, 0.7);
  --panel-border: rgba(255, 255, 255, 0.08);
  
  --card-bg-front: linear-gradient(135deg, rgba(35, 41, 80, 0.9) 0%, rgba(24, 28, 58, 0.95) 100%);
  --card-bg-back: linear-gradient(135deg, rgba(32, 36, 72, 0.95) 0%, rgba(20, 23, 48, 0.98) 100%);
  --card-border: rgba(255, 255, 255, 0.12);
  --card-shadow: 0 20px 40px rgba(0, 0, 0, 0.5), 0 0 40px rgba(127, 137, 206, 0.1);

  --text-primary: #F7F4EE;
  --text-secondary: #A2A6C2;
  --text-muted: #7B7FA3;
  
  --accent-gold: #FFAE52;
  --accent-gold-gradient: linear-gradient(135deg, #FFC98A 0%, #D98A2B 100%);
  --accent-blue: #7F89CE;
  --accent-blue-gradient: linear-gradient(135deg, #9AA3E0 0%, #5A64A8 100%);
  
  --color-success: #10B981;
  --color-success-bg: rgba(16, 185, 129, 0.15);
  --color-danger: #EF4444;
  --color-danger-bg: rgba(239, 68, 68, 0.15);
  --color-warning: #FFAE52;
  --color-warning-bg: rgba(255, 174, 82, 0.15);
  
  --btn-secondary-bg: rgba(255, 255, 255, 0.05);
  --btn-secondary-hover: rgba(255, 255, 255, 0.1);
  --btn-secondary-border: rgba(255, 255, 255, 0.1);

  --font-arabic: "Noto Naskh Arabic", "Noto Sans Arabic", "Noto", serif;
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  
  --border-radius-lg: 24px;
  --border-radius-md: 16px;
  --border-radius-sm: 10px;
  
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-card: transform 0.6s cubic-bezier(0.2, 0.8, 0.2, 1.15), box-shadow 0.3s ease;
}

body.font-amiri {
  --font-arabic: 'Amiri', "Noto Naskh Arabic", "Noto Sans Arabic", "Noto", serif;
}

/* Light Theme Variables */
.light-theme {
  --bg-color: #F2EFE9;
  --bg-gradient: radial-gradient(circle at 50% 50%, #F7F4EE 0%, #E5E0D4 100%);
  --panel-bg: rgba(255, 255, 255, 0.8);
  --panel-border: rgba(32, 38, 77, 0.08);
  
  --card-bg-front: linear-gradient(135deg, rgba(255, 255, 255, 0.95) 0%, rgba(247, 244, 238, 0.98) 100%);
  --card-bg-back: linear-gradient(135deg, rgba(255, 255, 255, 0.98) 0%, rgba(242, 239, 233, 0.98) 100%);
  --card-border: rgba(32, 38, 77, 0.08);
  --card-shadow: 0 20px 40px rgba(32, 38, 77, 0.06), 0 0 20px rgba(127, 137, 206, 0.03);

  --text-primary: #20264D;
  --text-secondary: #4A5074;
  --text-muted: #A2A6C2;
  
  --accent-gold: #D98A2B;
  --accent-gold-gradient: linear-gradient(135deg, #FFAE52 0%, #B06E1C 100%);
  
  --btn-secondary-bg: rgba(32, 38, 77, 0.04);
  --btn-secondary-hover: rgba(32, 38, 77, 0.08);
  --btn-secondary-border: rgba(32, 38, 77, 0.08);
}

/* --- Base Resets & Layout --- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  overflow-x: hidden;
  width: 100%;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-color);
  background-image: var(--bg-gradient);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow-x: hidden;
  position: relative;
  transition: background 0.5s ease, color 0.3s ease;
  width: 100%;
}

/* --- Ambient Glowing Spheres (Premium Aesthetic) --- */
.glow-container {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  overflow: hidden;
  z-index: -1;
  pointer-events: none;
}

.glow-sphere {
  position: absolute;
  width: 400px;
  height: 400px;
  border-radius: 50%;
  filter: blur(120px);
  z-index: -1;
  opacity: 0.15;
  pointer-events: none;
  animation: float-glow 20s infinite alternate ease-in-out;
}

.glow-1 {
  background: var(--accent-blue);
  top: -100px;
  right: -50px;
}

.glow-2 {
  background: var(--accent-gold);
  bottom: -150px;
  left: -100px;
  animation-delay: -10s;
}

@keyframes float-glow {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(50px, 50px) scale(1.2); }
}

/* --- App Container --- */
.app-container {
  width: 100%;
  max-width: 1100px;
  padding: 24px 24px 8px 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  min-height: 95vh;
}

/* --- Header Component --- */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--panel-border);
}

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

.logo-mark {
  width: 68px;
  height: 68px;
  display: block;
  margin: -8px 0;
}

.logo-text h1 {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.logo-text .tagline {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

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

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

.stat-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--btn-secondary-bg);
  border: 1px solid var(--btn-secondary-border);
  padding: 8px 16px;
  border-radius: 30px;
  font-size: 0.85rem;
  font-weight: 500;
  transition: var(--transition-smooth);
}

.stat-badge i {
  color: var(--accent-gold);
}

.icon-btn {
  background: var(--btn-secondary-bg);
  border: 1px solid var(--btn-secondary-border);
  color: var(--text-primary);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  transition: var(--transition-smooth);
}

body.desktop-device .icon-btn:hover {
  background: var(--btn-secondary-hover);
  transform: translateY(-2px);
}

.mobile-menu-btn {
  display: none;
}

/* --- Main Layout Grid --- */
.main-content {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 24px;
  flex: 1;
  align-items: start; /* Aligns columns to the top naturally */
}

/* --- Card Blur Effect --- */
.card-blur {
  background: var(--panel-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--panel-border);
  border-radius: var(--border-radius-lg);
  padding: 24px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
}

/* --- Controls Sidebar (Left Column) --- */
.controls-sidebar {
  display: flex;
  flex-direction: column;
  gap: 20px;
  align-self: start;
}

.sidebar-card {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.sidebar-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0;
}

.sidebar-card-header h3 {
  font-size: 0.95rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}

.reset-link-btn {
  background: none;
  border: none;
  color: var(--accent-blue);
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: var(--border-radius-sm);
  transition: var(--transition-smooth);
}

.reset-link-btn:hover {
  background: rgba(127, 137, 206, 0.1);
  color: var(--text-primary);
}

.panel-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.panel-section h3 {
  font-size: 0.95rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
}

.control-group label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
}

/* Custom Select Dropdown Styling */
.select-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.select-wrapper select {
  width: 100%;
  background-color: #1C2145; /* Solid dark background matching card gradients to prevent white flash */
  border: 1px solid var(--btn-secondary-border);
  border-radius: var(--border-radius-sm);
  padding: 12px 16px;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  transition: var(--transition-smooth);
  color-scheme: dark; /* Tells Windows browsers to use dark-themed native dropdown rendering */
}

.light-theme .select-wrapper select {
  background-color: #F2EFE9; /* Solid light background matching light theme panel colors */
  color-scheme: light; /* Tells Windows browsers to use light-themed native dropdown rendering */
}

.select-wrapper select option {
  background-color: #1C2145; /* Match parent select solid background */
  color: #F7F4EE; /* Literal value — Windows browsers don't resolve CSS vars on <option> elements */
}

.light-theme .select-wrapper select option {
  background-color: #ffffff;
  color: #20264D; /* Literal dark text for light theme options */
}

.select-wrapper select:focus {
  outline: none;
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(127, 137, 206, 0.15);
}

.select-arrow {
  position: absolute;
  right: 16px;
  font-size: 0.75rem;
  color: var(--text-muted);
  pointer-events: none;
  transition: var(--transition-smooth);
}

.select-wrapper select:focus + .select-arrow {
  transform: rotate(180deg);
  color: var(--accent-blue);
}

.select-prefix-icon {
  position: absolute;
  left: 14px;
  font-size: 0.9rem;
  color: var(--text-muted);
  pointer-events: none;
}

.select-wrapper.has-prefix select {
  padding-left: 38px;
}

/* iOS Style Toggle Switch */
.switch-wrapper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: var(--border-radius-sm);
  transition: var(--transition-smooth);
}

.light-theme .switch-wrapper {
  background: rgba(32, 38, 77, 0.02);
  border: 1px solid rgba(32, 38, 77, 0.04);
}

.switch-wrapper:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.08);
}

.light-theme .switch-wrapper:hover {
  background: rgba(32, 38, 77, 0.04);
  border-color: rgba(32, 38, 77, 0.08);
}

.switch-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
  user-select: none;
}

.switch-label i {
  font-size: 0.95rem;
}

.switch-label .star-icon {
  color: var(--accent-gold);
}

.switch-label .eye-icon {
  color: var(--accent-blue);
}

/* Switch element */
.switch {
  position: relative;
  display: inline-block;
  width: 42px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider-switch {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--btn-secondary-bg);
  border: 1px solid var(--btn-secondary-border);
  transition: .3s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 34px;
}

.slider-switch:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: var(--text-secondary);
  transition: .3s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 50%;
}

.switch input:checked + .slider-switch {
  background-color: var(--accent-gold);
  border-color: var(--accent-gold);
}

.switch input:focus-visible + .slider-switch {
  box-shadow: 0 0 0 3px rgba(255, 174, 82, 0.25);
}

.switch input#hide-known-toggle:checked + .slider-switch {
  background-color: var(--accent-blue);
  border-color: var(--accent-blue);
}

.switch input:checked + .slider-switch:before {
  transform: translateX(18px);
  background-color: #ffffff;
}

/* Double Range Slider Styling */
.slider-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.slider-value-display {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent-blue);
  background: rgba(127, 137, 206, 0.1);
  padding: 2px 8px;
  border-radius: 12px;
}

.range-slider-wrapper {
  position: relative;
  width: 100%;
  height: 6px;
  margin: 15px 0 10px 0;
  background: var(--btn-secondary-border);
  border-radius: 4px;
}

.slider-track {
  position: absolute;
  height: 100%;
  background: var(--accent-blue-gradient);
  border-radius: 4px;
  left: 0%;
  right: 0%;
}

.range-slider-wrapper input[type="range"] {
  position: absolute;
  width: 100%;
  height: 6px;
  top: 0;
  left: 0;
  background: none;
  pointer-events: none;
  appearance: none;
  -webkit-appearance: none;
  margin: 0;
}

.range-slider-wrapper input[type="range"]::-webkit-slider-thumb {
  height: 18px;
  width: 18px;
  border-radius: 50%;
  background: var(--text-primary);
  border: 2.5px solid var(--accent-blue);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  pointer-events: auto;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  transition: transform 0.15s ease, background-color 0.15s ease;
  position: relative;
  z-index: 2;
}

.range-slider-wrapper input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
  background: var(--accent-blue);
}

.range-slider-wrapper input[type="range"]::-webkit-slider-thumb:active {
  transform: scale(1.3);
  box-shadow: 0 0 0 8px rgba(127, 137, 206, 0.15);
}

.range-slider-wrapper input[type="range"]::-moz-range-thumb {
  height: 18px;
  width: 18px;
  border-radius: 50%;
  background: var(--text-primary);
  border: 2.5px solid var(--accent-blue);
  cursor: pointer;
  pointer-events: auto;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  transition: transform 0.15s ease, background-color 0.15s ease;
  position: relative;
  z-index: 2;
}

.range-slider-wrapper input[type="range"]::-moz-range-thumb:hover {
  transform: scale(1.2);
  background: var(--accent-blue);
}

.range-slider-wrapper input[type="range"]::-moz-range-thumb:active {
  transform: scale(1.3);
  box-shadow: 0 0 0 8px rgba(127, 137, 206, 0.15);
}

/* Stats Styling */
.stats-sidebar-card {
  gap: 16px !important;
}

.stats-overview-box {
  background: linear-gradient(135deg, rgba(127, 137, 206, 0.03) 0%, rgba(127, 137, 206, 0.08) 100%);
  border: 1px solid rgba(127, 137, 206, 0.12);
  border-radius: var(--border-radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.light-theme .stats-overview-box {
  background: linear-gradient(135deg, rgba(127, 137, 206, 0.02) 0%, rgba(127, 137, 206, 0.05) 100%);
  border: 1px solid rgba(127, 137, 206, 0.08);
}

.progress-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.progress-title {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
}

/* Progress Bar */
.progress-bar-container {
  height: 8px;
  width: 100%;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  overflow: hidden;
}

.light-theme .progress-bar-container {
  background: rgba(32, 38, 77, 0.06);
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #7F89CE 0%, #a855f7 50%, #10b981 100%);
  width: 0%;
  border-radius: 10px;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 0 10px rgba(127, 137, 206, 0.25);
}

.text-success { color: var(--color-success); }
.text-danger { color: var(--color-danger); }
.text-warning { color: var(--color-warning); }

/* New Stats Grid Layout */
.stats-grid-new {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.stat-card-new {
  background: var(--btn-secondary-bg);
  border: 1px solid var(--btn-secondary-border);
  border-radius: var(--border-radius-md);
  padding: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: var(--transition-smooth);
}

.stat-card-new:hover {
  background: var(--btn-secondary-hover);
  border-color: rgba(255, 255, 255, 0.12);
  transform: translateY(-2px);
}

.light-theme .stat-card-new:hover {
  border-color: rgba(32, 38, 77, 0.12);
}

.stat-icon-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: var(--border-radius-sm);
  font-size: 0.95rem;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-secondary);
  flex-shrink: 0;
}

.light-theme .stat-icon-wrapper {
  background: rgba(32, 38, 77, 0.03);
}

.stat-card-new.seen .stat-icon-wrapper {
  color: var(--accent-blue);
  background: rgba(127, 137, 206, 0.1);
}

.stat-card-new.known {
  border-color: rgba(16, 185, 129, 0.15);
}

.stat-card-new.known:hover {
  border-color: rgba(16, 185, 129, 0.35);
}

.stat-card-new.known .stat-icon-wrapper {
  color: var(--color-success);
  background: var(--color-success-bg);
}

.stat-card-new.learning {
  border-color: rgba(255, 174, 82, 0.15);
}

.stat-card-new.learning:hover {
  border-color: rgba(255, 174, 82, 0.35);
}

.stat-card-new.learning .stat-icon-wrapper {
  color: var(--color-warning);
  background: var(--color-warning-bg);
}

.stat-card-new.remaining .stat-icon-wrapper {
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.05);
}

.light-theme .stat-card-new.remaining .stat-icon-wrapper {
  background: rgba(32, 38, 77, 0.04);
}

.stat-content {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.stat-label-new {
  font-size: 0.65rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stat-val-new {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
}

/* Modern stats actions container */
.stats-actions-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-top: 1px solid var(--panel-border);
  padding-top: 14px;
}

.btn-action {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.8rem;
  padding: 10px 16px;
  border-radius: var(--border-radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: var(--transition-smooth);
}

.btn-action:disabled {
  opacity: 0.4;
  cursor: not-allowed !important;
  pointer-events: none;
}

.btn-action.reset {
  background: rgba(239, 68, 68, 0.05);
  border-color: rgba(239, 68, 68, 0.15);
  color: #f87171;
  width: 100%;
}

.btn-action.reset:hover {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.3);
  color: #ef4444;
  transform: translateY(-1px);
}

.backup-actions {
  display: flex;
  gap: 8px;
  width: 100%;
}

.btn-action.export, .btn-action.import {
  background: var(--btn-secondary-bg);
  border-color: var(--btn-secondary-border);
  color: var(--text-secondary);
  flex: 1;
}

.btn-action.export:hover, .btn-action.import:hover {
  background: var(--btn-secondary-hover);
  border-color: rgba(255, 255, 255, 0.15);
  color: var(--text-primary);
  transform: translateY(-1px);
}

.light-theme .btn-action.export:hover, .light-theme .btn-action.import:hover {
  border-color: rgba(32, 38, 77, 0.15);
}

/* Buttons */
.btn {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.9rem;
  padding: 12px 20px;
  border-radius: var(--border-radius-sm);
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: var(--transition-smooth);
}

.btn-full {
  width: 100%;
}

.btn-secondary {
  background: var(--btn-secondary-bg);
  color: var(--text-primary);
  border: 1px solid var(--btn-secondary-border);
}

body.desktop-device .btn-secondary:hover {
  background: var(--btn-secondary-hover);
  transform: translateY(-1px);
}

/* --- Card Display Area (Right Side) --- */
.card-display-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 20px;
  padding-top: 10px; /* Visually aligns with the first sidebar card */
}

/* 3D Card Flipping Container */
.flashcard-container {
  width: 100%;
  max-width: 680px;
  height: 440px;
  perspective: 1200px;
}

.flashcard {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: var(--transition-card);
  cursor: pointer;
  border-radius: var(--border-radius-lg);
}

/* Active Flip State */
.flashcard.is-flipped {
  transform: rotateY(180deg);
}

/* Desktop Hover Micro-lift and Glow */
body.desktop-device .flashcard-container:hover .flashcard {
  transform: translateY(-1.5px);
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.6), 0 0 50px rgba(127, 137, 206, 0.2);
}

body.desktop-device .flashcard-container:hover .flashcard.is-flipped {
  transform: translateY(-1.5px) rotateY(180deg);
}

.flashcard:focus-visible {
  outline: 3px solid var(--accent-blue);
  outline-offset: 4px;
}

/* Card Faces */
.card-face {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: var(--border-radius-lg);
  border: 1.5px solid var(--swipe-border-color, var(--card-border));
  box-shadow: var(--card-shadow);
  padding: 30px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  transition: border-color 0.3s ease;
}

.card-face::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 6px;
  background: var(--accent-blue-gradient);
}

/* Front card specific */
.card-front {
  background: var(--card-bg-front);
}

/* Back card specific & rotated */
.card-back {
  background: var(--card-bg-back);
  transform: rotateY(180deg);
  padding: 22px; /* More compact padding to maximize internal height */
}



.card-back::before {
  background: var(--accent-gold-gradient);
}

/* Ensure card back body doesn't overflow */
.card-back .card-body {
  gap: 10px; /* Tighter spacing on the back to fit meanings and links */
  overflow-y: auto; /* Scroll safety guard if content exceeds boundary */
  max-height: 100%;
  width: 100%;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

/* Styled scrollbar for card back body */
.card-back .card-body::-webkit-scrollbar {
  width: 4px;
}

.card-back .card-body::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}

.card-back .card-body::-webkit-scrollbar-track {
  background: transparent;
}

/* Card Substructures */
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

.card-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.pos-tag {
  background: var(--color-success-bg);
  color: var(--color-success);
  border: 1px solid rgba(16, 185, 129, 0.2);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
  letter-spacing: 0.5px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.frequency-tag {
  background: rgba(127, 137, 206, 0.1);
  color: var(--accent-blue);
  border: 1px solid rgba(127, 137, 206, 0.15);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 20px;
  letter-spacing: 0.5px;
}

.card-back .frequency-tag {
  background: rgba(255, 174, 82, 0.1);
  color: var(--accent-gold);
  border: 1px solid rgba(255, 174, 82, 0.15);
}

.card-index-indicator {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* Card Body */
.card-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  gap: 16px;
  -webkit-user-select: text !important;
  user-select: text !important;
}

.arabic-text,
.arabic-mini,
.transliteration,
.transliteration-mini,
.meaning-text,
.word-root {
  -webkit-user-select: text !important;
  user-select: text !important;
  cursor: text;
}

/* Quranic Arabic typography */
.arabic-word-wrapper {
  margin: 10px 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  position: relative;
}

.speak-btn {
  background: var(--btn-secondary-bg);
  border: 1px solid var(--btn-secondary-border);
  color: var(--accent-blue);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
  transition: var(--transition-smooth);
}

body.desktop-device .speak-btn:hover {
  background: var(--btn-secondary-hover);
  border-color: var(--accent-blue);
  transform: scale(1.1) translateY(-1px);
}

.speak-btn:active {
  transform: scale(0.95);
}

.arabic-mini-wrapper {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.speak-btn-mini {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 4px;
  display: inline-flex;
  align-items: center;
  transition: var(--transition-smooth);
}

body.desktop-device .speak-btn-mini:hover {
  color: var(--accent-blue);
  transform: scale(1.15);
}

.speak-btn-mini:active {
  transform: scale(0.95);
}


.arabic-text {
  font-family: var(--font-arabic);
  font-size: 5.6rem; /* Scaled up for majestic presence */
  font-weight: 700;
  line-height: 1.1;
  color: var(--text-primary);
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
  direction: rtl;
}

/* Arabic text back face layout */
.arabic-mini {
  font-family: var(--font-arabic);
  font-size: 2.2rem; /* Decreased for a cleaner layout on the meaning side */
  font-weight: 700;
  color: var(--text-secondary);
}

.transliteration {
  font-size: 1.75rem; /* Scaled up further */
  color: var(--accent-blue);
  font-weight: 500;
  letter-spacing: 0.5px;
}

.transliteration-mini {
  display: none; /* Removed from the back of the card per user request */
}

.divider {
  width: 60px;
  height: 2px;
  background: var(--card-border);
  margin: 8px 0;
}

/* English Meaning style */
.meaning-wrapper {
  max-width: 90%;
}

.meaning-text {
  font-size: 1.45rem; /* Decreased to fit combined comma-separated meanings list comfortably */
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.4;
}

.card-footer {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  margin-top: 10px;
}

.interaction-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

body.desktop-device .card-face:hover .interaction-hint {
  color: var(--text-secondary);
}

/* Pulse interaction for hint icon */
.interaction-hint i {
  animation: pulse-icon 2s infinite ease-in-out;
}

@keyframes pulse-icon {
  0% { transform: scale(1); }
  50% { transform: scale(1.15) rotate(15deg); }
  100% { transform: scale(1); }
}

/* --- Assessment Controls Deck --- */
.controls-deck {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  width: 100%;
  max-width: 680px;
}

.btn-nav {
  background: var(--panel-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--panel-border);
  color: var(--text-primary);
  width: 56px;
  height: 56px;
  border-radius: 50%;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

body.desktop-device .btn-nav:hover {
  background: var(--btn-secondary-hover);
  border-color: var(--accent-blue);
  color: var(--accent-blue);
  transform: translateY(-2px);
}

.btn-nav:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  transform: none;
  border-color: var(--panel-border);
  color: var(--text-muted);
}

.assessment-buttons {
  display: flex;
  gap: 12px;
  flex: 1;
  align-items: center;
}

.btn-danger {
  background: var(--color-danger-bg);
  border: 1px solid var(--color-danger);
  color: var(--color-danger);
  flex: 1;
}

body.desktop-device .btn-danger:hover:not(:disabled) {
  background: var(--color-danger);
  color: #FFF;
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 8px 24px rgba(239, 68, 68, 0.4);
}

.btn-success {
  background: var(--color-success-bg);
  border: 1px solid var(--color-success);
  color: var(--color-success);
  flex: 1;
}

body.desktop-device .btn-success:hover:not(:disabled) {
  background: var(--color-success);
  color: #FFF;
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 8px 24px rgba(16, 185, 129, 0.4);
}

.btn-danger:disabled, .btn-success:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  transform: none;
}

/* --- Undo Button Styling --- */
#undo-btn {
  flex: 0 0 56px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--panel-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--panel-border);
  color: var(--text-primary);
  font-size: 1.1rem;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  transition: var(--transition-smooth);
}

body.desktop-device #undo-btn:hover:not(:disabled) {
  background: var(--btn-secondary-hover);
  border-color: var(--accent-blue);
  color: var(--accent-blue);
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(127, 137, 206, 0.2);
}

#undo-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  transform: none !important;
  border-color: var(--panel-border);
  color: var(--text-muted);
}

/* --- Keyboard Shortcuts Help Banner --- */
.keyboard-shortcuts {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--btn-secondary-bg);
  padding: 6px 16px;
  border-radius: 30px;
  border: 1px solid var(--btn-secondary-border);
}

.keyboard-shortcuts kbd {
  background: var(--text-muted);
  color: var(--bg-color);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.7rem;
}

/* --- Footer --- */
footer {
  text-align: center;
  padding: 16px 0 0 0;
  font-size: 0.8rem;
  color: var(--text-muted);
  border-top: 1px solid var(--panel-border);
  margin-top: auto;
}

.rules-reference {
  margin-top: 10px;
  display: flex;
  justify-content: center;
  width: 100%;
}

.reference-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.75rem;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition-smooth);
}

body.desktop-device .reference-link:hover {
  color: var(--accent-blue);
  transform: translateY(-1px);
}

/* --- Page Transitions / Dynamic Animation Classes --- */
.scale-down {
  transform: scale(0.95);
  opacity: 0.8;
}

.slide-next-out {
  transform: translateX(-50px) rotateY(-10deg) scale(0.95);
  opacity: 0;
}

.slide-prev-out {
  transform: translateX(50px) rotateY(10deg) scale(0.95);
  opacity: 0;
}

.slide-in {
  transform: scale(1.05);
  opacity: 0;
}

/* --- Contextual Meanings (Back of Card) --- */
.context-meanings {
  margin-top: 14px;
  width: 100%;
  text-align: center;
}

.context-title {
  display: block;
  font-size: 0.85rem; /* Scaled up further */
  color: var(--text-muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 8px;
}

.context-tags {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  max-height: 80px;
  overflow-y: auto;
  padding: 2px;
}

/* Glassmorphic Capsule Chips */
.context-chip {
  font-size: 0.9rem; /* Scaled up further */
  font-weight: 500;
  padding: 5px 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  color: var(--text-primary);
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
  transition: var(--transition-smooth);
}

body.desktop-device .context-chip:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--accent-gold-semi);
  transform: translateY(-1px);
}

/* Light mode specific variations */
[data-theme="light"] .context-chip {
  background: rgba(0, 0, 0, 0.03);
  border-color: rgba(0, 0, 0, 0.06);
}

body.desktop-device [data-theme="light"] .context-chip:hover {
  background: rgba(0, 0, 0, 0.05);
  border-color: var(--accent-gold);
}

.study-link-wrapper {
  margin-top: 16px;
  display: flex;
  justify-content: center;
  width: 100%;
}

.study-link {
  background: rgba(127, 137, 206, 0.08);
  border: 1px solid rgba(127, 137, 206, 0.18);
  color: var(--accent-blue);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 8px 18px;
  border-radius: 30px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: var(--transition-smooth);
}

body.desktop-device .study-link:hover {
  background: rgba(255, 174, 82, 0.08);
  border-color: var(--accent-gold);
  color: var(--accent-gold);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(255, 174, 82, 0.15);
}

.study-link:active {
  transform: translateY(0);
}

/* --- Responsive Adjustments --- */
@media (max-width: 860px) {
  .main-content {
    grid-template-columns: 1fr;
    gap: 20px;
    max-width: 520px;
    width: 100%;
    margin: 0 auto;
    box-sizing: border-box;
  }

  .main-content > * {
    min-width: 0;
  }
  
  .controls-sidebar {
    order: 2; /* Sidebar goes down on mobile */
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }
  
  .card-display-area {
    order: 1;
    margin-top: 10px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: stretch; /* Stretch children to full width like the about page */
  }
  
  .flashcard-container {
    height: 440px; /* Increased to support scaled fonts on tablet */
    width: 100%;
    max-width: 100%;
  }

  .controls-deck {
    width: 100%;
    max-width: 100%;
  }

  .arabic-text {
    font-size: 4.8rem;
  }
}

@media (max-width: 600px) {
  .app-container {
    padding: 12px 8px;
    gap: 16px;
  }

  header {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
  }

  .header-actions {
    width: auto;
    justify-content: flex-end;
    gap: 8px;
  }

  .mastery-text {
    display: none;
  }

  .stat-badge {
    padding: 8px 12px;
  }

  .mobile-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .actions-wrapper {
    display: none;
    position: absolute;
    top: 50px;
    right: 0;
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: var(--border-radius-sm);
    padding: 8px;
    width: 210px;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    flex-direction: column;
    gap: 4px;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transform-origin: top right;
    animation: fadeInScale 0.15s cubic-bezier(0.16, 1, 0.3, 1);
  }

  .actions-wrapper.active {
    display: flex;
  }

  @keyframes fadeInScale {
    from {
      opacity: 0;
      transform: scale(0.95) translateY(-10px);
    }
    to {
      opacity: 1;
      transform: scale(1) translateY(0);
    }
  }

  .actions-wrapper .icon-btn,
  .actions-wrapper .user-profile-btn,
  .actions-wrapper .sync-indicator {
    width: 100% !important;
    height: 44px !important;
    border-radius: 8px !important;
    background: transparent !important;
    border: none !important;
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    padding: 0 12px !important;
    gap: 12px !important;
    color: var(--text-primary) !important;
    font-size: 0.95rem !important;
    transition: background 0.15s ease, transform 0.1s ease !important;
    box-sizing: border-box !important;
    cursor: pointer;
    box-shadow: none !important;
  }

  .actions-wrapper .icon-btn:hover,
  .actions-wrapper .user-profile-btn:hover,
  .actions-wrapper .sync-indicator:hover {
    background: rgba(255, 255, 255, 0.08) !important;
  }

  .actions-wrapper .icon-btn:active,
  .actions-wrapper .user-profile-btn:active,
  .actions-wrapper .sync-indicator:active {
    transform: scale(0.98);
  }

  .actions-wrapper .user-profile-btn img {
    width: 22px !important;
    height: 22px !important;
    border-radius: 50% !important;
    object-fit: cover !important;
    margin: 0 !important;
  }

  #profile-btn::after {
    content: "Account & Sync";
    font-weight: 500;
  }

  #theme-toggle::after {
    content: "Toggle Theme";
    font-weight: 500;
  }

  #focus-toggle::after {
    content: "Focus Mode";
    font-weight: 500;
  }

  #vocab-explorer-btn::after {
    content: "Vocab Explorer";
    font-weight: 500;
  }

  #settings-btn::after {
    content: "Filters & Settings";
    font-weight: 500;
  }

  #help-btn::after {
    content: "Help & Shortcuts";
    font-weight: 500;
  }

  .actions-wrapper .sync-indicator {
    order: -1;
    background: rgba(127, 137, 206, 0.08) !important;
    border: 1px solid rgba(127, 137, 206, 0.15) !important;
  }

  .actions-wrapper .sync-indicator span {
    display: inline !important;
    font-size: 0.95rem !important;
    color: var(--text-primary) !important;
    font-weight: 500;
  }

  @media (max-width: 360px) {
    .logo-text .tagline {
      display: none;
    }
    .logo-text h1 {
      font-size: 1.25rem;
    }
  }

  .flashcard-container {
    width: 100%;
    max-width: 100%;
    height: 390px; /* Increased to support scaled fonts on mobile */
    margin-left: auto;
    margin-right: auto;
  }

  .arabic-text {
    font-size: 4rem;
  }

  .meaning-text {
    font-size: 1.15rem;
  }

  .controls-deck {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    width: 100%;
    max-width: 100%;
    margin-left: auto;
    margin-right: auto;
  }

  .btn-nav {
    width: 48px;
    height: 48px;
  }

  .assessment-buttons {
    grid-column: span 2;
    display: flex;
    gap: 8px;
    width: 100%;
    align-items: center;
  }

  .assessment-buttons .btn {
    flex: 1;
    justify-content: center;
    padding: 10px 8px;
    font-size: 0.8rem;
    white-space: nowrap;
  }

  #undo-btn {
    flex: 0 0 42px !important;
    width: 42px !important;
    height: 42px !important;
    font-size: 0.95rem;
  }

  #prev-btn {
    grid-column: 1;
    grid-row: 2;
    justify-self: end;
    margin-right: 12px;
  }

  #next-btn {
    grid-column: 2;
    grid-row: 2;
    justify-self: start;
    margin-left: 12px;
  }

  .btn {
    padding: 10px 14px;
    font-size: 0.8rem;
  }
  
  .keyboard-shortcuts {
    display: none; /* Hide shortcuts on very small screens since they don't have keyboards */
  }
}

/* --- About Page Styling --- */
.main-content.single-column {
  grid-template-columns: 1fr;
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
}

.about-card {
  width: 100%;
  text-align: left;
}

.profile-header {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--panel-border);
  padding-bottom: 20px;
}

.profile-avatar {
  width: 70px;
  height: 70px;
  background: var(--btn-secondary-hover);
  border: 1.5px solid var(--panel-border);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.2rem;
  color: var(--accent-blue);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
  flex-shrink: 0;
}

.profile-title h2 {
  font-family: var(--font-sans);
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 4px;
  color: var(--text-primary);
}

.profile-subtitle {
  font-size: 0.95rem;
  color: var(--text-muted);
  font-weight: 500;
}

.profile-bio p {
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.section-title {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 24px 0 16px 0;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-primary);
  border-bottom: 1px solid var(--panel-border);
  padding-bottom: 8px;
}

.credentials-list {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 24px;
}

.credentials-list li {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.credential-icon {
  width: 36px;
  height: 36px;
  background: rgba(127, 137, 206, 0.08);
  border: 1px solid rgba(127, 137, 206, 0.15);
  border-radius: var(--border-radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  color: var(--accent-blue);
  flex-shrink: 0;
  margin-top: 2px;
}

.credential-detail {
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
}

.credential-detail strong {
  font-size: 0.95rem;
  color: var(--text-primary);
  font-weight: 600;
}

.credential-detail span {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.connect-links {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 12px;
}

.connect-item {
  background: var(--btn-secondary-bg);
  border: 1px solid var(--btn-secondary-border);
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 500;
  padding: 8px 16px;
  border-radius: 30px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: var(--transition-smooth);
}

body.desktop-device .connect-item:hover {
  background: var(--btn-secondary-hover);
  border-color: var(--accent-blue);
  color: var(--accent-blue);
  transform: translateY(-2px);
}

/* --- Search Input & Dropdown Styling --- */
.search-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.search-icon {
  position: absolute;
  left: 12px;
  color: var(--text-muted);
  font-size: 0.9rem;
  pointer-events: none;
}

.search-wrapper input {
  width: 100%;
  padding: 10px 36px 10px 34px;
  background: var(--input-bg);
  border: 1.5px solid var(--card-border);
  border-radius: var(--border-radius-sm);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  transition: var(--transition-smooth);
}

.search-wrapper input:focus {
  outline: none;
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(127, 137, 206, 0.15);
  background: var(--btn-secondary-hover);
}

.clear-search-btn {
  position: absolute;
  right: 12px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  transition: var(--transition-smooth);
}

.clear-search-btn:hover {
  color: var(--text-primary);
  transform: scale(1.1);
}

.search-results-box {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--card-bg-front);
  border: 1.5px solid var(--card-border);
  border-radius: var(--border-radius-sm);
  max-height: 250px;
  overflow-y: auto;
  z-index: 100;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

/* Styled scrollbar for search results */
.search-results-box::-webkit-scrollbar {
  width: 4px;
}

.search-results-box::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}

.search-result-item {
  padding: 10px 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--card-border);
  font-size: 0.85rem;
  transition: var(--transition-smooth);
  text-align: left;
}

.search-result-item:last-child {
  border-bottom: none;
}

.search-result-item.selected,
.search-result-item:hover {
  background: rgba(127, 137, 206, 0.08);
  color: var(--accent-blue);
}

.search-result-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-width: 70%;
}

.search-result-translit {
  font-weight: 600;
  color: var(--text-primary);
}

.search-result-meaning {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-result-arabic {
  font-family: var(--font-arabic);
  font-size: 1.15rem;
  color: var(--text-secondary);
  direction: rtl;
}

.search-result-no-match {
  padding: 12px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* --- Star Bookmark Styling --- */
.card-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.star-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-smooth);
}

body.desktop-device .star-btn:hover {
  color: var(--accent-gold);
  transform: scale(1.15);
}

.star-btn:active {
  transform: scale(0.9);
}

.star-btn.starred {
  color: var(--accent-gold);
}

.star-btn.starred i {
  font-weight: 900; /* Force solid FontAwesome star */
}

/* --- Focus Mode Styles --- */
body.focus-mode header > :not(.header-actions),
body.focus-mode .header-actions > :not(.actions-wrapper),
body.focus-mode .actions-wrapper > :not(#focus-toggle),
body.focus-mode .controls-sidebar,
body.focus-mode .keyboard-shortcuts,
body.focus-mode .rules-reference,
body.focus-mode footer {
  display: none !important;
}

body.focus-mode .actions-wrapper {
  display: flex !important;
  position: static !important;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  padding: 0 !important;
  width: auto !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  animation: none !important;
}

body.focus-mode .actions-wrapper #focus-toggle {
  width: 40px !important;
  height: 40px !important;
  border-radius: 50% !important;
  background: var(--btn-secondary-bg) !important;
  border: 1px solid var(--btn-secondary-border) !important;
  justify-content: center !important;
  padding: 0 !important;
}

body.focus-mode .actions-wrapper #focus-toggle:hover {
  background: var(--btn-secondary-hover) !important;
}

body.focus-mode #focus-toggle::after {
  content: none !important;
}

body.focus-mode .main-content {
  grid-template-columns: 1fr;
  max-width: 520px;
  width: 100%;
  margin: 0 auto;
}

body.focus-mode .app-container {
  min-height: 95vh;
  justify-content: center;
  align-items: center;
  padding: 24px;
}

body.focus-mode header {
  border-bottom: none;
  position: absolute;
  top: 24px;
  right: 24px;
  padding: 0;
  z-index: 1000;
}

body.focus-mode .header-actions {
  width: auto;
}

@media (max-width: 600px) {
  body.focus-mode .app-container {
    padding: 16px 8px;
  }
  
  body.focus-mode header {
    top: 12px;
    right: 8px;
  }
}

/* Ensure cards and controls take full width on mobile devices/browsers */
body.mobile-device .flashcard-container,
body.mobile-device .controls-deck {
  width: 100%;
  max-width: 100%;
}

/* --- Authentication & Sync Styling --- */

/* Sync status indicator in header */
.sync-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  padding: 6px 12px;
  border-radius: var(--border-radius-sm);
  background: var(--btn-secondary-bg);
  border: 1px solid var(--btn-secondary-border);
  color: var(--text-secondary);
  transition: var(--transition-smooth);
  cursor: pointer;
}

.sync-indicator:hover {
  background: var(--btn-secondary-hover);
  color: var(--text-primary);
}

.sync-indicator.syncing i {
  animation: spin 1.5s linear infinite;
  color: var(--accent-blue);
}

.sync-indicator.synced i {
  color: var(--color-success);
}

.sync-indicator.error i {
  color: var(--color-danger);
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* User Profile Header Button */
.user-profile-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid var(--btn-secondary-border);
  cursor: pointer;
  transition: var(--transition-smooth);
  background: var(--btn-secondary-bg);
}

.user-profile-btn:hover {
  border-color: var(--accent-blue);
  transform: scale(1.05);
}

.user-profile-btn img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.user-profile-btn i {
  font-size: 1.2rem;
  color: var(--text-secondary);
}

/* Auth Modal Overlay */
.auth-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(10, 12, 28, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

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

/* Auth Modal Card */
.auth-modal-card {
  width: 90%;
  max-width: 420px;
  background: var(--card-bg-front);
  border: 1px solid var(--card-border);
  box-shadow: var(--card-shadow);
  border-radius: var(--border-radius-lg);
  padding: 32px;
  position: relative;
  transform: scale(0.9);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  text-align: center;
}

.auth-modal-overlay.active .auth-modal-card {
  transform: scale(1);
}

.auth-modal-close {
  position: absolute;
  top: 20px;
  right: 20px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.auth-modal-close:hover {
  color: var(--text-primary);
  transform: rotate(90deg);
}

.auth-modal-header {
  margin-bottom: 24px;
}

.auth-modal-icon {
  font-size: 3rem;
  background: var(--accent-blue-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 16px;
  display: inline-block;
}

.auth-modal-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.auth-modal-subtitle {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.auth-features-list {
  text-align: left;
  margin: 24px 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.02);
  border-radius: var(--border-radius-md);
  border: 1px solid var(--panel-border);
}

.auth-feature-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.88rem;
  color: var(--text-secondary);
}

.auth-feature-item i {
  color: var(--color-success);
  font-size: 1rem;
}

/* Google Button Container */
.google-btn-wrapper {
  display: flex;
  justify-content: center;
  margin: 24px 0 12px 0;
  min-height: 40px;
}

/* Profile Info inside Auth Modal */
.profile-user-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 3px solid var(--accent-blue);
  margin: 0 auto 16px auto;
  overflow: hidden;
  box-shadow: 0 10px 20px rgba(127, 137, 206, 0.2);
}

.profile-user-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-user-name {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.profile-user-email {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 24px;
}

.profile-sync-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 16px;
  border-radius: 50px;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 32px;
  background: var(--color-success-bg);
  color: var(--color-success);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.profile-sync-status-badge.syncing {
  background: rgba(127, 137, 206, 0.15);
  color: var(--accent-blue);
  border-color: rgba(127, 137, 206, 0.2);
}

.profile-sync-status-badge.syncing i {
  animation: spin 1.5s linear infinite;
}

/* Action Buttons */
.auth-action-btn {
  width: 100%;
  padding: 12px;
  border-radius: var(--border-radius-md);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: var(--transition-smooth);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-signout {
  background: var(--btn-secondary-bg);
  border: 1px solid var(--btn-secondary-border);
  color: var(--text-primary);
  margin-bottom: 12px;
}

.btn-signout:hover {
  background: var(--btn-secondary-hover);
}

.btn-delete-acc {
  background: rgba(239, 68, 68, 0.05);
  border: 1px solid rgba(239, 68, 68, 0.15);
  color: var(--color-danger);
}

.btn-delete-acc:hover {
  background: var(--color-danger-bg);
  border-color: var(--color-danger);
}

/* Modal Confirmation Screen */
.delete-confirmation-box {
  display: none;
  background: rgba(239, 68, 68, 0.05);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: var(--border-radius-md);
  padding: 16px;
  margin-top: 16px;
  text-align: left;
}

.delete-confirmation-box.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

.delete-confirm-title {
  color: var(--color-danger);
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 6px;
}

.delete-confirm-text {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.4;
  margin-bottom: 12px;
}

.delete-confirm-actions {
  display: flex;
  gap: 8px;
}

.btn-danger-confirm {
  background: var(--color-danger);
  border: none;
  color: white;
  padding: 8px 12px;
  border-radius: var(--border-radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-danger-cancel {
  background: var(--btn-secondary-bg);
  border: 1px solid var(--btn-secondary-border);
  color: var(--text-primary);
  padding: 8px 12px;
  border-radius: var(--border-radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

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

/* Guest sign-in prompt callout */
.guest-signin-prompt {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(135deg, rgba(127, 137, 206, 0.1) 0%, rgba(127, 137, 206, 0.05) 100%);
  border: 1px solid rgba(127, 137, 206, 0.2);
  border-radius: var(--border-radius-md);
  padding: 16px 20px;
  margin: 20px 0;
  display: none; /* Controlled by JS */
}

.guest-signin-prompt-content {
  text-align: left;
}

.guest-signin-prompt-title {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.95rem;
  margin-bottom: 4px;
}

.guest-signin-prompt-subtitle {
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.guest-signin-prompt-btn {
  background: var(--accent-blue-gradient);
  border: none;
  color: white;
  padding: 8px 16px;
  border-radius: var(--border-radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(127, 137, 206, 0.3);
  transition: var(--transition-smooth);
}

.guest-signin-prompt-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(127, 137, 206, 0.4);
}

/* Settings Modal Overlay */
.settings-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(10, 12, 28, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 1500;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

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

/* Settings Modal Card */
.settings-modal-card {
  width: 90%;
  max-width: 460px;
  background: var(--card-bg-front);
  border: 1px solid var(--card-border);
  box-shadow: var(--card-shadow);
  border-radius: var(--border-radius-lg);
  padding: 32px;
  position: relative;
  transform: scale(0.9);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.settings-modal-overlay.active .settings-modal-card {
  transform: scale(1);
}

.settings-modal-close {
  position: absolute;
  top: 20px;
  right: 20px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.settings-modal-close:hover {
  color: var(--text-primary);
  transform: rotate(90deg);
}

.settings-modal-header {
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--panel-border);
  padding-bottom: 15px;
}

.settings-modal-header h3 {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.settings-modal-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: 60vh;
  overflow-y: auto;
  padding-right: 4px;
}

/* Custom Scrollbar for Settings Body */
.settings-modal-body::-webkit-scrollbar {
  width: 6px;
}
.settings-modal-body::-webkit-scrollbar-track {
  background: transparent;
}
.settings-modal-body::-webkit-scrollbar-thumb {
  background: var(--panel-border);
  border-radius: 3px;
}

.settings-modal-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--panel-border);
  padding-top: 15px;
  margin-top: 5px;
}

/* Vocabulary Explorer Overlay */
.vocab-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(10, 12, 28, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 1400; /* Just below settings, above cards */
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

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

/* Vocabulary Explorer Card */
.vocab-modal-card {
  width: 95%;
  max-width: 800px;
  height: 85vh;
  background: var(--card-bg-front);
  border: 1px solid var(--card-border);
  box-shadow: var(--card-shadow);
  border-radius: var(--border-radius-lg);
  padding: 24px;
  position: relative;
  transform: scale(0.95);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.vocab-modal-overlay.active .vocab-modal-card {
  transform: scale(1);
}

.vocab-modal-close {
  position: absolute;
  top: 20px;
  right: 20px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.vocab-modal-close:hover {
  color: var(--text-primary);
  transform: rotate(90deg);
}

.vocab-modal-header {
  display: flex;
  align-items: baseline;
  gap: 12px;
  border-bottom: 1px solid var(--panel-border);
  padding-bottom: 12px;
}

.vocab-modal-header h3 {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.vocab-total-count {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 400;
}

.vocab-search-row {
  width: 100%;
}

/* Tabs styling */
.vocab-tabs-row {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--panel-border);
  padding-bottom: 8px;
  overflow-x: auto;
  scrollbar-width: none; /* Hide scrollbar for tabs row */
}

.vocab-tabs-row::-webkit-scrollbar {
  display: none;
}

.vocab-tab {
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 8px 16px;
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: 20px;
  cursor: pointer;
  transition: var(--transition-smooth);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.vocab-tab:hover {
  color: var(--text-primary);
  background: var(--btn-secondary-bg);
}

.vocab-tab.active {
  color: white;
  background: var(--accent-blue-gradient);
  box-shadow: 0 4px 10px rgba(127, 137, 206, 0.3);
}

.vocab-modal-body {
  flex: 1;
  overflow-y: auto;
  padding-right: 4px;
}

/* Scrollbar for Vocab Body */
.vocab-modal-body::-webkit-scrollbar {
  width: 6px;
}
.vocab-modal-body::-webkit-scrollbar-track {
  background: transparent;
}
.vocab-modal-body::-webkit-scrollbar-thumb {
  background: var(--panel-border);
  border-radius: 3px;
}

.vocab-table-wrapper {
  width: 100%;
}

.vocab-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.vocab-table th,
.vocab-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--panel-border);
  font-size: 0.9rem;
  vertical-align: middle;
}

.vocab-table th {
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  position: sticky;
  top: 0;
  background: var(--card-bg-front);
  z-index: 1;
}

.vocab-table tbody tr {
  transition: var(--transition-smooth);
}

.vocab-table tbody tr:hover {
  background: rgba(127, 137, 206, 0.05);
}

.arabic-vocab-cell {
  font-family: 'Scheherazade New', 'Amiri', serif;
  font-size: 1.6rem;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.2;
}

.vocab-star-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  transition: var(--transition-smooth);
}

.vocab-star-btn.starred {
  color: var(--accent-gold);
  transform: scale(1.1);
}

.vocab-star-btn:hover {
  transform: scale(1.2);
}

.vocab-study-btn {
  background: rgba(127, 137, 206, 0.1);
  border: 1px solid rgba(127, 137, 206, 0.2);
  color: var(--accent-blue);
  padding: 4px 10px;
  border-radius: var(--border-radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.vocab-study-btn:hover {
  background: var(--accent-blue-gradient);
  border-color: transparent;
  color: white;
  box-shadow: 0 4px 10px rgba(127, 137, 206, 0.2);
}

.vocab-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--text-muted);
  text-align: center;
  gap: 12px;
}

.vocab-empty-state i {
  font-size: 2.5rem;
  opacity: 0.5;
}

.vocab-empty-state p {
  font-size: 0.95rem;
}

/* Responsiveness for table columns */
@media (max-width: 600px) {
  .col-hide-mobile {
    display: none;
  }
  .vocab-table th,
  .vocab-table td {
    padding: 8px 6px;
    font-size: 0.85rem;
  }
  .arabic-vocab-cell {
    font-size: 1.4rem;
  }
  .vocab-modal-card {
    padding: 16px;
    height: 90vh;
  }
}

/* ==========================================================================
   Exam Mode CSS
   ========================================================================== */

/* Sidebar Button */
.btn-action.exam {
  background: rgba(127, 137, 206, 0.1);
  border-color: rgba(127, 137, 206, 0.25);
  color: #9AA3E0;
  width: 100%;
  margin-top: 10px;
}

.btn-action.exam:hover {
  background: var(--accent-blue-gradient);
  border-color: transparent;
  color: #ffffff;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(127, 137, 206, 0.35);
}

.light-theme .btn-action.exam {
  background: rgba(127, 137, 206, 0.05);
  border-color: rgba(127, 137, 206, 0.15);
  color: #5A64A8;
}

.light-theme .btn-action.exam:hover {
  background: var(--accent-blue-gradient);
  border-color: transparent;
  color: #ffffff;
}

/* Modal Overlay & Card */
.exam-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(10, 12, 28, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 1500;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

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

.exam-modal-card {
  width: 92%;
  max-width: 540px;
  background: var(--card-bg-front);
  border: 1px solid var(--card-border);
  box-shadow: var(--card-shadow);
  border-radius: var(--border-radius-lg);
  padding: 30px;
  position: relative;
  transform: scale(0.9);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: flex;
  flex-direction: column;
  gap: 22px;
  max-height: 90vh;
  overflow-y: auto;
}

.exam-modal-overlay.active .exam-modal-card {
  transform: scale(1);
}

.exam-modal-close {
  position: absolute;
  top: 18px;
  right: 18px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 1.2rem;
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-smooth);
  z-index: 10;
}

.exam-modal-close:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}

.light-theme .exam-modal-close:hover {
  background: rgba(32, 38, 77, 0.06);
}

/* Exam Views Common */
.exam-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 5px;
}

.exam-title i {
  color: #9AA3E0;
}

.exam-subtitle {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.4;
  margin-bottom: 5px;
}

/* Setup Form Styles */
.exam-setup-section {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.exam-setup-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.exam-setup-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
}

.exam-pills-container {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.exam-pill-btn {
  background: var(--btn-secondary-bg);
  border: 1px solid var(--btn-secondary-border);
  color: var(--text-secondary);
  padding: 12px;
  border-radius: var(--border-radius-sm);
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: 0.88rem;
  cursor: pointer;
  transition: var(--transition-smooth);
  text-align: center;
}

.exam-pill-btn:hover {
  background: var(--btn-secondary-hover);
  border-color: rgba(127, 137, 206, 0.3);
  color: var(--text-primary);
}

.exam-pill-btn.active {
  background: rgba(127, 137, 206, 0.15);
  border-color: #7F89CE;
  color: #9AA3E0;
  font-weight: 600;
  box-shadow: 0 0 12px rgba(127, 137, 206, 0.15);
}

.light-theme .exam-pill-btn.active {
  background: rgba(127, 137, 206, 0.08);
  border-color: #5A64A8;
  color: #5A64A8;
}

.btn-start-exam {
  background: var(--accent-blue-gradient);
  color: white;
  border: none;
  border-radius: var(--border-radius-sm);
  padding: 14px;
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: var(--transition-smooth);
  margin-top: 10px;
  box-shadow: 0 4px 14px rgba(127, 137, 206, 0.3);
}

.btn-start-exam:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(127, 137, 206, 0.45);
}

/* Active Exam Gameplay Styles */
.exam-header {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.exam-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

.exam-progress-text {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.btn-quit-exam {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  transition: var(--transition-smooth);
}

.btn-quit-exam:hover {
  color: var(--color-danger);
}

.exam-progress-bar-container {
  width: 100%;
  height: 6px;
  background: var(--btn-secondary-bg);
  border-radius: 3px;
  overflow: hidden;
}

.exam-progress-bar-fill {
  height: 100%;
  background: var(--accent-blue-gradient);
  width: 0%;
  border-radius: 3px;
  transition: width 0.3s ease;
}

.exam-question-arabic {
  font-family: var(--font-arabic);
  font-size: 3.2rem;
  font-weight: 700;
  color: var(--text-primary);
  text-align: center;
  padding: 30px 10px;
  margin: 10px 0;
  direction: rtl;
  min-height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.exam-choices-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.exam-choice-btn {
  background: var(--btn-secondary-bg);
  border: 1px solid var(--btn-secondary-border);
  color: var(--text-primary);
  padding: 16px 20px;
  border-radius: var(--border-radius-sm);
  font-family: var(--font-sans);
  font-size: 0.92rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-smooth);
  text-align: left;
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
  line-height: 1.3;
}

.exam-choice-btn:hover:not(:disabled) {
  background: var(--btn-secondary-hover);
  border-color: rgba(127, 137, 206, 0.4);
  transform: translateY(-1px);
}

.exam-choice-badge {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.exam-choice-btn.correct-choice {
  background: rgba(16, 185, 129, 0.1) !important;
  border-color: var(--color-success) !important;
  color: #34d399 !important;
  font-weight: 600;
  box-shadow: 0 0 14px rgba(16, 185, 129, 0.2);
}

.exam-choice-btn.correct-choice .exam-choice-badge {
  background: var(--color-success) !important;
  color: white !important;
}

.exam-choice-btn.incorrect-choice {
  background: rgba(239, 68, 68, 0.1) !important;
  border-color: var(--color-danger) !important;
  color: #f87171 !important;
  font-weight: 600;
  box-shadow: 0 0 14px rgba(239, 68, 68, 0.2);
}

.exam-choice-btn.incorrect-choice .exam-choice-badge {
  background: var(--color-danger) !important;
  color: white !important;
}

.exam-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 15px;
  min-height: 46px;
}

.btn-next-question {
  background: var(--btn-secondary-bg);
  border: 1px solid var(--btn-secondary-border);
  color: var(--text-primary);
  padding: 10px 24px;
  border-radius: var(--border-radius-sm);
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: var(--transition-smooth);
}

.btn-next-question:hover:not(:disabled) {
  background: var(--accent-blue-gradient);
  border-color: transparent;
  color: white;
  transform: translateY(-1px);
}

/* Results View Styles */
.exam-results-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  text-align: center;
}

.exam-results-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.exam-circular-score {
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(127, 137, 206, 0.1) 0%, rgba(127, 137, 206, 0.02) 100%);
  border: 4px solid rgba(127, 137, 206, 0.2);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 20px rgba(127, 137, 206, 0.1);
}

.exam-score-number {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.1;
}

.exam-score-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.exam-badge-tag {
  background: rgba(255, 174, 82, 0.1);
  border: 1px solid rgba(255, 174, 82, 0.25);
  color: var(--accent-gold);
  padding: 8px 16px;
  border-radius: 30px;
  font-size: 0.85rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 0 10px rgba(255, 174, 82, 0.05);
}

/* Missed list review section */
.exam-review-section {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
}

.exam-review-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
}

.exam-missed-list {
  max-height: 200px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-right: 4px;
}

.exam-missed-item {
  background: var(--btn-secondary-bg);
  border: 1px solid var(--btn-secondary-border);
  border-radius: var(--border-radius-sm);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.exam-missed-left {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.exam-missed-arabic {
  font-family: var(--font-arabic);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.exam-missed-translit {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.exam-missed-right {
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: right;
}

.exam-missed-meanings {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.exam-correct-meaning {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--color-success);
}

.exam-wrong-meaning {
  font-size: 0.78rem;
  color: var(--color-danger);
  text-decoration: line-through;
  opacity: 0.8;
}

.exam-star-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1rem;
  cursor: pointer;
  padding: 6px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-smooth);
}

.exam-star-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--accent-gold);
}

.exam-star-btn.starred {
  color: var(--accent-gold);
}

.exam-results-actions {
  display: flex;
  gap: 10px;
  width: 100%;
  margin-top: 5px;
}

.btn-results-retry,
.btn-results-exit {
  flex: 1;
  padding: 12px;
  border-radius: var(--border-radius-sm);
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: var(--transition-smooth);
  border: 1px solid transparent;
}

.btn-results-retry {
  background: var(--accent-blue-gradient);
  color: white;
  box-shadow: 0 4px 10px rgba(127, 137, 206, 0.2);
}

.btn-results-retry:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(127, 137, 206, 0.35);
}

.btn-results-exit {
  background: var(--btn-secondary-bg);
  border-color: var(--btn-secondary-border);
  color: var(--text-secondary);
}

.btn-results-exit:hover {
  background: var(--btn-secondary-hover);
  color: var(--text-primary);
  transform: translateY(-1px);
}

/* Light Theme Styling Tweaks */
.light-theme .exam-circular-score {
  background: radial-gradient(circle, rgba(127, 137, 206, 0.05) 0%, rgba(127, 137, 206, 0.01) 100%);
  border-color: rgba(127, 137, 206, 0.12);
}

.light-theme .exam-choice-badge {
  background: rgba(32, 38, 77, 0.06);
}

/* Responsive tweaks for MCQ */
@media (max-width: 600px) {
  .exam-modal-card {
    padding: 20px;
    gap: 16px;
    height: 95vh;
  }
  .exam-question-arabic {
    font-size: 2.6rem;
    padding: 16px 5px;
    min-height: 80px;
  }
  .exam-choices-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .exam-choice-btn {
    padding: 12px 16px;
    font-size: 0.88rem;
  }
  .exam-results-actions {
    flex-direction: column;
  }
}

/* --- Help & Shortcuts Modal Overlay --- */
.help-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(10, 12, 28, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 1500;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

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

.help-modal-card {
  width: 90%;
  max-width: 480px;
  background: var(--card-bg-front);
  border: 1px solid var(--card-border);
  box-shadow: var(--card-shadow);
  border-radius: var(--border-radius-lg);
  padding: 32px;
  position: relative;
  transform: scale(0.9);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.help-modal-overlay.active .help-modal-card {
  transform: scale(1);
}

.help-modal-close {
  position: absolute;
  top: 20px;
  right: 20px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.help-modal-close:hover {
  color: var(--text-primary);
  transform: rotate(90deg);
}

.help-modal-header {
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--panel-border);
  padding-bottom: 15px;
}

.help-modal-header h3 {
  font-size: 1.25rem;
  color: var(--text-primary);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.help-modal-body {
  max-height: 60vh;
  overflow-y: auto;
  padding-right: 5px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.help-modal-body::-webkit-scrollbar {
  width: 6px;
}
.help-modal-body::-webkit-scrollbar-track {
  background: transparent;
}
.help-modal-body::-webkit-scrollbar-thumb {
  background: var(--panel-border);
  border-radius: 3px;
}

.help-section h4 {
  font-size: 1.05rem;
  color: var(--primary-color);
  margin-top: 0;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.help-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.help-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.02);
  border-radius: var(--border-radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.light-theme .help-row {
  background: rgba(0, 0, 0, 0.01);
  border: 1px solid rgba(0, 0, 0, 0.03);
}

.help-key kbd {
  background: var(--btn-secondary-bg);
  color: var(--text-primary);
  border: 1px solid var(--btn-secondary-border);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.85rem;
}

.help-gesture {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  color: var(--text-secondary);
}

.help-desc {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

