/* ═══════════════════════════════════════════════════════════════
   CadetPro — Knowledge Modules Stylesheet
   Modern dark exam-engine theme with smooth transitions
   ═══════════════════════════════════════════════════════════════ */

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

:root {
    /* Core Palette */
    --bg-primary: #0b1120;
    --bg-secondary: #111827;
    --bg-card: #1a2332;
    --bg-elevated: #1e293b;
    --bg-hover: #243047;

    /* Text */
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    /* Accent Colors */
    --accent-blue: #3b82f6;
    --accent-blue-h: #60a5fa;
    --accent-green: #10b981;
    --accent-green-h: #34d399;
    --accent-red: #ef4444;
    --accent-red-h: #f87171;
    --accent-amber: #f59e0b;
    --accent-purple: #8b5cf6;

    /* Borders */
    --border: rgba(255, 255, 255, 0.06);
    --border-hover: rgba(255, 255, 255, 0.12);

    /* Misc */
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    --transition: 0.2s ease;

    /* Font */
    --font: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

/* ─── Loading Screen ───────────────────────────────────────── */
.loader-screen {
    position: fixed;
    inset: 0;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.4s, visibility 0.4s;
}

.loader-screen.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

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

.loader-icon {
    font-size: 3rem;
    margin-bottom: 16px;
    animation: pulse 1.5s ease-in-out infinite;
}

.loader-content h2 {
    font-size: 1.6rem;
    color: var(--accent-blue);
    margin-bottom: 8px;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.loader-content p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 20px;
}

.loader-bar {
    width: 200px;
    height: 4px;
    background: var(--bg-elevated);
    border-radius: 4px;
    overflow: hidden;
    margin: 0 auto;
}

.loader-bar-fill {
    height: 100%;
    width: 30%;
    background: linear-gradient(90deg, var(--accent-blue), var(--accent-purple));
    border-radius: 4px;
    animation: loading 1.2s ease-in-out infinite;
}

@keyframes loading {
    0% {
        transform: translateX(-100%);
    }

    100% {
        transform: translateX(400%);
    }
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.15);
    }
}

/* ─── Category Selection Grid ─── */
.category-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    margin: 15px 0;
    max-height: 400px;
    overflow-y: auto;
    padding-right: 5px;
}

.category-item {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-align: left;
}

.category-item:hover {
    background: var(--bg-hover);
    border-color: var(--accent-blue);
    transform: translateY(-2px);
}

.category-info {
    display: flex;
    flex-direction: column;
}

.cat-code {
    font-size: 0.75rem;
    color: var(--accent-blue);
    font-weight: 700;
}

.cat-title {
    font-size: 0.95rem;
    font-weight: 600;
}

.cat-count {
    font-size: 0.75rem;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.05);
    padding: 2px 8px;
    border-radius: 10px;
}

/* ─── Airlines Seçimi ─── */
.airlines-step-wrapper {
    width: 100%;
}

.airlines-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 24px 0 20px 0;
}

.airline-btn {
    width: 100%;
    padding: 16px 24px;
    font-size: 1rem;
    font-weight: 600;
    font-family: var(--font);
    color: var(--text-primary);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

.airline-btn:hover {
    background: var(--bg-hover);
    border-color: var(--accent-blue);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

/* ─── Exam Config Modal ─── */
.exam-config-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 20px;
}

.exam-config-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 28px;
    max-width: 420px;
    width: 100%;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

/* ─── Uyarı modal (ekran ortası) ─── */
.alert-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 20px;
    animation: alertOverlayIn 0.2s ease;
}

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

.alert-modal-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 28px 32px;
    max-width: 420px;
    width: 100%;
    border: 1px solid rgba(245, 158, 11, 0.4);
    box-shadow: 0 8px 48px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.05);
    animation: alertCardIn 0.25s ease;
}

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

.alert-modal-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--accent-amber);
    margin: 0 0 16px 0;
}

.alert-modal-message {
    font-size: 1rem;
    line-height: 1.55;
    color: var(--text-primary);
    margin: 0 0 24px 0;
}

