:root {
    --bg-main: #f4f7f9; 
    --bg-card: #ffffff; 
    --primary: #046BD2; 
    --primary-hover: #0353a4; 
    --secondary: #e2e8f0; 
    --text-main: #1e293b; 
    --text-muted: #64748b; 
    --font-main: 'Fredoka', sans-serif;
    --success: #10b981; 
    --warning: #f59e0b; 
    --warning-rgb: 245, 158, 11;
    --error: #ef4444;
    --radius-sm: 10px;
    --radius-md: 20px;
    --radius-full: 50px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body { 
    font-family: var(--font-main) !important; 
    background-color: var(--bg-main) !important; 
    color: var(--text-main) !important; 
    line-height: 1.6; 
    min-height: 100vh; 
    display: flex; 
    flex-direction: column; 
    overflow-x: hidden; 
}

/* Agrega esto justo debajo del body para proteger los títulos de Kadence */
h1, h2, h3, h4, .song-title, .chord-name {
    font-family: var(--font-main) !important;
}

/* --- HEADER Y BÚSQUEDA --- */
header.app-header { 
    background-color: rgba(255, 255, 255, 0.95); 
    border-bottom: 1px solid var(--secondary); 
    position: sticky; top: 0; z-index: 100; 
    backdrop-filter: blur(10px); 
    box-shadow: 0 2px 10px rgba(0,0,0,0.02); 
    width: 100%; 
    height: 60px;
    display: flex;
}
.nav-container { 
    max-width: 1400px; width: 100%; margin: 0 auto; 
    padding: 0 1rem; display: flex; justify-content: space-between; align-items: center; 
}
.app-logo { display: flex; align-items: center; text-decoration: none; font-size: 1.2rem; font-weight: 600; color: var(--text-main); gap: 10px;}

.btn-outline { 
    background: transparent; color: var(--text-muted); border: 1px solid var(--secondary); 
    padding: 0.4rem 1.2rem; border-radius: var(--radius-full); font-size: 0.95rem; 
    cursor: pointer; transition: all 0.3s; text-decoration: none; display: inline-flex; align-items: center; gap: 8px; font-weight: 500;
}
.btn-outline:hover, .btn-outline.active { border-color: var(--primary); color: var(--primary); background-color: rgba(4, 107, 210, 0.05); }

.btn-primary { 
    background-color: var(--primary); color: #ffffff; border: none; 
    padding: 0.5rem 1.5rem; border-radius: var(--radius-full); font-weight: 600; 
    cursor: pointer; display: inline-flex; align-items: center; gap: 8px; 
    transition: all 0.2s; 
}
.btn-primary:hover { background-color: var(--primary-hover); transform: translateY(-2px); box-shadow: 0 4px 10px rgba(4, 107, 210, 0.2); }

/* --- BUSCADOR INTEGRADO EN EL HEADER --- */
.header-search-wrapper {
    display: flex; 
    align-items: center;
    justify-content: center;
    flex: 1; 
    max-width: 600px; /* Aumentamos el ancho ya que no está el botón */
    margin: 0 20px; 
    transition: all 0.3s ease;
}

.search-bar { 
    width: 100%; /* Ahora la barra de búsqueda toma todo el espacio disponible */
    position: relative; 
}

.search-bar input { 
    width: 100%; 
    padding: 0.6rem 1.5rem 0.6rem 2.8rem; /* Ligeramente más alta y espaciosa */
    border-radius: var(--radius-full); 
    border: 2px solid var(--secondary); 
    font-family: var(--font-main); 
    font-size: 0.95rem; 
    outline: none; 
    transition: all 0.3s ease; /* Transición suave para todos los efectos */
    background: var(--bg-main);
}

.search-bar input:focus { 
    border-color: var(--primary); 
    background: #ffffff; 
    /* Agregamos un resplandor elegante al hacer clic */
    box-shadow: 0 4px 15px rgba(4, 107, 210, 0.12); 
    transform: translateY(-1px);
}

.search-bar .search-icon { 
    position: absolute; 
    left: 1.2rem; 
    top: 50%; 
    transform: translateY(-50%); 
    color: var(--text-muted); 
    transition: color 0.3s ease;
    z-index: 2;
}

/* La lupa se ilumina en azul al escribir */
.search-bar:focus-within .search-icon {
    color: var(--primary); 
}

.header-actions { display: flex; align-items: center; gap: 10px; }
.mobile-search-toggle { 
    display: none; background: none; border: none; 
    font-size: 1.2rem; color: var(--text-main); cursor: pointer; 
    padding: 5px; transition: color 0.2s;
}
.mobile-search-toggle:hover { color: var(--primary); }

/* --- DISEÑO PRINCIPAL --- */
.main-workspace { max-width: 1400px; width: 100%; margin: 1.5rem auto 2rem; padding: 0 1rem; display: grid; grid-template-columns: 350px 1fr; gap: 1.5rem; align-items: start; }

/* --- PANEL IZQUIERDO (VIDEO/AUDIO) --- */
.video-panel { background: var(--bg-card); border-radius: var(--radius-md); border: 1px solid var(--secondary); overflow: hidden; box-shadow: 0 4px 6px rgba(0,0,0,0.02); position: sticky; top: 80px; z-index: 90; }

.video-placeholder { width: 100%; aspect-ratio: 16/9; position: relative; display: flex; align-items: center; justify-content: center; overflow: hidden; background: #000; }
.video-background-img { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background-position: center !important; background-size: cover !important; background-repeat: no-repeat !important; opacity: 1; transition: opacity 0.4s; z-index: 1; }
.video-placeholder iframe, .video-placeholder audio { position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; }

.video-placeholder::after {
    content: ''; position: absolute; top:0; left:0; right:0; bottom:0; 
    background: linear-gradient(180deg, rgba(0,0,0,0.3) 0%, rgba(0,0,0,0) 40%, rgba(0,0,0,0.9) 100%);
    border-radius: inherit; pointer-events: none; z-index: 2; transition: opacity 0.4s ease;
}

.video-placeholder.is-playing .video-background-img { opacity: 0.3; /* Mantenemos un poco visible si es audio */ }
.video-placeholder.is-youtube.is-playing .video-background-img { opacity: 0; }
.video-placeholder.is-playing::after { background: linear-gradient(180deg, rgba(0,0,0,0.1) 0%, rgba(0,0,0,0.1) 65%, rgba(0,0,0,0.6) 100%); }

/* --- OVERLAYS EN EL VIDEO --- */
.video-stats-overlay, .video-title-overlay, .video-actions-overlay { transition: opacity 0.4s ease, transform 0.4s ease; z-index: 4; }

.video-placeholder.is-playing .video-stats-overlay,
.video-placeholder.is-playing .video-title-overlay,
.video-placeholder.is-playing .video-actions-overlay { opacity: 0; pointer-events: none; transform: translateY(-10px); }
.video-placeholder.is-playing .video-title-overlay { transform: translateY(10px); }

.video-stats-overlay { position: absolute; top: 12px; left: 12px; right: 50px; display: flex; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 5px; pointer-events: none; }
.stat-badge { background: rgba(0, 0, 0, 0.4); color: #ffffff; padding: 0 10px; height: 26px; border-radius: var(--radius-full); font-size: 0.75rem; font-weight: 500; display: inline-flex; align-items: center; gap: 5px; backdrop-filter: blur(4px); border: 1px solid rgba(255, 255, 255, 0.15); white-space: nowrap; pointer-events: auto; }

.video-actions-overlay { position: absolute; top: 12px; right: 12px; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; pointer-events: none; }
.expand-btn { background: rgba(0, 0, 0, 0.4); color: white; border: 1px solid rgba(255, 255, 255, 0.2); border-radius: var(--radius-full); height: 32px; padding: 0 10px; font-size: 0.8rem; font-family: var(--font-main); cursor: pointer; backdrop-filter: blur(4px); display: inline-flex; align-items: center; justify-content: center; transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1); white-space: nowrap; pointer-events: auto; }
.expand-btn i { min-width: 16px; text-align: center; font-size: 1rem; }
.expand-btn:hover { background: rgba(0, 0, 0, 0.7); border-color: rgba(255,255,255,0.4); }
.expand-btn.active { background: var(--primary); border-color: var(--primary); }
.expand-text { max-width: 0; opacity: 0; overflow: hidden; transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1); display: inline-block; vertical-align: middle; }
.expand-btn:hover .expand-text { max-width: 100px; opacity: 1; margin-left: 6px; }

.video-title-overlay {
    position: absolute; bottom: 12px; left: 12px; right: 12px;
    color: #ffffff; text-align: left;
    pointer-events: none; z-index: 5;
}
.video-title-overlay .song-title { 
    font-size: 1.1rem !important; /* Más pequeño */
    font-weight: 600; margin: 0; line-height: 1.2; 
    color: #ffffff !important; /* Forzamos el blanco */
    text-shadow: 0 2px 5px rgba(0,0,0,0.9), 0 0 15px rgba(0,0,0,0.8) !important;
}
.video-title-overlay .song-artist { 
    font-size: 0.85rem !important; 
    margin: 0; opacity: 0.9; 
    color: #e2e8f0 !important;
    text-shadow: 0 2px 4px rgba(0,0,0,0.9) !important;
}

/* --- CONTROLES CENTRALES DE REPRODUCCIÓN --- */
.playback-controls { position: absolute; inset: 0; z-index: 6; display: flex; align-items: center; justify-content: center; gap: 15px; pointer-events: none; transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1); }
.video-side-btn { width: 45px; height: 45px; flex-shrink: 0; padding: 0; margin: 0; background: rgba(255,255,255,0.2); border-radius: 50%; color: white; font-size: 1.1rem; display: flex; align-items: center; justify-content: center; cursor: pointer; border: 1px solid rgba(255,255,255,0.5); backdrop-filter: blur(5px); transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1); pointer-events: auto; box-sizing: border-box; }
.video-side-btn:hover { background: rgba(255,255,255,0.4); transform: scale(1.1); }
.video-side-btn.active { background: var(--warning); border-color: var(--warning); box-shadow: 0 0 10px rgba(245, 158, 11, 0.5); }

