:root {
    --bg-primary: #07090e;
    --bg-secondary: rgba(11, 19, 41, 0.82);
    --glass-bg: rgba(11, 19, 41, 0.72);
    --glass-border: rgba(56, 189, 248, 0.28);
    --glass-shadow: 0 12px 40px 0 rgba(0, 0, 0, 0.65);
    
    --accent-cyan: #00f3ff;
    --accent-blue: #38bdf8;
    --accent-pink: #ff0055;
    --accent-purple: #c084fc;
    --accent-emerald: #10b981;
    --accent-amber: #f59e0b;
    --accent-orange: #f97316;
    --accent-red: #ef4444;
    
    --depth-shallow: #00f3ff;   /* 0-30 km */
    --depth-medium: #f59e0b;    /* 30-150 km */
    --depth-deep: #ff0055;      /* 150-300 km */
    --depth-ultra: #c084fc;     /* 300-700 km */

    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --font-main: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --sidebar-width: 370px;
}

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

body, html {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: var(--bg-primary);
    font-family: var(--font-main);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
}

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

/* Cesium Cleanups */
.cesium-widget-credits,
.cesium-viewer-bottom,
.cesium-viewer-toolbar {
    display: none !important;
}

/* Glassmorphism Panel */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
    border-radius: var(--radius-md);
}

.panel-drag-bar {
    cursor: grab;
    padding: 6px 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--accent-blue);
    user-select: none;
}

.panel-drag-bar:active {
    cursor: grabbing;
}

.drag-dots {
    color: var(--accent-cyan);
    margin-right: 4px;
}

.panel-min-btn {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: var(--text-primary);
    border-radius: 4px;
    width: 20px;
    height: 20px;
    font-size: 0.65rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.panel-min-btn:hover {
    background: rgba(56, 189, 248, 0.3);
    border-color: var(--accent-blue);
}

/* HUD Overlay Layout */
.hud-overlay {
    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;
    padding: 16px;
}

.hud-top-split {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    width: 100%;
}

.header-left-island,
.header-right-island,
.sidebar,
.hud-card,
.depth-legend-card,
.camera-dpad-hud,
.dpad-island {
    pointer-events: auto;
}

.header-left-island {
    padding: 12px 18px;
    display: flex;
    flex-direction: column;
}

.logo-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.pulse-icon {
    position: relative;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(239, 68, 68, 0.6) 0%, rgba(239, 68, 68, 0.1) 70%);
    border: 1.5px solid var(--accent-red);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
}

.pulse-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 2px solid var(--accent-red);
    animation: pulseWave 2s infinite ease-out;
}

@keyframes pulseWave {
    0% { transform: scale(0.95); opacity: 0.9; }
    100% { transform: scale(2.2); opacity: 0; }
}

.app-title {
    font-size: 1.45rem;
    font-weight: 800;
    letter-spacing: -0.3px;
    color: #ffffff !important;
    -webkit-background-clip: unset !important;
    -webkit-text-fill-color: #ffffff !important;
    text-shadow: 0 0 14px rgba(239, 68, 68, 0.85), 0 0 28px rgba(245, 158, 11, 0.5), 0 2px 4px rgba(0, 0, 0, 0.9);
    line-height: 1.2;
}

.app-subtitle {
    font-size: 0.76rem;
    color: #cbd5e1;
    font-weight: 500;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

.header-right-island {
    padding: 8px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.stats-pills {
    display: flex;
    gap: 10px;
    align-items: center;
}

.stat-pill {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-sm);
    padding: 4px 10px;
    display: flex;
    flex-direction: column;
}

.stat-label {
    font-size: 0.65rem;
    color: var(--text-muted);
}

.stat-value {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--accent-cyan);
}

