/* SoundLab - dark theme matching WebLab / WebTools family */

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #1e1e1e;
    color: #e0e0e0;
    min-height: 100vh;
}

/* Header */
.header {
    background: #252526;
    padding: 14px 20px;
    border-bottom: 1px solid #3c3c3c;
    text-align: center;
}

.header-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 18px;
    flex-wrap: wrap;
}

.header h1 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
    color: #007acc;
}

.tagline {
    margin: 4px 0 0 0;
    font-size: 0.85rem;
    color: #888;
}

/* Mode toggle (Beginner / Advanced) */
.mode-toggle {
    display: inline-flex;
    border: 1px solid #3c3c3c;
    border-radius: 4px;
    overflow: hidden;
    background: #1e1e1e;
}

.mode-toggle-btn {
    background: transparent;
    color: #cfcfcf;
    border: none;
    padding: 5px 14px;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.12s, color 0.12s;
}

.mode-toggle-btn + .mode-toggle-btn {
    border-left: 1px solid #3c3c3c;
}

.mode-toggle-btn:hover {
    background: #2d2d30;
    color: #fff;
}

.mode-toggle-btn.active {
    background: #007acc;
    color: #fff;
}

.mode-toggle-btn:focus-visible {
    outline: 2px solid #007acc;
    outline-offset: -2px;
}

/* Hide advanced controls when in beginner mode */
body.beginner-mode .advanced-only {
    display: none !important;
}

/* Split-pane layout */
.layout {
    display: grid;
    grid-template-columns: 360px 1fr;
    gap: 16px;
    padding: 16px;
    align-items: start;
}

.rail {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

@media (max-width: 880px) {
    .layout {
        grid-template-columns: 1fr;
    }
}

/* Panels */
.panel {
    background: #252526;
    border: 1px solid #3c3c3c;
    border-radius: 6px;
    padding: 14px 16px;
}

.panel-title {
    margin: 0 0 12px 0;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #007acc;
}

/* Collapsible panels (left rail). Click the title to fold a panel. */
.panel-collapsible {
    margin: 0;
}

.panel-collapsible > summary.panel-title {
    cursor: pointer;
    user-select: none;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 8px;
    outline: none;
}

.panel-collapsible > summary.panel-title::-webkit-details-marker {
    display: none;
}

.panel-collapsible > summary.panel-title::before {
    content: '\25be';
    font-size: 0.85em;
    color: #888;
    transition: transform 0.15s;
    display: inline-block;
}

.panel-collapsible:not([open]) > summary.panel-title::before {
    transform: rotate(-90deg);
}

.panel-collapsible:not([open]) > summary.panel-title {
    margin-bottom: 0;
}

.panel-collapsible > summary.panel-title:hover::before {
    color: #cfcfcf;
}

.panel-collapsible > summary.panel-title:focus-visible {
    outline: 1px solid #007acc;
    outline-offset: 2px;
    border-radius: 2px;
}

.panel-placeholder {
    margin: 0;
    font-size: 0.85rem;
    color: #777;
    font-style: italic;
}

/* Controls */
.control {
    margin-bottom: 12px;
}

.control:last-child {
    margin-bottom: 0;
}

.control label {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-size: 0.82rem;
    color: #cfcfcf;
    margin-bottom: 6px;
}

.value-readout {
    font-family: 'Consolas', 'Menlo', monospace;
    font-size: 0.8rem;
    color: #9cdcfe;
}

.control select,
.control input[type="number"],
.control input[type="text"] {
    width: 100%;
    background: #1e1e1e;
    color: #e0e0e0;
    border: 1px solid #3c3c3c;
    border-radius: 4px;
    padding: 6px 8px;
    font-size: 0.9rem;
    font-family: inherit;
}

.control input[type="text"] {
    font-family: 'Consolas', 'Menlo', monospace;
}

.control select:focus,
.control input[type="number"]:focus,
.control input[type="text"]:focus {
    outline: none;
    border-color: #007acc;
}

.control input[type="range"] {
    width: 100%;
    accent-color: #007acc;
}

.checkbox-control label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 0;
    cursor: pointer;
}

