/* =============================================
   VOICE STACK V2 — Mini-DAW + Pitch Editor
   Glass theme: surface-2/3/4 + edge-soft/medium + color-primary.
   ============================================= */

/* ===== Body class scoping VS2 page =====
   Mobile nav oculto. Topbar back arrow ya manejado por BACK_ROUTES app.js. */
body.vs2-mode .mobile-nav {
    display: none;
}
/* VS2: ocultar particles + blob drift de fondo (modo distraction-free). */
body.vs2-mode::before {
    display: none;
    animation: none;
}
body.vs2-mode .bg-particles {
    display: none;
}
body.vs2-mode .main {
    padding: 0;
}
/* Sin padding-bottom de mobile-nav (ya oculto) → elimina espacio fantasma
   que causaba scroll falso. Scroll real lo maneja .vs2-track-list cuando
   tiene muchas pistas. */
body.vs2-mode .app-content {
    padding-bottom: 0;
}
/* Desktop: margen lateral leve para que no quede tan pegado a los bordes. */
@media (min-width: 821px) {
    body.vs2-mode .main {
        padding: 0 var(--space-5, 20px);
    }
}

/* ===== Page wrapper ===== */
.vs2-page {
    position: relative;
    display: flex;
    flex-direction: column;
    height: calc(100vh - var(--header-height, 56px));
    height: calc(100dvh - var(--header-height, 56px));
    background: transparent;
    isolation: isolate;
    overflow: hidden;
    padding: 0;
    /* Mobile UX: no callout iOS, no tap highlight, no select. */
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    user-select: none;
}
.vs2-page * {
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}
/* Excepciones: inputs editables sí permiten selección de texto. */
.vs2-page input,
.vs2-page textarea,
.vs2-side-input {
    -webkit-user-select: text;
    user-select: text;
}

/* ===== Topbar ===== */
.vs2-topbar {
    display: flex;
    align-items: center;
    gap: var(--space-1, 4px);
    padding: var(--space-2, 8px) var(--space-3, 12px);
    background: var(--surface-3);
    backdrop-filter: blur(16px) saturate(120%);
    -webkit-backdrop-filter: blur(16px) saturate(120%);
    border-bottom: 1px solid var(--edge-soft);
    flex-shrink: 0;
    z-index: 5;
}
[data-theme="light"] .vs2-topbar {
    background: var(--bg-card);
    border-bottom-color: var(--border-color);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
}

.vs2-tb-spacer {
    flex: 1;
    min-width: 0;
}

.vs2-tb-btn {
    width: 36px;
    height: 36px;
    border: 1px solid var(--edge-soft);
    background: var(--surface-3);
    color: var(--text-primary);
    border-radius: var(--border-radius-md, 10px);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
    font-size: 13px;
    padding: 0;
}

.vs2-tb-btn:hover {
    background: color-mix(in srgb, var(--color-primary) 15%, var(--surface-3));
    border-color: var(--color-primary);
}

.vs2-tb-btn.vs2-tb-play {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: white;
}
.vs2-tb-btn.vs2-tb-play:hover {
    background: var(--color-primary-hover, var(--color-primary));
}

.vs2-tb-btn.vs2-tb-rec {
    background: var(--surface-3);
    color: #ef4444;
    border-color: var(--edge-soft);
}
.vs2-tb-btn.vs2-tb-rec.vs2-rec-active {
    background: #ef4444;
    border-color: #ef4444;
    color: white;
    animation: vs2-rec-pulse 1.2s ease-in-out infinite;
}

@keyframes vs2-rec-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.6); }
    50% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
}

.vs2-tb-btn.vs2-tb-snap[data-active="true"] {
    background: color-mix(in srgb, var(--color-primary) 25%, var(--surface-3));
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.vs2-tb-transport {
    display: flex;
    gap: var(--space-1, 4px);
}

/* Metronome inline en topbar (desktop). Oculto en mobile (usa modal). */
.vs2-tb-metronome {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: 16px;
    padding-left: 16px;
    border-left: 1px solid var(--edge-soft);
}
.vs2-tb-metro-bpm {
    width: 56px;
    height: 36px;
    border: 1px solid var(--edge-soft);
    background: var(--surface-3);
    color: var(--text-primary);
    border-radius: var(--border-radius-md, 10px);
    text-align: center;
    font-size: 13px;
    font-family: 'Fira Code', 'Consolas', monospace;
    font-variant-numeric: tabular-nums;
    padding: 0 4px;
    -moz-appearance: textfield;
}
.vs2-tb-metro-bpm::-webkit-outer-spin-button,
.vs2-tb-metro-bpm::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.vs2-tb-btn.vs2-tb-metro-active {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: #fff;
}
@media (max-width: 720px) {
    .vs2-tb-metronome { display: none; }
}

/* ===== Timebar =====
   Grid 56px (track-head width = solo mic icon) + 1fr (ruler).
   Bg surface-3 (más opaco) para que las marcas del ruler sean visibles
   en dark mode sobre el body translúcido. */
.vs2-timebar {
    display: grid;
    grid-template-columns: 56px 1fr;
    background: var(--surface-3);
    border-bottom: 1px solid var(--edge-soft);
    flex-shrink: 0;
    z-index: 4;
}
[data-theme="light"] .vs2-timebar {
    background: var(--bg-tertiary);
    border-bottom-color: var(--border-color);
}

.vs2-elapsed-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-2, 8px) 4px;
    border-right: 1px solid var(--edge-soft);
}

.vs2-elapsed {
    font-family: 'Fira Code', 'Consolas', monospace;
    font-size: 11px;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

.vs2-ruler-wrap {
    position: relative;
    height: 32px;
    overflow-x: auto;
    overflow-y: hidden;
    cursor: pointer;
    touch-action: pan-x;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    overscroll-behavior-y: none;
    will-change: scroll-position;
}
.vs2-ruler-wrap::-webkit-scrollbar {
    height: 0;
    display: none;
}
.vs2-ruler-wrap { scrollbar-width: none; }

.vs2-ruler {
    width: 100%;
    height: 32px;
}

/* Ruler playhead: línea vertical 2px dentro del ruler-wrap scrollable.
   Handle circular en TOP siempre visible como anchor del marker. */
.vs2-playhead {
    position: absolute;
    top: 0;
    left: 0;
    width: 2px;
    height: 100%;
    background: var(--color-primary);
    transform: translateX(0);
    pointer-events: auto;
    cursor: ew-resize;
    box-shadow: 0 0 6px color-mix(in srgb, var(--color-primary) 60%, transparent);
    z-index: 6;
    touch-action: none;
}
/* Handle circular en top — indicador visual permanente. */
.vs2-playhead::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 50%;
    transform: translateX(-50%);
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--color-primary);
    border: 2px solid var(--surface-2, #fff);
    box-shadow: 0 0 8px color-mix(in srgb, var(--color-primary) 60%, transparent),
                0 2px 4px rgba(0, 0, 0, 0.25);
    pointer-events: none;
}
/* Hit zone wider invisible para agarre fácil. */
.vs2-playhead::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: -10px;
    width: 22px;
    background: transparent;
    cursor: ew-resize;
}

