body {
    background-color: #1a1b1e; 
    color: #eeeeee;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0; padding: 0;
    height: 100vh; width: 100vw;
    box-sizing: border-box;
    overscroll-behavior: none; 
    position: relative; overflow: hidden; 
}

#animated-bg {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    width: 100vw; height: 100vh; opacity: 0; 
    transition: opacity 0.5s ease-in-out;
    z-index: 0; pointer-events: none; image-rendering: pixelated;
}

/* ========================================== */
/* FLOATING GLASS BRAND BUBBLE                */
/* ========================================== */
.glass-bubble {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
    padding: 8px 16px; border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.15); border-top: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    flex-shrink: 0;
}

.brand-container {
    display: inline-flex;
    align-items: center;
    gap: 15px;
    margin: 0 0 5px 0;
    padding-right: 40px; 
}

.app-title {
    font-size: 38px; font-weight: 900; margin: 0; letter-spacing: -1px;
    font-family: 'Arial Rounded MT Bold', 'Segoe UI', sans-serif;
    color: rgba(255, 255, 255, 0.9);
    text-shadow: 1px 2px 4px rgba(0,0,0,0.5);
}

#main-logo {
    height: 60px;
    width: auto;
    opacity: 0.5; 
    image-rendering: pixelated;
}

#focus-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.85);
    z-index: 50; opacity: 0; pointer-events: none;
    transition: opacity 0.4s ease;
}
#focus-overlay.active { opacity: 1; cursor: default; }
#close-x { pointer-events: auto; }
#focus-overlay.hole-punch {
    background: radial-gradient(circle at 70% 20%, transparent 20%, rgba(0,0,0,0.85) 55%);
    pointer-events: none; 
}

/* ========================================== */
/* QUADRANT LAYOUT SYSTEM                     */
/* ========================================== */
#left-controls {
    position: absolute; top: 0; left: 0; width: 40vw; height: 40vh;
    padding: 20px; box-sizing: border-box; overflow-y: auto;
    z-index: 10; display: flex; flex-direction: column; gap: 12px; pointer-events: none;
}
#left-controls * { pointer-events: auto; }

#right-controls-container {
    position: absolute; top: 0; right: 0; width: 60vw; height: 40vh; z-index: 5;
}

#workspace {
    position: absolute; top: 40vh; left: 0; width: 100vw; height: 60vh;
    padding: 20px; box-sizing: border-box; display: flex; gap: 20px;
    z-index: 10; background: rgba(0,0,0,0.2);
}

.control-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

button, input[type="text"], input[type="number"], textarea {
    padding: 8px 12px; background: rgba(58, 58, 58, 0.4); 
    backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px);
    color: white; border: 1px solid rgba(255, 255, 255, 0.1); border-top: 1px solid rgba(255, 255, 255, 0.3); 
    border-radius: 4px; font-family: 'Segoe UI', sans-serif; box-shadow: 0 4px 6px rgba(0,0,0,0.3);
    text-shadow: 1px 1px 2px rgba(0,0,0,0.8); font-weight: bold; cursor: pointer; transition: 0.1s;
}
button:hover { background: rgba(74, 74, 74, 0.6); }
button:active { transform: translateY(2px); box-shadow: none; }

