/* ========================================
   WINDOWS 95 SYSTEM VARIABLES
========================================= */
:root {
    /* Core System Colors */
    --sys-teal: #008080;
    --sys-gray: #c0c0c0;
    --sys-dark: #404040;
    --sys-darker: #000000;
    --sys-light: #dfdfdf;
    --sys-white: #ffffff;

    /* Accent Colors */
    --sys-blue: #000080;
    --sys-highlight: #0000ff;
    --sys-green: #00ff66;
    --sys-error: #ff0000;

    /* Text */
    --text-primary: #000000;
    --text-inverse: #ffffff;

    /* Dynamic Variables (modified by JS) */
    --glitch-intensity: 0;
    --system-lag: 0ms;
    --entropy: 0;
}

/* ========================================
   RESET & BASE
========================================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ========================================
   TYPOGRAPHY - SYSTEM FONTS
========================================= */
@font-face {
    font-family: 'MS Sans Serif';
    src: local('MS Sans Serif'), local('Microsoft Sans Serif'), local('Segoe UI');
}

body {
    font-family: 'MS Sans Serif', 'Segoe UI', system-ui, sans-serif;
    font-size: 11px;
    line-height: 1.4;
    background: var(--sys-teal);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    cursor: default;
}

.mono {
    font-family: 'Courier New', 'IBM Plex Mono', monospace;
}

/* ========================================
   DESKTOP ENVIRONMENT
========================================= */
.desktop {
    position: relative;
    min-height: 100vh;
    padding: 10px;
    padding-bottom: 50px;
}

/* ========================================
   TASKBAR
========================================= */
.taskbar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 28px;
    background: var(--sys-gray);
    border-top: 2px solid var(--sys-white);
    display: flex;
    align-items: center;
    padding: 2px 4px;
    z-index: 9999;
    gap: 4px;
}

.start-button {
    background: var(--sys-gray);
    border: 2px solid;
    border-color: var(--sys-white) var(--sys-dark) var(--sys-dark) var(--sys-white);
    padding: 2px 6px;
    font-weight: bold;
    font-size: 11px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
}

.start-button:active {
    border-color: var(--sys-dark) var(--sys-white) var(--sys-white) var(--sys-dark);
}

