:root {
    color-scheme: light;
    font-family:
        Inter,
        ui-sans-serif,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
    background: #ececec;
    color: #1f2528;
}

[data-theme="dark"] {
    color-scheme: dark;
    background: #0a0a0c;
    color: #e4e4e7;
}

* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
    margin: 0;
    overflow: hidden;
}

button,
select,
input {
    font: inherit;
}

.viewer-page {
    position: relative;
    width: 100vw;
    height: 100vh;
    perspective: 2200px;
    background-color: #ececec;
    overflow: hidden;
}

.viewer-page[data-flat="true"] {
    perspective: none;
}

[data-theme="dark"] .viewer-page {
    background-color: #0a0a0c;
}

.dynamic-bg {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(
            ellipse at 50% 38%,
            rgba(255, 255, 255, 0.96) 0%,
            rgba(245, 245, 245, 0.82) 35%,
            rgba(224, 224, 224, 0.92) 72%,
            #d7d7d7 100%
        ),
        linear-gradient(180deg, #f4f4f4 0%, #dddddd 100%);
    transition: background 1.5s ease;
    z-index: 0;
}

[data-theme="dark"] .dynamic-bg {
    background:
        radial-gradient(
            ellipse at 50% 38%,
            rgba(40, 40, 48, 0.96) 0%,
            rgba(25, 25, 30, 0.82) 35%,
            rgba(15, 15, 18, 0.92) 72%,
            #0a0a0c 100%
        ),
        linear-gradient(180deg, #121214 0%, #0a0a0c 100%);
}

.dynamic-bg::before,
.dynamic-bg::after {
    content: "";
    position: absolute;
    left: -8vw;
    right: -8vw;
    height: 22vh;
    background: rgba(255, 255, 255, 0.42);
    filter: blur(18px);
    transform: rotate(-3deg);
}

[data-theme="dark"] .dynamic-bg::before,
[data-theme="dark"] .dynamic-bg::after {
    background: rgba(255, 255, 255, 0.04);
}

.dynamic-bg::before {
    top: 10vh;
    box-shadow: 0 32px 70px rgba(90, 90, 90, 0.18);
}

.dynamic-bg::after {
    bottom: 8vh;
    box-shadow: 0 -28px 70px rgba(90, 90, 90, 0.14);
}

.stage {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transform-style: preserve-3d;
    z-index: 1;
    filter: saturate(0.9);
}

.stage[data-flat="true"] {
    transform-style: flat;
}

.camera {
    position: relative;
    transform-style: preserve-3d;
    will-change: transform;
    z-index: 0;
}

.camera[data-mode="flat"] {
    transform-style: flat;
}

.camera.fly-mode {
    transition-timing-function: cubic-bezier(0.66, 0, 0.34, 1);
}

.camera.static-breathing {
    animation: wall-breath 18s infinite ease-in-out;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes wall-breath {
    0%,
    100% {
        margin-top: 0;
        margin-left: 0;
    }
    25% {
        margin-top: -6px;
        margin-left: 4px;
    }
    50% {
        margin-top: 3px;
        margin-left: -5px;
    }
    75% {
        margin-top: -3px;
        margin-left: 3px;
    }
}

.photo-node {
    position: absolute;
    width: 160px;
    height: auto;
    left: 0;
    top: 0;
    overflow: hidden;
    background: #ffffff;
    border: 2px solid rgba(255, 255, 255, 0.84);
    border-radius: 3px;
    padding: 0;
    transition-property:
        transform, filter, opacity, box-shadow, border-color, border-radius,
        padding, width;
    transition-duration: var(--transition-dur, 1.5s);
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform;
    cursor: pointer;
    opacity: 1;
    z-index: 1;
    box-shadow:
        0 8px 16px rgba(68, 72, 74, 0.18),
        0 1px 1px rgba(255, 255, 255, 0.95) inset;
}

[data-theme="dark"] .photo-node {
    background: #1a1a1e;
    border: 2px solid rgba(255, 255, 255, 0.12);
    box-shadow:
        0 8px 16px rgba(0, 0, 0, 0.5),
        0 1px 1px rgba(255, 255, 255, 0.04) inset;
}

.photo-node img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
    border-radius: 1px;
}

.photo-node:hover {
    border-color: #ffffff;
    opacity: 1;
    box-shadow:
        0 12px 24px rgba(65, 70, 72, 0.24),
        0 0 0 1px rgba(255, 255, 255, 0.8);
    z-index: 100 !important;
}

.photo-node.is-active-slide {
    opacity: 1;
    border: 3px solid rgba(255, 255, 255, 0.96) !important;
    border-radius: 10px;
    padding: 0;
    box-shadow:
        0 28px 48px rgba(45, 48, 50, 0.38),
        0 0 0 1px rgba(90, 92, 94, 0.16) !important;
    z-index: 9999 !important;
}

.camera:has(.is-active-slide).static-breathing
    .photo-node:not(.is-active-slide) {
    opacity: 0.36;
    filter: blur(1.2px) grayscale(18%) brightness(1.08);
}

.camera:has(.is-active-slide).fly-mode .photo-node:not(.is-active-slide) {
    opacity: 0.42;
    filter: blur(1px) grayscale(18%);
}

.icon-button {
    width: 44px;
    height: 44px;
    border: 0;
    border-radius: 999px;
    display: grid;
    place-items: center;
    background: rgba(255, 255, 255, 0.72);
    color: #3a4144;
    box-shadow: 0 8px 24px rgba(90, 95, 98, 0.16);
    cursor: pointer;
}

[data-theme="dark"] .icon-button {
    background: rgba(255, 255, 255, 0.1);
    color: #e4e4e7;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.settings-button {
    position: absolute;
    top: 18px;
    left: 18px;
    z-index: 10;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 4px;
}

.settings-button span {
    width: 20px;
    height: 2px;
    display: block;
    background: currentColor;
}

.page-title {
    position: absolute;
    top: 18px;
    left: calc(18px + 44px + 12px);
    height: 44px;
    display: flex;
    align-items: center;
    font-size: 1.1rem;
    font-weight: 300;
    letter-spacing: 0.5px;
    color: #1f2528;
    z-index: 10;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: calc(100vw - 76px);
}

[data-theme="dark"] .page-title {
    color: #e4e4e7;
}

.settings-panel {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(340px, calc(100vw - 32px));
    padding: 76px 18px 20px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    background: rgba(250, 250, 250, 0.78);
    border-right: 1px solid rgba(130, 130, 130, 0.18);
    backdrop-filter: blur(20px);
    transform: translateX(-100%);
    transition: transform 220ms ease;
    z-index: 8;
}

[data-theme="dark"] .settings-panel {
    background: rgba(18, 18, 22, 0.85);
    border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.settings-panel.open {
    transform: translateX(0);
}

.panel-title {
    font-size: 1rem;
    font-weight: 300;
    letter-spacing: 0;
    color: #2f3639;
}

[data-theme="dark"] .panel-title {
    color: #e4e4e7;
}

.field {
    display: grid;
    gap: 8px;
    color: #596165;
    font-size: 0.82rem;
}

[data-theme="dark"] .field {
    color: #a1a1aa;
}

select,
input[type="range"] {
    width: 100%;
}

select {
    height: 42px;
    border: 1px solid rgba(80, 86, 88, 0.14);
    border-radius: 6px;
    padding: 0 12px;
    background: rgba(255, 255, 255, 0.78);
    color: #20272a;
}

[data-theme="dark"] select {
    background: rgba(30, 30, 36, 0.9);
    border-color: rgba(255, 255, 255, 0.12);
    color: #e4e4e7;
}

.segmented {
    display: grid;
    grid-template-columns: 1fr 1fr;
    border: 1px solid rgba(80, 86, 88, 0.14);
    border-radius: 6px;
    overflow: hidden;
}

.segmented button,
.primary-button {
    min-height: 42px;
    border: 0;
    color: #30383b;
    background: rgba(255, 255, 255, 0.76);
    cursor: pointer;
}

[data-theme="dark"] .segmented button,
[data-theme="dark"] .primary-button {
    color: #e4e4e7;
    background: rgba(255, 255, 255, 0.08);
}

.segmented button.active,
.primary-button {
    background: #2f3d40;
    color: #ffffff;
    font-weight: 700;
}

[data-theme="dark"] .segmented button.active,
[data-theme="dark"] .primary-button {
    background: #2f3d40;
}

.toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #c8c8c8;
    font-size: 0.9rem;
}

.folder-nav {
    display: grid;
    gap: 8px;
    min-height: 0;
}

.folder-nav-title {
    color: #596165;
    font-size: 0.82rem;
}

.folder-list {
    display: grid;
    gap: 6px;
    max-height: 24vh;
    overflow: auto;
    padding-right: 4px;
}

.folder-link {
    min-height: 34px;
    width: 100%;
    border: 1px solid rgba(80, 86, 88, 0.12);
    border-radius: 6px;
    padding: 0 10px 0 calc(10px + var(--folder-depth, 0) * 18px);
    background: rgba(255, 255, 255, 0.66);
    color: #2e3639;
    text-align: left;
    cursor: pointer;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

[data-theme="dark"] .folder-link {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.08);
    color: #a1a1aa;
}

.folder-link:hover {
    border-color: rgba(47, 61, 64, 0.35);
    background: rgba(255, 255, 255, 0.9);
}

[data-theme="dark"] .folder-link:hover {
    background: rgba(255, 255, 255, 0.12);
}

.folder-link.active {
    border-color: #2f3d40;
    background: #2f3d40;
    color: #ffffff;
    font-weight: 700;
}

.folder-empty {
    color: #888888;
    font-size: 0.82rem;
}

.key-legend {
    display: grid;
    gap: 4px;
}

.key-row {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    color: #596165;
}

.key-row kbd {
    display: inline-block;
    min-width: 22px;
    padding: 2px 6px;
    font-family: inherit;
    font-size: 0.72rem;
    text-align: center;
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(80, 86, 88, 0.2);
    border-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
    color: #30383b;
}

[data-theme="dark"] .key-row kbd {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.15);
    color: #e4e4e7;
}

.swatches {
    display: flex;
    gap: 10px;
}

.swatch {
    width: 28px;
    height: 28px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    cursor: pointer;
}

.swatch.active {
    outline: 2px solid #ffffff;
    outline-offset: 2px;
}

.swatch.dark {
    background: #000000;
}

.swatch.matrix {
    background: #103b22;
}

.swatch.cyber {
    background: #0c3155;
}

.loader {
    position: absolute;
    inset: 0;
    display: none;
    place-items: center;
    align-content: center;
    gap: 16px;
    background: rgba(245, 245, 245, 0.88);
    color: #2f3d40;
    font-family: "Courier New", Courier, monospace;
    z-index: 20;
}

[data-theme="dark"] .loader {
    background: rgba(10, 10, 12, 0.92);
    color: #a1a1aa;
}

.loader.visible {
    display: grid;
}

.spinner {
    width: 52px;
    height: 52px;
    border: 2px solid rgba(47, 61, 64, 0.18);
    border-top-color: #2f3d40;
    border-radius: 999px;
    animation: spin 850ms linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.status {
    position: absolute;
    right: 16px;
    bottom: 16px;
    max-width: min(520px, calc(100vw - 32px));
    padding: 10px 12px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.72);
    color: #30383b;
    font-size: 0.86rem;
    z-index: 10;
}

[data-theme="dark"] .status {
    background: rgba(30, 30, 36, 0.85);
    color: #e4e4e7;
}

.status:empty {
    display: none;
}

@media (max-width: 700px) {
    .photo-node {
        width: 118px;
    }
}

.mbm-logo-link {
    position: absolute;
    bottom: 18px;
    left: 18px;
    z-index: 10;
    opacity: 0.6;
    transition:
        opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    text-decoration: none !important;
}

.mbm-logo-link:hover {
    opacity: 1;
    transform: scale(1.05);
}

.mbm-logo-link img {
    width: 128px;
    height: auto;
    display: block;
}

.mbm-logo-label {
    font-size: 0.95rem;
    font-weight: 800;
    color: #ffffff;
    opacity: 0.9;
    text-decoration: none !important;
}

.share-qr-container {
    position: absolute;
    bottom: 72px;
    right: 18px;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid rgba(80, 86, 88, 0.15);
    border-radius: 12px;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
    opacity: 0.9;
    text-decoration: none;
    transition:
        opacity 0.3s ease,
        transform 0.3s ease;
}

.share-qr-container:hover {
    opacity: 1;
    transform: scale(1.03);
    background: rgba(255, 255, 255, 0.95);
}

.share-qr-container .qr-label {
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 1.5px;
    color: #596165;
}

.share-qr-container img {
    width: 100px;
    height: 100px;
    display: block;
    border-radius: 4px;
}

/* === Passwort-Login Overlay === */
#passwordOverlay {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(
            ellipse at 50% 38%,
            rgba(255, 255, 255, 0.96) 0%,
            rgba(245, 245, 245, 0.82) 35%,
            rgba(224, 224, 224, 0.92) 72%,
            #d7d7d7 100%
        ),
        linear-gradient(180deg, #f4f4f4 0%, #dddddd 100%);
}