.layer-btn { color: #ccc; }
.layer-btn.active { background-color: rgba(79, 163, 209, 0.6); color: white; border-top-color: rgba(142, 208, 245, 0.8); }
.tool-btn.active { background-color: rgba(136, 136, 136, 0.6); border-top-color: rgba(204, 204, 204, 0.8); }

/* NEW PAINT BUCKET STYLE */
#btn-tool-fill.active { background-color: rgba(241, 196, 15, 0.5); border-top-color: rgba(241, 196, 15, 0.8); color: white; }

#btn-export { background-color: rgba(214, 60, 60, 0.5); border-top-color: rgba(255, 119, 119, 0.8); font-size: 14px; padding: 10px 20px;}
#btn-export:hover { background-color: rgba(231, 76, 60, 0.7); }
.btn-green { background-color: rgba(39, 174, 96, 0.5) !important; border-top-color: rgba(46, 204, 113, 0.8) !important; }
.btn-green:hover { background-color: rgba(39, 174, 96, 0.7) !important; }
.btn-blue { background-color: rgba(41, 128, 185, 0.5) !important; border-top-color: rgba(52, 152, 219, 0.8) !important; }
.btn-blue:hover { background-color: rgba(41, 128, 185, 0.7) !important; }

/* ========================================== */
/* AESTHETIC PANEL                            */
/* ========================================== */
#aesthetic-panel {
    position: absolute; top: 120px; left: 100px; 
    background: rgba(5, 10, 5, 0.9); border: 2px solid #33ff33; 
    backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px);
    border-radius: 8px; width: 340px; z-index: 200;
    box-shadow: 0 10px 50px rgba(51, 255, 51, 0.15);
    display: none; flex-direction: column; resize: both; overflow: hidden; min-width: 300px; min-height: 250px;
}
#aesthetic-panel.active { display: flex; }
.panel-header { background: rgba(10, 31, 10, 0.8); padding: 12px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #33ff33; cursor: move; user-select: none; }
.panel-header h4 { margin: 0; color: #33ff33; text-transform: uppercase; font-size: 14px; text-shadow: 0 0 5px #33ff33; letter-spacing: 1px; pointer-events: none;}
.tab-content { display: none; padding: 15px; flex-direction: column; gap: 10px; overflow-y: auto; flex: 1; }
.tab-content.active { display: flex; }
.tab-content label { color: #33ff33; font-size: 11px; text-transform: uppercase; display: flex; justify-content: space-between; font-family: monospace; font-weight: bold; text-shadow: 0 0 2px #33ff33;}

.dh-row { display: grid; grid-template-columns: 40px 1fr 40px; gap: 5px; align-items: center; font-size: 10px; color: #33ff33; font-family: monospace;}
.panel-tabs { display: flex; border-bottom: 2px solid #115511; background: rgba(10, 31, 10, 0.8); flex-shrink: 0;}
.tab-btn { flex: 1; background: transparent; border: none; border-right: 1px solid #115511; color: #115511; font-family: monospace; font-weight: bold; padding: 8px; cursor: pointer; text-transform: uppercase; transition: 0.2s;}
.tab-btn:hover { background: rgba(17, 51, 17, 0.8); color: #33ff33; }
.tab-btn.active { background: rgba(51, 255, 51, 0.8); color: #000; box-shadow: inset 0 0 10px rgba(0,0,0,0.5); }

input[type=range].green-slider { -webkit-appearance: none; width: 100%; background: transparent; margin: 4px 0 8px 0;}
input[type=range].green-slider:focus { outline: none; }
input[type=range].green-slider::-webkit-slider-runnable-track { width: 100%; height: 4px; cursor: pointer; background: #0a1f0a; border: 1px solid #115511; border-radius: 2px; }
input[type=range].green-slider::-webkit-slider-thumb { border: 1px solid #fff; height: 14px; width: 8px; border-radius: 2px; background: #33ff33; box-shadow: 0 0 5px #33ff33; cursor: pointer; -webkit-appearance: none; margin-top: -6px;  }
input[type=number].val-input { background: transparent; border: none; border-bottom: 1px solid rgba(51, 255, 51, 0.3); color: #33ff33; font-family: monospace; font-size: 11px; font-weight: bold; text-align: right; width: 38px; outline: none; text-shadow: 0 0 2px #33ff33; padding: 0; margin-left: 5px; cursor: text; transition: 0.2s; }
input[type=number].val-input:focus { border-bottom: 1px solid #33ff33; background: rgba(51, 255, 51, 0.1); }
input[type=number].val-input::-webkit-outer-spin-button, input[type=number].val-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.color-picker { width: 100%; height: 30px; border: 1px solid #33ff33; cursor: pointer; padding: 0; background: none; border-radius:2px; overflow:hidden;}
.color-box-container { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 5px;}
.color-box-wrapper { flex: 1; min-width: 40px; display:flex; flex-direction:column; align-items:center; gap:2px;}

/* ========================================== */
/* TRIM EDITOR OVERLAY                        */
/* ========================================== */
#trim-editor-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.85); display: none; align-items: center; justify-content: center; z-index: 400; pointer-events: auto; }
#trim-editor-overlay .expanded-window { background: #1a1a1a; border: 4px solid #f1c40f; width: 600px; max-width: 90%; border-radius: 8px; display: flex; flex-direction: column; padding: 20px; gap: 15px; box-shadow: 0 10px 30px rgba(0,0,0,0.8); }
.waveform-container { position: relative; height: 120px; background: #000; border: 2px solid #333; overflow: hidden; border-radius: 4px; }
#trim-region { position: absolute; top: 0; bottom: 0; background: rgba(241, 196, 15, 0.3); border-left: 6px solid #f1c40f; border-right: 6px solid #f1c40f; cursor: grab; box-sizing: border-box; }
#trim-region:active { cursor: grabbing; }
.trim-handle { position: absolute; top: 0; bottom: 0; width: 12px; cursor: ew-resize; z-index: 10; }
#trim-handle-left { left: -6px; } #trim-handle-right { right: -6px; }
#trim-playhead { position: absolute; top: 0; bottom: 0; width: 2px; background: #e74c3c; z-index: 5; pointer-events: none; box-shadow: 0 0 5px red; }

/* ========================================== */
/* WORKSPACE PANELS                           */
/* ========================================== */
#palette-panel { background: rgba(45, 45, 45, 0.6); backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px); padding: 15px; border-radius: 8px; display: flex; flex-direction: column; box-shadow: 0 4px 15px rgba(0,0,0,0.5); max-width: 320px; width: 320px; min-height: 0; min-width: 0; z-index: 10;}
#tile-ui { display: flex; flex-direction: column; flex: 1; min-height: 0; min-width: 0; }
#map-panel { background: rgba(45, 45, 45, 0.6); backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px); padding: 15px; border-radius: 8px; flex: 1; display: flex; flex-direction: column; box-shadow: 0 4px 15px rgba(0,0,0,0.5); min-height: 0; min-width: 0; z-index: 1;} 
#palette-container, #map-container { overflow: auto; position: relative; background-color: rgba(43, 43, 54, 0.8); flex: 1; min-height: 0; min-width: 0; overscroll-behavior: none; border: 2px solid rgba(17, 17, 17, 0.8); }
#palette-container { margin-top: 5px; }
#entity-palette, #collision-palette { display: none; flex-direction: column; gap: 10px; margin-top: 10px; overflow-y: auto; }
.ent-btn { padding: 10px; text-align: left; border: 2px solid rgba(68, 68, 68, 0.8); background-color: rgba(51, 51, 51, 0.8); color: white; display: flex; align-items: center; min-height: 40px; image-rendering: pixelated; border-radius: 4px;}
.ent-btn.active { border-color: white; background-color: rgba(68, 68, 68, 0.8); transform: scale(1.02); }
.ent-btn:hover { background-color: rgba(79, 163, 209, 0.8); border-color: white; cursor: pointer; } 
#properties-panel { display: none; flex-direction: column; background: rgba(26, 26, 26, 0.8); padding: 15px; border-radius: 6px; margin-top: 15px; border: 2px solid #4fa3d1; }
#properties-panel h4 { margin: 0 0 10px 0; color: #4fa3d1; text-transform: uppercase; font-size: 12px; }
.prop-group { display: flex; flex-direction: column; gap: 8px; }
.prop-group label { font-size: 12px; color: #aaa; font-weight: bold; }
canvas { image-rendering: pixelated; transform-origin: top left; display: block; }
#map-canvas, #palette-canvas { cursor: crosshair; }
#map-canvas.panning, #palette-canvas.panning { cursor: grabbing; }
#selected-tile-preview { width: 64px; height: 64px; border: 2px dashed rgba(136, 136, 136, 0.8); margin-top: 10px; background: rgba(43, 43, 54, 0.8); display: flex; align-items: center; justify-content: center; color: #ccc; font-size: 12px; font-weight: bold; }
.error-text { color: #ff5555; font-size: 12px; margin-top: 5px; display: none; }
.hint-text { color: #888; font-size: 12px; margin: 0; padding: 0; display: flex; justify-content: space-between; align-items: center;}
.fit-btn { background: none; border: none; color: #4fa3d1; padding: 0; font-size: 12px; cursor: pointer; box-shadow: none;}
.fit-btn:hover { background: none; color: #fff; text-decoration: underline; }
.grid-ui input { padding: 4px; font-size: 12px; background: rgba(34, 34, 34, 0.8); border: 1px solid rgba(85, 85, 85, 0.8); width: 45px;}
.grid-ui button { padding: 4px 8px; font-size: 12px; }

/* ========================================== */
/* AUDIO PLAYER HTML STYLES (Mapped via CSS3D)*/
/* ========================================== */
.sansui-black-panel { background: #111; border-bottom: 2px solid #ddd; padding: 12px 15px 15px 15px; position: relative; pointer-events: auto; }
.sansui-brand { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.sansui-silver-panel { background: linear-gradient(180deg, #e4e5e7 0%, #aeb1b5 100%); padding: 12px 15px; display: flex; flex-direction: column; gap: 10px; flex: 1; pointer-events: auto; }
.music-row { display: flex; align-items: center; justify-content: space-between; width: 100%; gap: 10px; }
.music-row.sliders { gap: 8px; }

.sansui-push-btn {
    background: linear-gradient(180deg, #1a1a1a 0%, #050505 100%); color: #ccc;
    border: none; border-top: 1px solid #333; border-left: 1px solid #222;
    border-bottom: 2px solid #000; border-right: 2px solid #000;
    padding: 2px 16px; font-size: 12px; box-shadow: 2px 2px 4px rgba(0,0,0,0.8), inset 1px 1px 1px rgba(255,255,255,0.1);
    cursor: pointer; transition: all 0.05s; height: 22px; display: flex; align-items: center; justify-content: center;
}
.sansui-push-btn:active, .sansui-push-btn.active, .sansui-push-btn.looping, .sansui-push-btn.active-loop {
    background: #000; transform: translate(1px, 1px);
    border-top: 2px solid #000; border-left: 2px solid #000; border-bottom: 1px solid #222; border-right: 1px solid #222;
    box-shadow: inset 2px 2px 5px rgba(0,0,0,0.9); color: #888;
}
.sansui-push-btn.looping { color: #e74c3c; text-shadow: 0 0 5px #e74c3c; }
.sansui-push-btn.active-loop { color: #f1c40f; text-shadow: 0 0 5px #f1c40f; }

.sansui-tiny-btn { width: 14px; height: 14px; border-radius: 50%; background: #111; border: 1px solid #000; box-shadow: inset 1px 1px 2px #444, -1px -1px 2px rgba(0,0,0,0.5); padding: 0; transition: 0.1s; cursor: pointer;}
.sansui-tiny-btn.active { background: #e74c3c; box-shadow: inset -1px -1px 2px #e74c3c, 0 0 5px #e74c3c, inset 1px 1px 2px rgba(0,0,0,0.5); }

.trim-icon-container { position: relative; width: 30px; height: 16px; margin: auto; display: flex; align-items: center; justify-content: center; transform: scale(0.85); }
.trim-waveform { position: absolute; width: 100%; height: 100%; z-index: 1; }
.trim-region { position: absolute; top: 2px; bottom: 2px; left: 6px; right: 6px; background-color: rgba(241, 196, 15, 0.25); z-index: 2; }
.trim-start-bar, .trim-end-bar { position: absolute; width: 2px; height: 14px; background-color: #f1c40f; top: 2px; z-index: 3; }
.trim-start-bar { left: 6px; } .trim-end-bar { right: 6px; }
.trim-start-bar::before, .trim-start-bar::after, .trim-end-bar::before, .trim-end-bar::after { content: ''; position: absolute; width: 4px; height: 4px; background-color: #f1c40f; border-radius: 50%; left: -1px; }
.trim-start-bar::before, .trim-end-bar::before { top: -2px; } .trim-start-bar::after, .trim-end-bar::after { bottom: -2px; }

#vu-meter-container { display: flex; align-items: center; justify-content: center; gap: 3px; background: #080808; padding: 6px 10px; border-radius: 4px; border: 2px solid #111; border-top: 2px solid #000; border-bottom: 2px solid #222; box-shadow: inset 0 4px 10px rgba(0,0,0,0.9), 0 0 20px rgba(255,0,0,0.2); flex: 1; height: 30px; box-sizing: border-box; width: 240px; }
.vu-seg { opacity: 0.15; transition: opacity 0.03s ease; box-shadow: inset 0 0 2px rgba(0,0,0,0.8); }
.vu-seg.active { opacity: 1; }
.vu-center { width: 14px; height: 4px; background: #e74c3c; box-shadow: 0 0 10px #e74c3c; border-radius: 1px; }
.vu-r { width: 12px; height: 6px; background: #e74c3c; box-shadow: 0 0 10px #e74c3c; border-radius: 1px; }
.vu-y { width: 14px; height: 10px; background: #f1c40f; box-shadow: 0 0 10px #f1c40f; border-radius: 1px; }
.vu-g { width: 16px; height: 14px; background: #2ecc71; box-shadow: 0 0 10px #2ecc71; border-radius: 1px; }
.vu-b { width: 18px; height: 18px; background: #3498db; box-shadow: 0 0 10px #3498db; border-radius: 1px; }

.slider-group { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; flex: 1; }
.slider-group label { font-size: 8px; color: #222; text-transform: uppercase; font-weight: 900; display: flex; justify-content: space-between; width: 100%; letter-spacing: 0.5px;}
.slider-group span { color: #820; font-family: monospace; font-size: 9px; text-shadow: none; font-weight: bold;}
.slider-notch { position: absolute; width: 2px; height: 8px; background: #080808; border-right: 1px solid #333; bottom: 4px; z-index: 0; pointer-events: none; }
input[type=range].silver-slider { -webkit-appearance: none; width: 100%; background: transparent; z-index: 2; position: relative; }
input[type=range].silver-slider:focus { outline: none; }
input[type=range].silver-slider::-webkit-slider-runnable-track { width: 100%; height: 6px; cursor: pointer; background: #080808; border-radius: 1px; border: 1px solid #111; border-bottom: 1px solid #444; box-shadow: inset 0 2px 4px rgba(0,0,0,0.9), 0 1px 0 rgba(255,255,255,0.5); }
input[type=range].silver-slider::-webkit-slider-thumb { border: 1px solid #222; height: 16px; width: 12px; border-radius: 2px; background: linear-gradient(to right, #ccc 0%, #fff 20%, #888 50%, #fff 80%, #ccc 100%); box-shadow: -2px 0px 4px rgba(0,0,0,0.8), inset 0px 0px 1px rgba(0,0,0,0.8); cursor: pointer; -webkit-appearance: none; margin-top: -6px;  }
.stacked-sliders { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.stacked-sliders .slider-group { gap: 0; }
.stacked-sliders input[type=range].silver-slider::-webkit-slider-thumb { height: 12px; margin-top: -3px; }
.stacked-sliders label { font-size: 7px; }

.sansui-knob { position: relative; border-radius: 50%; background: #111; border: 1px solid #000; box-shadow: 2px 2px 3px rgba(0,0,0,0.5), inset 1px 1px 1px rgba(255,255,255,0.1); transition: all 0.1s; cursor: ns-resize; display: block; }
.sansui-knob.big-black { width: 48px; height: 48px; background: linear-gradient(135deg, #222 0%, #000 100%); border: 2px solid #111; }
#vol-knob { width: 40px; height: 40px; margin-right: 5px; }

#music-player-ui { transition: filter 0.5s ease-in-out; }