:root {
    --desktop: #008080;
    --window: #c0c0c0;
    --window-light: #ffffff;
    --window-mid: #dfdfdf;
    --window-dark: #808080;
    --window-black: #000000;
    --title: #000080;
    --title-bright: #1084d0;
    --selection: #000080;
    --lcd: #071d13;
    --lcd-green: #69ff8c;
    --font-ui: "MS Sans Serif", Tahoma, Geneva, sans-serif;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    min-width: 320px;
    margin: 0;
    background:
        linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px),
        linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
        var(--desktop);
    background-size: 4px 4px;
    color: #000;
    font-family: var(--font-ui);
    font-size: 13px;
    overflow: hidden;
}

button,
input,
select {
    border-radius: 0;
    font: inherit;
}

button,
a,
select {
    color: inherit;
}

button,
select {
    cursor: pointer;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
    outline: 1px dotted #000;
    outline-offset: -4px;
}

img {
    display: block;
    max-width: 100%;
}

[hidden] {
    display: none !important;
}

.skip-link {
    position: fixed;
    top: 0.25rem;
    left: 0.25rem;
    z-index: 10000;
    padding: 0.5rem;
    border: 2px outset var(--window);
    background: var(--window);
    transform: translateY(-140%);
}

.skip-link:focus {
    transform: none;
}

.desktop {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) 38px;
    gap: 7px;
    height: 100vh;
    padding: 7px 7px 0;
}

.window {
    min-width: 0;
    border: 2px solid;
    border-color: var(--window-light) var(--window-black) var(--window-black) var(--window-light);
    background: var(--window);
    box-shadow:
        inset 1px 1px 0 var(--window-mid),
        inset -1px -1px 0 var(--window-dark);
}

.title-bar {
    display: flex;
    height: 26px;
    align-items: center;
    justify-content: space-between;
    margin: 2px;
    padding: 2px 3px 2px 5px;
    background: linear-gradient(90deg, var(--title), var(--title-bright));
    color: #fff;
    font-size: 12px;
    letter-spacing: 0.02em;
}

.title-copy {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 6px;
}

.title-copy strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-icon,
.tiny-app-icon {
    display: inline-grid;
    width: 18px;
    height: 16px;
    place-items: center;
    border: 1px solid #fff;
    background: #000;
    color: #fff;
    font-size: 8px;
    font-weight: bold;
}

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

.window-buttons span {
    display: grid;
    width: 19px;
    height: 18px;
    place-items: center;
    border: 2px solid;
    border-color: var(--window-light) var(--window-black) var(--window-black) var(--window-light);
    background: var(--window);
    color: #000;
    font-family: Arial, sans-serif;
    font-size: 12px;
    font-weight: bold;
    line-height: 1;
}

.menu-bar {
    display: flex;
    gap: 20px;
    min-height: 25px;
    align-items: center;
    padding: 1px 9px;
}

.menu-bar a,
.menu-bar button {
    padding: 3px 1px;
    border: 0;
    background: transparent;
    text-decoration: none;
}

.menu-bar a:hover,
.menu-bar button:hover {
    background: var(--selection);
    color: #fff;
}

