:root {
    --bg-color: #f3f3f3;
    --taskbar-bg: rgba(243, 243, 243, 0.85);
    --window-bg: rgba(255, 255, 255, 0.9);
    --acrylic-blur: blur(20px) saturate(125%);
    --accent-color: #0078d4;
    --text-color: #222;
    --border-color: rgba(0, 0, 0, 0.1);
    --border-radius: 8px;
    --shadow: 0 10px 30px rgba(0,0,0,0.15);
    --Wallpaper: url('https://images.unsplash.com/photo-1618005182384-a83a8bd57fbe?q=80&w=2564&auto=format&fit=crop');
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg-color: #202020;
        --taskbar-bg: rgba(32, 32, 32, 0.85);
        --window-bg: rgba(40, 40, 40, 0.85);
        --text-color: #eee;
        --border-color: rgba(255, 255, 255, 0.1);
        --shadow: 0 10px 30px rgba(0,0,0,0.5);
    }
}

* { box-sizing: border-box; user-select: none; margin: 0; padding: 0; }
body, html { margin: 0; padding: 0; width: 100%; height: 100%; overflow: hidden; font-family: 'Segoe UI', sans-serif; color: var(--text-color); }
#root { width: 100%; height: 100%; }

#boot-screen {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: #000; z-index: 99999; display: flex; flex-direction: column;
    justify-content: center; align-items: center; color: white; transition: opacity 1s;
}
.spinner {
    border: 4px solid rgba(255, 255, 255, 0.1); width: 50px; height: 50px;
    border-radius: 50%; border-left-color: var(--accent-color);
    animation: spin 1s linear infinite; margin-bottom: 20px;
}
@keyframes spin { 100% { transform: rotate(360deg); } }

#desktop {
    background-image: var(--Wallpaper);
    background-size: cover; background-position: center;
    width: 100vw; height: 100vh; position: fixed; top: 0; left: 0; overflow: hidden;
    transition: transform 0.1s ease-out;
}

#desktop-icons {
    padding: 10px; display: flex; flex-direction: column; gap: 10px; flex-wrap: wrap; height: 90%; width: fit-content;
}

.d-icon {
    width: 80px; text-align: center; padding: 10px 5px; border-radius: 4px;
    cursor: pointer; color: white; text-shadow: 0 1px 4px rgba(0,0,0,0.8);
    transition: background 0.2s; display: flex; flex-direction: column; align-items: center;
}
.d-icon:hover { background: rgba(255,255,255,0.1); }
.d-icon.selected { background: rgba(255,255,255,0.2); border: 1px dotted rgba(255,255,255,0.5); }
.d-icon i { font-size: 32px; margin-bottom: 5px; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5)); }
.d-icon[data-app="file-explorer"] i { color: #ffd66b; }
.d-icon[data-app="edge"] i { color: #00ca7d; }
.d-icon span { font-size: 12px; word-break: break-word; }

#taskbar {
    position: absolute; bottom: 0; left: 0; width: 100%; height: 48px;
    background: var(--taskbar-bg); backdrop-filter: var(--acrylic-blur);
    border-top: 1px solid var(--border-color); display: flex; justify-content: space-between; align-items: center;
    padding: 0 15px; z-index: 10000;
}

.taskbar-center { display: flex; gap: 8px; height: 100%; align-items: center; position:absolute; left: 50%; transform: translateX(-50%); }
.tb-icon {
    width: 40px; height: 40px; border-radius: 4px; display: flex; justify-content: center; align-items: center;
    font-size: 22px; cursor: pointer; transition: all 0.2s; color: var(--text-color); position: relative;
}
.tb-icon:hover { background: rgba(255,255,255,0.1); }
.tb-icon:active { transform: scale(0.9); }
.tb-icon.active::after {
    content: ''; position: absolute; bottom: 2px; width: 16px; height: 3px;
    background: var(--accent-color); border-radius: 2px;
}
#start-btn i { color: #00a2ed; }

.taskbar-right { display: flex; align-items: center; gap: 15px; font-size: 12px; }
#clock { text-align: center; cursor: default;}

#start-menu {
    position: absolute; bottom: 55px; left: 50%; transform: translateX(-50%) translateY(20px);
    width: 600px; height: 600px; background: var(--window-bg);
    backdrop-filter: var(--acrylic-blur); border: 1px solid var(--border-color);
    border-radius: var(--border-radius); box-shadow: var(--shadow);
    padding: 20px; display: none; flex-direction: column; opacity: 0; transition: all 0.2s ease-out; z-index: 10001;
}
#start-menu.open { display: flex; opacity: 1; transform: translateX(-50%) translateY(0); }