/* Playhead overlay dentro de .vs2-track-list — extiende línea solo sobre tracks reales.
   Top/height seteados por JS según número de tracks. */
.vs2-playhead-tracks {
    position: absolute;
    top: 0;
    left: 56px;
    width: 2px;
    background: var(--color-primary);
    box-shadow: 0 0 8px color-mix(in srgb, var(--color-primary) 50%, transparent);
    transform: translateX(0);
    pointer-events: auto;
    cursor: ew-resize;
    z-index: 3;
    touch-action: none;
    will-change: transform, opacity;
    transition: opacity 0.12s ease;
}
.vs2-playhead-tracks.hidden { display: none; }
.vs2-playhead-tracks::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: -10px;
    width: 22px;
    background: transparent;
    cursor: ew-resize;
}
@media (max-width: 720px) {
    .vs2-playhead-tracks { left: 48px; }
}

/* Track-list needs position relative para que playhead absolute ancle correctamente. */
.vs2-track-list {
    position: relative;
}

/* ===== Track list ===== */
.vs2-track-list {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: var(--space-3, 12px) 0;
    display: flex;
    flex-direction: column;
    gap: var(--space-2, 8px);
    touch-action: pan-x pan-y;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
}

/* GPU layer hints en strip-inner y regions */
.vs2-strip-inner,
.vs2-region {
    transform: translateZ(0);
    backface-visibility: hidden;
}

.vs2-empty {
    margin: auto;
    text-align: center;
    padding: var(--space-6, 24px);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-3, 12px);
    max-width: 420px;
}
.vs2-empty-icon {
    width: 88px;
    height: 88px;
    border-radius: 50%;
    background: color-mix(in srgb, var(--color-primary) 18%, transparent);
    border: 2px solid color-mix(in srgb, var(--color-primary) 40%, transparent);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: var(--space-2, 8px);
}
.vs2-empty-icon i {
    font-size: 36px;
    color: var(--color-primary);
}
.vs2-empty-title {
    margin: 0;
    color: var(--text-primary);
    font-size: var(--font-size-xl, 18px);
    font-weight: var(--font-weight-semibold, 600);
}
.vs2-empty-sub {
    margin: 0;
    color: var(--text-secondary);
    font-size: var(--font-size-sm, 13px);
    line-height: 1.5;
}
.vs2-empty-btn {
    margin-top: var(--space-3, 12px);
    display: inline-flex;
    align-items: center;
    gap: var(--space-2, 8px);
    padding: var(--space-3, 12px) var(--space-5, 20px);
    background: var(--color-primary);
    border: none;
    border-radius: var(--border-radius-full, 999px);
    color: white;
    font-size: var(--font-size-base, 14px);
    font-weight: var(--font-weight-semibold, 600);
    cursor: pointer;
    box-shadow: 0 6px 20px color-mix(in srgb, var(--color-primary) 40%, transparent);
    transition: transform 0.15s ease, background 0.15s ease;
}
.vs2-empty-btn:hover {
    background: var(--color-primary-hover, var(--color-primary));
    transform: translateY(-1px);
}

/* Botón inline al final del track-list */
.vs2-add-inline {
    display: inline-flex;
    align-self: center;
    align-items: center;
    gap: var(--space-2, 8px);
    padding: var(--space-2, 8px) var(--space-4, 16px);
    background: var(--surface-3);
    border: 1px dashed color-mix(in srgb, var(--color-primary) 50%, transparent);
    border-radius: var(--border-radius-full, 999px);
    color: var(--color-primary);
    font-size: var(--font-size-sm, 13px);
    font-weight: var(--font-weight-medium, 500);
    cursor: pointer;
    margin-top: var(--space-1, 4px);
    transition: background 0.15s ease, border-color 0.15s ease;
}
.vs2-add-inline:hover {
    background: color-mix(in srgb, var(--color-primary) 12%, var(--surface-3));
    border-color: var(--color-primary);
    border-style: solid;
}
[data-theme="light"] .vs2-add-inline {
    background: var(--bg-card);
}
[data-theme="light"] .vs2-add-inline:hover {
    background: color-mix(in srgb, var(--color-primary) 8%, var(--bg-card));
}

.vs2-track {
    --track-color: var(--color-primary);
    display: grid;
    grid-template-columns: 56px 1fr;
    gap: 0;
    background: var(--surface-3);
    border-top: 1px solid var(--edge-soft);
    border-bottom: 1px solid var(--edge-soft);
    border-radius: 0;
    overflow: hidden;
    min-height: 64px;
}

.vs2-track.vs2-muted .vs2-region {
    opacity: 0.4;
    filter: saturate(0.5);
}
/* Mute styling extendido: track-head + mic icon + strip */
.vs2-track.vs2-muted .vs2-track-head {
    opacity: 0.55;
}
.vs2-track.vs2-muted .vs2-track-mic {
    background: var(--text-muted, #888);
    box-shadow: none;
}
.vs2-track.vs2-muted .vs2-track-strip {
    background-color: rgba(128, 128, 128, 0.06);
}

/* Solo styling: highlight amber */
.vs2-track.vs2-solo .vs2-track-mic {
    background: #f59e0b;
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.45),
                0 0 14px rgba(245, 158, 11, 0.5);
}
.vs2-track.vs2-solo .vs2-region {
    box-shadow: inset 0 0 0 1px rgba(245, 158, 11, 0.7);
}

/* Cuando algún solo activo, otros tracks dimmed (sin label) */
.vs2-track-list.vs2-has-solo .vs2-track:not(.vs2-solo) {
    opacity: 0.5;
}

/* Marquee active: lock scroll completo de la página + tracks */
body.vs2-marquee-active {
    overflow: hidden;
    touch-action: none;
}
body.vs2-marquee-active .vs2-track-list,
body.vs2-marquee-active .vs2-ruler-wrap,
body.vs2-marquee-active .vs2-track-strip {
    touch-action: none;
    overflow: hidden;
}

.vs2-track-head {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-2, 8px) 4px;
    background: color-mix(in srgb, var(--track-color) 12%, var(--surface-2));
    border-right: 1px solid var(--edge-soft);
    cursor: pointer;
    transition: background 0.15s ease;
}
.vs2-track-head:hover {
    background: color-mix(in srgb, var(--track-color) 22%, var(--surface-2));
}

