:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-tertiary: #1a1a25;
    --border-color: #2a2a3a;
    --accent-cyan: #00f5ff;
    --accent-magenta: #ff00aa;
    --accent-yellow: #f5ff00;
    --accent-green: #00ff88;
    --text-primary: #ffffff;
    --text-secondary: #8888aa;
    --text-muted: #555566;
    --neuron-inactive: #333344;
    --neuron-active: #00f5ff;
    --connection-positive: #00ff88;
    --connection-negative: #ff00aa;
}

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

body {
    font-family: 'Space Grotesk', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Header */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 30px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

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

h1 {
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.subtitle {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.header-stats {
    display: flex;
    gap: 12px;
}

.stat-badge {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    backdrop-filter: blur(10px);
}

.stat-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    color: var(--accent-cyan);
    font-weight: 500;
}

/* Main */
main {
    margin: 0 auto;
    padding: 25px 30px;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 25px;
    align-items: start;
}

.panel-left {
    position: sticky;
    top: 25px;
}

.panel-right {
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-width: 0;
}

.section-title {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 12px;
}

/* Output Grid */
.output-section {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
}

.output-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
}

.output-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 6px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    transition: all 0.2s ease;
}

.output-card.winner {
    border-color: var(--accent-cyan);
    background: rgba(0, 245, 255, 0.08);
    box-shadow: 0 0 15px rgba(0, 245, 255, 0.15);
}

.digit-label {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-muted);
    transition: color 0.2s ease;
}

.output-card.winner .digit-label {
    color: var(--accent-cyan);
}

.confidence-bar {
    width: 100%;
    height: 4px;
    background: var(--bg-primary);
    border-radius: 2px;
    margin: 8px 0 4px;
    overflow: hidden;
}

.confidence-fill {
    height: 100%;
    width: 0%;
    background: var(--accent-cyan);
    border-radius: 2px;
    transition: width 0.15s ease;
}

.output-card.winner .confidence-fill {
    background: linear-gradient(90deg, var(--accent-cyan), var(--accent-green));
    box-shadow: 0 0 8px rgba(0, 245, 255, 0.4);
}

.confidence-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.65rem;
    color: var(--text-muted);
    transition: color 0.2s ease;
}

.output-card.winner .confidence-value {
    color: var(--accent-cyan);
}

/* Visualization */
.visualization-section {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
}

.viz-container {
    width: 100%;
    border-radius: 8px;
    overflow: hidden;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
}

#network-canvas {
    width: 100%;
    height: 300px;
    display: block;
}

/* Drawing */
.drawing-section {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

#drawing-canvas {
    width: 320px;
    height: 320px;
    border-radius: 8px;
    border: 2px solid var(--border-color);
    cursor: crosshair;
    image-rendering: pixelated;
    background: var(--bg-primary);
    flex-shrink: 0;
}

.drawing-controls {
    display: flex;
    align-items: center;
    gap: 20px;
}

.btn {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    padding: 10px 24px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn:hover {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 20px rgba(0, 245, 255, 0.15);
}

.btn-clear:hover {
    border-color: var(--accent-magenta);
    box-shadow: 0 0 20px rgba(255, 0, 170, 0.15);
}

.brush-size {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

input[type="range"] {
    -webkit-appearance: none;
    width: 120px;
    height: 4px;
    background: var(--bg-primary);
    border-radius: 2px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent-cyan);
    cursor: pointer;
}

/* Footer */
footer {
    text-align: center;
    padding: 20px;
    color: var(--text-muted);
    font-size: 0.75rem;
    border-top: 1px solid var(--border-color);
}

/* Responsive */
@media (max-width: 768px) {
    header {
        flex-direction: column;
        gap: 12px;
        text-align: center;
    }

    main {
        grid-template-columns: 1fr;
    }

    .panel-left {
        position: static;
    }

    .drawing-section {
        align-items: center;
    }

    #drawing-canvas {
        width: 260px;
        height: 260px;
    }
}

@keyframes glow {
    0%, 100% { box-shadow: 0 0 5px var(--accent-cyan); }
    50% { box-shadow: 0 0 20px var(--accent-cyan), 0 0 30px var(--accent-cyan); }
}

.loading {
    animation: glow 2s ease-in-out infinite;
}
