:root {
    --bg: #0f1418;
    --panel: rgba(12, 18, 24, 0.72);
    --panel-strong: rgba(10, 15, 20, 0.88);
    --border: rgba(255, 255, 255, 0.14);
    --border-strong: rgba(255, 255, 255, 0.28);
    --text: #edf2f7;
    --muted: rgba(237, 242, 247, 0.72);
    --accent: #d9b86c;
    --shadow: 0 24px 54px rgba(0, 0, 0, 0.32);
    --glass-panel:
        linear-gradient(180deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.04)),
        linear-gradient(135deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.01)),
        rgba(12, 18, 24, 0.56);
    --glass-panel-strong:
        linear-gradient(180deg, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0.05)),
        linear-gradient(135deg, rgba(255, 255, 255, 0.10), rgba(255, 255, 255, 0.02)),
        rgba(10, 15, 20, 0.64);
    --glass-highlight: inset 0 1px 0 rgba(255, 255, 255, 0.14);
    --glass-shadow: 0 18px 42px rgba(0, 0, 0, 0.30);
}

html,
body {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: "Avenir Next", "Helvetica Neue", Helvetica, Arial, sans-serif;
    background:
        radial-gradient(circle at top left, rgba(217, 184, 108, 0.08), transparent 24%),
        radial-gradient(circle at top right, rgba(97, 132, 164, 0.08), transparent 28%),
        linear-gradient(180deg, #000000 0%, #000000 100%);
    color: var(--text);
    overflow: hidden;
    overscroll-behavior: none;
    overscroll-behavior-x: none;
}

.app-container {
    height: 100dvh;
    position: relative;
    overscroll-behavior: none;
    overscroll-behavior-x: none;
}

.viewer-wrapper {
    position: relative;
    height: 100%;
    overscroll-behavior: none;
    overscroll-behavior-x: none;
}

#content-host,
#iframe-target,
#iframe-target iframe,
#viewer-target,
#viewer-target canvas {
    width: 100%;
    height: 100%;
    border: none;
}

#content-host {
    position: relative;
    height: 100%;
    background: #000;
}

#iframe-target,
#viewer-target {
    position: absolute;
    inset: 0;
}

#viewer-target {
    display: none;
}

#content-host.mode-spz #viewer-target {
    display: block;
}

#content-host.mode-spz #iframe-target {
    display: none;
}

#viewer-loader {
    position: absolute;
    inset: 0;
    z-index: 40;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(8, 12, 18, 0.42);
    pointer-events: none;
}

#viewer-loader.visible {
    display: flex;
}

.viewer-loader-card {
    min-width: 220px;
    max-width: 280px;
    padding: 14px 16px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.03)),
        var(--glass-bg-strong);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow), var(--glass-highlight);
    -webkit-backdrop-filter: blur(10px) saturate(120%);
    backdrop-filter: blur(10px) saturate(120%);
}

.viewer-loader-text {
    font-size: 13px;
    margin-bottom: 8px;
}

.viewer-loader-bar {
    height: 5px;
    background: rgba(255, 255, 255, 0.14);
    overflow: hidden;
}

.viewer-loader-fill {
    width: 0;
    height: 100%;
    background: linear-gradient(90deg, rgba(140, 196, 255, 0.45), rgba(140, 196, 255, 0.95));
}

.viewer-loader-progress {
    margin-top: 8px;
    font-size: 11px;
    text-align: right;
    color: var(--glass-text-soft);
}

#controls,
#playback-controls,
#desktop-scene-menu {
    position: absolute;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--glass-panel);
    border: 1px solid rgba(255, 255, 255, 0.16);
    box-shadow: var(--glass-highlight), var(--glass-shadow);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
}

#controls {
    left: 8px;
    right: 8px;
    bottom: 8px;
    padding: 10px;
}

#desktop-scene-menu-wrap {
    position: absolute;
    left: 10px;
    bottom: 78px;
    z-index: 22;
}

#desktop-scene-menu {
    left: 0;
    bottom: calc(100% + 6px);
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    width: max-content;
    max-width: min(420px, calc(100vw - 28px));
    max-height: min(34vh, 280px);
    padding: 8px 8px 7px;
    background: var(--glass-panel-strong);
    border: 1px solid rgba(255, 255, 255, 0.18);
    box-shadow: var(--glass-highlight), var(--glass-shadow);
}

#desktop-scene-menu[hidden] {
    display: none;
}

#desktop-scene-menu-list {
    display: flex;
    flex-direction: column;
    gap: 5px;
    overflow-y: auto;
    padding-right: 2px;
    max-width: 100%;
}

#playback-controls {
    right: 8px;
    left: auto;
    bottom: 79px;
    z-index: 951;
    display: none;
    align-items: center;
    gap: 8px;
    width: min(240px, calc(100vw - 16px));
    padding: 6px 8px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.10), rgba(255, 255, 255, 0.03)),
        rgba(9, 14, 20, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 12px 26px rgba(0, 0, 0, 0.24);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
}