.alert-modal-btn {
    width: 100%;
    justify-content: center;
}

.exam-config-title {
    font-size: 1.25rem;
    margin: 0 0 24px 0;
    color: var(--text-primary);
}

.exam-config-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.exam-config-row {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.exam-config-row label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.exam-config-row select {
    padding: 10px 14px;
    font-size: 1rem;
    font-family: var(--font);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
}

.config-subchapters {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 180px;
    overflow-y: auto;
}

.config-subchapters label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 400;
    cursor: pointer;
}

.config-subchapters input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent-blue);
}

.config-check-label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 400;
    cursor: pointer;
}

.config-check-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent-blue);
}

.config-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin: 4px 0 0 28px;
}

.exam-config-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 24px;
}

/* ─── Chapter / Bölüm Seçimi — Modern Professional Design ─── */
.chapter-step-wrapper {
    width: 100%;
}

.chapter-section-header {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 24px;
}

.section-header-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.15), rgba(139, 92, 246, 0.1));
    border: 1px solid rgba(59, 130, 246, 0.25);
    border-radius: var(--radius);
    font-size: 1.5rem;
    flex-shrink: 0;
}

.section-header-text {
    flex: 1;
    min-width: 0;
}

.section-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    margin: 0 0 4px 0;
}

.section-desc {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin: 0;
    line-height: 1.4;
}

.search-row-modern {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
}

.search-input-modern {
    flex: 1;
    min-width: 0;
    padding: 12px 18px;
    font-size: 0.95rem;
    font-family: var(--font);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.search-input-modern::placeholder {
    color: var(--text-muted);
}

.search-input-modern:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.btn-search-modern {
    flex-shrink: 0;
}

.search-results-modern {
    margin-bottom: 20px;
}

.search-results-modern .search-result-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    cursor: pointer;
    transition: all var(--transition);
}

.search-results-modern .search-result-card:hover {
    background: var(--bg-hover);
    border-color: var(--accent-blue);
    transform: translateX(4px);
}

.search-results-modern .search-result-card .result-meta {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

.chapter-divider {
    display: flex;
    align-items: center;
    gap: 16px;
    margin: 24px 0 16px 0;
}

.chapter-divider::before,
.chapter-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--border), transparent);
}

.divider-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.category-grid-modern {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    max-height: 380px;
    overflow-y: auto;
    padding-right: 8px;
    scrollbar-width: thin;
    scrollbar-color: var(--accent-blue) transparent;
}

.category-grid-modern::-webkit-scrollbar {
    width: 6px;
}

.category-grid-modern::-webkit-scrollbar-track {
    background: transparent;
}

.category-grid-modern::-webkit-scrollbar-thumb {
    background: var(--accent-blue);
    border-radius: 3px;
}

.category-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
}

.category-card:hover {
    background: var(--bg-hover);
    border-color: var(--accent-blue);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

.category-card .cat-icon {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.12), rgba(139, 92, 246, 0.08));
    border-radius: var(--radius-sm);
    font-size: 1.35rem;
    flex-shrink: 0;
}

.category-card .cat-title {
    flex: 1;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.category-card .cat-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.04);
    padding: 6px 12px;
    border-radius: 20px;
    flex-shrink: 0;
}