[data-theme="dark"] #passwordOverlay {
    background:
        radial-gradient(
            ellipse at 50% 38%,
            rgba(40, 40, 48, 0.96) 0%,
            rgba(25, 25, 30, 0.82) 35%,
            rgba(15, 15, 18, 0.92) 72%,
            #0a0a0c 100%
        ),
        linear-gradient(180deg, #121214 0%, #0a0a0c 100%);
}

.password-card {
    width: min(400px, calc(100vw - 48px));
    padding: 40px 32px;
    background: rgba(255, 255, 255, 0.85);
    border-radius: 16px;
    box-shadow:
        0 24px 48px rgba(0, 0, 0, 0.12),
        0 0 0 1px rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(20px);
    text-align: center;
}

[data-theme="dark"] .password-card {
    background: rgba(30, 30, 36, 0.9);
    box-shadow:
        0 24px 48px rgba(0, 0, 0, 0.4),
        0 0 0 1px rgba(255, 255, 255, 0.08);
}

.password-card h2 {
    margin: 0 0 8px;
    font-size: 1.5rem;
    font-weight: 600;
    color: #1f2528;
}

[data-theme="dark"] .password-card h2 {
    color: #e4e4e7;
}

.password-card p {
    margin: 0 0 24px;
    font-size: 0.9rem;
    color: #596165;
}

[data-theme="dark"] .password-card p {
    color: #a1a1aa;
}

#passwordForm {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

#passwordInput {
    height: 48px;
    padding: 0 16px;
    border: 1px solid rgba(80, 86, 88, 0.2);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.9);
    font-size: 1rem;
    color: #1f2528;
    outline: none;
    transition: border-color 0.2s ease;
}

#passwordInput:focus {
    border-color: #2f3d40;
}

[data-theme="dark"] #passwordInput {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.15);
    color: #e4e4e7;
}

.password-error {
    margin-top: 16px;
    padding: 10px 12px;
    background: rgba(220, 38, 38, 0.1);
    border: 1px solid rgba(220, 38, 38, 0.3);
    border-radius: 8px;
    color: #dc2626;
    font-size: 0.85rem;
}