.start-icon {
    width: 16px;
    height: 16px;
    background: linear-gradient(135deg, #ff0000 25%, #00ff00 25%, #00ff00 50%, #0000ff 50%, #0000ff 75%, #ffff00 75%);
}

.taskbar-items {
    display: flex;
    gap: 2px;
    flex: 1;
    overflow: hidden;
}

.taskbar-item {
    background: var(--sys-gray);
    border: 2px solid;
    border-color: var(--sys-white) var(--sys-dark) var(--sys-dark) var(--sys-white);
    padding: 2px 8px;
    font-size: 11px;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
}

.taskbar-item.active {
    border-color: var(--sys-dark) var(--sys-white) var(--sys-white) var(--sys-dark);
    background: repeating-linear-gradient(
        90deg,
        var(--sys-gray) 0px,
        var(--sys-gray) 1px,
        var(--sys-white) 1px,
        var(--sys-white) 2px
    );
}

.system-tray {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 8px;
    border-left: 2px solid var(--sys-dark);
    margin-left: auto;
}

.system-clock {
    font-family: 'Courier New', monospace;
    font-size: 11px;
}

.system-status {
    font-size: 9px;
    color: var(--sys-dark);
}

/* ========================================
   WINDOW SYSTEM
========================================= */
.window {
    position: absolute;
    background: var(--sys-gray);
    border: 2px solid;
    border-color: var(--sys-white) var(--sys-dark) var(--sys-dark) var(--sys-white);
    box-shadow: 2px 2px 0 rgba(0,0,0,0.3);
    min-width: 200px;
    min-height: 100px;
    display: flex;
    flex-direction: column;
    transition: transform var(--system-lag), opacity 0.1s;
}

.window.minimized {
    display: none;
}

.window.focused {
    z-index: 100;
}

/* Maximized window */
.window[data-maximized="true"] {
    border-radius: 0;
}

.window[data-maximized="true"] .window-content {
    flex: 1;
    overflow: auto;
}

.window[data-maximized="true"] .window-statusbar {
    flex-shrink: 0;
}

/* ========================================
   FULLSCREEN ENHANCEMENTS
========================================= */
/* Bigger titlebar in fullscreen */
.window[data-maximized="true"] .window-titlebar {
    padding: 6px 12px;
}

.window[data-maximized="true"] .window-title {
    font-size: 14px;
}

.window[data-maximized="true"] .window-btn {
    width: 22px;
    height: 20px;
    font-size: 12px;
}

.window[data-maximized="true"] .window-controls {
    gap: 4px;
}

/* YouTube iframe - preserve aspect ratio in fullscreen */
.window[data-maximized="true"] .media-frame iframe {
    width: 100%;
    max-width: 900px;
    height: auto;
    aspect-ratio: 16 / 9;
    margin: 0 auto;
    display: block;
}

.window[data-maximized="true"] .media-frame {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.window[data-maximized="true"] .media-frame .media-caption {
    width: 100%;
    max-width: 900px;
}

/* Bigger images/videos in fullscreen gallery */
.window[data-maximized="true"] .image-grid {
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
}

.window[data-maximized="true"] .image-frame img,
.window[data-maximized="true"] .media-frame video {
    max-height: 400px;
    object-fit: contain;
    width: 100%;
}

/* Larger menubar in fullscreen */
.window[data-maximized="true"] .window-menubar {
    padding: 4px 0;
}

.window[data-maximized="true"] .menu-item {
    padding: 4px 12px;
    font-size: 12px;
}

/* Larger statusbar in fullscreen */
.window[data-maximized="true"] .window-statusbar {
    padding: 4px 8px 4px 40px;
    font-size: 12px;
    min-height: 28px;
}

/* Shift content away from fisheye edges in fullscreen */
.window[data-maximized="true"] .info-group {
    padding-left: 30px;
}

.window[data-maximized="true"] .sys-list {
    padding-left: 40px;
}

/* Disable fisheye when Paint is open - prevents coordinate issues */
body.paint-open .crt-enabled .desktop {
    transform: none !important;
    filter: contrast(1.1) brightness(1.05);
}

/* Paint canvas bigger in fullscreen */
.window[data-maximized="true"] #paint-canvas {
    width: 800px !important;
    height: 600px !important;
    margin: 0 auto;
}

.window[data-maximized="true"] .paint-canvas-wrapper {
    max-height: none;
    overflow: visible;
    text-align: center;
    padding: 20px 8px;
}

.window-titlebar {
    background: linear-gradient(90deg, var(--sys-blue), #1084d0);
    color: var(--text-inverse);
    padding: 2px 4px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: move;
    user-select: none;
    flex-shrink: 0;
}

.window.unfocused .window-titlebar {
    background: linear-gradient(90deg, #808080, #a0a0a0);
}

.window-title {
    font-size: 11px;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 4px;
}

.window-icon {
    width: 14px;
    height: 14px;
    background: var(--sys-gray);
    border: 1px solid var(--sys-dark);
}

.window-controls {
    display: flex;
    gap: 2px;
}

.window-btn {
    width: 16px;
    height: 14px;
    background: var(--sys-gray);
    border: 2px solid;
    border-color: var(--sys-white) var(--sys-dark) var(--sys-dark) var(--sys-white);
    font-size: 9px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-family: 'Courier New', monospace;
}

.window-btn:active {
    border-color: var(--sys-dark) var(--sys-white) var(--sys-white) var(--sys-dark);
}

.window-menubar {
    background: var(--sys-gray);
    border-bottom: 1px solid var(--sys-dark);
    padding: 2px 0;
    display: flex;
    gap: 0;
    flex-shrink: 0;
}

.menu-item {
    padding: 2px 8px;
    cursor: pointer;
}

.menu-item:hover {
    background: var(--sys-blue);
    color: var(--text-inverse);
}

.window-content {
    flex: 1;
    padding: 8px;
    overflow: auto;
    background: var(--sys-gray);
    min-height: 0; /* Important for flex overflow */
}

.window-content.inset {
    margin: 4px;
    border: 2px solid;
    border-color: var(--sys-dark) var(--sys-white) var(--sys-white) var(--sys-dark);
    background: var(--sys-white);
}

.window-statusbar {
    background: var(--sys-gray);
    border-top: 2px solid;
    border-color: var(--sys-dark) var(--sys-white) var(--sys-white) var(--sys-dark);
    padding: 2px 4px;
    font-size: 10px;
    display: flex;
    gap: 8px;
    flex-shrink: 0;
    min-height: 20px;
    max-height: 24px;
}

.status-section {
    border: 1px solid;
    border-color: var(--sys-dark) var(--sys-white) var(--sys-white) var(--sys-dark);
    padding: 0 4px;
}

/* ========================================
   CONTENT STYLING
========================================= */
.info-group {
    margin-bottom: 12px;
}

.info-label {
    font-weight: bold;
    margin-bottom: 4px;
    border-bottom: 1px solid var(--sys-dark);
    padding-bottom: 2px;
}

.info-line {
    font-family: 'Courier New', monospace;
    font-size: 11px;
    margin: 2px 0;
    padding-left: 8px;
}

.info-line::before {
    content: ">";
    margin-right: 4px;
    color: var(--sys-dark);
}

/* Links as buttons */
a.sys-link {
    display: inline-block;
    background: var(--sys-gray);
    border: 2px solid;
    border-color: var(--sys-white) var(--sys-dark) var(--sys-dark) var(--sys-white);
    padding: 4px 12px;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 11px;
    cursor: pointer;
}

a.sys-link:active {
    border-color: var(--sys-dark) var(--sys-white) var(--sys-white) var(--sys-dark);
}

a.sys-link:hover {
    background: var(--sys-light);
}

/* Lists */
.sys-list {
    list-style: none;
    padding: 0;
}

.sys-list li {
    padding: 2px 0 2px 16px;
    position: relative;
}

.sys-list li::before {
    content: "■";
    position: absolute;
    left: 0;
    font-size: 8px;
}

/* ========================================
   VIDEO & MEDIA
========================================= */
.media-frame {
    border: 2px solid;
    border-color: var(--sys-dark) var(--sys-white) var(--sys-white) var(--sys-dark);
    background: #000;
    margin: 8px 0;
}

.media-frame iframe,
.media-frame video {
    display: block;
    width: 100%;
}

.media-caption {
    background: var(--sys-gray);
    padding: 2px 4px;
    font-size: 10px;
    font-family: 'Courier New', monospace;
    border-top: 1px solid var(--sys-dark);
}

/* ========================================
   IMAGE GRID
========================================= */
.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 8px;
}

.image-item {
    cursor: pointer;
}

.image-frame {
    border: 2px solid;
    border-color: var(--sys-dark) var(--sys-white) var(--sys-white) var(--sys-dark);
    background: var(--sys-gray);
}

.image-frame img {
    display: block;
    width: 100%;
    height: auto;
}

.image-label {
    padding: 2px 4px;
    font-size: 10px;
    font-family: 'Courier New', monospace;
    background: var(--sys-gray);
    border-top: 1px solid var(--sys-dark);
}

/* ========================================
   SPLIT SECTION - GLITCH/UNSTABLE
========================================= */
.split-container {
    position: relative;
    overflow: hidden;
}

.split-glitch {
    position: relative;
}

.split-glitch::before,
.split-glitch::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0.8;
}

.split-glitch::before {
    color: var(--sys-error);
    animation: glitch-1 0.3s infinite;
    clip-path: polygon(0 0, 100% 0, 100% 45%, 0 45%);
}

.split-glitch::after {
    color: var(--sys-green);
    animation: glitch-2 0.3s infinite;
    clip-path: polygon(0 55%, 100% 55%, 100% 100%, 0 100%);
}

@keyframes glitch-1 {
    0%, 100% { transform: translate(0); }
    20% { transform: translate(-2px, 1px); }
    40% { transform: translate(2px, -1px); }
    60% { transform: translate(-1px, 2px); }
    80% { transform: translate(1px, -2px); }
}

@keyframes glitch-2 {
    0%, 100% { transform: translate(0); }
    20% { transform: translate(2px, -1px); }
    40% { transform: translate(-2px, 1px); }
    60% { transform: translate(1px, -2px); }
    80% { transform: translate(-1px, 2px); }
}

.split-noise {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(0, 255, 102, 0.03) 2px,
        rgba(0, 255, 102, 0.03) 4px
    );
    pointer-events: none;
    animation: noise-scroll 0.5s steps(8) infinite;
}