.exam-approved {
    display: inline-block;
    padding: 2px 8px;
    background: rgba(16, 185, 129, 0.15); /* light green background */
    color: var(--accent-green); /* emerald green */
    border: 1px solid rgba(16, 185, 129, 0.3);
    border-radius: 6px;
    font-weight: 700;
    font-size: 0.75rem;
    margin-left: 8px;
    vertical-align: middle;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ─── Leaderboard Filters ─── */
.lb-filters {
    display: flex;
    gap: 8px;
    margin-bottom: 15px;
    background: var(--bg-secondary);
    padding: 4px;
    border-radius: var(--radius);
}

.lb-filter-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.lb-filter-btn.active {
    background: var(--bg-card);
    color: var(--text-primary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.category-breadcrumb {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-left: 10px;
    padding-left: 10px;
    border-left: 1px solid var(--border);
}

/* ─── App Shell ────────────────────────────────────────────── */
.app {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 16px 32px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ─── Header ───────────────────────────────────────────────── */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 20px;
    position: sticky;
    top: 0;
    background: var(--bg-primary);
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand {
    font-size: 1.2rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.5px;
}

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

/* ─── Badges ───────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.3px;
}

.badge-blue {
    background: rgba(59, 130, 246, 0.15);
    color: var(--accent-blue-h);
}

.badge-muted {
    background: rgba(100, 116, 139, 0.15);
    color: var(--text-secondary);
    font-weight: 500;
}

/* ─── Engine Metadata Bar ─────────────────────────────────── */
.engine-meta {
    padding: 6px 16px;
    background: rgba(139, 92, 246, 0.08);
    border: 1px solid rgba(139, 92, 246, 0.15);
    border-radius: var(--radius-sm);
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--text-muted);
    letter-spacing: 0.3px;
    font-variant-numeric: tabular-nums;
    margin-bottom: 4px;
}

/* ─── Difficulty Selector ─────────────────────────────────── */
.difficulty-select {
    padding: 5px 10px;
    border-radius: 6px;
    border: 1px solid var(--border-hover);
    background: var(--bg-elevated);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}

.difficulty-select:hover {
    border-color: var(--accent-purple);
    background: var(--bg-hover);
}

.difficulty-select:focus {
    outline: none;
    border-color: var(--accent-purple);
    box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.2);
}

.difficulty-select option {
    background: var(--bg-card);
    color: var(--text-primary);
}

/* ─── Timer ────────────────────────────────────────────────── */
.timer {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: var(--bg-elevated);
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    border: 1px solid var(--border);
}

.timer-icon {
    font-size: 0.85rem;
}

/* ─── Buttons ──────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 22px;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    font-family: var(--font);
    font-size: 0.9rem;
    font-weight: 600;
    transition: all var(--transition);
    text-decoration: none;
    white-space: nowrap;
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: #fff;
    box-shadow: 0 2px 12px rgba(59, 130, 246, 0.3);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #60a5fa, #3b82f6);
    box-shadow: 0 4px 20px rgba(59, 130, 246, 0.4);
}

.btn-primary:disabled {
    background: var(--bg-elevated);
    color: var(--text-muted);
    box-shadow: none;
    cursor: not-allowed;
}

.btn-accent {
    background: linear-gradient(135deg, var(--accent-purple), #6d28d9);
    color: #fff;
    box-shadow: 0 2px 12px rgba(139, 92, 246, 0.3);
}

.btn-accent:hover {
    box-shadow: 0 4px 20px rgba(139, 92, 246, 0.4);
}

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

.btn-next:hover {
    background: var(--bg-hover);
}

.btn-ghost {
    background: transparent;
    color: var(--accent-blue-h);
    border: 1px solid rgba(96, 165, 250, 0.3);
}

.btn-ghost:hover {
    background: rgba(96, 165, 250, 0.1);
}

.btn-outline {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-hover);
}

.btn-outline:hover {
    background: var(--bg-elevated);
    color: var(--text-primary);
}

.btn-sm {
    padding: 6px 14px;
    font-size: 0.8rem;
}

/* ─── Main Content ─────────────────────────────────────────── */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* ─── Question Card ────────────────────────────────────────── */
.question-card {
    display: flex;
    flex-direction: column;
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 28px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    min-height: 560px;
}

.question-title {
    font-size: 0.8rem;
    color: var(--accent-blue-h);
    font-weight: 600;
}

.exam-approved {
    color: var(--accent-green);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 12px;
}

.question-text {
    font-size: 1.05rem;
    line-height: 1.7;
    color: var(--text-primary);
    margin-bottom: 24px;
    white-space: pre-line;
}

/* ─── Options ──────────────────────────────────────────────── */
.options {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 24px;
}

.option-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
    border: 2px solid transparent;
    cursor: pointer;
    transition: all var(--transition);
    font-size: 0.95rem;
    user-select: none;
}

.option-row:hover {
    background: var(--bg-hover);
    border-color: rgba(96, 165, 250, 0.2);
}

.option-row.selected {
    border-color: var(--accent-blue);
    background: rgba(59, 130, 246, 0.08);
}

.option-row.correct {
    border-color: var(--accent-green) !important;
    background: rgba(16, 185, 129, 0.1) !important;
}

.option-row.incorrect {
    border-color: var(--accent-red) !important;
    background: rgba(239, 68, 68, 0.08) !important;
}

.option-row.locked {
    cursor: default;
    pointer-events: none;
}

.option-row.dimmed {
    opacity: 0.5;
}

.option-letter {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.06);
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--text-secondary);
    flex-shrink: 0;
    transition: all var(--transition);
}