#playback-controls.visible {
    display: flex;
}

#content-buttons-wrapper {
    flex: 1;
    min-width: 0;
    display: flex;
    gap: 8px;
    overflow-x: auto;
    white-space: nowrap;
    scrollbar-width: thin;
    scrollbar-color: rgba(200, 220, 255, 0.38) transparent;
}

#content-buttons-wrapper::-webkit-scrollbar {
    height: 8px;
}

#content-buttons-wrapper::-webkit-scrollbar-track {
    background: transparent;
}

#content-buttons-wrapper::-webkit-scrollbar-thumb {
    background-color: rgba(200, 220, 255, 0.3);
    border-radius: 4px;
}

button,
#playback-slider {
    appearance: none;
}

#controls button,
#playback-controls button,
#desktop-scene-menu-toggle,
#list-toggle-btn,
#info-toggle-btn,
#fullscreen-btn,
#list-modal-close,
.desktop-scene-menu-button {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.10), rgba(255, 255, 255, 0.03));
    color: var(--text);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
}

#controls button,
#playback-controls button {
    padding: 7px 14px;
    margin: 0;
    font-size: 13px;
    display: inline-flex;
    justify-content: center;
    align-items: center;
}

#content-buttons-wrapper button {
    flex: 0 0 auto;
    white-space: nowrap;
}

#desktop-scene-menu-toggle {
    appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 68px;
    height: 28px;
    padding: 0 10px;
    font: inherit;
    font-size: 11px;
    line-height: 1;
    letter-spacing: 0.04em;
}

.desktop-scene-menu-button {
    appearance: none;
    width: 100%;
    padding: 7px 8px;
    text-align: left;
    font: inherit;
    font-size: 11px;
    line-height: 1.35;
}

#controls button.active {
    background:
        linear-gradient(180deg, rgba(217, 184, 108, 0.38), rgba(217, 184, 108, 0.14)),
        rgba(43, 36, 20, 0.82);
    border-color: rgba(217, 184, 108, 0.72);
    color: #fff7e7;
}

#controls button:hover,
#playback-controls button:hover,
#desktop-scene-menu-toggle:hover,
.desktop-scene-menu-button:hover,
#desktop-scene-menu-toggle.is-open {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.05));
    border-color: var(--border-strong);
    transform: translateY(-1px);
}

.desktop-scene-menu-button.active {
    background:
        linear-gradient(180deg, rgba(217, 184, 108, 0.38), rgba(217, 184, 108, 0.14)),
        rgba(43, 36, 20, 0.82);
    border-color: rgba(217, 184, 108, 0.72);
    color: #fff7e7;
}

#prev-btn,
#next-btn {
    width: 42px;
    height: 42px;
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

#playback-toggle {
    width: 34px;
    height: 34px;
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    font-size: 14px;
    line-height: 1;
    white-space: nowrap;
    background:
        linear-gradient(180deg, rgba(217, 184, 108, 0.22), rgba(217, 184, 108, 0.08)),
        rgba(26, 22, 14, 0.74);
    border-color: rgba(217, 184, 108, 0.5);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 4px 12px rgba(0, 0, 0, 0.18);
}

#playback-slider {
    flex: 1 1 auto;
    width: 100%;
    min-width: 0;
    accent-color: var(--accent);
    opacity: 1;
    background: transparent;
}

#playback-slider::-webkit-slider-runnable-track {
    height: 8px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.16);
    border: 1px solid rgba(255, 255, 255, 0.34);
    box-sizing: border-box;
}

#playback-slider::-webkit-slider-thumb {
    appearance: none;
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    margin-top: -4px;
    border: 1px solid rgba(255, 255, 255, 0.56);
    border-radius: 999px;
    background: var(--accent);
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.2), 0 0 12px rgba(217, 184, 108, 0.22);
    box-sizing: border-box;
}

#playback-slider::-moz-range-track {
    height: 8px;
    border: 1px solid rgba(255, 255, 255, 0.34);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.16);
    box-sizing: border-box;
}

#playback-slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border: 1px solid rgba(255, 255, 255, 0.56);
    border-radius: 999px;
    background: var(--accent);
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.2), 0 0 12px rgba(217, 184, 108, 0.22);
    box-sizing: border-box;
}

.archives-index-link {
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 1100;
    display: inline-flex;
    align-items: center;
    padding: 8px 12px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0.02)),
        var(--glass-panel-strong);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    box-shadow: var(--glass-highlight), var(--glass-shadow);
    color: var(--text);
    font-size: 12px;
    line-height: 1;
    letter-spacing: 0.02em;
    text-decoration: none;
    white-space: nowrap;
}

.icon {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
}

#prev-btn .icon,
#next-btn .icon {
    width: 24px;
    height: 24px;
    stroke-width: 2.5;
}

#info-box {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 20;
    width: min(360px, calc(100vw - 28px));
    padding: 14px 15px;
    background: var(--glass-panel-strong);
    border: 1px solid rgba(255, 255, 255, 0.18);
    box-shadow: var(--glass-highlight), var(--glass-shadow);
    max-height: calc(100% - 16px);
    overflow-y: auto;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
}

