/* ── font ── */
@font-face {
    font-family: 'VCR';
    src: url('https://pub-9091d0906adb4816b149c689fbe4fd6f.r2.dev/assets/VCR_OSD_MONO_1.001.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
}

/* ── reset ── */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    font-family: 'VCR', monospace;
    background: #000;
    color: #fff;
    height: 100%;
    overflow: hidden;
}

/* ── fullscreen background layers (crossfade) ── */
.bg-layer {
    position: fixed;
    inset: 0;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    transition: opacity 4s ease;
}

#bg-a { z-index: 0; opacity: 1; }
#bg-b { z-index: 0; opacity: 0; }

.bg-layer::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
}

/* ── page layout ── */
.page {
    position: relative;
    z-index: 1;
    height: 100vh;
    height: 100dvh;
}

/* ── taskbar ── */
.taskbar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 40px;
    background: #c0c0c0;
    border-top: 2px solid #fff;
    display: flex;
    align-items: center;
    padding: 3px 3px 3px 3px;
    gap: 3px;
    z-index: 1000;
    font-family: 'MS Sans Serif', Arial, sans-serif;
}

.taskbar-start {
    display: flex;
    align-items: center;
    gap: 4px;
    background: #c0c0c0;
    border: 2px solid;
    border-color: #fff #000 #000 #fff;
    padding: 2px 8px;
    font-size: 13px;
    font-weight: bold;
    color: #000;
    cursor: pointer;
    flex-shrink: 0;
    height: 32px;
    user-select: none;
}

.taskbar-start:active,
.taskbar-start.active {
    border-color: #000 #fff #fff #000;
}

.taskbar-start-icon {
    width: 20px;
    height: 20px;
    image-rendering: pixelated;
}

.taskbar-windows {
    display: flex;
    gap: 2px;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    align-items: center;
    height: 100%;
}

.taskbar-win-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    background: #c0c0c0;
    border: 2px solid;
    border-color: #fff #000 #000 #fff;
    padding: 2px 8px;
    font-size: 13px;
    color: #000;
    cursor: pointer;
    height: 32px;
    max-width: 180px;
    min-width: 0;
    font-family: 'MS Sans Serif', Arial, sans-serif;
    flex-shrink: 0;
}

.taskbar-win-btn span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.taskbar-win-btn.active {
    border-color: #000 #fff #fff #000;
    background: #b0b0b0;
}

.taskbar-win-btn canvas {
    width: 20px;
    height: 20px;
    image-rendering: pixelated;
    flex-shrink: 0;
}

.taskbar-tray {
    display: flex;
    align-items: center;
    font-size: 12px;
    padding: 0 8px;
    flex-shrink: 0;
    color: #000;
    gap: 0;
    height: 32px;
    border: 2px solid;
    border-color: #808080 #fff #fff #808080;
    background: #c0c0c0;
}

.taskbar-tray a {
    color: #000;
    text-decoration: none;
}

.taskbar-tray a:hover {
    color: #000080;
}

.taskbar-sep {
    margin: 0 4px;
    opacity: 0.4;
    color: #000;
}

/* ── tv area ── */
.tv-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    gap: 0;
    position: relative;
}

.tv-anchor {
    position: relative;
    top: -5%;
    display: inline-flex;
}
.tv-anchor.tv3-active {
    top: 1%;
}
.tv-anchor.tv4-active {
    top: -9%;
}

.tv-frame {
    display: block;
    height: 1032px;
    width: auto;
    position: relative;
    z-index: 2;
    pointer-events: none;
}

/* ── clickable area on TV — adjust --tv-click-size to resize (0-100%) ── */
.tv-click-area {
    --tv-click-size: 30%;
    position: absolute;
    z-index: 3;
    width: var(--tv-click-size);
    height: var(--tv-click-size);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    cursor: pointer;
}

.tv-screen {
    position: absolute;
    z-index: 1;
    overflow: hidden;
    top: 31%;
    left: 30%;
    width: 40%;
    height: 30%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
    cursor: pointer;
}

.tv-gif {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: 390px;
    object-fit: contain;
    display: block;
    transition: opacity 0.8s ease;
}

#tv-gif-a {
    opacity: 1;
    z-index: 1;
}

#tv-gif-b {
    opacity: 0;
    z-index: 0;
}

/* ── nav arrows ── */
.nav-arrows {
    z-index: 10;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.arrow-btn {
    background: none;
    border: none;
    padding: 10px;
    cursor: pointer;
    opacity: 0.85;
    transition: opacity 0.2s, transform 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    pointer-events: auto;
}

#prev-btn {
    top: 72%;
    left: 38%;
}

#random-btn {
    top: 72%;
    left: 50%;
    transform: translateX(-50%);
}

