/* ============================================
   Bench Tools — WebAudio MOS 6581 / 8580 SID Chiptune Synth & Music Lab Visualizer
   Theme-aware CRT / Digital Grid styles for /bench-tools/sid-synth & /music-lab
   ============================================ */

.sid-chip-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    justify-content: space-between;
    margin: 0.85rem 0 1.1rem;
    padding-bottom: 0.85rem;
    border-bottom: 1px solid var(--border, rgba(255, 255, 255, 0.1));
}

.sid-chip-group,
.sid-preset-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    align-items: center;
}

.sid-preset-bar {
    margin-bottom: 1.1rem;
    padding: 0.7rem 0.85rem;
    background: var(--code-bg, #1e1e2e);
    border: 1px solid var(--border, rgba(255, 255, 255, 0.1));
    border-radius: 10px;
}

.sid-bar-label {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-right: 0.25rem;
}

.sid-btn,
.sid-select,
.sid-input {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-primary);
    background: var(--bg-card-solid, #14141f);
    border: 1px solid var(--border, rgba(255, 255, 255, 0.14));
    border-radius: 6px;
    padding: 0.42rem 0.72rem;
    cursor: pointer;
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.38rem;
}

.sid-btn:hover,
.sid-select:hover {
    border-color: var(--accent, #00ff88);
    color: var(--accent, #00ff88);
}

.sid-btn.active,
.sid-btn-primary {
    background: var(--accent-glow, rgba(0, 255, 136, 0.14));
    border-color: var(--accent, #00ff88);
    color: var(--accent, #00ff88);
    font-weight: 600;
    box-shadow: 0 0 12px rgba(0, 255, 136, 0.14);
}

.sid-btn-danger {
    border-color: rgba(255, 68, 102, 0.4);
    color: var(--error, #ff4466);
}

.sid-btn-danger:hover {
    background: rgba(255, 68, 102, 0.14);
    border-color: var(--error, #ff4466);
    color: var(--error, #ff4466);
}

.sid-tag {
    font-size: 0.65rem;
    opacity: 0.85;
    padding: 0.08rem 0.38rem;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.07);
}

/* Music Lab Visualizer Stage (integrated with .music-player / .eq-container) */
.sid-musiclab-stage {
    position: relative;
    background: #05070e;
    border: 1px solid var(--border, rgba(255, 255, 255, 0.12));
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 1.2rem;
    box-shadow: inset 0 0 32px rgba(0, 255, 136, 0.05);
}

.sid-musiclab-topbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.6rem 0.95rem;
    background: rgba(12, 14, 24, 0.92);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    font-family: var(--font-mono);
    font-size: 0.72rem;
}

.sid-musiclab-status {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    color: var(--accent, #00ff88);
    font-weight: 600;
}

.sid-led-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #5e5e78;
    display: inline-block;
    transition: all 0.15s ease;
}

.sid-led-dot.is-on {
    background: var(--accent, #00ff88);
    box-shadow: 0 0 10px var(--accent, #00ff88);
}

.sid-canvas-wrap {
    position: relative;
    width: 100%;
    height: 230px;
    background:
        linear-gradient(rgba(0, 255, 136, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 255, 136, 0.03) 1px, transparent 1px),
        #05070d;
    background-size: 24px 24px;
}

.sid-eq-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

.sid-hud-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 0.65rem 1rem;
    background: linear-gradient(transparent, rgba(5, 7, 13, 0.88));
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: flex-end;
    gap: 0.5rem;
    pointer-events: none;
    font-family: var(--font-mono);
}

.sid-hud-patch {
    display: flex;
    flex-direction: column;
    gap: 0.12rem;
}

.sid-hud-eyebrow {
    font-size: 0.62rem;
    letter-spacing: 0.16em;
    color: var(--accent, #00ff88);
    text-transform: uppercase;
}

.sid-hud-title {
    font-family: var(--font-heading);
    font-size: 1.02rem;
    font-weight: 700;
    color: #fff;
}

.sid-hud-metrics {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    font-size: 0.7rem;
    color: #a8b2d1;
}

.sid-hud-metrics strong {
    color: var(--accent, #00ff88);
}

/* Telemetry Readout Strip */
.sid-telemetry-strip {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(155px, 1fr));
    gap: 0.6rem;
    margin-bottom: 1.2rem;
}

.sid-stat-card {
    background: var(--code-bg, #1e1e2e);
    border: 1px solid var(--border, rgba(255, 255, 255, 0.1));
    border-radius: 8px;
    padding: 0.55rem 0.75rem;
    font-family: var(--font-mono);
}

.sid-stat-label {
    display: block;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.15rem;
}

.sid-stat-val {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--accent, #00ff88);
}

/* 3-Voice Oscillator & ADSR Grid */
.sid-voices-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
    margin-bottom: 1.2rem;
}

@media (max-width: 1080px) {
    .sid-voices-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

.sid-voice-card {
    background: var(--code-bg, #1e1e2e);
    border: 1px solid var(--border, rgba(255, 255, 255, 0.12));
    border-radius: 10px;
    padding: 1rem;
    position: relative;
    transition: border-color 0.2s ease;
}

.sid-voice-card.is-muted {
    opacity: 0.6;
}

.sid-voice-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    padding-bottom: 0.55rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sid-voice-title {
    font-family: var(--font-heading);
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.45rem;
    margin: 0;
}

.sid-reg-badge {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    padding: 0.12rem 0.42rem;
    border-radius: 4px;
    background: rgba(0, 255, 136, 0.1);
    color: var(--accent, #00ff88);
    border: 1px solid rgba(0, 255, 136, 0.25);
}

.sid-wave-btns {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.35rem;
    margin-bottom: 0.75rem;
}

.sid-wave-btn {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    padding: 0.42rem 0.3rem;
    border-radius: 6px;
    background: var(--bg-card-solid, #14141f);
    border: 1px solid var(--border, rgba(255, 255, 255, 0.14));
    color: var(--text-secondary);
    cursor: pointer;
    text-align: center;
    transition: all 0.15s ease;
}

.sid-wave-btn:hover {
    border-color: var(--accent, #00ff88);
    color: var(--accent, #00ff88);
}

.sid-wave-btn.active {
    background: var(--accent-glow, rgba(0, 255, 136, 0.16));
    border-color: var(--accent, #00ff88);
    color: var(--accent, #00ff88);
    font-weight: 700;
}

.sid-control-row {
    margin-bottom: 0.6rem;
}

.sid-control-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: var(--font-mono);
    font-size: 0.71rem;
    color: var(--text-secondary);
    margin-bottom: 0.22rem;
}

.sid-control-val {
    color: var(--accent, #00ff88);
    font-weight: 600;
}

.sid-slider {
    width: 100%;
    accent-color: var(--accent, #00ff88);
    cursor: pointer;
    height: 6px;
}

.sid-adsr-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem 0.65rem;
    padding-top: 0.55rem;
    margin-top: 0.55rem;
    border-top: 1px dashed rgba(255, 255, 255, 0.1);
}

/* Filter, Arpeggiator & ADSR Preview Row */
.sid-mid-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
    margin-bottom: 1.2rem;
}

@media (max-width: 960px) {
    .sid-mid-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

.sid-subcard {
    background: var(--code-bg, #1e1e2e);
    border: 1px solid var(--border, rgba(255, 255, 255, 0.12));
    border-radius: 10px;
    padding: 1rem;
}

.sid-subcard-title {
    font-family: var(--font-heading);
    font-size: 0.96rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 0.75rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.sid-filter-modes,
.sid-route-toggles {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin-bottom: 0.75rem;
}

.sid-adsr-svg-wrap {
    background: #070912;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    padding: 0.45rem;
    margin-top: 0.6rem;
}

/* 16-Step Pattern Sequencer */
.sid-seq-grid {
    display: grid;
    grid-template-columns: repeat(16, minmax(42px, 1fr));
    gap: 0.35rem;
    overflow-x: auto;
    padding-bottom: 0.35rem;
    margin-top: 0.65rem;
}

.sid-seq-step {
    background: var(--bg-card-solid, #14141f);
    border: 1px solid var(--border, rgba(255, 255, 255, 0.12));
    border-radius: 6px;
    padding: 0.35rem 0.25rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.28rem;
    font-family: var(--font-mono);
    font-size: 0.68rem;
    transition: all 0.12s ease;
}

.sid-seq-step.is-playing {
    border-color: var(--accent, #00ff88);
    box-shadow: 0 0 12px rgba(0, 255, 136, 0.28);
    background: rgba(0, 255, 136, 0.1);
}

.sid-seq-step.is-muted-step {
    opacity: 0.42;
}

.sid-seq-num {
    font-size: 0.62rem;
    color: var(--text-muted);
}

.sid-seq-gate {
    width: 100%;
    padding: 0.2rem 0;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(0, 255, 136, 0.15);
    color: var(--accent, #00ff88);
    font-family: var(--font-mono);
    font-size: 0.64rem;
    font-weight: 700;
    cursor: pointer;
}

.sid-seq-step.is-muted-step .sid-seq-gate {
    background: transparent;
    color: var(--text-muted);
}

.sid-seq-note {
    width: 100%;
    font-family: var(--font-mono);
    font-size: 0.66rem;
    padding: 0.18rem 0.1rem;
    border-radius: 4px;
    background: #0b0d17;
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.12);
    text-align: center;
}

/* Playable 2-Octave Piano & QWERTY Keyboard */
.sid-keyboard-wrap {
    position: relative;
    user-select: none;
    -webkit-user-select: none;
    overflow-x: auto;
    padding: 0.5rem 0.2rem 0.25rem;
}

.sid-piano {
    position: relative;
    display: flex;
    height: 148px;
    min-width: 680px;
    gap: 3px;
}

.sid-key-white {
    flex: 1;
    background: linear-gradient(180deg, #e8ecf4 0%, #cfd6e6 100%);
    border: 1px solid #4a5568;
    border-radius: 0 0 7px 7px;
    position: relative;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    padding-bottom: 0.45rem;
    color: #1a202c;
    font-family: var(--font-mono);
    font-size: 0.68rem;
    font-weight: 700;
    transition: background 0.08s ease, transform 0.06s ease;
}

.sid-key-white:hover {
    background: linear-gradient(180deg, #ffffff 0%, #d8f8e8 100%);
}

.sid-key-white.is-active {
    background: linear-gradient(180deg, var(--accent, #00ff88) 0%, #00b894 100%);
    color: #04080e;
    transform: translateY(2px);
    box-shadow: 0 0 16px rgba(0, 255, 136, 0.45);
}

.sid-key-black {
    position: absolute;
    top: 0;
    width: 3.8%;
    height: 92px;
    background: linear-gradient(180deg, #1e2433 0%, #090c14 100%);
    border: 1px solid #384152;
    border-radius: 0 0 5px 5px;
    z-index: 3;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    padding-bottom: 0.35rem;
    color: #cbd5e1;
    font-family: var(--font-mono);
    font-size: 0.6rem;
    transform: translateX(-50%);
    transition: background 0.08s ease;
}

.sid-key-black.is-active {
    background: linear-gradient(180deg, #00ccff 0%, var(--accent, #00ff88) 100%);
    color: #05070e;
    font-weight: 700;
    box-shadow: 0 0 14px rgba(0, 255, 136, 0.5);
}

.sid-key-kbd {
    font-size: 0.58rem;
    padding: 0.06rem 0.25rem;
    border-radius: 3px;
    background: rgba(0, 0, 0, 0.14);
    margin-bottom: 0.15rem;
}

.sid-key-black .sid-key-kbd {
    background: rgba(255, 255, 255, 0.12);
}

/* Live SID Register Dump & 6502/BASIC Code Export */
.sid-reg-matrix {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(105px, 1fr));
    gap: 0.35rem;
    margin-bottom: 0.85rem;
}

.sid-reg-cell {
    background: #090c15;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 5px;
    padding: 0.3rem 0.45rem;
    font-family: var(--font-mono);
    font-size: 0.67rem;
    font-variant-numeric: tabular-nums;
    height: 44px;
    min-height: 44px;
    max-height: 44px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.sid-reg-addr {
    color: var(--text-muted);
    font-size: 0.6rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sid-reg-hex {
    color: var(--accent, #00ff88);
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sid-code-pre {
    background: #080a12;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.75rem;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    line-height: 1.5;
    color: #a6e3a1;
    max-height: 210px;
    overflow-y: auto;
    white-space: pre-wrap;
    margin: 0;
}

.sid-howto-details {
    margin-top: 1.25rem;
    background: var(--code-bg, #1e1e2e);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.85rem 1.1rem;
}

.sid-howto-summary {
    font-family: var(--font-heading);
    font-size: 0.98rem;
    font-weight: 700;
    color: var(--accent, #00ff88);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