@keyframes noise-scroll {
    0% { transform: translateY(0); }
    100% { transform: translateY(8px); }
}

.split-fragment {
    opacity: 0.7;
    filter: blur(0.5px);
    animation: fragment-flicker 2s infinite;
}

@keyframes fragment-flicker {
    0%, 92%, 100% { opacity: 0.7; }
    93% { opacity: 0.3; }
    94% { opacity: 0.8; }
    95% { opacity: 0.4; }
}

.split-data {
    font-family: 'Courier New', monospace;
    font-size: 9px;
    color: var(--sys-green);
    opacity: 0.6;
    overflow: hidden;
    white-space: nowrap;
}

.split-corrupted {
    position: relative;
    display: inline-block;
}

.split-corrupted::after {
    content: "█████";
    position: absolute;
    top: 0;
    left: 0;
    color: var(--sys-dark);
    animation: corrupt-reveal 4s infinite;
}

@keyframes corrupt-reveal {
    0%, 70% { opacity: 1; }
    75%, 85% { opacity: 0; }
    90%, 100% { opacity: 1; }
}

/* ========================================
   SYSTEM ALERTS & ERRORS
========================================= */
.system-alert {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--sys-gray);
    border: 2px solid;
    border-color: var(--sys-white) var(--sys-dark) var(--sys-dark) var(--sys-white);
    box-shadow: 4px 4px 0 rgba(0,0,0,0.5);
    z-index: 10000;
    min-width: 300px;
    display: none;
}