.option-row.selected .option-letter {
    background: var(--accent-blue);
    color: #fff;
}

.option-row.correct .option-letter {
    background: var(--accent-green);
    color: #fff;
}

.option-row.incorrect .option-letter {
    background: var(--accent-red);
    color: #fff;
}

.option-text {
    flex: 1;
}

.option-icon {
    font-size: 1.2rem;
    opacity: 0;
    transition: opacity var(--transition);
}

.option-row.correct .option-icon,
.option-row.incorrect .option-icon {
    opacity: 1;
}

/* ─── Action Row ───────────────────────────────────────────── */
.action-row {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: auto;
}

/* ─── Navigation Bar ───────────────────────────────────────── */
.nav-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    flex-wrap: wrap;
}

.progress-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 600;
    min-width: 60px;
}

.nav-buttons {
    display: flex;
    gap: 6px;
    flex: 1;
    flex-wrap: wrap;
}

.nav-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    border: 1px solid var(--border-hover);
    background: var(--bg-elevated);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.82rem;
    cursor: pointer;
    transition: all var(--transition);
    font-family: var(--font);
}

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

.nav-btn.active {
    background: var(--accent-blue);
    color: #fff;
    border-color: var(--accent-blue);
}

.nav-btn.answered {
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent-green);
    border-color: rgba(16, 185, 129, 0.3);
}

.nav-btn.wrong {
    background: rgba(239, 68, 68, 0.12);
    color: var(--accent-red);
    border-color: rgba(239, 68, 68, 0.3);
}

/* ─── Tab Panel ────────────────────────────────────────────── */
.tab-panel {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
}

.tab-header {
    display: flex;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
}

.tab-btn {
    flex: 1;
    padding: 12px 16px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-family: var(--font);
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    cursor: pointer;
    transition: all var(--transition);
    position: relative;
    white-space: nowrap;
}

.tab-btn::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 2px;
    background: var(--accent-blue);
    transition: width 0.3s ease;
}

.tab-btn:hover {
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.02);
}

.tab-btn.active {
    color: var(--accent-blue-h);
    background: rgba(59, 130, 246, 0.05);
}

.tab-btn.active::after {
    width: 60%;
}

.tab-body {
    padding: 20px;
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

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

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ─── Progress Grid ────────────────────────────────────────── */
.progress-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 10px;
}

.progress-item {
    padding: 12px 14px;
    background: var(--bg-elevated);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--text-muted);
    font-size: 0.85rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.progress-item.correct-item {
    border-left-color: var(--accent-green);
}

.progress-item.incorrect-item {
    border-left-color: var(--accent-red);
}

.progress-item .pi-label {
    color: var(--text-secondary);
}

.progress-item .pi-status {
    font-weight: 700;
    font-size: 0.8rem;
}

.pi-status.correct {
    color: var(--accent-green);
}

.pi-status.incorrect {
    color: var(--accent-red);
}

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

/* ─── Explanation ──────────────────────────────────────────── */
.explanation-content {
    font-size: 0.92rem;
    line-height: 1.7;
    white-space: pre-line;
    color: var(--text-secondary);
}

.explanation-content .correct-label {
    display: inline-block;
    padding: 4px 12px;
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent-green);
    border-radius: 6px;
    font-weight: 700;
    font-size: 0.85rem;
    margin-bottom: 12px;
}

