body {
    margin: 0;
    background-image: url("./BACKGROUNDS/bg_space_dark.png");
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    font-family: sans-serif;
    overflow: hidden;
}

.window {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border: 3px solid #000000;
    border-radius: 10px;
    box-sizing: border-box;
}

.welcome {
    width: 60vw;
    max-width: 800px;
    padding: 3vw;
    text-align: center;
    background-color: #ffffff;
    z-index: 10;
}

.terminal {
    width: 65vw;
    height: 65vh;
    max-width: 900px;
    max-height: 700px;
    min-width: min(500px, 85vw);
    min-height: min(400px, 75vh);
    padding: 2.5vw;
    background-color: #0a0a0a;
    color: #00ff41;
    font-family: monospace;
    text-align: left;
    z-index: 11;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    overflow: hidden;
}

.clock {
    width: 50vw;
    max-width: 700px;
    padding: 3vw;
    background-color: #1a1a1a;
    color: #e5e5e5;
    text-align: center;
    z-index: 12;
}

.settings {
    width: 50vw;
    max-width: 700px;
    padding: 3vw;
    background-color: #1a1a1a;
    color: #e5e5e5;
    text-align: left;
    z-index: 13;
}

.settings h2 {
    margin-top: 0;
    font-size: clamp(1.3rem, 2vw, 2rem);
}

.setting {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 0;
    font-size: clamp(1rem, 1.3vw, 1.5rem);
    font-weight: bold;
}

.setting-description {
    color: #999999;
    font-size: 0.9rem;
}

.switch {
    position: relative;
    display: inline-block;
    width: 55px;
    height: 30px;
    flex-shrink: 0;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background-color: #555555;
    border-radius: 30px;
    transition: 0.2s;
}

.slider:before {
    content: "";
    position: absolute;
    width: 22px;
    height: 22px;
    left: 4px;
    bottom: 4px;
    background-color: #e5e5e5;
    border-radius: 50%;
    transition: 0.2s;
}

.switch input:checked + .slider {
    background-color: #2d2580;
}

.switch input:checked + .slider:before {
    transform: translateX(25px);
}

h1 {
    color: #121e2b;
    font-size: 50px;
    margin-bottom: 20px;
}

.welcome img {
    width: 50%;
    height: auto;
    max-height: 30vh;
    object-fit: contain;
    display: block;
    margin: 0 auto 20px auto;
}

a {
    color: blue;
    font-weight: bold;
    font-size: clamp(1rem, 1.5vw, 2rem);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.topbar {
    width: 100%;
    color: #ffffff;
    font-family: sans-serif;
    font-size: clamp(0.8rem, 1vw, 1.2rem);
    font-weight: bold;
    display: flex;
    justify-content: space-around;
    align-items: center;
    position: relative;
    z-index: 100;
}

.windowheader {
    color: #000000;
    background-color: #e5e5e5;
    margin: -3vw -3vw 2vw -3vw;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: sans-serif;
    font-size: clamp(0.8rem, 1vw, 1.2rem);
    font-weight: bold;
    border-bottom: 3px solid #000000;
    border-radius: 7px 7px 0 0;
    cursor: grab;
    user-select: none;
    flex: 0 0 auto;
    min-height: 45px;
    box-sizing: border-box;
}

.windowheader p {
    margin: 15px 0;
}

.windowheader p:last-child {
    cursor: pointer;
    padding: 10px 15px;
    margin: 0;
}

.windowheader p:last-child:hover {
    background-color: #e81123;
    color: #ffffff;
}

.terminal .windowheader {
    margin: -2.5vw -2.5vw 2vw -2.5vw;
    color: #00ff41;
    background-color: #1a1a1a;
    font-family: monospace;
    border-bottom: 3px solid #00ff41;
}

.clock .windowheader {
    margin: -3vw -3vw 2vw -3vw;
    color: #e5e5e5;
    background-color: #000000;
    border-bottom: 3px solid #000000;
}

.settings .windowheader {
    margin: -3vw -3vw 2vw -3vw;
    color: #e5e5e5;
    background-color: #000000;
    border-bottom: 3px solid #000000;
}

#desktopApps {
    position: absolute;
    top: 8%;
    left: 1.5%;
    width: auto;
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 67px;
    text-align: center;
    z-index: 1;
}

