/* ═══════════════════════════════════════════════════════════
   مراجع — Clean Light Theme Design System (RTL Arabic)
   ═══════════════════════════════════════════════════════════ */

/* ─── Reset & Base ──────────────────────────────────────── */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Core palette — soft light */
    --bg-primary: #f8f9fc;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --bg-card-hover: #fafbff;
    --bg-glass: rgba(255, 255, 255, 0.7);
    --bg-muted: #f1f3f9;

    /* Accent — refined indigo/violet */
    --accent-1: #6366f1;
    --accent-2: #818cf8;
    --accent-3: #4f46e5;
    --gradient-primary: linear-gradient(135deg, #6366f1, #8b5cf6);
    --gradient-soft: linear-gradient(135deg, #f0f0ff, #e8e0ff);
    --gradient-text: linear-gradient(135deg, #4f46e5, #7c3aed);

    /* Text */
    --text-primary: #1e1e2e;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --text-accent: #6366f1;

    /* Borders */
    --border-subtle: #e2e8f0;
    --border-accent: rgba(99, 102, 241, 0.25);

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04);
    --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.08);
    --shadow-btn: 0 4px 14px rgba(99, 102, 241, 0.25);

    /* Sizing */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    /* Transitions */
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --transition-fast: 0.2s var(--ease-out);
    --transition-normal: 0.35s var(--ease-out);
}

/* ─── Dark Mode ─────────────────────────────────────────── */
[data-theme="dark"] {
    --bg-primary: #0f1117;
    --bg-secondary: #1a1b23;
    --bg-card: #1a1b23;
    --bg-card-hover: #22232d;
    --bg-glass: rgba(26, 27, 35, 0.8);
    --bg-muted: #22232d;

    --text-primary: #e8e8ef;
    --text-secondary: #9ca3b4;
    --text-muted: #5f6577;
    --text-accent: #818cf8;

    --border-subtle: #2d2e3a;
    --border-accent: rgba(129, 140, 248, 0.25);

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.2);
    --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.4);
    --shadow-btn: 0 4px 14px rgba(99, 102, 241, 0.3);

    --gradient-soft: linear-gradient(135deg, #1e1f2e, #252636);
}

[data-theme="dark"] .bg-particles::before {
    background: radial-gradient(circle, rgba(99, 102, 241, 0.1) 0%, transparent 70%);
}

[data-theme="dark"] .bg-particles::after {
    background: radial-gradient(circle, rgba(139, 92, 246, 0.08) 0%, transparent 70%);
}

[data-theme="dark"] .upload-zone {
    background: var(--bg-muted);
    border-color: var(--border-accent);
}

[data-theme="dark"] .upload-zone:hover,
[data-theme="dark"] .upload-zone.dragover {
    background: #252636;
    border-color: var(--accent-2);
}

[data-theme="dark"] .file-info {
    background: #252636;
}

[data-theme="dark"] .question-answer {
    background: #1a2e1a;
    border-color: #2d4a2d;
}

[data-theme="dark"] .question-answer__label {
    color: #4ade80;
}

[data-theme="dark"] .error-msg {
    background: #2a1515;
    border-color: #4a2525;
    color: #f87171;
}

[data-theme="dark"] .question-options.answered .question-option.correct {
    border-color: #22c55e;
    background: #1a2e1a;
}

[data-theme="dark"] .question-options.answered .question-option.wrong {
    border-color: #ef4444;
    background: #2a1515;
}

[data-theme="dark"] .status--correct {
    background: #1a2e1a;
    color: #4ade80;
}

[data-theme="dark"] .status--wrong {
    background: #2a1515;
    color: #f87171;
}

[data-theme="dark"] .status--partial {
    background: #2a2515;
    color: #fbbf24;
}

[data-theme="dark"] .btn--check {
    background: #252636;
    border-color: var(--border-accent);
    color: var(--accent-2);
}

[data-theme="dark"] .btn--ghost {
    background: var(--bg-muted);
    border-color: var(--border-subtle);
    color: var(--text-secondary);
}

[data-theme="dark"] .answer-input,
[data-theme="dark"] .text-preview {
    background: var(--bg-muted);
    border-color: var(--border-subtle);
    color: var(--text-primary);
}

[data-theme="dark"] .answer-input:focus {
    background: var(--bg-secondary);
    border-color: var(--accent-2);
}

[data-theme="dark"] .answer-input::placeholder {
    color: var(--text-muted);
}

[data-theme="dark"] .checkbox-card__content,
[data-theme="dark"] .upload-zone__formats {
    background: var(--bg-muted);
}

