/* BCR2000 Web Editor — Hardware & Component Styles
   Layout utilities are handled by Tailwind CDN.
   This file contains only hardware-specific visuals and
   stateful transitions that Tailwind can't easily express. */

:root {
    --log-h: 130px;
    --header-h: 38px;
    --bcr-bg: #0f1923;
    --bcr-text: #e8e8e8;
    --bcr-border: #2a3a4a;
    --bcr-panel: #162030;
    --bcr-editor: #141e2e;
    --bcr-body: #1e3050;
    --bcr-body-light: #2a4468;
    --bcr-body-dark: #152238;
    --bcr-strip: #c8ccd0;
    --enc-ring-bg: #1a1a1e;
    --enc-led: #ff2020;
    --enc-knob-center: #444;
    --enc-knob-edge: #1a1a1a;
    --btn-hw: #1e1e22;
    --btn-hw-border: #3a3a40;
    --btn-hw-hover: #2e2e36;
    --accent: #e94560;
    --accent-light: #ff6b81;
    --accent-rgb: 233, 69, 96;
    --text-secondary: #99a8b8;
    --text-muted: #5a6a7a;
    --midi-in: #2ed573;
    --midi-out: #f59e0b;

    /* ── Type scale ── */
    --fs-xs: 9px;
    /* tiny hardware annotations */
    --fs-sm: 11px;
    /* buttons, form labels, most UI chrome */
    --fs-base: 13px;
    /* titles, sidebar headers */
    --fs-lg: 15px;
    /* app name */
}

/* ═══════════ GLOBAL FORM DARK THEME ═══════════ */

input,
select,
textarea {
    background: var(--bcr-bg);
    color: var(--bcr-text);
    border: 1px solid var(--bcr-border);
    border-radius: 3px;
    padding: 4px 6px;
    font-family: 'Courier New', Courier, monospace !important;
    font-size: 12px !important;
    line-height: normal;
    vertical-align: middle;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--accent);
    outline: none;
}

input[type="checkbox"] {
    accent-color: var(--accent);
}

/* ═══════════ SWITCH TOGGLE ═══════════ */

.switch-toggle {
    display: inline-flex;
    cursor: pointer;
    position: relative;
    align-items: center;
    flex-shrink: 0;
}

/* Visually hide the native checkbox while keeping it accessible */
.switch-toggle input[type="checkbox"] {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    background: transparent;
    border: none;
    padding: 0;
}

.switch-track {
    display: inline-block;
    width: 34px;
    height: 18px;
    background: var(--bcr-border);
    border-radius: 9px;
    position: relative;
    transition: background .2s;
}

.switch-track::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 14px;
    height: 14px;
    background: var(--text-muted);
    border-radius: 50%;
    transition: transform .2s, background .2s;
}

.switch-toggle input:checked~.switch-track {
    background: var(--accent);
}

.switch-toggle input:checked~.switch-track::after {
    transform: translateX(16px);
    background: white;
}

/* Indeterminate = "keep as-is" in bulk editor — thumb sits in the middle */
.switch-toggle input:indeterminate~.switch-track {
    background: rgba(var(--accent-rgb), 0.3);
}

.switch-toggle input:indeterminate~.switch-track::after {
    transform: translateX(8px);
    background: var(--bcr-text);
}

/* ═══════════ TYPOGRAPHY UTILITIES ═══════════
   Three consolidated utility classes replace all scattered
   repetitions of the same pattern.
   ─────────────────────────────────────────────
   .type-label  — 10px / semibold / uppercase / muted
                  Use for: section headers, strip labels, UI chrome
   .type-field  — 11px / normal / secondary
                  Use for: form field labels, editor panel labels
   .type-caption— 9px / muted
                  Use for: tiny hardware annotations, hints
   ════════════════════════════════════════════ */

.type-label {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    text-transform: uppercase;
    line-height: 1;
}

.type-field {
    font-size: var(--fs-sm);
    color: var(--text-secondary);
    line-height: 1.3;
}

.type-caption {
    font-size: var(--fs-xs);
    color: var(--text-muted);
    line-height: 1.3;
}

/* ═══════════ EDITOR FORM UTILITIES ═══════════ */

.field-label {
    display: block;
    font-size: var(--fs-sm);
    color: var(--text-secondary);
    margin-bottom: 2px;
}

.field-group {
    margin-bottom: 9px;
}

.field-section {
    background: rgba(0, 0, 0, 0.15);
    border: 1px solid var(--bcr-border);
    border-radius: 6px;
    padding: 8px;
    margin-bottom: 9px;
}

.field-half {
    flex: 1;
    margin-bottom: 9px;
}

.field-pair {
    display: flex;
    gap: 6px;
}

.btn-close-x {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.125rem;
    line-height: 1.75rem;
    cursor: pointer;
    padding: 2px 6px;
}

.btn-close-x:hover {
    color: var(--bcr-text);
}

.toggle-label {
    font-size: var(--fs-sm);
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
}

/* Editor form input — full width with alignment (not Tailwind w-full) */
.input-field {
    width: 100%;
    height: 2em;
    padding-right: 8px;
    text-align: right;
    -moz-appearance: textfield;
}