.play-btn-large { width: 60px; height: 60px; flex-shrink: 0; padding: 0; margin: 0; background: var(--primary); border-radius: 50%; color: white; font-size: 1.5rem; display: flex; align-items: center; justify-content: center; cursor: pointer; border: none; box-shadow: 0 4px 15px rgba(4, 107, 210, 0.4); transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1); pointer-events: auto; box-sizing: border-box; }
.play-btn-large:hover { transform: scale(1.1); }

.video-placeholder.is-playing .playback-controls { inset: auto 0 0 0; height: 50px; justify-content: flex-start; padding: 0 12px; gap: 10px; background: linear-gradient(to top, rgba(0,0,0,0.8), transparent); }
.video-placeholder.is-playing .play-btn-large { width: 35px; height: 35px; font-size: 1rem; }
.video-placeholder.is-playing .video-side-btn { width: 30px; height: 30px; font-size: 0.9rem; background: transparent; border-color: transparent; backdrop-filter: none; }
.video-placeholder.is-playing .video-side-btn:hover { background: rgba(255,255,255,0.2); transform: scale(1); }

#countdownOverlay { display: none; position: absolute; top: 0; left: 0; width: 100%; height: 100%; border-radius: inherit; background: rgba(0,0,0,0.7); z-index: 10; justify-content: center; align-items: center; font-size: 6rem; color: white; font-weight: bold; animation: pulse 1s infinite; }
@keyframes pulse { 0% { transform: scale(1); } 50% { transform: scale(1.1); } 100% { transform: scale(1); } }