.system-alert.active {
    display: block;
    animation: alert-shake 0.3s;
}

@keyframes alert-shake {
    0%, 100% { transform: translate(-50%, -50%); }
    25% { transform: translate(-48%, -50%); }
    75% { transform: translate(-52%, -50%); }
}

.alert-content {
    padding: 16px;
    display: flex;
    gap: 16px;
    align-items: flex-start;
}

.alert-icon {
    width: 32px;
    height: 32px;
    background: var(--sys-error);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 20px;
    flex-shrink: 0;
}

.alert-icon.warning {
    background: #ffff00;
    color: #000;
}

.alert-icon.info {
    background: var(--sys-blue);
    color: white;
}

.alert-text {
    flex: 1;
}

.alert-title {
    font-weight: bold;
    margin-bottom: 8px;
}

.alert-message {
    font-size: 11px;
    line-height: 1.5;
}

.alert-buttons {
    padding: 8px 16px 16px;
    display: flex;
    justify-content: center;
    gap: 8px;
}

.alert-btn {
    background: var(--sys-gray);
    border: 2px solid;
    border-color: var(--sys-white) var(--sys-dark) var(--sys-dark) var(--sys-white);
    padding: 4px 24px;
    font-size: 11px;
    cursor: pointer;
    min-width: 75px;
}

.alert-btn:active {
    border-color: var(--sys-dark) var(--sys-white) var(--sys-white) var(--sys-dark);
}

/* ========================================
   DESTABILIZATION EFFECTS
========================================= */
.destabilizing {
    animation: micro-shake calc(0.1s + var(--system-lag)) infinite;
}

@keyframes micro-shake {
    0%, 100% { transform: translate(0, 0); }
    25% { transform: translate(calc(var(--glitch-intensity) * 1px), 0); }
    75% { transform: translate(calc(var(--glitch-intensity) * -1px), 0); }
}

.lag-cursor {
    cursor: wait !important;
}

.text-corrupt {
    animation: text-glitch 0.1s steps(2) infinite;
}

@keyframes text-glitch {
    0% { text-shadow: 1px 0 var(--sys-error), -1px 0 var(--sys-green); }
    50% { text-shadow: -1px 0 var(--sys-error), 1px 0 var(--sys-green); }
}

.element-drift {
    animation: drift 10s ease-in-out infinite;
}

@keyframes drift {
    0%, 100% { transform: translate(0, 0); }
    50% { transform: translate(calc(var(--glitch-intensity) * 2px), calc(var(--glitch-intensity) * 1px)); }
}

/* ========================================
   LIGHTBOX
========================================= */
.lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 128, 128, 0.95);
    z-index: 10001;
    justify-content: center;
    align-items: center;
    cursor: pointer;
}

