:root {
    --bg-deep: #050510;
    --bg-sidebar: #0f1020;
    --bg-panel: rgba(20, 20, 35, 0.6);
    --primary: #00f0ff;
    /* Neon Cyan */
    --secondary: #7000ff;
    /* Neon Purple */
    --accent: #ff0055;
    /* Neon Pink */
    --text: #ffffff;
    --text-dim: #8b9bb4;
    --border-color: rgba(255, 255, 255, 0.1);
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;
    --font-mono: 'Fira Code', monospace;
    --sidebar-width: 280px;
}

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

body {
    background-color: var(--bg-deep);
    color: var(--text);
    font-family: var(--font-body);
    overflow: hidden;
    /* Main scroll handled by content area */
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Background Effects */
.stars-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(1px 1px at 10% 10%, #fff 1px, transparent 0),
        radial-gradient(1px 1px at 20% 40%, #fff 1px, transparent 0),
        radial-gradient(2px 2px at 40% 60%, rgba(255, 255, 255, 0.5) 1px, transparent 0),
        radial-gradient(1px 1px at 80% 30%, #fff 1px, transparent 0);
    background-size: 550px 550px;
    z-index: -2;
    opacity: 0.3;
    pointer-events: none;
}

.scanlines {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0) 50%, rgba(0, 0, 0, 0.1) 50%, rgba(0, 0, 0, 0.1));
    background-size: 100% 4px;
    pointer-events: none;
    z-index: 100;
    opacity: 0.3;
}

/* Navbar */
.nav-bar {
    height: 60px;
    padding: 0 40px;
    display: flex;
    align-items: center;
    background: var(--bg-sidebar);
    border-bottom: 1px solid var(--border-color);
    z-index: 50;
    flex-shrink: 0;
}

.back-link {
    color: var(--text-dim);
    text-decoration: none;
    font-family: var(--font-heading);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: color 0.3s;
}

.back-link:hover {
    color: var(--primary);
}

/* Layout Container */
.layout-container {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 20px 0;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 0 24px 20px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 20px;
}

.sidebar-header h2 {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    color: var(--primary);
    margin-bottom: 4px;
}

.sidebar-header p {
    color: var(--text-dim);
    font-size: 0.85rem;
}

.nav-menu {
    list-style: none;
    overflow-y: auto;
    flex: 1;
}

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

.group-title {
    display: block;
    padding: 0 24px 8px;
    font-size: 0.75rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

.nav-item {
    padding: 10px 24px;
    cursor: pointer;
    color: var(--text);
    font-size: 0.95rem;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

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

.nav-item.active {
    background: rgba(0, 240, 255, 0.1);
    color: var(--primary);
    border-left-color: var(--primary);
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 40px;
    overflow-y: auto;
    position: relative;
    background: rgba(0, 0, 0, 0.2);
}

.content-section {
    display: none;
    max-width: 1200px;
    margin: 0 auto;
    animation: fadeIn 0.4s ease-out;
}

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

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

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

.content-section h1 {
    font-family: var(--font-heading);
    font-size: 2.5rem;
    margin-bottom: 10px;
    background: linear-gradient(90deg, #fff, #8b9bb4);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.section-desc {
    font-size: 1.1rem;
    color: var(--text-dim);
    margin-bottom: 30px;
    line-height: 1.6;
    max-width: 800px;
}

.concept-explanation {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 30px;
}

.concept-explanation p {
    margin-bottom: 12px;
    line-height: 1.6;
    color: var(--text-dim);
}

.concept-explanation strong {
    color: var(--primary);
}

.concept-explanation p:last-child {
    margin-bottom: 0;
}

/* Visualization Wrapper */
.viz-wrapper {
    background: #0a0c15;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    position: relative;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.3);
    min-height: 500px;
    display: flex;
    flex-direction: column;
}

.viz-placeholder {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    color: var(--text-dim);
    opacity: 0.6;
}

.icon-large {
    font-size: 5rem;
    margin-bottom: 20px;
}

canvas {
    background: #0f111a;
    width: 100%;
    flex: 1;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

/* Controls */
.viz-controls {
    display: flex;
    gap: 15px;
    padding: 20px 0 0;
    align-items: center;
}

.control-btn {
    background: rgba(0, 240, 255, 0.1);
    border: 1px solid var(--primary);
    color: var(--primary);
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-family: var(--font-mono);
    font-size: 0.9rem;
    transition: all 0.2s;
}

.control-btn:hover {
    background: var(--primary);
    color: #000;
}

.control-btn:active {
    transform: translateY(1px);
}

#current-watermark {
    font-family: var(--font-mono);
    color: var(--accent);
    margin-left: auto;
}

/* Legend */
.viz-legend {
    display: flex;
    gap: 20px;
    margin-top: 15px;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-dim);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

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

.dot.data {
    background: #00f0ff;
}

.dot.barrier {
    background: #ff0055;
    border-radius: 2px;
    width: 4px;
    height: 16px;
}

/* Barrier is a bar */
.dot.snapshot {
    border: 2px dashed #ffcc00;
    background: transparent;
}

.dot.event-ok {
    background: #00ff00;
}

.dot.event-late {
    background: #555;
}

.dot.line-w {
    background: #ffcc00;
    height: 2px;
    width: 14px;
    border-radius: 0;
}

.dot.block-line {
    background: #ff3333;
    width: 14px;
    height: 4px;
    border-radius: 2px;
}

/* Responsive */
@media (max-width: 900px) {
    .layout-container {
        flex-direction: column;
        overflow-y: auto;
    }

    .sidebar {
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        padding: 0;
        max-height: 200px;
        /* Collapsible feeling or just small */
        overflow-y: auto;
    }

    .sidebar-header {
        display: none;
    }

    .nav-menu ul {
        display: flex;
        flex-wrap: wrap;
        padding: 5px;
    }

    .group-title {
        width: 100%;
        padding: 5px;
    }

    .nav-item {
        padding: 8px 12px;
        font-size: 0.85rem;
    }

    .main-content {
        padding: 20px;
        overflow: visible;
    }

    body {
        overflow-y: auto;
        /* Enable body scroll on mobile */
    }
}