/* --- CONTROLES Y ACORDES --- */
.rating-section { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; background: var(--bg-card); border-bottom: 1px solid var(--secondary); }
.rating-label { font-size: 0.85rem; font-weight: 600; color: var(--text-muted); }
.star-rating { display: flex; gap: 5px; cursor: pointer; align-items: center; justify-content: center; }
.star-rating i {
    color: #d1d5db; font-size: 1.3rem; 
    margin: 0 4px !important; 
    width: 24px; text-align: center; /* Forzamos su espacio para que no se monten */
    display: inline-block !important; 
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), color 0.2s;
}
.star-rating i.active { color: var(--warning) !important; /* Forzamos el color */ }
.star-rating i:hover { transform: scale(1.2); }

.mobile-controls-toggle { display: flex; justify-content: space-between; align-items: center; width: 100%; padding: 12px 16px; background: var(--bg-card); border: none; border-bottom: 1px solid var(--secondary); color: var(--text-main); font-weight: 600; font-size: 0.9rem; cursor: pointer; }
.controls-section { padding: 1.2rem; transition: max-height 0.3s ease; }
.control-group { margin-bottom: 1.2rem; }
.control-label { font-size: 0.8rem; text-transform: uppercase; color: var(--text-muted); font-weight: 600; margin-bottom: 0.5rem; display: block; letter-spacing: 0.5px; }
.control-buttons { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-tool { background: var(--bg-main); border: 1px solid var(--secondary); padding: 0.5rem 0.8rem; border-radius: var(--radius-sm); color: var(--text-main); font-family: var(--font-main); font-weight: 500; cursor: pointer; transition: all 0.2s; flex: 1; text-align: center; display: flex; align-items: center; justify-content: center; gap: 5px; font-size: 0.85rem; }
.btn-tool:hover { background: var(--secondary); }
.btn-tool.active { background: var(--primary); color: white; border-color: var(--primary); }
.stepper { display: flex; align-items: center; background: var(--bg-main); border: 1px solid var(--secondary); border-radius: var(--radius-sm); width: 100%; }
.stepper button { background: transparent; border: none; padding: 0.5rem 1rem; cursor: pointer; color: var(--text-main); font-size: 1rem; }
.stepper span { flex-grow: 1; text-align: center; font-weight: 600; }

.chords-panel { background: var(--bg-card); border-radius: var(--radius-md); border: 1px solid var(--secondary); padding: 1.5rem; box-shadow: 0 4px 6px rgba(0,0,0,0.02); min-height: 500px; min-width: 0; max-width: 100%; overflow: visible; }
.chords-header { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--secondary); padding-bottom: 1rem; margin-bottom: 1.5rem; transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1); max-height: 150px; opacity: 1; overflow: visible; }
.chords-header.is-playing { max-height: 0; padding-bottom: 0; margin-bottom: 0; border-bottom-width: 0; opacity: 0; pointer-events: none; overflow: hidden; }

.dropdown { position: relative; display: inline-block; z-index: 100; }
.dropdown-menu { display: none; position: absolute; right: 0; top: calc(100% + 5px); background: var(--bg-card); box-shadow: 0 10px 25px rgba(0,0,0,0.1); border-radius: var(--radius-sm); border: 1px solid var(--secondary); z-index: 200; min-width: 160px; overflow: hidden; }
.dropdown-menu.show { display: block; }
.dropdown-item { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 12px 15px; border: none; background: none; cursor: pointer; color: var(--text-main); font-family: var(--font-main); font-size: 0.95rem; transition: background 0.2s; }
.dropdown-item:hover { background: var(--bg-main); color: var(--primary); }
.dropdown-item.active { background: rgba(4, 107, 210, 0.1); color: var(--primary); font-weight: 600; border-left: 3px solid var(--primary); }