.checkbox-control input[type="checkbox"] {
    accent-color: #007acc;
    width: 14px;
    height: 14px;
    margin: 0;
}

.control-static-label {
    display: block;
    font-size: 0.82rem;
    color: #cfcfcf;
    margin-bottom: 6px;
}

.lfo-section {
    margin-bottom: 14px;
    padding-bottom: 12px;
    border-bottom: 1px solid #2d2d30;
}

.lfo-section:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.lfo-header {
    margin-bottom: 10px;
}

/* Effects rack. Each effect is a narrow channel strip with horizontal
 * sliders stacked vertically inside; the effect name and enable
 * checkbox sit at the top of each strip. Strips lay out side-by-side
 * with wrap on narrow screens. */
.effects-rack {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: flex-start;
}

.effect-strip {
    flex: 0 0 calc((100% - 32px) / 5);
    box-sizing: border-box;
    background: #1e1e1e;
    border: 1px solid #3c3c3c;
    border-radius: 4px;
    padding: 6px 7px;
}

.effect-strip-header {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.7rem;
    font-weight: 600;
    color: #007acc;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin: 0 0 6px 0;
    cursor: pointer;
    user-select: none;
}

.effect-strip-header input[type="checkbox"] {
    accent-color: #007acc;
    width: 12px;
    height: 12px;
    margin: 0;
    flex: 0 0 auto;
}

.effect-strip .control {
    margin-bottom: 6px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
}

.effect-strip .control:last-child {
    margin-bottom: 0;
}

.effect-strip .control label {
    font-size: 0.66rem;
    color: #cfcfcf;
    margin-bottom: 2px;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 4px;
}

.effect-strip .value-readout {
    font-size: 0.62rem;
    color: #9aa0a6;
    font-variant-numeric: tabular-nums;
}

.effect-strip input[type="range"] {
    width: 100%;
    accent-color: #007acc;
    height: 14px;
    margin: 0;
}

.effect-strip select {
    width: 100%;
    background: #252526;
    color: #e0e0e0;
    border: 1px solid #3c3c3c;
    border-radius: 3px;
    padding: 2px 4px;
    font-size: 0.68rem;
    font-family: inherit;
}

.effect-strip select:focus {
    outline: none;
    border-color: #007acc;
}

/* Filter frequency-response display (v3-18) */
.filter-response {
    display: block;
    width: 100%;
    height: 70px;
    background: #1e1e1e;
    border: 1px solid #3c3c3c;
    border-radius: 4px;
    margin-bottom: 10px;
}

/* Piano roll (v3-15) */
.piano-roll[hidden],
.sequence-notes[hidden] { display: none; }

.piano-roll {
    display: block;
    width: 100%;
    height: 200px;
    background: #1e1e1e;
    border: 1px solid #3c3c3c;
    border-radius: 4px;
    margin-bottom: 10px;
    cursor: crosshair;
    outline: none;
}

.piano-roll:focus {
    border-color: #007acc;
}

/* Sequence editor */
.sequence-notes {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 10px;
}

.sequence-note-row {
    display: flex;
    gap: 8px;
    align-items: end;
}

.sequence-note-row label {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 3px;
    font-size: 0.74rem;
    color: #cfcfcf;
    margin: 0;
}

.sequence-note-row input[type="number"],
.sequence-note-row input[type="text"] {
    width: 100%;
    background: #1e1e1e;
    color: #e0e0e0;
    border: 1px solid #3c3c3c;
    border-radius: 4px;
    padding: 4px 6px;
    font-size: 0.85rem;
    font-family: inherit;
    min-width: 0;
}