.vs2-track-mic {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: var(--track-color);
    color: white;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    box-shadow: 0 2px 8px color-mix(in srgb, var(--track-color) 40%, transparent);
    transition: transform 0.15s ease;
}
.vs2-track-mic:hover {
    transform: scale(1.08);
}
.vs2-track.vs2-track-selected .vs2-track-mic {
    box-shadow:
        0 0 0 2px rgba(255, 255, 255, 0.95),
        0 0 0 5px rgba(255, 255, 255, 0.35),
        0 0 14px color-mix(in srgb, var(--track-color) 70%, transparent);
}
[data-theme="light"] .vs2-track.vs2-track-selected .vs2-track-mic {
    box-shadow:
        0 0 0 2px rgba(0, 0, 0, 0.85),
        0 0 0 5px rgba(0, 0, 0, 0.20),
        0 0 14px color-mix(in srgb, var(--track-color) 70%, transparent);
}

.vs2-track-strip {
    position: relative;
    background:
        repeating-linear-gradient(
            90deg,
            transparent 0,
            transparent calc(var(--vs2-px-per-sec, 60px) - 1px),
            color-mix(in srgb, var(--edge-soft) 60%, transparent) calc(var(--vs2-px-per-sec, 60px) - 1px),
            color-mix(in srgb, var(--edge-soft) 60%, transparent) var(--vs2-px-per-sec, 60px)
        );
    min-height: 72px;
    overflow-x: auto;
    overflow-y: hidden;
    touch-action: pan-x;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    overscroll-behavior-y: none;
    will-change: scroll-position;
}
.vs2-track-strip::-webkit-scrollbar {
    height: 0;
    display: none;
}
.vs2-track-strip { scrollbar-width: none; }

/* Inner wrapper con width = totalContent pa permitir scroll horizontal.
   Regions positioned absolute dentro de este inner. */
.vs2-strip-inner {
    position: relative;
    height: 100%;
    min-height: 72px;
}

/* ===== Region ===== */
.vs2-region {
    position: absolute;
    top: 4px;
    bottom: 4px;
    background: color-mix(in srgb, var(--track-color) 60%, transparent);
    border: 1px solid color-mix(in srgb, var(--track-color) 80%, transparent);
    border-radius: var(--border-radius-sm, 6px);
    overflow: hidden;
    cursor: grab;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    touch-action: none;
}
.vs2-region:hover {
    border-color: var(--color-primary);
}
.vs2-region.vs2-region-selected {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--color-primary) 50%, transparent);
}

/* Live recording ghost region — bg rojo pulsante + canvas waveform en vivo */
.vs2-region.vs2-region-live {
    background: rgba(239, 68, 68, 0.45);
    border: 1px solid #ef4444;
    box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.35);
    pointer-events: none;
    overflow: hidden;
    animation: vs2-region-live-pulse 1.2s ease-in-out infinite;
}
.vs2-region.vs2-region-live .vs2-live-wave {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    display: block;
    pointer-events: none;
}
@keyframes vs2-region-live-pulse {
    0%, 100% { box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.35); }
    50% { box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.55); }
}

.vs2-wave {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
}

/* Track name overlay sobre region — grande pero muy sutil */
.vs2-region-name {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding-left: 10px;
    font-size: clamp(18px, 4vh, 36px);
    font-weight: 700;
    letter-spacing: 0.04em;
    color: #ffffff;
    opacity: 0.10;
    text-transform: uppercase;
    pointer-events: none;
    user-select: none;
    overflow: hidden;
    white-space: nowrap;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
    z-index: 2;
}

.vs2-handle {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 8px;
    cursor: ew-resize;
    z-index: 2;
    touch-action: none;
}
.vs2-handle-l { left: 0; }
.vs2-handle-r { right: 0; }
.vs2-handle::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: 3px;
    width: 2px;
    background: rgba(255, 255, 255, 0.5);
    opacity: 0;
    transition: opacity 0.15s ease;
}
.vs2-region:hover .vs2-handle::before,
.vs2-region.vs2-region-selected .vs2-handle::before {
    opacity: 1;
}

/* ===== Marquee (drag-select) ===== */
.vs2-marquee {
    position: fixed;
    border: 1px dashed var(--color-primary);
    background: color-mix(in srgb, var(--color-primary) 10%, transparent);
    pointer-events: none;
    z-index: 50;
}

/* ===== Add menu (modal centered) ===== */
.vs2-add-menu-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-4, 16px);
}
.vs2-add-menu-backdrop.hidden { display: none; }

.vs2-add-menu {
    width: 100%;
    max-width: 360px;
    background: var(--surface-2);
    backdrop-filter: blur(20px) saturate(140%);
    -webkit-backdrop-filter: blur(20px) saturate(140%);
    border: 1px solid var(--edge-medium);
    border-radius: var(--border-radius-lg, 14px);
    padding: var(--space-3, 12px);
    display: flex;
    flex-direction: column;
    gap: var(--space-1, 4px);
    box-shadow: 0 12px 40px rgba(0,0,0,0.2);
}

.vs2-add-menu-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-1, 4px) var(--space-2, 8px) var(--space-2, 8px);
    border-bottom: 1px solid var(--edge-soft);
    margin-bottom: var(--space-2, 8px);
}
.vs2-add-menu-header h3 {
    margin: 0;
    font-size: var(--font-size-lg, 16px);
    color: var(--text-primary);
    font-weight: var(--font-weight-semibold, 600);
}

[data-theme="light"] .vs2-add-menu {
    background: var(--bg-card);
    border-color: var(--border-color);
    box-shadow: 0 8px 32px rgba(0,0,0,0.1);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}
[data-theme="light"] .vs2-add-menu-backdrop {
    background: rgba(0,0,0,0.25);
}

.vs2-add-menu-btn {
    display: flex;
    align-items: center;
    gap: var(--space-3, 12px);
    padding: var(--space-3, 12px) var(--space-3, 12px);
    background: var(--surface-3);
    border: 1px solid var(--edge-soft);
    border-radius: var(--border-radius-md, 10px);
    color: var(--text-primary);
    cursor: pointer;
    text-align: left;
    font-size: var(--font-size-sm, 13px);
    font-weight: var(--font-weight-medium, 500);
    transition: background 0.15s ease, border-color 0.15s ease;
}
.vs2-add-menu-btn:hover {
    background: color-mix(in srgb, var(--color-primary) 12%, var(--surface-3));
    border-color: var(--color-primary);
}
.vs2-add-menu-btn i {
    color: var(--color-primary);
    width: 22px;
    text-align: center;
    font-size: 16px;
}
[data-theme="light"] .vs2-add-menu-btn {
    background: var(--bg-tertiary);
    border-color: var(--border-color);
}
[data-theme="light"] .vs2-add-menu-btn:hover {
    background: color-mix(in srgb, var(--color-primary) 8%, var(--bg-tertiary));
}