.quick-links-row {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.quick-btn {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: var(--text-secondary);
    padding: 4px 10px;
    font-size: 0.75rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.quick-btn:hover {
    background: rgba(56, 189, 248, 0.2);
    color: var(--accent-cyan);
    border-color: var(--accent-cyan);
}

/* Sidebar Container */
.sidebar {
    width: var(--sidebar-width);
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    position: absolute;
    top: 90px;
    left: 16px;
    display: flex;
    flex-direction: column;
    z-index: 20;
}

.sidebar-content {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.sidebar-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    padding-bottom: 14px;
}

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

.section-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--accent-blue);
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Select & Search */
.custom-select {
    pointer-events: auto !important;
    cursor: pointer;
    width: 100%;
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid rgba(56, 189, 248, 0.35);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    padding: 8px 12px;
    font-size: 0.82rem;
    font-weight: 600;
    outline: none;
    cursor: pointer;
}

.search-box {
    position: relative;
    width: 100%;
}

.search-box input {
    width: 100%;
    background: rgba(15, 23, 42, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    padding: 8px 12px;
    font-size: 0.82rem;
    outline: none;
}

.search-box input:focus {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 10px rgba(0, 243, 255, 0.3);
}

.btn-icon {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.1rem;
    cursor: pointer;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 14px;
    font-size: 0.82rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}

.btn-primary {
    background: linear-gradient(135deg, #ef4444, #f97316);
    color: #fff;
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.4);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.6);
}

.btn-secondary {
    background: rgba(15, 23, 42, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: var(--text-primary);
}

.btn-secondary:hover,
.btn-secondary.active {
    background: rgba(239, 68, 68, 0.2);
    border-color: var(--accent-red);
    color: #fff;
}

.source-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.source-status-badge {
    font-size: 0.72rem;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 4px;
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid rgba(16, 185, 129, 0.35);
    color: var(--accent-emerald);
    text-align: center;
}

/* Toggle Switch */
.toggle-switch {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 0.82rem;
    color: var(--text-secondary);
}

.toggle-switch input {
    display: none;
}

.slider {
    position: relative;
    width: 38px;
    min-width: 38px;
    height: 20px;
    background-color: rgba(255, 255, 255, 0.18);
    border-radius: 20px;
    transition: 0.25s;
}

.slider:before {
    content: "";
    position: absolute;
    height: 14px;
    width: 14px;
    left: 3px;
    top: 3px;
    background-color: #fff;
    border-radius: 50%;
    transition: 0.25s;
}

.toggle-switch input:checked + .slider {
    background-color: var(--accent-red);
}

.toggle-switch input:checked + .slider:before {
    transform: translateX(18px);
}

/* Detail Card */
.hud-card {
    position: absolute;
    bottom: 24px;
    right: 24px;
    width: 400px;
    max-height: calc(100vh - 140px);
    overflow-y: auto;
    z-index: 25;
}

.card-header {
    padding: 14px 16px 10px 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.card-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
}

.card-subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.card-body {
    padding: 10px 16px 14px 16px;
}

.grid-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.data-item {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
}

.data-label {
    font-size: 0.68rem;
    color: var(--text-muted);
}

.data-value {
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--accent-cyan);
    margin-top: 2px;
}

.full-width-item {
    grid-column: 1 / -1;
}

.badge {
    display: inline-block;
    padding: 2px 8px;
    font-size: 0.7rem;
    font-weight: 700;
    border-radius: 4px;
    width: fit-content;
}

.badge-shindo {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: #fff;
    border: 1px solid #f87171;
}

.badge-mag {
    background: rgba(245, 158, 11, 0.2);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.4);
}

/* Depth Color Legend */
.depth-legend-card {
    position: absolute;
    bottom: 24px;
    left: 400px;
    padding: 10px 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    z-index: 20;
}

.depth-legend-title {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-secondary);
}

.depth-legend-bar {
    display: flex;
    gap: 12px;
    align-items: center;
}

.depth-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.72rem;
}

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

/* Dpad Camera Controller */
.dpad-island {
    position: absolute;
    bottom: 24px;
    left: 16px;
    width: var(--sidebar-width);
    z-index: 20;
}