.chords-display { 
    display: flex; overflow-x: auto; gap: 30px; 
    padding: 70px 20px 40px 20px; /* AUMENTADO DRAMÁTICAMENTE: 70px arriba para que la etiqueta no choque al hacer zoom */
    scroll-behavior: smooth; align-items: center; width: 100%; position: relative; scrollbar-width: none; 
}        
.chords-display::-webkit-scrollbar { display: none; }
@media (min-width: 768px) { .chords-display { padding: 70px 50px 40px 50px; } }

.chord-item { 
    display: flex; flex-direction: column; align-items: center; gap: 15px; 
    position: relative; flex: 0 0 auto; 
    min-width: 155px; /* Aumentado de 135px para que respire la caja nueva */
    opacity: 0.4; transform: scale(0.9); transition: all 0.3s; 
}        
.chord-item.playing { 
    opacity: 1; 
    transform: scale(1.15); 
    z-index: 2; 
    margin: 0 15px; /* <-- Esto empuja físicamente a las tarjetas vecinas para hacer espacio */
}
.chord-item.preparing { opacity: 1; transform: scale(1.02); z-index: 1; }

.chord-name { background: var(--bg-main); border: 2px solid var(--secondary); border-radius: var(--radius-sm); width: 100%; aspect-ratio: 1; display: flex; align-items: center; justify-content: center; font-size: 1.4rem; font-weight: 600; cursor: pointer; transition: all 0.2s; position: relative; }
.chord-item.playing .chord-name { background: var(--primary); border-color: var(--primary); color: white; box-shadow: 0 4px 15px rgba(4, 107, 210, 0.4); }
.chord-item.preparing .chord-name { border: 2px dashed rgba(var(--warning-rgb), var(--prep-intensity, 0.4)); background: rgba(var(--warning-rgb), calc(var(--prep-intensity, 0.4) * 0.15)); box-shadow: 0 0 15px rgba(var(--warning-rgb), calc(var(--prep-intensity, 0.4) * 0.3)); }

.next-badge { 
    position: absolute; top: -35px; /* Un poco más arriba para separarlo del acorde */
    background: var(--warning); color: white; font-size: 0.65rem; 
    padding: 4px 10px; border-radius: 12px; font-weight: 700; opacity: 0.6; pointer-events: none; 
    white-space: nowrap; 
    z-index: 5; 
    box-shadow: 0 4px 6px rgba(0,0,0,0.1); /* Sombra para que destaque */
}        
.chord-item.playing .next-badge { opacity: 1; background: var(--primary); }