.lightbox.active {
    display: flex;
}

.lightbox img {
    max-width: 90%;
    max-height: 90%;
    border: 4px solid;
    border-color: var(--sys-white) var(--sys-dark) var(--sys-dark) var(--sys-white);
    box-shadow: 4px 4px 0 rgba(0,0,0,0.5);
}

/* ========================================
   CRT EFFECT
========================================= */
.crt-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 9998;
}

/* Scanlines */
.crt-overlay::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.15) 0px,
        rgba(0, 0, 0, 0.15) 1px,
        transparent 1px,
        transparent 2px
    );
    pointer-events: none;
}

/* Vignette + curvature glow */
.crt-overlay::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(
        ellipse at center,
        transparent 0%,
        transparent 60%,
        rgba(0, 0, 0, 0.4) 100%
    );
    pointer-events: none;
}

/* Fish-eye / barrel distortion effect - DESKTOP ONLY */
@media (min-width: 769px) {
    .crt-enabled {
        overflow: hidden;
    }

    .crt-enabled .desktop {
        filter: contrast(1.1) brightness(1.05);
        text-shadow: 0 0 1px rgba(255, 255, 255, 0.1);
        /* Fisheye barrel distortion effect */
        transform: perspective(800px) rotateX(2deg) scale(1.02);
        transform-origin: center 40%;
    }

    /* Enhanced vignette for fisheye feel */
    .crt-enabled .crt-overlay::after {
        background: radial-gradient(
            ellipse 120% 120% at center,
            transparent 0%,
            transparent 50%,
            rgba(0, 0, 0, 0.3) 80%,
            rgba(0, 0, 0, 0.6) 100%
        );
    }

}

/* RGB shift on text */
.crt-enabled .window-title,
.crt-enabled .info-label,
.crt-enabled h1 {
    text-shadow:
        -0.5px 0 rgba(255, 0, 0, 0.3),
        0.5px 0 rgba(0, 255, 255, 0.3);
}

/* Screen flicker - very subtle */
.crt-enabled .crt-overlay {
    animation: crt-flicker 0.1s infinite;
}

@keyframes crt-flicker {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.98; }
}

/* Phosphor glow on bright elements */
.crt-enabled .window-titlebar {
    box-shadow: 0 0 10px rgba(0, 0, 128, 0.3);
}

.crt-enabled .sys-link:hover {
    box-shadow: 0 0 8px rgba(0, 0, 255, 0.4);
}

/* CRT off state */
.crt-disabled .crt-overlay {
    display: none;
}

.crt-disabled .desktop {
    filter: none;
}

/* CRT Toggle Button in system tray */
.crt-toggle {
    background: var(--sys-gray);
    border: 1px solid;
    border-color: var(--sys-white) var(--sys-dark) var(--sys-dark) var(--sys-white);
    padding: 1px 4px;
    font-size: 9px;
    cursor: pointer;
    font-family: inherit;
    display: flex;
    align-items: center;
    gap: 3px;
}

.crt-toggle:active {
    border-color: var(--sys-dark) var(--sys-white) var(--sys-white) var(--sys-dark);
}

.crt-toggle-icon {
    width: 10px;
    height: 8px;
    border: 1px solid var(--text-primary);
    border-radius: 2px;
    position: relative;
}

.crt-toggle-icon::after {
    content: "";
    position: absolute;
    bottom: -3px;
    left: 50%;
    transform: translateX(-50%);
    width: 6px;
    height: 2px;
    background: var(--text-primary);
}

.crt-enabled .crt-toggle-icon {
    background: var(--sys-green);
    box-shadow: 0 0 4px var(--sys-green);
}

/* ========================================
   REDUCED MOTION
========================================= */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .split-glitch::before,
    .split-glitch::after {
        animation: none;
        opacity: 0;
    }

    .split-noise {
        display: none;
    }
}

/* ========================================
   PAINT WINDOW
========================================= */
.paint-toolbar {
    background: var(--sys-gray);
    border-bottom: 2px solid;
    border-color: var(--sys-dark) var(--sys-white) var(--sys-white) var(--sys-dark);
    padding: 8px;
    display: flex;
    gap: 16px;
    align-items: center;
    flex-wrap: wrap;
}

.paint-tools {
    display: flex;
    gap: 4px;
}