/* ===== Sidebar derecha ===== */
.vs2-side-right {
    position: fixed;
    top: 0;
    right: 0;
    width: 340px;
    max-width: 90vw;
    height: 100dvh;
    background: rgba(20, 14, 35, 0.75);
    backdrop-filter: blur(24px) saturate(160%);
    -webkit-backdrop-filter: blur(24px) saturate(160%);
    border-left: 1px solid var(--edge-medium);
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
    z-index: 60;
    display: flex;
    flex-direction: column;
    box-shadow: -8px 0 32px rgba(0, 0, 0, 0.35);
}
.vs2-side-right.vs2-side-open {
    transform: translateX(0);
}

[data-theme="light"] .vs2-side-right {
    background: rgba(252, 252, 254, 0.96);
    border-color: rgba(0, 0, 0, 0.12);
    backdrop-filter: blur(24px) saturate(160%);
    -webkit-backdrop-filter: blur(24px) saturate(160%);
    box-shadow: -8px 0 32px rgba(0, 0, 0, 0.12);
}
[data-theme="light"] .vs2-side-header {
    border-bottom-color: rgba(0, 0, 0, 0.08);
}
[data-theme="light"] .vs2-side-color-dot {
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.06);
}
[data-theme="light"] .vs2-side-title {
    color: #1f2937;
}
[data-theme="light"] .vs2-side-label {
    color: #6b7280;
}
[data-theme="light"] .vs2-side-value {
    color: var(--color-primary);
}
[data-theme="light"] .vs2-side-input {
    background: #f3f4f6;
    border-color: rgba(0, 0, 0, 0.10);
    color: #1f2937;
}
[data-theme="light"] .vs2-side-input:focus {
    background: white;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-primary) 18%, transparent);
}
[data-theme="light"] .vs2-side-toggle {
    background: #f3f4f6;
    border-color: rgba(0, 0, 0, 0.10);
    color: #1f2937;
}
[data-theme="light"] .vs2-side-toggle:hover {
    background: #e5e7eb;
    border-color: var(--color-primary);
}
[data-theme="light"] .vs2-side-toggle.vs2-active {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: white;
}
[data-theme="light"] .vs2-side-toggle-solo.vs2-active {
    background: #f59e0b;
    border-color: #f59e0b;
    color: #1f2937;
}
[data-theme="light"] .vs2-side-range {
    accent-color: var(--color-primary);
}
[data-theme="light"] .vs2-color-dot.vs2-active {
    box-shadow:
        0 0 0 2px white,
        0 0 0 4px var(--color-primary);
}
[data-theme="light"] .vs2-side-section-danger {
    border-top-color: rgba(0, 0, 0, 0.08);
}
[data-theme="light"] .vs2-side-danger-btn {
    background: rgba(239, 68, 68, 0.08);
    border-color: rgba(239, 68, 68, 0.30);
    color: #dc2626;
}
[data-theme="light"] .vs2-side-danger-btn:hover {
    background: #ef4444;
    color: white;
    border-color: #ef4444;
}
[data-theme="light"] .vs2-side-right .vs2-tb-btn {
    background: #f3f4f6;
    border-color: rgba(0, 0, 0, 0.10);
    color: #1f2937;
}
[data-theme="light"] .vs2-side-right .vs2-tb-btn:hover {
    background: #e5e7eb;
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.vs2-side-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 55;
}
.vs2-side-overlay.vs2-side-overlay-active {
    opacity: 1;
    pointer-events: auto;
}

/* Header */
.vs2-side-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2, 8px);
    padding: var(--space-3, 12px) var(--space-4, 16px);
    border-bottom: 1px solid var(--edge-soft);
    flex-shrink: 0;
}
[data-theme="light"] .vs2-side-header {
    border-bottom-color: var(--border-color);
}
.vs2-side-header-left {
    display: flex;
    align-items: center;
    gap: var(--space-2, 8px);
    flex: 1;
    min-width: 0;
}
.vs2-side-color-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--text-primary) 8%, transparent);
}
.vs2-side-title {
    font-weight: var(--font-weight-semibold, 600);
    font-size: var(--font-size-base, 14px);
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Body */
.vs2-side-body {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-4, 16px);
    display: flex;
    flex-direction: column;
    gap: var(--space-4, 16px);
}

.vs2-side-section {
    display: flex;
    flex-direction: column;
    gap: var(--space-2, 8px);
}

.vs2-side-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: var(--font-weight-semibold, 600);
}

.vs2-side-label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.vs2-side-value {
    font-family: 'Fira Code', 'Consolas', monospace;
    font-size: var(--font-size-sm, 13px);
    color: var(--color-primary);
    font-weight: var(--font-weight-semibold, 600);
    font-variant-numeric: tabular-nums;
}

/* Input */
.vs2-side-input {
    width: 100%;
    padding: 10px var(--space-3, 12px);
    border: 1px solid var(--edge-soft);
    border-radius: var(--border-radius-md, 10px);
    background: var(--surface-2);
    color: var(--text-primary);
    font-size: var(--font-size-sm, 13px);
    transition: border-color 0.15s ease;
}
.vs2-side-input:focus {
    outline: none;
    border-color: var(--color-primary);
}
[data-theme="light"] .vs2-side-input {
    background: var(--bg-tertiary);
    border-color: var(--border-color);
}

/* ===== Slider custom (wrapper structure) =====
   Container relative con track (full width pill bg), fill div (purple
   positioned), thumb absolute (ball), input range overlay invisible. */
.vs2-slider {
    position: relative;
    width: 100%;
    height: 24px;
    display: flex;
    align-items: center;
    cursor: pointer;
}
.vs2-slider-track {
    position: relative;
    width: 100%;
    height: 6px;
    background: var(--surface-3);
    border-radius: 999px;
    overflow: hidden;
}
.vs2-slider-fill {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 0;
    background: var(--color-primary);
    border-radius: 999px;
    transition: none;
}
.vs2-slider-thumb {
    position: absolute;
    top: 50%;
    left: 0;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: white;
    border: 3px solid var(--color-primary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
    transform: translate(-50%, -50%);
    pointer-events: none;
    transition: box-shadow 0.15s ease, transform 0.15s cubic-bezier(0.32, 0.72, 0, 1);
    transform-origin: center;
    z-index: 2;
}
.vs2-slider:hover .vs2-slider-thumb {
    transform: translate(-50%, -50%) scale(1.12);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3),
                0 0 0 6px color-mix(in srgb, var(--color-primary) 18%, transparent);
}
.vs2-slider:active .vs2-slider-thumb {
    transform: translate(-50%, -50%) scale(1.18);
    box-shadow: 0 2px 14px rgba(0, 0, 0, 0.35),
                0 0 0 8px color-mix(in srgb, var(--color-primary) 24%, transparent);
}
.vs2-slider-input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    margin: 0;
    padding: 0;
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
}
.vs2-slider-input::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    background: transparent;
}
.vs2-slider-input::-moz-range-thumb {
    width: 24px;
    height: 24px;
    background: transparent;
    border: none;
}

