: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);
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    height: 100%;
    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);
    font-family: "Avenir Next", "Helvetica Neue", Helvetica, Arial, sans-serif;
    overflow: hidden;
}

body {
    position: relative;
}

.viewer-shell {
    position: relative;
    width: 100%;
    height: 100dvh;
    overflow: hidden;
}

#viewer {
    position: absolute;
    inset: 0;
}

canvas {
    display: block;
}

.info-panel,
.control-panel,
.lang-switch,
.loader-card,
.desktop-scene-menu {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

.brand {
    position: absolute;
    top: 10px;
    left: 118px;
    z-index: 24;
    display: inline-flex;
    flex-direction: column;
    gap: 1px;
    padding: 0;
    max-width: min(340px, calc(100vw - 420px));
}

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

.desktop-scene-menu {
    position: absolute;
    left: 0;
    bottom: calc(100% + 6px);
    display: flex;
    flex-direction: column;
    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-toggle {
    appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 68px;
    height: 28px;
    padding: 0 10px;
    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);
    box-shadow: var(--glass-highlight), var(--glass-shadow);
    color: var(--text);
    font: inherit;
    font-size: 11px;
    line-height: 1;
    letter-spacing: 0.04em;
    cursor: pointer;
    transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.desktop-scene-menu-toggle:hover,
.desktop-scene-menu-toggle.is-open {
    transform: translateY(-1px);
    border-color: var(--border-strong);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.04)),
        var(--glass-panel-strong);
}

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

.desktop-scene-menu-button {
    appearance: none;
    width: 100%;
    padding: 7px 8px;
    border: 1px solid var(--border);
    color: var(--text);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.10), rgba(255, 255, 255, 0.03));
    text-align: left;
    font: inherit;
    font-size: 11px;
    line-height: 1.35;
    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);
}

.desktop-scene-menu-button.is-arabic {
    direction: rtl;
    text-align: right;
}

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

.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;
}

.brand-title {
    margin: 0;
    font-size: 13px;
    line-height: 1.1;
    font-weight: 600;
    text-shadow:
        0 1px 2px rgba(0, 0, 0, 0.85),
        0 4px 18px rgba(0, 0, 0, 0.5);
}

.brand-subtitle {
    margin: 0;
    font-size: 9px;
    line-height: 1.2;
    color: var(--muted);
    text-shadow:
        0 1px 2px rgba(0, 0, 0, 0.85),
        0 4px 18px rgba(0, 0, 0, 0.5);
}

.lang-switch {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 24;
    display: inline-flex;
    gap: 4px;
    padding: 4px;
    background: var(--glass-panel);
    border: 1px solid rgba(255, 255, 255, 0.16);
    box-shadow: var(--glass-highlight), var(--glass-shadow);
}

.archive-link {
    position: absolute;
    top: 50px;
    left: 8px;
    z-index: 24;
    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);
    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;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.archive-link:hover {
    transform: translateY(-1px);
    border-color: var(--border-strong);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.04)),
        var(--glass-panel-strong);
}

.lang-button {
    appearance: none;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text);
    font: inherit;
    font-size: 11px;
    line-height: 1;
    padding: 6px 8px;
    cursor: pointer;
    opacity: 0.72;
    transition: opacity 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

.lang-button.active {
    opacity: 1;
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.18);
}

.info-panel {
    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);
}

.info-panel h2 {
    margin: 0 0 8px;
    font-size: 17px;
    line-height: 1.35;
}

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

.info-panel p.is-english {
    text-align: justify;
    text-justify: inter-word;
}

.is-arabic {
    direction: rtl;
    text-align: right;
}

.status-badge {
    margin-top: 10px;
    font-size: 11px;
    line-height: 1.5;
    color: var(--muted);
}

.status-badge:empty {
    display: none;
}

.nav-button,
.scene-button,
.playback-button,
.side-button,
.mobile-button {
    appearance: none;
    border: 1px solid var(--border);
    color: var(--text);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.10), rgba(255, 255, 255, 0.03));
    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);
}

.nav-button:hover,
.scene-button:hover,
.playback-button:hover,
.side-button:hover,
.mobile-button:hover {
    transform: translateY(-1px);
    border-color: var(--border-strong);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.05));
}

.control-panel {
    position: absolute;
    left: 8px;
    right: 8px;
    bottom: 8px;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: var(--glass-panel);
    border: 1px solid rgba(255, 255, 255, 0.16);
    box-shadow: var(--glass-highlight), var(--glass-shadow);
}