.paint-tool {
    width: 32px;
    height: 32px;
    background: var(--sys-gray);
    border: 2px solid;
    border-color: var(--sys-white) var(--sys-dark) var(--sys-dark) var(--sys-white);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.paint-tool:active,
.paint-tool.active {
    border-color: var(--sys-dark) var(--sys-white) var(--sys-white) var(--sys-dark);
    background: var(--sys-light);
}

.paint-palette {
    display: flex;
    gap: 2px;
    flex-wrap: wrap;
    max-width: 240px;
}

.paint-color {
    width: 18px;
    height: 18px;
    border: 2px solid var(--sys-dark);
    cursor: pointer;
    box-sizing: border-box;
}

.paint-color.active {
    border: 3px solid var(--text-primary);
    box-shadow: 0 0 0 1px var(--sys-white);
}

.paint-actions {
    display: flex;
    gap: 4px;
    margin-left: auto;
}

.paint-btn {
    background: var(--sys-gray);
    border: 2px solid;
    border-color: var(--sys-white) var(--sys-dark) var(--sys-dark) var(--sys-white);
    padding: 4px 12px;
    font-size: 11px;
    font-family: inherit;
    cursor: pointer;
}

.paint-btn:active {
    border-color: var(--sys-dark) var(--sys-white) var(--sys-white) var(--sys-dark);
}

.paint-canvas-wrapper {
    background: var(--sys-white);
    padding: 8px;
    overflow: visible;
    max-height: 420px;
    text-align: center;
}

#paint-canvas {
    display: inline-block;
    border: 1px solid var(--sys-dark);
    background: white;
    cursor: crosshair;
    image-rendering: pixelated;
    vertical-align: top;
}