[data-theme="dark"] .slider::-webkit-slider-runnable-track {
    background: var(--bg-muted);
}

[data-theme="dark"] .btn--ghost:hover {
    background: #252636;
    border-color: var(--border-accent);
}

[data-theme="dark"] .btn--icon {
    background: var(--bg-muted);
    border-color: var(--border-subtle);
    color: var(--text-secondary);
}

[data-theme="dark"] .btn--icon svg {
    stroke: #9ca3b4;
}

[data-theme="dark"] .btn--icon:hover svg {
    stroke: var(--accent-2);
}

[data-theme="dark"] .modal-overlay {
    background: rgba(0, 0, 0, 0.6);
}

/* ─── Theme Toggle Button ───────────────────────────────── */
.theme-toggle {
    position: fixed;
    top: 1.2rem;
    left: 1.2rem;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid var(--border-subtle);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    z-index: 20;
}

.theme-toggle:hover {
    border-color: var(--border-accent);
    color: var(--accent-1);
    background: var(--bg-muted);
    transform: rotate(15deg);
}

.theme-toggle__moon {
    display: none;
}

[data-theme="dark"] .theme-toggle__sun {
    display: none;
}

[data-theme="dark"] .theme-toggle__moon {
    display: block;
}

/* smooth transition for theme change */
body,
.card,
.upload-zone,
.question-item,
.question-option,
.btn,
.modal,
.toast,
.header,
.steps-indicator,
.type-counter,
.lang-toggle,
.lang-btn,
.text-preview,
.file-info,
.answer-input,
.match-result,
.question-answer,
.error-msg,
.loading-facts {
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Tajawal', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    direction: rtl;
    overflow-x: hidden;
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
}

/* ─── Background ────────────────────────────────────────── */
.bg-particles {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.bg-particles::before {
    content: '';
    position: absolute;
    top: -20%;
    right: -15%;
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.06) 0%, transparent 70%);
    border-radius: 50%;
    animation: floatBlob 20s ease-in-out infinite;
}

.bg-particles::after {
    content: '';
    position: absolute;
    bottom: -15%;
    left: -10%;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(139, 92, 246, 0.05) 0%, transparent 70%);
    border-radius: 50%;
    animation: floatBlob 25s ease-in-out infinite reverse;
}

@keyframes floatBlob {

    0%,
    100% {
        transform: translate(0, 0) scale(1);
    }

    33% {
        transform: translate(20px, -30px) scale(1.03);
    }

    66% {
        transform: translate(-15px, 20px) scale(0.97);
    }
}

.bg-shape {
    position: absolute;
    color: rgba(99, 102, 241, 0.28);
    animation: floatShape linear infinite;
    pointer-events: none;
    z-index: 0;
}

.bg-shape:nth-child(odd) {
    color: rgba(139, 92, 246, 0.24);
}

.bg-shape:nth-child(3n) {
    color: rgba(59, 130, 246, 0.22);
}

.bg-shape svg {
    width: 100%;
    height: 100%;
}

.bg-code {
    position: absolute;
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    color: rgba(99, 102, 241, 0.25);
    font-weight: 800;
    letter-spacing: 0.5px;
    white-space: nowrap;
    animation: floatCode linear infinite;
    pointer-events: none;
    z-index: 0;
    direction: ltr;
}

.bg-code:nth-child(even) {
    color: rgba(139, 92, 246, 0.22);
}

.bg-code:nth-child(3n+1) {
    color: rgba(79, 70, 229, 0.24);
}

@keyframes floatShape {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 0;
    }

    10% {
        opacity: 1;
    }

    90% {
        opacity: 1;
    }

    100% {
        transform: translateY(-120px) rotate(180deg);
        opacity: 0;
    }
}

@keyframes floatCode {
    0% {
        transform: translateY(0) translateX(0);
        opacity: 0;
    }

    10% {
        opacity: 1;
    }

    90% {
        opacity: 1;
    }

    100% {
        transform: translateY(-80px) translateX(30px);
        opacity: 0;
    }
}

.particle {
    display: none;
}

.header {
    position: relative;
    z-index: 10;
    text-align: center;
    padding: 2.5rem 1.5rem 0.5rem;
}

.header__logo {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.5rem;
}

.header__icon {
    font-size: 1.5rem;
    display: none;
}

.header__title {
    font-size: 2rem;
    font-weight: 900;
    background: var(--gradient-text);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.5px;
}