#info-box h3 {
    margin: 0 0 8px;
    font-size: 17px;
    line-height: 1.35;
}

#info-box p {
    margin: 0;
    font-size: 12px;
    line-height: 1.65;
    color: var(--muted);
}

#credit-display {
    margin-top: 10px;
    font-size: 11px;
    line-height: 1.5;
    color: var(--muted);
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    padding-top: 8px;
}

#credit-display a {
    color: #a9cbff;
    text-decoration: none;
}

#credit-display a:hover {
    text-decoration: underline;
}

.mobile-ui {
    display: none;
}

#overlay-buttons {
    display: none !important;
}

#list-modal {
    position: fixed;
    inset: 0;
    background:
        radial-gradient(circle at top, rgba(122, 176, 255, 0.12), transparent 38%),
        rgba(6, 10, 18, 0.72);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
    -webkit-backdrop-filter: blur(8px) saturate(110%);
    backdrop-filter: blur(8px) saturate(110%);
}

#list-modal.visible {
    opacity: 1;
    visibility: visible;
}

#list-modal-header {
    padding: 15px;
    text-align: right;
}

#list-modal-content {
    flex-grow: 1;
    overflow-y: auto;
    padding: 0 15px 15px;
}

.list-item {
    padding: 15px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 0;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02));
    color: #eee;
    font-size: 16px;
    cursor: pointer;
    margin-bottom: 10px;
    box-shadow: var(--glass-highlight);
    transition: background-color 0.2s, border-color 0.2s, transform 0.2s;
}

.list-item.active {
    background:
        linear-gradient(180deg, rgba(217, 184, 108, 0.38), rgba(217, 184, 108, 0.14)),
        rgba(43, 36, 20, 0.82);
    border-color: rgba(217, 184, 108, 0.72);
    color: #fff7e7;
}

@media (max-width: 860px) {
    #desktop-scene-menu-wrap {
        display: none;
    }

    #controls {
        display: none;
    }

    #playback-controls {
        bottom: 96px;
        width: min(86vw, 360px);
        max-width: min(86vw, 360px);
        left: 50%;
        right: auto;
        transform: translateX(-50%);
    }

    .mobile-ui {
        display: flex;
        align-items: center;
        justify-content: center;
        background: none;
        border: none;
        cursor: pointer;
        color: white;
    }

    #mobile-controls {
        position: absolute;
        inset: 0;
        z-index: 22;
        pointer-events: none;
        display: block;
        padding: 0;
    }

    #mobile-prev,
    #mobile-next {
        position: absolute;
        width: 50px;
        height: 50px;
        top: 50% !important;
        transform: translateY(-50%) !important;
        padding: 0;
        background: var(--glass-panel);
        border: 1px solid rgba(255, 255, 255, 0.2);
        box-shadow: var(--glass-highlight), var(--glass-shadow);
        pointer-events: auto;
    }

    #mobile-prev {
        left: 8px;
    }

    #mobile-next {
        right: 8px;
    }

    #mobile-prev .icon,
    #mobile-next .icon {
        width: 20px;
        height: 20px;
        stroke-width: 2.2;
    }

    #mobile-center-controls {
        position: absolute;
        left: 50%;
        bottom: 10px;
        transform: translateX(-50%);
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 8px;
        pointer-events: auto;
    }

    #scene-counter {
        font-size: 14px;
        font-weight: bold;
        line-height: 1;
        text-shadow:
            0 1px 2px rgba(0, 0, 0, 0.85),
            0 4px 18px rgba(0, 0, 0, 0.5);
    }

    #list-toggle-btn {
        width: 60px;
        height: 60px;
        padding: 0;
        background: var(--glass-panel);
        border: 1px solid rgba(255, 255, 255, 0.2);
        box-shadow: var(--glass-highlight), var(--glass-shadow);
    }

    #list-toggle-btn .icon {
        width: 28px;
        height: 28px;
    }

    #info-box {
        top: 8px;
        right: 8px;
        left: 8px;
        width: auto;
        bottom: auto;
        max-height: none;
        padding: 9px 10px;
        transition: none;
    }

    #info-box h3 {
        margin: 0 0 6px;
        font-size: 15px;
        line-height: 1.3;
    }

    #info-box p,
    #credit-display {
        font-size: 11px;
        line-height: 1.5;
    }

    #overlay-buttons {
        display: none !important;
    }

    #info-toggle-btn,
    #fullscreen-btn {
        width: 50px;
        height: 50px;
        background: var(--glass-panel);
        border: 1px solid rgba(255, 255, 255, 0.2);
        box-shadow: var(--glass-highlight), var(--glass-shadow);
    }

    #info-toggle-btn .icon,
    #fullscreen-btn .icon {
        width: 22px;
        height: 22px;
    }

    #fullscreen-btn,
    .archives-index-link {
        display: none;
    }
}
