* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    background: #1a1a2e;
    color: white;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', sans-serif;
    overflow: hidden;
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    -webkit-user-select: none;
    user-select: none;
}

/* Connection Bar */
#connection-bar {
    background: rgba(0, 0, 0, 0.9);
    padding: 8px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex-shrink: 0;
    z-index: 100;
}

#bar-top {
    display: flex;
    align-items: center;
    gap: 10px;
}

#bar-top select {
    flex: 1;
    min-width: 0;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 8px 10px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='white'%3E%3Cpath d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    padding-right: 28px;
    cursor: pointer;
}

#bar-top select option {
    background: #1a1a2e;
    color: white;
}

#bar-top select:focus {
    outline: none;
    border-color: #667eea;
}

#bar-actions {
    display: flex;
    gap: 8px;
}

#status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    flex-shrink: 0;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.status-dot.connected { background: #34C759; }
.status-dot.disconnected { background: #666; }
.status-dot.connecting { background: #FF9500; animation: pulse 1s infinite; }
.status-dot.warning { background: #FF3B30; animation: pulse 1s infinite; }
.status-dot.error { background: #FF3B30; }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

#status-text {
    color: rgba(255, 255, 255, 0.7);
}

/* Action Buttons (Hotspots, Passthrough) */
.action-btn {
    flex: 1;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.8);
    padding: 8px 14px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.action-btn:active {
    transform: scale(0.97);
}

.action-btn.active {
    background: rgba(0, 122, 255, 0.7);
    border-color: rgba(0, 122, 255, 0.9);
    color: white;
}

/* Preview Container */
#preview-container {
    flex: 1;
    position: relative;
    min-height: 30vh;
    background: #111;
    overflow: hidden;
}

#preview-container canvas {
    width: 100% !important;
    height: 100% !important;
    display: block;
}

#crosshair {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: rgba(255, 255, 255, 0.5);
    font-size: 28px;
    font-weight: 200;
    pointer-events: none;
    z-index: 10;
    text-shadow: 0 0 8px rgba(0, 0, 0, 0.8);
}


/* Controls Container */
#controls-container {
    flex-shrink: 0;
    max-height: 55vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 10px 12px;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
    gap: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* Trigger Button — overlaid on bottom center of 360 preview */
#trigger-section {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 20;
    pointer-events: auto;
}

#trigger-btn {
    width: 120px;
    height: 40px;
    border-radius: 22px;
    border: none;
    cursor: pointer;
    transition: background 0.2s;
    background: rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

#trigger-btn:disabled {
    background: rgba(255, 255, 255, 0.25);
    cursor: default;
}

#trigger-btn:not(:disabled) {
    background: rgba(0, 122, 255, 0.7);
}

#trigger-btn:not(:disabled):active {
    background: rgba(0, 122, 255, 1);
    transform: scale(0.97);
}

/* Sections */
#quick-nav-section,
#space-section,
#panorama-section,
#variant-section {
    display: none;
}

#quick-nav-section.visible,
#space-section.visible,
#panorama-section.visible,
#variant-section.visible {
    display: block;
}

/* Button Row */
.button-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* Quick Nav Buttons */
.quick-nav-btn {
    background: rgba(102, 126, 234, 0.7);
    color: white;
    border: none;
    padding: 10px 18px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: background 0.15s;
    flex-shrink: 0;
}

.quick-nav-btn:active {
    background: rgba(102, 126, 234, 1);
    transform: scale(0.97);
}

/* Space Tabs */
#space-tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
    scrollbar-width: none;
}

#space-tabs::-webkit-scrollbar {
    display: none;
}

.space-tab {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: rgba(255, 255, 255, 0.8);
    padding: 6px 14px;
    border-radius: 16px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    flex-shrink: 0;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.space-tab:active {
    transform: scale(0.97);
}

.space-tab.active {
    background: rgba(102, 126, 234, 0.5);
    border-color: #667eea;
    color: white;
    font-weight: 600;
}

/* Panorama Grid — single horizontal row with scroll */
#panorama-grid {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 2px;
}

#panorama-grid::-webkit-scrollbar {
    display: none;
}

.pano-card {
    cursor: pointer;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid transparent;
    transition: border-color 0.2s, transform 0.1s;
    background: rgba(255, 255, 255, 0.05);
    flex-shrink: 0;
    width: 110px;
}

.pano-card:active {
    transform: scale(0.97);
}

.pano-card.active {
    border-color: #667eea;
    background: rgba(102, 126, 234, 0.15);
}

.pano-card img {
    width: 100%;
    height: 65px;
    object-fit: cover;
    display: block;
    background: #222;
}

.pano-card span {
    display: block;
    padding: 4px 6px;
    font-size: 11px;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: rgba(255, 255, 255, 0.8);
}

.pano-card.active span {
    color: white;
    font-weight: 600;
}

/* Variant Selector */
.variant-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: white;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    transition: background 0.15s, border-color 0.15s;
    flex-shrink: 0;
}

.variant-btn:active {
    transform: scale(0.97);
}

.variant-btn.active {
    background: rgba(102, 126, 234, 0.4);
    border-color: #667eea;
    font-weight: 600;
}

.color-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Responsive adjustments for smaller screens */
@media (max-width: 600px) {
    .pano-card {
        width: 90px;
    }

    .pano-card img {
        height: 50px;
    }

    .pano-card span {
        font-size: 10px;
    }
}

/* Landscape iPad optimization */
@media (orientation: landscape) and (min-width: 700px) {
    #preview-container {
        min-height: 40vh;
    }

    #controls-container {
        max-height: 50vh;
    }

    .pano-card {
        width: 120px;
    }
}
