        /* Basic setup and scene container */
        body,
        html {
            margin: 0;
            padding: 0;
            width: 100%;
            height: 100%;
            /*overflow: hidden;*/
            /* Prevents scrollbars from appearing */
            font-family: 'Montserrat', sans-serif;
            background-color: #f0f4f8;
        }

        /* --- Fading Backgrounds --- */
        .scene-background {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            opacity: 0;
            transition: opacity 2s ease-in-out;
        }

        #admin-badge {
            display: none;
            /* Hidden by default */
            margin-left: 8px;
            padding: 3px 8px;
            font-size: 0.7rem;
            font-weight: bold;
            color: white;
            background-color: #6f42c1;
            /* A nice purple for admins */
            border-radius: 10px;
            vertical-align: middle;
        }

        .promote-btn {
            position: absolute;
            bottom: 8px;
            right: 46px;
            /* Positioned next to the delete button */
            padding: 6px 10px;
            background-color: #e6f7ff;
            color: #007bff;
            border: 1px solid #b3e0ff;
            border-radius: 5px;
            cursor: pointer;
            font-size: 12px;
            font-weight: bold;
            transition: all 0.2s ease;
        }

        .promote-btn:hover {
            background-color: #007bff;
            color: white;
        }

        .promote-btn:disabled {
            background-color: #e9ecef;
            color: #6c757d;
            cursor: not-allowed;
            border-color: #dee2e6;
        }

        #scene {
            position: relative;
            width: 100%;
            height: 100%;
            transition: background 0.5s ease;
            overflow: hidden;
        }

        /* CSS for the delete button on gallery thumbnails */
        .thumbnail-card {
            position: relative;
            /* Needed for positioning the delete button */
        }

        .delete-btn {
            position: absolute;
            bottom: 8px;
            right: 8px;
            width: 30px;
            height: 30px;
            background-color: #fee;
            color: #c00;
            border: 1px solid #fcc;
            border-radius: 50%;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 16px;
            transition: all 0.2s ease;
        }

        .delete-btn:hover {
            background-color: #c00;
            color: white;
            border-color: #c00;
        }

        .category-item {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 2px 0;
        }

        .delete-category-btn {
            background-color: #fee;
            color: #c00;
            border: 1px solid #fcc;
            border-radius: 50%;
            cursor: pointer;
            width: 20px;
            height: 20px;
            font-size: 14px;
            line-height: 1;
            transition: all 0.2s ease;
        }

        .delete-category-btn:hover {
            background-color: #c00;
            color: white;
        }

        /* STYLES FOR THE NEW BUTTON GROUP */
        .action-btn-group {
            display: flex;
            /* Arrange buttons side-by-side */
            gap: 8px;
            /* Create space between the buttons */
            margin-top: 15px;
        }

        /* Override the width for any action button inside our new group */
        .action-btn-group .action-btn {
            width: 100%;
            margin-top: 0;
        }

        /* Styling for each layer */
        .layer {
            position: absolute;
            bottom: 0;
            left: -30%;
            width: 160%;
            height: 100%;
            transition: transform 0.1s linear, fill 0.5s ease;

            /* Apply drop-shadow directly */
            --drop-shadow: none;
            filter: var(--drop-shadow);
        }

        .layer svg {
            width: 100%;
            height: 100%;
            display: block;
        }

        #category-filters {
            margin: 20px auto;
            text-align: center;
        }

        #category-filters button {
            background-color: #e9ecef;
            border: 1px solid #dee2e6;
            color: #495057;
            padding: 8px 15px;
            margin: 4px;
            border-radius: 20px;
            cursor: pointer;
            font-size: 0.9rem;
            transition: all 0.2s ease;
        }

        #category-filters button:hover {
            background-color: #ced4da;
        }

        #category-filters button.active {
            background-color: #007bff;
            color: white;
            border-color: #007bff;
        }


        /* Title and text styling */
        .title-container {
            position: absolute;
            top: 30%;
            /* Initial vertical position */
            left: 50%;
            transform: translate(-50%, -50%);
            text-align: center;
            color: white;
            text-shadow: 2px 2px 8px rgba(0, 0, 0, 0.7);
            z-index: 20;
            width: 90%;
            transition: color 0.5s ease;
        }

        h1 {
            font-family: 'Montserrat', sans-serif;
            /* This makes the font size fluid */
            font-size: clamp(2.5rem, 8vw, 5rem);
            margin: 0;
            font-weight: 900;
            letter-spacing: 0px;
            line-height: 1.2;
            /* This prevents long words from overflowing */
            overflow-wrap: break-word;
        }

        p {
            font-family: 'Montserrat', sans-serif;
            /* This makes the font size fluid */
            font-size: clamp(0.9rem, 2.5vw, 1.3rem);
            margin-top: 10px;
            letter-spacing: 0px;
            line-height: 1.2;
            /* This prevents long words from overflowing */
            overflow-wrap: break-word;
            width: 80%;
            /* ADD THESE TWO LINES TO CENTER THE TEXT BLOCK */
            margin-left: auto;
            margin-right: auto;
        }

        /* Fix for contenteditable text direction bug */
        [contenteditable="true"] {
            direction: ltr;
            text-align: left;
        }

        .title-container [contenteditable="true"] {
            text-align: center;
        }


        /* --- Controls --- */
        #panel-toggle {
            /* CSS reset for button element */
            border: none;
            padding: 0;

            position: absolute;
            top: 10px;
            left: 10px;
            width: 40px;
            height: 40px;
            background-color: rgba(255, 255, 255, 0.95);
            border-radius: 50%;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
            z-index: 101;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        #panel-toggle svg {
            width: 24px;
            height: 24px;
            fill: #333;
            transition: transform 0.3s ease;
        }

        .close-icon {
            display: none;
        }

        #controls {
            position: absolute;
            top: 10px;
            left: 10px;
            background-color: rgba(255, 255, 255, 0.65);
            padding: 15px;
            padding-top: 60px;
            border-radius: 12px;
            box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
            z-index: 100;
            border: 1px solid rgba(0, 0, 0, 0.1);
            max-height: 90vh;
            overflow-y: auto;
            transform: translateX(0);
            transition: transform 0.4s cubic-bezier(0.25, 1, 0.5, 1);
        }

        #controls.hidden {
            transform: translateX(-110%);
        }

        #controls h3 {
            margin: 15px 0 10px 0;
            font-size: 1rem;
            color: #333;
            text-align: center;
            border-top: 1px solid #ddd;
            padding-top: 15px;
        }

        #controls h3:first-of-type {
            margin-top: 0;
            border-top: none;
            padding-top: 0;
        }

        .collapsible-header {
            cursor: pointer;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .collapsible-header .arrow {
            transition: transform 0.3s ease;
            font-size: 1.2rem;
            font-weight: bold;
        }

        .collapsible-header.collapsed .arrow {
            transform: rotate(-90deg);
        }

        .collapsible-content {
            max-height: 3000px;
            /* Large value for open state */
            overflow: hidden;
            transition: max-height 0.4s ease-in-out, padding 0.4s ease-in-out, margin 0.4s ease-in-out;
        }

        .collapsible-content.collapsed {
            max-height: 0;
            padding-top: 0 !important;
            padding-bottom: 0 !important;
            margin-top: 0 !important;
            margin-bottom: 0 !important;
        }

        /* NEW: Styles for nested collapsible sections */
        .collapsible-content>.collapsible-header {
            margin: 12px 0 5px 0;
            padding: 8px;
            font-size: 0.9rem;
            font-weight: bold;
            background-color: #f0f3f5;
            border-radius: 5px;
            text-align: left;
            padding-left: 10px;
        }

        .collapsible-content>.collapsible-content {
            padding-top: 5px;
            padding-left: 10px;
            border-left: 2px solid #e9eef2;
            margin-left: 4px;
            padding-bottom: 5px;
        }

        #controls hr {
            border: none;
            border-top: 1px solid #ddd;
            margin: 15px 0;
        }


        .control-group {
            margin-bottom: 8px;
        }

        .control-group label {
            display: block;
            margin-bottom: 4px;
            font-size: 0.8rem;
            font-weight: 600;
            color: #555;
        }

        .control-group input[type="text"],
        .control-group input[type="password"],
        .control-group input[type="file"],
        .control-group input[type="range"],
        .control-group input[type="number"],
        .control-group select {
            font-size: 0.8rem;
            width: 180px;
            box-sizing: border-box;
        }

        .control-group select,
        .control-group input[type="text"],
        .control-group input[type="password"],
        .control-group input[type="number"] {
            padding: 4px;
            border: 1px solid #ccc;
            border-radius: 4px;
        }

        .micro-controls {
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .micro-controls input[type="range"] {
            width: 110px;
        }

        .micro-controls input[type="number"] {
            width: 60px;
        }

        /* Styles for the new layer transform controls */
        .layer-controls {
            border-top: 1px solid #eee;
            padding-top: 8px;
            margin-top: 8px;
        }

        .layer-controls:first-child {
            border-top: none;
            margin-top: 0;
            padding-top: 0;
        }

        .layer-controls h4 {
            font-size: 0.85rem;
            margin: 0 0 4px 0;
            color: #444;
        }

        .layer-controls {
            display: none;
            /* Hidden by default */
        }

        .layer-controls.visible {
            display: block;
            /* Shown when SVG is uploaded */
        }

        /* Shared button styles */
        .action-btn {
            display: block;
            width: 100%;
            padding: 10px;
            margin-top: 10px;
            border: none;
            border-radius: 8px;
            font-family: 'Montserrat', sans-serif;
            font-weight: 700;
            font-size: 0.9rem;
            cursor: pointer;
            transition: background-color 0.2s;
            text-align: center;
            text-decoration: none;
            box-sizing: border-box;
        }

        #save-pdf-btn {
            background-color: #2b5784;
            color: white;
        }

        #save-pdf-btn:hover {
            background-color: #3c6e9e;
        }

        #export-svg-btn {
            background-color: #6c757d;
            color: white;
        }

        #export-svg-btn:hover {
            background-color: #5a6268;
        }

        #save-scene-btn {
            background-color: #28a745;
            color: white;
        }

        #save-scene-btn:hover {
            background-color: #218838;
        }

        #load-scene-btn {
            background-color: #007bff;
            color: white;
        }

        #load-scene-btn:hover {
            background-color: #0069d9;
        }

        #load-scene-select {
            max-width: 100%;
        }

        #login-btn,
        #register-btn {
            background-color: #17a2b8;
            color: white;
        }

        #login-btn:hover,
        #register-btn:hover {
            background-color: #138496;
        }

        #logout-btn,
        #delete-scene-btn {
            background-color: #dc3545;
            color: white;
        }

        #logout-btn:hover,
        #delete-scene-btn:hover {
            background-color: #c82333;
        }

        .revert-btn {
            background-color: #ffc107;
            color: #212529;
            padding: 4px 8px;
            font-size: 0.75rem;
            width: auto;
            display: inline-block;
            margin-left: 8px;
        }

        .revert-btn:hover {
            background-color: #e0a800;
        }

        #share-scene-btn {
            background-color: #fd7e14;
            color: white;
        }

        #share-scene-btn:hover {
            background-color: #e66a00;
        }

        #import-scene-btn {
            background-color: #20c997;
            color: white;
        }

        #import-scene-btn:hover {
            background-color: #1baa80;
        }

        #motion-permission-btn {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            z-index: 102;
            padding: 12px 24px;
            font-size: 1rem;
            font-family: 'Montserrat', sans-serif;
            font-weight: 700;
            background-color: rgba(255, 255, 255, 0.95);
            color: #333;
            border: none;
            border-radius: 8px;
            box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
            cursor: pointer;
            display: none;
            /* Hidden by default */
        }

        #user-info {
            text-align: center;
            margin-bottom: 10px;
        }

        /* --- Scene Color Palettes --- */
        .day-scene.scene-background {
            background: linear-gradient(to bottom, #287a9b 0%, #d0e8ff 60%, #bde0fe 100%);
        }
        .sunset-scene.scene-background {
            background: linear-gradient(to bottom, #d9478e 0%, #feb47b 100%);
        }        
        .night-scene.scene-background {
            background: linear-gradient(to bottom, #061431 0%, #59738d 60%, #bde0fe 100%);
        }
        .misty-scene.scene-background {
            background: linear-gradient(to bottom, #60afbd 0%, #feb47b 100%);
        }
        .sunrise-scene.scene-background {
            background: linear-gradient(to bottom, #f5ad76 0%, #d0e8ff 60%, #bde0fe 100%);
        }
        .white-paper-scene.scene-background {
            background: linear-gradient(to bottom, #d7d7d7 0%, #ffffff 100%);
        }
        .antique-paper-scene.scene-background {
            background: linear-gradient(to bottom, #c7c3ac 0%, #d3c9ac 100%);
        }
        .day-scene {
            --layer-color-start: #d4f1f9;
            --layer-color-end: #1e3b5c;
        }
        .sunset-scene {
            --layer-color-start: #ffdebd;
            --layer-color-end: #3b2f5b;
        }
        .night-scene {
            --layer-color-start: #46556b;
            --layer-color-end: #0b0f19;
        }
        .misty-scene {
            --layer-color-start: #e0e9e7;
            --layer-color-end: #5b7065;
        }
        .sunrise-scene {
            --layer-color-start: #fce1a8;
            --layer-color-end: #523a59;
        }
        .white-paper-scene {
            --layer-color-start: #999999;
            --layer-color-end: #ffffff;
        }
        .antique-paper-scene {
            --layer-color-start: #d3c9ac;
            --layer-color-end: #f8f3e4;
        }
        
        /* Drop shadows now defined via CSS variables */
        #layer-1 {
            --drop-shadow: none;
        }

         #layer-2,
         #layer-3,
         #layer-4 {
            --drop-shadow: drop-shadow(5px 5px 4px rgba(0, 0, 0, 0.05));
        }

         #Layer-5,
         #layer-6 {
            --drop-shadow: drop-shadow(8px 8px 6px rgba(0, 0, 0, 0.1));
        }

        #layer-7,
        #layer-8 {
            --drop-shadow: drop-shadow(10px 10px 8px rgba(0, 0, 0, 0.15));
        }

        #layer-9,
        #layer-10 {
            --drop-shadow: drop-shadow(10px 10px 10px rgba(0, 0, 0, 0.2));
        }

        #layer-11 {
            --drop-shadow: drop-shadow(12px 12px 12px rgba(0, 0, 0, 0.25));
        }

        #layer-12 {
            --drop-shadow: drop-shadow(12px 12px 15px rgba(0, 0, 0, 0.3));
        }

        /* Media query for mobile
        @media (max-width: 768px) {
            h1 {
                font-size: 3rem;
            }
        } */

        /* Keyframe animations */
        @keyframes float {

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

            50% {
                transform: translateY(-10px);
            }
        }

        @keyframes pulse {

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

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

        .anim-float {
            animation: float var(--animation-duration, 6s) ease-in-out infinite;
        }

        .anim-pulse {
            animation: pulse var(--animation-duration, 4s) ease-in-out infinite;
        }

        /* --- Help Overlay Styles --- */
        #help-btn {
            position: fixed;
            top: 10px;
            right: 10px;
            width: 40px;
            height: 40px;
            border-radius: 50%;
            background-color: rgba(255, 255, 255, 0.95);
            border: none;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
            font-size: 1.5rem;
            font-weight: bold;
            color: #333;
            z-index: 101;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        /* And REPLACE it with this simpler version */
        #help-overlay {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(0, 0, 0, 0.6);
            z-index: 200;
            display: none;
            /* Hidden by default */
            align-items: center;
            justify-content: center;
        }

        #help-overlay.visible {
            display: flex;
            /* Shown with JS */
        }

        #help-modal {
            background-color: white;
            padding: 25px 35px;
            border-radius: 10px;
            max-width: 600px;
            max-height: 80vh;
            display: flex;
            flex-direction: column;
            position: relative;
        }

        #close-help-btn {
            position: absolute;
            top: 10px;
            right: 15px;
            background: none;
            border: none;
            font-size: 2rem;
            color: #888;
            cursor: pointer;
        }

        #help-content {
            overflow-y: auto;
            /* This makes the content scrollable */
            line-height: 1.6;
        }

        #help-content h4 {
            margin-top: 20px;
            color: #2b5784;
        }

        /* --- Footer Styles --- */
        #app-footer {
            position: fixed;
            bottom: 0;
            left: 0;
            width: 100%;
            background: #1e3b5c;
            color: #e0e0e0;
            padding: 20px 0;
            z-index: 90;
            /* When hidden, the footer is mostly off-screen, revealing only the 40px tab */
            transform: translateY(calc(100% - 40px));
            transition: transform 0.4s ease-in-out;
        }

        #app-footer.visible {
            transform: translateY(0);
            /* Slides the entire footer into view */
        }

        /* NEW styling for the footer toggle as a tab */
        #toggle-footer-btn {
            position: absolute;
            bottom: 100%;
            /* Sits directly on top of the footer content */
            right: 30px;
            padding: 10px 25px;
            border: none;
            background: #1e3b5c;
            /* Matches the footer */
            color: white;
            font-family: 'Montserrat', sans-serif;
            font-weight: bold;
            font-size: 1rem;
            cursor: pointer;
            /* Creates the tab shape */
            border-top-left-radius: 8px;
            border-top-right-radius: 8px;
        }

        .footer-content {
            max-width: 1200px;
            margin: 0 auto;
            padding: 0 20px;
            display: flex;
            justify-content: space-between;
            gap: 20px;
        }

        .footer-column {
            flex: 1;
        }

        .footer-column h4 {
            color: white;
            border-bottom: 1px solid #3c6e9e;
            padding-bottom: 8px;
        }

        .footer-column ul {
            list-style: none;
            padding: 0;
        }

        .footer-column a {
            color: #a2d2ff;
            text-decoration: none;
        }

        .footer-column a:hover {
            text-decoration: underline;
        }

        /* On smaller screens, stack footer columns */
        @media (max-width: 768px) {
            .footer-content {
                flex-direction: column;
            }
        }