.locked-msg {
    color: var(--text-muted);
    font-style: italic;
    text-align: center;
    padding: 20px 0;
}

/* ─── Notes ────────────────────────────────────────────────── */
.notes-textarea {
    width: 100%;
    min-height: 140px;
    padding: 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-hover);
    background: var(--bg-elevated);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.9rem;
    line-height: 1.6;
    resize: vertical;
    transition: border-color var(--transition);
}

.notes-textarea:focus {
    outline: none;
    border-color: var(--accent-blue);
}

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

.notes-status {
    margin-top: 8px;
    font-size: 0.8rem;
    color: var(--accent-green);
    height: 20px;
    transition: opacity 0.3s;
}

/* ─── Stats ────────────────────────────────────────────────── */
.stats-content {
    font-size: 0.9rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.stat-box {
    padding: 16px;
    background: var(--bg-elevated);
    border-radius: var(--radius-sm);
    text-align: center;
    border: 1px solid var(--border);
}

.stat-value {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--accent-blue-h);
    line-height: 1.2;
}

.stat-value.green {
    color: var(--accent-green);
}

.stat-value.amber {
    color: var(--accent-amber);
}

.stat-value.red {
    color: var(--accent-red);
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 4px;
}

.recent-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
    margin-top: 8px;
}

.recent-table th {
    text-align: left;
    padding: 8px 10px;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.72rem;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
}

.recent-table td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
}

.recent-table tr:last-child td {
    border-bottom: none;
}

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

/* ─── Footer ───────────────────────────────────────────────── */
.footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 0;
    margin-top: 24px;
    border-top: 1px solid var(--border);
    font-size: 0.8rem;
    color: var(--text-muted);
}

.footer-link {
    color: var(--text-muted);
    text-decoration: none;
    transition: color var(--transition);
}

.footer-link:hover {
    color: var(--accent-blue-h);
}

/* ─── Animations ───────────────────────────────────────────── */
@keyframes correctPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(16, 185, 129, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
    }
}

@keyframes incorrectShake {

    0%,
    100% {
        transform: translateX(0);
    }

    10%,
    50%,
    90% {
        transform: translateX(-3px);
    }

    30%,
    70% {
        transform: translateX(3px);
    }
}

.option-row.correct {
    animation: correctPulse 0.6s ease;
}

.option-row.incorrect {
    animation: incorrectShake 0.4s ease;
}

/* ─── Start Screen ─────────────────────────────────────────── */
.start-screen {
    position: fixed;
    inset: 0;
    background: linear-gradient(135deg, #0b1120 0%, #1a1040 50%, #0b1120 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    transition: opacity 0.4s ease, visibility 0.4s ease;
}

.start-screen.fade-out {
    opacity: 0;
    visibility: hidden;
}

.start-card {
    background: rgba(26, 35, 50, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(139, 92, 246, 0.2);
    border-radius: 20px;
    padding: 48px 40px;
    max-width: 420px;
    width: 90%;
    text-align: center;
    box-shadow: 0 8px 60px rgba(139, 92, 246, 0.15), 0 0 120px rgba(59, 130, 246, 0.05);
    animation: startCardIn 0.6s ease;
}

@keyframes startCardIn {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.no-questions-message {
    display: none;
    margin-bottom: 20px;
    padding: 14px 18px;
    background: rgba(245, 158, 11, 0.15);
    border: 1px solid rgba(245, 158, 11, 0.4);
    border-radius: var(--radius-sm);
    color: var(--accent-amber);
    font-size: 0.95rem;
    line-height: 1.5;
    text-align: center;
}

.start-logo {
    font-size: 4.2rem;
    margin-top: 12px;
    margin-bottom: 12px;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.08);
    }
}

.start-title {
    max-width: 280px;
    height: auto;
    margin: 0 auto 4px auto;
    display: block;
}

.start-subtitle {
    color: var(--text-muted);
    font-size: 0.88rem;
    margin-bottom: 32px;
}

.start-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
}

#nickname-step,
#pin-step {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.pin-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
}