.input-field::-webkit-outer-spin-button,
.input-field::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* ═══════════ BCR2000 FRAME ═══════════ */
.bcr2000 {
    background: linear-gradient(170deg, var(--bcr-body-light) 0%, var(--bcr-body) 30%, var(--bcr-body-dark) 100%);
    border: 2px solid #3a5070;
    border-radius: 14px;
    padding: 12px;
    max-width: 960px;
    min-width: 800px;
    width: 100%;
    box-shadow: 0 8px 32px rgba(0, 0, 0, .5), inset 0 1px 0 rgba(255, 255, 255, .06);
}

.device-body {
    display: flex;
    gap: 10px;
}

.main-area {
    flex: 1;
    min-width: 0;
}

/* Push encoder labels */
.push-encoder-labels {
    display: grid;
    grid-template-columns: repeat(8, minmax(0, 1fr));
    gap: 4px;
    margin-bottom: 2px;
}

.push-encoder-labels span {
    font-size: 7px;
    color: #7a8a9a;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: .5px;
}

/* ═══════════ ENCODER ROW ═══════════ */
.encoder-row {
    display: grid;
    grid-template-columns: repeat(8, minmax(0, 1fr));
    gap: 4px;
    margin-bottom: 4px;
}

.push-enc-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    justify-content: space-between;
    width: 100%;
    position: relative;
}

.push-enc-cell .element {
    flex: 1;
    justify-content: flex-start;
    padding-top: 2px;
    width: 100%;
}

/* ═══════════ DEDICATED ENCODER CELL ═══════════ */
.dedicated-enc-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    position: relative;
}

.dedicated-enc-cell .element {
    width: 100%;
}

/* ═══════════ BUTTON GRID ROW ═══════════ */
.button-grid-row {
    display: grid;
    grid-template-columns: repeat(8, minmax(0, 1fr));
    gap: 4px;
    margin-bottom: 3px;
}

.button-grid-row .hw-button {
    width: 100%;
    box-sizing: border-box;
}

/* ─── Button drag-and-drop ─── */
.hw-button[draggable="true"],
.hw-btn[draggable="true"] {
    cursor: grab;
}

.hw-button[draggable="true"]:active,
.hw-btn[draggable="true"]:active {
    cursor: grabbing;
}

.hw-button.drag-over,
.hw-btn.drag-over {
    outline: 2px dashed var(--accent);
    outline-offset: -2px;
    background: rgba(var(--accent-rgb), .1);
}

.hw-button.drag-insert-before::before,
.hw-btn.drag-insert-before::before,
.hw-button.drag-insert-after::after,
.hw-btn.drag-insert-after::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--accent);
    border-radius: 2px;
    z-index: 10;
    box-shadow: 0 0 8px rgba(var(--accent-rgb), .9);
}

.hw-button.drag-insert-before::before,
.hw-btn.drag-insert-before::before {
    left: -2px;
}

.hw-button.drag-insert-after::after,
.hw-btn.drag-insert-after::after {
    right: -2px;
}

.hw-button.dragging,
.hw-btn.dragging {
    opacity: 0.35;
}

/* ═══════════ STRIP DIVIDER ═══════════ */
.strip-divider {
    background: var(--bcr-strip);
    height: 16px;
    margin: 6px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 7px;
    font-weight: 700;
    color: #444;
    letter-spacing: 2px;
    text-transform: uppercase;
    border-radius: 2px;
}

/* ═══════════ ENCODER ELEMENT ═══════════ */
.element {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all .12s;
    border: 2px solid transparent;
    border-radius: 6px;
    padding: 2px;
    width: 100%;
    box-sizing: border-box;
}

.element:hover {
    border-color: rgba(var(--accent-rgb), .35);
    background: rgba(var(--accent-rgb), .04);
}

.element.selected {
    border-color: var(--accent);
    background: rgba(var(--accent-rgb), .1);
    box-shadow: 0 0 10px rgba(var(--accent-rgb), .2);
}

/* For encoder/fader cells: lift hover/select outline to the full cell so it
   encompasses the element + label */
.push-enc-cell:has(.element:hover),
.dedicated-enc-cell:has(.element:hover) {
    outline: 2px solid rgba(var(--accent-rgb), .1);
    outline-offset: -2px;
    background: rgba(var(--accent-rgb), .02);
    border-radius: 6px;
}

.push-enc-cell:has(.element:hover) .element:hover,
.dedicated-enc-cell:has(.element:hover) .element:hover {
    border-color: transparent;
    background: transparent;
}

.push-enc-cell:has(.element.selected),
.dedicated-enc-cell:has(.element.selected) {
    outline: 2px solid rgba(var(--accent-rgb), .4);
    outline-offset: -2px;
    background: rgba(var(--accent-rgb), .02);
    border-radius: 6px;
    box-shadow: 0 0 10px rgba(var(--accent-rgb), .2);
}

.push-enc-cell:has(.element.selected) .element.selected,
.dedicated-enc-cell:has(.element.selected) .element.selected {
    border-color: transparent;
    background: transparent;
    box-shadow: none;
}

.element.configured .element-label {
    color: var(--accent-light);
}

/* Drag-and-drop encoder swap */
.push-enc-cell[draggable="true"],
.dedicated-enc-cell[draggable="true"] {
    cursor: grab;
}