.nav-button {
    width: 42px;
    height: 42px;
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

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

.scene-list {
    display: flex;
    gap: 8px;
    flex: 1 1 auto;
    overflow-x: auto;
    scrollbar-width: none;
}

.playback-controls {
    position: absolute;
    right: 8px;
    bottom: 79px;
    z-index: 21;
    display: flex;
    align-items: center;
    gap: 8px;
    width: min(240px, calc(100vw - 16px));
    padding: 0;
    background: transparent;
    border: 0;
    box-shadow: none;
}

.playback-button {
    width: 32px;
    height: 32px;
    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: transparent;
    border-color: rgba(255, 255, 255, 0.28);
    box-shadow: none;
}

.timeline {
    flex: 1 1 auto;
    width: 100%;
    accent-color: var(--accent);
    opacity: 0.92;
}

.scene-list::-webkit-scrollbar {
    display: none;
}

.scene-button {
    padding: 10px 14px;
    font-size: 13px;
    white-space: nowrap;
    flex: 0 0 auto;
}

.scene-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;
}

.side-nav,
.mobile-toolbar {
    display: none;
}

.side-nav {
    position: absolute;
    inset: 0;
    z-index: 22;
    pointer-events: none;
}

.mobile-toolbar {
    position: absolute;
    inset: 0;
    z-index: 22;
    pointer-events: none;
}

.side-button,
.mobile-button {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 58px;
    height: 58px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    pointer-events: auto;
    background: var(--glass-panel);
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: var(--glass-highlight), var(--glass-shadow);
}

#desktop-prev,
#mobile-prev {
    left: 8px;
}

#desktop-next,
#mobile-next {
    right: 8px;
}

.loader {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    background: rgba(4, 7, 10, 0.22);
    z-index: 26;
    pointer-events: none;
}

.loader[hidden] {
    display: none;
}

.loader-card {
    min-width: min(320px, calc(100vw - 40px));
    padding: 0;
    background: transparent;
    border: 0;
    box-shadow: none;
    font-size: 13px;
    color: var(--muted);
}

.loader-label {
    margin-bottom: 10px;
    color: #f4f6f8;
    text-shadow:
        0 1px 2px rgba(0, 0, 0, 0.85),
        0 6px 18px rgba(0, 0, 0, 0.55);
}

.loader-bar {
    width: 100%;
    height: 8px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
    overflow: hidden;
}

.loader-bar-fill {
    width: 0%;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, rgba(217, 184, 108, 0.72), rgba(217, 184, 108, 1));
    transition: width 0.18s ease;
}

.loader-progress {
    margin-top: 8px;
    font-size: 11px;
    text-align: right;
    color: rgba(244, 246, 248, 0.9);
    text-shadow:
        0 1px 2px rgba(0, 0, 0, 0.85),
        0 6px 18px rgba(0, 0, 0, 0.55);
}

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

    .info-panel {
        top: 8px;
        right: 8px;
        left: 8px;
        width: auto;
        padding: 9px 10px;
    }

    .info-panel h2 {
        margin: 0 0 6px;
        font-size: 15px;
        line-height: 1.3;
    }

    .info-panel p {
        font-size: 11px;
        line-height: 1.5;
    }

    .mobile-toolbar {
        display: grid;
    }

    .control-panel {
        display: none;
    }

    .playback-controls {
        bottom: 71px;
        width: 90vw;
        max-width: 90vw;
        left: 50%;
        right: auto;
        transform: translateX(-50%);
    }

    .brand {
        top: auto;
        left: 10px;
        bottom: 14px;
        max-width: calc(100vw - 20px);
    }

    .lang-switch {
        top: auto;
        left: auto;
        right: 10px;
        bottom: auto;
        margin-top: 0;
        transform: none;
        padding: 3px;
    }

    .archive-link {
        top: auto;
        left: auto;
        right: 10px;
        padding: 7px 10px;
        font-size: 11px;
    }

    .lang-button {
        font-size: 10px;
        padding: 5px 7px;
    }

    .side-nav {
        display: none;
    }

    .mobile-button {
        width: 50px;
        height: 50px;
        top: 50% !important;
        transform: translateY(-50%) !important;
    }

    #mobile-prev,
    #mobile-next {
        top: 50% !important;
    }
}
