:root {
    --bg-color: #0f172a;
    --grid-col: #1e293b;
    --wire-low: #ef4444;
    --wire-high: #10b981;
}

body.logic-bg {
    background-color: var(--bg-color);
    margin: 0;
    overflow: hidden;
    font-family: 'JetBrains Mono', monospace;
    color: #e2e8f0;
}

.toolbox {
    position: absolute;
    top: 80px;
    left: 20px;
    width: 250px;
    z-index: 100;
}

.gate-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.btn-tool {
    background: rgba(30, 41, 59, 0.8);
    border: 1px solid rgba(255,255,255,0.1);
    color: #fff;
    padding: 8px;
    border-radius: 6px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: bold;
    transition: all 0.2s;
}
.btn-tool:hover { background: rgba(59, 130, 246, 0.5); }
.btn-tool:active { transform: scale(0.95); }

.workspace {
    position: absolute;
    top: 0; left: 0;
    width: 100vw; height: 100vh;
    background-image: 
        radial-gradient(var(--grid-col) 1px, transparent 1px);
    background-size: 20px 20px;
    z-index: 0;
}

.wire-layer {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 10;
}

.wire {
    fill: none;
    stroke-width: 4;
    pointer-events: stroke;
    cursor: pointer;
    transition: stroke 0.1s;
}

.wire[data-state="0"] { stroke: var(--wire-low); opacity: 0.6; }
.wire[data-state="1"] { stroke: var(--wire-high); filter: drop-shadow(0 0 4px var(--wire-high)); }

/* Components */
.comp-node {
    position: absolute;
    background: #1e293b;
    border: 2px solid #334155;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.5);
    z-index: 20;
    user-select: none;
    min-width: 80px;
}
.comp-node.selected { border-color: #3b82f6; }

.comp-controls {
    position: absolute;
    top: -25px; right: 0;
    display: flex; gap: 5px;
    display: none;
}
.comp-node:hover .comp-controls { display: flex; }
.btn-del {
    background: #ef4444; color: white; border: none; border-radius: 3px; font-size: 0.7rem; padding: 2px 5px; cursor: pointer;
}

.comp-label {
    flex: 1;
    text-align: center;
    font-weight: bold;
    padding: 0 10px;
    cursor: grab;
}
.comp-label:active { cursor: grabbing; }

.ports-in, .ports-out {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.port {
    width: 12px; height: 12px;
    background: #0f172a;
    border: 2px solid #64748b;
    border-radius: 50%;
    cursor: crosshair;
}
.port:hover { background: #fff; }
.port[data-state="1"] { background: var(--wire-high); border-color: #fff; }

/* Specific Components */
.comp-bulb .bulb-indicator {
    width: 20px; height: 20px;
    border-radius: 50%;
    background: #333;
    border: 2px solid #555;
    transition: all 0.1s;
}
.comp-bulb[data-on="1"] .bulb-indicator {
    background: #facc15;
    border-color: #fff;
    box-shadow: 0 0 15px #facc15;
}

.comp-switch { cursor: pointer; }
.comp-switch .switch-btn {
    width: 30px; height: 15px;
    background: #444; border-radius: 8px;
    position: relative; transition: background 0.2s;
}
.comp-switch .switch-btn::after {
    content: ''; position: absolute;
    width: 15px; height: 15px;
    background: #888; border-radius: 50%;
    left: 0; top: 0; transition: left 0.2s;
}
.comp-switch[data-on="1"] .switch-btn { background: var(--wire-high); }
.comp-switch[data-on="1"] .switch-btn::after { left: 15px; background: #fff; }
