* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body,
html {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: radial-gradient(circle at center, #848482 0%, #9a9793 100%);
    color: #ffffff;
}

#canvas-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

#control-zone {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
}

/* Camera Viewfinder Frame */
#camera-frame {
    position: absolute;
    z-index: 4;
    pointer-events: none;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
}

.cf-panel {
    position: absolute;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    background: rgba(0, 0, 0, 0.65);
    /* Darkened slightly for a cinematic passepartout */
    clip-path: inset(0);
    /* Crucial: strictly prevents any blur bleeding into the center */
}

/* Bounds are now computed dynamically in JS for the perfect aspect ratio */
.cf-top {
    top: 0;
    left: 0;
    right: 0;
}

.cf-bottom {
    bottom: 0;
    left: 0;
    right: 0;
}

.cf-left {
    left: 0;
}

.cf-right {
    right: 0;
}

.cf-center-frame {
    position: absolute;
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.4);
    z-index: 10;
}

/* Drop Zone */
#drop-zone {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(20, 20, 22, 0.9);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.3s ease;
}

#drop-zone.hidden {
    opacity: 0;
    pointer-events: none;
}

.drop-content {
    text-align: center;
    border: 2px dashed #3a3a40;
    padding: 40px;
    border-radius: 12px;
    background: #1c1c1e;
}

.drop-logo {
    max-width: 200px;
    margin: 0 auto 20px auto;
    display: block;
    border-radius: 12px;
}

.drop-content h2 {
    margin-bottom: 10px;
    font-weight: 500;
}

.drop-content p {
    margin-bottom: 20px;
    color: #a0a0a5;
}

.drop-content input[type="file"] {
    display: none;
}

.drop-content button {
    background: #2b5c9e;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
}

.drop-content button:hover {
    background: #346dbb;
}

/* UI Overlay (Sketchfab style) */
#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: opacity 0.3s ease;
}

#ui-layer.hidden {
    opacity: 0;
}

/* Header mimicking Sketchfab */
.header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: 24px 20px;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.65) 0%, transparent 100%);
    pointer-events: none;
    z-index: 10;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    pointer-events: auto;
}

.avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #1caad9;
    /* Sketchfab-like blue or put your own image here */
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 18px;
    color: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.avatar-outline {
    background: transparent;
    border: 2px solid #1caad9;
    box-shadow: inset 0 0 10px rgba(28, 170, 217, 0.2), 0 0 10px rgba(28, 170, 217, 0.4);
}

.avatar-logo {
    width: 40px;
    height: auto;
    object-fit: contain;
}

.info h1 {
    font-size: 17px;
    font-weight: 700;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
    margin-bottom: 2px;
    cursor: pointer;
}

.info h1:hover {
    color: #1caad9;
}