.desktop-app {
    width: 90px;
    height: 110px;
    padding: 10px 5px;
    margin-bottom: 10px;
    border-radius: 10px;
    cursor: pointer;
    box-sizing: border-box;
}

.desktop-app.app-selected {
    background-color: rgba(255, 255, 255, 0.3);
}

.app-icons {
    width: 70px;
    height: 70px;
    object-fit: contain;
    border-radius: 15px;
    display: block;
    margin: 0 auto;
    border: 2px solid #ffffff;
}

.app-texts {
    color: #ffffff;
    font-family: sans-serif;
    font-size: 14px;
    font-weight: bold;
    text-align: center;
    margin: 5px 0 0 0;
}

#terminalwindow,
#clockwindow,
#settingswindow {
    display: none;
}

#terminaloutput {
    color: #00ff41;
    font-family: monospace;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: break-word;
    flex: 1 1 auto;
    min-height: 0;
    min-width: 0;
    overflow-y: auto;
    overflow-x: hidden;
    line-height: 1.4;
    font-size: clamp(0.7rem, 0.9vw, 1.2rem);
}

#terminaloutput div {
    max-width: 100%;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.terminal-input-line {
    width: 100%;
    display: flex;
    align-items: center;
    flex-shrink: 0;
    min-width: 0;
    font-family: monospace;
    color: #00ff41;
    margin-top: 10px;
}

.prompt {
    color: #00ff41;
    margin-right: 8px;
    white-space: nowrap;
    flex-shrink: 0;
    font-size: clamp(0.7rem, 0.9vw, 1.2rem);
}

#terminalinput {
    flex: 1 1 auto;
    width: 0;
    min-width: 0;
    background-color: transparent;
    border: none;
    outline: none;
    color: #00ff41;
    font-family: monospace;
    font-size: clamp(0.7rem, 0.9vw, 1.2rem);
}

#clockdisplay {
    color: #e5e5e5;
    font-family: monospace;
    font-size: clamp(2rem, 5vw, 6rem);
    font-weight: bold;
    padding: 30px 0;
}

#desktop-app-bar {
    position: fixed;
    bottom: 2%;
    left: 50%;
    transform: translateX(-50%);
    width: auto;
    height: auto;
    padding: 10px 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background-color: rgba(20, 20, 20, 0.85);
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-radius: 18px;
    backdrop-filter: blur(10px);
    z-index: 200;
    box-sizing: border-box;
}

.desktop-app-bar-icons {
    width: 55px;
    height: 55px;
    object-fit: contain;
    border-radius: 12px;
    cursor: pointer;
    transition: transform 0.15s ease;
}

.desktop-app-bar-icons:hover {
    transform: scale(1.12);
}

@media (max-width: 700px) {
    .welcome {
        width: 90vw;
        padding: 5vw;
    }

    .terminal {
        width: 90vw;
        height: 70vh;
        min-width: 0;
        min-height: 0;
        padding: 5vw;
    }

    .clock {
        width: 85vw;
        padding: 5vw;
    }

    .settings {
        width: 85vw;
        padding: 5vw;
    }

    .windowheader {
        margin: -5vw -5vw 3vw -5vw;
    }

    .terminal .windowheader {
        margin: -5vw -5vw 3vw -5vw;
    }

    .clock .windowheader {
        margin: -5vw -5vw 3vw -5vw;
    }

    .settings .windowheader {
        margin: -5vw -5vw 3vw -5vw;
    }

    #desktopApps {
        left: 2vw;
        width: 75px;
    }

    .desktop-app {
    width: 90px;
    height: 110px;
    padding: 10px 5px;
    margin-bottom: 0;
    border-radius: 10px;
    cursor: pointer;
    box-sizing: border-box;
    }

    .app-icons {
        width: 55px;
        height: 55px;
    }

    .app-texts {
        font-size: 12px;
    }

    #desktop-app-bar {
        bottom: 2%;
        padding: 8px 12px;
        gap: 8px;
        border-radius: 15px;
    }

    .desktop-app-bar-icons {
        width: 45px;
        height: 45px;
    }
}