#next-btn {
    top: 72%;
    right: 38%;
}

.arrow-btn img {
    height: 62px;
    width: auto;
    display: block;
}

.arrow-btn:hover {
    opacity: 1;
    transform: scale(1.5);
}

#random-btn:hover {
    transform: translateX(-50%) scale(1.5);
}

.arrow-btn:active {
    transform: scale(0.95);
}

#random-btn:active {
    transform: translateX(-50%) scale(0.95);
}

/* ── app icons (top-left) ── */
.app-icons {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 30px;
    z-index: 10;
    pointer-events: none;
}

.app-icons .app-icon {
    position: absolute;
    pointer-events: auto;
}

.app-icons .app-icon.dragging {
    opacity: 0.7;
    z-index: 100;
}

/* ── portfolio folder (near TV) ── */
.portfolio-folder-icon {
    position: fixed;
    z-index: 10;
}

.portfolio-folder-icon .app-icon {
    pointer-events: auto;
}

.portfolio-folder-icon .app-icon.dragging {
    opacity: 0.7;
    z-index: 100;
}

/* ── portfolio folder window ── */
.portfolio-folder-window {
    position: fixed;
    background: #c0c0c0;
    border: 2px solid;
    border-color: #fff #000 #000 #fff;
    box-shadow: 2px 2px 8px rgba(0,0,0,0.3);
    z-index: 500;
    min-width: 340px;
    animation: windowOpen 0.12s ease-out;
}

.portfolio-folder-titlebar {
    background: #000080;
    color: #fff;
    padding: 2px 4px;
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: bold;
    cursor: grab;
}

.portfolio-folder-titlebar:active { cursor: grabbing; }

.portfolio-folder-titlebar .folder-title { flex: 1; }

