/* --- CSS Reset & Variablen --- */
*, *::before, *::after { 
    box-sizing: border-box; 
    margin: 0; 
    padding: 0; 
}

:root {
    --c-primary: #d4a017;
    --c-bg: #000000;
    --c-text: #ffffff;
    --radius-pill: 99px;
}

/* FIX: Absolute Vollbild-Erzwingung */
html, body {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    margin: 0;
    padding: 0;
    overflow: hidden;
    background-color: var(--c-bg);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--c-text);
    position: fixed;
    user-select: none;
    -webkit-user-select: none;
}

/* Verstecke WebXR Fehler-Button auf iPhones/Desktops */
#native-vr-btn[style*="display: none"],
#VRButton { 
    display: none !important; 
}

/* FIX: Der Viewer dockt hart an die Bildschirmränder an */
.viewer {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at center, #2c241b 0%, #000000 100%);
    overflow: hidden;
}

.viewer__canvas {
    position: absolute;
    top: 0;
    left: 0;
    display: block;
    width: 100%;
    height: 100%;
    outline: none;
    cursor: grab;
    opacity: 0;
    transition: opacity 1s ease;
    touch-action: none; 
}
.viewer__canvas--visible { opacity: 1; }

/* UI Layer */
.viewer__ui-layer {
    position: absolute;
    bottom: max(1.5rem, env(safe-area-inset-bottom));
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    opacity: 0;
    background: rgba(25, 20, 15, 0.9);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    padding: 0.6rem 1.2rem;
    border-radius: var(--radius-pill);
    display: flex; gap: 1rem; align-items: center;
    border: 1px solid rgba(212, 160, 23, 0.3);
    transition: all 0.6s cubic-bezier(0.19, 1, 0.22, 1);
    z-index: 100;
}
.viewer__ui-layer--visible { 
    transform: translateX(-50%) translateY(0); 
    opacity: 1; 
}

.viewer__ui-divider { width: 1px; height: 24px; background: rgba(255,255,255,0.2); }

/* Buttons */
.viewer__btn {
    background: rgba(255,255,255,0.1); color: #f0e6d2; border: none; padding: 0.7rem 1.5rem;
    border-radius: var(--radius-pill); cursor: pointer; font-weight: 600; 
    display: inline-flex; align-items: center; gap: 0.7rem;
}
.viewer__btn--primary { background: var(--c-primary); color: #000; }
.viewer__btn--icon { padding: 0.6rem; width: 42px; height: 42px; justify-content: center; }
.viewer__btn--active { background: var(--c-primary); color: #000; }

/* Spinner */
.spinner { width: 16px; height: 16px; border: 2px solid rgba(0,0,0,0.2); border-top-color: #000; border-radius: 50%; animation: spin 0.8s linear infinite; display: none; }
@keyframes spin { 100% { transform: rotate(360deg); } }

/* Custom Switch */
.viewer__switch-group { display: flex; align-items: center; gap: 0.5rem; font-size: 0.8rem; color: var(--c-primary); }
.viewer__switch { position: relative; width: 44px; height: 24px; }
.viewer__switch input { opacity: 0; width: 0; height: 0; }
.viewer__slider { position: absolute; inset: 0; background: #333; border-radius: 20px; transition: 0.3s; cursor: pointer; }
.viewer__slider:before { content: ""; position: absolute; height: 18px; width: 18px; left: 3px; bottom: 3px; background: #fff; border-radius: 50%; transition: 0.3s; }
input:checked + .viewer__slider { background: var(--c-primary); }
input:checked + .viewer__slider:before { transform: translateX(20px); }

/* Overlays */
.viewer__overlay {
    position: absolute; inset: 0; background: #000; z-index: 200;
    display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; padding: 2rem; transition: 0.5s;
}
.viewer__overlay--hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.viewer__overlay--transparent { background: rgba(0,0,0,0.4); }
.viewer__title { font-size: 2.2rem; margin-bottom: 0.5rem; color: var(--c-primary); }
.viewer__desc { font-size: 1rem; opacity: 0.8; margin-bottom: 2rem; max-width: 400px; color: #fff; }
.viewer__vr-divider { position: absolute; top: 0; bottom: 0; left: 50%; width: 1px; background: rgba(212, 160, 23, 0.5); display: none; z-index: 50; }

/* FIX: Settings Panel sichtbar machen */
.viewer__settings-panel { 
    position: absolute; 
    top: 50%; 
    left: 50%; 
    transform: translate(-50%, -40%); 
    background: rgba(20, 20, 20, 0.95); 
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid var(--c-primary); 
    padding: 1.5rem; 
    border-radius: 12px; 
    width: 320px; 
    max-width: 90vw;
    opacity: 0; 
    visibility: hidden; 
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.19, 1, 0.22, 1); 
    z-index: 9999; /* Sehr hoch! */
    box-shadow: 0 20px 50px rgba(0,0,0,0.8);
}
.viewer__settings-panel--open { 
    opacity: 1 !important; 
    visibility: visible !important; 
    pointer-events: auto !important;
    transform: translate(-50%, -50%) !important; 
}

.viewer__setting-row { display: flex; flex-direction: column; gap: 0.75rem; margin-bottom: 1.25rem; }
.viewer__setting-row:last-child { margin-bottom: 0; }
.viewer__setting-row label { font-size: 0.85rem; color: var(--c-primary); font-weight: 600; display: flex; justify-content: space-between; }
.viewer__setting-row select { width: 100%; background: rgba(0,0,0,0.5); color: #fff; border: 1px solid rgba(255,255,255,0.2); padding: 0.6rem; border-radius: 8px; font-size: 1rem; }

/* iOS Range Slider Fixes */
.viewer__setting-row input[type="range"] {
    -webkit-appearance: none; appearance: none; width: 100%; height: 6px; background: rgba(255,255,255,0.2);
    border-radius: 5px; outline: none; padding: 0; margin-top: 5px; border: none;
}
.viewer__setting-row input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none; width: 20px; height: 20px;
    border-radius: 50%; background: var(--c-primary); cursor: pointer; box-shadow: 0 0 10px rgba(0,0,0,0.5);
}

#error-log { position: absolute; top: 0; left: 0; width: 100%; background: rgba(220, 20, 60, 0.95); color: white; padding: 10px; font-size: 12px; font-family: monospace; z-index: 9999; display: none; }