.metronome-mini { position: absolute; top: 6px; display: flex; gap: 5px; opacity: 0.5; }
.chord-item.playing .metronome-mini { opacity: 1; }
.beat-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--text-muted); transition: all 0.1s; }
.chord-item.playing .beat-dot { background: rgba(255, 255, 255, 0.4); }
.beat-dot.active { background: var(--primary); box-shadow: 0 0 6px var(--primary); transform: scale(1.5); }
.chord-item.playing .beat-dot.active { background: #ffffff; box-shadow: 0 0 8px #ffffff; }

/* Contenedor del diagrama base ampliado */
.chord-diagram { 
    width: 145px; /* ¡Mucho más ancho! */
    height: 105px; /* Ligeramente más bajo para dar el efecto panorámico */
    background: #ffffff; 
    border: 2px solid var(--secondary); border-radius: var(--radius-sm); 
    display: flex; align-items: center; justify-content: center; overflow: hidden;
    transition: all 0.3s; 
    padding: 5px; 
}

/* Estado: COMPÁS ACTUAL SONANDO */
.chord-item.playing .chord-diagram { 
    border-color: var(--primary); 
    box-shadow: 0 4px 10px rgba(4, 107, 210, 0.15);
}
.chord-item.playing .chord-diagram .finger-dot-svg { fill: var(--primary); }
/* Para cambiar el color de las teclas del piano que están presionadas */
.chord-item.playing .chord-diagram .piano-key-svg[fill="var(--primary)"] { fill: var(--primary); }

/* Estado: PREPARACIÓN (Acorde siguiente) */
.chord-item.preparing .chord-diagram { 
    border-color: rgba(var(--warning-rgb), var(--prep-intensity, 0.4)); 
}
.chord-item.preparing .chord-diagram .finger-dot-svg { 
    fill: rgba(var(--warning-rgb), var(--prep-intensity, 0.4)); 
}
.chord-item.preparing .chord-diagram .piano-key-svg[fill="var(--primary)"] { 
    fill: rgba(var(--warning-rgb), var(--prep-intensity, 0.4)); 
}

/* --- ESTILOS MODO EDICIÓN --- */
.chord-name.edit-mode {
    border: 2px dashed var(--primary);
    background: rgba(4, 107, 210, 0.05);
    cursor: default;
    aspect-ratio: unset; /* Quitamos la forma cuadrada para que quepan todos los inputs */
    min-height: 100px;
    padding: 10px 5px;
}

.beat-edit-input {
    width: 45px;
    text-align: center;
    font-size: 1rem;
    font-weight: 600;
    font-family: var(--font-main);
    border: 1px solid var(--primary);
    background: #ffffff;
    color: var(--text-main);
    border-radius: 4px;
    outline: none;
    padding: 2px;
    transition: all 0.2s;
}

.beat-edit-input:focus {
    box-shadow: 0 0 0 2px rgba(4, 107, 210, 0.3);
}

/* RESPONSIVO */
@media (max-width: 900px) and (orientation: portrait) {
    /* Ajustes del Header en Móvil */
    .logo-text { display: none; } /* Ocultamos el texto, dejamos el ícono musical */
    .back-text { display: none; } /* Ocultamos la palabra "Volver" */
    .btn-outline.back-btn { padding: 0.4rem 0.6rem; border: none; font-size: 1.2rem; }
    .btn-outline.back-btn i { margin: 0; }
    
    .mobile-search-toggle { display: block; } /* Mostramos la lupa */
    
    /* El buscador sale del header y flota debajo al hacer clic */
    .header-search-wrapper {
        position: absolute; top: 100%; left: 0; width: 100%; max-width: 100%;
        margin: 0; padding: 15px; background: rgba(255, 255, 255, 0.98);
        backdrop-filter: blur(10px); border-bottom: 1px solid var(--secondary);
        box-shadow: 0 10px 15px rgba(0,0,0,0.05);
        opacity: 0; visibility: hidden; transform: translateY(-10px);
        z-index: 99;
    }
    .header-search-wrapper.show-mobile {
        opacity: 1; visibility: visible; transform: translateY(0);
    }
    .main-workspace { display: flex; flex-direction: column; gap: 0; padding: 0; margin: 0; width: 100%; max-width: 100%; }
    .video-panel { position: sticky; top: 60px; border-radius: 0; border: none; margin: 0; width: 100%; max-width: 100%; z-index: 90; box-shadow: 0 4px 15px rgba(0,0,0,0.08); background: var(--bg-card); }
    .video-placeholder { width: 100%; max-width: none; height: auto; aspect-ratio: 16/9; border-radius: 0; }
    .video-stats-overlay { top: 10px; left: 10px; right: 45px; gap: 4px; } 
    .stat-badge { font-size: 0.6rem; padding: 0 8px; height: 22px; gap: 4px; }
    .video-actions-overlay { top: 10px; right: 10px; max-width: 50%; }
    .expand-btn { font-size: 0.75rem; padding: 0 8px; height: 28px; }
    .video-title-overlay { bottom: 10px; left: 10px; max-width: 90%; }
    .video-title-overlay .song-title { font-size: 1.1rem; }
    .video-title-overlay .song-artist { font-size: 0.8rem; }
    .video-placeholder.is-playing .playback-controls { padding: 0 10px; gap: 8px; height: 40px; }
    .video-placeholder.is-playing .play-btn-large { width: 30px; height: 30px; font-size: 0.9rem; }
    .video-placeholder.is-playing .video-side-btn { width: 28px; height: 28px; font-size: 0.8rem; }
    .controls-section { display: none; max-height: 45vh; overflow-y: auto; background: var(--bg-card); padding: 1rem; }
    .controls-section.show { display: block; }
    .chords-panel { border-radius: 0; border: none; box-shadow: none; padding: 1rem 0.5rem; min-height: calc(100vh - 60px - 220px); }
    .chords-header { padding: 0 1rem 1rem 1rem; }
    .chords-header.is-playing { padding-bottom: 0; margin-bottom: 0; max-height: 0; border-width: 0; opacity: 0; overflow: hidden; }
    /* --- AJUSTES PARA QUE QUEPAN 2 ACORDES EN MÓVIL VERTICAL --- */
    .chords-display { gap: 15px; padding: 80px 15px 30px 15px; }
    .chord-item { min-width: 140px; width: 140px; } /* Suficiente para el piano ancho */
    .chord-diagram { width: 130px; height: 90px; } /* Proporción panorámica */
    .chord-name { font-size: 1.1rem; }
}

@media (max-width: 950px) and (orientation: landscape) {
    .search-section { display: none; } 
    .main-workspace { display: grid; grid-template-columns: 45% 1fr; gap: 15px; padding: 10px; margin: 0; width: 100%; max-width: 100%; align-items: start; }
    .video-panel { position: sticky; top: 70px; border-radius: var(--radius-md); border: 1px solid var(--secondary); margin: 0; z-index: 90; box-shadow: 0 4px 15px rgba(0,0,0,0.08); background: var(--bg-card); max-height: calc(100vh - 80px); overflow-y: auto; }
    .video-panel::-webkit-scrollbar { display: none; } 
    .video-placeholder { width: 100%; max-width: none; height: auto; aspect-ratio: 16/9; border-radius: var(--radius-md) var(--radius-md) 0 0; }
    .video-stats-overlay { top: 8px; left: 8px; right: 40px; } 
    .stat-badge { font-size: 0.65rem; padding: 0 6px; height: 22px; }
    .video-actions-overlay { top: 8px; right: 8px; max-width: 50%; gap: 5px;}
    .expand-btn { font-size: 0.7rem; padding: 0 6px; height: 24px; }
    .expand-btn i { font-size: 0.8rem; min-width: 12px;}
    .video-title-overlay { bottom: 8px; left: 8px; max-width: 90%; }
    .video-title-overlay .song-title { font-size: 1rem; }
    .video-title-overlay .song-artist { font-size: 0.75rem; }
    .playback-controls { gap: 10px; }
    .play-btn-large { width: 45px; height: 45px; font-size: 1.1rem; }
    .video-side-btn { width: 35px; height: 35px; font-size: 0.9rem; }
    .video-placeholder.is-playing .playback-controls { height: 35px; padding: 0 8px; gap: 8px;}
    .video-placeholder.is-playing .play-btn-large { width: 28px; height: 28px; font-size: 0.8rem; }
    .video-placeholder.is-playing .video-side-btn { width: 24px; height: 24px; font-size: 0.75rem; }
    .mobile-controls-toggle { display: none; }
    .controls-section { display: block; padding: 1rem; }
    .chords-panel { border-radius: var(--radius-md); border: 1px solid var(--secondary); padding: 1rem; min-height: calc(100vh - 80px); }
    .chords-header { padding-bottom: 0.5rem; margin-bottom: 1rem; }
    .chords-header.is-playing { padding-bottom: 0; margin-bottom: 0; max-height: 0; border-width: 0; opacity: 0; overflow: hidden; }
    .chord-diagram { width: 115px; height: 85px; } 
    .chord-name { font-size: 1.2rem; }
    .chord-item { width: 125px; gap: 10px; min-width: 125px; }
}

/* --- NOTIFICACIÓN FLOTANTE (TOAST) --- */
#ep-toast {
    visibility: hidden; min-width: 250px; background-color: #333; color: #fff;
    text-align: center; border-radius: var(--radius-sm); padding: 16px;
    position: fixed; z-index: 9999; left: 50%; bottom: 30px; transform: translateX(-50%);
    font-family: var(--font-main); font-weight: 500; font-size: 0.95rem;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2); opacity: 0; transition: opacity 0.3s, bottom 0.3s;
}
#ep-toast.show { visibility: visible; opacity: 1; bottom: 50px; }

