.box-window {
    width: min(860px, calc(100vw - 36px));
    height: min(560px, calc(100vh - 36px));
    zoom: var(--ui-scale);
}

body.fit-window .box-window {
    width: min(980px, calc(100vw / var(--ui-scale) - 20px));
    height: min(720px, calc(100vh / var(--ui-scale) - 20px));
}

.box-command-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 8px;
    min-height: 40px;
    padding: 6px 8px;
}

.box-toolbar-button {
    width: auto;
    min-width: 158px;
    display: inline-flex;
    gap: 6px;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
}

.box-toolbar-button img {
    width: 16px;
    height: 16px;
    image-rendering: pixelated;
}

.box-address {
    grid-column: 1;
    min-width: 0;
    width: 100%;
    height: 24px;
    display: flex;
    align-items: center;
    padding: 0 6px;
    overflow: hidden;
    color: #000000;
    background: #ffffff;
    border-top: 1px solid #808080;
    border-left: 1px solid #808080;
    border-right: 1px solid #dfdfdf;
    border-bottom: 1px solid #dfdfdf;
    font-family: inherit;
    font-size: 13px;
    line-height: 13px;
    text-align: left;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.win98-window.popup-window {
    display: none;
}

.win98-window.popup-window.is-visible {
    display: flex;
}

.box-meta {
    min-height: 24px;
    padding: 0 8px 6px;
    color: #333333;
    font-size: 12px;
    line-height: 12px;
}

.box-meta span {
    display: flex;
    align-items: center;
    min-height: 18px;
}

.box-panel {
    flex: 1;
    min-height: 0;
    margin: 0 8px 8px;
    overflow: auto;
    background-color: #ffffff;
    background-image:
        linear-gradient(180deg, rgba(255,255,255,.9), rgba(238,238,238,.58)),
        repeating-linear-gradient(0deg, rgba(0,0,0,.025) 0 1px, transparent 1px 6px);
}

.box-file-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
    gap: 8px;
    padding: 10px;
    box-sizing: border-box;
}

.box-file {
    min-width: 0;
    height: 96px;
    display: grid;
    grid-template-rows: 34px 18px 28px;
    justify-items: center;
    align-items: center;
    padding: 8px 6px;
    color: #000000;
    text-decoration: none;
}

.box-file.is-loading,
.box-file.is-failed {
    color: #666666;
    filter: grayscale(1);
}

.box-file.is-loading {
    animation: box-loading-pulse 900ms steps(2, end) infinite;
}

.box-file.is-failed {
    opacity: 0.58;
}

.box-file.is-failed .box-file-name::after {
    content: " (failed)";
}

.box-file[aria-disabled="true"] {
    cursor: default;
}

.box-file:hover,
.box-file:focus-visible {
    color: #ffffff;
    background: #000078;
    outline: 1px dotted #ffffff;
    outline-offset: -3px;
}

.box-file-icon {
    width: 32px;
    height: 32px;
    object-fit: contain;
    image-rendering: pixelated;
}

.box-file.has-thumbnail .box-file-icon {
    width: 40px;
    height: 32px;
    object-fit: cover;
    background: #ffffff;
    border: 1px solid #808080;
}

.box-file-name,
.box-file-meta {
    width: 100%;
    min-width: 0;
    overflow: hidden;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@keyframes box-loading-pulse {
    0% {
        opacity: 0.48;
    }

    100% {
        opacity: 0.82;
    }
}

.box-file-name {
    font-size: 13px;
    line-height: 13px;
}

.box-file-meta {
    align-self: start;
    color: #555555;
    font-size: 11px;
    line-height: 13px;
}

.box-file:hover .box-file-meta,
.box-file:focus-visible .box-file-meta {
    color: #ffffff;
}

.box-context-menu {
    position: fixed;
    min-width: 168px;
    display: none;
    padding: 2px;
    background: var(--w98-gray);
    border-top: 2px solid #ffffff;
    border-left: 2px solid #ffffff;
    border-right: 2px solid #000000;
    border-bottom: 2px solid #000000;
    box-shadow: 3px 3px 0 rgba(0,0,0,.35);
    z-index: 95;
}

.box-context-menu.is-visible {
    display: block;
}

.box-context-menu button {
    width: 100%;
    min-height: 24px;
    display: grid;
    grid-template-columns: 20px minmax(0, 1fr);
    gap: 8px;
    align-items: center;
    padding: 2px 7px;
    color: #000000;
    background: transparent;
    border: 0;
    font-family: inherit;
    font-size: 12px;
    line-height: 13px;
    text-align: left;
}

.box-context-menu button:hover,
.box-context-menu button:focus-visible {
    color: #ffffff;
    background: #000078;
    outline: none;
}

.box-context-menu img {
    width: 16px;
    height: 16px;
    object-fit: contain;
    image-rendering: pixelated;
}

.properties-grid {
    display: grid;
    grid-template-columns: 92px minmax(0, 1fr);
    gap: 7px 10px;
    padding: 10px;
    background: #dfdfdf;
    border-top: 1px solid #808080;
    border-left: 1px solid #808080;
    border-right: 1px solid #ffffff;
    border-bottom: 1px solid #ffffff;
}

.properties-grid dt {
    font-weight: bold;
}

.properties-grid dd {
    min-width: 0;
    margin: 0;
    overflow-wrap: anywhere;
}

.preview-frame {
    width: min(680px, 100%);
    min-height: 260px;
    max-height: min(520px, calc(100vh - 160px));
    display: block;
    margin: 0 auto;
    background: #000000;
    border: 1px solid #808080;
}

.preview-frame.is-text {
    min-height: 240px;
    padding: 10px;
    overflow: auto;
    color: #00ff66;
    font-family: 'MonoCraft', 'PixelOperatorMono', 'Courier New', monospace;
    font-size: 12px;
    line-height: 15px;
    white-space: pre;
}

.preview-frame.is-text code {
    display: inline-block;
    min-width: 100%;
    color: inherit;
    font: inherit;
    white-space: inherit;
}

.box-empty {
    margin: 0;
    padding: 12px;
    color: #555555;
    font-size: 13px;
    line-height: 15px;
}

.box-statusbar {
    grid-template-columns: 1fr 96px;
}

@media (max-width: 600px) {
    main {
        display: block;
        min-height: 100dvh;
        padding: 0;
    }

    .box-window {
        width: 100vw;
        height: 100dvh;
        border: 0;
        box-shadow: none;
        zoom: 1;
    }

    .box-titlebar {
        height: 24px;
        margin: 0;
    }

    .box-menu {
        height: 26px;
    }

    .box-command-row {
        grid-template-columns: 1fr 1fr;
    }

    .box-address {
        grid-column: 1 / -1;
        grid-row: 1;
    }

    .box-panel {
        margin: 0 6px 8px;
    }

    .box-file-grid {
        grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
    }
}