.dpad-grid {
    display: grid;
    grid-template-columns: repeat(3, 36px);
    grid-template-rows: repeat(3, 36px);
    gap: 4px;
    justify-content: center;
    padding: 8px;
}

.dpad-btn {
    background: rgba(15, 23, 42, 0.75);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: var(--text-primary);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.dpad-btn:hover {
    background: rgba(239, 68, 68, 0.3);
    border-color: var(--accent-red);
    color: #fff;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    pointer-events: auto;
}

.modal-content {
    width: 100%;
    max-width: 650px;
    max-height: 85vh;
    overflow-y: auto;
    padding: 24px;
    position: relative;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 12px;
    margin-bottom: 16px;
}

.modal-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--accent-cyan);
}

.btn-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
}

.btn-close:hover {
    color: #fff;
}

.modal-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding-bottom: 8px;
    overflow-x: auto;
}

.modal-tab {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    padding: 6px 12px;
    font-size: 0.78rem;
    border-radius: 6px;
    cursor: pointer;
    white-space: nowrap;
}

.modal-tab.active {
    background: rgba(239, 68, 68, 0.25);
    border-color: var(--accent-red);
    color: #fff;
}

.tab-content {
    display: none;
    line-height: 1.65;
    font-size: 0.85rem;
    color: #cbd5e1;
}

.tab-content.active {
    display: block;
}

/* Loading Overlay */
.loading-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 16px 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 50;
}

.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid rgba(239, 68, 68, 0.3);
    border-top-color: var(--accent-red);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.hidden {
    display: none !important;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        width: calc(100% - 32px);
        max-height: 45vh;
        top: 140px;
    }
    .hud-card {
        width: calc(100% - 32px);
        right: 16px;
        bottom: 16px;
    }
    .depth-legend-card {
        display: none;
    }
    .dpad-island {
        display: none;
    }
}

/* 3D Camera Direction D-Pad Control HUD */
.camera-dpad-hud {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 900;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    border-radius: var(--radius-md);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.dpad-grid {
    display: grid;
    grid-template-columns: repeat(3, 44px);
    grid-template-rows: repeat(3, 44px);
    gap: 5px;
    justify-content: center;
    align-items: center;
    margin-top: 4px;
}

.dpad-btn {
    width: 44px;
    height: 44px;
    background: rgba(15, 23, 42, 0.85);
    border: 1.5px solid rgba(56, 189, 248, 0.4);
    border-radius: var(--radius-sm);
    color: #38bdf8;
    font-size: 1.3rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    user-select: none;
}

.dpad-btn:hover {
    background: rgba(56, 189, 248, 0.25);
    border-color: #00f3ff;
    color: #00f3ff;
    box-shadow: 0 0 12px rgba(0, 243, 255, 0.5);
    transform: scale(1.06);
}

.dpad-btn:active {
    background: rgba(0, 243, 255, 0.4);
    transform: scale(0.95);
}

.card-collapsible-content.collapsed {
    display: none;
}

/* Screen-Space Native Vector HTML Cutaway Pins */
.cutaway-html-pins-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 20;
    overflow: hidden;
}

.cutaway-pin-badge {
    position: absolute;
    transform: translate(-50%, -100%);
    background: rgba(15, 23, 42, 0.90);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1.5px solid rgba(56, 189, 248, 0.5);
    border-radius: 6px;
    padding: 4px 10px;
    font-family: var(--font-sans);
    font-size: 0.78rem;
    font-weight: 700;
    color: #ffffff;
    white-space: nowrap;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.7), 0 0 10px rgba(0, 243, 255, 0.3);
    pointer-events: auto;
    transition: opacity 0.2s ease, transform 0.1s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.cutaway-pin-badge::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%);
    border-width: 6px 5px 0 5px;
    border-style: solid;
    border-color: rgba(15, 23, 42, 0.90) transparent transparent transparent;
}

.cutaway-pin-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}