/* --- MODAL DE LISTAS (DISEÑO TIPO ÁLBUMES) --- */
.ep-modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(15, 23, 42, 0.7); backdrop-filter: blur(8px);
    z-index: 99999; display: flex; align-items: center; justify-content: center;
    opacity: 0; visibility: hidden; transition: all 0.3s ease;
}
.ep-modal-overlay.active { opacity: 1; visibility: visible; }
.ep-modal-content {
    background: var(--bg-card); border-radius: 20px; width: 90%; max-width: 550px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2); transform: translateY(20px);
    transition: all 0.3s ease; overflow: hidden; border: 1px solid var(--secondary);
}
.ep-modal-overlay.active .ep-modal-content { transform: translateY(0); }
.ep-modal-header {
    padding: 20px 25px; border-bottom: 1px solid var(--secondary);
    display: flex; justify-content: space-between; align-items: center;
}
.ep-modal-header h3 { margin: 0; font-size: 1.2rem; color: var(--text-main); font-weight: 600;}
.ep-modal-close {
    background: none; border: none; font-size: 1.5rem; color: var(--text-muted);
    cursor: pointer; transition: color 0.2s;
}
.ep-modal-close:hover { color: var(--error); }
.ep-modal-body { padding: 25px; max-height: 60vh; overflow-y: auto; }

.listas-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 15px;
}
.lista-item {
    aspect-ratio: 1; background: var(--bg-main); border: 2px solid var(--secondary);
    border-radius: 12px; display: flex; flex-direction: column; align-items: center;
    justify-content: center; cursor: pointer; transition: all 0.2s; text-align: center;
    padding: 10px; color: var(--text-main); font-weight: 500; font-size: 0.85rem;
}
.lista-item i { font-size: 2.2rem; margin-bottom: 8px; color: var(--text-muted); transition: all 0.2s; }
.lista-item:hover { border-color: var(--primary); transform: translateY(-3px); box-shadow: 0 5px 15px rgba(4, 107, 210, 0.15); }
.lista-item:hover i { color: var(--primary); }