.btn-link {
    background: none;
    border: none;
    color: var(--accent-cyan);
    font-size: 0.85rem;
    cursor: pointer;
    text-decoration: underline;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.btn-link:hover {
    opacity: 1;
}

.start-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-secondary);
    letter-spacing: 0.1rem;
}

.start-input {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 14px 16px;
    color: white;
    font-size: 1.1rem;
    width: 100%;
    outline: none;
    letter-spacing: 0;
    pointer-events: auto;
}

#pin-input {
    caret-color: white;
}

.search-row {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
    align-items: center;
}

.search-row .search-input {
    flex: 1;
    min-width: 0;
}

.search-results {
    margin-bottom: 16px;
}

.search-results .search-result-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition);
}

.search-results .search-result-card:hover {
    background: var(--bg-hover);
    border-color: var(--accent-blue);
}

.search-results .search-result-card .result-meta {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.search-results .search-no-results {
    color: var(--text-secondary);
    font-size: 0.9rem;
    padding: 12px 0;
}

.start-error {
    color: var(--accent-red);
    font-size: 0.82rem;
    font-weight: 600;
    min-height: 20px;
    display: none;
}

.start-btn {
    margin-top: 4px;
}

.btn-lg {
    padding: 14px 28px;
    font-size: 1rem;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    padding: 12px 24px;
    font-weight: 700;
    font-family: var(--font);
    cursor: pointer;
    transition: all var(--transition);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 20px rgba(59, 130, 246, 0.3);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.start-hint {
    margin-top: 20px;
    font-size: 0.72rem;
    color: var(--text-muted);
    letter-spacing: 0.3px;
}

/* ─── Welcome Bar ──────────────────────────────────────────── */
.welcome-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.08), rgba(139, 92, 246, 0.08));
    border: 1px solid rgba(59, 130, 246, 0.12);
    border-radius: var(--radius-sm);
    margin-bottom: 4px;
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.welcome-msg {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}

.btn-xs {
    padding: 4px 10px;
    font-size: 0.72rem;
}

/* ─── Rank Badge Bar (in Stats) ────────────────────────────── */
.rank-badge-bar {
    padding: 12px 16px;
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.1), rgba(139, 92, 246, 0.08));
    border: 1px solid rgba(245, 158, 11, 0.2);
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 0.9rem;
    color: var(--accent-amber);
    text-align: center;
}

/* ─── Topic Badges ─────────────────────────────────────────── */
.topic-badges {
    display: flex;
    gap: 10px;
    margin: 12px 0;
    flex-wrap: wrap;
}

.topic-badge {
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
}

.topic-badge.strong {
    background: rgba(16, 185, 129, 0.12);
    color: var(--accent-green);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.topic-badge.weak {
    background: rgba(239, 68, 68, 0.1);
    color: var(--accent-red-h);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

/* ─── Leaderboard ──────────────────────────────────────────── */
.global-stats-bar {
    display: flex;
    justify-content: space-around;
    padding: 14px;
    background: var(--bg-elevated);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    margin-bottom: 16px;
    font-size: 0.82rem;
    color: var(--text-secondary);
    flex-wrap: wrap;
    gap: 8px;
}

.global-stats-bar strong {
    color: var(--text-primary);
}

.my-rank-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.12), rgba(139, 92, 246, 0.1));
    border: 1px solid rgba(245, 158, 11, 0.25);
    border-radius: var(--radius);
    margin-bottom: 16px;
}

.my-rank-position {
    font-size: 1.8rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent-amber), var(--accent-purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    min-width: 60px;
    text-align: center;
}

.my-rank-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.my-rank-info strong {
    font-size: 1rem;
    color: var(--text-primary);
}

.my-rank-info span {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.lb-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}

.lb-table th {
    text-align: left;
    padding: 10px 10px;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--border);
}

.lb-table td {
    padding: 10px 10px;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
}

.lb-table tr:last-child td {
    border-bottom: none;
}

.lb-table tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

.lb-me td {
    background: rgba(59, 130, 246, 0.06) !important;
    color: var(--accent-blue-h) !important;
    font-weight: 600;
}