.app-banner {
    display: grid;
    grid-template-columns: minmax(230px, auto) 1fr auto;
    gap: 28px;
    align-items: center;
    margin: 0 3px 3px;
    padding: 8px 12px;
    border: 2px inset var(--window);
    background:
        linear-gradient(90deg, rgba(0, 0, 0, 0.7), rgba(0, 0, 128, 0.7)),
        repeating-linear-gradient(135deg, #202020 0 8px, #161616 8px 16px);
    color: #fff;
}

.banner-wordmark {
    display: flex;
    align-items: baseline;
    font-family: "Arial Narrow", Arial, sans-serif;
    font-size: clamp(21px, 3vw, 34px);
    font-weight: 700;
    letter-spacing: 0.14em;
    line-height: 1;
}

.banner-wordmark span:nth-child(2) {
    color: #c7c7c7;
}

.banner-wordmark i {
    color: #fff;
    font-style: normal;
}

.app-banner > p {
    margin: 0;
    color: #bcbcbc;
    font-family: "Courier New", monospace;
    font-size: 11px;
    letter-spacing: 0.15em;
}

.app-banner dl {
    display: flex;
    gap: 22px;
    margin: 0;
}

.app-banner dl div {
    text-align: right;
}

.app-banner dt {
    color: #a9ff00;
    font-family: "Courier New", monospace;
    font-size: 20px;
    font-weight: bold;
    line-height: 1;
}

.app-banner dd {
    margin: 3px 0 0;
    color: #bcbcbc;
    font-size: 9px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.workspace {
    display: grid;
    grid-template-columns: minmax(0, 58fr) minmax(390px, 42fr);
    gap: 7px;
    min-height: 0;
}

.archive-window,
.player-window {
    display: flex;
    min-height: 0;
    flex-direction: column;
}

.archive-toolbar {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) minmax(175px, 0.65fr) auto;
    gap: 8px;
    padding: 7px 6px;
    border-top: 1px solid var(--window-light);
}

.archive-toolbar label {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 6px;
}

.archive-toolbar input,
.archive-toolbar select {
    width: 100%;
    min-width: 0;
    height: 25px;
    padding: 2px 5px;
    border: 2px inset var(--window);
    background: #fff;
}

.archive-toolbar button,
.transport button {
    min-width: 56px;
    border: 2px solid;
    border-color: var(--window-light) var(--window-black) var(--window-black) var(--window-light);
    background: var(--window);
    box-shadow: inset 1px 1px 0 var(--window-mid), inset -1px -1px 0 var(--window-dark);
}

.archive-toolbar button:active,
.transport button:active,
.start-button:active {
    border-color: var(--window-black) var(--window-light) var(--window-light) var(--window-black);
    box-shadow: inset 1px 1px 0 var(--window-dark);
    padding-top: 2px;
    padding-left: 2px;
}

.address-bar {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 5px;
    align-items: center;
    padding: 0 6px 6px;
}

.address-bar > span {
    color: #444;
}

.address-bar > div {
    display: flex;
    height: 24px;
    align-items: center;
    gap: 6px;
    padding: 2px 5px;
    border: 2px inset var(--window);
    background: #fff;
    overflow: hidden;
    white-space: nowrap;
}

.folder-icon,
.mini-folder {
    display: inline-block;
    width: 15px;
    height: 10px;
    border: 1px solid #5c4b00;
    background: #f5d347;
    box-shadow: inset 1px 1px #fff19a;
}

.folder-icon::before,
.mini-folder::before {
    display: block;
    width: 7px;
    height: 3px;
    margin-top: -4px;
    border: 1px solid #5c4b00;
    border-bottom: 0;
    background: #f5d347;
    content: "";
}

.archive-viewport {
    position: relative;
    min-height: 0;
    flex: 1;
    margin: 0 5px;
    border: 2px inset var(--window);
    background:
        linear-gradient(rgba(0, 0, 0, 0.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 0, 0, 0.035) 1px, transparent 1px),
        #fff;
    background-size: 8px 8px;
    overflow: auto;
}

.loading-state,
.error-dialog,
.empty-state {
    display: flex;
    min-height: 100%;
    align-items: center;
    justify-content: center;
    gap: 9px;
    font-family: "Courier New", monospace;
    font-size: 12px;
}

.hourglass {
    font-size: 20px;
}

.error-dialog {
    margin: 25px;
    min-height: auto;
    padding: 20px;
    border: 2px outset var(--window);
    background: var(--window);
    color: #800000;
}

.tracks-master-container {
    display: flex;
    width: max-content;
    min-width: 100%;
    min-height: 100%;
    gap: 5px;
    align-items: flex-start;
    padding: 8px 8px 16px;
}

.album-column {
    display: flex;
    min-width: 50px;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.vertical-album-title {
    display: flex;
    width: 48px;
    height: 110px;
    align-items: center;
    padding: 5px 0;
    border: 1px dotted transparent;
    color: var(--selection);
    font-size: 10px;
    font-weight: bold;
    line-height: 1;
    text-align: left;
    text-transform: uppercase;
    writing-mode: vertical-rl;
    overflow: hidden;
}

.vertical-album-title::before {
    display: inline-block;
    width: 9px;
    height: 9px;
    margin-bottom: 5px;
    background: var(--selection);
    content: "";
}

.album-column:hover .vertical-album-title {
    border-color: #000;
    background: var(--selection);
    color: #fff;
}

.album-column:hover .vertical-album-title::before {
    background: #fff;
}

.album-tracks {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.track-box,
.track-placeholder {
    width: 48px;
    height: 48px;
}

.track-box {
    position: relative;
    padding: 2px;
    border: 2px solid;
    border-color: var(--window-light) var(--window-black) var(--window-black) var(--window-light);
    background: var(--window);
    box-shadow: inset 1px 1px var(--window-mid), inset -1px -1px var(--window-dark);
    cursor: pointer;
    transition: transform 80ms linear;
}

.track-box:hover,
.track-box:focus-visible {
    z-index: 2;
    outline: 1px dotted #000;
    outline-offset: -5px;
    transform: scale(1.14);
}

.track-box.playing {
    border-color: #a9ff00 #245000 #245000 #a9ff00;
    background: #4d7700;
}

.track-box.previewing {
    border-color: #ffff00 #000080 #000080 #ffff00;
    background: #000080;
    animation: preview-flash 550ms steps(2) infinite;
}

@keyframes preview-flash {
    50% { filter: brightness(1.3); }
}

.track-box.unavailable {
    cursor: not-allowed;
    filter: grayscale(1);
    opacity: 0.38;
}

.track-box img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    image-rendering: auto;
}

.track-box .play-corner {
    position: absolute;
    right: 1px;
    bottom: 1px;
    display: grid;
    width: 12px;
    height: 12px;
    place-items: center;
    background: #000080;
    color: #fff;
    font-size: 7px;
}

.track-box.playing .play-corner {
    background: #a9ff00;
    color: #000;
}

.status-bar {
    display: grid;
    grid-template-columns: minmax(110px, 0.65fr) minmax(210px, 1.2fr) auto;
    gap: 3px;
    padding: 5px;
}

.status-bar > span {
    min-width: 0;
    padding: 3px 5px;
    border: 1px inset var(--window);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#preview-status {
    min-width: 76px;
    text-align: center;
}

.player-menu {
    display: flex;
    gap: 18px;
    padding: 5px 8px;
}

.screen-bezel {
    position: relative;
    min-height: 0;
    flex: 1;
    margin: 0 6px;
    border: 3px inset var(--window);
    background: #000;
    overflow: hidden;
}

.screen-bezel::after {
    position: absolute;
    inset: 0;
    z-index: 3;
    pointer-events: none;
    background: repeating-linear-gradient(
        to bottom,
        transparent 0,
        transparent 3px,
        rgba(255, 255, 255, 0.035) 3px,
        rgba(255, 255, 255, 0.035) 4px
    );
    content: "";
}

.player-placeholder {
    display: flex;
    height: 100%;
    min-height: 280px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 26px;
    background:
        radial-gradient(circle, #12296a 0, #050924 47%, #000 78%);
    color: #fff;
    text-align: center;
}

.boot-copy {
    display: flex;
    flex-direction: column;
}

.boot-copy strong {
    color: #fff;
    font-family: "Arial Narrow", Arial, sans-serif;
    font-size: clamp(32px, 6vw, 72px);
    font-weight: 700;
    letter-spacing: 0.12em;
    line-height: 1;
}

.boot-copy span {
    margin-top: 10px;
    color: #a9ff00;
    font-family: "Courier New", monospace;
    font-size: 11px;
    letter-spacing: 0.18em;
}

.player-placeholder p {
    margin: 0;
    color: #c0c0c0;
    font-family: "Courier New", monospace;
    font-size: 10px;
    letter-spacing: 0.12em;
}

.equalizer {
    display: flex;
    height: 58px;
    align-items: end;
    gap: 5px;
}

.equalizer i {
    width: 9px;
    height: 60%;
    background: linear-gradient(#ffff00 0 20%, #a9ff00 20% 55%, #00a000 55%);
    animation: equalize 550ms steps(4) infinite alternate;
}

.equalizer i:nth-child(2n) { animation-delay: -200ms; height: 90%; }
.equalizer i:nth-child(3n) { animation-delay: -350ms; height: 35%; }
.equalizer i:nth-child(5n) { animation-delay: -100ms; height: 75%; }

@keyframes equalize {
    to { height: 18%; }
}

#youtube-player-container,
#youtube-player,
.audio-player-visual {
    width: 100%;
    height: 100%;
    min-height: 280px;
}

#youtube-player {
    display: block;
    border: 0;
}

.audio-player-visual {
    position: relative;
}

.audio-player-visual img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.audio-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    padding: 4px 7px;
    border: 1px solid #fff;
    background: #000080;
    color: #fff;
    font-weight: bold;
}

.lcd-display {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    min-height: 54px;
    margin: 6px;
    padding: 6px 8px;
    border: 2px inset var(--window);
    background:
        repeating-linear-gradient(0deg, rgba(105, 255, 140, 0.04) 0 1px, transparent 1px 3px),
        var(--lcd);
    color: var(--lcd-green);
    font-family: "Courier New", monospace;
}

.lcd-display > span {
    font-size: 10px;
}

.lcd-display div {
    min-width: 0;
}

.lcd-display strong,
.lcd-display small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.lcd-display strong {
    font-size: 13px;
}

.lcd-display small {
    margin-top: 3px;
    color: #48a962;
    font-size: 9px;
}

.transport {
    display: flex;
    gap: 5px;
    padding: 0 6px 6px;
}

.transport button {
    height: 34px;
    min-width: 44px;
    font-weight: bold;
}

.transport .wide-button {
    min-width: 82px;
    margin-left: auto;
    font-size: 10px;
}

.player-status {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin: 0 6px 6px;
    padding: 4px 6px;
    border: 1px inset var(--window);
    overflow: hidden;
}

.player-status span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.taskbar {
    display: flex;
    gap: 5px;
    align-items: center;
    min-width: 0;
    margin: 0 -7px;
    padding: 4px 6px;
    border-top: 2px solid #fff;
    background: var(--window);
}

.start-button,
.task-button,
.tray {
    display: flex;
    height: 29px;
    align-items: center;
    gap: 5px;
    padding: 3px 8px;
    border: 2px solid;
    border-color: var(--window-light) var(--window-black) var(--window-black) var(--window-light);
    background: var(--window);
    color: #000;
    font-weight: bold;
    text-decoration: none;
}

.start-logo {
    display: grid;
    width: 18px;
    height: 18px;
    place-items: center;
    background: #111;
    color: #fff;
    font: 700 8px Arial, sans-serif;
}

.task-button {
    width: min(220px, 20vw);
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.task-button.active {
    border-color: var(--window-black) var(--window-light) var(--window-light) var(--window-black);
    background:
        repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.35) 0 1px, transparent 1px 3px),
        #c8c8c8;
}

.tray {
    margin-left: auto;
    border-width: 1px;
    border-color: var(--window-dark) var(--window-light) var(--window-light) var(--window-dark);
    font-weight: normal;
}

.tray-speaker {
    font-weight: bold;
}

.hover-card {
    position: fixed;
    z-index: 9999;
    display: none;
    width: 260px;
    padding: 5px;
    border: 2px solid;
    border-color: var(--window-light) var(--window-black) var(--window-black) var(--window-light);
    background: var(--window);
    box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.6);
    pointer-events: none;
}