.header__tagline {
    font-size: 0.95rem;
    color: var(--text-secondary);
    font-weight: 400;
}

/* ─── Header Top Row ────────────────────────────────────── */
.header__top-row {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.5rem;
}

/* ─── User Info Bar ─────────────────────────────────────── */
.user-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.user-info__avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border-subtle);
}

.user-info__name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-info__signout {
    background: none;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: 4px 10px;
    cursor: pointer;
    color: var(--text-muted);
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 4px;
    font-family: 'Tajawal', sans-serif;
    font-size: 0.78rem;
    font-weight: 600;
}

.user-info__signout:hover {
    color: #ef4444;
    border-color: #ef4444;
    background: rgba(239, 68, 68, 0.06);
}

/* Login Button (header) */
.user-info__login {
    background: none;
    border: 1px solid var(--accent-2);
    border-radius: var(--radius-sm);
    padding: 4px 12px;
    cursor: pointer;
    color: var(--accent-2);
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 5px;
    font-family: 'Tajawal', sans-serif;
    font-size: 0.78rem;
    font-weight: 600;
}

.user-info__login:hover {
    background: var(--accent-1);
    color: #fff;
    border-color: var(--accent-1);
}

/* ─── Auth Screen ───────────────────────────────────────── */
.card--auth {
    max-width: 420px;
    margin: 0 auto;
    padding: 2.5rem 2rem;
    text-align: center;
}

.auth-header {
    margin-bottom: 2rem;
}

.auth-header__title {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 0.4rem;
}

.auth-header__desc {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* Google Sign-In Button */
.btn-google {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.7rem;
    padding: 0.75rem 1.5rem;
    background: var(--bg-card);
    border: 1.5px solid var(--border-subtle);
    border-radius: var(--radius-md);
    font-family: 'Tajawal', sans-serif;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-google:hover {
    border-color: var(--accent-2);
    box-shadow: var(--shadow-card);
    transform: translateY(-1px);
}

.btn-google:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Divider */
.auth-divider {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin: 1.5rem 0;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-subtle);
}

/* Auth Form */
.auth-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    text-align: right;
}

.auth-form__group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.3rem;
}

.auth-form__group input {
    width: 100%;
    padding: 0.7rem 1rem;
    background: var(--bg-muted);
    border: 1.5px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    font-family: 'Tajawal', sans-serif;
    font-size: 0.95rem;
    color: var(--text-primary);
    transition: all var(--transition-fast);
    outline: none;
}