.lb-rank {
    font-weight: 800;
    font-size: 0.9rem;
    min-width: 36px;
}

.lb-nick {
    font-weight: 600;
    color: var(--text-primary) !important;
}

.lb-score {
    font-weight: 800;
    color: var(--accent-amber) !important;
    font-size: 0.92rem;
}

/* ─── Set Complete Overlay ─────────────────────────────────── */
.set-complete-overlay {
    position: fixed;
    inset: 0;
    background: rgba(11, 17, 32, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5000;
    animation: fadeIn 0.3s ease;
}

.set-complete-card {
    background: var(--bg-card);
    border: 1px solid rgba(139, 92, 246, 0.2);
    border-radius: 20px;
    padding: 40px 36px;
    max-width: 460px;
    width: 90%;
    text-align: center;
    box-shadow: 0 8px 60px rgba(0, 0, 0, 0.5);
    animation: startCardIn 0.4s ease;
}

.set-complete-icon {
    font-size: 3rem;
    margin-bottom: 12px;
}

.set-complete-card h2 {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 20px;
}

.set-complete-stats {
    display: flex;
    justify-content: space-around;
    gap: 12px;
    margin-bottom: 20px;
}

.scs-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.scs-value {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--accent-blue-h);
}

.scs-value.green {
    color: var(--accent-green);
}

.scs-value.amber {
    color: var(--accent-amber);
}

.scs-value.red {
    color: var(--accent-red);
}

.scs-label {
    font-size: 0.72rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.set-complete-rank {
    padding: 12px 16px;
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.2);
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    font-size: 0.9rem;
    color: var(--accent-amber);
}

/* ─── Responsive ───────────────────────────────────────────── */
@media (max-width: 600px) {
    .app {
        padding: 0 10px 20px;
    }

    .header {
        padding: 12px 0;
        flex-wrap: wrap;
        gap: 8px;
    }

    .header-left {
        flex-wrap: wrap;
    }

    .brand {
        font-size: 1rem;
    }

    .question-card {
        padding: 20px 16px;
    }

    .question-text {
        font-size: 0.95rem;
    }

    .option-row {
        padding: 12px 14px;
        font-size: 0.88rem;
    }

    .option-letter {
        width: 30px;
        height: 30px;
        font-size: 0.78rem;
    }

    .tab-btn {
        padding: 10px 10px;
        font-size: 0.72rem;
        letter-spacing: 0.3px;
    }

    .nav-bar {
        padding: 10px 14px;
    }

    .nav-btn {
        width: 32px;
        height: 32px;
        font-size: 0.75rem;
    }

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

    .action-row {
        flex-direction: column;
    }

    .action-row .btn {
        width: 100%;
    }

    .btn-sm {
        font-size: 0.75rem;
        padding: 5px 10px;
    }

    /* Start screen mobile */
    .start-card {
        padding: 32px 24px;
    }

    .start-title {
        max-width: 220px;
    }

    .start-input {
        font-size: 0.9rem;
        padding: 12px 14px;
    }

    /* Chapter selection mobile */
    .chapter-section-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 12px;
    }

    .category-card {
        padding: 14px 16px;
    }

    .category-card .cat-icon {
        width: 40px;
        height: 40px;
        font-size: 1.2rem;
    }

    .category-grid-modern {
        max-height: 320px;
    }

    /* Welcome bar mobile */
    .welcome-bar {
        flex-direction: column;
        gap: 6px;
        text-align: center;
    }

    /* Leaderboard mobile */
    .global-stats-bar {
        flex-direction: column;
        text-align: center;
        gap: 4px;
    }

    .my-rank-card {
        flex-direction: column;
        text-align: center;
    }

    .lb-table {
        font-size: 0.75rem;
    }

    .lb-table th,
    .lb-table td {
        padding: 8px 6px;
    }

    /* Set complete mobile */
    .set-complete-card {
        padding: 28px 20px;
    }

    .set-complete-stats {
        flex-direction: column;
        gap: 16px;
    }
}