/* MIDI tab — port config + live mapping table (KL-71, extracted to
   features/ in KL-130). Shares .setting-row layout with Director AI. */
@layer features {

/* MIDI config tab — shares layout with Director AI */
.midi-config {
    background: var(--surface);
    border-radius: 0.5rem;
    padding: 1rem;
    margin-bottom: 1rem;
}

.midi-config > h2 {
    font-size: 1rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-dim);
    margin-bottom: 0.75rem;
}

.midi-config .setting-row {
    margin-bottom: 1rem;
}

.midi-config .toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8rem;
    color: var(--text);
    cursor: pointer;
}

.midi-config .toggle input[type="checkbox"] {
    accent-color: var(--accent);
    width: 1rem;
    height: 1rem;
}

/* KL-88: Settings tab toggles (Autoplay + Anonymous Usage) — mirror the
   panel-scoped .toggle styling that DMX / Govee / Director / MIDI tabs
   use. Without this rule the toggle label inherits body font-size and
   reads chunkier than the section name above it. */
.settings .toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8rem;
    color: var(--text);
    cursor: pointer;
}

.settings .toggle input[type="checkbox"] {
    accent-color: var(--accent);
    width: 1rem;
    height: 1rem;
}

/* ─── KL-71: live MIDI mapping table ──────────────────────────────
   Connection pill, recent-message ticker, and the action ↔ control
   mapping rows with per-row Learn / Clear buttons. Sits below the
   existing port-config block in the MIDI tab. Spec lives in KL-71;
   key UX rule is that Learn shows a pulsing "press a control" state
   so the user has unambiguous feedback that the listener is armed.
   ─────────────────────────────────────────────────────────────────── */
.midi-map {
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.midi-map-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.5rem;
}
.midi-map-head h3 {
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: var(--text);
    margin: 0;
}
.midi-map-help {
    color: var(--text-dim);
    font-size: 0.82rem;
    line-height: 1.55;
    margin: 0 0 1rem;
}

.midi-conn {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    font-family: var(--font-mono, monospace);
    font-size: 0.7rem;
    color: var(--text-dim);
}
.midi-conn-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(120, 120, 140, 0.6);
    box-shadow: none;
}
.midi-conn-dot[data-state="on"] {
    background: rgba(120, 220, 140, 0.95);
    box-shadow: 0 0 6px rgba(120, 220, 140, 0.5);
}

.midi-recent {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 0.75rem;
    background: rgba(255, 255, 255, 0.025);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    margin-bottom: 1rem;
    min-height: 2.1rem;
    overflow-x: auto;
}
.midi-recent-label {
    font-family: var(--font-mono, monospace);
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    color: rgba(200, 200, 220, 0.4);
    text-transform: uppercase;
    flex-shrink: 0;
}
.midi-recent-strip {
    display: flex;
    gap: 0.4rem;
    flex-wrap: nowrap;
    flex: 1;
    min-width: 0;
}
.midi-recent-empty {
    color: var(--text-muted, rgba(150, 150, 170, 0.5));
    font-size: 0.75rem;
    font-style: italic;
}
.midi-recent-msg {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.18rem 0.5rem;
    background: rgba(201, 70, 255, 0.12);
    border: 1px solid rgba(201, 70, 255, 0.25);
    border-radius: 4px;
    font-family: var(--font-mono, monospace);
    font-size: 0.7rem;
    color: var(--text);
    white-space: nowrap;
    flex-shrink: 0;
    animation: midi-msg-fade 0.3s ease-out;
}
@keyframes midi-msg-fade {
    from { background: rgba(201, 70, 255, 0.45); transform: scale(1.05); }
    to   { background: rgba(201, 70, 255, 0.12); transform: scale(1); }
}
.midi-recent-msg-kind {
    color: rgba(200, 200, 220, 0.55);
    font-weight: 700;
}

.midi-map-table {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 0.5rem 0.75rem;
    align-items: center;
}
.midi-map-row {
    display: contents;
}
.midi-map-row > * {
    padding: 0.55rem 0;
    border-top: 1px solid rgba(255, 255, 255, 0.04);
}
.midi-map-row:first-child > * {
    border-top: none;
}
.midi-map-action {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}
.midi-map-action-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
}
.midi-map-action-tip {
    font-size: 0.72rem;
    color: var(--text-muted, rgba(150, 150, 170, 0.55));
    line-height: 1.4;
}
.midi-map-binding {
    font-family: var(--font-mono, monospace);
    font-size: 0.78rem;
    color: var(--text-dim);
    min-width: 7rem;
    text-align: right;
}
.midi-map-binding[data-state="unset"] {
    color: var(--text-muted, rgba(150, 150, 170, 0.5));
    font-style: italic;
}
.midi-map-binding[data-state="armed"] {
    color: var(--accent);
    animation: midi-armed-pulse 1s ease-in-out infinite;
}
@keyframes midi-armed-pulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.45; }
}

.midi-map-actions {
    display: flex;
    gap: 0.4rem;
    justify-content: flex-end;
}
.midi-map-btn {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: var(--text-dim);
    padding: 0.35rem 0.7rem;
    border-radius: 4px;
    font-family: inherit;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.midi-map-btn:hover {
    color: var(--text);
    border-color: rgba(255, 255, 255, 0.25);
}
.midi-map-btn[data-armed="true"] {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
    animation: midi-armed-pulse 1s ease-in-out infinite;
}
.midi-map-btn-clear {
    color: var(--text-muted, rgba(150, 150, 170, 0.5));
    border-color: transparent;
    padding: 0.35rem 0.55rem;
}
.midi-map-btn-clear:hover {
    color: var(--red, #ff3d5a);
    border-color: rgba(255, 61, 90, 0.4);
}

.midi-map-footer {
    display: flex;
    justify-content: flex-end;
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid rgba(255, 255, 255, 0.04);
}

} /* end @layer features */