.info .author {
    font-size: 13px;
    color: #cccccc;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

.info .author a {
    color: #ffffff;
    text-decoration: none;
    font-weight: 600;
}

.info .author a:hover {
    text-decoration: underline;
}

/* Footer / Control Bar mimicking Sketchfab */
.footer {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    background: linear-gradient(0deg, rgba(0, 0, 0, 0.65) 0%, transparent 100%);
    pointer-events: auto;
    z-index: 10;
}

.controls-left,
.controls-right {
    display: flex;
    align-items: center;
    gap: 12px;
    pointer-events: auto;
}

.btn-divider {
    width: 1px;
    height: 24px;
    background: rgba(255, 255, 255, 0.2);
    margin: 0 4px;
}

.icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 4px;
    background: rgba(30, 30, 30, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    backdrop-filter: blur(5px);
}

.icon-btn:hover {
    background: rgba(80, 80, 80, 0.9);
    border-color: rgba(255, 255, 255, 0.3);
}

.icon-btn.active {
    background: rgba(28, 170, 217, 0.25);
    border-color: rgba(28, 170, 217, 0.6);
    color: #1caad9;
}

.icon-btn svg {
    width: 22px;
    height: 22px;
    fill: currentColor;
}

.res-select {
    background: rgba(30, 30, 30, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 20px;
    padding: 8px 12px;
    color: white;
    font-size: 13.5px;
    font-weight: 500;
    cursor: pointer;
    backdrop-filter: blur(5px);
    outline: none;
}

.res-select option {
    background: #1c1c1e;
}

/* Inspector Sidebars mimicking Sketchfab Inspector */
.inspector-container {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    pointer-events: none;
    display: flex;
    justify-content: flex-start;
    padding: 100px 24px 90px 24px;
    z-index: 5;
    transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

#inspector-layer.hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.98);
}

.sidebar {
    width: 260px;
    background: linear-gradient(145deg, rgba(25, 25, 30, 0.75), rgba(15, 15, 18, 0.9));
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 8px 0;
    height: max-content;
    max-height: 100%;
    overflow-y: auto;
    pointer-events: auto;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

/* Hide Scrollbar for clean look */
.sidebar::-webkit-scrollbar {
    display: none;
}

.sidebar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.sidebar-section {
    padding: 20px 0 8px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.sidebar-section:last-child {
    border-bottom: none;
}

.section-title {
    font-size: 11px;
    font-weight: 700;
    color: #7a7a7a;
    letter-spacing: 1px;
    padding: 0 24px 12px 24px;
}

.inspector-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.inspector-list li {
    padding: 12px 24px;
    font-size: 13.5px;
    color: #aaaaaa;
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 12px;
    border-radius: 4px;
}

.inspector-list li:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
}

.inspector-list li.active {
    background: linear-gradient(90deg, rgba(28, 170, 217, 0.15), transparent);
    color: #1caad9;
    font-weight: 600;
    border-radius: 0 4px 4px 0;
}

.inspector-list li.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: #1caad9;
    box-shadow: 0 0 10px #1caad9;
}

.swatch {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    display: inline-block;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1);
}

.icon {
    font-size: 14px;
    opacity: 0.7;
}

/* --- Animated Loader --- */
#loader {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at center, #2a2a2d 0%, #141416 100%);
    z-index: 90;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: opacity 0.4s ease;
}

#loader.hidden {
    opacity: 0;
    pointer-events: none;
}

.logo-img {
    width: 180px;
    height: auto;
    object-fit: contain;
    animation: pulse3d 1.5s ease-in-out infinite alternate;
    margin-bottom: 0;
    filter: drop-shadow(0 0 16px rgba(28, 170, 217, 0.5));
}

@keyframes pulse3d {
    0% {
        transform: scale(0.95);
        opacity: 0.8;
    }

    100% {
        transform: scale(1.05);
        opacity: 1;
    }
}

.progress-container {
    width: 200px;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    margin-top: 20px;
    overflow: hidden;
}

#progress-bar {
    width: 0%;
    height: 100%;
    background: #1caad9;
    transition: width 0.2s ease-out;
}

#progress-text {
    margin-top: 10px;
    font-size: 14px;
    color: #1caad9;
    font-weight: 600;
}

@keyframes fade {
    0% {
        opacity: 0.5;
    }

    100% {
        opacity: 1;
    }
}

/* --- Camera Dropdown --- */
.custom-select {
    position: relative;
    margin-left: 8px;
}

