/* noise-density lab */

.nd-layout {
    max-width: var(--ai-container-max);
    margin: 0 auto;
    padding: 0;
}

.nd-panel {
    border: 1px solid var(--ai-gray-200);
    border-radius: var(--ai-radius-lg);
    overflow: hidden;
    background: #fff;
    box-shadow: var(--ai-shadow-md);
}

.nd-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    padding: 16px 18px;
    background: #f8fafc;
    border-bottom: 1px solid var(--ai-gray-200);
}

.nd-header h2 {
    margin: 0;
    font-size: 1.2rem;
    color: var(--ai-blue-800);
}

.nd-ref {
    margin: 6px 0 0;
    font-size: 0.88rem;
    color: var(--ai-gray-600);
}

.nd-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px;
}

.nd-controls label {
    font-size: 0.88rem;
    color: var(--ai-gray-700);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nd-controls select {
    font-size: 0.9rem;
    padding: 7px 10px;
    border-radius: var(--ai-radius-sm);
    border: 1px solid var(--ai-gray-300);
    min-width: 160px;
    max-width: 220px;
}

.nd-swatch {
    display: inline-block;
    width: 0.65rem;
    height: 0.65rem;
    border-radius: 2px;
    margin-right: 4px;
    vertical-align: middle;
}

.nd-swatch-a { background: #2563eb; }
.nd-swatch-b { background: #c026d3; }

.nd-btn {
    font-size: 0.95rem;
    padding: 9px 16px;
    font-weight: 600;
    border: none;
    border-radius: var(--ai-radius-md);
    cursor: pointer;
}

.nd-btn-primary {
    background: var(--ai-blue-600);
    color: #fff;
}
.nd-btn-primary:hover { background: var(--ai-blue-800); }

.nd-btn-secondary {
    background: #fff;
    color: var(--ai-blue-800);
    border: 1px solid var(--ai-gray-300);
}
.nd-btn-secondary:hover { border-color: #93c5fd; }

.nd-body {
    padding: 14px 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.nd-nsd-wrap {
    border: 1px solid var(--ai-gray-200);
    border-radius: var(--ai-radius-md);
    background: #fff;
    overflow: hidden;
}

.nd-nsd-canvas {
    display: block;
    width: 100%;
    height: 280px;
}

.nd-band-block {
    padding: 10px 4px 4px;
}

.nd-band-label {
    font-size: 1.05rem;
    font-weight: 700;
    color: #5b21b6;
    margin: 0 0 8px;
}

.nd-band-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}

.nd-preset-btn {
    font-size: 0.78rem;
    font-weight: 600;
    padding: 5px 10px;
    border-radius: 999px;
    border: 1px solid var(--ai-gray-300);
    background: #fff;
    color: var(--ai-gray-700);
    cursor: pointer;
}
.nd-preset-btn:hover { border-color: #a78bfa; color: #5b21b6; }
.nd-preset-btn.is-active {
    background: #ede9fe;
    border-color: #8b5cf6;
    color: #5b21b6;
}

/* Dual-thumb slider */
.nd-band-slider {
    user-select: none;
    touch-action: none;
}
.nd-band-slider-track {
    position: relative;
    height: 10px;
    margin: 18px 10px 8px;
    background: #e2e8f0;
    border-radius: 999px;
}
.nd-band-slider-range {
    position: absolute;
    top: 0;
    height: 100%;
    background: rgba(124, 58, 237, 0.45);
    border-radius: 999px;
    pointer-events: none;
}
.nd-band-slider-thumb {
    position: absolute;
    top: 50%;
    width: 20px;
    height: 20px;
    margin-left: -10px;
    margin-top: -10px;
    border-radius: 50%;
    border: 2px solid #5b21b6;
    background: #fff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18);
    cursor: grab;
    padding: 0;
}
.nd-band-slider-thumb:focus-visible {
    outline: 2px solid #8b5cf6;
    outline-offset: 2px;
}
.nd-band-slider-thumb:active { cursor: grabbing; }
.nd-band-slider-ends {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--ai-gray-500);
    padding: 0 6px;
}

.nd-readouts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 8px;
}

.nd-readout {
    background: #f8fafc;
    border: 1px solid var(--ai-gray-200);
    border-radius: var(--ai-radius-md);
    padding: 10px 12px;
}
.nd-readout--a { border-left: 3px solid #2563eb; }
.nd-readout--b { border-left: 3px solid #c026d3; }
.nd-readout-label {
    display: block;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--ai-gray-500);
    margin-bottom: 2px;
}
.nd-readout-value {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--ai-blue-800);
}
.nd-readout-note {
    display: block;
    font-size: 0.78rem;
    color: var(--ai-gray-500);
    margin-top: 2px;
}

/* Two channels side-by-side: each is [scope | hist] with shared V/div */
.nd-time-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.nd-time-row.nd-time-row--solo {
    grid-template-columns: 1fr;
    max-width: 920px;
}
.nd-time-row.nd-time-row--solo .nd-channel-b {
    display: none;
}
.nd-channel {
    display: grid;
    grid-template-columns: 1.25fr 0.95fr;
    gap: 8px;
    min-width: 0;
}

.nd-scope-wrap,
.nd-hist-wrap {
    border: 1px solid var(--ai-gray-200);
    border-radius: var(--ai-radius-md);
    overflow: hidden;
    background: #eef0f3;
    min-height: 0;
}
.nd-panel-caption {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--ai-gray-600);
    padding: 6px 10px 0;
    background: #f1f5f9;
}
.nd-scope-canvas,
.nd-hist-canvas {
    display: block;
    width: 100%;
    height: 220px;
}

.nd-hint {
    margin: 0;
    font-size: 0.88rem;
    color: var(--ai-gray-600);
    line-height: 1.45;
}
.nd-aha {
    margin: 0;
    font-size: 0.9rem;
    color: var(--ai-gray-700);
    line-height: 1.5;
    padding: 10px 12px;
    background: #eff6ff;
    border-radius: var(--ai-radius-md);
    border: 1px solid #bfdbfe;
}

.nd-recipe-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.nd-recipe-btn {
    font-size: 0.78rem;
    font-weight: 600;
    padding: 5px 10px;
    border-radius: var(--ai-radius-sm);
    border: 1px solid #93c5fd;
    background: #eff6ff;
    color: var(--ai-blue-800);
    cursor: pointer;
}
.nd-recipe-btn:hover { background: #dbeafe; }

.nd-capstone {
    font-size: 0.9rem;
    margin: 0;
}

@media (max-width: 1100px) {
    .nd-time-row {
        grid-template-columns: 1fr;
    }
}
@media (max-width: 640px) {
    .nd-channel {
        grid-template-columns: 1fr;
    }
    .nd-nsd-canvas {
        height: 240px;
    }
}
