
    /* =================================== */
    /* --- Global Styles & Variables --- */
    /* =================================== */
    :root {
        /* Define key colors for easy theme management */
        --w3s-green: #04AA6D;
        --w3s-dark: #282A35;
        --w3s-light-grey: #E7E9EB;
        --w3s-white: #FFFFFF;
        --w3s-code-bg: #F1F1F1;
        /* Define fixed heights for navigation elements */
        --nav-height: 44px;
        /* W3S subject nav height */
        --top-nav-height: 60px;
        /* Our top nav height */
    }

    /* Base styles for the entire page */
    body {
        margin: 0;
        font-family: 'Source Sans Pro', sans-serif;
        font-size: 15px;
        line-height: 1.5;
        background-color: var(--w3s-white);
        color: #000;
        /* Sets up main grid layout for header, nav, main, footer */
        display: grid;
        /* Auto for header/nav, 1fr for main content to fill space, auto for footer */
        grid-template-rows: auto auto 1fr auto;
        min-height: 100vh;
    }

    /* **NEW:** Style to prevent body scrolling when the mobile menu is open */
    .no-scroll {
        overflow: hidden !important;
    }

    a {
        /* Remove underline from all links */
        text-decoration: none;
        /* Links inherit color from parent element */
        color: inherit;
    }

    h1, h2, h3 {
        font-family: 'Segoe UI', Arial, sans-serif;
        font-weight: 400;
    }

    h1 {
        font-size: 38px;
    }

    hr {
        /* Create a thin divider line */
        border: 0;
        border-top: 1px solid #eee;
        margin: 20px 0;
    }

    /* =================================== */
    /* --- 1. Top Navigation (Desktop Styles) --- */
    /* =================================== */
    .top-nav {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0 1rem;
        height: var(--top-nav-height);
        background-color: var(--w3s-white);
        box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
        /* Make the nav stick to the top when scrolling */
        position: sticky;
        top: 0;
        z-index: 1000;
        flex-wrap: nowrap;
        /* FIX: Ensures it starts exactly at the top edge, fixing the gap on all screens. */
        margin: 0;
    }

    .top-nav .logo a {
        font-size: 24px;
        font-weight: 700;
        color: #000;
    }

    /* Style the ".com" part of the logo */
    .top-nav .logo span {
        font-weight: 400;
    }

    /* Desktop Button size/style */
    .auth-links a {
        padding: 8px 18px;
        border-radius: 25px;
        margin-left: 8px;
        font-weight: 600;
        font-size: 14px;
    }

    .auth-links .btn-signup {
        background-color: var(--w3s-green);
        color: var(--w3s-white);
    }

    .auth-links .btn-login {
        background-color: var(--w3s-code-bg);
        color: #000;
    }

    /* Hover effects */
    .auth-links .btn-login:hover {
        background-color: #ccc;
    }

    .auth-links .btn-signup:hover {
        background-color: #059862;
    }

    /* Hide unused mobile toggles container on desktop */
    .mobile-toggles,
    .subject-nav .subject-header-mobile {
        display: none;
    }

    /* Hide the icon button on desktop */
    .subject-nav #sidebar-icon-toggle {
        display: none;
    }

    /* =================================== */
    /* --- 2. Subject Navigation (Desktop/Default View) --- */
    /* =================================== */
    .subject-nav {
        display: flex;
        background-color: var(--w3s-dark);
        color: var(--w3s-white);
        height: var(--nav-height);
        /* Stick below the top nav */
        position: sticky;
        top: var(--top-nav-height);
        z-index: 999;
        /* Allows navigation items to scroll horizontally if many exist */
        overflow-x: auto;
    }

    .subject-nav a {
        padding: 0 1.2rem;
        display: flex;
        align-items: center;
        /* Forces links to stay on a single line */
        white-space: nowrap;
        font-size: 14px;
    }

    .subject-nav a:hover {
        background-color: #000;
    }

    /* Highlight the currently active subject */
    .subject-nav a.active {
        background-color: var(--w3s-green);
    }


    /* =================================== */
    /* --- 3. Main Container (Grid Wrapper) --- */
    /* =================================== */
    .main-container {
        display: grid;
        /* Desktop layout: Sidebar (230px) and Main Content (1fr = rest of space) */
        grid-template-columns: 230px 1fr;
        grid-row: 3;
        background-color: var(--w3s-white);
    }

    /* =================================== */
    /* --- 4. Sidebar (Contents) --- */
    /* =================================== */
    .sidebar {
        background-color: var(--w3s-light-grey);
        padding-top: 1rem;
        /* Make the sidebar stick below the navigation bars */
        position: sticky;
        top: calc(var(--top-nav-height) + var(--nav-height));
        /* Helps sticky work correctly within grid */
        align-self: start;
        /* Calculates height to fill the remaining screen space */
        height: calc(100vh - var(--top-nav-height) - var(--nav-height));
        /* Allows content to scroll vertically if necessary */
        overflow-y: auto;
        z-index: 998;

    }

    .sidebar h3 {
        font-size: 20px;
        margin: 0 1rem 0.5rem 1rem;
    }

    .sidebar a {
        display: block;
        padding: 4px 1rem;
        font-size: 15px;
        color: #000;

    }

    .sidebar a:hover {
        background-color: #cccccc;
    }

    /* Highlight the currently active link in the sidebar */
    .sidebar a.active {
        background-color: var(--w3s-green);
        color: var(--w3s-white);
    }

    /* =================================== */
    /* --- 5. Main Content --- */
    /* =================================== */
    .main-content {
        /* Large padding for desktop view */
        padding: 1.5rem 2.5rem;
        background-color: var(--w3s-white);
    }

    /* Navigation buttons (Previous/Next) */
    .page-nav {
        display: flex;
        justify-content: space-between;
        margin-top: 1rem;
    }

    .page-nav a {
        background-color: var(--w3s-green);
        color: var(--w3s-white);
        padding: 10px 20px;
        border-radius: 5px;
        font-weight: 600;
    }

    .page-nav a:hover {
        background-color: #059862;
    }

    /* Highlight box for examples/notes */
    .example-box {
        background-color: #D9EEE1;
        border-radius: 5px;
        padding: 1rem 1.5rem;
        margin: 1.5rem 0;
    }

    /* Container for code snippets */
    .code-box {
        background-color: var(--w3s-code-bg);
        border-radius: 5px;
        padding: 1rem;
        margin: 1rem 0;
        /* CRITICAL: Allows the code block itself to scroll horizontally if lines are too wide */
        overflow-x: auto;
        border-left: 4px solid var(--w3s-green);
    }

    pre {
        margin: 0;
        font-family: "Consolas", "Courier New", monospace;
        font-size: 14px;
    }

    .btn-try {
        background-color: var(--w3s-green);
        color: var(--w3s-white);
        padding: 8px 15px;
        border-radius: 5px;
        display: inline-block;
        margin-top: 0.5rem;
        font-weight: 600;
    }

    .btn-try:hover {
        background-color: #059862;
    }


    /* --- 6. Footer --- */
    .footer {
        grid-row: 4;
        background-color: var(--w3s-dark);
        color: var(--w3s-white);
        padding: 2rem 1rem;
        text-align: center;
    }

    .social-links a {
        margin: 0 0.75rem;
        font-size: 1.5rem;
        color: var(--w3s-white);
    }

    .social-links a:hover {
        color: var(--w3s-green);
    }

    /* --- Overlay for mobile menus (dim background when sidebar is open) --- */
    .overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: rgba(0, 0, 0, 0.5);
        z-index: 1001;
    }

    .overlay.visible {
        display: block;
    }


    /* ################################### */
    /* ---      RESPONSIVE (MOBILE)      --- */
    /* ################################### */
    /* Styles applied for screens 990px wide or smaller (Mobile/Tablet) */
    @media (max-width: 990px) {

        /* === CRITICAL FIX: Stops the ENTIRE PAGE from side scrolling === */
        body {
            overflow-x: hidden;
        }

        /* === 1. TOP NAV ADJUSTMENTS (Full Width Restored) === */


        /* Shrink the size of the buttons to fit on small screens */
        .auth-links a {
            padding: 6px 12px;
            font-size: 13px;
            border-radius: 20px;
            margin-left: 6px;
        }

        /* === 2. SUBJECT NAV ADJUSTMENTS (Full Width Restored) === */
        .subject-nav {
            /* This element naturally takes 100% width unless constrained */
            position: static;
            height: var(--nav-height);
            flex-direction: row;
            /* Keeps horizontal scroll for the links */
            overflow-x: auto;
            top: auto;
            /* Adds space on the left for the fixed icon button */
            padding-left: 40px;
        }

        .subject-nav #sidebar-icon-toggle {
            display: flex;
            align-items: center;
            justify-content: center;
            background-color: var(--w3s-dark);
            color: var(--w3s-white);
            border: none;
            padding: 0;
            width: 40px;
            height: var(--nav-height);
            cursor: pointer;
            font-size: 16px;
            z-index: 1000;

            /* Pins the icon button to the left edge above the scrollable links */
            position: sticky;
            left: 0px;
            right: 5px;
            top: 0;
        }

        .subject-nav #sidebar-icon-toggle:hover {
            background-color: #000;
        }

        .subject-nav a {
            padding: 0 1rem;
            border-bottom: none;
        }

        /* ################################### */
        /* --- COPA TEST SPECIFIC STYLES (Mobile Overrides) --- */
        /* ################################### */

        /* The test wrapper needs to lose its flex/grid layout and just be vertical content */
        .exam-wrapper {
            flex-direction: column !important;
            /* Ensure it overrides the desktop grid */
            width: 100% !important;
            margin: 0 !important;
            padding: 0 !important;
            box-shadow: none !important;
            min-height: auto !important;
        }

        /* === FIX 1: Main content takes full width on mobile === */
        .main-container {
            grid-template-columns: 1fr; /* Only one column for main content */
        }

        /* === FIX 2: Sidebar becomes a fixed, off-canvas element === */
        .sidebar {
            position: fixed; /* Must be fixed to overlay content */
            left: -230px;
            /* Hidden off-screen by default */
            width: 230px; /* Explicit width is needed for fixed positioning */
            top: calc(var(--top-nav-height) + var(--nav-height));
            height: calc(100vh - var(--top-nav-height) - var(--nav-height));
            transition: left 0.3s;
            z-index: 1002;
            box-shadow: 2px 0 5px rgba(0, 0, 0, 0.2);
        }

        .sidebar.show {
            left: 0;
        }

        /* Reduce main content padding for mobile */
        .main-content {
            padding: 1rem 1.2rem;
        }

        /* Remove padding from body to make room for full-width components */
        body {
            padding: 0;
        }

        /* Hide elements that are not used in this specific content page */
        .page-nav {
            display: none;
        }
    }


    /* ################################### */
    /* --- COPA MOCK TEST STYLES --- */
    /* ################################### */

    /* NOTE: The COPA styles are integrated here. They are designed to be mobile-first. 
        The desktop media query in the COPA styles will adapt the content within the W3S layout. */
    .exam-wrapper {
        /* Modified to fit into the main-content area, not the full screen body */
        font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
        margin: 0 auto;
        /* No max-width restriction here, let it fill the W3S main-content */
        display: flex;
        flex-direction: column;
        min-height: auto;
        /* Don't force 100vh inside another scrolling container */
        box-shadow: none;
        background-color: var(--w3s-white);
        /* Match main content background */
    }

    /* LEFT PANEL (Question Area - Top on Mobile) */
    .primary-content {
        order: 2;
        background-color: #fff;
        padding: 0;
        /* No extra padding, main-content handles it */
        overflow-y: visible;
        /* Let the page scroll, not this element */
        flex-grow: 1;
    }

    /* Question Display Title/Text */
    .question-display h2 {
        font-size: 1.3em;
        color: #0056b3;
    }

    .question-display p {
        font-size: 1.1em;
        line-height: 1.6;
    }

    /* RIGHT PANEL (Navigation/Palette - Top on Mobile) */
    .aux-sidebar {
        order: 1;
        background-color: #eef3f6;
        padding: 15px;
        border-bottom: 2px solid #ddd;
    }

    /* Question Palette & Grid */
    .aux-sidebar h3 {
        color: #0056b3;
        border-bottom: 2px solid #0056b3;
        padding-bottom: 5px;
        margin-top: 0;
        font-size: 1.1em;
    }

    .nav-section {
        max-height: 120px;
        overflow-y: auto;
        margin-bottom: 10px;
    }

    .item-grid {
        display: grid;
        grid-template-columns: repeat(6, 1fr);
        gap: 6px;
        padding: 5px 0;
    }

    .item-btn {
        padding: 8px 3px;
        border: 1px solid #ccc;
        background-color: #fff;
        cursor: pointer;
        border-radius: 4px;
        font-size: 0.8em;
        font-weight: bold;
    }

    /* Working Area */
    .draft-space {
        display: none;
    }

    #rough-work-area {
        width: 100%;
        box-sizing: border-box;
        resize: vertical;
        padding: 10px;
        border: 1px solid #ccc;
        border-radius: 5px;
        min-height: 100px;
    }


    /* Options and Feedback Styles */
    .choice-list label {
        display: block;
        background: #f9f9f9;
        padding: 12px;
        margin-bottom: 8px;
        border-radius: 5px;
        cursor: pointer;
        border: 1px solid #eee;
    }

    .choice-list label:hover {
        background: #f0f0f0;
    }

    .choice-list label.opt-correct {
        background-color: #d4edda;
        border-color: #28a745;
        font-weight: bold;
    }

    .choice-list label.opt-incorrect {
        background-color: #f8d7da;
        border-color: #dc3545;
        font-weight: bold;
    }

    .choice-list input[type="radio"] {
        display: none;
    }

    /* Navigation Buttons */
    .action-controls {
        padding-top: 15px;
        display: flex;
        justify-content: space-between;
    }

    .action-controls button {
        padding: 10px 15px;
        font-size: 0.9em;
        border: none;
        border-radius: 5px;
        cursor: pointer;
        font-weight: bold;
    }

    #prev-btn {
        background-color: #6c757d;
        color: white;
    }

    #next-btn {
        background-color: #007bff;
        color: white;
    }

    #next-btn.state-disabled {
        background-color: #adb5bd;
        cursor: not-allowed;
    }

    #prev-btn:disabled {
        opacity: 0.5;
        cursor: not-allowed;
    }

    /* Button Status Colors */
    .item-btn.status-current {
        background-color: #ffc107;
        border-color: #ffc107;
        color: #333;
    }

    .item-btn.status-answered {
        background-color: #28a745;
        border-color: #28a745;
        color: white;
    }

    /* Modal Style */
    .result-box {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.7);
        z-index: 1000;
        justify-content: center;
        align-items: center;
    }

    .summary-pane {
        background: white;
        padding: 30px;
        border-radius: 10px;
        max-width: 90%;
        text-align: center;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    }

    /* --- DESKTOP OPTIMIZATION (Min 768px for COPA content) --- */
    @media (min-width: 768px) {
        .exam-wrapper {
            flex-direction: row;
            border-radius: 8px;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.05);
            /* Lighter shadow since it's inside main-content */
            /* Force max width to prevent it from getting too wide in the main content area */
            max-width: 1000px;
            margin: 20px auto;
        }

        .primary-content {
            order: 1;
            flex: 3;
            padding: 20px 30px;
            border-right: 1px solid #ddd;
            min-height: 500px;
            /* Give it a minimum height to look good on desktop */
            overflow-y: visible;
        }

        .aux-sidebar {
            order: 2;
            flex: 1.5;
            padding: 20px;
            border-bottom: none;
        }

        .nav-section {
            max-height: none;
            overflow-y: visible;
            margin-bottom: 20px;
        }

        .item-grid {
            grid-template-columns: repeat(5, 1fr);
        }

        .item-btn {
            padding: 10px 5px;
            font-size: 1em;
        }

        .draft-space {
            display: block;
            flex-grow: 1;
        }

        #rough-work-area {
            min-height: 200px;
            /* Adjusted to fit better in a sidebar */
        }
    }