.sequence-note-row input[type="number"]:focus,
.sequence-note-row input[type="text"]:focus {
    outline: none;
    border-color: #007acc;
}

.sequence-delete {
    background: #1e1e1e;
    border: 1px solid #3c3c3c;
    border-radius: 4px;
    color: #888;
    padding: 0 10px;
    height: 27px;
    font-size: 1rem;
    cursor: pointer;
    font-family: inherit;
}

.sequence-delete:hover {
    background: #3a1e1e;
    border-color: #6e3030;
    color: #e07070;
}

.sequence-add-btn {
    width: auto;
    padding: 5px 12px;
}

.radio-options {
    display: flex;
    gap: 16px;
}

.radio-option {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
    color: #d4d4d4;
    cursor: pointer;
    margin: 0;
}

.radio-option input[type="radio"] {
    accent-color: #007acc;
    width: 14px;
    height: 14px;
    margin: 0;
}

/* Buttons */
.btn {
    background: #2d2d30;
    color: #e0e0e0;
    border: 1px solid #3c3c3c;
    border-radius: 4px;
    padding: 8px 16px;
    font-size: 0.9rem;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s;
}

.btn:hover {
    background: #37373d;
    border-color: #4a4a4a;
}

.btn:active {
    background: #1e1e1e;
}

.btn-primary {
    background: #007acc;
    border-color: #007acc;
    color: #ffffff;
    font-weight: 600;
    min-width: 120px;
}

.btn-primary:hover {
    background: #1a8ad6;
    border-color: #1a8ad6;
}

/* Preview panel */
.scope-row {
    margin-bottom: 10px;
}

.scope-label {
    display: block;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #888;
    margin-bottom: 4px;
}

.preview-scope {
    display: block;
    width: 100%;
    height: 100px;
    background: #1e1e1e;
    border: 1px solid #3c3c3c;
    border-radius: 4px;
}

.preview-controls {
    display: flex;
    gap: 16px;
    align-items: center;
}

.preview-actions {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-top: 12px;
}

.preview-radius-row {
    margin-top: 12px;
    margin-bottom: 0;
}

.loop-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: #cfcfcf;
    cursor: pointer;
}

.loop-toggle input[type="checkbox"] {
    accent-color: #007acc;
    width: 14px;
    height: 14px;
    margin: 0;
}

.loop-delay-inline {
    flex: 1;
    min-width: 140px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.loop-delay-inline[hidden] {
    display: none;
}

.loop-delay-inline label {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-size: 0.78rem;
    color: #cfcfcf;
    margin: 0;
}

.loop-delay-inline input[type="range"] {
    width: 100%;
    accent-color: #007acc;
    margin: 0;
}

/* Layer tabs */
.layer-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 10px;
    border-bottom: 1px solid #3c3c3c;
}

.layer-tab {
    flex: 1;
    background: transparent;
    border: 1px solid transparent;
    border-bottom: none;
    border-radius: 4px 4px 0 0;
    color: #999;
    font-size: 0.82rem;
    font-family: inherit;
    padding: 6px 10px;
    cursor: pointer;
    transition: background 0.12s, color 0.12s, border-color 0.12s;
    margin-bottom: -1px;
}

.layer-tab:hover {
    color: #d4d4d4;
    background: #2d2d30;
}

.layer-tab.active {
    background: #1e1e1e;
    color: #ffffff;
    border-color: #3c3c3c;
    border-bottom-color: #1e1e1e;
    font-weight: 600;
}

.layer-tab.layer-on::after {
    content: ' \25cf';
    color: #6a9955;
    font-size: 0.7em;
    vertical-align: super;
}

.layer-tab.dragging {
    opacity: 0.45;
}

.layer-tab.drop-left {
    border-left: 2px solid #007acc;
}

.layer-tab.drop-right {
    border-right: 2px solid #007acc;
}

.effect-strip.dragging {
    opacity: 0.5;
}