.push-enc-cell[draggable="true"]:active,
.dedicated-enc-cell[draggable="true"]:active {
    cursor: grabbing;
}

.push-enc-cell.drag-over,
.dedicated-enc-cell.drag-over {
    outline: 2px dashed var(--accent);
    outline-offset: -2px;
    background: rgba(var(--accent-rgb), .1);
    border-radius: 6px;
}

/* Insert-between indicator: vertical accent line on cell edge */
.push-enc-cell.drag-insert-before::before,
.dedicated-enc-cell.drag-insert-before::before,
.push-enc-cell.drag-insert-after::after,
.dedicated-enc-cell.drag-insert-after::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--accent);
    border-radius: 2px;
    z-index: 10;
    box-shadow: 0 0 8px rgba(var(--accent-rgb), .9);
}

.push-enc-cell.drag-insert-before::before,
.dedicated-enc-cell.drag-insert-before::before {
    left: -2px;
}

.push-enc-cell.drag-insert-after::after,
.dedicated-enc-cell.drag-insert-after::after {
    right: -2px;
}

.push-enc-cell.dragging,
.dedicated-enc-cell.dragging {
    opacity: 0.35;
}

/* Encoder ring */
.enc-ring {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    /* Two distinct rings: outer light grey (LED zone 51–90%) + inner dark (0–51%) + dark outer rim (90–100%) */
    background: radial-gradient(circle,
            #111111 0% 51%,
            #1b1b1b 51% 90%,
            #1a1a20 90% 100%);
    box-shadow: 0 0px 5px rgba(0, 0, 0, .4);
}

/* Inner dark ring inset — creates the recessed well the knob sits in */
.enc-ring::before {
    content: '';
    position: absolute;
    inset: 22%;
    border-radius: 50%;
    background: radial-gradient(circle, #0d0d0d 60%, #1a1a1e 100%);
    box-shadow: inset 0 2px 6px rgba(0, 0, 0, .9), 0 0 0 1px rgba(0, 0, 0, .5);
    z-index: 0;
}

.enc-ring svg.led-ring {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: visible;
}

.enc-ring svg.led-ring circle {
    fill: #4a2020;
}

.enc-ring svg.led-ring circle.lit {
    fill: var(--enc-led);
    filter: drop-shadow(0 0 2px var(--enc-led));
}

.enc-ring.small svg.led-ring circle {
    r: 4.5;
}

.enc-ring.large svg.led-ring circle {
    r: 5;
}

.enc-knob {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, var(--enc-knob-center), var(--enc-knob-edge));
    box-shadow: 0 1px 5px rgba(0, 0, 0, .6);
    position: relative;
    z-index: 1;
    transition: transform 0.05s ease-out;
    cursor: grab;
    user-select: none;
}

.enc-knob::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 50%;
    width: 2px;
    height: 8px;
    transform: translateX(-50%);
    background: #999;
    border-radius: 1px;
}

.element-label {
    font-size: 9px;
    text-align: center;
    color: var(--text-secondary);
    line-height: 1.2;
    max-width: 72px;
    overflow: hidden;
    margin-top: 1px;
    word-break: break-all;
}

/* Colored label box under encoders */
.enc-label-box {
    width: 100%;
    min-height: 14px;
    padding: 2px 3px;
    margin-top: 5px;
    border-radius: 2px;
    font-size: 8px;
    font-weight: 600;
    text-align: center;
    color: #111;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    box-sizing: border-box;
}

#midi-input,
#midi-output,
#device-id,
#edit-type {
    height: 2em;
}

/* ═══════════ COLOR PICKER ═══════════ */
.color-picker-row {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.color-swatch {
    width: 18px;
    height: 18px;
    border-radius: 3px;
    border: 2px solid transparent;
    cursor: pointer;
    transition: border-color .1s, transform .1s;
}

.color-swatch:hover {
    transform: scale(1.15);
}

.color-swatch.active {
    border-color: #fff;
    box-shadow: 0 0 4px rgba(255, 255, 255, 0.4);
}

.color-swatch.no-color {
    background: #2a3a4a;
    position: relative;
}

.color-swatch.no-color::after {
    content: '✕';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    color: #5a6a7a;
}

/* ═══════════ LABEL COLOR OVERRIDES ═══════════ */
.push-button-cell.has-label-color .element-label,
.hw-button.has-label-color .element-label,
.hw-btn.has-label-color .element-label {
    color: #fff;
}

/* ═══════════ HARDWARE BUTTONS ═══════════ */
.hw-button,
.hw-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    background: var(--btn-hw);
    border: 1px solid var(--btn-hw-border);
    color: var(--text-muted);
    font-size: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all .12s;
    text-transform: uppercase;
    letter-spacing: .3px;
}

