:root {
    --bg-dark: #0a0b10;
    --panel-bg: rgba(17, 19, 24, 0.75);
    --accent: #00d2ff;
    --accent-gradient: linear-gradient(135deg, #00d2ff 0%, #3a7bd5 100%);
    --text-primary: #f0f0f5;
    --text-secondary: #a0a0b0;
    --border-color: rgba(255, 255, 255, 0.1);
    --glass-blur: blur(12px);
    --sidebar-width: 320px;
    --nav-height: 64px;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-primary);
    overflow: hidden; /* Canvas takes full screen */
    height: 100vh;
    width: 100vw;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

#app-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* Background Globe Canvas */
#globe-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
}

/* Navbar */
.navbar {
    position: relative;
    z-index: 10;
    height: var(--nav-height);
    background: var(--panel-bg);
    backdrop-filter: var(--glass-blur);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
}

.nav-brand {
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-actions {
    display: flex;
    gap: 12px;
}

/* Sidebar Shelves */
.sidebar {
    position: absolute;
    top: var(--nav-height);
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--panel-bg);
    backdrop-filter: var(--glass-blur);
    z-index: 5;
    border: 1px solid var(--border-color);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    padding: 24px;
}

.sidebar-left {
    left: 0;
    border-left: none;
    border-top-right-radius: 16px;
    border-bottom-right-radius: 16px;
}

.sidebar-left.is-collapsed {
    transform: translateX(-100%);
}

.sidebar-right {
    right: 0;
    border-right: none;
    border-top-left-radius: 16px;
    border-bottom-left-radius: 16px;
}

.sidebar-right.is-collapsed {
    transform: translateX(100%);
}

/* Control Groups */
.control-section {
    margin-bottom: 32px;
}

.control-section:last-child {
    margin-bottom: 0;
}

.control-section h3 {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

.control-group {
    margin-bottom: 16px;
}

.control-group label {
    display: block;
    font-size: 0.9rem;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.control-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Inputs */
input[type="range"] {
    flex: 1;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    appearance: none;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 14px;
    height: 14px;
    background: var(--accent);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(0, 210, 255, 0.5);
}

input[type="number"], select {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 0.85rem;
    outline: none;
}

input[type="number"]:focus, select:focus {
    border-color: var(--accent);
}

.value-display {
    font-family: monospace;
    font-size: 0.8rem;
    color: var(--accent);
    min-width: 32px;
    text-align: right;
}

/* Buttons */
.btn {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.2);
}

.btn-primary {
    background: var(--accent-gradient);
    border: none;
    color: white;
}

.btn-primary:hover {
    filter: brightness(1.1);
    box-shadow: 0 4px 15px rgba(0, 210, 255, 0.3);
}

/* Legend/Previews */
.preview-card {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    margin-top: 24px;
}

#selected-tile-info {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

#mini-tile-preview {
    width: 100%;
    aspect-ratio: 1;
    background: #000;
    border-radius: 8px;
    margin-top: 12px;
}

/* Loading */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg-dark);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
    transition: opacity 0.5s ease;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(0, 210, 255, 0.1);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

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

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

/* Overlays */
.overlay-text {
    position: absolute;
    z-index: 20;
    pointer-events: none;
    background: var(--panel-bg);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-color);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-family: monospace;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.compass-overlay {
    position: absolute;
    z-index: 20;
    pointer-events: none;
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.compass-circle {
    position: relative;
    width: 56px;
    height: 56px;
    background: var(--panel-bg);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.compass-needle {
    position: relative;
    width: 2px;
    height: 32px;
    transition: transform 0.1s linear;
}

.needle-north {
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-bottom: 16px solid #ff4b2b;
}

.needle-south {
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 16px solid #444;
}

.compass-n {
    position: absolute;
    top: 6px;
    font-size: 9px;
    font-weight: 800;
    color: var(--text-primary);
}

/* Noise Previews in Sidebar */
.noise-canvas-wrap {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.noise-canvas-label {
    font-size: 0.65rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.noise-preview-canvas {
    width: 100%;
    aspect-ratio: 1;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: #000;
}

/* Floating Action CTA */
.cta-floating {
    position: absolute;
    bottom: 50px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 30;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.cta-floating.hidden {
    bottom: -150px;
    opacity: 0;
    pointer-events: none;
}

.cta-preview-wrap {
    width: 130px;
    height: 130px;
    padding: 5px;
    background: var(--panel-bg);
    backdrop-filter: var(--glass-blur);
    border: 2px solid var(--accent);
    box-shadow: 0 0 30px rgba(0, 210, 255, 0.4), inset 0 0 15px rgba(0, 210, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

#cta-tile-preview {
    width: 100%;
    height: 100%;
    image-rendering: pixelated;
}

.btn-cta {
    padding: 16px 40px;
    font-size: 1.1rem;
    font-weight: 800;
    letter-spacing: 2px;
    border-radius: 50px;
    box-shadow: 0 10px 40px rgba(0, 210, 255, 0.4);
    animation: pulse-glow 2s infinite;
    border: 2px solid rgba(255, 255, 255, 0.2);
    text-transform: uppercase;
}

@keyframes pulse-glow {
    0% { box-shadow: 0 10px 40px rgba(0, 210, 255, 0.4); }
    50% { box-shadow: 0 10px 50px rgba(0, 210, 255, 0.7); transform: scale(1.02); }
    100% { box-shadow: 0 10px 40px rgba(0, 210, 255, 0.4); }
}

.btn-cta .icon {
    font-size: 1.2rem;
    margin-right: 8px;
}
