:root {
    --menu-height: 30px;
    --dock-height: 70px;
    --bg-grey: #1a1a1a;
    --accent-blue: #007aff;
    --apple-music-red: #fa233b;
    --limewire-green: #32cd32;
    --terminal-bg: #0c0c0c;
    --dock-item-size: 48px;
    --dock-gap: 10px;
    --dock-padding: 8px 12px;

    /* Desktop Icon Variables */
    --icon-width: 85px;
    --folder-width: 50px;
    --folder-height: 40px;
    --folder-tab-width: 20px;
    --folder-tab-height: 8px;
    --folder-tab-top: -5px;
    --mp3-width: 38px;
    --mp3-height: 48px;
    --icon-font-size: 11px;
}

@media (max-width: 640px) {
    :root {
        --menu-height: 26px;
        --menu-font-size: 11px;
        --dock-item-size: 36px;
        --dock-gap: 6px;
        --dock-padding: 6px 8px;

        /* Smaller mobile icons */
        --icon-width: 68px;
        --folder-width: 38px;
        --folder-height: 30px;
        --folder-tab-width: 15px;
        --folder-tab-height: 6px;
        --folder-tab-top: -4px;
        --mp3-width: 28px;
        --mp3-height: 36px;
        --icon-font-size: 9.5px;
    }
    .menu-left .menu-item:nth-child(4) { display: none; }
}

@media (max-width: 385px) {
    :root {
        --dock-item-size: 30px;
        --dock-gap: 4px;
        --dock-padding: 4px 6px;

        /* Super small screens */
        --icon-width: 58px;
        --folder-width: 32px;
        --folder-height: 26px;
        --folder-tab-width: 12px;
        --folder-tab-height: 5px;
        --folder-tab-top: -3px;
        --mp3-width: 24px;
        --mp3-height: 30px;
        --icon-font-size: 8.5px;
    }
}

@keyframes mesh-move {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

body, html {
    margin: 0; padding: 0; height: 100%; overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    user-select: none; background-color: #121212;
    /* Base text color for the whole dark OS shell — without this, any element that forgets an
       explicit text-white/color rule silently falls back to the browser's default black text,
       which is invisible against this dark background. The light-themed Finder popup overrides
       this locally with its own explicit colors. */
    color: rgba(255, 255, 255, 0.92);
    touch-action: none;
}

#desktop {
    width: 100vw; height: 100vh;
    background: linear-gradient(-45deg, #151515, #222225, #12161f, #1a151e);
    background-size: 400% 400%;
    animation: mesh-move 20s ease infinite;
    position: relative; overflow: hidden;
}

#desktop::before {
    content: ""; position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    opacity: 0.04; pointer-events: none; z-index: 1;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
}

/* Menu Bar Styling */
#menubar {
    height: var(--menu-height); width: 100%;
    background: rgba(20, 20, 20, 0.75); backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px); display: flex; align-items: center;
    justify-content: space-between; padding: 0 12px; color: rgba(255, 255, 255, 0.95);
    font-size: var(--menu-font-size); position: absolute; top: 0;
    z-index: 9999; border-bottom: 0.5px solid rgba(255, 255, 255, 0.1);
}

.menu-left, .menu-right { display: flex; align-items: center; }
.menu-item { padding: 0 10px; height: var(--menu-height); display: flex; align-items: center; cursor: default; position: relative; }
.menu-item:active, .menu-item.active { background: rgba(255, 255, 255, 0.15); border-radius: 4px; }

.dropdown {
    position: absolute; top: var(--menu-height); left: 0;
    background: rgba(30, 30, 30, 0.98); backdrop-filter: blur(40px);
    min-width: 200px; border-radius: 6px; box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    padding: 5px; display: none; flex-direction: column;
    border: 0.5px solid rgba(255, 255, 255, 0.15); z-index: 9001;
}
.menu-item.active .dropdown { display: flex; }
.dropdown-item { padding: 6px 12px; border-radius: 4px; color: white; font-size: 13px; cursor: pointer; }
.dropdown-item:hover { background: var(--accent-blue); }

/* Desktop Icon Layout styling */
.desktop-icon { position: absolute; width: var(--icon-width); display: flex; flex-direction: column; align-items: center; cursor: default; z-index: 10; }
.icon-name { margin-top: 5px; color: white; font-size: var(--icon-font-size); text-shadow: 0 1px 3px rgba(0,0,0,1); padding: 2px 5px; border-radius: 3px; text-align: center; width: 100%; line-height: 1.2; background: rgba(0,0,0,0.45); backdrop-filter: blur(10px); font-weight: 500; border: 0.5px solid rgba(255, 255, 255, 0.05); }