.hw-button.has-label-color,
.hw-btn.has-label-color {
    background: color-mix(in srgb, var(--label-color) 45%, #000);
}

.hw-button {
    height: 26px;
}

.hw-btn {
    height: 28px;
}

.hw-button:hover,
.hw-btn:hover {
    background: var(--btn-hw-hover);
    border-color: #555;
    color: var(--bcr-text);
}

.hw-button.has-label-color:hover,
.hw-btn.has-label-color:hover {
    background: color-mix(in srgb, var(--label-color) 65%, #000);
}

.hw-button.selected,
.hw-btn.selected {
    border-color: var(--accent);
    box-shadow: 0 0 6px rgba(var(--accent-rgb), .3);
}

.hw-button.pressed,
.hw-btn.pressed {
    background: #ffd166;
    color: #000;
    box-shadow: 0 0 8px rgba(255, 209, 102, .5);
}

.hw-btn.bc-function-active {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 0 8px rgba(230, 57, 70, .6);
}

.hw-button.has-label-color.pressed,
.hw-btn.has-label-color.pressed {
    background: var(--label-color);
}

.hw-button .element-label {
    margin: 0;
}

.hw-button.configured .element-label,
.hw-btn.configured {
    color: #fff;
}

/* Push button (tiny, under push encoder) */
.push-button-cell {
    width: 100%;
    height: 16px;
    background: var(--btn-hw);
    border: 1px solid var(--btn-hw-border);
    box-sizing: border-box;
    border-radius: 2px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .1s;
}

.push-button-cell.has-label-color {
    background: color-mix(in srgb, var(--label-color) 55%, #000);
}

.push-button-cell:hover {
    background: var(--btn-hw-hover);
}

.push-button-cell.selected {
    border-color: var(--accent);
}

.push-button-cell.pressed {
    background: #ffd166;
}

.push-button-cell.has-label-color.pressed {
    background: var(--label-color);
}

.push-button-cell .element-label {
    font-size: 7px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .3px;
    margin: 0;
    color: var(--text-muted);
}

.push-button-cell.configured .element-label {
    color: #fff;
}

/* ═══════════ SIDE PANEL ═══════════ */
.side-panel {
    width: 150px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding-top: 17px;
}

/* LED Display */
.led-display {
    background: #0a0a0a;
    border: 2px solid #333;
    border-radius: 4px;
    padding: 8px 4px;
    text-align: center;
    width: 100%;
}

.led-text {
    font-family: 'Courier New', monospace;
    font-size: 30px;
    font-weight: bold;
    color: #ff3030;
    text-shadow: 0 0 10px rgba(255, 48, 48, .6);
    letter-spacing: 3px;
}

.led-info {
    font-family: 'Courier New', monospace;
    font-size: 10px;
    font-weight: bold;
    color: #ff3030;
    text-shadow: 0 0 6px rgba(255, 48, 48, .4);
    letter-spacing: 1px;
    margin-top: 2px;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.led-value {
    font-family: 'Courier New', monospace;
    font-size: 10px;
    font-weight: bold;
    color: #ff3030;
    text-shadow: 0 0 8px rgba(255, 48, 48, .5);
    letter-spacing: 2px;
    margin-top: 4px;
    min-height: 18px;
}

.panel-label {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-top: 4px;
    text-align: center;
    width: 100%;
}

/* 2x2 grid for side panel groups */
.side-grid-2x2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    width: 100%;
}

.group-btn.active {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 0 6px rgba(var(--accent-rgb), .3);
}

/* Status LEDs */
.status-leds {
    display: flex;
    gap: 7px;
    justify-content: center;
    margin-top: 2px;
}

.led-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
}

.led-col span:last-child {
    font-size: 6px;
    color: var(--text-muted);
    text-align: center;
}

.led-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: none;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, .6), inset 0 1px 2px rgba(0, 0, 0, .5);
    transition: background 80ms, box-shadow 80ms;
}