/* Lista seleccionada */
.lista-item.selected { background: var(--primary); border-color: var(--primary); color: #fff; }
.lista-item.selected i { color: #fff; }

/* Crear Nueva */
.lista-item.create-new { border: 2px dashed var(--text-muted); background: transparent; }
.lista-item.create-new:hover { border-color: var(--primary); border-style: solid; background: rgba(4, 107, 210, 0.05); }

/* =======================================================
    MODO INMERSIVO (OCULTAR ELEMENTOS AL REPRODUCIR)
    Aplica solo para Móviles y Tablets (Vertical y Horizontal)
    ======================================================= */
@media (max-width: 950px) {
    
    /* 1. Preparamos los elementos para que la animación sea suave */
    header.app-header, 
    .rating-section, 
    .mobile-controls-toggle {
        transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
        overflow: hidden;
    }

    /* (Opcional) Damos un max-height base a los que no tienen height fijo para que animen bien al volver */
    .rating-section, .mobile-controls-toggle { max-height: 60px; }

    /* 2. Cuando el body tiene 'is-playing-mode', colapsamos todo a cero */
    body.is-playing-mode header.app-header {
        height: 0 !important; 
        border-bottom: none !important; 
        opacity: 0;
    }
    
    body.is-playing-mode .rating-section,
    body.is-playing-mode .mobile-controls-toggle {
        max-height: 0 !important; 
        padding-top: 0 !important; 
        padding-bottom: 0 !important; 
        border-bottom: none !important; 
        opacity: 0;
    }

    /* 3. Como el header desapareció (dejó de ocupar 60px), 
            subimos el panel del video hasta el tope (0) de la pantalla */
    body.is-playing-mode .video-panel {
        top: 0 !important;
    }
}

/* --- DESPLEGABLE DE BÚSQUEDA EN VIVO --- */
.search-dropdown {
    position: absolute; top: 100%; left: 0; width: 100%; 
    background: var(--bg-card); border-radius: var(--radius-sm); 
    box-shadow: 0 10px 25px rgba(0,0,0,0.1); border: 1px solid var(--secondary);
    margin-top: 5px; z-index: 200; overflow: hidden;
    opacity: 0; visibility: hidden; transition: all 0.2s;
    max-height: 350px; overflow-y: auto;
}
.search-dropdown.show { opacity: 1; visibility: visible; }
.search-result-item {
    display: flex; flex-direction: column; padding: 12px 15px; 
    border-bottom: 1px solid var(--secondary); text-decoration: none; 
    color: var(--text-main); transition: background 0.2s; cursor: pointer;
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--bg-main); }
.search-result-title { font-weight: 600; font-size: 0.95rem; }
.search-result-artist { font-size: 0.8rem; color: var(--text-muted); display: flex; align-items: center; justify-content: flex-start; gap: 6px; }

/* Caja cuando no hay resultados */
.search-no-results { padding: 15px; text-align: center; }
.search-no-results p { font-size: 0.9rem; color: var(--text-muted); margin-bottom: 10px; }
.btn-request-song {
    background: rgba(4, 107, 210, 0.1); color: var(--primary); 
    border: 1px dashed var(--primary); padding: 8px 15px; 
    border-radius: var(--radius-full); font-size: 0.85rem; font-weight: 600;
    cursor: pointer; width: 100%; transition: all 0.2s;
}
.btn-request-song:hover { background: var(--primary); color: #fff; }

/* --- ESTILOS PARA ENFOQUE 2: VISTA ATRIL (GRILLA INFINITA) --- */
.chords-display.modo-atril-grid {
    display: grid;
    /* Crea columnas dinámicas que nunca serán más pequeñas de 145px */
    grid-template-columns: repeat(auto-fill, minmax(145px, 1fr));
    gap: 20px;
    padding: 30px; /* Padding más uniforme */
    overflow-x: hidden;
    overflow-y: auto; /* Activamos el scroll vertical */
    align-items: start;
    justify-content: center;
    max-height: 65vh; /* Le damos un alto máximo para que scrollee internamente */
}

/* Ajustes de las tarjetas cuando están en modo grilla */
.chords-display.modo-atril-grid .chord-item {
    opacity: 0.8; /* Un poco más visibles por defecto para poder leer la partitura */
    transform: scale(1); /* Quitamos la escala pequeña para no desordenar la grilla */
    margin: 0; /* Quitamos los márgenes laterales */
    width: 100%; /* Toma el ancho exacto de su "celda" en la grilla */
    min-width: auto;
}

/* El acorde que está sonando en ese momento */
.chords-display.modo-atril-grid .chord-item.playing {
    opacity: 1;
    transform: scale(1.05); /* Escala más sutil para no chocar con las tarjetas de arriba o abajo */
    z-index: 2;
}

.chords-display.modo-atril-grid .chord-item.preparing {
    opacity: 1;
    transform: scale(1);
}

@media print {
    /* 1. Ocultar TODO lo que no sea la partitura */
    header, aside, .rating-section, .mobile-controls-toggle, 
    #playbackControls, .em-progress-container, .btn-outline, 
    #btnEditarAcordes, #btnSincronizar, .dropdown, #modal-listas,
    #videoStats, #videoActions, .next-badge, .metronome-mini {
        display: none !important;
    }

    /* 2. Resetear el layout para ocupar toda la hoja */
    body, html {
        background: white !important;
        color: black !important;
        margin: 0;
        padding: 0;
    }

    .main-workspace {
        display: block !important; /* Quitamos el grid de 2 columnas */
        margin: 0 !important;
        padding: 0 !important;
        max-width: 100% !important;
    }

    .chords-panel {
        border: none !important;
        box-shadow: none !important;
        padding: 0 !important;
        width: 100% !important;
    }

    /* 3. Mostrar el encabezado de impresión */
    .print-only-header {
        display: block !important;
        text-align: center;
    }

    /* 4. Forzar la cuadrícula de acordes (4 o 5 por fila suele ser ideal) */
    .chords-display {
        display: grid !important;
        grid-template-columns: repeat(5, 1fr) !important;
        gap: 15px !important;
        padding: 0 !important;
        overflow: visible !important;
    }

    .chord-item {
        opacity: 1 !important;
        transform: none !important;
        page-break-inside: avoid; /* Evita que un acorde se corte entre dos páginas */
        width: 100% !important;
    }

    .chord-name {
        background: #f8f9fa !important;
        color: black !important;
        border: 1px solid #ddd !important;
        -webkit-print-color-adjust: exact; /* Fuerza a que se imprima el fondo gris claro */
    }

    .chord-diagram svg {
        filter: grayscale(1); /* Ahorra tinta de color si la hubiera */
    }
}

/* --- BLINDAJE CONTRA KADENCE: TODOS LOS SLIDERS --- */
.main-workspace input[type="range"] {
    -webkit-appearance: none !important;
    appearance: none !important;
    background: linear-gradient(to right, var(--slider-color, var(--primary)) var(--slider-percent, 0%), transparent var(--slider-percent, 0%)) !important;
    height: 6px !important;
    border-radius: 3px !important;
    margin: 0 !important;
    padding: 0 !important;
    box-shadow: none !important;
    border: none !important;
}

/* La pista (hacemos su fondo transparente para que se vea el gradiente del input) */
.main-workspace input[type="range"]::-webkit-slider-runnable-track {
    width: 100%;
    height: 6px !important;
    cursor: pointer;
    background: transparent !important;
    border: none !important;
}

/* Forzar color específico para el slider de velocidad (Naranja) */
#sliderVelocidad {
    --slider-color: var(--warning) !important;
}