.select-trigger {
    display: flex;
    align-items: center;
    background: rgba(30, 30, 30, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 20px;
    padding: 8px 18px;
    color: white;
    font-size: 13.5px;
    font-weight: 500;
    cursor: pointer;
    backdrop-filter: blur(5px);
    transition: all 0.2s ease;
}

.select-trigger:hover {
    background: rgba(80, 80, 80, 0.9);
    border-color: rgba(255, 255, 255, 0.3);
}

.select-trigger .arrow {
    font-size: 10px;
    margin-left: 6px;
    opacity: 0.6;
}

.cam-icon {
    width: 18px;
    height: 18px;
    fill: white;
    margin-right: 8px;
    opacity: 0.8;
}

.select-options {
    position: absolute;
    bottom: calc(100% + 12px);
    left: 0;
    background: rgba(25, 25, 30, 0.95);
    backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 14px;
    list-style: none;
    padding: 6px;
    margin: 0;
    min-width: 200px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
    opacity: 0;
    pointer-events: none;
    transform: translateY(10px);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.select-options.show {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.select-options li {
    padding: 10px 14px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13.5px;
    color: #aaa;
    transition: all 0.2s;
}

.select-options li:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
}

.select-options li.active {
    background: rgba(28, 170, 217, 0.15);
    color: #1caad9;
    font-weight: 600;
}

.ar-overlay {
    position: absolute;
    right: 20px;
    bottom: 92px;
    z-index: 16;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 14px;
    pointer-events: none;
    opacity: 0;
    transform: translateY(12px) scale(0.96);
    transition: opacity 0.26s ease, transform 0.32s cubic-bezier(0.16, 1, 0.3, 1);
}

.ar-overlay.is-visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.ar-share-card,
.view-in-ar-btn {
    pointer-events: auto;
}

.ar-share-card {
    position: relative;
    width: min(360px, calc(100vw - 32px));
    padding: 14px;
    border-radius: 18px;
    background: linear-gradient(155deg, rgba(12, 14, 20, 0.94), rgba(22, 26, 35, 0.78));
    border: 1px solid rgba(255, 255, 255, 0.09);
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.38);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
}

.ar-share-card.is-busy::after {
    content: '';
    position: absolute;
    top: 14px;
    right: 14px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid rgba(127, 231, 255, 0.25);
    border-top-color: #7fe7ff;
    animation: arShareSpin 0.8s linear infinite;
}

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

.ar-share-kicker {
    margin-bottom: 10px;
    color: #7fe7ff;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.qr-code-frame {
    display: grid;
    place-items: center;
    width: 100%;
    min-height: 280px;
    margin-bottom: 12px;
    border-radius: 14px;
    background:
        radial-gradient(circle at top, rgba(28, 170, 217, 0.18), transparent 58%),
        rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
    overflow: hidden;
}

.qr-code-frame canvas,
.qr-code-frame svg {
    border-radius: 10px;
    background: #ffffff;
    padding: 10px;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.06);
}

.ar-share-copy {
    color: #ffffff;
    font-size: 14px;
    line-height: 1.45;
    font-weight: 600;
}

.ar-share-note {
    margin-top: 8px;
    color: #aab4c2;
    font-size: 12.5px;
    line-height: 1.45;
}

.ar-share-expiry {
    margin-top: 10px;
    color: #7fe7ff;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.03em;
}

.ar-share-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-top: 12px;
    padding: 10px 14px;
    border-radius: 999px;
    background: rgba(28, 170, 217, 0.16);
    color: #7fe7ff;
    text-decoration: none;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.02em;
    transition: background 0.2s ease, transform 0.2s ease;
}

.ar-share-link:hover {
    background: rgba(28, 170, 217, 0.24);
    transform: translateY(-1px);
}

.view-in-ar-btn {
    min-width: 170px;
    border: 0;
    border-radius: 999px;
    padding: 14px 18px;
    background: linear-gradient(135deg, #1caad9, #7ed957);
    color: #08131d;
    font-size: 14px;
    font-weight: 800;
    letter-spacing: 0.02em;
    cursor: pointer;
    box-shadow: 0 22px 44px rgba(0, 0, 0, 0.34);
    transition: transform 0.22s ease, box-shadow 0.22s ease, opacity 0.22s ease;
}

.view-in-ar-btn:hover:not(:disabled) {
    transform: translateY(-1px) scale(1.01);
    box-shadow: 0 26px 52px rgba(0, 0, 0, 0.42);
}

.view-in-ar-btn:disabled {
    cursor: not-allowed;
    opacity: 0.58;
    box-shadow: none;
}

@media (max-width: 1024px) {
    .ar-overlay {
        right: 14px;
        bottom: 88px;
    }

    .view-in-ar-btn {
        min-width: 184px;
    }
}

@media (max-width: 640px) {
    .ar-overlay {
        left: 14px;
        right: 14px;
        align-items: stretch;
    }

    .ar-share-card {
        width: 100%;
    }

    .view-in-ar-btn {
        width: 100%;
    }
}

.hidden {
    display: none !important;
}

/* 2D Viewport Message Overlay */
#msg-2d {
    position: absolute;
    top: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(20, 20, 22, 0.9);
    color: #aaa;
    z-index: 2;
    text-align: center;
    padding: 20px;
}

#msg-2d p {
    color: #fff;
    font-weight: 600;
    margin-bottom: 8px;
}