.hover-card.visible {
    display: grid;
    grid-template-columns: 104px 1fr;
    gap: 8px;
}

.hover-card img {
    width: 104px;
    height: 104px;
    border: 2px inset var(--window);
    object-fit: cover;
}

.hover-card div {
    min-width: 0;
    padding-top: 3px;
}

.hover-card strong,
.hover-card span,
.hover-card em {
    display: block;
}

.hover-card strong {
    font-size: 14px;
    line-height: 1.1;
    overflow-wrap: anywhere;
}

.hover-card span {
    margin-top: 8px;
    color: #444;
    font-size: 10px;
    text-transform: uppercase;
}

.hover-card em {
    width: max-content;
    margin-top: 10px;
    padding: 3px 4px;
    background: #000080;
    color: #fff;
    font-size: 9px;
    font-style: normal;
}

@media (max-width: 900px) {
    body {
        overflow: auto;
    }

    .desktop {
        display: flex;
        height: auto;
        min-height: 100vh;
        flex-direction: column;
        padding-bottom: 38px;
    }

    .app-banner {
        grid-template-columns: 1fr auto;
    }

    .app-banner > p {
        display: none;
    }

    .workspace {
        display: flex;
        flex-direction: column;
    }

    .archive-window {
        height: 72vh;
        min-height: 580px;
    }

    .player-window {
        min-height: 70vh;
    }

    .taskbar {
        position: fixed;
        right: 0;
        bottom: 0;
        left: 0;
        z-index: 9000;
        margin: 0;
    }

    .player-task {
        display: none;
    }
}

@media (max-width: 580px) {
    .desktop {
        padding: 3px 3px 38px;
        gap: 4px;
    }

    .app-banner {
        gap: 10px;
    }

    .banner-wordmark {
        font-size: 31px;
    }

    .app-banner dl {
        gap: 10px;
    }

    .app-banner dl div:last-child {
        display: none;
    }

    .menu-bar {
        gap: 12px;
        overflow-x: auto;
    }

    .archive-toolbar {
        grid-template-columns: 1fr auto;
    }

    .archive-toolbar label:first-child {
        grid-column: 1 / -1;
    }

    .archive-toolbar label span {
        width: 43px;
    }

    .status-bar {
        grid-template-columns: 1fr auto;
    }

    #archive-help {
        display: none;
    }

    .vertical-album-title {
        height: 90px;
    }

    .track-box,
    .track-placeholder {
        width: 45px;
        height: 45px;
    }

    .album-column {
        min-width: 47px;
    }

    .hover-card {
        display: none !important;
    }

    .task-button {
        width: auto;
        flex: 1;
    }

    .lcd-display {
        grid-template-columns: minmax(0, 1fr) auto;
    }

    .lcd-display > span:first-child {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
    }
}
