:root {
    --bg-primary: #f8fafc;
    --bg-surface: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border-color: #cbd5e1;
    --brand-color: #ff5722; /* Adda247 Orange */
    --brand-dark: #e64a19;
    
    /* Exam Status Palette Colors */
    --status-answered: #2e7d32;
    --status-not-answered: #d32f2f;
    --status-marked: #0288d1;
    --status-not-visited: #78909c;
}

[data-theme="dark"] {
    --bg-primary: #0f172a;
    --bg-surface: #1e293b;
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --border-color: #334155;
}

body {
    margin: 0;
    font-family: 'Segoe UI', system-ui, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-main);
    transition: background 0.3s, color 0.3s;
}

/* Base Top Navbar Layout styling */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-surface);
    padding: 12px 24px;
    border-bottom: 1px solid var(--border-color);
}
.logo-area { font-size: 1.4rem; font-weight: 800; color: var(--brand-color); text-transform: uppercase; }

/* Global Grid Layout Configurations */
.main-wrapper {
    display: grid;
    grid-template-columns: 1fr;
    min-height: calc(100vh - 65px);
}
@media (min-width: 992px) {
    .main-wrapper { grid-template-columns: 3fr 1fr; }
}

.card {
    background: var(--bg-surface);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    padding: 20px;
    margin-bottom: 20px;
}

/* Global Shared Buttons */
.btn {
    padding: 10px 18px;
    border: none;
    border-radius: 5px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-brand { background: var(--brand-color); color: white; }
.btn-brand:hover { background: var(--brand-dark); }
.btn-secondary { background: var(--text-muted); color: white; }

/* Status Labels Mapping styles */
.badge { padding: 4px 8px; border-radius: 4px; font-size: 0.8rem; font-weight: bold; }
.bg-easy { background: #e8f5e9; color: #2e7d32; }
.bg-medium { background: #fff3e0; color: #ef6c00; }
.bg-hard { background: #ffebee; color: #c62828; }
/* ==========================================
   RANK KARUNADU ULTIMATE MOBILE TEST ENGINE STYLE
   ========================================== */
@media screen and (max-width: 768px) {
    
    /* 1. Stack the layout columns vertically */
    .exam-layout-container, 
    .main-split-wrapper {
        display: flex !important;
        flex-direction: column !important;
        padding: 10px !important;
        gap: 15px !important;
    }

    /* 2. Force panels to full width */
    .question-display-panel, 
    .side-palette-panel,
    .result-container,
    .review-box-item {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 auto !important;
        padding: 15px !important;
        box-sizing: border-box !important;
    }

    /* 3. Re-adjust typography weights for small displays */
    h2 { font-size: 1.4rem !important; }
    h4 { font-size: 1.1rem !important; }
    p { font-size: 1rem !important; line-height: 1.4 !important; }

    /* 4. Make option row blocks easy to tap with a thumb */
    .option-item {
        padding: 14px 12px !important; /* Bigger tap area */
        margin-bottom: 10px !important;
        font-size: 0.95rem !important;
        display: flex !important;
        align-items: flex-start !important; /* Align checkboxes cleanly with multi-line text */
    }
    
    .option-item input[type="radio"],
    .option-item input[type="checkbox"] {
        transform: scale(1.3) !important; /* Make inputs highly visible */
        margin-right: 12px !important;
        margin-top: 3px !important; /* Keep aligned with first line of text */
    }

    /* 5. Optimize the Action Navigation Bottom Row */
    .action-button-row,
    .btn-group {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important; /* Clean 2-column button split grid */
        gap: 10px !important;
        width: 100% !important;
    }

    .btn, .btn-secondary {
        width: 100% !important;
        padding: 12px 8px !important;
        font-size: 0.9rem !important;
        text-align: center !important;
    }
    
    /* Make huge full-width action buttons stand out */
    .btn-submit-comprehensive {
        grid-column: span 2 !important; /* Stretch submit button across both columns */
        margin-top: 10px !important;
    }

    /* 6. Prevent grid tracking circles from overflowing */
    .palette-grid-inject {
        grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)) !important;
        gap: 6px !important;
    }
    
    .pal-btn {
        height: 40px !important;
        width: 40px !important;
        font-size: 0.85rem !important;
    }
}
/* =======================================================
   RANK KARUNADU CUSTOM MOBILE LAYOUT OPTIMIZATION RULES
   ======================================================= */
@media screen and (max-width: 991px) {
    /* 1. Stack the main engine wrapper so questions appear first */
    .test-body-grid {
        display: flex !important;
        flex-direction: column !important;
        height: auto !important;
        overflow-y: visible !important;
    }

    /* 2. Give the working panel priority space at the top */
    .work-panel {
        padding: 16px !important;
        order: 1 !important; /* Forces question details to load first at the top */
        width: 100% !important;
        box-sizing: border-box !important;
    }

    /* 3. Push the heavy palette sidebar panel safely to the bottom */
    .sidebar-panel {
        order: 2 !important; /* Pushes the grid beneath the choices */
        border-left: none !important;
        border-top: 1px solid var(--border-color) !important;
        padding: 20px 16px !important;
        width: 100% !important;
        box-sizing: border-box !important;
        background: #f9fafb !important;
    }

    /* 4. Shrink the grid buttons slightly so 5 buttons fit perfectly across small screens */
    .palette-box {
        grid-template-columns: repeat(5, 1fr) !important;
        gap: 6px !important;
        max-height: 250px !important; /* Restricts height so it doesn't run off screen */
    }

    .pal-btn {
        padding: 10px 0 !important;
        font-size: 0.9rem !important;
    }

    /* 5. Make text fonts wrap cleanly without clipping */
    #q-text-en, #q-text-kn {
        font-size: 1.1rem !important;
        line-height: 1.5 !important;
    }
}