/* Light overrides slider */
[data-theme="light"] .vs2-slider-track {
    background: #e5e7eb;
}
[data-theme="light"] .vs2-slider-thumb {
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

/* Mute / Solo toggle pair */
.vs2-side-btn-pair {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-2, 8px);
}

.vs2-side-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px var(--space-3, 12px);
    border: 1px solid var(--edge-soft);
    background: var(--surface-2);
    color: var(--text-primary);
    border-radius: var(--border-radius-md, 10px);
    cursor: pointer;
    font-size: var(--font-size-sm, 13px);
    font-weight: var(--font-weight-medium, 500);
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.vs2-side-toggle:hover {
    border-color: var(--color-primary);
}
.vs2-side-toggle.vs2-active {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: white;
}
.vs2-side-toggle-solo.vs2-active {
    background: #f59e0b;
    border-color: #f59e0b;
    color: #1f2937;
}
[data-theme="light"] .vs2-side-toggle {
    background: var(--bg-tertiary);
    border-color: var(--border-color);
}

/* Color picker grid */
.vs2-color-picker {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: var(--space-2, 8px);
}
.vs2-color-dot {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    padding: 0;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}
.vs2-color-dot:hover {
    transform: scale(1.12);
}
.vs2-color-dot i {
    color: white;
    font-size: 10px;
    opacity: 0;
    transition: opacity 0.15s ease;
    text-shadow: 0 0 4px rgba(0, 0, 0, 0.4);
}
.vs2-color-dot.vs2-active {
    box-shadow: 0 0 0 3px var(--text-primary);
}
.vs2-color-dot.vs2-active i {
    opacity: 1;
}

/* Danger section */
.vs2-side-section-danger {
    margin-top: auto;
    padding-top: var(--space-3, 12px);
    border-top: 1px solid var(--edge-soft);
}
[data-theme="light"] .vs2-side-section-danger {
    border-top-color: var(--border-color);
}
.vs2-side-danger-btn {
    width: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2, 8px);
    padding: 10px var(--space-3, 12px);
    background: color-mix(in srgb, #ef4444 12%, transparent);
    border: 1px solid color-mix(in srgb, #ef4444 35%, transparent);
    color: #ef4444;
    border-radius: var(--border-radius-md, 10px);
    cursor: pointer;
    font-size: var(--font-size-sm, 13px);
    font-weight: var(--font-weight-medium, 500);
    transition: background 0.15s ease, color 0.15s ease;
}
.vs2-side-danger-btn:hover {
    background: #ef4444;
    color: white;
    border-color: #ef4444;
}

/* ===== Modal ===== */
.vs2-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-4, 16px);
}
.vs2-modal-backdrop.hidden { display: none; }

.vs2-modal {
    width: 100%;
    max-width: 420px;
    background: var(--surface-2);
    backdrop-filter: blur(20px) saturate(140%);
    -webkit-backdrop-filter: blur(20px) saturate(140%);
    border: 1px solid var(--edge-medium);
    border-radius: var(--border-radius-lg, 14px);
    display: flex;
    flex-direction: column;
    max-height: 80vh;
    overflow: hidden;
}

.vs2-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-3, 12px) var(--space-4, 16px);
    border-bottom: 1px solid var(--edge-soft);
}
.vs2-modal-header h3 {
    margin: 0;
    color: var(--text-primary);
    font-size: var(--font-size-lg, 16px);
}

.vs2-modal-body {
    padding: var(--space-4, 16px);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: var(--space-3, 12px);
}

.vs2-setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3, 12px);
    color: var(--text-primary);
    font-size: var(--font-size-sm, 13px);
    cursor: pointer;
}
.vs2-setting-row input[type="number"],
.vs2-setting-row select {
    padding: var(--space-1, 4px) var(--space-2, 8px);
    border: 1px solid var(--edge-soft);
    border-radius: var(--border-radius-sm, 6px);
    background: var(--surface-3);
    color: var(--text-primary);
    font-size: var(--font-size-sm, 13px);
    min-width: 80px;
}
.vs2-metronome-fields {
    padding: var(--space-3, 12px);
    border: 1px solid var(--edge-soft);
    border-radius: var(--border-radius-sm, 6px);
    background: color-mix(in srgb, var(--color-primary) 6%, transparent);
    display: flex;
    flex-direction: column;
    gap: var(--space-2, 8px);
}
.vs2-metronome-fields.hidden { display: none; }

/* Manual latency adjust slider + input */
.vs2-setting-row-stack {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
}
.vs2-latency-manual {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
}
.vs2-latency-manual input[type="range"] {
    flex: 1;
    accent-color: var(--color-primary);
}
.vs2-latency-manual input[type="number"] {
    width: 64px;
    padding: 4px 6px;
    border: 1px solid var(--edge-soft);
    border-radius: var(--border-radius-sm, 6px);
    background: var(--surface-3);
    color: var(--text-primary);
    font-size: 13px;
    font-family: 'Fira Code', 'Consolas', monospace;
    font-variant-numeric: tabular-nums;
    text-align: center;
}
.vs2-latency-unit {
    color: var(--text-secondary);
    font-size: 12px;
}

/* Setting action buttons (calibrar + reset latencia) */
.vs2-setting-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.vs2-setting-btn {
    flex: 1;
    min-width: 120px;
    padding: 10px 14px;
    border: 1px solid var(--color-primary);
    background: var(--color-primary);
    color: #fff;
    border-radius: var(--border-radius-md, 10px);
    font-size: 13px;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}
.vs2-setting-btn:hover { background: var(--color-primary-hover, var(--color-primary)); }
.vs2-setting-btn.vs2-setting-btn-secondary {
    background: var(--surface-3);
    color: var(--text-primary);
    border-color: var(--edge-soft);
}
.vs2-setting-btn.vs2-setting-btn-secondary:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.vs2-setting-hint {
    font-size: 11px;
    color: var(--text-secondary);
    line-height: 1.3;
    padding: 4px 2px;
}

