* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
:root {
    --bg-main: #0d0d0f;
    --bg-panel: #161618;
    --bg-hover: #1e1e21;
    --accent: #4CAF50;
    --accent-hover: #45a049;
    --text-main: #e0e0e0;
    --text-muted: #888;
    --border: #2a2a2d;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.topbar {
    height: 54px;
    min-height: 54px;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 16px;
    z-index: 20;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand h1 {
    font-family: 'JetBrains Mono', monospace;
    font-size: 18px;
    font-weight: 700;
    color: #fff;
    letter-spacing: -0.5px;
}

.cube-container { width: 20px; height: 20px; perspective: 150px; }
.cube { width: 100%; height: 100%; position: relative; transform-style: preserve-3d; animation: rotate 6s infinite linear; }
.face { position: absolute; width: 20px; height: 20px; border: 1.5px solid var(--accent); background: rgba(76, 175, 80, 0.1); }
.front  { transform: translateZ(10px); }
.back   { transform: rotateY(180deg) translateZ(10px); }
.right  { transform: rotateY(90deg) translateZ(10px); }
.left   { transform: rotateY(-90deg) translateZ(10px); }
.top    { transform: rotateX(90deg) translateZ(10px); }
.bottom { transform: rotateX(-90deg) translateZ(10px); }

@keyframes rotate {
    0%   { transform: rotateX(0deg) rotateY(0deg); }
    100% { transform: rotateX(360deg) rotateY(360deg); }
}

.app-container {
    display: flex;
    flex: 1;
    width: 100vw;
    height: calc(100dvh - 54px);
    overflow: hidden;
}

.sidebar {
    width: 320px;
    min-width: 320px;
    background: var(--bg-panel);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 16px;
    gap: 12px;
    overflow-y: auto;
    z-index: 10;
}

.panel { background: var(--bg-main); border: 1px solid var(--border); border-radius: 8px; padding: 12px; }
.panel h3 { font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: var(--text-muted); margin-bottom: 8px; }
.control-group { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-size: 14px; }

.file-select {
    width: 100%; padding: 10px; background: var(--bg-hover); color: var(--text-main);
    border: 1px solid var(--border); border-radius: 6px; font-size: 14px; outline: none; cursor: pointer;
}
.file-select:focus { border-color: var(--accent); }

button { font-family: inherit; cursor: pointer; transition: 0.2s; border-radius: 6px; font-weight: 600; }
.btn-primary { width: 100%; padding: 12px; background: var(--accent); color: #fff; border: none; font-size: 15px; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { width: 100%; padding: 10px; background: transparent; border: 1px solid var(--border); color: var(--text-main); font-size: 14px; }
.btn-secondary:hover { background: var(--bg-hover); border-color: var(--text-muted); }

#viewport {
    flex: 1;
    position: relative;
    background: radial-gradient(circle at 50% 50%, #222 0%, #0d0d0f 100%);
    overflow: hidden;
    touch-action: none;
}
#webglCanvas { width: 100%; height: 100%; display: block; touch-action: none; }

.view-controls {
    position: absolute; top: 12px; right: 12px; z-index: 15;
    background: rgba(22, 22, 24, 0.9); backdrop-filter: blur(6px);
    border: 1px solid var(--border); border-radius: 10px; padding: 8px;
    display: flex; flex-direction: column; gap: 8px; width: 145px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}
.view-section { display: flex; flex-direction: column; gap: 4px; }
.view-label { font-size: 9px; text-transform: uppercase; color: var(--text-muted); letter-spacing: 0.5px; font-weight: bold; }
.view-grid { display: grid; gap: 3px; }
.cardinals { grid-template-columns: repeat(3, 1fr); }
.diagonals { grid-template-columns: repeat(4, 1fr); }

.view-btn {
    background: var(--bg-hover); border: 1px solid var(--border); color: var(--text-main);
    font-size: 10px; font-family: 'JetBrains Mono', monospace; padding: 8px 0; border-radius: 4px; text-align: center;
}
.view-btn:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.recenter-btn { width: 100%; padding: 8px; font-size: 11px; background: #222; }
.view-divider { height: 1px; background: var(--border); width: 100%; }

#dropzone {
    position: absolute; inset: 16px; border: 2px dashed var(--border); border-radius: 12px;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    background: rgba(22, 22, 24, 0.85); backdrop-filter: blur(4px); z-index: 10;
}
.drop-content { text-align: center; padding: 16px; }
.drop-content h2 { margin: 12px 0 6px; font-size: 20px; font-weight: 500; }
.drop-content p { color: var(--text-muted); margin-bottom: 16px; font-size: 13px; }

#loadingOverlay {
    position: fixed; inset: 0; background: rgba(13, 13, 15, 0.95); z-index: 100;
    display: flex; align-items: center; justify-content: center; backdrop-filter: blur(8px);
}
.loader-content { text-align: center; padding: 20px; }
.spinner {
    width: 36px; height: 36px; border: 3px solid rgba(76,175,80,0.3); border-top-color: var(--accent);
    border-radius: 50%; animation: spin 1s linear infinite; margin: 0 auto 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.ad-placeholder {
    background: var(--bg-main); border: 1px dashed var(--border); display: flex;
    align-items: center; justify-content: center; color: var(--text-muted); font-family: monospace; font-size: 11px; border-radius: 8px;
}
.sidebar-ad {
    width: 300px !important;
    height: 250px !important;
    min-width: 300px;
    min-height: 250px;
    max-width: 300px;
    max-height: 250px;
    margin: 12px auto 0 auto; /* Centers it nicely in the sidebar */
    flex-shrink: 0;
    background: var(--bg-main);
    border: 1px dashed var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-family: monospace;
    font-size: 11px;
    border-radius: 8px;
    box-sizing: border-box;
}

.hidden { display: none !important; }

@media (max-width: 768px) {
    .app-container { flex-direction: column-reverse; }
    .sidebar {
        width: 100%;
        min-width: 100%;
        max-height: 220px;
        padding: 12px;
        border-right: none;
        border-top: 1px solid var(--border);
    }
    .sidebar-ad { display: none; }
    .view-controls { top: 8px; right: 8px; width: 130px; padding: 6px; }
    .view-btn { padding: 6px 0; font-size: 9px; }
}