.effect-strip.drop-left {
    box-shadow: inset 3px 0 0 0 #007acc;
}

.effect-strip.drop-right {
    box-shadow: inset -3px 0 0 0 #007acc;
}

.effect-strip-header {
    cursor: grab;
}

.effect-strip-header:active {
    cursor: grabbing;
}

.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: #252526;
    color: #e0e0e0;
    border: 1px solid #007acc;
    border-radius: 4px;
    padding: 8px 14px;
    font-size: 0.85rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    z-index: 9999;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.18s ease-out;
}

.toast.toast-visible {
    opacity: 1;
}

.layer-tab-add {
    flex: 0 0 auto;
    background: transparent;
    border: 1px dashed #3c3c3c;
    border-bottom: none;
    border-radius: 4px 4px 0 0;
    color: #888;
    font-size: 0.82rem;
    font-family: inherit;
    padding: 6px 10px;
    cursor: pointer;
    transition: color 0.12s, border-color 0.12s;
    margin-bottom: -1px;
}

.layer-tab-add:hover {
    color: #d4d4d4;
    border-color: #4a4a4a;
}

.layer-tab-add:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.layer-remove-btn {
    width: 100%;
    margin-top: 4px;
    background: #1e1e1e;
    border-color: #4a3030;
    color: #c08080;
}

.layer-remove-btn:hover {
    background: #3a1e1e;
    border-color: #6e3030;
    color: #e07070;
}

.layer-enable-row {
    margin-top: 4px;
}

#layer-disabled-note {
    margin: 8px 0 0 0;
}

/* Preset search (v3-17) */
.preset-search {
    width: 100%;
    background: #1e1e1e;
    color: #e0e0e0;
    border: 1px solid #3c3c3c;
    border-radius: 4px;
    padding: 5px 8px;
    font-size: 0.82rem;
    font-family: inherit;
    margin-bottom: 8px;
}

.preset-search:focus {
    outline: none;
    border-color: #007acc;
}

.modal-hint {
    color: #888;
    font-weight: normal;
    font-size: 0.78rem;
}

/* Preset list */
.preset-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.preset-item {
    background: #1e1e1e;
    border: 1px solid #3c3c3c;
    border-radius: 4px;
    padding: 7px 10px;
    color: #d4d4d4;
    font-size: 0.85rem;
    font-family: inherit;
    text-align: left;
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.preset-item:hover {
    background: #2d2d30;
    border-color: #4a4a4a;
    color: #ffffff;
}

.preset-item:focus {
    outline: none;
    border-color: #007acc;
}

.preset-item.active {
    background: #094771;
    border-color: #007acc;
    color: #ffffff;
}

.preset-divider {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 14px 0 8px 0;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #888;
}

.preset-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #3c3c3c;
}

.user-preset-row {
    display: flex;
    gap: 4px;
    border-top: 2px solid transparent;
    border-bottom: 2px solid transparent;
    transition: opacity 0.1s;
}

.user-preset-row .preset-item {
    flex: 1;
}

.user-preset-row.dragging {
    opacity: 0.45;
}

.user-preset-row.drop-above {
    border-top-color: #007acc;
}

.user-preset-row.drop-below {
    border-bottom-color: #007acc;
}

.preset-delete {
    background: #1e1e1e;
    border: 1px solid #3c3c3c;
    border-radius: 4px;
    color: #888;
    padding: 0 10px;
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    font-family: inherit;
}

.preset-delete:hover {
    background: #3a1e1e;
    border-color: #6e3030;
    color: #e07070;
}

.preset-edit {
    background: #1e1e1e;
    border: 1px solid #3c3c3c;
    border-radius: 4px;
    color: #888;
    padding: 0 8px;
    font-size: 0.95rem;
    line-height: 1;
    cursor: pointer;
    font-family: inherit;
}

.preset-edit:hover {
    background: #1e2a3a;
    border-color: #305070;
    color: #80b0e0;
}