/* red LEDs: A, B */
.led-dot.red {
    background: radial-gradient(circle at 50% 60%, #3a0808, #1a0303);
}

.led-dot.red.active {
    background: radial-gradient(circle at 50% 60%, #ff4040, #cc1010);
    box-shadow: inset 0 2px 3px rgba(0, 0, 0, .3), 0 0 6px #ff2020;
}

/* yellow LEDs: SW1, SW2 */
.led-dot.yellow {
    background: radial-gradient(circle at 50% 60%, #3a2e04, #181202);
}

.led-dot.yellow.active {
    background: radial-gradient(circle at 50% 60%, #ffe040, #c89000);
    box-shadow: inset 0 2px 3px rgba(0, 0, 0, .3), 0 0 6px #d4a800;
}

/* green LEDs: IN, MODE */
.led-dot.green {
    background: radial-gradient(circle at 50% 60%, #0a2a0a, #030d03);
}

.led-dot.green.active {
    background: radial-gradient(circle at 50% 60%, #60ff80, #10c030);
    box-shadow: inset 0 2px 3px rgba(0, 0, 0, .3), 0 0 6px #2ed573;
}

/* Branding */
.branding {
    text-align: center;
    margin: 6px 0;
    user-select: none;
}

.brand-line {
    font-size: 10px;
    letter-spacing: 3px;
    color: #8899aa;
    font-weight: 700;
}

.brand-sub {
    font-size: 8px;
    color: var(--accent);
    letter-spacing: 2px;
    font-weight: 600;
}

.brand-model {
    font-size: 11px;
    letter-spacing: 2px;
    color: #8899aa;
    font-weight: 700;
    margin-top: 2px;
}

/* Preset nav */
.preset-nav-hw {
    display: flex;
    align-items: center;
    gap: 4px;
    width: 100%;
    justify-content: center;
    margin-top: 2px;
}

.preset-label {
    font-size: 7px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.preset-hw-btn {
    width: 34px;
}

/* ═══════════ EDITOR PANEL TRANSITION ═══════════ */
.main-layout {
    height: calc(100vh - var(--header-h) - var(--log-h));
}

.editor-panel {
    width: 0;
    background: var(--bcr-editor);
    border-left: 1px solid var(--bcr-border);
    overflow-y: auto;
    transition: width .2s;
    flex-shrink: 0;
    position: relative;
}

.editor-panel.open {
    width: var(--editor-w, 240px);
}

/* Element editor: always visible as 24px strip when collapsed */
#element-editor {
    width: 24px;
    min-width: 24px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

#element-editor.open {
    width: var(--editor-w, 240px);
    min-width: unset;
    overflow-y: auto;
}

/* Hide content and resize handle when not open */
#element-editor:not(.open) .editor-panel-content,
#element-editor:not(.open) .sidebar-resize-handle {
    display: none;
}

/* When bulk editor is open, hide element-editor entirely */
#element-editor.bulk-active {
    width: 0;
    min-width: 0;
}

/* Editor strip — mirror of banks-strip */
.editor-strip {
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding-top: 10px;
    flex: 1;
    user-select: none;
    cursor: pointer;
}

.editor-strip:hover {
    background: rgba(var(--accent-rgb), 0.08);
}

.editor-strip-label {
    writing-mode: vertical-rl;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    text-transform: uppercase;
}

#element-editor:not(.open):not(.bulk-active) .editor-strip {
    display: flex;
}

/* Don't show resize handles on collapsed sidebar */
.banks-sidebar.collapsed .sidebar-resize-handle {
    display: none;
}

/* Sidebar resize handles */
.sidebar-resize-handle {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 5px;
    cursor: ew-resize;
    z-index: 10;
    background: transparent;
    transition: background .15s;
}

.sidebar-resize-handle:hover,
.sidebar-resize-handle.dragging {
    background: rgba(var(--accent-rgb), 0.4);
}

.banks-sidebar {
    position: relative;
}

.banks-sidebar .sidebar-resize-handle {
    right: -3px;
}

.editor-panel .sidebar-resize-handle {
    left: -3px;
}

/* ═══════════ LOG PANEL TRANSITION ═══════════ */
.log-panel {
    height: 130px;
    transition: height .2s;
}

.log-panel.resizing {
    transition: none;
}

.log-panel.collapsed {
    height: 24px;
}

.log-resize-handle {
    height: 5px;
    cursor: ns-resize;
    flex-shrink: 0;
    background: transparent;
    transition: background .15s;
}

.log-resize-handle:hover,
.log-resize-handle.dragging {
    background: rgba(var(--accent-rgb), 0.4);
}

.log-panel.collapsed .log-resize-handle {
    display: none;
}

/* Log / MIDI Monitor tabs */
.log-tab {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    cursor: pointer;
    padding: 2px 8px;
    border-radius: 3px;
    transition: all .1s;
}

.log-tab:hover {
    color: #e8e8e8;
}

.log-tab.active {
    background: rgba(var(--accent-rgb), .15);
    color: var(--accent-light);
    font-weight: 600;
}

.log-header-btn {
    background: transparent;
    border: 1px solid var(--bcr-border);
    color: var(--text-muted);
    font-size: 13px;
    line-height: 1;
    width: 22px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 3px;
    cursor: pointer;
    transition: all .15s;
}

.log-header-btn:hover {
    color: var(--bcr-text);
    border-color: var(--bcr-text);
}

/* MIDI connection LED */
.midi-led {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #5a6a7a;
    transition: background .15s, box-shadow .15s;
}

.midi-led.connected {
    background: #2ed573;
    box-shadow: 0 0 6px rgba(46, 213, 115, .6);
}

.midi-led.active {
    background: #fff;
    box-shadow: 0 0 8px rgba(255, 255, 255, .8);
}

/* ═══════════ UI BUTTONS ═══════════ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 24px;
    text-transform: uppercase;
    padding: 0 10px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all .1s;
    white-space: nowrap;
}

.btn:hover {
    filter: brightness(1.2);
    box-shadow: 0 0 0 1px rgba(255, 255, 255, .08);
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: #e94560;
    color: #fff;
}

.btn-primary:hover {
    background: #ff5a75;
}

.btn-outline-primary {
    background: transparent;
    color: #fff;
    border: 1.5px solid #e94560 !important;
    box-shadow: 0 0 6px rgba(233, 69, 96, .3);
}

.btn-outline-primary:hover {
    background: rgba(233, 69, 96, .12);
    box-shadow: 0 0 10px rgba(233, 69, 96, .5);
}

.btn-default {
    background: #2a3a4a;
    color: #e8e8e8;
}

.btn-default:hover {
    background: #374a5e;
}

.btn-success {
    background: #2ed573;
    color: #111;
}

.btn-disabled,
.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn:disabled:hover {
    filter: brightness(1);
}

.btn:disabled:active {
    transform: scale(1);
}

/* ═══════════ BANKS SIDEBAR ═══════════ */

.banks-sidebar {
    width: 220px;
    min-width: 220px;
    background: var(--bcr-panel);
    border-right: 1px solid var(--bcr-border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow: hidden;
    transition: width .2s, min-width .2s;
}

.banks-sidebar.collapsed {
    width: 24px;
    min-width: 24px;
    cursor: pointer;
}

/* Strip shown when collapsed */
.banks-strip {
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding-top: 10px;
    flex: 1;
    user-select: none;
}

.banks-strip:hover {
    background: rgba(var(--accent-rgb), 0.08);
}

/* banks-strip-label and editor-strip-label both extend .type-label + vertical writing */
.banks-strip-label,
.editor-strip-label {
    writing-mode: vertical-rl;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    text-transform: uppercase;
}

.banks-strip-label {
    transform: rotate(180deg);
}

/* Fixed UI label typography — consolidated into .type-label; .ui-label kept as alias */
.ui-label {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    text-transform: uppercase;
    line-height: 1;
}

.banks-sidebar.collapsed .banks-strip {
    display: flex;
}

.banks-sidebar.collapsed .banks-sidebar-header,
.banks-sidebar.collapsed .banks-sidebar-content {
    display: none;
}

.banks-sidebar-header {
    padding: 0.75em 0.75em;
    border-bottom: 1px solid var(--bcr-border);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
}

.banks-sidebar-title {
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.banks-title-count {
    background: var(--bcr-border);
    color: var(--text-secondary);
    font-size: 10px;
    font-weight: 500;
    border-radius: 8px;
    padding: 0 5px;
    min-width: 16px;
    text-align: center;
}

.btn-sm {
    height: 20px;
    padding: 0 6px;
    font-size: var(--fs-sm);
    line-height: 1;
}

.banks-sidebar-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Individual bank */
.bank-item {
    border-bottom: 1px solid rgba(42, 58, 74, 0.5);
}

.bank-item-header {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 6px 8px;
    cursor: pointer;
    transition: background .1s;
    user-select: none;
}

.bank-item-header:hover {
    background: rgba(255, 255, 255, .03);
}

.bank-item-header.active {
    background: rgba(var(--accent-rgb), .08);
}

.bank-item-chevron {
    font-size: 8px;
    color: var(--text-muted);
    flex-shrink: 0;
    transition: transform .15s;
    display: inline-block;
}

.bank-item-chevron.open {
    transform: rotate(90deg);
}

.bank-item-name {
    font-size: 12px;
    font-weight: 500;
    color: var(--accent);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
    cursor: text;
}

.bank-item-name:hover {
    text-decoration: underline;
    text-decoration-style: dotted;
}

.inline-editing {
    border-bottom: 1px solid var(--accent);
    outline: none;
    cursor: text;
    min-width: 20px;
}

.bank-item-count {
    font-size: 9px;
    color: var(--text-muted);
    flex-shrink: 0;
    white-space: nowrap;
}

/* Small icon buttons for bank/slot actions */
.bank-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 2px;
    font-size: 10px;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    flex-shrink: 0;
    padding: 0;
    transition: color .1s, background .1s;
    opacity: 0;
}

.bank-item-header:hover .bank-icon-btn,
.bank-slot:hover .bank-icon-btn {
    opacity: 1;
}

.bank-icon-btn:hover {
    color: var(--bcr-text);
    background: rgba(255, 255, 255, .08);
}

.bank-icon-btn.bank-icon-delete:hover {
    color: #ff4757;
    background: rgba(255, 71, 87, .1);
}

.bank-icon-btn.bank-icon-recv:hover {
    color: #2ed573;
    background: rgba(46, 213, 115, .1);
}

.bank-icon-btn.bank-icon-send:hover {
    color: #ffa502;
    background: rgba(255, 165, 2, .1);
}

.bank-icon-btn.bank-icon-save:hover {
    color: #2ed573;
    background: rgba(46, 213, 115, .1);
}

.bank-item-header.has-active-preset {
    background: rgba(var(--accent-rgb), .08);
}

/* Bank slot list */
.bank-slots {
    background: rgba(0, 0, 0, .15);
}

.bank-slot {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 2px 6px 2px 14px;
    cursor: pointer;
    transition: background .1s;
    border-bottom: 1px solid rgba(42, 58, 74, .2);
    min-height: 22px;
}

.bank-slot:hover {
    background: rgba(255, 255, 255, .04);
}

.bank-slot.loaded {
    background: rgba(var(--accent-rgb), .07);
}

.bank-slot-num {
    font-size: 9px;
    color: var(--text-muted);
    min-width: 16px;
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
}

.bank-slot-name {
    flex: 1;
    font-size: 11px;
    color: var(--bcr-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.bank-slot-name:not(.empty) {
    cursor: text;
}

.bank-slot-name:not(.empty):hover {
    text-decoration: underline;
    text-decoration-style: dotted;
}

.bank-slot-name.empty {
    color: #3a4a5a;
    font-style: italic;
    font-size: 10px;
}

.empty-slot {
    opacity: 0.6;
    transition: opacity .1s;
}

.empty-slot:hover {
    opacity: 1;
    background: rgba(var(--accent-rgb), .04);
}

.bank-slot-check {
    font-size: 10px;
    color: #3a4a5a;
    flex-shrink: 0;
    cursor: pointer;
    transition: color .1s;
}

.bank-slot.loaded .bank-slot-check {
    color: #ff4757;
}

.bank-slot:not(.loaded):not(.empty-slot):hover .bank-slot-check,
.empty-slot:hover .bank-slot-check {
    color: var(--text-muted);
}

/* ═══════════ TOPBAR BRAND + DEVICE TOGGLE ═══════════ */
.topbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    white-space: nowrap;
    flex-shrink: 0;
}

.topbar-appname {
    font-size: var(--fs-lg);
    font-weight: 700;
    color: var(--accent);
    letter-spacing: .3px;
}

/* Segmented pill control — floating-pill style */
.device-toggle {
    display: flex;
    background: var(--bcr-bg);
    border: 1px solid var(--bcr-border);
    border-radius: 6px;
    padding: 3px;
    gap: 2px;
}

.device-toggle-btn {
    padding: 3px 12px;
    font-size: var(--fs-sm);
    font-weight: 600;
    letter-spacing: .3px;
    border-radius: 3px;
    border: none;
    cursor: pointer;
    background: transparent;
    color: var(--text-muted);
    transition: background .18s, color .18s, box-shadow .18s;
}

.device-toggle-btn:hover {
    color: var(--text-secondary);
}

.device-toggle-btn.active {
    background: var(--bcr-panel);
    color: var(--bcr-text);
    box-shadow: 0 1px 3px rgba(0, 0, 0, .45), inset 0 0 0 1px rgba(255, 255, 255, .06);
}

/* ═══════════ BCF2000 FADERS ═══════════ */

.fader-element {
    justify-content: center;
    padding: 4px 0;
}

/* Vertical separator lines between fader cells and on outer edges */
.fader-row .dedicated-enc-cell::before {
    content: '';
    position: absolute;
    left: -3px;
    /* centred within the 4px grid gap */
    top: 0;
    width: 2px;
    height: calc(100% - 19px);
    /* stop at bottom of .fader-number, above .enc-label-box */
    background: rgba(200, 204, 208, 0.7);
    z-index: 1;
}

.fader-row .dedicated-enc-cell:first-child::before {
    left: 0;
    /* outer left edge of fader 1 */
}

.fader-row .dedicated-enc-cell:last-child::after {
    content: '';
    position: absolute;
    right: 0;
    /* outer right edge of fader 8 */
    top: 0;
    width: 2px;
    height: calc(100% - 19px);
    background: rgba(200, 204, 208, 0.7);
    z-index: 1;
}

/* Outer fader channel wrapper — positions tick SVG + groove + annotations */
.fader-channel {
    position: relative;
    width: 60px;
    height: 230px;
}

/* The SVG tick layer covers the full channel area */
.fader-ticks {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    overflow: visible;
}

.fader-ticks line {
    stroke: rgba(255, 255, 255, .5);
}

/* SVG text annotations (+, −, ▲, ▼) */
.fader-ticks .fader-ann {
    fill: rgba(255, 255, 255, .5);
    font-size: 7px;
    font-family: sans-serif;
    dominant-baseline: middle;
}

/* Central groove */
.fader-groove {
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    transform: translateX(-50%);
    width: 8px;
    background: #0d0d12;
    border-radius: 4px;
    border-left: 1px solid #111;
    border-right: 1px solid #333;
    box-shadow: inset 0 0 4px rgba(0, 0, 0, .9);
    z-index: 1;
}

.fader-fill {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(var(--accent-rgb), .6), rgba(var(--accent-rgb), .15));
    border-radius: 0 0 2px 2px;
    transition: height .05s ease-out;
    z-index: 2;
}

/* Fader knob — capsule shape matching encoder dark palette */
.fader-thumb {
    position: absolute;
    left: 50%;
    transform: translate(-50%, 50%);
    width: 34px;
    height: 62px;
    border-radius: 15px;
    cursor: grab;
    transition: bottom .05s ease-out;
    z-index: 3;
    /* Dark outer shell matching encoder ring tones */
    background: linear-gradient(180deg,
            #2a2a2e 0%, #1e1e22 12%,
            #1a1a1e 50%,
            #1e1e22 88%, #2a2a2e 100%);
    border: 1px solid #222222;
    box-shadow:
        0px 3px rgba(0, 0, 0, .08),
        inset 0 5px 0 rgba(255, 255, 255, .03),
        inset 0 -5px 0 rgba(0, 0, 0, .3)
}

/* Dark ridged inner surface */
.fader-thumb::before {
    content: '';
    position: absolute;
    top: 8px;
    left: 5px;
    right: 5px;
    bottom: 8px;
    border-radius: 6px;
    background:
        repeating-linear-gradient(180deg,
            #2e2e32 0px, #222226 2px,
            #1a1a1e 2px, #222226 4px);
    box-shadow: inset 0 1px 4px rgba(0, 0, 0, .7);
}

/* Bright center line on the ridged area */
.fader-thumb::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 7px;
    right: 7px;
    height: 2px;
    background: #ccc;
    transform: translateY(-50%);
    border-radius: 1px;
    box-shadow: 0 1px 0 rgba(0, 0, 0, .4);
    z-index: 1;
}

.fader-number {
    font-size: 8px;
    font-weight: 600;
    color: #fff;
    /*color: var(--text-muted);*/
    text-transform: uppercase;
    letter-spacing: .3px;
    width: 100%;
    text-align: left;
    padding-left: 12px;
    margin-top: 3px;
    box-sizing: border-box;
}

/* ═══════════ RESPONSIVE ═══════════ */
@media (max-width: 800px) {
    .device-body {
        flex-direction: column;
    }

    .side-panel {
        width: 100%;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px;
    }

    .side-panel>* {
        flex-shrink: 0;
    }

    .side-grid-2x2 {
        width: auto;
        min-width: 120px;
    }

    .led-display {
        width: auto;
        min-width: 100px;
    }

    .enc-ring {
        width: 50px;
        height: 50px;
    }

    .enc-knob {
        width: 26px;
        height: 26px;
    }

    .enc-knob::after {
        height: 6px;
    }
}

/* ═══════════ MODAL ═══════════ */

.app-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.app-modal-box {
    background: var(--bcr-bg);
    border: 1px solid var(--bcr-border);
    border-radius: 6px;
    padding: 20px 24px;
    min-width: 280px;
    max-width: 400px;
    font-family: 'Courier New', Courier, monospace;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.7);
}

.app-modal-msg {
    margin: 0 0 14px;
    font-size: 12px;
    line-height: 1.6;
    color: #c0d0e0;
}

.app-modal-input {
    display: block;
    width: 100%;
    margin-bottom: 14px;
    box-sizing: border-box;
}

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

/* ═══════════ SCROLLBAR ═══════════ */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bcr-bg);
}

::-webkit-scrollbar-thumb {
    background: var(--bcr-border);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #445;
}

/* ─── MIDI Monitor Filter Panel ─────────────────────────────────── */
.monitor-filter-panel {
    position: absolute;
    bottom: calc(100% + 6px);
    right: 0;
    z-index: 200;
    background: #162030;
    border: 1px solid #2a3a4a;
    border-radius: 6px;
    padding: 12px 14px;
    box-shadow: 0 -6px 20px rgba(0, 0, 0, .5);
    font-size: 11px;
    white-space: nowrap;
}

.mf-col {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.mf-divider {
    margin: 5px 0;
    border-top: 1px solid #2a3a4a;
}

.mf-row {
    display: flex;
    align-items: center;
    gap: 5px;
    color: #e8e8e8;
    cursor: pointer;
    user-select: none;
    line-height: 1.4;
}

.mf-parent {
    font-weight: 600;
}

.mf-child {
    padding-left: 14px;
    color: #99a8b8;
}

.monitor-filter-panel input[type="radio"] {
    accent-color: #e94560;
    width: 12px;
    height: 12px;
    cursor: pointer;
    flex-shrink: 0;
    margin: 0;
}

/* Toggle switch */
.mf-toggle-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
}

.mf-toggle {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.mf-toggle-track {
    width: 26px;
    height: 14px;
    border-radius: 7px;
    background: #3a4a5a;
    display: flex;
    align-items: center;
    padding: 2px;
    transition: background .15s;
    cursor: pointer;
}

.mf-toggle:checked+.mf-toggle-track {
    background: #e94560;
}

.mf-toggle-thumb {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #fff;
    transition: transform .15s;
}

.mf-toggle:checked+.mf-toggle-track .mf-toggle-thumb {
    transform: translateX(12px);
}

.mf-num-input {
    width: 36px;
    background: #0f1923;
    border: 1px solid #2a3a4a;
    border-radius: 3px;
    padding: 1px 4px;
    color: #e8e8e8;
    font-size: 11px;
    text-align: center;
    -moz-appearance: textfield;
}

.mf-num-input::-webkit-outer-spin-button,
.mf-num-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

#btn-monitor-filter.active {
    color: #e94560;
    border-color: #e94560;
}

/* Apply MIDI icon in monitor rows */
.monitor-apply-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 16px;
    height: 16px;
    cursor: pointer;
    border-radius: 3px;
    transition: opacity .15s, background .15s;
}

.monitor-apply-btn svg {
    stroke: #e94560 !important;
}

.monitor-apply-btn:hover {
    background: rgba(233, 69, 96, 0.15);
}

.monitor-apply-btn.muted {
    opacity: 0.6;
    cursor: default;
    pointer-events: none;
}

/* ─── MIDI monitor column grid ─── */

/* Global IN / OUT color utility classes */
.midi-in {
    color: var(--midi-in);
}

.midi-out {
    color: var(--midi-out);
}

#midi-monitor-messages {
    display: grid;
    grid-template-columns: 20px repeat(8, max-content);
    min-width: max-content;
}

.monitor-hcell {
    position: sticky;
    top: 0;
    background: var(--bcr-panel);
    border-bottom: 1px solid var(--bcr-border);
    padding: 2px 8px;
    white-space: nowrap;
    z-index: 1;
}

.monitor-row {
    display: contents;
}

.monitor-col {
    padding: 1px 1px 1px 8px;
    white-space: nowrap;
}