/* =================================== */
        /* --- 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);
            /* Example background color for testing */
            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;
        }

        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 === */
           

            /* === 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;
            }

            /* --- 3. Main Container (Full Width Restored) --- */
            .main-container {
                /* This element naturally takes 100% width unless constrained */

                /* Switch to a single column layout */
                grid-template-columns: 1fr;
                /* Ensure padding and border are contained within the defined width */
                box-sizing: border-box;
            }

            /* --- 3. Sidebar: Off-canvas menu on mobile --- */
            .sidebar {
                /* Initially hidden */
                display: none;
                /* Use fixed position to slide in over content */
                position: fixed;
                left: 0;
                top: 100px;
                width: 80%;
                max-width: 300px;
                height: 2000px;
                z-index: 1002;
                box-shadow: 4px 0 10px rgba(0, 0, 0, 0.2);
                padding-top: 1rem;
                align-self: auto;
            }

            /* Class added by JavaScript to show the sidebar */
            .sidebar.visible {
                display: block;
            }

            /* --- 5. Main content: Adjust padding and containment for mobile view --- */
            .main-content {
                /* Reduce padding for smaller screens */
                padding: 1rem 1.2rem;
                /* Ensures padding is included *inside* the width, preventing horizontal overflow */
                box-sizing: border-box;
            }

            /* Additional check for the example box container */
            .example-box {
                box-sizing: border-box;
            }

            /* --- 6. Footer (Full Width Restored) --- */

        }