/* ===== Calibration modal ===== */
.vs2-calib-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.78);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.vs2-calib-card {
    background: var(--surface-2);
    border: 1px solid var(--edge-soft);
    border-radius: var(--border-radius-lg, 16px);
    padding: 24px 20px;
    max-width: 380px;
    width: 100%;
    text-align: center;
    color: var(--text-primary);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}
.vs2-calib-card h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}
.vs2-calib-instructions {
    margin: 0;
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.4;
}
.vs2-calib-pulse {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(124, 77, 255, 0.12);
    border: 2px solid color-mix(in srgb, var(--color-primary) 40%, transparent);
    transition: transform 0.12s ease, background 0.12s ease;
}
.vs2-calib-pulse.vs2-calib-pulse-active {
    animation: vs2-calib-pulse-anim 0.4s ease-out;
}
@keyframes vs2-calib-pulse-anim {
    0% { transform: scale(0.85); background: rgba(124, 77, 255, 0.55); }
    100% { transform: scale(1); background: rgba(124, 77, 255, 0.12); }
}

.vs2-calib-tap-btn {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    border: none;
    background: var(--color-primary);
    color: #fff;
    font-size: 22px;
    font-weight: 700;
    letter-spacing: 0.1em;
    cursor: pointer;
    box-shadow: 0 6px 20px color-mix(in srgb, var(--color-primary) 50%, transparent);
    transition: transform 0.08s ease, background 0.12s ease;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}
.vs2-calib-tap-btn:active { transform: scale(0.94); }
.vs2-calib-tap-btn.vs2-calib-tap-flash {
    animation: vs2-calib-tap-flash-anim 0.18s ease-out;
}
@keyframes vs2-calib-tap-flash-anim {
    0% { background: #fff; box-shadow: 0 0 0 6px color-mix(in srgb, var(--color-primary) 60%, transparent); }
    100% { background: var(--color-primary); box-shadow: 0 6px 20px color-mix(in srgb, var(--color-primary) 50%, transparent); }
}
.vs2-calib-counter {
    font-family: 'Fira Code', 'Consolas', monospace;
    font-size: 14px;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}
.vs2-calib-status {
    min-height: 18px;
    font-size: 13px;
    color: var(--text-primary);
    max-width: 320px;
    line-height: 1.4;
}
.vs2-calib-actions {
    display: flex;
    gap: 8px;
}
.vs2-calib-cancel {
    padding: 8px 18px;
    border: 1px solid var(--edge-soft);
    background: var(--surface-3);
    color: var(--text-primary);
    border-radius: var(--border-radius-md, 10px);
    cursor: pointer;
    font-size: 13px;
}
.vs2-calib-cancel:hover { border-color: var(--color-primary); color: var(--color-primary); }

/* ===== Toggle switch ===== */
.vs2-toggle {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}
.vs2-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}
.vs2-toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--surface-3);
    border: 1px solid var(--edge-soft);
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.2s ease;
}
.vs2-toggle-slider::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    background: var(--text-primary);
    border-radius: 50%;
    transition: transform 0.2s ease, background 0.2s ease;
}
.vs2-toggle input:checked + .vs2-toggle-slider {
    background: var(--color-primary);
    border-color: var(--color-primary);
}
.vs2-toggle input:checked + .vs2-toggle-slider::after {
    transform: translateX(20px);
    background: white;
}

/* ===== Light theme overrides =====
   NOTA: .vs2-side-right tiene su propio bloque light específico arriba
   (línea ~484). NO incluirlo aquí — pisaría el blur + bg sólido. */
[data-theme="light"] .vs2-topbar,
[data-theme="light"] .vs2-timebar,
[data-theme="light"] .vs2-modal,
[data-theme="light"] .vs2-add-menu {
    background: var(--bg-card);
    border-color: var(--border-color);
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}
[data-theme="light"] .vs2-track {
    background: var(--bg-card);
    border-color: var(--border-color);
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
[data-theme="light"] .vs2-track-head {
    background: color-mix(in srgb, var(--track-color) 12%, var(--bg-card));
}
[data-theme="light"] .vs2-tb-btn,
[data-theme="light"] .vs2-side-btn,
[data-theme="light"] .vs2-toggle-slider,
[data-theme="light"] .vs2-modal-body input,
[data-theme="light"] .vs2-modal-body select,
[data-theme="light"] .vs2-side-row input[type="text"],
[data-theme="light"] .vs2-side-row input[type="number"] {
    background: var(--bg-tertiary);
    border-color: var(--border-color);
    color: var(--text-primary);
}
[data-theme="light"] .vs2-tb-btn.vs2-tb-play {
    background: var(--color-primary);
    color: white;
}
[data-theme="light"] .vs2-tb-btn.vs2-tb-rec.vs2-rec-active {
    color: white;
}
[data-theme="light"] .vs2-modal-backdrop {
    background: rgba(0,0,0,0.25);
}

/* ===== Mobile responsive ===== */
@media (max-width: 720px) {
    .vs2-timebar {
        grid-template-columns: 48px 1fr;
    }
    .vs2-track {
        grid-template-columns: 48px 1fr;
        min-height: 56px;
    }
    .vs2-track-head {
        padding: var(--space-1, 4px);
    }
    .vs2-track-mic {
        width: 32px;
        height: 32px;
    }
    .vs2-tb-btn {
        width: 32px;
        height: 32px;
        font-size: 12px;
    }
    .vs2-elapsed {
        font-size: 10px;
    }
}

/* ===== Light theme overrides — APPLIED LATE (after bulk group) ===== */
[data-theme="light"] .vs2-page .vs2-timebar {
    background: #f3f4f6;
    border-bottom-color: rgba(0, 0, 0, 0.10);
}
[data-theme="light"] .vs2-page .vs2-elapsed-cell {
    border-right-color: rgba(0, 0, 0, 0.10);
}
[data-theme="light"] .vs2-page .vs2-elapsed {
    color: #1f2937;
}
[data-theme="light"] .vs2-page .vs2-topbar {
    background: var(--bg-card);
    border-bottom-color: var(--border-color);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
}


/* =============================================
   PITCH EDITOR v2 (R574 desde cero, monolitico)
   ============================================= */
.vs2-pe-page {
    position: fixed;
    top: 0; bottom: 0; left: 0; right: 0;
    z-index: 200;
    display: flex;
    flex-direction: column;
    background: #0d0c17;
    isolation: isolate;
}
@media (min-width: 821px) {
    .vs2-pe-page { left: var(--sidebar-width, 280px); }
}
[data-theme="light"] .vs2-pe-page { background: #f9fafb; }

.vs2-pe-topbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--surface-3);
    border-bottom: 1px solid var(--edge-soft);
    flex-shrink: 0;
}
.vs2-pe-title {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 14px;
}
.vs2-pe-spacer { flex: 1; }
.vs2-pe-btn {
    height: 36px;
    min-width: 36px;
    border: 1px solid var(--edge-soft);
    background: var(--surface-3);
    color: var(--text-primary);
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    cursor: pointer;
    padding: 0 12px;
    font-size: 13px;
    transition: background 0.12s ease, border-color 0.12s ease;
}
.vs2-pe-btn:hover {
    background: color-mix(in srgb, var(--color-primary) 15%, var(--surface-3));
    border-color: var(--color-primary);
}
.vs2-pe-btn.vs2-pe-play-btn {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: #fff;
}
.vs2-pe-btn.vs2-pe-play-btn:hover {
    background: var(--color-primary-hover, var(--color-primary));
}