/* ========================================
   MOBILE: SAFE MODE / POWER SAVING
   Clean, readable, calm interpretation
========================================= */
@media (max-width: 768px) {
    body {
        background: var(--sys-teal);
        padding: 12px;
        padding-bottom: 70px;
        font-size: 12px;
        line-height: 1.6;
    }

    /* Desktop becomes process flow */
    .desktop {
        padding: 0;
        min-height: auto;
    }

    /* Hide desktop navigation window on mobile */
    #win-nav {
        display: none !important;
    }

    /* Windows become process cards with breathing room */
    .window {
        position: relative !important;
        width: 100% !important;
        left: 0 !important;
        top: auto !important;
        margin: 0 0 16px 0;
        box-shadow: 2px 2px 0 rgba(0,0,0,0.2);
        min-height: auto;
    }

    .window.minimized {
        display: block !important;
    }

    /* Collapsed state for mobile */
    .window.mobile-collapsed .window-content,
    .window.mobile-collapsed .window-menubar,
    .window.mobile-collapsed .window-statusbar {
        display: none;
    }

    /* Titlebar becomes process header */
    .window-titlebar {
        cursor: pointer;
        padding: 12px 16px;
    }

    .window-title {
        font-size: 12px;
        flex: 1;
    }

    /* Process status badge - subtle */
    .mobile-status {
        display: inline-block;
        font-size: 8px;
        padding: 2px 8px;
        margin-left: auto;
        border: 1px solid;
        letter-spacing: 0.5px;
    }

    .mobile-status.running {
        background: transparent;
        color: var(--sys-green);
        border-color: var(--sys-green);
    }

    .mobile-status.idle {
        background: transparent;
        color: var(--sys-dark);
        border-color: var(--sys-dark);
    }

    .mobile-status.unstable {
        background: transparent;
        color: #ff6600;
        border-color: #ff6600;
    }

    /* Hide window controls on mobile - tap to expand */
    .window-controls {
        display: none;
    }

    /* Subtle expand indicator */
    .window-titlebar::after {
        content: "+";
        font-size: 14px;
        font-weight: normal;
        margin-left: 12px;
        color: var(--sys-dark);
    }

    .window:not(.mobile-collapsed) .window-titlebar::after {
        content: "−";
    }

    /* Window content - more breathing room */
    .window-content {
        padding: 16px 20px;
        max-height: none !important;
    }

    .window-menubar {
        display: none;
    }

    .window-statusbar {
        padding: 10px 16px;
        font-size: 10px;
    }

    /* Typography improvements */
    .info-line {
        font-size: 11px;
        margin-bottom: 6px;
        line-height: 1.5;
    }

    .info-label {
        font-size: 11px;
        margin-bottom: 8px;
        padding-bottom: 6px;
    }

    .sys-list li {
        font-size: 11px;
        line-height: 1.6;
        margin-bottom: 4px;
    }

    /* Media adjustments - better proportions */
    .media-frame {
        margin: 12px 0;
    }

    .media-frame iframe {
        height: 200px;
    }

    .media-caption {
        padding: 6px 8px;
        font-size: 9px;
    }

    .image-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    /* Links - cleaner on mobile */
    a.sys-link {
        padding: 8px 16px;
        font-size: 11px;
    }

    /* SPLIT section - elegant minimal */
    #win-split .window-content {
        background: #1a1a1a;
        padding: 24px 20px;
    }

    #win-split .split-noise,
    #win-split .split-glitch::before,
    #win-split .split-glitch::after,
    #win-split canvas,
    #win-split .split-data,
    #win-split .split-fragment,
    #win-split .split-corrupted,
    #win-split .info-group {
        display: none;
    }

    /* Simplified split content for mobile - elegant */
    .mobile-split-notice {
        display: block !important;
        text-align: left;
        padding: 0;
        color: var(--sys-green);
        font-family: 'Courier New', monospace;
        font-size: 11px;
        line-height: 1.8;
        opacity: 0.9;
    }

    .mobile-split-notice::before {
        content: ">";
        margin-right: 8px;
        opacity: 0.5;
    }

    /* Bottom taskbar - minimal 3 buttons */
    .taskbar {
        height: 50px;
        padding: 0;
        flex-direction: row;
        align-items: stretch;
    }

    .start-button {
        display: none;
    }

    .taskbar-items {
        display: none;
    }

    .system-tray {
        display: none;
    }

    /* Mobile bottom nav - clean, 3 buttons */
    .mobile-nav {
        display: flex;
        width: 100%;
        height: 100%;
        background: var(--sys-gray);
    }

    .mobile-nav-btn {
        flex: 1;
        padding: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 10px;
        font-weight: bold;
        letter-spacing: 0.5px;
        background: var(--sys-gray);
        border: none;
        border-left: 1px solid var(--sys-dark);
        cursor: pointer;
        font-family: inherit;
        color: var(--text-primary);
    }

    .mobile-nav-btn:first-child {
        border-left: none;
    }

    .mobile-nav-btn:active {
        background: var(--sys-blue);
        color: white;
    }

    /* Disable ALL destabilization on mobile */
    .destabilizing,
    .element-drift,
    .text-corrupt {
        animation: none !important;
    }

    /* System alerts - DISABLED on mobile */
    .system-alert {
        display: none !important;
    }

    /* Paint - simplified on mobile */
    #win-paint .paint-toolbar {
        padding: 6px;
        gap: 8px;
    }

    #win-paint .paint-tools {
        width: 100%;
        justify-content: center;
    }

    #win-paint .paint-tool {
        width: 40px;
        height: 40px;
    }

    #win-paint .paint-palette {
        width: 100%;
        max-width: none;
        justify-content: center;
    }

    #win-paint .paint-color {
        width: 24px;
        height: 24px;
    }

    /* Hide some colors on mobile - keep only basics */
    #win-paint .paint-color:nth-child(n+7) {
        display: none;
    }

    #win-paint .paint-actions {
        width: 100%;
        margin-left: 0;
        justify-content: center;
    }

    #win-paint .paint-btn {
        flex: 1;
        padding: 8px;
        font-size: 12px;
    }

    #win-paint .paint-canvas-wrapper {
        padding: 8px;
        max-height: none;
        overflow: visible;
    }

    #win-paint #paint-canvas {
        touch-action: none;
        /* Canvas size controlled by JavaScript on mobile for accurate coordinates */
    }

    /* Disable fisheye transform on mobile entirely */
    .crt-enabled .desktop {
        transform: none !important;
        filter: none !important;
    }
}

/* Hide mobile-only elements on desktop */
@media (min-width: 769px) {
    .mobile-nav {
        display: none;
    }

    .mobile-status {
        display: none;
    }

    .mobile-split-notice {
        display: none;
    }
}