.auth-form__group input:focus {
    border-color: var(--accent-1);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.auth-form__group input::placeholder {
    color: var(--text-muted);
}

/* Password Toggle */
.password-wrapper {
    position: relative;
}

.password-wrapper input {
    padding-left: 40px;
}

.password-toggle {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: 4px;
    display: flex;
    align-items: center;
    transition: color var(--transition-fast);
}

.password-toggle:hover {
    color: var(--text-primary);
}

/* Password Strength Meter */
.password-strength {
    margin-top: 0.6rem;
    text-align: right;
}

.strength-bar {
    height: 5px;
    background: var(--bg-muted);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 0.4rem;
}

.strength-bar__fill {
    height: 100%;
    width: 0%;
    border-radius: 3px;
    transition: width 0.3s ease, background 0.3s ease;
}

.strength-bar__fill[data-level="1"] { width: 20%; background: #ef4444; }
.strength-bar__fill[data-level="2"] { width: 40%; background: #f97316; }
.strength-bar__fill[data-level="3"] { width: 60%; background: #eab308; }
.strength-bar__fill[data-level="4"] { width: 80%; background: #84cc16; }
.strength-bar__fill[data-level="5"] { width: 100%; background: #22c55e; }

.strength-label {
    font-size: 0.78rem;
    font-weight: 600;
}

.strength-label[data-level="1"] { color: #ef4444; }
.strength-label[data-level="2"] { color: #f97316; }
.strength-label[data-level="3"] { color: #eab308; }
.strength-label[data-level="4"] { color: #84cc16; }
.strength-label[data-level="5"] { color: #22c55e; }

.strength-checks {
    list-style: none;
    margin-top: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.strength-checks li {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.4rem;
    justify-content: flex-end;
}

.strength-checks li::after {
    content: '✗';
    color: #ef4444;
    font-weight: 700;
    font-size: 0.8rem;
    order: -1;
}

.strength-checks li.pass {
    color: #22c55e;
}

.strength-checks li.pass::after {
    content: '✓';
    color: #22c55e;
}

.auth-form__submit {
    margin-top: 0.5rem;
    width: 100%;
    padding: 0.8rem;
    font-size: 1rem;
    font-weight: 700;
}

/* Auth Toggle */
.auth-toggle {
    margin-top: 1.2rem;
    font-size: 0.88rem;
    color: var(--text-secondary);
}

.auth-toggle a {
    color: var(--accent-1);
    text-decoration: none;
    font-weight: 700;
    transition: color var(--transition-fast);
}

.auth-toggle a:hover {
    color: var(--accent-3);
}

/* ─── Steps Indicator ───────────────────────────────────── */
.steps-indicator {
    position: relative;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem 1rem;
    gap: 0;
    max-width: 480px;
    margin: 0 auto;
}

.step-dot {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    position: relative;
    cursor: default;
}

.step-dot__number {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.82rem;
    font-weight: 700;
    background: var(--bg-secondary);
    border: 2px solid var(--border-subtle);
    color: var(--text-muted);
    transition: all var(--transition-normal);
}

.step-dot.active .step-dot__number {
    background: var(--gradient-primary);
    border-color: transparent;
    color: #fff;
    box-shadow: 0 0 16px rgba(99, 102, 241, 0.3);
}

.step-dot.completed .step-dot__number {
    background: #22c55e;
    border-color: transparent;
    color: #fff;
}

.step-dot__label {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 500;
    transition: color var(--transition-fast);
    white-space: nowrap;
}

.step-dot.active .step-dot__label {
    color: var(--text-accent);
    font-weight: 600;
}

.step-dot.completed .step-dot__label {
    color: #22c55e;
}

.step-line {
    flex: 1;
    height: 2px;
    background: var(--border-subtle);
    margin: 0 0.5rem;
    margin-bottom: 1.5rem;
    transition: background var(--transition-normal);
    max-width: 80px;
}

.step-line.active {
    background: var(--gradient-primary);
}

/* ─── Screens ───────────────────────────────────────────── */
main {
    position: relative;
    z-index: 10;
    max-width: 680px;
    margin: 0 auto;
    padding: 0.5rem 1.25rem 3rem;
}

.screen {
    display: none;
    animation: screenIn 0.4s var(--ease-out) both;
}

.screen.active {
    display: block;
}

@keyframes screenIn {
    0% {
        opacity: 0;
        transform: translateY(16px);
    }

    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ─── Cards ─────────────────────────────────────────────── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xl);
    padding: 2.5rem 2rem;
    box-shadow: var(--shadow-card);
    position: relative;
}

.card::before {
    display: none;
}

.card__title {
    font-size: 1.5rem;
    font-weight: 800;
    margin-bottom: 0.3rem;
    color: var(--text-primary);
    -webkit-text-fill-color: unset;
    background: none;
}

.card__subtitle {
    font-size: 0.92rem;
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

/* ─── Upload Zone ───────────────────────────────────────── */
.upload-zone {
    border: 2px dashed var(--border-accent);
    border-radius: var(--radius-lg);
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-normal);
    background: var(--bg-muted);
    position: relative;
}

.upload-zone:hover,
.upload-zone.dragover {
    border-color: var(--accent-1);
    background: #f0f0ff;
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(99, 102, 241, 0.1);
}

.upload-zone.dragover {
    border-style: solid;
}

.upload-zone__icon {
    color: var(--accent-1);
    margin-bottom: 1rem;
    transition: transform var(--transition-normal);
}

.upload-zone:hover .upload-zone__icon {
    transform: translateY(-4px);
}

.upload-zone__title {
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 0.4rem;
    color: var(--text-primary);
}

.upload-zone__desc {
    font-size: 0.88rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.upload-zone__formats {
    font-size: 0.78rem;
    color: var(--text-muted);
    padding: 0.3rem 0.9rem;
    background: rgba(99, 102, 241, 0.06);
    border-radius: 50px;
    display: inline-block;
}

/* ─── File Info ─────────────────────────────────────────── */
.file-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.2rem;
    background: #f0f0ff;
    border: 1px solid var(--border-accent);
    border-radius: var(--radius-md);
    margin-top: 1.5rem;
    animation: fadeUp 0.3s var(--ease-out);
}

.file-info__icon {
    font-size: 1.5rem;
    width: 40px;
    height: 40px;
    background: var(--gradient-soft);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
}

.file-info__details {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.file-info__name {
    font-weight: 600;
    font-size: 0.92rem;
    color: var(--text-primary);
}

.file-info__size {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.file-info__remove {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0.4rem;
    border-radius: 50%;
    transition: all var(--transition-fast);
}

.file-info__remove:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.08);
}

@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ─── Upload Progress ───────────────────────────────────── */
.upload-progress {
    margin-top: 1.5rem;
}

.upload-progress__bar {
    height: 4px;
    background: var(--bg-muted);
    border-radius: 10px;
    overflow: hidden;
}

.upload-progress__fill {
    height: 100%;
    width: 0%;
    background: var(--gradient-primary);
    border-radius: 10px;
    transition: width 0.5s var(--ease-out);
}

.upload-progress__text {
    font-size: 0.82rem;
    color: var(--text-secondary);
    text-align: center;
    margin-top: 0.5rem;
}

/* ─── Error Message ─────────────────────────────────────── */
.error-msg {
    margin-top: 1rem;
    padding: 0.8rem 1.2rem;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: var(--radius-md);
    color: #dc2626;
    font-size: 0.88rem;
    animation: fadeUp 0.3s var(--ease-out);
}

/* ─── Quota Warning Banner ──────────────────────────────── */
.quota-banner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    padding: 0.8rem 1.5rem;
    margin: 0 auto 1rem;
    max-width: 600px;
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: var(--radius-md);
    color: #92400e;
    font-size: 0.85rem;
    font-weight: 600;
    animation: fadeUp 0.4s var(--ease-out);
    text-align: center;
    position: relative;
    z-index: 10;
}

.quota-banner svg {
    flex-shrink: 0;
    color: #d97706;
}

[data-theme="dark"] .quota-banner {
    background: #2a2515;
    border-color: #4a3b15;
    color: #fbbf24;
}

[data-theme="dark"] .quota-banner svg {
    color: #fbbf24;
}

/* ─── Buttons ───────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.7rem 1.6rem;
    border: none;
    border-radius: var(--radius-md);
    font-family: 'Tajawal', sans-serif;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
}

.btn::after {
    display: none;
}

.btn:active {
    transform: scale(0.97);
}

.btn--primary {
    background: var(--gradient-primary);
    color: #fff;
    box-shadow: var(--shadow-btn);
}

.btn--primary:hover {
    box-shadow: 0 6px 24px rgba(99, 102, 241, 0.35);
    transform: translateY(-1px);
}

.btn--large {
    padding: 0.9rem 2.2rem;
    font-size: 1.05rem;
    border-radius: var(--radius-lg);
}

.btn--ghost {
    background: var(--bg-muted);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
}

.btn--ghost:hover {
    border-color: var(--border-accent);
    color: var(--text-primary);
    background: #f0f0ff;
}

.btn--icon {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: var(--radius-sm);
    background: var(--bg-muted);
    border: 1px solid var(--border-subtle);
    font-size: 1rem;
}

.btn--icon:hover {
    border-color: var(--border-accent);
    background: #f0f0ff;
}

.btn__arrow {
    font-size: 1.1rem;
    transition: transform var(--transition-fast);
}

.btn:hover .btn__arrow {
    transform: translateX(-3px);
}

.btn__sparkle {
    display: none;
}

.btn--primary.btn--large {
    margin-top: 1.5rem;
    width: 100%;
}

/* ─── Form Elements ─────────────────────────────────────── */
.form-group {
    margin-bottom: 1.8rem;
}

.form-label {
    display: block;
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.7rem;
}

.slider-group {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.slider {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    background: var(--bg-muted);
    border-radius: 10px;
    outline: none;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--gradient-primary);
    cursor: pointer;
    box-shadow: 0 0 10px rgba(99, 102, 241, 0.3);
    transition: transform var(--transition-fast);
}

.slider::-webkit-slider-thumb:hover {
    transform: scale(1.15);
}

.slider::-moz-range-thumb {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--gradient-primary);
    cursor: pointer;
    border: none;
    box-shadow: 0 0 10px rgba(99, 102, 241, 0.3);
}

.slider-value {
    font-size: 1.5rem;
    font-weight: 900;
    color: var(--accent-3);
    min-width: 2.5rem;
    text-align: center;
}

/* ─── Checkbox Cards ────────────────────────────────────── */
.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 0.7rem;
}

.checkbox-card {
    position: relative;
    cursor: pointer;
    display: block;
}

.checkbox-card input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.checkbox-card__content {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 0.25rem;
    padding: 1.1rem 0.7rem;
    background: var(--bg-muted);
    border: 1.5px solid var(--border-subtle);
    border-radius: var(--radius-md);
    transition: all var(--transition-normal);
}

.checkbox-card:hover .checkbox-card__content {
    border-color: var(--border-accent);
    background: #f5f3ff;
}

.checkbox-card input:checked~.checkbox-card__content {
    border-color: var(--accent-1);
    background: #f0f0ff;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.08);
}

.checkbox-card__icon {
    font-size: 1.4rem;
    margin-bottom: 0.15rem;
}

.checkbox-card__title {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-primary);
}

.checkbox-card__desc {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.checkbox-card__check {
    position: absolute;
    top: 6px;
    left: 6px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--gradient-primary);
    color: #fff;
    font-size: 0.7rem;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: scale(0.5);
    transition: all var(--transition-fast);
}

.checkbox-card input:checked~.checkbox-card__check {
    opacity: 1;
    transform: scale(1);
}

/* ─── Text Preview ──────────────────────────────────────── */
.text-preview {
    max-height: 120px;
    overflow-y: auto;
    padding: 0.9rem 1.1rem;
    background: var(--bg-muted);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.8;
    white-space: pre-wrap;
    word-break: break-word;
}

.text-preview::-webkit-scrollbar {
    width: 4px;
}

.text-preview::-webkit-scrollbar-thumb {
    background: var(--accent-2);
    border-radius: 4px;
}

/* ─── Button Row ────────────────────────────────────────── */
.btn-row {
    display: flex;
    gap: 0.7rem;
    align-items: center;
    margin-top: 1.5rem;
}

.btn-row .btn--primary.btn--large {
    flex: 1;
    margin-top: 0;
}

/* ─── Loading Screen ────────────────────────────────────── */
.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
    text-align: center;
}

.loading-orb {
    position: relative;
    width: 100px;
    height: 100px;
    margin-bottom: 2rem;
}

.loading-orb__ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2px solid transparent;
}

.loading-orb__ring:nth-child(1) {
    border-top-color: var(--accent-1);
    animation: orbSpin 1.5s linear infinite;
}

.loading-orb__ring:nth-child(2) {
    inset: 10px;
    border-right-color: var(--accent-2);
    animation: orbSpin 2s linear infinite reverse;
}

.loading-orb__ring:nth-child(3) {
    inset: 20px;
    border-bottom-color: var(--accent-3);
    animation: orbSpin 2.5s linear infinite;
}

.loading-orb__core {
    position: absolute;
    inset: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    animation: pulse 2s ease-in-out infinite;
    color: var(--accent-1);
}

@keyframes orbSpin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
        opacity: 0.6;
    }

    50% {
        transform: scale(1.15);
        opacity: 1;
    }
}

.loading__title {
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 0.4rem;
}

.loading__desc {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.loading-facts {
    margin-top: 2rem;
    padding: 0.9rem 1.3rem;
    background: var(--bg-muted);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    max-width: 380px;
}

.loading-fact {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.6;
    transition: opacity 0.3s ease;
}

/* ─── Results Screen ────────────────────────────────────── */
.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.results-actions {
    display: flex;
    gap: 0.4rem;
    align-items: center;
}

.questions-list {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

/* ─── Question Item ─────────────────────────────────────── */
.question-item {
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 1.4rem;
    transition: all var(--transition-normal);
    animation: fadeUp 0.4s var(--ease-out) both;
}

.question-item:hover {
    border-color: var(--border-accent);
    box-shadow: var(--shadow-sm);
}

.question-item__header {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.7rem;
}

.question-item__number {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--gradient-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    flex-shrink: 0;
}

.question-item__type {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--accent-3);
    background: #f0f0ff;
    padding: 0.15rem 0.6rem;
    border-radius: 50px;
}

.question-item__text {
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.8;
    margin-bottom: 0.7rem;
    color: var(--text-primary);
}

/* MCQ Options — Interactive */
.question-options {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-bottom: 0.4rem;
}

.question-option {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.65rem 1rem;
    background: var(--bg-muted);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-family: inherit;
    text-align: start;
    width: 100%;
    transition: all var(--transition-fast);
}

.question-option--clickable {
    cursor: pointer;
}

.question-option--clickable:hover {
    border-color: var(--border-accent);
    background: #f5f3ff;
    transform: translateX(-2px);
}

.question-option__radio {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid var(--border-subtle);
    flex-shrink: 0;
    transition: all var(--transition-fast);
    position: relative;
}

.question-option--clickable:hover .question-option__radio {
    border-color: var(--accent-2);
}

/* Answered states */
.question-options.answered .question-option--clickable {
    cursor: default;
    opacity: 0.5;
}

.question-options.answered .question-option--clickable:hover {
    transform: none;
    border-color: var(--border-subtle);
    background: var(--bg-muted);
}

.question-options.answered .question-option.correct {
    opacity: 1;
    border-color: #22c55e;
    background: #f0fdf4;
    color: var(--text-primary);
}

.question-options.answered .question-option.correct .question-option__radio {
    border-color: #22c55e;
    background: #22c55e;
}

.question-options.answered .question-option.correct .question-option__radio::after {
    content: '✓';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    color: #fff;
    font-weight: 700;
}

.question-options.answered .question-option.wrong {
    opacity: 1;
    border-color: #ef4444;
    background: #fef2f2;
    color: #b91c1c;
}

.question-options.answered .question-option.wrong .question-option__radio {
    border-color: #ef4444;
    background: #ef4444;
}

.question-options.answered .question-option.wrong .question-option__radio::after {
    content: '✕';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    color: #fff;
    font-weight: 700;
}

/* ─── Status Badge ──────────────────────────────────────── */
.question-item__status {
    margin-right: auto;
    font-size: 0.78rem;
    font-weight: 700;
    padding: 0.15rem 0.55rem;
    border-radius: 50px;
    animation: fadeUp 0.3s var(--ease-out);
}

.status--correct {
    color: #16a34a;
    background: #f0fdf4;
}

.status--wrong {
    color: #dc2626;
    background: #fef2f2;
}

.status--partial {
    color: #d97706;
    background: #fffbeb;
}

/* ─── Answer Input ──────────────────────────────────────── */
.answer-input-group {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin-bottom: 0.4rem;
}

.answer-input {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--bg-muted);
    border: 1.5px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: 'Tajawal', sans-serif;
    font-size: 0.92rem;
    line-height: 1.7;
    transition: all var(--transition-fast);
    direction: inherit;
    resize: vertical;
}

.answer-input:focus {
    outline: none;
    border-color: var(--accent-1);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.08);
}

.answer-input:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.answer-input::placeholder {
    color: var(--text-muted);
}

.answer-input--long {
    min-height: 90px;
}

/* ─── Check Answer Button ───────────────────────────────── */
.btn--check {
    align-self: flex-start;
    padding: 0.5rem 1.1rem;
    background: #f0f0ff;
    border: 1px solid var(--border-accent);
    border-radius: var(--radius-sm);
    color: var(--accent-3);
    font-family: 'Tajawal', sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn--check:hover {
    background: #e8e0ff;
    border-color: var(--accent-1);
    transform: translateY(-1px);
}

.btn--check:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* ─── Match Result ──────────────────────────────────────── */
.match-result {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    padding: 1rem 1.2rem;
    background: var(--bg-muted);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    animation: fadeUp 0.3s var(--ease-out);
    margin-top: 0.5rem;
}

.match-result__top {
    display: flex;
    align-items: center;
    justify-content: center;
}

.match-bar {
    width: 100%;
    height: 8px;
    background: var(--border-subtle);
    border-radius: 10px;
    overflow: hidden;
}

.match-bar__fill {
    height: 100%;
    width: 0%;
    border-radius: 10px;
    transition: width 0.8s var(--ease-out), background 0.3s ease;
}

.match--excellent {
    background: linear-gradient(90deg, #22c55e, #4ade80);
}

.match--good {
    background: linear-gradient(90deg, #f59e0b, #fbbf24);
}

.match--poor {
    background: linear-gradient(90deg, #ef4444, #f87171);
}

.match-percentage {
    font-size: 1.6rem;
    font-weight: 900;
    color: var(--text-primary);
}

.match-label {
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-secondary);
    line-height: 1.5;
    text-align: center;
    margin: 0;
}

/* Answer */
.question-answer {
    margin-top: 0.7rem;
    padding: 0.9rem 1.1rem;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: var(--radius-sm);
    display: none;
}

.question-answer.visible {
    display: block;
    animation: fadeUp 0.3s var(--ease-out);
}

.question-answer__label {
    font-size: 0.75rem;
    font-weight: 700;
    color: #16a34a;
    margin-bottom: 0.25rem;
    display: block;
}

.question-answer__text {
    font-size: 0.92rem;
    color: var(--text-primary);
    line-height: 1.8;
}

/* ─── Results Footer ────────────────────────────────────── */
.results-footer {
    display: flex;
    justify-content: center;
    margin-top: 1.5rem;
}

.results-footer .btn--primary.btn--large {
    width: auto;
    margin-top: 0;
}

/* ─── Toast ─────────────────────────────────────────────── */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(16px);
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 0.7rem 1.3rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.88rem;
    color: var(--text-primary);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    opacity: 0;
    transition: all 0.3s var(--ease-out);
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ─── Hidden utility ────────────────────────────────────── */
.hidden {
    display: none !important;
}

.privacy-note,
.results-note {
    margin: 1rem 0;
    color: var(--text-secondary);
    font-size: 0.86rem;
    line-height: 1.8;
}

.privacy-note a { color: var(--accent-3); }

.question-source {
    margin-top: 0.75rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.question-source summary { cursor: pointer; }

.question-source blockquote {
    margin: 0.5rem 0 0;
    padding-inline-start: 0.75rem;
    border-inline-start: 2px solid var(--border-subtle);
    white-space: pre-wrap;
}

.question-item__text,
.question-answer__text,
.question-option__text {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

:where(button, .upload-zone, summary, a):focus-visible {
    outline: 3px solid var(--accent-1);
    outline-offset: 4px;
}

button:disabled { cursor: not-allowed; }

.counter-btn:disabled { opacity: 0.4; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation: none !important;
        transition: none !important;
        scroll-behavior: auto !important;
    }
    .bg-particles { display: none; }
}

/* ─── Print Styles ──────────────────────────────────────── */
@media print {

    .header,
    .steps-indicator,
    .results-actions,
    .results-footer,
    .bg-particles,
    .toast {
        display: none !important;
    }

    .card {
        box-shadow: none;
        border: none;
        padding: 0;
    }

    .question-item {
        border: 1px solid #ddd;
        break-inside: avoid;
    }

    .question-answer {
        display: block !important;
    }
}

/* ─── Modal ─────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
    animation: fadeIn 0.2s ease;
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xl);
    padding: 2rem;
    width: 90%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
    animation: modalIn 0.3s var(--ease-out);
    text-align: center;
}

.modal__title {
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 0.3rem;
}

.modal__desc {
    font-size: 0.88rem;
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.modal__actions {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.modal__btn {
    flex-direction: column;
    padding: 1rem;
    width: 100%;
    text-align: center;
}

.modal__btn-desc {
    display: block;
    font-size: 0.72rem;
    font-weight: 400;
    color: var(--text-muted);
    margin-top: 0.2rem;
}

.btn--primary .modal__btn-desc {
    color: rgba(255, 255, 255, 0.7);
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(10px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* ─── Language Toggle ───────────────────────────────────── */
.lang-toggle {
    display: flex;
    gap: 0;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--bg-muted);
}

.lang-btn {
    flex: 1;
    padding: 0.6rem 1.2rem;
    border: none;
    background: transparent;
    font-family: 'Tajawal', sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.lang-btn.active {
    background: var(--gradient-primary);
    color: #fff;
}

.lang-btn:not(.active):hover {
    background: rgba(99, 102, 241, 0.06);
    color: var(--text-primary);
}

/* ─── Type Counters ─────────────────────────────────────── */
.type-counters {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.type-counter {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.8rem 1rem;
    background: var(--bg-muted);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.type-counter:hover {
    border-color: var(--border-accent);
}

.type-counter__info {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.type-counter__title {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-primary);
}

.type-counter__desc {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.type-counter__controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.counter-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid var(--border-subtle);
    background: var(--bg-secondary);
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    font-family: 'Tajawal', sans-serif;
    line-height: 1;
}

.counter-btn:hover {
    border-color: var(--accent-1);
    color: var(--accent-1);
    background: #f0f0ff;
}

.counter-btn:active {
    transform: scale(0.92);
}

.counter-value {
    font-size: 1.2rem;
    font-weight: 900;
    color: var(--accent-3);
    min-width: 1.8rem;
    text-align: center;
}

.type-counter__total {
    text-align: center;
    padding: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
    border-top: 1px solid var(--border-subtle);
    margin-top: 0.2rem;
}

.type-counter__total strong {
    color: var(--accent-3);
    font-size: 1rem;
}

/* ─── Responsive ────────────────────────────────────────── */
@media (max-width: 640px) {
    .header__title {
        font-size: 1.5rem;
    }

    .card {
        padding: 1.4rem 1.1rem;
        border-radius: var(--radius-lg);
    }

    .upload-zone {
        padding: 2rem 1rem;
    }

    .results-header {
        flex-direction: column;
        text-align: center;
    }

    .btn--large {
        padding: 0.8rem 1.4rem;
        font-size: 0.95rem;
    }
}
