:root {
    --bg-app: #0B0C10;
    --bg-panel: #111419;
    --bg-input: #1a1f26;
    --border: #232b35;
    
    --text-main: #C5C6C7;
    --text-dim: #7f8a96;
    
    --accent: #66FCF1;
    --accent-dim: #45A29E;
    --boids: #F2A900;
    --danger: #ef4444;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    background: var(--bg-app);
    color: var(--text-main);
    font-family: 'Inter', sans-serif;
    display: flex;
    height: 100vh;
    overflow: hidden;
    font-size: 13px;
    -webkit-font-smoothing: antialiased;
}

.mono { 
    font-family: 'JetBrains Mono', monospace; 
}

.layout {
    display: flex;
    width: 100%;
    height: 100%;
}

aside.sidebar {
    width: 320px;
    background: var(--bg-panel);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 10;
    box-shadow: 2px 0 15px rgba(0,0,0,0.4);
    flex-shrink: 0;
}

.sidebar-header {
    padding: 20px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.sidebar-header h2 {
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.status {
    font-size: 11px;
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-dim);
}
.status::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
}
.status.connected::before { background: var(--accent); box-shadow: 0 0 6px var(--accent); }
.status.disconnected::before { background: var(--danger); box-shadow: 0 0 6px var(--danger); }

.tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
}
.tabs button {
    flex: 1;
    background: transparent;
    border: none;
    padding: 12px 0;
    color: var(--text-dim);
    font-weight: 500;
    font-size: 12px;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}
.tabs button:hover { color: var(--text-main); }
.tabs button.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.scroll-area {
    flex: 1;
    overflow-y: auto;
    padding: 20px 16px;
}
/* Scrollbar */
.scroll-area::-webkit-scrollbar { width: 6px; }
.scroll-area::-webkit-scrollbar-track { background: transparent; }
.scroll-area::-webkit-scrollbar-thumb { background: #333; border-radius: 3px; }

.section {
    margin-bottom: 28px;
}
.section-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-dim);
    margin-bottom: 12px;
    font-weight: 600;
}

.row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}
.row.coords {
    display: flex;
    gap: 6px;
}
.row.coords input { 
    flex: 1; 
    min-width: 0; 
    text-align: center; 
}

.two-cols {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

label {
    flex: 1;
    color: var(--text-main);
}
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

input[type="number"], input[type="text"] {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: #fff;
    padding: 6px 8px;
    border-radius: 4px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    width: 70px;
    outline: none;
    transition: border-color 0.2s;
}
input[type="number"]:focus { border-color: var(--accent-dim); }
input[type="number"]::-webkit-inner-spin-button { opacity: 0.2; }

input[type="range"] {
    flex: 2;
    accent-color: var(--accent);
}

.btn {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: #fff;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.2s;
}
.btn i { width: 14px; height: 14px; }
.btn:hover { background: #262e38; border-color: var(--text-dim); }

.btn.full { 
    width: 100%; 
    background: rgba(102, 252, 241, 0.05); 
    border-color: var(--accent-dim); 
    color: var(--accent); 
    padding: 10px;
}
.btn.full:hover { background: rgba(102, 252, 241, 0.15); }

.btn-danger { color: var(--danger); border-color: rgba(239, 68, 68, 0.3); }
.btn-danger:hover { background: rgba(239, 68, 68, 0.1); border-color: var(--danger); }

.btn-icon { padding: 8px; flex: 1; }
.btn-icon i { width: 16px; height: 16px; }

.metrics {
    border-top: 1px solid var(--border);
    background: #0d0f13;
    padding: 16px;
}
.metric {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
}
.metric:last-child { margin-bottom: 0; }
.metric .lbl { color: var(--text-dim); }
.metric .val { color: var(--accent); }

.goal-list {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 4px;
    max-height: 140px;
    overflow-y: auto;
    margin-top: 8px;
}
.goal-list::-webkit-scrollbar { width: 4px; }
.goal-list::-webkit-scrollbar-thumb { background: #444; }

.goal-item {
    display: flex;
    gap: 8px;
    padding: 8px;
    border-bottom: 1px solid var(--border);
    font-size: 12px;
}
.goal-item:last-child { border-bottom: none; }
.goal-item.active { 
    background: rgba(102, 252, 241, 0.1); 
    color: var(--accent); 
}
.goal-item .idx { color: var(--text-dim); width: 16px; }

.empty-state {
    padding: 16px;
    text-align: center;
    color: var(--text-dim);
    font-style: italic;
    font-size: 12px;
}

main.viewport {
    flex: 1;
    position: relative;
    background: var(--bg-app);
}

.canvas-wrapper {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}
canvas {
    display: block;
    width: 100%;
    height: 100%;
    outline: none;
    cursor: crosshair;
}

.overlay-msg {
    position: absolute;
    top: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(17, 20, 25, 0.85);
    border: 1px solid var(--accent-dim);
    color: var(--accent);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    z-index: 20;
    pointer-events: none;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    display: none;
    white-space: nowrap;
}

.legend {
    position: absolute;
    bottom: 24px;
    right: 24px;
    background: rgba(17, 20, 25, 0.85);
    border: 1px solid var(--border);
    padding: 12px 16px;
    border-radius: 6px;
    display: flex;
    gap: 16px;
    z-index: 20;
    backdrop-filter: blur(4px);
    flex-wrap: wrap;
    max-width: min(620px, calc(100% - 48px));
}
.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-dim);
}
.swatch {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}
.swatch.gnca { background: var(--accent); }
.swatch.boids { background: var(--boids); }
.swatch.goal { background: #4ADE80; box-shadow: 0 0 6px rgba(74,222,128,0.8); }
.legend-note {
    width: 100%;
    padding-top: 8px;
    border-top: 1px solid var(--border);
    color: var(--text-dim);
    font: 10px 'JetBrains Mono', monospace;
    letter-spacing: 0.02em;
}

@media (max-width: 768px) {
    .layout { flex-direction: column; }
    aside.sidebar { 
        width: 100%; 
        height: 50vh; 
        border-right: none; 
        border-bottom: 1px solid var(--border); 
    }
    main.viewport { height: 50vh; }
}