.preset-empty {
    margin: 0 0 10px 0;
    font-size: 0.78rem;
    color: #666;
    font-style: italic;
}

/* Inline delete-confirm row replaces a user-preset-row in place. */
.user-preset-row.confirming {
    background: #3a1e1e;
    border: 1px solid #6e3030;
    border-radius: 4px;
    padding: 4px 8px;
    align-items: center;
}

.confirm-text {
    flex: 1;
    color: #f0dada;
    font-size: 0.82rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.confirm-yes,
.confirm-no {
    border: 1px solid #3c3c3c;
    background: #1e1e1e;
    color: #d4d4d4;
    border-radius: 3px;
    padding: 3px 10px;
    font-size: 0.78rem;
    cursor: pointer;
    font-family: inherit;
}

.confirm-yes:hover {
    background: #5a2020;
    border-color: #8e3838;
    color: #ffe0e0;
}

.confirm-no:hover {
    background: #2d2d30;
    border-color: #4a4a4a;
}

.confirm-yes:focus-visible,
.confirm-no:focus-visible {
    outline: 1px solid #007acc;
    outline-offset: 2px;
}

/* Save preset modal. */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 100;
}

.modal-backdrop[hidden] {
    display: none;
}

.modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #252526;
    border: 1px solid #3c3c3c;
    border-radius: 6px;
    padding: 22px 24px;
    min-width: 340px;
    max-width: 90vw;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
    z-index: 101;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.modal[hidden] {
    display: none;
}

.modal-title {
    margin: 0 0 16px 0;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #007acc;
}

.modal-label {
    display: block;
    font-size: 0.82rem;
    color: #cfcfcf;
    margin-bottom: 6px;
}

.modal input[type="text"] {
    width: 100%;
    background: #1e1e1e;
    color: #e0e0e0;
    border: 1px solid #3c3c3c;
    border-radius: 4px;
    padding: 8px 10px;
    font-size: 0.9rem;
    font-family: inherit;
    margin-bottom: 18px;
}

.modal input[type="text"]:focus {
    outline: none;
    border-color: #007acc;
}

.modal-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.shortcuts-table {
    width: 100%;
    border-collapse: collapse;
    margin: 8px 0 14px 0;
    font-size: 0.85rem;
}

.shortcuts-table td {
    padding: 6px 8px;
    border-bottom: 1px solid #2d2d30;
    color: #cfcfcf;
}

.shortcuts-table td:first-child {
    width: 110px;
    white-space: nowrap;
}

.shortcuts-table kbd {
    display: inline-block;
    background: #1e1e1e;
    border: 1px solid #3c3c3c;
    border-radius: 3px;
    padding: 1px 6px;
    font-family: ui-monospace, Menlo, Consolas, monospace;
    font-size: 0.78rem;
    color: #e0e0e0;
    line-height: 1.4;
}

.btn-small {
    padding: 6px 10px;
    font-size: 0.82rem;
}

.preset-buttons {
    display: flex;
    gap: 6px;
    margin-top: 8px;
}

.ab-copy-btn {
    width: 100%;
    margin-top: 10px;
}

.preset-buttons .btn-small {
    flex: 1;
}

/* Code panel */
.code-output {
    background: #1e1e1e;
    border: 1px solid #3c3c3c;
    border-radius: 4px;
    padding: 12px 14px;
    font-family: 'Consolas', 'Menlo', monospace;
    font-size: 0.82rem;
    line-height: 1.45;
    color: #d4d4d4;
    overflow-x: auto;
    margin: 0 0 10px 0;
    max-height: 540px;
}

.code-output code {
    white-space: pre;
}

.code-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

.copy-feedback {
    color: #6a9955;
    font-size: 0.85rem;
    opacity: 0;
    transition: opacity 0.2s;
}

.copy-feedback.visible {
    opacity: 1;
}