.vs2-pe-status {
    position: absolute;
    top: 60px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--surface-3);
    border: 1px solid var(--edge-soft);
    color: var(--text-primary);
    padding: 8px 16px;
    border-radius: 999px;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}
.vs2-pe-status.hidden { display: none; }

.vs2-pe-viewport {
    flex: 1;
    display: grid;
    grid-template-columns: 64px 1fr;
    overflow: hidden;
    position: relative;
}

.vs2-pe-piano {
    overflow-y: auto;
    border-right: 1px solid var(--edge-soft);
    background: var(--surface-2);
    user-select: none;
}
.vs2-pe-key {
    position: relative;
    border-bottom: 1px solid var(--edge-soft);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    padding: 0 6px;
    font-size: 10px;
    font-family: 'Fira Code', monospace;
}
.vs2-pe-key-black {
    background: color-mix(in srgb, var(--text-primary) 25%, transparent);
}
.vs2-pe-key-c {
    color: var(--color-primary);
    font-weight: 600;
}

.vs2-pe-grid {
    overflow: auto;
    background: var(--bg-body, #0d0c17);
    position: relative;
}
[data-theme="light"] .vs2-pe-grid { background: #ffffff; }
.vs2-pe-grid-inner {
    position: relative;
    min-height: 100%;
    background-image: repeating-linear-gradient(
        to bottom,
        transparent 0,
        transparent calc(var(--vs2-pe-key-h, 20px) - 1px),
        rgba(255, 255, 255, 0.04) calc(var(--vs2-pe-key-h, 20px) - 1px),
        rgba(255, 255, 255, 0.04) var(--vs2-pe-key-h, 20px)
    );
}

/* Blobs: rectangulares sin border-radius, organicos via clip-path RMS */
.vs2-pe-blob {
    position: absolute;
    background: linear-gradient(180deg,
        color-mix(in srgb, #10b981 90%, transparent) 0%,
        color-mix(in srgb, #059669 90%, transparent) 100%);
    border: none;
    border-radius: 0;
    cursor: grab;
    overflow: hidden;
    user-select: none;
    transition: filter 0.12s ease;
    z-index: 2;
}
.vs2-pe-blob:hover { filter: brightness(1.15); }
.vs2-pe-blob:active { cursor: grabbing; }
.vs2-pe-blob.vs2-pe-selected {
    outline: 2px solid #fff;
    outline-offset: -2px;
    z-index: 4;
}
.vs2-pe-blob.vs2-pe-shifted {
    background: linear-gradient(180deg,
        color-mix(in srgb, var(--color-primary) 90%, transparent) 0%,
        color-mix(in srgb, var(--color-primary) 95%, transparent) 100%);
}

/* Curva pitch global amarilla */
.vs2-pe-curve {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 3;
    overflow: visible;
}
.vs2-pe-curve-line {
    fill: none;
    stroke: #fde047;
    stroke-width: 1.4;
    vector-effect: non-scaling-stroke;
    stroke-linecap: butt;
    stroke-linejoin: miter;
}
.vs2-pe-curve-shadow {
    fill: none;
    stroke: rgba(0, 0, 0, 0.55);
    stroke-width: 3;
    vector-effect: non-scaling-stroke;
    stroke-linecap: butt;
    stroke-linejoin: miter;
}

/* PE: timebar + ruler + playhead (R577) */
.vs2-pe-timebar {
    display: grid;
    grid-template-columns: 64px 1fr;
    background: var(--surface-3);
    border-bottom: 1px solid var(--edge-soft);
    flex-shrink: 0;
    z-index: 4;
}
[data-theme="light"] .vs2-pe-timebar {
    background: var(--bg-tertiary);
    border-bottom-color: var(--border-color);
}
.vs2-pe-elapsed-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    border-right: 1px solid var(--edge-soft);
}
.vs2-pe-elapsed {
    font-family: 'Fira Code', 'Consolas', monospace;
    font-size: 11px;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}
.vs2-pe-ruler-wrap {
    position: relative;
    height: 32px;
    overflow-x: auto;
    overflow-y: hidden;
    cursor: pointer;
    touch-action: pan-x;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
}
.vs2-pe-ruler-wrap::-webkit-scrollbar { display: none; }
.vs2-pe-ruler {
    display: block;
    height: 32px;
}
.vs2-pe-ruler-playhead {
    position: absolute;
    top: 0;
    left: 0;
    width: 2px;
    height: 100%;
    background: var(--color-primary);
    box-shadow: 0 0 6px color-mix(in srgb, var(--color-primary) 60%, transparent);
    pointer-events: none;
    z-index: 6;
    transform: translateX(0);
    will-change: transform;
}
.vs2-pe-ruler-playhead::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 50%;
    transform: translateX(-50%);
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--color-primary);
    border: 2px solid var(--surface-2, #fff);
    box-shadow: 0 0 8px color-mix(in srgb, var(--color-primary) 60%, transparent);
    pointer-events: none;
}
.vs2-pe-playhead {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 2px;
    background: var(--color-primary);
    box-shadow: 0 0 6px color-mix(in srgb, var(--color-primary) 50%, transparent);
    pointer-events: none;
    z-index: 5;
    transform: translateX(0);
    will-change: transform;
}

/* PE R578: playheads grabbables + hit zones wider */
.vs2-pe-ruler-playhead {
    pointer-events: auto;
    cursor: ew-resize;
    touch-action: none;
}
.vs2-pe-ruler-playhead::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: -10px;
    width: 22px;
    background: transparent;
    cursor: ew-resize;
}
.vs2-pe-playhead {
    pointer-events: auto;
    cursor: ew-resize;
    touch-action: none;
}
.vs2-pe-playhead::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: -10px;
    width: 22px;
    background: transparent;
    cursor: ew-resize;
}

/* PE Toolbar R580 — barra de herramientas entre topbar y timebar */
.vs2-pe-toolbar {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--edge-soft);
    flex-shrink: 0;
}
[data-theme="light"] .vs2-pe-toolbar {
    background: var(--bg-tertiary);
    border-bottom-color: var(--border-color);
}
.vs2-pe-tool-btn {
    width: 36px;
    height: 36px;
    border: 1px solid var(--edge-soft);
    background: var(--surface-3);
    color: var(--text-secondary);
    border-radius: 8px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
    font-size: 13px;
    padding: 0;
}
.vs2-pe-tool-btn:hover {
    background: color-mix(in srgb, var(--color-primary) 15%, var(--surface-3));
    color: var(--text-primary);
    border-color: var(--color-primary);
}
.vs2-pe-tool-btn.vs2-pe-active {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: #fff;
}

