:root {
    --bg-deep: #050505;
    --bg-panel: #0a0a0a;
    --bg-card: #0f1115;
    --border-dim: rgba(255, 255, 255, 0.05);
    --border-subtle: rgba(255, 255, 255, 0.1);
    --accent-cyan: #00d4ff;
    --accent-mint: #00ffaa;
    --accent-gold: #ffb020;
    --text-primary: #f0f4ff;
    --text-dim: #8892b0;
    --mono: 'Space Mono', monospace;
    --sans: 'Syne', sans-serif;
}

/* Progress Bars */
.progress-bg {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 2px;
    height: 4px;
    width: 100%;
    margin-top: 8px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    background: var(--bg-deep);
    color: var(--text-primary);
    font-family: var(--sans);
    overflow: hidden;
    height: 100vh;
}

/* Base Layout */
.obsidian-layout {
    display: grid;
    grid-template-columns: 280px 1fr 320px;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    background: var(--bg-panel);
    border-right: 1px solid var(--border-dim);
    display: flex;
    flex-direction: column;
    padding: 32px 24px;
    height: 100%;
}

.brand {
    font-size: 1.4rem;
    font-weight: 800;
    letter-spacing: -1px;
    margin-bottom: 48px;
    color: var(--accent-cyan);
    font-family: var(--sans);
}

.nav-group {
    margin-bottom: 40px;
}

.nav-label {
    font-family: var(--mono);
    font-size: 0.65rem;
    text-transform: uppercase;
    color: var(--text-dim);
    letter-spacing: 2px;
    margin-bottom: 16px;
    opacity: 0.6;
}

.nav-item {
    padding: 12px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-dim);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    margin-bottom: 6px;
    border: 1px solid transparent;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-primary);
}

.nav-item.active {
    background: rgba(0, 212, 255, 0.05);
    color: var(--text-primary);
    border-color: rgba(0, 212, 255, 0.2);
    border-left: 3px solid var(--accent-cyan);
}

/* Main Viewport */
.main-viewport {
    background: var(--bg-deep);
    position: relative;
    overflow-y: auto;
    padding: 48px;
    height: 100%;
}

.tab-content {
    animation: slideUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Metrics Dashboard */
.metric-card {
    background: var(--bg-card);
    border: 1px solid var(--border-dim);
    padding: 24px;
    border-radius: 8px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
}

.metric-label {
    font-family: var(--mono);
    font-size: 0.7rem;
    color: var(--text-dim);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

#fieldCanvas {
    width: 100%;
    height: 300px;
    background: #000;
    border-radius: 4px;
    border: 1px solid var(--border-dim);
}

/* Right Panel */
.metrics-panel {
    background: var(--bg-panel);
    border-left: 1px solid var(--border-dim);
    padding: 32px 24px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    height: 100%;
}

.metric-value {
    font-family: var(--mono);
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--accent-mint);
    letter-spacing: -1px;
}

/* Tuning Panel */
.tuning-panel {
    display: flex;
    flex-direction: column;
}

.control-group label {
    display: block;
    margin-bottom: 8px;
    letter-spacing: 1px;
}

input[type=range] {
    width: 100%;
    appearance: none;
    background: var(--border-dim);
    height: 4px;
    border-radius: 2px;
    outline: none;
}

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

/* Manual Tabs */
.manual-nav {
    margin-bottom: 24px;
}

.m-tab {
    font-family: var(--mono);
    font-size: 0.75rem;
    color: var(--text-dim);
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 4px;
    transition: all 0.2s;
}

.m-tab:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.m-tab.active {
    color: var(--accent-cyan);
    background: rgba(0, 212, 255, 0.05);
}

/* ACL Editor */
.acl-container {
    margin-top: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

#aclEditor {
    width: 100%;
    height: 300px;
    background: #000;
    color: var(--accent-mint);
    border: 1px solid var(--border-dim);
    padding: 24px;
    font-family: var(--mono);
    font-size: 0.95rem;
    border-radius: 4px;
    outline: none;
    resize: none;
    line-height: 1.5;
}

.run-btn {
    padding: 14px 28px;
    background: var(--accent-cyan);
    color: #000;
    font-weight: 800;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-family: var(--mono);
    font-size: 0.8rem;
    letter-spacing: 1px;
    transition: all 0.2s;
}

.run-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 212, 255, 0.4);
}

/* Manual & ISA */
.primitive-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
    margin-top: 24px;
}

.primitive-card {
    background: var(--bg-card);
    border: 1px solid var(--border-dim);
    padding: 16px;
    border-radius: 6px;
    transition: border-color 0.2s;
}

.primitive-card:hover {
    border-color: var(--border-subtle);
}

.primitive-code {
    font-family: var(--mono);
    color: var(--accent-gold);
    font-size: 0.85rem;
    font-weight: 700;
}

/* Ambience */
.field-ambient {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at 70% 30%, rgba(0, 212, 255, 0.03) 0%, transparent 50%),
        radial-gradient(circle at 20% 80%, rgba(0, 255, 170, 0.03) 0%, transparent 50%);
    z-index: -1;
    pointer-events: none;
}

/* Scrollbar Optimization */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-dim);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border-subtle);
}

/* Carrier Pool Telemetry */
.pool-progress-bg {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
    margin-top: 12px;
    overflow: hidden;
}

.pool-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-cyan), var(--accent-mint));
    box-shadow: 0 0 10px var(--accent-cyan);
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.mesh-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}

.node-id {
    display: block;
    color: var(--accent-cyan);
    font-weight: 700;
}

.node-status {
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(34, 197, 94, 0.1);
    color: var(--accent-mint);
}