.wallpaper-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-top: 12px;
}

.wallpaper-option {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 8px;
    color: #e5e5e5;
    background: #252525;
    border: 2px solid #555;
    border-radius: 8px;
    font: inherit;
    cursor: pointer;
    text-align: center;
}

.wallpaper-option:hover {
    background: #353535;
    border-color: #aaa;
}

.wallpaper-option.active {
    border-color: #00ff41;
}

.wallpaper-preview {
    display: block;
    width: 100%;
    aspect-ratio: 16 / 9;
    border-radius: 4px;
    background-size: cover;
    background-position: center;
}

.dark-wallpaper {
    background-image: url("./WALLPAPERS/bg_space_dark.png");
}

.light-wallpaper {
    background-image: url("./WALLPAPERS/bg_space_light.png");
}

@media (max-width: 500px) {
    .wallpaper-grid {
        grid-template-columns: 1fr;
    }
}

/* For 1920x1080 displays */
@media (min-width: 1600px) and (max-width: 2200px) and (max-height: 1200px) {
    .welcome {
        width: 52vw;
        padding: 2.5vw;
    }

    .terminal {
        width: 58vw;
        height: 60vh;
        padding: 2vw;
    }

    .clock,
    .settings {
        width: 44vw;
        padding: 2.5vw;
    }

    #desktopApps {
        gap: 45px;
    }

    .desktop-app {
        width: 80px;
        height: 100px;
    }

    .app-icons {
        width: 60px;
        height: 60px;
    }

    #desktop-app-bar {
        gap: 9px;
        padding: 8px 12px;
    }

    .desktop-app-bar-icons {
        width: 48px;
        height: 48px;
    }
}

.nexdraw {
    display: none;
    flex-direction: column;
    width: 82vw;
    height: 80vh;
    max-width: 1250px;
    max-height: 900px;
    min-width: min(320px, 92vw);
    min-height: min(300px, 75vh);
    padding: 0;
    overflow: hidden;
    background: #d4d0c8;
    color: #111;
    z-index: 14;
}

.nexdraw .nexdraw-header {
    flex: 0 0 auto;
    margin: 0;
    border-radius: 5px 5px 0 0;
}

.nexdraw-toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px;
    background: #777;
    border-bottom: 2px solid #777;
    font-size: 13px;
    flex: 0 0 auto;
}

.nexdraw-toolbar button,
.nexdraw-toolbar select {
    min-height: 30px;
    padding: 4px 8px;
    color: #111;
    background: #fff;
    border: 1px solid #888;
    border-radius: 5px;
    cursor: pointer;
    font: inherit;
}

.nexdraw-toolbar button:hover {
    background: #ddd;
}

.nexdraw-toolbar input[type="range"] {
    width: 85px;
    accent-color: #3478f6;
    cursor: pointer;
}

.color-picker-wrap {
    position: relative;
}

.color-current-button {
    display: flex;
    align-items: center;
    gap: 7px;
    min-height: 34px;
    padding: 5px 9px;
    border: 1px solid #aaa;
    border-radius: 7px;
    background: #fff;
    color: #222;
    cursor: pointer;
}

#drawcolorpreview {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 1px solid #888;
    border-radius: 5px;
    background: #000;
}

.color-panel {
    position: absolute;
    top: calc(100% + 9px);
    left: 0;
    z-index: 999;
    width: 270px;
    padding: 14px;
    background: #fff;
    color: #222;
    border: 1px solid #ddd;
    border-radius: 13px;
    box-shadow: 0 12px 35px rgba(0, 0, 0, .3);
    box-sizing: border-box;
}

.color-panel[hidden] {
    display: none;
}

.color-panel-heading {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    font-size: 15px;
}