/* Cursor por tool activa scoped a .vs2-pe-page */
.vs2-pe-page.vs2-pe-tool-pitch-centre .vs2-pe-blob,
.vs2-pe-page.vs2-pe-tool-pitch-drift .vs2-pe-blob,
.vs2-pe-page.vs2-pe-tool-pitch-modulation .vs2-pe-blob {
    cursor: ns-resize;
}
.vs2-pe-page.vs2-pe-tool-timing .vs2-pe-blob {
    cursor: move;
}
.vs2-pe-page.vs2-pe-tool-split .vs2-pe-blob {
    cursor: crosshair;
}

/* PE Tool tooltip flotante (Fase B R589): pill rectangular 4px, fondo
   oscuro semitransparente, texto blanco. */
.vs2-pe-tooltip {
    position: fixed;
    z-index: 9999;
    pointer-events: none;
    padding: 4px 8px;
    background: rgba(15, 15, 25, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 4px;
    color: #ffffff;
    font-family: 'Fira Code', 'Consolas', monospace;
    font-size: 11px;
    font-variant-numeric: tabular-nums;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    white-space: nowrap;
    user-select: none;
}

/* Pitch Drift R582: zonas 30/40/30 visibles en blob cuando tool activa */
.vs2-pe-page.vs2-pe-tool-pitch-drift .vs2-pe-blob {
    position: absolute;
}
.vs2-pe-page.vs2-pe-tool-pitch-drift .vs2-pe-blob::before,
.vs2-pe-page.vs2-pe-tool-pitch-drift .vs2-pe-blob::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    width: 0;
    border-left: 1px dashed rgba(255, 255, 255, 0.2);
    pointer-events: none;
    z-index: 1;
}
.vs2-pe-page.vs2-pe-tool-pitch-drift .vs2-pe-blob::before { left: 30%; }
.vs2-pe-page.vs2-pe-tool-pitch-drift .vs2-pe-blob::after { left: 70%; }

/* Tool Timing R585: handles izq/der visibles cuando tool activa */
.vs2-pe-handle {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 8px;
    background: rgba(255, 255, 255, 0.4);
    display: none;
    z-index: 3;
    pointer-events: none;
}
/* Overlap warning: blob con borde rojo mientras se solapa con vecina */
.vs2-pe-blob.vs2-pe-overlap-warning {
    box-shadow: inset 0 0 0 2px #ef4444, 0 0 8px rgba(239, 68, 68, 0.6);
}
.vs2-pe-handle::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 2px;
    height: 60%;
    background: rgba(255, 255, 255, 0.85);
    border-radius: 1px;
}
.vs2-pe-handle-l { left: 0; }
.vs2-pe-handle-r { right: 0; }
.vs2-pe-page.vs2-pe-tool-timing .vs2-pe-handle {
    display: block;
    pointer-events: auto;
}
.vs2-pe-page.vs2-pe-tool-timing .vs2-pe-handle-l { cursor: w-resize; }
.vs2-pe-page.vs2-pe-tool-timing .vs2-pe-handle-r { cursor: e-resize; }

/* Tool Split R587: linea vertical hover dentro del blob */
.vs2-pe-split-cursor {
    position: absolute;
    width: 1px;
    background: rgba(255, 255, 255, 0.7);
    pointer-events: none;
    z-index: 6;
    display: none;
    box-shadow: 0 0 4px rgba(0, 0, 0, 0.6);
}

/* R588 split markers: inset border 1px muy sutil en lado del corte. */
.vs2-pe-blob.vs2-pe-split-left {
    box-shadow: inset 1px 0 0 rgba(255, 255, 255, 0.22);
}
.vs2-pe-blob.vs2-pe-split-right {
    box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.22);
}
.vs2-pe-blob.vs2-pe-split-left.vs2-pe-split-right {
    box-shadow:
        inset 1px 0 0 rgba(255, 255, 255, 0.22),
        inset -1px 0 0 rgba(255, 255, 255, 0.22);
}

/* Pitch Modulation R591: badge sobre blob cuando modDepth != 100 */
.vs2-pe-mod-badge {
    position: absolute;
    top: -16px;
    left: 4px;
    font-family: 'Fira Code', 'Consolas', monospace;
    font-size: 11px;
    font-weight: 700;
    background: rgba(0, 0, 0, 0.85);
    padding: 1px 5px;
    border-radius: 4px;
    pointer-events: none;
    white-space: nowrap;
    z-index: 5;
    display: none;
    line-height: 1.2;
}
[data-theme="light"] .vs2-pe-mod-badge {
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(0, 0, 0, 0.1);
}
.vs2-pe-mod-badge.vs2-pe-mod-reduced,
.vs2-pe-mod-badge.vs2-pe-mod-flat {
    color: #60a5fa;
}
.vs2-pe-mod-badge.vs2-pe-mod-amplified {
    color: #f97316;
}

/* Split tool R595: hover protection + pop animation + invalid flash */
.vs2-pe-page.vs2-pe-tool-split .vs2-pe-blob.vs2-pe-split-protected {
    cursor: not-allowed;
}
@keyframes vs2-pe-split-pop {
    0%   { transform: scale(1); }
    50%  { transform: scale(1.05); }
    100% { transform: scale(1); }
}
.vs2-pe-blob.vs2-pe-split-pop {
    animation: vs2-pe-split-pop 200ms ease-out;
    transform-origin: center;
    z-index: 5;
}
@keyframes vs2-pe-split-invalid {
    0%, 100% { outline-color: transparent; outline-width: 0; }
    50%      { outline-color: #ef4444; outline-width: 3px; }
}
.vs2-pe-blob.vs2-pe-split-invalid {
    outline: 0 solid transparent;
    animation: vs2-pe-split-invalid 150ms ease-out;
}