.search-bar {
    background: rgba(128,128,128,0.1); border: 1px solid var(--border-color); border-radius: 4px;
    padding: 8px 12px; display: flex; align-items: center; gap: 10px; margin-bottom: 20px;
}
.search-bar input { border: none; background: transparent; outline: none; width: 100%; color: var(--text-color); }

.pinned-apps { display: grid; grid-template-columns: repeat(6, 1fr); gap: 15px; padding: 10px; overflow-y: auto; }
.app-item { display: flex; flex-direction: column; align-items: center; gap: 8px; cursor: pointer; padding: 10px; border-radius: 4px; }
.app-item:hover { background: rgba(255,255,255,0.1); }
.app-item i { font-size: 28px; }
.app-item span { font-size: 11px; text-align: center; }

.window {
    position: absolute; background: var(--window-bg); backdrop-filter: blur(40px);
    border: 1px solid var(--border-color); border-radius: var(--border-radius);
    box-shadow: var(--shadow); display: flex; flex-direction: column; overflow: hidden;
    min-width: 300px; min-height: 200px;
}

.resize-handle {
    position: absolute;
    z-index: 10;
}

.resize-n, .resize-s {
    left: 0;
    right: 0;
    height: 5px;
    cursor: ns-resize;
}

.resize-n { top: 0; }
.resize-s { bottom: 0; }

.resize-e, .resize-w {
    top: 0;
    bottom: 0;
    width: 5px;
    cursor: ew-resize;
}

.resize-e { right: 0; }
.resize-w { left: 0; }

.resize-ne, .resize-nw, .resize-se, .resize-sw {
    width: 10px;
    height: 10px;
}

.resize-ne {
    top: 0;
    right: 0;
    cursor: nesw-resize;
}

.resize-nw {
    top: 0;
    left: 0;
    cursor: nwse-resize;
}

.resize-se {
    bottom: 0;
    right: 0;
    cursor: nwse-resize;
}

.resize-sw {
    bottom: 0;
    left: 0;
    cursor: nesw-resize;
}
@keyframes openWindow { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }
.window.minimized { display: none; }
.window.maximized { top: 0 !important; left: 0 !important; width: 100% !important; height: calc(100% - 48px) !important; border-radius: 0; }