.color-panel-heading button {
    min-height: 28px;
    width: 28px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: #eee;
    font-size: 20px;
}

.color-preview-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
}

#drawcolorlargepreview {
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    border: 1px solid #ddd;
    border-radius: 10px;
    background: #000;
}

.color-preview-row strong,
.color-preview-row small {
    display: block;
}

.color-preview-row small {
    margin-top: 3px;
    color: #777;
    font-size: 11px;
}

.picker-label {
    display: block;
    margin: 12px 0 6px;
    color: #555;
    font-size: 12px;
    font-weight: 600;
}

.color-saturation {
    position: relative;
    width: 100%;
    height: 145px;
    overflow: hidden;
    border-radius: 8px;
    background-color: red;
    background-image:
        linear-gradient(to top, #000, transparent),
        linear-gradient(to right, #fff, transparent);
    cursor: crosshair;
    touch-action: none;
}

#drawsvcursor {
    position: absolute;
    top: 0;
    left: 100%;
    width: 14px;
    height: 14px;
    border: 2px solid #fff;
    border-radius: 50%;
    box-shadow: 0 0 0 1px #222;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

#drawhue {
    display: block;
    width: 100%;
    margin: 7px 0;
    height: 18px;
    background: linear-gradient(to right,
        #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00);
    border-radius: 10px;
    appearance: none;
}

#drawhue::-webkit-slider-thumb {
    appearance: none;
    width: 14px;
    height: 20px;
    border: 2px solid white;
    border-radius: 5px;
    background: #333;
    box-shadow: 0 0 2px #000;
}

#drawhue::-moz-range-thumb {
    width: 12px;
    height: 18px;
    border: 2px solid white;
    border-radius: 5px;
    background: #333;
    box-shadow: 0 0 2px #000;
}

.hex-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 6px;
    border: 1px solid #ddd;
    border-radius: 7px;
    background: #fafafa;
}

.hex-row > span {
    color: #777;
    font-weight: bold;
}

.hex-row input {
    flex: 1;
    min-width: 0;
    width: 0;
    border: 0;
    outline: none;
    background: transparent;
    color: #222;
    font: 13px monospace;
    text-transform: uppercase;
}

.hex-row button {
    min-height: 27px;
    padding: 4px 8px;
    background: #3478f6;
    color: #fff;
    border: 0;
    border-radius: 5px;
    font-size: 12px;
}

.hex-row button:hover {
    background: #245fca;
}

.palette-heading {
    margin: 14px 0 8px;
    color: #555;
    font-size: 12px;
    font-weight: 600;
}

.color-palette {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 7px;
}

.color-palette button {
    width: 23px;
    height: 23px;
    min-height: 23px;
    padding: 0;
    border: 2px solid #ddd;
    border-radius: 7px;
    background: var(--swatch);
    cursor: pointer;
}

.color-palette button:hover {
    transform: scale(1.12);
    border-color: #555;
}

.color-palette button.active {
    outline: 2px solid #3478f6;
    outline-offset: 2px;
}

.nexdraw-canvas-area {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    overflow: auto;
    display: flex;
    align-items: flex-start;
    justify-content: flex-start;
    padding: 12px;
    background: #777;
}

#drawcanvas {
    display: block;
    flex: 0 0 auto;
    width: 100%;
    height: auto;
    max-width: 1200px;
    background: #fff;
    box-shadow: 0 1px 5px #333;
    touch-action: none;
    cursor: crosshair;
}

@media (max-width: 700px) {
    .nexdraw {
        width: 94vw;
        height: 82vh;
        min-width: 0;
        min-height: 0;
    }

    .nexdraw-toolbar {
        gap: 5px;
        padding: 6px;
    }

    .nexdraw-toolbar button,
    .nexdraw-toolbar select {
        font-size: 12px;
        padding: 3px 5px;
    }

    .nexdraw-toolbar input[type="range"] {
        width: 60px;
    }

    .nexdraw-canvas-area {
        padding: 6px;
    }

    .color-panel {
        width: min(270px, 82vw);
    }
}