/* Dock Styling */
#dock-container { position: absolute; bottom: 15px; left: 50%; transform: translateX(-50%); z-index: 9500; width: auto; max-width: 98vw; }
/* The scroll safety net lives on this separate wrapper (not #dock itself) with generous extra
   padding, because `overflow-x: auto` forces `overflow-y` to also become `auto` (per spec, you
   can't mix visible+auto on the two axes) — without the padding, that clips the hover pop-out
   (translateY + scale) on every icon. #dock keeps overflow:visible so nothing gets cut off. */
#dock-scroll {
    max-width: 100%; overflow-x: auto; overflow-y: visible;
    -webkit-overflow-scrolling: touch; touch-action: pan-x;
    /* 65px covers both the hover pop-out (translateY -12px + scale growth) and the tooltip
       label, which sits 50px above the icon via .dock-item::after. */
    padding: 65px 4px 12px; margin: -65px -4px -12px;
}
#dock-scroll::-webkit-scrollbar { display: none; }
#dock {
    background: rgba(255, 255, 255, 0.12); backdrop-filter: blur(45px); -webkit-backdrop-filter: blur(45px);
    padding: var(--dock-padding); border-radius: 24px; display: flex; align-items: center; gap: var(--dock-gap);
    border: 0.5px solid rgba(255, 255, 255, 0.15); box-shadow: 0 15px 40px rgba(0,0,0,0.5);
    width: max-content;
}
.dock-item { width: var(--dock-item-size); height: var(--dock-item-size); border-radius: calc(var(--dock-item-size) * 0.25); display: flex; align-items: center; justify-content: center; background: #fff; flex-shrink: 0; cursor: pointer; transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275); position: relative; overflow: visible; }
.dock-item:hover { transform: translateY(-12px) scale(1.25); }

/* Premium Dock Icon Styles */
.dock-item.app-instagram { background: linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%) !important; box-shadow: 0 4px 12px rgba(220, 39, 67, 0.3); }
.dock-item.app-youtube { background: linear-gradient(135deg, #ff4b4b, #ff0000) !important; box-shadow: 0 4px 12px rgba(255, 0, 0, 0.35); }
.dock-item.app-music { background: linear-gradient(135deg, #ff2d55, #fa233b) !important; box-shadow: 0 4px 12px rgba(250, 35, 59, 0.35); }
.dock-item.app-photos { background: #ffffff !important; box-shadow: 0 4px 12px rgba(255, 255, 255, 0.15); }
.dock-item.app-game { background: linear-gradient(135deg, #3a3d40, #181719) !important; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4); }
.dock-item.app-limewire { background: #132b13 !important; box-shadow: 0 4px 12px rgba(34, 139, 34, 0.3); }
.dock-item.app-spotify { background: #1DB954 !important; box-shadow: 0 4px 12px rgba(29, 185, 84, 0.35); }
.dock-item.app-mail { background: linear-gradient(135deg, #4dabf7, #1864ab) !important; box-shadow: 0 4px 12px rgba(24, 100, 171, 0.35); }

.dock-item img { width: 100%; height: 100%; object-fit: contain; padding: 2px; }
.dock-item::after { content: attr(data-label); position: absolute; top: -50px; background: rgba(0,0,0,0.85); color: white; font-size: 11px; padding: 5px 12px; border-radius: 6px; opacity: 0; pointer-events: none; transition: opacity 0.2s; white-space: nowrap; border: 0.5px solid rgba(255,255,255,0.1); }
.dock-item:hover::after { opacity: 1; }
.active-dot { position: absolute; bottom: -8px; width: 4px; height: 4px; border-radius: 50%; background: rgba(255,255,255,0.7); display: none; }

/* Window Styling */
.mac-window { position: absolute; top: 12%; left: 8vw; width: 85vw; height: 70%; max-width: 900px; max-height: 600px; background: #161616; border-radius: 12px; box-shadow: 0 40px 80px rgba(0,0,0,0.85); border: 0.5px solid rgba(255, 255, 255, 0.12); display: none; flex-direction: column; overflow: hidden; z-index: 5000; }
@media (max-width: 640px) {
    .mac-window {
        top: 40px !important;
        left: 4vw !important;
        width: 92vw !important;
        height: calc(100vh - 140px) !important;
        max-height: none !important;
        /* Some windows (LimeWire, Upload, Finder popup) center themselves with
           left:50%+transform:translateX(-50%) — without resetting transform here too,
           that leftover translate compounds with the forced `left` above and pushes
           them off-screen to the left. */
        transform: none !important;
    }
}
.window-header { height: 42px; display: flex; align-items: center; padding: 0 16px; background: rgba(255, 255, 255, 0.04); flex-shrink: 0; cursor: move; border-bottom: 0.5px solid rgba(255,255,255,0.05); }
.dot { width: 12px; height: 12px; border-radius: 50%; margin-right: 8px; cursor: pointer; transition: filter 0.1s; }
.dot:hover { filter: brightness(1.2); }
.dot-red { background: #ff5f57; }
.dot-yellow { background: #febc2e; }
.dot-green { background: #28c840; }
.window-title { flex: 1; text-align: center; font-size: 13px; font-weight: 700; color: white; opacity: 0.6; }

.resize-handle {
    position: absolute; right: 0; bottom: 0; width: 20px; height: 20px;
    cursor: nwse-resize; z-index: 20; touch-action: none;
    background:
        linear-gradient(135deg, transparent 0 40%, rgba(255,255,255,0.3) 40% 46%, transparent 46% 56%, rgba(255,255,255,0.3) 56% 62%, transparent 62% 72%, rgba(255,255,255,0.3) 72% 78%, transparent 78%);
}
@media (max-width: 640px) {
    .resize-handle { display: none; }
}

/* Apple Music Polish */
.music-app { display: flex; flex: 1; height: 100%; overflow: hidden; background: #111; flex-direction: row; }
.music-sidebar { width: 180px; background: rgba(0,0,0,0.45); border-right: 1px solid rgba(255,255,255,0.05); padding: 20px 10px; display: flex; flex-direction: column; gap: 2px; }
@media (max-width: 768px) { .music-sidebar { display: none; } }
.sb-item { padding: 8px 12px; border-radius: 6px; font-size: 13px; color: rgba(255,255,255,0.65); cursor: pointer; transition: background 0.2s; }
.sb-item:hover { background: rgba(255,255,255,0.05); }
.sb-item.active { background: rgba(255,255,255,0.1); color: white; font-weight: 600; }

/* Mobile replacement for the sidebar nav (which is display:none below 768px) — without this,
   phones have no way to reach Browse/Radio/Albums/Songs/Videos/Upload at all. */
.music-mobile-tabs { display: none; }
@media (max-width: 768px) {
    .music-mobile-tabs {
        display: flex; gap: 6px; overflow-x: auto; padding: 10px 14px;
        background: rgba(0,0,0,0.4); border-bottom: 0.5px solid rgba(255,255,255,0.08);
        position: sticky; top: 0; z-index: 15; -webkit-overflow-scrolling: touch; touch-action: pan-x;
    }
    .music-mobile-tabs::-webkit-scrollbar { display: none; }
}
.mtab {
    flex-shrink: 0; padding: 6px 14px; border-radius: 999px; font-size: 12px; font-weight: 600;
    color: rgba(255,255,255,0.65); background: rgba(255,255,255,0.07); white-space: nowrap; cursor: pointer;
}
.mtab.active { background: rgba(255,255,255,0.18); color: white; }
.music-content { flex: 1; overflow-y: auto; background: linear-gradient(to bottom, #1d1d1f, #111); touch-action: pan-y; }
.view-section { display: none; }
.view-section.active { display: block; }
.music-header { padding: 40px; display: flex; gap: 30px; align-items: flex-end; }
.album-art-huge { width: 180px; height: 180px; background: linear-gradient(135deg, #444, #111); border-radius: 12px; box-shadow: 0 20px 50px rgba(0,0,0,0.6); display: flex; align-items: center; justify-content: center; font-weight: 900; font-size: 40px; color: rgba(255,255,255,0.05); overflow: hidden; }
.album-art-huge img { width: 100%; height: 100%; object-fit: cover; }
.album-back-btn {
    background: rgba(255,255,255,0.08); color: white; font-size: 12px; font-weight: 700;
    padding: 6px 14px; border-radius: 999px; cursor: pointer; transition: background 0.15s;
}
.album-back-btn:hover { background: rgba(255,255,255,0.16); }
.grid-art img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }
.video-player-large { width: 100%; max-width: 720px; aspect-ratio: 16/9; border-radius: 12px; box-shadow: 0 20px 50px rgba(0,0,0,0.6); object-fit: contain; background: #000; display: block; }
.track-video-badge { display: inline-block; margin-left: 6px; color: var(--apple-music-red); font-size: 10px; font-weight: 900; letter-spacing: 0.05em; vertical-align: middle; }
.tracklist { padding: 10px 40px 60px 40px; }
.track-row { display: flex; align-items: center; padding: 12px 0; border-bottom: 0.5px solid rgba(255,255,255,0.05); color: white; font-size: 14px; border-radius: 4px; transition: background 0.1s; cursor: default; }
.track-row.playable:hover { background: rgba(255,255,255,0.08); cursor: pointer; }
.track-row.active { background: rgba(250, 35, 59, 0.12); }
.track-num { width: 45px; text-align: left; color: rgba(255,255,255,0.4); font-size: 13px; padding-left: 10px; }
.track-name { flex: 1; font-weight: 500; color: white !important; }
.track-duration { width: 120px; text-align: right; color: rgba(255,255,255,0.4); font-size: 12px; font-weight: 700; padding-right: 10px; }
.track-artist { color: rgba(255,255,255,0.4); font-weight: 500; font-size: 12px; margin-left: 6px; }
.track-links { display: flex; gap: 6px; flex-shrink: 0; padding: 0 8px; }
.track-platform-link {
    width: 22px; height: 22px; border-radius: 50%; display: flex; align-items: center;
    justify-content: center; flex-shrink: 0; opacity: 0.85; transition: opacity 0.15s, transform 0.15s;
}
.track-platform-link:hover { opacity: 1; transform: scale(1.1); }
.track-platform-link svg { width: 12px; height: 12px; }
.track-delete-btn {
    width: 26px; height: 26px; flex-shrink: 0; display: flex; align-items: center; justify-content: center;
    color: rgba(255,255,255,0.35); font-size: 15px; font-weight: 700; border-radius: 6px; cursor: pointer;
    transition: color 0.15s, background 0.15s;
}
.track-delete-btn:hover { color: #ff5f57; background: rgba(255,95,87,0.12); }

.grid-item { position: relative; cursor: pointer; }
.album-delete-btn {
    position: absolute; top: -6px; right: -6px; width: 20px; height: 20px; border-radius: 50%;
    background: #ff5f57; color: white; font-size: 12px; font-weight: 800; display: flex;
    align-items: center; justify-content: center; cursor: pointer; box-shadow: 0 2px 6px rgba(0,0,0,0.4);
    z-index: 5;
}
.album-delete-btn:hover { filter: brightness(1.1); }

.music-player-bar { height: 75px; background: rgba(25, 25, 25, 0.98); border-top: 1px solid rgba(255,255,255,0.05); display: flex; align-items: center; padding: 0 24px; gap: 14px; flex-shrink: 0; position: relative; }
.play-pause-circle { width: 36px; height: 36px; border-radius: 50%; background: white; color: black; display: flex; align-items: center; justify-content: center; cursor: pointer; z-index: 10; }
.skip-btn { width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; cursor: pointer; z-index: 10; color: rgba(255,255,255,0.7); transition: color 0.15s; }
.skip-btn:hover { color: white; }
.progress-bg { flex: 1; height: 4px; background: rgba(255,255,255,0.1); border-radius: 2px; z-index: 10; }
.progress-fill { width: 0%; height: 100%; background: var(--apple-music-red); border-radius: 2px; transition: width 0.1s linear; }

/* Visualizer Canvas */
#music-visualizer { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; opacity: 0.35; z-index: 1; }

/* Photos App layout */
.photos-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 16px; padding: 24px; flex: 1; overflow-y: auto; background: #141414; touch-action: pan-y; }
.photo-card { background: rgba(255,255,255,0.03); border: 0.5px solid rgba(255,255,255,0.08); border-radius: 8px; aspect-ratio: 1; display: flex; flex-direction: column; overflow: hidden; }
.photo-card img, .photo-card video { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-label { background: rgba(0,0,0,0.8); color: rgba(255,255,255,0.7); font-size: 10px; font-weight: 800; padding: 4px 8px; text-align: center; }

/* Terminal Window */
.terminal-body { flex: 1; background: var(--terminal-bg); padding: 16px; font-family: 'SF Mono', 'Courier New', Courier, monospace; color: #00ff00; overflow-y: auto; font-size: 14px; line-height: 1.6; display: flex; flex-direction: column; cursor: text; touch-action: pan-y; }
.terminal-history { display: flex; flex-direction: column; gap: 4px; }
.terminal-prompt-row { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.terminal-input-hidden { position: absolute; opacity: 0; pointer-events: none; width: 0; height: 0; }

/* Auth styling */
.auth-container { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 15px; padding: 40px; text-align: center; }
.auth-input { background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.2); color: white; padding: 10px 15px; border-radius: 8px; width: 240px; text-align: center; outline: none; font-size: 16px; transition: border-color 0.2s; }
.auth-input:focus { border-color: var(--limewire-green); }
.auth-hint { font-size: 12px; color: rgba(255,255,255,0.4); font-style: italic; }
.auth-btn { background: var(--limewire-green); color: black; font-weight: 800; padding: 8px 25px; border-radius: 6px; cursor: pointer; margin-top: 10px; }

.upload-file-input { color: rgba(255,255,255,0.8); max-width: 240px; }
.upload-file-input::file-selector-button {
    background: rgba(255,255,255,0.12); color: white; border: 0.5px solid rgba(255,255,255,0.2);
    border-radius: 6px; padding: 6px 12px; font-weight: 600; cursor: pointer; margin-right: 8px;
}
.upload-file-input::file-selector-button:hover { background: rgba(255,255,255,0.2); }

/* Stick figure Run Game */
.game-container { flex: 1; display: flex; flex-direction: column; background: #000; overflow: hidden; position: relative; }
#game-canvas { width: 100%; height: 100%; background: #000; display: block; object-fit: contain; }

/* Guidance Arrow */
#hint-arrow {
    position: fixed; width: 18px; height: 18px; z-index: 10000; pointer-events: none; opacity: 0; transition: opacity 0.5s;
    filter: drop-shadow(0 2px 3px rgba(0,0,0,0.4));
}
@keyframes float-arrow { 0% { transform: translateY(0); } 50% { transform: translateY(-8px); } 100% { transform: translateY(0); } }
.floating { animation: float-arrow 1.5s ease-in-out infinite; }

#loading-overlay { position: fixed; inset: 0; background: #000; display: flex; align-items: center; justify-content: center; color: white; z-index: 10000; font-weight: 900; }

/* Finder "About" links popup — light macOS "About This Mac" style, distinct from the dark theme */
.finder-about-window { background: #f4f4f4; }
.finder-about-header { background: transparent; border-bottom: none; }
.finder-about-body {
    flex: 1; display: flex; flex-direction: column; align-items: center; text-align: center;
    justify-content: center; gap: 10px; padding: 4px 30px 28px;
}
.finder-about-portrait img {
    width: 130px; height: 130px; border-radius: 50%; object-fit: cover;
    box-shadow: 0 12px 30px rgba(0,0,0,0.18); border: 6px solid #fff;
    display: block;
}
.finder-about-title { font-size: 26px; font-weight: 800; color: #111; letter-spacing: -0.02em; }
.finder-about-subtitle { font-size: 13px; color: rgba(0,0,0,0.45); margin: 2px 0 10px; font-weight: 500; }
.finder-about-links { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 100%; max-width: 220px; }
.finder-link-row {
    display: flex; align-items: center; gap: 10px; padding: 6px 10px; border-radius: 8px;
    cursor: pointer; text-decoration: none; color: #111; transition: background 0.15s; width: 100%;
}
.finder-link-row:hover { background: rgba(0,0,0,0.06); }
.finder-link-icon {
    width: 24px; height: 24px; border-radius: 7px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center; color: #fff;
}
.finder-link-icon svg { width: 14px; height: 14px; }
.finder-link-label { font-size: 14px; font-weight: 600; }

/* Sleek, OS-matching scrollbars for every scrollable pane */
.music-content, .photos-grid, .terminal-body, .finder-about-links {
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.25) transparent;
}
.music-content::-webkit-scrollbar, .photos-grid::-webkit-scrollbar,
.terminal-body::-webkit-scrollbar, .finder-about-links::-webkit-scrollbar {
    width: 8px; height: 8px;
}
.music-content::-webkit-scrollbar-track, .photos-grid::-webkit-scrollbar-track,
.terminal-body::-webkit-scrollbar-track, .finder-about-links::-webkit-scrollbar-track {
    background: transparent;
}
.music-content::-webkit-scrollbar-thumb, .photos-grid::-webkit-scrollbar-thumb,
.terminal-body::-webkit-scrollbar-thumb, .finder-about-links::-webkit-scrollbar-thumb {
    background-color: rgba(255,255,255,0.2);
    border-radius: 8px;
    border: 2px solid transparent;
    background-clip: padding-box;
}
.music-content:hover::-webkit-scrollbar-thumb, .photos-grid:hover::-webkit-scrollbar-thumb,
.terminal-body:hover::-webkit-scrollbar-thumb, .finder-about-links:hover::-webkit-scrollbar-thumb {
    background-color: rgba(255,255,255,0.35);
}
.music-content::-webkit-scrollbar-corner, .photos-grid::-webkit-scrollbar-corner,
.terminal-body::-webkit-scrollbar-corner, .finder-about-links::-webkit-scrollbar-corner {
    background: transparent;
}