.title-bar {
    height: 32px; display: flex; justify-content: space-between; align-items: center; padding: 0 10px;
    border-bottom: 1px solid var(--border-color); cursor: grab; background: rgba(255,255,255,0.05);
}
.title-bar-text { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 600;}
.window-controls { display: flex; height: 100%; position: relative; z-index: 10; }
.win-btn { width: 40px; height: 100%; display: flex; justify-content: center; align-items: center; cursor: pointer; transition: 0.2s; position: relative;}
.win-btn:hover { background: rgba(128,128,128,0.1); }
.win-btn.close:hover { background: #e81123; color: white; }
.win-btn:active { transform: scale(0.95); }

.window-content { flex: 1; overflow: auto; position: relative; user-select: text; }

textarea.notepad-area { width: 100%; height: 100%; border: none; padding: 10px; resize: none; outline: none; background: transparent; color: var(--text-color); font-family: monospace; }

.terminal { background: #1e1e1e; color: #ccc; font-family: 'Consolas', monospace; padding: 10px; height: 100%; overflow-y: auto; font-size: 14px; }

#bsod { position: fixed; top:0; left:0; width:100%; height:100%; background: #0078d7; color: white; z-index: 100000; padding: 100px; font-family: 'Segoe UI', sans-serif; display: none; flex-direction: column; gap: 20px;}
#bsod h1 { font-size: 100px; font-weight: 100; margin: 0;}
#bsod p { font-size: 24px; }

.app-menu { padding: 5px; border-bottom: 1px solid var(--border-color); font-size: 12px; display: flex; gap: 10px; }
.menu-item { padding: 2px 8px; cursor: pointer; } 
.menu-item:hover { background: rgba(128,128,128,0.1); border-radius: 4px;}

.terminal .term-output { white-space: pre-wrap; }
.terminal .term-input-line { display: flex; margin-top: 5px; }
.terminal .prompt { color: #4caf50; margin-right: 5px; font-weight: bold; }
.terminal .term-input { background: transparent; border: none; color: #fff; outline: none; flex: 1; font-family: inherit; font-size: inherit; }

.fe-container { display: flex; height: 100%; flex-direction: column;}
.fe-toolbar { padding: 8px; border-bottom: 1px solid var(--border-color); display: flex; gap: 10px;}
.fe-path { padding: 4px 10px; border: 1px solid var(--border-color); flex: 1; border-radius: 4px; font-size: 12px; display: flex; align-items: center;}
.fe-body { display: flex; flex: 1; overflow: hidden; }
.fe-sidebar { width: 150px; border-right: 1px solid var(--border-color); padding: 10px; font-size: 13px; }
.fe-sidebar div { padding: 5px; cursor: pointer; border-radius: 4px; display: flex; gap: 8px; align-items: center;}
.fe-sidebar div:hover { background: rgba(128,128,128,0.1); }
.fe-content { flex: 1; padding: 10px; display: grid; grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); grid-auto-rows: min-content; gap: 10px; overflow-y: auto;}
.file-item { display: flex; flex-direction: column; align-items: center; gap: 5px; cursor: pointer; padding: 5px; border-radius: 4px; text-align: center;}
.file-item:hover { background: rgba(128,128,128,0.1); }
.file-item i { font-size: 32px; }
.file-item[data-type="folder"] i { color: #ffd66b; }
.file-item[data-type="txt"] i { color: #aaa; }
.file-item[data-type="js"] i, .file-item[data-type="py"] i { color: #519aba; }
.file-item span { font-size: 11px; word-break: break-all;}

.paint-container { display: flex; flex-direction: column; height: 100%; }
.paint-toolbar { padding: 5px; border-bottom: 1px solid var(--border-color); display: flex; gap: 10px; align-items: center; background: rgba(128,128,128,0.05);}
canvas.paint-canvas { background: #fff; cursor: crosshair; display: block; margin: auto; box-shadow: 0 0 5px rgba(0,0,0,0.2); }
.color-btn { width: 20px; height: 20px; border-radius: 50%; cursor: pointer; border: 1px solid #ccc; }
.color-btn.active { border: 2px solid var(--text-color); transform: scale(1.1); }

.game-container { background: #000; display: flex; justify-content: center; align-items: center; height: 100%; flex-direction: column; color: #0f0; font-family: 'Courier New', Courier, monospace;}
#game-canvas { border: 2px solid #0f0; box-shadow: 0 0 20px #0f0; background: #001100;}
.game-ui { display: flex; justify-content: space-between; width: 400px; margin-bottom: 10px; font-size: 18px; text-shadow: 0 0 5px #0f0;}
.game-over-overlay { position: absolute; top:50%; left:50%; transform: translate(-50%, -50%); text-align: center; display: none;}
.game-over-overlay h1 { font-size: 40px; color: red; text-shadow: 0 0 10px red; margin: 0;}
.neon-btn { border: 1px solid #0f0; color: #0f0; padding: 5px 15px; background: transparent; cursor: pointer; margin-top: 10px; box-shadow: 0 0 5px #0f0; }
.neon-btn:hover { background: #0f0; color: #000; }

.vid-container { display: flex; flex-direction: column; height: 100%; background: #222; color: white; }
.vid-preview { flex: 1; display: flex; justify-content: center; align-items: center; background: #000; position: relative; overflow: hidden;}
.vid-timeline { height: 100px; border-top: 1px solid #444; padding: 10px; display: flex; flex-direction: column; gap: 5px;}
.vid-controls { display: flex; gap: 15px; justify-content: center; padding: 10px; background: #333; }
.trk { height: 30px; background: #4caf50; border-radius: 4px; position: relative; width: 80%; cursor: ew-resize;}
.trk::after { content: 'Clip 1.mp4'; position: absolute; left: 5px; top: 50%; transform: translateY(-50%); font-size: 10px; color: black;}
.playhead { position: absolute; height: 100%; width: 2px; background: red; left: 0; top:0; pointer-events: none;}
#vid-canvas { height: 90%; max-width: 100%; }

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.fe-content.list { display: flex; flex-direction: column; grid-template-columns: none; }
.fe-content.list .file-item { width: 100%; }
.fe-content .file-item.selected { background: rgba(0, 120, 212, 0.2); border: 1px solid var(--accent-color); }