.portfolio-folder-close {
    background: #c0c0c0;
    border: 2px solid;
    border-color: #fff #808080 #808080 #fff;
    font-size: 10px;
    width: 16px;
    height: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.portfolio-folder-close:active {
    border-color: #808080 #fff #fff #808080;
}

.portfolio-folder-body {
    padding: 12px;
    display: grid;
    grid-template-columns: repeat(4, 75px);
    gap: 4px;
    justify-content: center;
    background: #c0c0c0;
    margin: 2px;
    border: 2px solid;
    border-color: #808080 #fff #fff #808080;
}

.portfolio-folder-status {
    padding: 2px 6px;
    font-size: 10px;
    border-top: 2px solid;
    border-color: #808080 #fff #fff #808080;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ── start menu ── */
.start-menu {
    position: fixed;
    bottom: 30px;
    left: 0;
    display: flex;
    z-index: 9999;
    border: 2px solid;
    border-color: #fff #000 #000 #fff;
    background: #c0c0c0;
    box-shadow: 2px -2px 8px rgba(0,0,0,0.4);
    animation: windowOpen 0.12s ease-out;
    font-family: 'MS Sans Serif', Arial, sans-serif;
}

.start-menu-sidebar {
    background: linear-gradient(to top, #000080, #1084d0);
    width: 22px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 6px;
    flex-shrink: 0;
}

.start-menu-sidebar span {
    color: #fff;
    font-weight: bold;
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    font-size: 15px;
    letter-spacing: 2px;
    font-family: 'VCR', monospace;
}

.start-menu-list {
    padding: 3px 0;
    min-width: 170px;
}

.start-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 24px 5px 8px;
    cursor: pointer;
    font-size: 11px;
    color: #000;
    position: relative;
    white-space: nowrap;
}

.start-menu-item:hover {
    background: #000080;
    color: #fff;
}

.start-menu-item:hover .sm-canvas {
    filter: brightness(2);
}

.sm-icon {
    width: 16px;
    text-align: center;
    font-size: 14px;
    flex-shrink: 0;
}

.sm-canvas {
    width: 16px;
    height: 16px;
    image-rendering: pixelated;
    flex-shrink: 0;
}

.sm-label {
    flex: 1;
}

.sm-arrow {
    font-size: 8px;
    position: absolute;
    right: 8px;
}

.start-menu-divider {
    height: 1px;
    background: #808080;
    margin: 3px 4px;
    border-bottom: 1px solid #fff;
}

.start-submenu {
    position: absolute;
    left: calc(100% - 2px);
    bottom: 0;
    border: 2px solid;
    border-color: #fff #000 #000 #fff;
    background: #c0c0c0;
    min-width: 160px;
    padding: 3px 0;
    box-shadow: 2px 2px 6px rgba(0,0,0,0.3);
}

/* ── volume popup ── */
.volume-popup {
    position: fixed;
    bottom: 45px;
    right: auto;
    background: #c0c0c0;
    border: 2px solid;
    border-color: #fff #000 #000 #fff;
    box-shadow: 2px -2px 6px rgba(0,0,0,0.3);
    z-index: 9998;
    font-family: 'MS Sans Serif', Arial, sans-serif;
    transform-origin: bottom;
    animation: popupGrow 0.15s ease-out;
}

.volume-popup-header {
    background: linear-gradient(to right, #000080, #1084d0);
    padding: 2px 6px;
    font-size: 10px;
    color: #fff;
}

.volume-popup-body {
    padding: 8px;
}

.volume-col {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.volume-col-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    min-width: 32px;
}

.volume-col-label {
    font-size: 9px;
    color: #000;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 50px;
}

.volume-slider-v {
    writing-mode: vertical-lr;
    direction: rtl;
    width: 18px;
    height: 80px;
    background: #c0c0c0;
    border: 2px solid;
    border-color: #808080 #fff #fff #808080;
    outline: none;
}

.volume-slider-v::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 10px;
    background: #c0c0c0;
    border: 2px solid;
    border-color: #fff #000 #000 #fff;
    cursor: pointer;
}

.volume-slider-v::-moz-range-thumb {
    width: 16px;
    height: 10px;
    background: #c0c0c0;
    border: 2px solid;
    border-color: #fff #000 #000 #fff;
    cursor: pointer;
    border-radius: 0;
}

.volume-mute-btn {
    background: #c0c0c0;
    border: 2px solid;
    border-color: #fff #000 #000 #fff;
    font-size: 11px;
    cursor: pointer;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.volume-mute-btn:active { border-color: #000 #fff #fff #000; }
.volume-mute-btn.muted { color: #cc0000; }

.volume-cols {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    justify-content: center;
    padding: 4px 0;
}

.volume-master-label {
    font-size: 10px;
    white-space: nowrap;
    min-width: 36px;
}

.volume-slider-h::-moz-range-thumb {
    width: 11px;
    height: 16px;
    background: #c0c0c0;
    border: 2px solid;
    border-color: #fff #000 #000 #fff;
    cursor: pointer;
    border-radius: 0;
}

.volume-divider {
    border-top: 1px solid #808080;
    border-bottom: 1px solid #fff;
    margin: 4px 0 8px;
}

.app-icon {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    padding: 8px;
    background: transparent;
    width: 90px;
    border: 1px solid transparent;
}

.app-icon:hover {
    background: rgba(0, 0, 128, 0.2);
    border: 1px dotted #000080;
}

.app-icon.active {
    background: #000080;
}

.app-icon.active .icon-label {
    color: #ffffff;
    background: #000080;
}

.icon-img {
    width: 38px;
    height: 38px;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    filter: none;
}

.icon-label {
    font-family: 'MS Sans Serif', Arial, sans-serif;
    font-size: 11px;
    color: #ffffff;
    text-align: center;
    line-height: 1.2;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
    padding: 2px 4px;
    background: transparent;
}

/* ── app window ── */
.app-window {
    position: fixed;
    top: 5%;
    left: 5%;
    width: 90vw;
    height: 90vh;
    max-width: 1400px;
    max-height: 900px;
    min-width: 200px;
    min-height: 300px;
    z-index: 200;
    background: #c0c0c0;
    border: 3px solid;
    border-color: #ffffff #000000 #000000 #ffffff;
    box-shadow: 2px 2px 10px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    animation: windowOpen 0.2s ease-out;
}

.app-window.closing {
    animation: windowClose 0.15s ease-in forwards;
}

@keyframes windowOpen {
    from {
        transform: scale(0.7);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes popupGrow {
    from {
        transform: scaleY(0);
        opacity: 0;
    }
    to {
        transform: scaleY(1);
        opacity: 1;
    }
}

@keyframes windowClose {
    from {
        transform: scale(1);
        opacity: 1;
    }
    to {
        transform: scale(0.7);
        opacity: 0;
    }
}

.window-header {
    background: linear-gradient(to right, #000080, #1084d0);
    padding: 2px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    cursor: move;
    user-select: none;
}

.window-title {
    display: flex;
    align-items: center;
    gap: 3px;
    font-family: 'MS Sans Serif', Arial, sans-serif;
    font-size: 10px;
    color: #ffffff;
    letter-spacing: 0;
    padding-left: 3px;
}

.window-icon {
    width: 16px;
    height: 16px;
    filter: none;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

.window-close {
    font-family: 'MS Sans Serif', Arial, sans-serif;
    font-size: 11px;
    font-weight: bold;
    color: #000000;
    background: #c0c0c0;
    border: 2px solid;
    border-color: #ffffff #000000 #000000 #ffffff;
    padding: 1px 6px;
    cursor: pointer;
    min-width: 16px;
    min-height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.window-close:hover {
    background: #dfdfdf;
}

.window-close:active {
    border-color: #000000 #ffffff #ffffff #000000;
    padding: 2px 5px 0px 7px;
}

.window-buttons {
    display: flex;
    gap: 2px;
    align-items: center;
}

.window-btn {
    font-family: 'Marlett', 'MS Sans Serif', Arial, sans-serif;
    font-size: 10px;
    color: #000000;
    background: #c0c0c0;
    border: 2px solid;
    border-color: #ffffff #000000 #000000 #ffffff;
    cursor: pointer;
    width: 16px;
    height: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;
}

.window-btn:hover {
    background: #dfdfdf;
}

.window-btn:active {
    border-color: #000000 #ffffff #ffffff #000000;
}

.app-window.maximized {
    left: 0 !important;
    top: 0 !important;
    width: 100vw !important;
    height: calc(100vh - 30px) !important;
    max-width: none !important;
    max-height: none !important;
    border-width: 2px !important;
}

.window-content {
    flex: 1;
    position: relative;
    overflow: hidden;
    border: 2px solid;
    border-color: #808080 #ffffff #ffffff #808080;
    background: #ffffff;
}

.window-content iframe {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}

.window-resize-handle {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 18px;
    height: 18px;
    cursor: se-resize;
    user-select: none;
    z-index: 10;
    background: linear-gradient(
        135deg,
        transparent 0%, transparent 40%,
        #808080 40%, #808080 45%, transparent 45%,
        transparent 55%, #808080 55%, #808080 60%, transparent 60%,
        transparent 70%, #808080 70%, #808080 75%, transparent 75%
    );
}

/* ── music window ── */
.music-body {
    display: flex;
    flex-direction: column;
    background: #c0c0c0;
    overflow: hidden;
}

.music-hdr {
    background: #001a00;
    border: 2px solid;
    border-color: #808080 #fff #fff #808080;
    margin: 4px 4px 0 4px;
    padding: 4px 6px;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.music-dot {
    width: 8px;
    height: 8px;
    background: #00ee55;
    animation: musicBlink 2s infinite;
}

@keyframes musicBlink {
    0%, 49% { opacity: 1; }
    50%, 100% { opacity: 0.2; }
}

.music-lbl {
    color: #00ee55;
    font-family: 'VCR', monospace;
    font-size: 14px;
    letter-spacing: 1px;
}

/* player */
.music-player {
    margin: 4px 4px 0 4px;
    border: 2px solid;
    border-color: #808080 #fff #fff #808080;
    background: #000;
    flex-shrink: 0;
}

.music-player iframe {
    width: 100%;
    aspect-ratio: 16/9;
    border: none;
    display: block;
}

.music-player-bar {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 3px 6px;
    border-top: 1px solid #1a1a1a;
}

.music-player-bar span {
    color: #00ee55;
    font-family: 'VCR', monospace;
    font-size: 12px;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.music-player-x {
    background: #c0c0c0;
    border: 2px solid;
    border-color: #fff #000 #000 #fff;
    color: #000;
    font-size: 9px;
    font-family: 'MS Sans Serif', Arial, sans-serif;
    padding: 0 4px;
    cursor: pointer;
}

.music-player-x:active {
    border-color: #000 #fff #fff #000;
}

/* now playing */
.music-np {
    background: #000;
    border: 2px solid;
    border-color: #808080 #fff #fff #808080;
    margin: 4px 4px 0 4px;
    padding: 4px 6px;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.music-np-dot {
    width: 8px;
    height: 8px;
    background: #ff3333;
    border-radius: 50%;
    flex-shrink: 0;
}

.music-np-dot.active {
    animation: musicBlink 1s infinite;
}

.music-np-text {
    color: #aaa;
    font-family: 'VCR', monospace;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* tabs */
.music-tabs {
    display: flex;
    margin: 4px 4px 0 4px;
    flex-shrink: 0;
}

.music-tab {
    flex: 1;
    padding: 4px 0;
    text-align: center;
    font-family: 'MS Sans Serif', Arial, sans-serif;
    font-size: 12px;
    cursor: pointer;
    background: #c0c0c0;
    border: 2px solid;
    border-color: #fff #808080 #808080 #fff;
    color: #000;
    user-select: none;
}

.music-tab:hover { background: #d4d4d4; }

.music-tab.active {
    background: #000080;
    color: #fff;
    border-color: #808080 #fff #fff #808080;
    font-weight: bold;
}

/* list */
.music-list {
    flex: 1;
    margin: 0 4px 4px 4px;
    border: 2px solid;
    border-color: #808080 #fff #fff #808080;
    background: #000;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
}

.music-list::-webkit-scrollbar { width: 14px; }
.music-list::-webkit-scrollbar-track {
    background: #c0c0c0;
    border-left: 1px solid #808080;
}
.music-list::-webkit-scrollbar-thumb {
    background: #c0c0c0;
    border: 2px solid;
    border-color: #fff #000 #000 #fff;
}

.music-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 8px;
    border-bottom: 1px solid #1a1a1a;
    cursor: pointer;
}

.music-row:hover { background: #0a1a0a; }
.music-row.playing { background: #001a00; }
.music-row.playing .mr-name { color: #fff; }
.music-row.playing .mr-play { color: #00ee55; }
.music-row:hover .mr-play { color: #00ee55; }

.mr-play {
    color: #333;
    font-size: 12px;
    width: 16px;
    text-align: center;
    flex-shrink: 0;
}

.mr-art {
    width: 42px;
    height: 42px;
    background: #1a1a1a;
    flex-shrink: 0;
    image-rendering: pixelated;
    object-fit: cover;
}

.mr-info { flex: 1; min-width: 0; overflow: hidden; }

.mr-name {
    color: #00ee55;
    font-family: 'VCR', monospace;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mr-sub {
    color: #666;
    font-family: 'VCR', monospace;
    font-size: 11px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mr-count {
    color: #444;
    font-family: 'VCR', monospace;
    font-size: 11px;
    flex-shrink: 0;
}

.music-filters {
    margin: 0 4px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex-shrink: 0;
    padding: 3px 4px;
    background: #c0c0c0;
    border: 2px solid;
    border-color: #808080 #fff #fff #808080;
}

.music-filter-row {
    display: flex;
    gap: 2px;
}

.music-fbtn {
    flex: 1;
    padding: 3px 0;
    text-align: center;
    font-family: 'VCR', monospace;
    font-size: 11px;
    cursor: pointer;
    background: #c0c0c0;
    border: 2px solid;
    border-color: #fff #808080 #808080 #fff;
    color: #000;
    user-select: none;
    letter-spacing: 0.5px;
}

.music-fbtn:hover { background: #d4d4d4; }

.music-fbtn.active {
    background: #000080;
    color: #fff;
    border-color: #808080 #fff #fff #808080;
}

.music-loading {
    color: #00ee55;
    font-family: 'VCR', monospace;
    font-size: 13px;
    text-align: center;
    padding: 20px;
    animation: musicBlink 1.5s infinite;
}


/* ── palette icons ── */
/* taskbar icons (screenshot, record, palette) */
.taskbar-icon {
    width: 24px;
    height: 24px;
    cursor: pointer;
    image-rendering: pixelated;
    margin: 0 3px;
    padding: 2px;
}

.taskbar-icon:hover {
    background: rgba(0, 0, 0, 0.1);
}

.taskbar-icon:active {
    background: rgba(0, 0, 0, 0.2);
}

.taskbar-icon.recording {
    animation: pulse 1s infinite;
}

/* ── palette popup ── */
.palette-popup {
    position: fixed;
    bottom: 45px;
    right: auto;
    width: 200px;
    max-height: 60vh;
    background: #c0c0c0;
    border: 3px solid;
    border-color: #ffffff #000000 #000000 #ffffff;
    box-shadow: 2px 2px 8px rgba(0,0,0,0.5);
    z-index: 300;
    transform-origin: bottom;
    animation: popupGrow 0.2s ease-out;
}

.palette-popup-header {
    background: linear-gradient(to right, #000080, #1084d0);
    padding: 2px 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: 'MS Sans Serif', Arial, sans-serif;
    font-size: 10px;
    color: #fff;
    cursor: default;
}

.palette-popup-body {
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 3px;
    overflow-y: auto;
    max-height: calc(60vh - 30px);
}

.palette-btn {
    background: #c0c0c0;
    border: 2px solid;
    border-color: #fff #000 #000 #fff;
    padding: 4px 8px;
    font-family: 'MS Sans Serif', Arial, sans-serif;
    font-size: 11px;
    cursor: pointer;
    text-align: left;
    color: #000;
}

.palette-btn:hover { background: #d4d4d4; }
.palette-btn:active { border-color: #000 #fff #fff #000; }

.palette-btn.active {
    background: #000080;
    color: #fff;
    border-color: #000 #fff #fff #000;
}

/* ── export popup ── */
.export-popup {
    position: fixed;
    bottom: 45px;
    right: auto;
    width: 280px;
    background: #c0c0c0;
    border: 3px solid;
    border-color: #ffffff #000000 #000000 #ffffff;
    box-shadow: 2px 2px 8px rgba(0,0,0,0.5);
    z-index: 400;
    transform-origin: bottom;
    animation: popupGrow 0.2s ease-out;
}

.export-popup-header {
    background: linear-gradient(to right, #000080, #1084d0);
    padding: 2px 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: 'MS Sans Serif', Arial, sans-serif;
    font-size: 11px;
    font-weight: bold;
    color: #fff;
}

.export-popup-body {
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.export-section {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.export-label {
    font-size: 11px;
    font-weight: bold;
    color: #000;
    font-family: 'MS Sans Serif', Arial, sans-serif;
}

.export-select {
    background: #fff;
    border: 2px solid;
    border-color: #808080 #fff #fff #808080;
    padding: 3px 4px;
    font-family: 'MS Sans Serif', Arial, sans-serif;
    font-size: 11px;
    color: #000;
}

.export-btns {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.export-btn {
    background: #c0c0c0;
    border: 2px solid;
    border-color: #fff #000 #000 #fff;
    padding: 4px 12px;
    font-family: 'MS Sans Serif', Arial, sans-serif;
    font-size: 11px;
    cursor: pointer;
    color: #000;
    flex: 1;
    min-width: 50px;
}

.export-btn:hover { background: #d4d4d4; }
.export-btn:active { border-color: #000 #fff #fff #000; }

.export-btn.active {
    background: #000080;
    color: #fff;
    border-color: #000 #fff #fff #000;
}

.export-checkbox {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-family: 'MS Sans Serif', Arial, sans-serif;
    color: #000;
    cursor: pointer;
    user-select: none;
}

.export-checkbox input[type="checkbox"] {
    cursor: pointer;
}

/* ── mobile warning popup ── */
.mobile-warning-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 400px;
    background: #c0c0c0;
    border: 3px solid;
    border-color: #ffffff #000000 #000000 #ffffff;
    box-shadow: 4px 4px 12px rgba(0,0,0,0.7);
    z-index: 10000;
    animation: windowOpen 0.2s ease-out;
}

.mobile-warning-header {
    background: linear-gradient(to right, #000080, #1084d0);
    padding: 4px 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: 'MS Sans Serif', Arial, sans-serif;
    font-size: 13px;
    font-weight: bold;
    color: #fff;
}

.mobile-warning-body {
    padding: 16px;
    font-family: 'MS Sans Serif', Arial, sans-serif;
    color: #000;
}

.export-execute-btn {
    background: #c0c0c0;
    border: 2px solid;
    border-color: #fff #000 #000 #fff;
    padding: 8px;
    font-family: 'MS Sans Serif', Arial, sans-serif;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    color: #000;
    margin-top: 4px;
}

.export-execute-btn:hover { background: #d4d4d4; }
.export-execute-btn:active { border-color: #000 #fff #fff #000; }

.export-execute-btn.recording {
    background: #cc0000;
    color: #fff;
}

/* ── color filter palettes ── */
body.palette-vhs-warm .bg-layer,
body.palette-vhs-warm .page,
body.palette-vhs-warm .app-window {
    filter: sepia(20%) saturate(130%) brightness(105%);
}

body.palette-cyberpunk .bg-layer,
body.palette-cyberpunk .page,
body.palette-cyberpunk .app-window {
    filter: contrast(120%) saturate(150%) hue-rotate(15deg) brightness(90%);
}

body.palette-monochrome .bg-layer,
body.palette-monochrome .page,
body.palette-monochrome .app-window {
    filter: grayscale(100%) contrast(110%);
}

/* Game Boy */
body.palette-gameboy .bg-layer,
body.palette-gameboy .page,
body.palette-gameboy .app-window {
    filter: sepia(100%) hue-rotate(60deg) saturate(200%) brightness(90%) contrast(120%);
}

/* Virtual Boy */
body.palette-virtualboy .bg-layer,
body.palette-virtualboy .page,
body.palette-virtualboy .app-window {
    filter: grayscale(100%) sepia(100%) hue-rotate(-30deg) saturate(300%) brightness(80%) contrast(130%);
}

/* Matrix */
body.palette-matrix .bg-layer,
body.palette-matrix .page,
body.palette-matrix .app-window {
    filter: sepia(100%) hue-rotate(80deg) saturate(300%) brightness(70%) contrast(140%);
}

/* Vaporwave */
body.palette-vaporwave .bg-layer,
body.palette-vaporwave .page,
body.palette-vaporwave .app-window {
    filter: saturate(180%) hue-rotate(270deg) brightness(110%) contrast(90%);
}

/* Infrared */
body.palette-infrared .bg-layer,
body.palette-infrared .page,
body.palette-infrared .app-window {
    filter: sepia(100%) hue-rotate(-50deg) saturate(400%) brightness(80%) contrast(120%);
}

/* Night Vision */
body.palette-nightvision .bg-layer,
body.palette-nightvision .page,
body.palette-nightvision .app-window {
    filter: sepia(100%) hue-rotate(70deg) saturate(500%) brightness(120%) contrast(150%);
}

/* Neon */
body.palette-neon .bg-layer,
body.palette-neon .page,
body.palette-neon .app-window {
    filter: saturate(300%) contrast(130%) brightness(110%);
}

/* Ice */
body.palette-ice .bg-layer,
body.palette-ice .page,
body.palette-ice .app-window {
    filter: sepia(20%) hue-rotate(180deg) saturate(120%) brightness(110%) contrast(95%);
}

/* Candy */
body.palette-candy .bg-layer,
body.palette-candy .page,
body.palette-candy .app-window {
    filter: saturate(250%) hue-rotate(310deg) brightness(115%) contrast(90%);
}

/* Acid */
body.palette-acid .bg-layer,
body.palette-acid .page,
body.palette-acid .app-window {
    filter: hue-rotate(90deg) saturate(250%) contrast(120%) brightness(105%);
}

/* ──────────────────────────────────────────────────────────
   MOBILE RESPONSIVE STYLES
   ────────────────────────────────────────────────────────── */

/* ── Tablet mode (601-767px) - Hybrid approach ── */
@media (min-width: 601px) and (max-width: 767px) {
    .tv-frame {
        height: 600px;
    }

    .app-icons,
    .portfolio-folder-icon {
        position: fixed;
        display: flex;
        flex-direction: column;
        background: rgba(0, 0, 0, 0.3);
        padding: 8px;
        gap: 8px;
        max-height: 60vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .app-icons {
        top: 12px;
        left: 12px;
    }

    .portfolio-folder-icon {
        top: 12px;
        right: 12px;
        transform: none;
    }

    .app-icon,
    .app-icons .app-icon {
        position: static !important;
        min-width: 80px;
    }
}

/* ── Mobile mode (max-width: 767px) ── */
@media (max-width: 767px) {

    /* ── Hide desktop background elements ── */
    .tv-area {
        display: none; /* Hide TV on mobile - maximizes app space */
    }

    /* ── Mobile Icon Grid Layout ── */
    .app-icons,
    .portfolio-folder-icon {
        position: static;
        transform: none;
        pointer-events: auto;
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: 8px;
        padding: 12px;
        background: rgba(0, 0, 0, 0.3);
        width: 100%;
        max-height: calc(100vh - 60px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .app-icons {
        padding-top: 20px;
    }

    .app-icon,
    .app-icons .app-icon {
        position: static !important;
        width: 100%;
        padding: 12px 8px;
        min-height: 80px;
        justify-content: center;
    }

    .app-icon:active {
        background: rgba(0, 0, 128, 0.4);
        transform: scale(0.95);
    }

    .icon-img {
        width: 40px;
        height: 40px;
    }

    .icon-label {
        font-size: 10px;
        line-height: 1.1;
    }

    /* ── Mobile Window Styles ── */
    .app-window.mobile-fullscreen {
        position: fixed !important;
        left: 0 !important;
        top: 0 !important;
        width: 100vw !important;
        height: 100vh !important;
        max-width: none !important;
        max-height: none !important;
        min-width: unset !important;
        min-height: unset !important;
        border-width: 0 !important;
        border-radius: 0;
        z-index: 1000 !important;
    }

    .app-window.mobile-fullscreen .window-header {
        cursor: default;
        -webkit-tap-highlight-color: transparent;
    }

    .app-window.mobile-fullscreen .window-resize-handle {
        display: none;
    }

    .app-window.mobile-fullscreen .window-content {
        border-width: 0;
    }

    /* Larger window controls for touch */
    .window-btn,
    .window-close {
        min-width: 44px !important;
        min-height: 44px !important;
        width: 44px;
        height: 44px;
        font-size: 16px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Hide minimize/maximize on mobile fullscreen, keep close button */
    .app-window.mobile-fullscreen .window-btn[title="Minimize"],
    .app-window.mobile-fullscreen .window-btn[title="Maximize"],
    .app-window.mobile-fullscreen .window-btn[title="Restore"] {
        display: none;
    }

    .app-window.mobile-fullscreen .window-btn.window-close,
    .app-window.mobile-fullscreen .window-close {
        display: flex !important;
    }

    .window-title {
        font-size: 14px;
        padding: 8px;
        flex: 1;
    }

    /* ── Mobile Taskbar ── */
    .taskbar {
        height: 50px;
        padding: 4px;
        gap: 4px;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .taskbar-start {
        min-height: 42px;
        height: 42px;
        padding: 4px 12px;
        font-size: 14px;
        gap: 6px;
        flex-shrink: 0;
    }

    .taskbar-start-icon {
        width: 24px;
        height: 24px;
    }

    /* Hide open window buttons on mobile taskbar */
    .taskbar-windows {
        display: none;
    }

    /* Mobile taskbar tray - simplified */
    .taskbar-tray {
        flex-shrink: 1;
        min-width: 0;
        overflow-x: auto;
        overflow-y: hidden;
        white-space: nowrap;
        padding: 0 8px;
        gap: 8px;
        height: 42px;
        font-size: 11px;
        -webkit-overflow-scrolling: touch;
    }

    /* Touch-friendly taskbar icons */
    .taskbar-icon {
        min-width: 36px;
        min-height: 36px;
        width: 36px;
        height: 36px;
        padding: 6px;
        margin: 0;
        flex-shrink: 0;
    }

    /* ── Mobile Start Menu (slide-up drawer) ── */
    .start-menu {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        max-height: 70vh;
        border: 0;
        border-top: 2px solid #fff;
        box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.6);
        flex-direction: column;
        animation: slideUp 0.2s ease-out;
    }

    @keyframes slideUp {
        from { transform: translateY(100%); }
        to { transform: translateY(0); }
    }

    .start-menu-sidebar {
        display: none;
    }

    .start-menu-list {
        min-width: 100%;
        width: 100%;
        max-height: calc(70vh - 60px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding: 8px 0;
    }

    .start-menu-item {
        padding: 12px 20px;
        font-size: 14px;
        gap: 12px;
        min-height: 48px;
    }

    .start-menu-item:active {
        background: #000080;
        color: #fff;
    }

    .sm-icon {
        width: 20px;
        font-size: 18px;
    }

    .sm-canvas {
        width: 20px;
        height: 20px;
    }

    /* Mobile submenu positioning */
    .start-submenu {
        position: static;
        left: 0;
        bottom: auto;
        width: 100%;
        box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
        border-left: 0;
        border-right: 0;
        margin: 0;
        background: #b0b0b0;
    }

    .start-submenu .start-menu-item {
        padding-left: 40px;
    }

    /* ── Mobile Popups ── */
    .volume-popup,
    .palette-popup,
    .export-popup {
        position: fixed;
        bottom: 60px;
        left: 50%;
        right: auto;
        top: auto;
        transform: translateX(-50%);
        width: calc(100vw - 24px);
        max-width: 320px;
        max-height: 60vh;
        border-width: 2px;
        animation: slideUp 0.15s ease-out;
    }

    .palette-popup-body,
    .export-popup-body {
        max-height: calc(60vh - 50px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Touch-friendly buttons */
    .palette-btn,
    .export-btn,
    .music-fbtn,
    .music-tab {
        min-height: 40px;
        padding: 10px 12px;
        font-size: 13px;
    }

    .export-execute-btn {
        min-height: 48px;
        font-size: 14px;
    }

    /* Volume popup columns */
    .volume-cols {
        gap: 20px;
        padding: 12px 0;
    }

    .volume-col-item {
        min-width: 50px;
    }

    .volume-slider-v {
        height: 100px;
        width: 24px;
    }

    .volume-mute-btn {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }

    /* ── Music Window Mobile ── */
    #music-window.mobile-fullscreen {
        position: fixed !important;
        left: 0 !important;
        top: 0 !important;
        width: 100vw !important;
        height: 100vh !important;
    }

    #music-window.mobile-fullscreen .music-body {
        height: 100%;
    }

    .music-list {
        margin: 0 4px 4px 4px;
    }

    .music-row {
        padding: 10px 12px;
        gap: 12px;
        min-height: 60px;
    }

    .mr-art {
        width: 50px;
        height: 50px;
    }

    .mr-name {
        font-size: 14px;
    }

    .mr-sub {
        font-size: 12px;
    }

    /* ── Page layout adjustments ── */
    .page {
        height: 100vh;
        height: 100dvh;
    }

    body {
        overflow: hidden;
        -webkit-overflow-scrolling: touch;
    }

    /* ── Touch improvements ── */
    * {
        -webkit-tap-highlight-color: rgba(0, 0, 128, 0.2);
        touch-action: manipulation;
    }

    button,
    .app-icon,
    .start-menu-item,
    .taskbar-icon {
        -webkit-tap-highlight-color: rgba(0, 0, 128, 0.3);
    }
}

/* ── Extra small mobile (max-width: 480px) ── */
@media (max-width: 480px) {
    /* Hide less important tray items on very small screens */
    .taskbar-tray a {
        display: none;
    }

    #view-count {
        display: none;
    }

    /* 3-column grid on very small screens */
    .app-icons,
    .portfolio-folder-icon {
        grid-template-columns: repeat(3, 1fr);
    }
}