/* El botón circular del slider */
.main-workspace input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none !important;
    appearance: none !important;
    height: 18px !important;
    width: 18px !important;
    border-radius: 50% !important;
    background: var(--primary) !important;
    border: 3px solid #ffffff !important;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2) !important;
    cursor: pointer;
    margin-top: -6px !important; /* Centra el botón en la pista de 6px */
}

/* Cambiar el color del slider de velocidad para que destaque en naranja */
#sliderVelocidad::-webkit-slider-thumb {
    background: var(--warning) !important;
}

.timeline-marker {
    position: absolute; top: -18px; background: var(--warning); color: white; font-size: 0.65rem; font-weight: 800; width: 18px; height: 18px; display: flex; align-items: center; justify-content: center; border-radius: 4px 4px 4px 0; z-index: 4; transform: translateX(-50%);
}
.timeline-marker::after {
    content: ''; position: absolute; bottom: -4px; left: 0; border-left: 4px solid var(--warning); border-bottom: 4px solid transparent;
}

/* --- BLINDAJE: ELIMINAR ESPACIO FANTASMA SUPERIOR --- */
html, body {
    margin-top: 0 !important;
    padding-top: 0 !important;
}

header.app-header {
    top: 0 !important;
    margin-top: 0 !important;
}

/* Ocultar cualquier elemento invisible que WordPress inyecte arriba */
#wpadminbar {
    display: none !important;
}

/* --- INPUT PERSONALIZADO PARA NUEVA LISTA --- */
#input-nueva-lista {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid var(--secondary);
    border-radius: var(--radius-sm);
    font-family: var(--font-main);
    font-size: 1rem;
    outline: none;
    transition: all 0.3s;
    background: var(--bg-main);
    color: var(--text-main);
    text-align: center;
}

#input-nueva-lista:focus {
    border-color: var(--primary);
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(4, 107, 210, 0.15);
}

#input-nueva-lista::placeholder {
    color: #cbd5e1;
}

/* --- INPUT PARA COMENTARIOS DE VALORACIÓN --- */
#input-comentario {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid var(--secondary);
    border-radius: var(--radius-sm);
    font-family: var(--font-main);
    font-size: 0.95rem;
    outline: none;
    transition: all 0.3s;
    background: var(--bg-main);
    color: var(--text-main);
    resize: none; /* Evita que el usuario rompa el diseño arrastrando la esquina */
}

#input-comentario:focus {
    border-color: var(--warning);
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.15);
}

#input-comentario::placeholder {
    color: #cbd5e1;
    font-style: italic;
}

/* --- ESTILO PARA EL CANDADO DE FUNCIONES PRO --- */
.lock-pro {
    color: var(--warning);
    font-size: 0.8rem;
    margin-left: 5px;
    opacity: 0.8;
    vertical-align: text-top;
}
.btn-outline .lock-pro {
    margin-left: 0;
}

/* --- ETIQUETAS DE DIFICULTAD --- */
.stat-badge.badge-facil { background: rgba(16, 185, 129, 0.85); border-color: rgba(16, 185, 129, 0.3); }
.stat-badge.badge-medio { background: rgba(245, 158, 11, 0.85); border-color: rgba(245, 158, 11, 0.3); }
.stat-badge.badge-dificil { background: rgba(239, 68, 68, 0.85); border-color: rgba(239, 68, 68, 0.3); }

/* --- BOTÓN DE INFORMACIÓN EN EL TÍTULO --- */
.btn-info-track {
    background: rgba(255, 255, 255, 0.2); 
    border: 1px solid rgba(255, 255, 255, 0.4);
    color: #fff; 
    border-radius: 50%; 
    width: 28px; 
    height: 28px;
    display: flex; 
    align-items: center; 
    justify-content: center;
    cursor: pointer; 
    transition: all 0.3s ease; 
    pointer-events: auto; /* IMPORTANTE: Para que sea clickeable sobre el video */
    font-size: 0.9rem;
}

.btn-info-track:hover { 
    background: var(--primary); 
    border-color: var(--primary); 
    transform: scale(1.1); 
    box-shadow: 0 0 10px rgba(4, 107, 210, 0.5);
}
